/* YAP — one calm conversation surface.
 * Visual language adapted from fin123-core/src/fin123/ui/static/styles.css
 * so YAP feels like the same Reckoning Machines product family.
 * No menubar chrome, no chips, no toolbar actions — only the brand
 * lockup and the Thread.
 */

:root {
  --bg:          #EEF4F5;
  --shell-bg:    #E4F4F5;
  --bg-grid:     #FFFFFF;
  --bg-header:   #F7FAFA;
  --bg-panel:    rgba(255, 255, 255, 0.91);
  --bg-input:    #FFFFFF;
  --surface:     #FFFFFF;
  --border:      rgba(28, 40, 45, 0.14);
  --fg:          #182327;
  --fg-dim:      #607077;
  --fg-muted:    #37484F;
  --accent:      #0C8791;
  --accent-dark: #075B64;
  --accent-light:#D8F3F5;
  --accent-wash: #EEFAFA;
  --accent-glow: rgba(12, 135, 145, 0.20);
  --error:       #D6455D;
  --success:     #0F8F98;

  --font:        -apple-system, BlinkMacSystemFont, 'SF Pro Text',
                 'Segoe UI', sans-serif;

  --radius-shell: 22px;
  --radius-pill:  999px;
  --radius-soft:  8px;
  --motion-fast:  150ms ease-out;

  --thread-width: 680px;
  --menubar-h:    38px;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html, body {
  width: 100%;
  height: 100%;
  font-family: var(--font);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  background:
    radial-gradient(circle at 18% 0%, rgba(255,255,255,0.86), rgba(255,255,255,0) 30%),
    linear-gradient(135deg, #DCEBEE 0%, #F1F6F6 46%, #D7EFF0 100%);
  color: var(--fg);
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}

/* ─────────────────────────────────────────────
   App shell (institutional gradient + soft shadow)
   ───────────────────────────────────────────── */

#app {
  display: flex;
  flex-direction: column;
  width: calc(100% - 36px);
  height: calc(100% - 36px);
  margin: 18px;
  overflow: hidden;
  border: 1px solid rgba(20, 90, 95, 0.24);
  border-radius: var(--radius-shell);
  background: linear-gradient(
    90deg,
    #8DBBC1 0%,
    #D1E9EC 42%,
    #E9F7F8 100%
  );
  box-shadow:
    0 26px 68px rgba(16, 82, 90, 0.22),
    0 6px 18px rgba(31, 42, 46, 0.08),
    inset 0 1px 0 rgba(255, 255, 255, 0.86),
    inset 0 0 0 1px rgba(255, 255, 255, 0.38);
  backdrop-filter: blur(18px) saturate(118%);
}

/* ─────────────────────────────────────────────
   Menubar — brand lockup only. No chips, no buttons.
   ───────────────────────────────────────────── */

#menubar {
  display: flex;
  align-items: center;
  padding: 0 16px;
  background: rgba(255, 255, 255, 0.30);
  border-bottom: 1px solid rgba(31, 42, 46, 0.13);
  height: var(--menubar-h);
  min-height: var(--menubar-h);
  user-select: none;
  flex: 0 0 auto;
}

#brand-lockup {
  display: flex;
  flex-direction: column;
  justify-content: center;
  flex: 0 0 auto;
  line-height: 1;
}

#logo {
  display: inline-flex;
  align-items: baseline;
  gap: 0;
  font-size: 14px;
  font-weight: 650;
  color: var(--accent-dark);
  letter-spacing: 0;
}

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

.app-brand-name {
  color: inherit;
}

#runtime-identity {
  margin-top: 2px;
  color: rgba(132, 68, 76, 0.62);
  font-size: 7.5px;
  font-weight: 560;
  letter-spacing: 0;
  white-space: nowrap;
}

/* ─────────────────────────────────────────────
   Thread — the working surface inside the shell.
   ───────────────────────────────────────────── */

.thread {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overflow-anchor: auto;
  background: var(--bg-panel);
  padding: 48px 28px 44px;
}

.thread-inner {
  max-width: var(--thread-width);
  margin: 0 auto;
}

.thread-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  border-bottom: 1px solid rgba(31, 42, 46, 0.10);
  padding-bottom: 14px;
  margin-bottom: 28px;
}

.thread-title {
  font-size: 11px;
  font-weight: 560;
  color: var(--fg-dim);
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.as-of {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 11px;
  color: var(--fg-dim);
}

.as-of input[type="date"] {
  height: 24px;
  padding: 1px 9px;
  border: 1px solid rgba(31, 42, 46, 0.14);
  border-radius: var(--radius-pill);
  background: rgba(255, 255, 255, 0.48);
  color: rgba(24, 35, 39, 0.76);
  font: 500 11px var(--font);
  outline: none;
  transition: border-color var(--motion-fast), background var(--motion-fast);
}

.as-of input[type="date"]:focus {
  border-color: rgba(15, 143, 152, 0.38);
  background: rgba(255, 255, 255, 0.7);
}

/* Soften the browser's native calendar-picker icon so it sits
 * quietly with the rest of the surface. */
.as-of input[type="date"]::-webkit-calendar-picker-indicator {
  opacity: 0.4;
  cursor: pointer;
  filter: grayscale(0.6);
  transition: opacity var(--motion-fast);
}

.as-of input[type="date"]:hover::-webkit-calendar-picker-indicator,
.as-of input[type="date"]:focus::-webkit-calendar-picker-indicator {
  opacity: 0.7;
}

.link-btn {
  background: transparent;
  border: 0;
  padding: 0;
  color: var(--accent);
  font: 500 11px var(--font);
  letter-spacing: 0.01em;
  cursor: pointer;
  transition: color var(--motion-fast);
}

.link-btn:hover {
  color: var(--accent-dark);
}

/* ─── Thesis (inline, calm — no card chrome) ───
 *
 * Renders the current or as-of thesis as a quiet typographic block.
 * No border, no background, no shadow. A barely-there hairline at the
 * bottom marks the boundary to the messages or audit section below.
 */

.thesis-card {
  margin-bottom: 36px;
  padding-bottom: 24px;
  border-bottom: 1px solid rgba(31, 42, 46, 0.06);
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.thesis__as-of {
  font-size: 11.5px;
  color: var(--fg-dim);
  letter-spacing: 0.01em;
  font-style: italic;
  margin-bottom: 2px;
}

.thesis__symbol {
  font-size: 19px;
  font-weight: 500;
  color: var(--fg);
  letter-spacing: 0.005em;
  line-height: 1.2;
}

.thesis__attrs {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 8px;
  font-size: 12px;
  color: var(--fg-muted);
}

.thesis__sep {
  color: rgba(31, 42, 46, 0.28);
}

.thesis__direction {
  font-weight: 560;
  color: var(--fg);
}

.thesis__direction.direction-long {
  color: var(--accent-dark);
}

.thesis__direction.direction-short {
  color: var(--error);
}

.thesis__summary {
  font-size: 14px;
  line-height: 1.65;
  color: var(--fg);
  max-width: 60ch;
}

/* One Thread, many States. Each per-symbol thesis renders as a
 * .thesis-block inside #thesis-card; the blocks are separated only
 * by quiet spacing and a barely-visible hairline. No tabs, no
 * selector, no filter — just inline rhythm. */
.thesis-block {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.thesis-block + .thesis-block {
  margin-top: 22px;
  padding-top: 22px;
  border-top: 1px solid rgba(31, 42, 46, 0.05);
}

.thesis__actions {
  margin-top: 4px;
}

.thesis__empty {
  font-size: 13px;
  color: var(--fg-dim);
}

/* ─── Audit (inline, notebook-style — no card chrome) ───
 *
 * A two-column rhythm: date on the left, change + evidence on the
 * right. No background tint, no border, no expandable panels. The
 * section reads as an archival note, not a dashboard.
 */

.audit-panel {
  margin-bottom: 36px;
  padding-bottom: 24px;
  border-bottom: 1px solid rgba(31, 42, 46, 0.06);
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.audit__label {
  font-size: 10px;
  font-weight: 560;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--fg-dim);
}

.audit-entry {
  display: grid;
  grid-template-columns: 110px 1fr;
  gap: 18px;
  padding-top: 14px;
  border-top: 1px solid rgba(31, 42, 46, 0.05);
}

.audit-entry:first-of-type {
  padding-top: 0;
  border-top: 0;
}

.audit-entry__when {
  font-size: 11px;
  color: var(--fg-dim);
  letter-spacing: 0.02em;
  padding-top: 2px;
}

.audit-entry__main {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
}

.audit-entry__symbol {
  font-size: 14px;
  font-weight: 500;
  color: var(--fg);
  letter-spacing: 0.005em;
}

/* Diff narration: one line per change. Plain prose, no color coding —
 * the institutional voice describes the change without inflection. */
.audit-entry__changes {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.audit-entry__change {
  font-size: 13px;
  line-height: 1.65;
  color: var(--fg-muted);
  max-width: 60ch;
}

.audit-entry__summary {
  font-size: 14px;
  line-height: 1.65;
  color: var(--fg);
  max-width: 60ch;
}

.audit-entry__evidence-meta {
  font-size: 10.5px;
  color: var(--fg-dim);
  letter-spacing: 0.02em;
  margin-top: 4px;
}

.audit-entry__evidence {
  font-size: 13px;
  line-height: 1.65;
  color: var(--fg-muted);
  font-style: italic;
  border-left: 2px solid var(--accent-light);
  padding: 2px 0 2px 12px;
  margin-top: 2px;
  white-space: pre-wrap;
  max-width: 60ch;
}

/* ─── Messages ─── */

.messages {
  display: flex;
  flex-direction: column;
  gap: 28px;
  margin-bottom: 40px;
  min-height: 60px;
}

.message {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.message-meta {
  font-size: 11px;
  color: var(--fg-dim);
  letter-spacing: 0.02em;
}

.message-body {
  font-size: 14px;
  line-height: 1.65;
  color: var(--fg);
  white-space: pre-wrap;
  word-wrap: break-word;
  max-width: 60ch;
}

.empty {
  color: var(--fg-dim);
  font-size: 12.5px;
  text-align: center;
  padding: 32px 0;
  font-style: italic;
  letter-spacing: 0.01em;
}

/* ─── Composer dock ───
 *
 * The composer lives in a small dock below the scrollable thread,
 * not inside it. The dock is a flex-column sibling of `.thread`
 * inside `#app`; it stays quietly available at the bottom of the
 * shell so the user never has to scroll to write. Same surface
 * color as the thread, a barely-visible hairline at the seam — no
 * elevated toolbar, no floating chrome, no shadow.
 */

.composer-dock {
  flex: 0 0 auto;
  background: var(--bg-panel);
  border-top: 1px solid rgba(31, 42, 46, 0.06);
  padding: 18px 28px 22px;
  /* The dock's side padding matches `.thread`, so the composer
   * spans the full Thread width — edge-to-edge with the scroll
   * content above. The prose column (60ch) inside the thread keeps
   * its own constraints; only the composer widens. */
}

/* Structural wrapper inside the dock — constrained to the Thread
 * column so the composer aligns with the header above (Thread label
 * on the left, as-of date on the right). */
.composer-dock__inner {
  width: 100%;
  max-width: var(--thread-width);
  margin: 0 auto;
}

/* The composer itself is intentionally subordinate to the writing
 * surface. The Send button uses the fin123 secondary-action pattern
 * (translucent white, soft pill border, accent text on hover) rather
 * than the primary Run-button gradient. The textarea auto-grows in
 * JS, so `resize` is disabled here.
 */

.composer {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.composer textarea {
  width: 100%;
  resize: none;
  min-height: 84px;
  border: 1px solid rgba(31, 42, 46, 0.10);
  border-radius: var(--radius-soft);
  padding: 14px 16px;
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.65;
  background: rgba(255, 255, 255, 0.86);
  color: var(--fg);
  caret-color: var(--accent);
  outline: none;
  overflow: hidden;
  transition: border-color var(--motion-fast), box-shadow var(--motion-fast);
}

.composer textarea::placeholder {
  color: rgba(31, 42, 46, 0.30);
}

/* Quiet inline notice when a send fails. Plain text, no surface, no
 * color emphasis. The preserved draft is the primary signal; this
 * line is just a calm acknowledgment. */
.composer__error {
  font-size: 12px;
  color: var(--fg-muted);
  letter-spacing: 0.01em;
}

.composer textarea:focus {
  border-color: rgba(15, 143, 152, 0.34);
  box-shadow: 0 0 0 2px var(--accent-glow);
}

.composer-row {
  display: flex;
  justify-content: flex-end;
}

.composer button {
  padding: 6px 14px;
  background: rgba(255, 255, 255, 0.55);
  color: var(--accent-dark);
  border: 1px solid rgba(31, 42, 46, 0.10);
  border-radius: var(--radius-pill);
  font-family: var(--font);
  font-size: 11.5px;
  font-weight: 500;
  letter-spacing: 0.01em;
  cursor: pointer;
  transition: background var(--motion-fast),
              border-color var(--motion-fast),
              color var(--motion-fast),
              opacity var(--motion-fast);
}

.composer button:hover:not(:disabled) {
  background: rgba(255, 255, 255, 0.82);
  border-color: rgba(15, 143, 152, 0.26);
}

.composer button:disabled {
  cursor: default;
}

/* ─── Narrow viewports ───
 *
 * The same one-Thread surface, with slightly tighter shell margins,
 * smaller side padding, and a wrapping thread-header so the as-of
 * control drops below the title rather than overflowing. No
 * separate mobile UI.
 */

@media (max-width: 640px) {
  #app {
    width: calc(100% - 16px);
    height: calc(100% - 16px);
    margin: 8px;
    border-radius: 14px;
  }

  .thread {
    padding: 28px 18px 32px;
  }

  .composer-dock {
    padding: 14px 18px 18px;
  }

  .thread-header {
    flex-wrap: wrap;
    gap: 10px;
  }

  .as-of {
    flex-wrap: wrap;
  }
}
