/* ==========================================================================
   Legal Lama — "Digital Gazette" design system
   Materiality through line work and color alone: paper, ink, hairline rules,
   one seal. No gradients, no glass, no card-nesting. Bangla is a first-class
   citizen: every Latin display stack explicitly falls through to Noto Sans
   Bengali so mixed-script headings never swap to a system default.
   ========================================================================== */

:root {
  /* palette — parchment, ink, statute-green, seal-vermilion */
  --paper:    #f5f1e4;
  --paper-2:  #eee8d6;
  --sheet:    #fbf8ef;
  --ink:      #1b1e17;
  --ink-2:    #55594b;
  --ink-3:    #8a8d7c;
  --line:     #d6cdb4;
  --line-2:   #c4b992;
  --green:    #0e5a3c;
  --green-2:  #0a4630;
  --green-tint: #e3ebdd;
  --verm:     #b1402a;
  --verm-tint:#f2e2d8;
  --gold:     #977a1c;

  /* type — display serif (Latin) -> Bengali -> serif fallback;
     body/UI Bengali-first so mixed text keeps one voice */
  --font-display: "Fraunces", "Noto Sans Bengali", "Bangla MN", Georgia, serif;
  --font-body: "Noto Sans Bengali", system-ui, "Bangla MN", "Vrinda", sans-serif;
  --font-mono: "SF Mono", ui-monospace, "Noto Sans Bengali", monospace;

  --fs-display: clamp(2.6rem, 1.6rem + 4.6vw, 5rem);
  --fs-h1: clamp(1.6rem, 1.2rem + 1.6vw, 2.2rem);
  --fs-h2: 1.15rem;
  --fs-body: 0.95rem;
  --fs-small: 0.82rem;
  --fs-micro: 0.72rem;

  --pad-shell: clamp(1rem, 3vw, 2.5rem);
  --ease-snap: cubic-bezier(0.76, 0, 0.24, 1);
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font-family: var(--font-body);
  font-size: var(--fs-body);
  line-height: 1.62;
  color: var(--ink);
  background: var(--paper);
  /* faint drafting grid, 92px — line work as material, never a texture image */
  background-image:
    linear-gradient(to right, rgba(27, 29, 23, 0.035) 1px, transparent 1px),
    linear-gradient(to bottom, rgba(27, 29, 23, 0.028) 1px, transparent 1px);
  background-size: 92px 92px, 92px 92px;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
}

::selection { background: var(--green); color: var(--paper); }

a { color: var(--green); text-decoration-thickness: 1px; text-underline-offset: 2px; }
a:hover { color: var(--green-2); }

h1, h2, h3 { font-family: var(--font-display); font-weight: 560; line-height: 1.18; }
h1 { font-size: var(--fs-h1); margin: 0 0 0.6rem; letter-spacing: 0.005em; }
h2 { font-size: var(--fs-h2); margin: 0 0 0.5rem; }

button { font-family: inherit; }

/* ------------------------------------------------------------------
   Masthead — thin rules top and bottom, gazette style
   ------------------------------------------------------------------ */
.masthead {
  border-top: 3px solid var(--ink);
  border-bottom: 1px solid var(--ink);
  background: var(--sheet);
  display: flex;
  align-items: stretch;
  gap: 1rem;
  padding: 0.55rem var(--pad-shell);
  position: relative;
  z-index: 5;
}
.masthead .brand {
  display: flex; align-items: center; gap: 0.6rem;
  text-decoration: none; color: var(--ink);
}
.masthead .brand:hover { color: var(--ink); }
.masthead .brand .word {
  font-family: var(--font-display);
  font-weight: 640;
  font-size: 1.22rem;
  letter-spacing: 0.01em;
}
.masthead .brand .word .bn { color: var(--green); font-weight: 500; }
.masthead .rule-v { width: 1px; background: var(--line-2); margin: 0.2rem 0; }
.masthead .spacer { flex: 1; }
.masthead .meta {
  align-self: center;
  font-size: var(--fs-small);
  color: var(--ink-2);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 34vw;
}
.masthead nav { display: flex; align-items: center; gap: 1rem; }
.masthead nav a, .masthead button.linkish {
  font-size: var(--fs-small);
  color: var(--ink-2);
  text-decoration: none;
  background: none; border: none; cursor: pointer; padding: 0.2rem 0;
  border-bottom: 1px solid transparent;
}
.masthead nav a:hover, .masthead button.linkish:hover { color: var(--ink); border-bottom-color: var(--ink); }
.masthead #langToggle { color: var(--green); font-weight: 600; }

/* ------------------------------------------------------------------
   The seal — one stamp, drawn in SVG, vermilion, slightly rotated.
   Appears on the landing hero and on every generated document sheet.
   ------------------------------------------------------------------ */
.seal { width: 118px; height: 118px; flex: none; }
.seal svg { display: block; width: 100%; height: 100%; overflow: visible; }
.seal .ring { fill: none; stroke: var(--verm); }
.seal text { fill: var(--verm); font-family: var(--font-body); }
.seal.sm { width: 84px; height: 84px; }

/* ------------------------------------------------------------------
   Landing
   ------------------------------------------------------------------ */
.landing { flex: 1; width: 100%; max-width: 1120px; margin: 0 auto; padding: 0 var(--pad-shell) 3rem; }
.hero {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 2rem;
  align-items: start;
  padding: 3.2rem 0 2.2rem;
  border-bottom: 1px solid var(--ink);
}
.kicker {
  font-size: var(--fs-micro);
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--green);
  margin-bottom: 0.9rem;
  font-weight: 700;
}
.hero .display {
  font-family: var(--font-display);
  font-size: var(--fs-display);
  font-weight: 580;
  line-height: 1.02;
  letter-spacing: -0.01em;
  margin: 0;
}
.hero .display .bn-line {
  display: block;
  color: var(--green);
  font-weight: 500;
  font-size: 0.62em;
  margin-top: 0.35rem;
  letter-spacing: 0;
}
.hero .tagline {
  margin-top: 1.2rem;
  max-width: 34em;
  font-size: 1.02rem;
  color: var(--ink-2);
}
.hero .seal { margin-top: 0.4rem; transform: rotate(-7deg); }

.cta-row { display: flex; align-items: center; gap: 1.4rem; margin-top: 1.8rem; flex-wrap: wrap; }
.cta-row .note { font-size: var(--fs-small); color: var(--ink-3); }

/* feature register — ruled rows, no boxes */
.register { border-bottom: 1px solid var(--line-2); margin-top: 2.6rem; }
.register .row {
  display: grid;
  grid-template-columns: 3.2rem 1fr;
  gap: 1rem;
  padding: 1.15rem 0;
  border-top: 1px solid var(--line-2);
}
.register .num {
  font-family: var(--font-display);
  font-size: 1.4rem;
  color: var(--green);
  line-height: 1.2;
}
.register h2 { margin-bottom: 0.3rem; }
.register p { margin: 0; color: var(--ink-2); max-width: 44em; }

/* corpus manifest — gazette index with dotted leaders */
.manifest { margin-top: 2.8rem; }
.manifest h2 {
  font-size: var(--fs-micro);
  font-family: var(--font-body);
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--ink-2);
  border-bottom: 2px solid var(--ink);
  padding-bottom: 0.4rem;
}
.manifest ul { list-style: none; margin: 0; padding: 0; }
.manifest li {
  display: flex;
  align-items: baseline;
  gap: 0.6rem;
  padding: 0.5rem 0;
  border-bottom: 1px dotted var(--line-2);
  font-size: var(--fs-small);
}
.manifest li .t { white-space: nowrap; }
.manifest li .leader { flex: 1; border-bottom: 1px dotted var(--line-2); transform: translateY(-0.3em); }
.manifest li .v { color: var(--ink-2); white-space: nowrap; }
.manifest .foot { margin-top: 0.8rem; font-size: var(--fs-micro); color: var(--ink-3); }

/* ------------------------------------------------------------------
   Buttons & forms
   ------------------------------------------------------------------ */
.btn-primary {
  background: var(--green);
  color: var(--paper);
  border: 1px solid var(--green-2);
  padding: 0.62rem 1.5rem;
  border-radius: 3px;
  cursor: pointer;
  font-size: var(--fs-body);
  font-weight: 600;
  letter-spacing: 0.01em;
  box-shadow: 2px 2px 0 var(--ink);
  transition: transform 90ms var(--ease-snap), box-shadow 90ms var(--ease-snap);
}
.btn-primary:hover { transform: translate(-1px, -1px); box-shadow: 3px 3px 0 var(--ink); }
.btn-primary:active { transform: translate(1px, 1px); box-shadow: 1px 1px 0 var(--ink); }
.btn-primary:disabled { opacity: 0.45; cursor: default; transform: none; box-shadow: 2px 2px 0 var(--ink); }

.btn-ghost {
  background: none;
  border: 1px solid var(--ink);
  color: var(--ink);
  padding: 0.5rem 1.1rem;
  border-radius: 3px;
  cursor: pointer;
  font-size: var(--fs-small);
}
.btn-ghost:hover { background: var(--ink); color: var(--paper); }

label.f { display: block; font-size: var(--fs-small); font-weight: 600; margin: 0.9rem 0 0.3rem; }
input, select, textarea {
  width: 100%;
  font-family: inherit;
  font-size: var(--fs-body);
  color: var(--ink);
  background: var(--sheet);
  border: 1px solid var(--line-2);
  border-radius: 3px;
  padding: 0.55rem 0.65rem;
}
input:focus, select:focus, textarea:focus {
  outline: 2px solid var(--green);
  outline-offset: 0;
  border-color: var(--green);
}
.error { color: var(--verm); font-size: var(--fs-small); min-height: 1.3em; margin: 0.4rem 0 0; }

/* ------------------------------------------------------------------
   Auth pages
   ------------------------------------------------------------------ */
.auth-wrap { flex: 1; display: grid; place-items: start center; padding: 3rem var(--pad-shell); }
.auth-sheet {
  width: min(430px, 100%);
  background: var(--sheet);
  border: 1px solid var(--ink);
  box-shadow: 4px 4px 0 var(--line-2);
  padding: 1.8rem 1.8rem 1.4rem;
  position: relative;
}
.auth-sheet::before {
  content: "";
  position: absolute; inset: 0 auto 0 2.1rem;
  width: 1px; background: var(--verm-tint);
  border-left: 1px solid #e5c5b5;
  pointer-events: none;
}
.auth-sheet > * { position: relative; }
.auth-sheet h1 { padding-left: 1.2rem; }
.auth-sheet form, .auth-sheet .form-body { padding-left: 1.2rem; }
.auth-alt { margin-top: 1rem; font-size: var(--fs-small); color: var(--ink-2); }

/* ------------------------------------------------------------------
   App shell — sidebar + fluid pane
   ------------------------------------------------------------------ */
.shell { flex: 1; display: grid; grid-template-columns: 225px 1fr; min-height: 0; }
.sidebar {
  border-right: 1px solid var(--line-2);
  background: var(--paper-2);
  padding: 1.1rem 0.9rem;
  display: flex;
  flex-direction: column;
  gap: 1.1rem;
}
.sidebar .nav { display: flex; flex-direction: column; }
.sidebar .nav button {
  text-align: left;
  background: none; border: none; cursor: pointer;
  font-family: inherit; font-size: var(--fs-body);
  color: var(--ink-2);
  padding: 0.5rem 0.6rem;
  border-left: 3px solid transparent;
  display: flex; justify-content: space-between; align-items: baseline;
}
.sidebar .nav button:hover { color: var(--ink); background: rgba(27,29,23,0.04); }
.sidebar .nav button.active {
  color: var(--ink);
  border-left-color: var(--green);
  background: var(--sheet);
  font-weight: 700;
}
.sidebar .nav button .bn-sub { font-size: var(--fs-micro); color: var(--ink-3); font-weight: 400; }

.sidebar .new-conv {
  width: 100%;
  text-align: left;
  border-color: var(--line-2);
  color: var(--ink-2);
  font-size: var(--fs-small);
  padding: 0.45rem 0.6rem;
}
.sidebar .new-conv:hover { background: var(--ink); color: var(--paper); border-color: var(--ink); }

.quota-mini { border-top: 1px solid var(--line-2); padding-top: 0.9rem; }
.quota-mini .qm-row { margin-bottom: 0.75rem; }
.quota-mini .qm-label {
  display: flex; justify-content: space-between;
  font-size: var(--fs-micro); color: var(--ink-2); margin-bottom: 0.25rem;
}
.meter { height: 5px; background: var(--line); border-radius: 3px; overflow: hidden; }
.meter > span { display: block; height: 100%; background: var(--green); border-radius: 3px; transition: width 400ms var(--ease-snap); }
.meter.warn > span { background: var(--verm); }
.quota-mini .resets { font-size: var(--fs-micro); color: var(--ink-3); }

.sidebar .corpus-note {
  margin-top: auto;
  font-size: var(--fs-micro);
  color: var(--ink-3);
  border-top: 1px dashed var(--line-2);
  padding-top: 0.8rem;
  line-height: 1.55;
}

.pane { min-width: 0; display: none; flex-direction: column; }
.pane.active { display: flex; }
.pane-inner { width: 100%; max-width: 880px; margin: 0 auto; padding: 1.2rem var(--pad-shell) 1rem; }

/* ------------------------------------------------------------------
   Chat
   ------------------------------------------------------------------ */
.chat-log { display: flex; flex-direction: column; gap: 1.05rem; padding-bottom: 0.5rem; }
/* keep the last message clear of the sticky composer on scrollIntoView */
.msg { scroll-margin-bottom: 9rem; }
.chat-empty {
  border: 1px dashed var(--line-2);
  padding: 1.6rem 1.4rem;
  color: var(--ink-2);
  background: rgba(251, 248, 239, 0.6);
}
.chat-empty h2 { margin-bottom: 0.4rem; }
.chat-empty p { margin: 0.25rem 0; font-size: var(--fs-small); }

.msg { max-width: 88%; position: relative; }
.msg.user {
  align-self: flex-end;
  background: var(--green-tint);
  border: 1px solid var(--line-2);
  border-radius: 3px;
  padding: 0.55rem 0.9rem;
}
.msg .ts { display: block; font-size: var(--fs-micro); color: var(--ink-3); margin-top: 0.3rem; }

.msg.assistant {
  align-self: flex-start;
  background: var(--sheet);
  border: 1px solid var(--line-2);
  border-radius: 3px;
  padding: 0.8rem 1.1rem 0.75rem 1.3rem;
}
/* gazette margin rule — double line at the left edge of every answer */
.msg.assistant::before {
  content: "";
  position: absolute; top: 0; bottom: 0; left: 0.55rem;
  width: 3px;
  border-left: 1px solid var(--line-2);
  border-right: 1px solid var(--paper-2);
}
.msg.assistant.refused { border-color: var(--verm); }
.msg.assistant.refused::before { border-left-color: var(--verm); }

.stamp {
  display: inline-block;
  font-size: var(--fs-micro);
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  padding: 0.16rem 0.55rem 0.12rem;
  border: 1.5px solid currentColor;
  border-radius: 2px;
  transform: rotate(-1.2deg);
  margin-bottom: 0.45rem;
}
.stamp.grounded { color: var(--green); background: rgba(14, 90, 60, 0.06); }
/* "sections found but not summarised" is informational, not a failure -- amber,
   not the red used for a genuine refusal. */
.stamp.sections { color: #8a6100; background: rgba(180, 130, 20, 0.10); }
.stamp.refused { color: var(--verm); background: rgba(177, 64, 42, 0.07); }
.msg.assistant.sections { border-color: rgba(180, 130, 20, 0.35); }

.msg .body { white-space: pre-wrap; overflow-wrap: anywhere; }
.msg .body p { margin: 0.3rem 0; }

.cites { margin-top: 0.65rem; border-top: 1px dotted var(--line-2); padding-top: 0.5rem; }
.cite { font-size: var(--fs-small); margin-top: 0.35rem; display: flex; gap: 0.45rem; align-items: baseline; }
.cite .n {
  font-family: var(--font-mono); font-size: var(--fs-micro);
  color: var(--green); flex: none;
}
.cite .what { color: var(--ink-2); }
.cite a { flex: none; font-size: var(--fs-micro); }

.trace {
  margin-top: 0.55rem;
  font-family: var(--font-mono);
  font-size: var(--fs-micro);
  color: var(--ink-3);
}
.trace b { font-weight: 400; color: var(--ink-2); }

.extractive-note {
  margin-top: 0.55rem;
  font-size: var(--fs-small);
  color: var(--gold);
  border-top: 1px dashed var(--line-2);
  padding-top: 0.45rem;
}

.help-line {
  margin-top: 0.55rem;
  font-size: var(--fs-small);
  color: var(--ink-3);
  border-top: 1px dashed var(--line-2);
  padding-top: 0.45rem;
}
.help-line .lbl { color: var(--green-2); font-weight: 600; }
.help-line .help-item b { color: var(--ink-2); }

.triage-card {
  margin: 0.4rem 0 0.55rem;
  padding: 0.45rem 0.65rem;
  border-radius: 3px;
  font-size: var(--fs-small);
  border: 1px solid var(--line-2);
  background: var(--sheet);
}
.triage-card.self { border-left: 3px solid var(--green); }
.triage-card.human { border-left: 3px solid var(--gold); }
.triage-card .triage-label { font-weight: 600; color: var(--ink-2); }
.triage-card .triage-forum { color: var(--ink-3); margin-left: 0.35rem; }

.mic-btn { display: inline-flex; align-items: center; padding: 0.45rem 0.55rem; }
.mic-btn.is-listening {
  border-color: var(--verm);
  color: var(--verm);
  animation: mic-pulse 1.2s ease-in-out infinite;
}
@keyframes mic-pulse {
  50% { box-shadow: 0 0 0 6px var(--verm-tint); }
}
.read-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  margin-top: 0.5rem;
}
.read-btn.is-playing { color: var(--verm); border-color: var(--verm); }

.share-row {
  margin-top: 0.5rem;
  font-size: var(--fs-small);
  color: var(--ink-3);
}
.share-row .lbl { color: var(--green-2); font-weight: 600; margin-right: 0.3rem; }
.share-row a { color: var(--green-2); }

.stream-progress {
  border: 1px solid var(--line-2);
  background: rgba(251, 248, 239, 0.9);
  border-radius: 3px;
  padding: 0.8rem 0.9rem 0.7rem;
}
.stream-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.8rem;
  margin-bottom: 0.65rem;
}
.stream-stages {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
}
.stage-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.31rem 0.6rem;
  border-radius: 999px;
  border: 1px solid var(--line-2);
  background: var(--sheet);
  color: var(--ink-3);
  font-size: var(--fs-micro);
}
.stage-chip .chip-icon {
  width: 0.55rem;
  height: 0.55rem;
  border-radius: 50%;
  background: currentColor;
  opacity: 0.7;
}
.stage-chip .chip-spinner {
  width: 0.55rem;
  height: 0.55rem;
  border-radius: 50%;
  border: 2px solid var(--line-2);
  border-top-color: var(--green);
  animation: chip-spin 0.8s linear infinite;
}
@keyframes chip-spin {
  to { transform: rotate(360deg); }
}
.stage-chip .chip-check { display: inline-flex; color: var(--green-2); }
.stage-chip.is-active { color: var(--green); border-color: var(--green); background: var(--green-tint); }
.stage-chip.is-done { color: var(--green-2); border-color: var(--line-2); }
.stage-chip.is-pending { opacity: 0.8; }
.stream-time {
  font-size: var(--fs-micro);
  color: var(--ink-3);
  font-family: var(--font-mono);
  white-space: nowrap;
}
.stream-body {
  border-top: 1px dashed var(--line-2);
  padding-top: 0.6rem;
  min-height: 2rem;
}
.stream-content {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  color: var(--ink-2);
  font-size: var(--fs-small);
}
.stream-muted { color: var(--ink-3); }
.stream-footer { display: flex; justify-content: flex-end; margin-top: 0.55rem; }

.inline-error-card {
  border: 1px solid var(--verm);
  background: var(--verm-tint);
  border-radius: 3px;
  padding: 0.7rem 0.8rem;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  margin-top: 0.75rem;
}
.inline-error-title { font-weight: 700; color: var(--verm); font-size: var(--fs-small); }
.inline-error-body { color: var(--ink); font-size: var(--fs-small); }
.btn-ghost.small { padding: 0.3rem 0.6rem; font-size: var(--fs-micro); }

.toast {
  position: fixed;
  right: 1rem;
  bottom: 1rem;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 0.55rem;
  padding: 0.7rem 0.9rem;
  background: var(--sheet);
  border: 1px solid var(--ink);
  box-shadow: 3px 3px 0 var(--line-2);
  color: var(--ink);
  max-width: min(320px, calc(100vw - 2rem));
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 180ms ease, transform 180ms ease;
}
.toast.show { opacity: 1; transform: translateY(0); }
.toast.success { border-color: var(--green); color: var(--green-2); }
.toast.error { border-color: var(--verm); color: var(--verm); }
.toast-icon { display: inline-flex; flex-shrink: 0; }

.msg.partial .body { color: var(--ink-3); }
.stopped-caption { font-size: var(--fs-micro); color: var(--ink-3); font-style: italic; }
.stopped-line { margin-top: 0.45rem; }
.stopped-standalone { padding: 0.4rem 0.2rem; }

.chat-skeleton {
  display: flex;
  flex-direction: column;
  gap: 0.7rem;
  padding: 0.2rem 0 0.4rem;
}
.skeleton-card {
  border: 1px solid var(--line);
  background: rgba(251, 248, 239, 0.88);
  border-radius: 3px;
  height: 3.2rem;
}
.skeleton-card.short { width: 64%; height: 2.4rem; }
.field-skeleton { display: grid; gap: 0.35rem; margin-top: 0.5rem; }
.skeleton-line {
  height: 0.8rem;
  width: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--line), var(--paper-2), var(--line));
  background-size: 200% 100%;
  animation: shimmer 1.2s linear infinite;
}
.skeleton-line.short { width: 52%; }
.skeleton-row td { padding-top: 0.2rem; padding-bottom: 0.2rem; }

.pending { color: var(--ink-3); font-size: var(--fs-small); }
.pending .dots span { animation: blink 1.2s infinite; display: inline-block; }
.pending .dots span:nth-child(2) { animation-delay: 0.25s; }
.pending .dots span:nth-child(3) { animation-delay: 0.5s; }
@keyframes blink { 0%, 70%, 100% { opacity: 0.15; } 30% { opacity: 1; } }
@keyframes shimmer { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }

/* sample chips */
.samples { display: flex; flex-wrap: wrap; gap: 0.45rem; margin: 0.2rem 0 0.7rem; }
.samples .lbl { font-size: var(--fs-micro); color: var(--ink-3); align-self: center; letter-spacing: 0.08em; text-transform: uppercase; }
.chip {
  font-family: inherit;
  font-size: var(--fs-small);
  background: var(--sheet);
  border: 1px solid var(--line-2);
  border-radius: 999px;
  padding: 0.3rem 0.85rem;
  cursor: pointer;
  color: var(--ink-2);
  transition: border-color 120ms, color 120ms, transform 120ms var(--ease-snap);
}
.chip:hover { border-color: var(--green); color: var(--green-2); transform: translateY(-1px); }
.suggestions-row { display: flex; flex-wrap: wrap; align-items: center; gap: 0.45rem; margin: 0.6rem 0 0.2rem; }
.suggestions-row .lbl { font-size: var(--fs-micro); color: var(--ink-3); letter-spacing: 0.08em; text-transform: uppercase; }
.suggestion-chip { font-size: var(--fs-small); }

/* composer */
.composer {
  position: sticky;
  bottom: 2.6rem; /* clears the disclaimer footer */
  background: var(--sheet);
  border: 1px solid var(--ink);
  box-shadow: 3px 3px 0 var(--line-2);
  border-radius: 3px;
  margin-top: 1.1rem;
  display: flex;
  align-items: flex-end;
  gap: 0.7rem;
  padding: 0.65rem 0.7rem 0.65rem 0.9rem;
}
.composer textarea {
  border: none;
  background: none;
  resize: none;
  padding: 0.25rem 0;
  line-height: 1.5;
  max-height: 9.5rem;
}
.composer textarea:focus { outline: none; }
.composer .btn-primary { flex: none; }

.notice {
  border: 1px solid var(--verm);
  background: var(--verm-tint);
  color: var(--ink);
  border-radius: 3px;
  padding: 0.7rem 0.95rem;
  font-size: var(--fs-small);
  margin-top: 0.8rem;
}
.notice b { color: var(--verm); }

/* ------------------------------------------------------------------
   Documents (wizards)
   ------------------------------------------------------------------ */
.wizard-head { display: grid; grid-template-columns: 1fr; gap: 0.2rem; max-width: 560px; }
.fields-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 1.2rem; max-width: 760px; }
.fields-grid label.f { margin-top: 0.8rem; }
.wizard-actions { display: flex; align-items: center; gap: 1rem; margin-top: 1.1rem; }

.doc-sheet-wrap { margin-top: 1.6rem; }
.doc-sheet {
  position: relative;
  background: var(--sheet);
  border: 1px solid var(--ink);
  box-shadow: 5px 5px 0 var(--line-2);
  max-width: 760px;
  padding: 2.4rem 2.6rem 2rem 3rem;
}
.doc-sheet::before {
  content: "";
  position: absolute; top: 0; bottom: 0; left: 2.2rem;
  width: 1px; background: #e5c5b5;
}
.doc-sheet .seal { position: absolute; top: 1.1rem; right: 1.2rem; opacity: 0.9; transform: rotate(6deg); }
.doc-sheet pre,
.doc-sheet .doc-body {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  font-family: var(--font-body);
  font-size: var(--fs-body);
  line-height: 1.75;
  margin: 0;
  position: relative;
}
.doc-sheet .doc-h { font-family: var(--font-display); margin: 1.1rem 0 0.4rem; }
.doc-sheet h2.doc-h { font-size: 1.3rem; }
.doc-sheet h3.doc-h { font-size: 1.05rem; }
.doc-sheet hr { border: none; border-top: 1px solid var(--line-2); margin: 1rem 0; }
.doc-sheet p { margin: 0.55rem 0; }
.doc-sheet code { font-family: var(--font-mono); font-size: 0.88em; background: var(--paper-2); padding: 0 0.25em; }
.doc-toolbar { display: flex; gap: 0.6rem; margin-top: 0.9rem; }

/* ------------------------------------------------------------------
   Usage pane
   ------------------------------------------------------------------ */
.ledger { width: 100%; border-collapse: collapse; margin-top: 1rem; max-width: 720px; }
.ledger th, .ledger td { text-align: left; padding: 0.55rem 0.4rem; border-bottom: 1px solid var(--line-2); font-size: var(--fs-small); }
.ledger th {
  font-size: var(--fs-micro); letter-spacing: 0.16em; text-transform: uppercase;
  color: var(--ink-2); border-bottom: 2px solid var(--ink);
}
.ledger td.num { font-family: var(--font-mono); font-size: 0.9rem; }
.ledger .meter { width: 140px; }

/* ------------------------------------------------------------------
   Pricing page
   ------------------------------------------------------------------ */
.pricing-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1.2rem;
  margin-top: 2.2rem;
}
.pricing-card {
  background: var(--sheet);
  border: 1px solid var(--ink);
  box-shadow: 4px 4px 0 var(--line-2);
  padding: 1.5rem 1.3rem 1.3rem;
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 0.8rem;
}
.pricing-card.recommended { border-color: var(--green); box-shadow: 4px 4px 0 var(--green-tint); }
.pricing-card .badge {
  position: absolute; top: -0.55rem; right: 0.9rem;
  background: var(--green); color: var(--paper);
  font-size: var(--fs-micro); font-weight: 700;
  padding: 0.25rem 0.6rem; border-radius: 2px;
}
.pricing-card h3 { font-size: 1.25rem; margin: 0; }
.pricing-card .price { font-family: var(--font-display); font-size: 1.8rem; font-weight: 620; }
.pricing-card .price .period { font-size: var(--fs-small); color: var(--ink-3); margin-left: 0.3rem; font-weight: 500; }
.pricing-card .features { flex: 1; list-style: none; margin: 0; padding: 0; font-size: var(--fs-small); }
.pricing-card .features li { padding: 0.3rem 0; border-bottom: 1px solid var(--line-2); }
.pricing-card .features li:last-child { border-bottom: none; }
.pricing-card .btn-primary, .pricing-card .btn-ghost { width: 100%; }

.upgrade-row { display: flex; flex-wrap: wrap; gap: 0.5rem; align-items: center; margin-top: 0.6rem; }
.upgrade-row .lbl { font-size: var(--fs-small); color: var(--ink-2); }
.upgrade-row .btn-ghost { font-size: var(--fs-micro); padding: 0.3rem 0.6rem; }

/* ------------------------------------------------------------------
   Persistent P22 disclaimer — every page, sticky, not dismissible
   ------------------------------------------------------------------ */
footer.disclaimer {
  position: sticky;
  bottom: 0;
  z-index: 8;
  background: #f3ecc9;
  border-top: 1.5px solid var(--gold);
  padding: 0.5rem var(--pad-shell);
  font-size: var(--fs-micro);
  color: #5d4b0e;
  line-height: 1.5;
}
footer.disclaimer .inner { max-width: 1120px; margin: 0 auto; display: flex; gap: 0.5rem; align-items: baseline; }
footer.disclaimer .sigil { flex: none; font-weight: 700; }

/* ------------------------------------------------------------------
   Responsive & motion preferences
   ------------------------------------------------------------------ */
@media (max-width: 860px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar {
    flex-direction: row; align-items: center; gap: 0.4rem;
    border-right: none; border-bottom: 1px solid var(--line-2);
    padding: 0.5rem var(--pad-shell);
    overflow-x: auto;
  }
  .sidebar .nav { flex-direction: row; }
  .sidebar .nav button { border-left: none; border-bottom: 2px solid transparent; white-space: nowrap; }
  .sidebar .nav button.active { border-bottom-color: var(--green); }
  .quota-mini, .sidebar .corpus-note { display: none; }
  .msg { max-width: 96%; }
  .hero { grid-template-columns: 1fr; }
  .hero .seal { display: none; }
  .fields-grid { grid-template-columns: 1fr; }
  .composer { bottom: 3.4rem; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}

/* ------------------------------------------------------------------
   Feedback widget (Phase 7d)
   ------------------------------------------------------------------ */
.feedback-row {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  margin-top: 0.6rem;
  border-top: 1px dotted var(--line-2);
  padding-top: 0.45rem;
}
.feedback-row .lbl {
  font-size: var(--fs-micro);
  color: var(--ink-3);
  margin-right: 0.3rem;
}
.feedback-row button {
  background: none;
  border: 1px solid var(--line-2);
  border-radius: 3px;
  cursor: pointer;
  padding: 0.25rem 0.5rem;
  font-size: var(--fs-small);
  color: var(--ink-2);
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
}
.feedback-row button:hover { border-color: var(--green); color: var(--green-2); }
.feedback-row button.active { background: var(--green-tint); border-color: var(--green); color: var(--green-2); }
.feedback-row .comment-box {
  display: flex;
  gap: 0.4rem;
  flex: 1;
  min-width: 0;
}
.feedback-row .comment-box input {
  flex: 1;
  font-size: var(--fs-small);
  padding: 0.35rem 0.5rem;
}
.feedback-row .comment-box button {
  flex: none;
  padding: 0.35rem 0.7rem;
}
.feedback-row .thanks {
  font-size: var(--fs-micro);
  color: var(--green-2);
  margin-left: auto;
}
