/* =============================================================
 * Sub2API · Chat Terminal
 * "Editorial Mono Dark" — 衬线编辑感与等宽终端感的混合
 * ============================================================= */

:root {
  color-scheme: dark;

  /* surfaces */
  --bg: #0c0e12;
  --bg-deep: #08090c;
  --ink: #14181f;
  --ink-2: #1a1f28;
  --ink-3: #232934;

  /* paper (text) */
  --paper: #ece6d6;
  --paper-2: #b6b0a1;
  --paper-3: #76715f;
  --paper-4: #4a4639;

  /* accents */
  --accent: #d9a86c;
  --accent-deep: #b88752;
  --accent-soft: rgba(217, 168, 108, 0.10);
  --accent-line: rgba(217, 168, 108, 0.32);
  --moss: #7fa491;
  --coral: #d76b5e;

  /* rules */
  --rule: rgba(236, 230, 214, 0.06);
  --rule-2: rgba(236, 230, 214, 0.13);
  --rule-3: rgba(236, 230, 214, 0.22);

  /* type */
  --serif:
    "New York", "Iowan Old Style", "Charter", "Palatino", "Cochin",
    "Songti SC", "STSong", "Source Han Serif SC",
    "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei",
    Georgia, "Times New Roman", serif;
  --sans:
    -apple-system, BlinkMacSystemFont, "Segoe UI Variable", "Helvetica Neue",
    "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", system-ui, sans-serif;
  --mono:
    ui-monospace, "JetBrains Mono", "SF Mono", "Cascadia Code", "Menlo",
    "Monaco", "Consolas",
    "PingFang SC", "Microsoft YaHei", monospace;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
}

body {
  background: var(--bg);
  color: var(--paper);
  font-family: var(--sans);
  font-size: 14px;
  line-height: 1.55;
  letter-spacing: 0.005em;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  font-feature-settings: "ss01", "cv11";
  overflow: hidden;
  background-image:
    radial-gradient(1200px 600px at 20% -10%, rgba(217, 168, 108, 0.05), transparent 60%),
    radial-gradient(900px 500px at 110% 110%, rgba(127, 164, 145, 0.04), transparent 60%);
}

button, input, select, textarea {
  font: inherit;
  color: inherit;
}

button { cursor: pointer; }

::selection {
  background: var(--accent);
  color: var(--bg);
}

/* === GRAIN OVERLAY === */
.grain {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 100;
  opacity: 0.35;
  mix-blend-mode: overlay;
  background-image:
    radial-gradient(1px 1px at 33% 25%, rgba(255, 250, 230, 0.6) 50%, transparent 50%),
    radial-gradient(1px 1px at 65% 70%, rgba(255, 250, 230, 0.4) 50%, transparent 50%),
    radial-gradient(1px 1px at 80% 15%, rgba(255, 250, 230, 0.5) 50%, transparent 50%);
  background-size: 7px 7px, 11px 11px, 13px 13px;
}

/* === TOP HAIRLINE === */
.rule--top {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: 1px;
  background: linear-gradient(
    90deg,
    transparent 0%,
    var(--accent) 18%,
    var(--accent) 82%,
    transparent 100%
  );
  z-index: 50;
  opacity: 0.55;
}

/* === SHELL === */
.shell {
  display: grid;
  grid-template-columns: 290px minmax(0, 1fr) 360px;
  height: 100vh;
  position: relative;
}

/* === LEFT NAV === */
.nav {
  display: flex;
  flex-direction: column;
  background: var(--bg-deep);
  border-right: 1px solid var(--rule);
  padding: 28px 18px 16px;
  min-width: 0;
  min-height: 0;
  position: relative;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding-bottom: 20px;
  margin-bottom: 18px;
  border-bottom: 1px solid var(--rule);
}

.brand__mark {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  flex-shrink: 0;
  border: 1px solid var(--accent);
  background:
    linear-gradient(135deg, rgba(217, 168, 108, 0.18), rgba(217, 168, 108, 0.04));
  color: var(--accent);
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.05em;
}

.brand__mark--lg {
  width: 52px;
  height: 52px;
  font-size: 14px;
}

.brand__text { min-width: 0; }

.brand__name {
  font-family: var(--serif);
  font-size: 19px;
  font-weight: 600;
  color: var(--paper);
  letter-spacing: -0.01em;
  line-height: 1.1;
}

.brand__name sub {
  font-size: 0.65em;
  vertical-align: 0.05em;
  color: var(--accent);
  font-style: italic;
}

.brand__sub {
  margin-top: 4px;
  font-size: 10px;
  color: var(--paper-3);
  letter-spacing: 0.18em;
}

.nav__section {
  margin-bottom: 22px;
}

.nav__threads {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
  gap: 12px;
}

.nav__foot {
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px solid var(--rule);
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: var(--sans);
  font-size: 11px;
  letter-spacing: 0.04em;
  color: var(--paper-3);
}

.dot {
  width: 6px; height: 6px;
  background: var(--paper-3);
  border-radius: 50%;
  flex-shrink: 0;
  box-shadow: 0 0 0 0 currentColor;
}

.dot--ok {
  background: var(--moss);
  box-shadow: 0 0 8px rgba(127, 164, 145, 0.55);
  animation: pulse 2.4s ease-in-out infinite;
}

.dot--err {
  background: var(--coral);
}

@keyframes pulse {
  0%, 100% { opacity: 0.85; }
  50% { opacity: 0.4; }
}

/* === META LABEL === */
.meta-label {
  font-family: var(--sans);
  font-size: 11px;
  color: var(--paper-3);
  letter-spacing: 0.06em;
  font-weight: 500;
  display: block;
  margin-bottom: 10px;
}

.meta-label--row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 6px;
}

.meta-count {
  font-size: 10px;
  color: var(--paper-3);
  letter-spacing: 0.06em;
}

/* === BUTTONS === */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 0 14px;
  height: 42px;
  border: 1px solid transparent;
  background: transparent;
  font-family: var(--sans);
  font-size: 13px;
  font-weight: 500;
  letter-spacing: 0.005em;
  transition:
    background-color 0.18s ease,
    border-color 0.18s ease,
    color 0.18s ease,
    transform 0.12s ease;
  position: relative;
}

.btn--primary {
  width: 100%;
  background: var(--accent);
  color: var(--bg-deep);
  font-weight: 600;
  border-color: var(--accent);
}

.btn--primary:hover {
  background: var(--paper);
  border-color: var(--paper);
}

.btn--primary:active { transform: scale(0.985); }

.btn--inline { width: auto; padding: 0 22px; }

.btn__plus {
  font-family: var(--mono);
  font-size: 18px;
  line-height: 0.5;
  font-weight: 400;
}

.kbd {
  font-size: 10px;
  padding: 2px 5px;
  border: 1px solid currentColor;
  opacity: 0.55;
  margin-left: auto;
  letter-spacing: 0.04em;
  border-radius: 1px;
}

.btn--send {
  height: 56px;
  padding: 0 26px;
  background: var(--accent);
  color: var(--bg-deep);
  border: 1px solid var(--accent);
  font-weight: 600;
  letter-spacing: 0.01em;
  align-self: stretch;
}

.btn--send:hover {
  background: var(--paper);
  border-color: var(--paper);
}

.btn--send:hover .arrow { transform: translateX(3px); }

.btn--send:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

.btn--send:disabled:hover { background: var(--accent); }

.btn--send .arrow {
  transition: transform 0.18s ease;
  font-size: 15px;
}

/* === CHIP === */
.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 30px;
  padding: 0 14px;
  background: transparent;
  border: 1px solid var(--rule-2);
  color: var(--paper-2);
  font-family: var(--sans);
  font-size: 12px;
  letter-spacing: 0.02em;
  transition:
    color 0.16s ease,
    border-color 0.16s ease,
    background-color 0.16s ease;
}

.chip:hover {
  color: var(--paper);
  border-color: var(--rule-3);
  background: var(--ink);
}

.chip__dot {
  width: 5px; height: 5px;
  background: var(--moss);
  border-radius: 50%;
  display: inline-block;
}

.icon {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  background: transparent;
  border: 1px solid var(--rule-2);
  color: var(--paper-2);
  font-family: var(--mono);
  font-size: 18px;
  line-height: 1;
  transition: all 0.16s ease;
}

.icon:hover {
  color: var(--paper);
  border-color: var(--rule-3);
  background: var(--ink);
}

/* === SELECT === */
.select {
  position: relative;
}

.select select {
  width: 100%;
  height: 42px;
  padding: 0 36px 0 14px;
  background: var(--ink);
  border: 1px solid var(--rule-2);
  color: var(--paper);
  font-family: var(--mono);
  font-size: 12px;
  letter-spacing: 0.02em;
  appearance: none;
  -webkit-appearance: none;
  outline: none;
  cursor: pointer;
  transition: border-color 0.16s ease, box-shadow 0.16s ease;
}

.select select:focus {
  border-color: var(--accent-line);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.select__caret {
  position: absolute;
  right: 14px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--paper-3);
  pointer-events: none;
  font-size: 10px;
}

/* === THREADS LIST === */
.threads {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 2px;
  overflow-y: auto;
  overflow-x: hidden;
  margin: 0 -8px;
  padding: 4px 6px;
  min-height: 0;
  scrollbar-width: thin;
  scrollbar-color: var(--rule-2) transparent;
}

.threads::-webkit-scrollbar { width: 4px; }
.threads::-webkit-scrollbar-thumb { background: var(--rule-2); }
.threads::-webkit-scrollbar-track { background: transparent; }

.thread {
  position: relative;
  display: grid;
  grid-template-columns: 28px minmax(0, 1fr);
  gap: 8px;
  padding: 11px 30px 11px 8px;
  cursor: pointer;
  border: 1px solid transparent;
  background: transparent;
  text-align: left;
  font-family: inherit;
  color: var(--paper);
  width: 100%;
  transition:
    background-color 0.16s ease,
    border-color 0.16s ease;
}

.thread::before {
  content: '';
  position: absolute;
  left: 0;
  top: 14px;
  bottom: 14px;
  width: 2px;
  background: var(--rule-2);
  transition: background-color 0.18s ease, top 0.18s ease, bottom 0.18s ease;
}

.thread:hover {
  background: var(--ink);
}

.thread:hover::before {
  background: var(--paper-3);
}

.thread.active {
  background: var(--ink-2);
  border-color: var(--rule-2);
}

.thread.active::before {
  background: var(--accent);
  top: 8px;
  bottom: 8px;
}

.thread__num {
  font-family: var(--mono);
  font-size: 10px;
  color: var(--paper-4);
  letter-spacing: 0.06em;
  padding-top: 3px;
}

.thread.active .thread__num {
  color: var(--accent-deep);
}

.thread__main { min-width: 0; }

.thread__title {
  display: block;
  font-family: var(--serif);
  font-size: 14px;
  color: var(--paper);
  font-weight: 500;
  letter-spacing: -0.005em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.35;
}

.thread__preview {
  display: block;
  margin-top: 4px;
  font-size: 11px;
  color: var(--paper-3);
  font-family: var(--mono);
  letter-spacing: 0.01em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.thread__delete {
  position: absolute;
  right: 6px;
  top: 50%;
  transform: translateY(-50%);
  width: 22px; height: 22px;
  background: transparent;
  border: 0;
  color: var(--paper-3);
  font-family: var(--mono);
  font-size: 14px;
  line-height: 1;
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.16s ease, color 0.16s ease;
  display: grid;
  place-items: center;
}

.thread:hover .thread__delete,
.thread:focus-within .thread__delete {
  opacity: 1;
}

.thread__delete:hover {
  color: var(--coral);
}

.threads__empty,
.threads__loading {
  display: grid;
  place-items: center;
  padding: 28px 16px;
  text-align: center;
  border: 1px dashed var(--rule-2);
  margin-top: 4px;
}

.threads__empty {
  color: var(--paper-3);
  font-family: var(--serif);
  font-style: italic;
  font-size: 13px;
  line-height: 1.5;
}

.threads__empty::before {
  content: '∅';
  display: block;
  font-size: 28px;
  font-style: normal;
  margin-bottom: 8px;
  color: var(--paper-4);
  font-family: var(--serif);
}

.threads__loading {
  gap: 12px;
  font-family: var(--sans);
  font-size: 11px;
  color: var(--paper-3);
  letter-spacing: 0.04em;
}

.threads__loading-bar {
  width: 60%;
  height: 1px;
  background: var(--rule-2);
  position: relative;
  overflow: hidden;
}

.threads__loading-bar::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, transparent, var(--accent), transparent);
  animation: scan 1.4s ease-in-out infinite;
}

@keyframes scan {
  0% { transform: translateX(-100%); }
  100% { transform: translateX(100%); }
}

/* === STAGE === */
.stage {
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr) auto;
  background: var(--bg);
  min-width: 0;
  height: 100vh;
  min-height: 0;
}

.stage__head {
  padding: 28px 32px 18px;
  border-bottom: 1px solid var(--rule);
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px 16px;
  align-items: end;
}

.stage__title {
  display: flex;
  align-items: baseline;
  gap: 14px;
  min-width: 0;
}

.hash {
  font-family: var(--serif);
  font-size: 26px;
  color: var(--accent);
  font-style: italic;
  line-height: 1;
  flex-shrink: 0;
}

.stage__title h1 {
  margin: 0;
  font-family: var(--serif);
  font-size: 28px;
  font-weight: 500;
  letter-spacing: -0.018em;
  color: var(--paper);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
  line-height: 1.15;
}

.stage__status {
  grid-column: 1 / -1;
  margin: 0;
  font-family: var(--sans);
  font-size: 11.5px;
  color: var(--paper-3);
  letter-spacing: 0.02em;
}

.stage__actions {
  display: flex;
  gap: 6px;
}

/* === READOUT === */
.readout {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  padding: 14px 32px 16px;
  border-bottom: 1px solid var(--rule);
}

.stat {
  padding: 4px 18px;
  border-left: 1px solid var(--rule);
  min-width: 0;
}

.stat:first-child {
  padding-left: 0;
  border-left: 0;
}

.stat__label {
  font-family: var(--sans);
  font-size: 11px;
  color: var(--paper-3);
  letter-spacing: 0.04em;
  margin-bottom: 7px;
}

.stat__value {
  display: block;
  font-family: var(--serif);
  font-size: 19px;
  color: var(--paper);
  font-weight: 500;
  letter-spacing: -0.012em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.1;
}

.stat__value.mono {
  font-family: var(--mono);
  font-size: 16px;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0;
}

/* === CONVERSATION === */
.conversation {
  padding: 32px 32px 28px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 28px;
  min-height: 0;
  scrollbar-width: thin;
  scrollbar-color: var(--rule-2) transparent;
}

.conversation::-webkit-scrollbar { width: 6px; }
.conversation::-webkit-scrollbar-thumb { background: var(--rule-2); }
.conversation::-webkit-scrollbar-track { background: transparent; }

.empty {
  margin: auto;
  text-align: center;
  max-width: 540px;
  padding: 32px 20px;
  animation: emptyIn 0.6s ease both;
}

@keyframes emptyIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

.empty__mark {
  font-family: var(--serif);
  font-style: italic;
  font-size: 92px;
  line-height: 0.9;
  color: var(--accent);
  opacity: 0.65;
  margin-bottom: 18px;
  font-weight: 400;
}

.empty__title {
  font-family: var(--serif);
  font-size: 32px;
  font-weight: 500;
  color: var(--paper);
  letter-spacing: -0.02em;
  margin: 0 0 12px;
  line-height: 1.15;
}

.empty__subtitle {
  font-family: var(--mono);
  font-size: 10px;
  color: var(--paper-3);
  letter-spacing: 0.18em;
  text-transform: uppercase;
  margin-bottom: 22px;
}

.empty__subtitle sub {
  font-size: 0.85em;
  vertical-align: 0.05em;
  color: var(--accent);
}

.empty__copy {
  font-family: var(--serif);
  font-size: 16px;
  line-height: 1.7;
  color: var(--paper-2);
  font-style: italic;
  margin: 0;
}

.empty__hint {
  margin-top: 20px;
  display: inline-flex;
  gap: 14px;
  padding: 10px 16px;
  border: 1px solid var(--rule-2);
  font-family: var(--mono);
  font-size: 11px;
  color: var(--paper-3);
  letter-spacing: 0.06em;
}

.empty__hint kbd {
  color: var(--paper);
  border: 1px solid var(--rule-2);
  padding: 1px 6px;
  font-size: 10px;
}

/* === MESSAGE === */
.message {
  display: grid;
  grid-template-columns: 64px minmax(0, 1fr);
  gap: 18px;
  align-items: start;
  position: relative;
  animation: msgIn 0.32s ease both;
}

@keyframes msgIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

.message__role {
  text-align: right;
  font-family: var(--sans);
  font-size: 11px;
  letter-spacing: 0.04em;
  padding-top: 13px;
  white-space: nowrap;
}

.message__role span {
  display: block;
  color: var(--paper-3);
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.06em;
}

.message__role strong {
  display: block;
  margin-top: 5px;
  color: var(--paper);
  font-weight: 600;
  font-size: 12px;
}

.message.user .message__role strong { color: var(--accent); }

.message__body {
  position: relative;
  background: var(--ink);
  border: 1px solid var(--rule);
  padding: 16px 22px;
  font-family: var(--serif);
  font-size: 15.5px;
  line-height: 1.72;
  color: var(--paper);
  white-space: pre-wrap;
  word-wrap: break-word;
  overflow-wrap: break-word;
}

.message.user .message__body {
  background: transparent;
  border-color: var(--accent-line);
  border-left-width: 2px;
  border-left-color: var(--accent);
}

.message.error .message__body {
  background: rgba(215, 107, 94, 0.06);
  border-color: rgba(215, 107, 94, 0.32);
  color: var(--coral);
  font-family: var(--mono);
  font-size: 12.5px;
  line-height: 1.6;
}

.message__cursor {
  display: inline-block;
  width: 0.55em;
  height: 1.05em;
  background: var(--accent);
  vertical-align: -0.13em;
  margin-left: 2px;
  animation: blink 1s steps(2) infinite;
}

@keyframes blink {
  50% { opacity: 0; }
}

/* === COMPOSER === */
.composer {
  padding: 16px 32px 24px;
  border-top: 1px solid var(--rule);
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  background:
    linear-gradient(to top, var(--bg-deep), var(--bg) 80%);
}

.composer__inner {
  position: relative;
  display: grid;
  grid-template-columns: 22px minmax(0, 1fr);
  gap: 8px;
  align-items: start;
  background: var(--ink);
  border: 1px solid var(--rule-2);
  padding: 12px 16px;
  transition: border-color 0.18s ease, box-shadow 0.18s ease;
}

.composer__inner:focus-within {
  border-color: var(--accent-line);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.composer__prompt {
  color: var(--accent);
  font-size: 14px;
  line-height: 1.7;
  padding-top: 6px;
}

.composer textarea {
  width: 100%;
  background: transparent;
  border: 0;
  outline: none;
  color: var(--paper);
  font-family: var(--serif);
  font-size: 15.5px;
  line-height: 1.72;
  resize: none;
  min-height: 32px;
  max-height: 200px;
  padding: 6px 0;
}

.composer textarea::placeholder {
  color: var(--paper-3);
  font-style: italic;
  font-size: 14.5px;
}

/* === LEDGER (RIGHT DRAWER) === */
.ledger {
  display: flex;
  flex-direction: column;
  background: var(--bg-deep);
  border-left: 1px solid var(--rule);
  height: 100vh;
  min-height: 0;
  transition: transform 0.26s cubic-bezier(0.4, 0, 0.2, 1);
}

.ledger.closed {
  transform: translateX(100%);
}

.ledger__head {
  padding: 28px 24px 18px;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  border-bottom: 1px solid var(--rule);
  flex-shrink: 0;
}

.ledger__head h2 {
  margin: 4px 0 0;
  font-family: var(--serif);
  font-size: 22px;
  font-weight: 500;
  color: var(--paper);
  letter-spacing: -0.012em;
  line-height: 1.2;
}

.ledger__sub {
  margin: 6px 0 0;
  font-family: var(--sans);
  font-size: 11.5px;
  color: var(--paper-3);
  letter-spacing: 0.02em;
}

.ledger__totals {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  padding: 18px 24px;
  border-bottom: 1px solid var(--rule);
  gap: 14px;
  flex-shrink: 0;
}

.ledger__totals > div { min-width: 0; }

.ledger__totals strong {
  display: block;
  margin-top: 6px;
  font-size: 16px;
  color: var(--paper);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.ledger__list {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  min-height: 0;
  scrollbar-width: thin;
  scrollbar-color: var(--rule-2) transparent;
}

.ledger__list::-webkit-scrollbar { width: 4px; }
.ledger__list::-webkit-scrollbar-thumb { background: var(--rule-2); }

.ledger__row {
  padding: 14px 24px;
  border-bottom: 1px solid var(--rule);
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 4px 16px;
  align-items: baseline;
  transition: background-color 0.14s ease;
}

.ledger__row:hover { background: var(--ink); }

.ledger__row strong {
  font-family: var(--serif);
  font-size: 13px;
  color: var(--paper);
  font-weight: 500;
  letter-spacing: -0.005em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
}

.ledger__row .price {
  font-family: var(--mono);
  font-size: 13px;
  color: var(--accent);
  font-variant-numeric: tabular-nums;
  letter-spacing: 0;
}

.ledger__row time,
.ledger__row .meta {
  font-family: var(--mono);
  font-size: 10px;
  color: var(--paper-3);
  letter-spacing: 0.06em;
}

.ledger__row .meta { text-align: right; }

.ledger__empty {
  margin: 32px 24px;
  text-align: center;
  color: var(--paper-3);
  font-family: var(--serif);
  font-style: italic;
  font-size: 13px;
  padding: 24px;
  border: 1px dashed var(--rule-2);
}

/* === KEY DIALOG === */
.key-dialog {
  width: min(540px, calc(100vw - 32px));
  border: 1px solid var(--rule-3);
  background: var(--ink);
  color: var(--paper);
  padding: 0;
  margin: auto;
  box-shadow: 0 36px 90px rgba(0, 0, 0, 0.5), 0 0 0 1px var(--rule);
}

.key-dialog::backdrop {
  background: rgba(8, 9, 12, 0.84);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

.key-card {
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 32px;
}

.key-card__head {
  display: flex;
  align-items: flex-start;
  gap: 16px;
  padding-bottom: 18px;
  border-bottom: 1px solid var(--rule);
}

.key-card__head h2 {
  margin: 0;
  font-family: var(--serif);
  font-size: 24px;
  font-weight: 500;
  color: var(--paper);
  letter-spacing: -0.015em;
}

.key-card__head p {
  margin: 8px 0 0;
  font-family: var(--serif);
  font-style: italic;
  font-size: 13px;
  color: var(--paper-2);
  line-height: 1.55;
}

.key-card input {
  width: 100%;
  height: 50px;
  background: var(--bg);
  border: 1px solid var(--rule-2);
  padding: 0 14px;
  font-size: 13px;
  color: var(--paper);
  letter-spacing: 0.04em;
  outline: none;
  transition: border-color 0.16s ease, box-shadow 0.16s ease;
}

.key-card input:focus {
  border-color: var(--accent-line);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.dialog-error {
  min-height: 18px;
  font-size: 11px;
  color: var(--coral);
  letter-spacing: 0.04em;
}

.dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 4px;
}

/* === MONO UTILITY === */
.mono {
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
  letter-spacing: 0;
}

/* === RESPONSIVE === */
@media (max-width: 1180px) {
  .shell {
    grid-template-columns: 240px minmax(0, 1fr);
  }

  .ledger {
    position: fixed;
    inset: 0 0 0 auto;
    width: min(380px, 92vw);
    z-index: 20;
    box-shadow: -20px 0 60px rgba(0, 0, 0, 0.55);
  }

  .ledger.closed {
    transform: translateX(105%);
  }

  .stage__head { padding: 22px 24px 14px; }
  .readout { padding: 12px 24px 14px; }
  .conversation { padding: 24px 24px 20px; }
  .composer { padding: 14px 24px 20px; }
  .stat { padding: 4px 14px; }
}

@media (max-width: 760px) {
  body { overflow: auto; }

  .shell {
    grid-template-columns: 1fr;
    grid-template-rows: auto minmax(0, 1fr);
    height: auto;
    min-height: 100vh;
  }

  .nav {
    height: auto;
    max-height: 44vh;
    border-right: 0;
    border-bottom: 1px solid var(--rule);
    padding: 22px 18px 16px;
  }

  .stage { height: auto; min-height: 60vh; }

  .stage__head h1 { font-size: 22px; }
  .hash { font-size: 22px; }

  .readout {
    grid-template-columns: repeat(2, 1fr);
    row-gap: 14px;
    padding: 14px 20px;
  }

  .stat:nth-child(odd) {
    border-left: 0;
    padding-left: 0;
  }

  .conversation { padding: 20px; }

  .message {
    grid-template-columns: 1fr;
    gap: 8px;
  }

  .message__role {
    text-align: left;
    padding-top: 0;
    display: flex;
    gap: 8px;
    align-items: baseline;
  }

  .composer {
    padding: 12px 20px 20px;
    grid-template-columns: 1fr;
  }

  .btn--send { width: 100%; }
}
