/* RIH Script Review — dark, readable, mobile-first (Ben reviews on his phone). */
:root {
  --bg: #0f1014; --surface: #181a20; --surface-2: #20232c; --line: #2a2e38;
  --fg: #e8e9ee; --fg-dim: #a4a8b4; --fg-faint: #6c7080;
  --accent: #ff5a8a; --accent-dim: #b23a60; --good: #34c98a;
  --safe-top: env(safe-area-inset-top, 0px); --safe-bottom: env(safe-area-inset-bottom, 0px);
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--fg);
  font: 16px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; }

.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; gap: 12px;
  padding: calc(10px + var(--safe-top)) 14px 10px;
  background: rgba(15,16,20,0.92); backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}
.brand { font-weight: 700; letter-spacing: 0.3px; color: var(--accent); white-space: nowrap; }
.picker {
  margin-left: auto; max-width: 62vw; padding: 7px 10px; color: var(--fg);
  background: var(--surface-2); border: 1px solid var(--line); border-radius: 8px; font-size: 14px;
}

.doc { padding: 8px 0 40vh; }
.hint { color: var(--fg-faint); padding: 24px 16px; }

.line {
  display: flex; align-items: baseline; gap: 10px;
  padding: 3px 14px; cursor: pointer; position: relative;
  border-left: 3px solid transparent; transition: background 0.08s;
}
.line:hover { background: var(--surface); }
.line:active { background: var(--surface-2); }
.line.has-comments { border-left-color: var(--accent); background: rgba(255,90,138,0.06); }
.line.blank { min-height: 12px; }
.ln { color: var(--fg-faint); font-size: 11px; min-width: 26px; text-align: right;
  user-select: none; font-variant-numeric: tabular-nums; flex: 0 0 auto; }
.lc { white-space: pre-wrap; word-break: break-word; flex: 1 1 auto; }
.lc code { background: var(--surface-2); padding: 1px 5px; border-radius: 4px; font-size: 0.9em; }

.line.h1 .lc { font-size: 1.5em; font-weight: 800; color: #fff; }
.line.h2 .lc { font-size: 1.25em; font-weight: 700; color: #fff; }
.line.h3 .lc { font-size: 1.08em; font-weight: 700; color: var(--fg); }
.line.h4 .lc { font-weight: 700; color: var(--fg); }
.line.h1, .line.h2 { margin-top: 10px; }
.line.li .lc { color: var(--fg); }
.line.quote .lc { color: var(--fg-dim); font-style: italic; border-left: 2px solid var(--line);
  padding-left: 8px; }

.cbadge {
  position: absolute; right: 10px; top: 50%; transform: translateY(-50%);
  background: var(--accent); color: #fff; font-size: 11px; font-weight: 700;
  min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px;
  display: inline-flex; align-items: center; justify-content: center;
}

/* composer */
.composer {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  background: var(--surface); border-top: 1px solid var(--line);
  border-radius: 16px 16px 0 0; padding: 14px 14px calc(14px + var(--safe-bottom));
  box-shadow: 0 -8px 30px rgba(0,0,0,0.5);
}
.composer-head { display: flex; align-items: center; margin-bottom: 8px; }
.composer-line { font-weight: 700; color: var(--accent); }
.icon-btn { margin-left: auto; background: none; border: none; color: var(--fg-dim);
  font-size: 18px; cursor: pointer; padding: 4px 8px; }
.composer-anchor { color: var(--fg-dim); font-size: 13px; background: var(--surface-2);
  border-radius: 8px; padding: 8px 10px; margin-bottom: 8px; max-height: 80px; overflow: auto;
  white-space: pre-wrap; }
.composer-existing { max-height: 28vh; overflow: auto; margin-bottom: 8px; }
.composer-existing .ex { background: var(--surface-2); border-radius: 8px; padding: 8px 10px;
  margin-bottom: 6px; font-size: 14px; white-space: pre-wrap; }
.ex-meta { display: block; color: var(--fg-faint); font-size: 11px; margin-bottom: 3px; }
.composer-text { width: 100%; background: var(--bg); color: var(--fg);
  border: 1px solid var(--line); border-radius: 10px; padding: 10px; font: inherit;
  font-size: 16px; resize: vertical; }
.btn-primary { margin-top: 10px; width: 100%; padding: 12px; background: var(--accent);
  color: #fff; border: none; border-radius: 10px; font-weight: 700; font-size: 16px; cursor: pointer; }
.btn-primary:disabled { opacity: 0.5; }

.toast { position: fixed; left: 50%; bottom: calc(20px + var(--safe-bottom));
  transform: translateX(-50%); background: var(--good); color: #04130c; font-weight: 700;
  padding: 10px 16px; border-radius: 20px; z-index: 30; }
.fatal { padding: 28vh 24px; text-align: center; color: var(--fg-dim); }

@media (min-width: 760px) {
  .doc { max-width: 820px; margin: 0 auto; }
  .composer { left: 50%; transform: translateX(-50%); max-width: 620px;
    border-radius: 16px; bottom: 16px; }
}
