:root {
  /* Strappa-via-inspired: warm light, terracotta/orange accent */
  --bg: #f0eeea;              /* warm light page */
  --bg-landing: #e9e8e4b2;      /* landing page only — slightly deeper warm */
  --surface: #fcfbf9;         /* cards — warm near-white */
  --surface-inset: #f3f1ed;   /* inputs */
  --text: #2b2b2f;            /* charcoal */
  --muted: #6e6a63;           /* warm grey — readable on the light bg */
  --border: #e4e1dc;          /* hairline */
  --border-strong: #c9c5bd;
  --accent: #d2652f;          /* terracotta */
  --accent-hover: #c25a2a;
  --navy: #3a4880;            /* secondary brand — landing tagline */
  --accent-strong: #d2652f;   /* filled buttons */
  --accent-contrast: #ffffff;
  --soft: #f8efe9;            /* peach — hover / chip / active */
  --error: #c05a4a;
  --success: #5f7d5a;
  --radius: 8px;
  --shadow: 0 1px 3px rgb(43 43 47 / 0.06);
  --font-display: "Playfair Display", Georgia, "Times New Roman", serif;
  --font-body: Montserrat, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

* {
  box-sizing: border-box;
}

::selection {
  background: rgb(232 121 74 / 0.2);
}

body {
  margin: 0;
  font-family: var(--font-body);
  font-size: 0.85rem;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

h1 {
  font-family: var(--font-display);
  font-weight: 600;
  letter-spacing: 0.01em;
  color: var(--text);
  font-size: 1.5rem;
}

h2 {
  font-family: var(--font-display);
  font-weight: 600;
  letter-spacing: 0.01em;
  color: var(--text);
  font-size: 1.25rem;
}

::placeholder {
  color: #8f8b84;
}

.screen {
  display: none;
}

.screen.active {
  display: block;
}

/* Login */
.login-card {
  max-width: 400px;
  margin: 12vh auto 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-top: 2px solid var(--accent);
}

.login-card .muted {
  color: var(--muted);
}

.login-card input {
  background: var(--surface-inset);
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.75rem;
  box-shadow: var(--shadow);
}

/* Branded landing page (pre-auth first view) */
.landing {
  min-height: 100vh;
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: stretch;
  gap: clamp(0.75rem, 1.5vw, 1.75rem);
  padding: clamp(1.25rem, 3vh, 2.5rem) clamp(1.25rem, 2.5vw, 2.75rem);
  background: var(--bg-landing);
}

.landing-brand {
  display: flex;
  align-items: center;
}

.landing-brand .brand-logo {
  display: block;
  width: auto;
  height: auto;
  max-width: 100%;
  max-height: clamp(2.75rem, 9vh, 5rem);
}

.landing-video {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 0;
}

.landing-video video {
  width: auto;
  max-width: 100%;
  height: auto;
  max-height: 80vh;
  object-fit: contain;
  border-radius: var(--radius);
}

.landing-right {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  justify-content: space-between;
  min-height: 0;
}

.landing-slot {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  justify-content: center;
  width: 100%;
}

.landing-tagline {
  margin: 0;
  font-family: var(--font-display);
  font-size: clamp(1.1rem, 2vw, 1.5rem);
  color: var(--navy);
  text-align: right;
  text-transform: uppercase;
}

.landing-tagline span {
  display: block;
}

.landing-cta-row {
  flex: 0 0 auto;
  display: flex;
  justify-content: flex-end;
  width: 100%;
}

.landing-cta {
  margin: 0;
  background: transparent;
  color: var(--accent);
  border-color: transparent;
  font-family: var(--font-display);
  font-weight: 500;
  letter-spacing: 0.14em;
}

.landing-cta:hover {
  background: transparent;
  border-color: transparent;
  color: var(--accent-hover);
}

/* Login form materialized in the landing's right slot — seamless, no card box */
.landing-login {
  width: 100%;
  max-width: 300px;
}

.landing-login form {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 0.7rem;
}

.landing-login input {
  width: 100%;
  padding: 0.6rem 0.4rem;
  border: none;
  border-bottom: 1px solid var(--border-strong);
  border-radius: 0;
  background: var(--bg-landing);
  -webkit-appearance: none;
  appearance: none;
  -moz-appearance: none;
  color: var(--text);
  font: inherit;
  font-size: 0.9rem;
  transition: border-color 120ms ease;
}

/* Remove the browser autofill tint so the fields read as transparent/underlined.
   WebKit (Chrome/Safari) uses :-webkit-autofill; Firefox uses :-moz-autofill /
   :autofill. Cover both (and the standard property pair) so no browser paints a
   different background over the landing background. */
.landing-login input:-webkit-autofill,
.landing-login input:-webkit-autofill:hover,
.landing-login input:-webkit-autofill:focus,
.landing-login input:-moz-autofill,
.landing-login input:-moz-autofill:hover,
.landing-login input:-moz-autofill:focus,
.landing-login input:autofill,
.landing-login input:autofill:hover,
.landing-login input:autofill:focus {
  /* Hardcode the landing background so Firefox's UA `-moz-autofill-background`
     (which paints the yellow) is always overridden — no var() resolution risk. */
  background-color: #ece7e0 !important;
  background-image: none !important;
  -webkit-box-shadow: 0 0 0 1000px #ece7e0 inset !important;
  box-shadow: 0 0 0 1000px #ece7e0 inset !important;
  -moz-box-shadow: 0 0 0 1000px #ece7e0 inset !important;
  -webkit-text-fill-color: var(--text) !important;
  color: var(--text) !important;
  caret-color: var(--text);
  border-bottom-color: var(--border-strong) !important;
}

.landing-login input::placeholder {
  color: var(--muted);
}

.landing-login input:focus {
  outline: none;
  border-bottom-color: var(--accent);
  box-shadow: none;
}

.landing-login .error {
  margin: 0;
  font-size: 0.8rem;
}

.landing-login .landing-cta {
  align-self: flex-end;
}

@media (max-width: 720px) {
  .landing {
    grid-template-columns: 1fr;
    grid-template-rows: auto 1fr auto;
    align-items: center;
  }
  .landing-brand {
    justify-content: center;
    text-align: center;
  }
  .landing-video video {
    max-height: 50vh;
  }
  .landing-right {
    align-items: center;
  }
  .landing-slot,
  .landing-cta-row {
    align-items: center;
    justify-content: center;
  }
  .landing-tagline {
    text-align: center;
  }
}

label {
  display: block;
  margin: 0.75rem 0 0.25rem;
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--muted);
}

input,
textarea,
select {
  width: 100%;
  padding: 0.6rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font: inherit;
  font-size: 0.9rem;
  background: var(--surface-inset);
  color: var(--text);
  transition: border-color 120ms ease, box-shadow 120ms ease;
}

textarea {
  resize: vertical;
}

input:focus,
textarea:focus,
select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgb(232 121 74 / 0.14);
}

button {
  margin-top: 1rem;
  padding: 0.6rem 1.1rem;
  border: 1px solid var(--accent-strong);
  border-radius: var(--radius);
  background: var(--accent-strong);
  color: var(--accent-contrast);
  font: inherit;
  font-size: 0.82rem;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  cursor: pointer;
  transition: background 120ms ease, border-color 120ms ease, color 120ms ease;
}

button:hover {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
}

button:focus-visible,
a:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

button.ghost {
  background: transparent;
  color: var(--text);
  border-color: var(--border-strong);
  font-weight: 500;
  margin: 0;
}

button.ghost:hover {
  color: var(--accent);
  border-color: var(--accent);
  background: transparent;
}

button.secondary {
  background: transparent;
  color: var(--accent);
  border-color: var(--accent);
}

button.secondary:hover {
  background: var(--soft);
}

button.danger {
  color: var(--error);
  border-color: rgb(192 90 74 / 0.4);
  background: transparent;
}

button.danger:hover {
  color: var(--accent-contrast);
  background: var(--error);
  border-color: var(--error);
}

.error {
  color: var(--error);
  font-size: 0.9rem;
}

.muted {
  color: var(--muted);
}

/* App shell */
.topbar {
  display: flex;
  align-items: center;
  gap: 1.25rem;
  padding: 0.85rem 1.5rem;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.brand {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 1.05rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--accent);
  text-decoration: none;
  cursor: pointer;
}

.brand:hover {
  color: var(--accent-hover);
}

.brand.active {
  color: var(--accent-hover);
}

.brand::after {
  content: "";
  display: inline-block;
  width: 1px;
  height: 1.1em;
  margin-left: 0.5rem;
  vertical-align: -0.15em;
  background: var(--accent);
}

.nav {
  display: flex;
  gap: 0.35rem;
  flex: 1;
}

.nav a {
  color: var(--muted);
  text-decoration: none;
  padding: 0.4rem 0.75rem;
  border-radius: var(--radius);
  font-weight: 500;
  font-size: 0.78rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.nav a:hover {
  color: var(--accent);
}

.nav a.active {
  color: var(--accent);
  background: var(--soft);
}

.user-box {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  color: var(--text);
}

.topbar .ghost {
  color: var(--muted);
  border-color: var(--border-strong);
}

.topbar .ghost:hover {
  color: var(--accent);
  border-color: var(--accent);
}

.badge {
  background: var(--soft);
  color: var(--accent);
  border-radius: 999px;
  padding: 0.2rem 0.6rem;
  font-size: 0.66rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
}

.view {
  padding: 1.5rem;
  max-width: 960px;
  margin: 0 auto;
}

.view h2,
.docs-content h1 {
  color: var(--accent);
}

.view h2 {
  margin-top: 0;
}

/* Library */
.tabs {
  display: flex;
  gap: 0.35rem;
  margin-bottom: 1rem;
  flex-wrap: wrap;
}

.tab {
  margin: 0;
  background: var(--surface);
  color: var(--muted);
  border: 1px solid var(--border);
  font-weight: 500;
  font-size: 0.85rem;
  text-transform: none;
  letter-spacing: 0.01em;
}

.tab:hover {
  border-color: var(--border-strong);
  color: var(--text);
}

.tab.active {
  color: var(--accent);
  border-color: var(--accent);
  background: var(--soft);
}

.library-row {
  display: flex;
  justify-content: space-between;
  gap: 1.5rem;
  padding: 1.1rem 0;
  border-bottom: 1px solid var(--border);
}

.library-row p {
  margin: 0.2rem 0 0;
}

.row-actions {
  display: flex;
  gap: 0.4rem;
  align-items: flex-start;
}

.chips {
  display: flex;
  gap: 0.4rem;
  flex-wrap: wrap;
  margin-top: 0.5rem;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  background: var(--soft);
  color: var(--text);
  border-radius: 999px;
  padding: 0.3rem 0.7rem;
  font-size: 0.8rem;
  font-weight: 500;
  transition: background 120ms ease;
}

.chip:hover {
  background: #f0e5dc;
}

.chip-btn {
  margin: 0; /* fix: global button adds margin-top, which misaligns the icons */
  border: none;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-size: 0.72rem;
  line-height: 1;
  padding: 0.1rem 0.25rem;
  border-radius: 999px;
  opacity: 0;
  transition: opacity 120ms ease, background 120ms ease, color 120ms ease;
}

.chip:hover .chip-btn,
.chip:focus-within .chip-btn {
  opacity: 1;
}

.chip-btn.edit-sub:hover {
  color: var(--accent);
  background: rgb(210 101 47 / 0.15);
}

.chip-btn.delete-sub:hover {
  color: var(--error);
  background: rgb(192 90 74 / 0.15);
}

.chips .ghost {
  text-transform: none;
  letter-spacing: 0.02em;
  font-size: 0.78rem;
  font-weight: 500;
}

.row-actions button {
  text-transform: none;
  letter-spacing: 0.02em;
  font-size: 0.78rem;
  font-weight: 500;
}

.form {
  margin-bottom: 1rem;
}

.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0 1rem;
}

.filter-bar {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
  flex-wrap: wrap;
}

.filter-bar select {
  width: auto;
  min-width: 160px;
  padding: 0.4rem 0.6rem;
  background: var(--surface);
}

.row-editor {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
}

.row-item {
  display: grid;
  gap: 0.4rem;
  padding: 0.6rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface-inset);
}

.row-item:has(.b-text),
.row-item:has(.b-label) {
  grid-template-columns: 160px 1fr auto;
}

.row-item:has(.p-name) {
  grid-template-columns: 140px 1fr 1fr auto;
}

.row-item:has(.q-text) {
  grid-template-columns: 1fr auto;
}

.row-item button {
  align-self: start;
}

.check-row {
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
  margin: 0.35rem 0;
  font-weight: 400;
}

.check-row input {
  width: auto;
  margin-top: 0.2rem;
}

/* Idea / output cards */
.idea-row {
  margin-bottom: 0.75rem;
}

.block-card {
  margin-bottom: 0.75rem;
}

.block-card textarea {
  margin-top: 0.5rem;
}

.attach-area {
  margin-top: 0.5rem;
}

/* Docs */
.docs {
  display: grid;
  grid-template-columns: 220px 1fr;
  gap: 1.5rem;
  align-items: start;
}

.docs-toc {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  position: sticky;
  top: 1.5rem;
}

.docs-toc-item {
  color: var(--muted);
  text-decoration: none;
  padding: 0.35rem 0.6rem;
  border-radius: var(--radius);
  font-weight: 500;
  font-size: 0.9rem;
}

.docs-toc-item:hover,
.docs-toc-item.active {
  color: var(--accent);
  background: var(--soft);
}

.docs-content {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem 2rem;
  box-shadow: var(--shadow);
}

.docs-content h1 {
  font-size: 1.4rem;
  margin-top: 0;
}

.docs-content h2 {
  margin-top: 1.5rem;
}

.docs-content code {
  background: var(--soft);
  color: var(--accent);
  border-radius: 4px;
  padding: 0.1rem 0.35rem;
  font-size: 0.9em;
}

.docs-content blockquote {
  margin: 1rem 0;
  padding: 0.5rem 1rem;
  border-left: 2px solid var(--accent);
  background: var(--soft);
  border-radius: 0 8px 8px 0;
}

.docs-content a {
  color: var(--accent);
}

.docs-content ul,
.docs-content ol {
  padding-left: 1.25rem;
}

.docs-group {
  margin: 0.75rem 0 0.25rem;
  font-size: 0.66rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--accent);
}

/* Form status */
.form-status {
  margin: 0.6rem 0 0;
  font-weight: 600;
  font-size: 0.9rem;
}

.form-status.success {
  color: var(--success);
}

.form-status.error {
  color: var(--error);
}

/* Nav dropdown */
.nav-dropdown {
  position: relative;
}

.nav-dropdown-trigger {
  margin: 0;
  background: transparent;
  border: none;
  color: var(--muted);
  font: inherit;
  font-size: 0.78rem;
  font-weight: 500;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  cursor: pointer;
  padding: 0.4rem 0.75rem;
  border-radius: var(--radius);
}

.nav-dropdown-trigger:hover {
  color: var(--accent);
  background: transparent; /* stop the global button:hover terracotta fill */
}

.nav-dropdown-trigger.active {
  color: var(--accent);
  background: var(--soft);
}

.nav-dropdown-panel {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  min-width: 210px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 4px 14px rgb(43 43 47 / 0.1);
  padding: 0.35rem;
  display: none;
  flex-direction: column;
  gap: 2px;
  z-index: 20;
}

.nav-dropdown.open .nav-dropdown-panel {
  display: flex;
}

.nav-dropdown-item {
  color: var(--muted);
  text-decoration: none;
  padding: 0.5rem 0.7rem;
  border-radius: 6px;
  font-size: 0.85rem;
  font-weight: 500;
}

.nav-dropdown-item:hover {
  color: var(--accent);
}

.nav-dropdown-item.active {
  color: var(--accent);
  background: var(--soft);
}

.limits-card {
  margin-top: 0.75rem;
}

.limits-row {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.35rem 0;
  border-bottom: 1px solid var(--border);
}

.limits-row:last-child {
  border-bottom: none;
}
