/* Kestros Dashboard
   Ink-blue working surface with brass as the single structural accent (the same house
   as the Kestros memo). Gains teal, losses orange: a pair that stays distinct for
   red-green colour blindness; every change also carries a sign and an arrow. */

@font-face { font-family: "IBM Plex Sans"; src: url(fonts/ibm-plex-sans-latin-400-normal.woff2) format("woff2"); font-weight: 400; font-display: swap; }
@font-face { font-family: "IBM Plex Sans"; src: url(fonts/ibm-plex-sans-latin-500-normal.woff2) format("woff2"); font-weight: 500; font-display: swap; }
@font-face { font-family: "IBM Plex Sans"; src: url(fonts/ibm-plex-sans-latin-600-normal.woff2) format("woff2"); font-weight: 600; font-display: swap; }
@font-face { font-family: "Spectral"; src: url(fonts/spectral-latin-400-normal.woff2) format("woff2"); font-weight: 400; font-display: swap; }
@font-face { font-family: "Spectral"; src: url(fonts/spectral-latin-400-italic.woff2) format("woff2"); font-weight: 400; font-style: italic; font-display: swap; }
@font-face { font-family: "Spectral"; src: url(fonts/spectral-latin-500-normal.woff2) format("woff2"); font-weight: 500; font-display: swap; }
@font-face { font-family: "Spectral"; src: url(fonts/spectral-latin-600-normal.woff2) format("woff2"); font-weight: 600; font-display: swap; }

:root {
  --bg: #F3F5F8; --surface: #FFFFFF; --surface-2: #EEF1F5; --line: #DCE1E8; --line-strong: #C5CDD8;
  --text: #142033; --muted: #5D6779; --accent: #8C6A35; --accent-ink: #FFFFFF;
  --up: #0080A0; --down: #B8461C;
  --up-wash: rgba(0, 128, 160, .14); --down-wash: rgba(184, 70, 28, .14); --accent-wash: rgba(140, 106, 53, .12);
  --shadow: 0 1px 0 rgba(20, 32, 51, .04);
  --sans: "IBM Plex Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  --serif: "Spectral", Georgia, "Times New Roman", serif;
  --top-h: 52px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0E1726; --surface: #142033; --surface-2: #1A2840; --line: #24324A; --line-strong: #33445F;
    --text: #E6E9EF; --muted: #8C97AB; --accent: #C2A06B; --accent-ink: #0E1726;
    --up: #1FA6B8; --down: #D96A3F;
    --up-wash: rgba(31, 166, 184, .20); --down-wash: rgba(217, 106, 63, .20); --accent-wash: rgba(194, 160, 107, .14);
    --shadow: none;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0E1726; --surface: #142033; --surface-2: #1A2840; --line: #24324A; --line-strong: #33445F;
  --text: #E6E9EF; --muted: #8C97AB; --accent: #C2A06B; --accent-ink: #0E1726;
  --up: #1FA6B8; --down: #D96A3F;
  --up-wash: rgba(31, 166, 184, .20); --down-wash: rgba(217, 106, 63, .20); --accent-wash: rgba(194, 160, 107, .14);
  --shadow: none;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg); color: var(--text);
  font: 400 14px/1.45 var(--sans);
  font-feature-settings: "tnum" 1, "lnum" 1;
  -webkit-font-smoothing: antialiased;
}
button, input, select { font: inherit; color: inherit; }
a { color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 3px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
[hidden] { display: none !important; }

.up { color: var(--up); }
.down { color: var(--down); }
.flat { color: var(--muted); }
.muted { color: var(--muted); }

/* ---------- top bar ---------- */
.top {
  height: var(--top-h); display: flex; align-items: center; gap: 20px;
  padding: 0 20px; border-bottom: 1px solid var(--line); background: var(--surface);
  position: sticky; top: 0; z-index: 20;
}
.brand { font: 500 15px/1 var(--serif); letter-spacing: .34em; padding-left: .34em; color: var(--text); white-space: nowrap; }
.status { display: flex; align-items: center; gap: 16px; flex: 1; min-width: 0; font-size: 13px; color: var(--muted); }
.phase::before, .feed::before {
  content: ""; display: inline-block; width: 7px; height: 7px; border-radius: 50%;
  background: var(--line-strong); margin-right: 7px; vertical-align: 1px;
}
.phase.open::before, .feed.live::before { background: var(--up); }
.feed.sim::before { background: var(--accent); }
.feed.warn::before { background: var(--down); }
.feed-btn {
  border: 1px solid var(--accent); background: var(--accent); color: var(--accent-ink);
  padding: 5px 12px; border-radius: 4px; font-weight: 500; font-size: 13px; text-decoration: none; white-space: nowrap;
}
.clock { margin-left: auto; white-space: nowrap; }
.top-actions { display: flex; gap: 4px; }
.ghost {
  background: none; border: 1px solid transparent; border-radius: 4px; padding: 5px 9px;
  color: var(--muted); cursor: pointer; font-size: 13px;
}
.ghost:hover { color: var(--text); border-color: var(--line); }

/* ---------- pinned strip: the headline readings ---------- */
.strip {
  display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr);
  border-bottom: 1px solid var(--line); background: var(--surface);
}
.reading { padding: 14px 20px 14px; border-right: 1px solid var(--line); min-width: 0; }
.reading:last-child { border-right: none; }
.reading .nm { font-size: 12.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.reading .val { font-size: 26px; font-weight: 500; letter-spacing: -.01em; line-height: 1.15; margin-top: 2px; white-space: nowrap; transition: color .5s; }
.reading .chg { font-size: 13px; font-weight: 500; margin-top: 1px; white-space: nowrap; }
.reading .meter { margin-top: 10px; }
.reading .ends { display: flex; justify-content: space-between; gap: 8px; font-size: 11px; color: var(--muted); margin-top: 4px; white-space: nowrap; }
.strip-empty { padding: 14px 20px; color: var(--muted); }

/* day-range meter: low..high track, previous-close tick, last-price dot */
.meter { position: relative; height: 10px; min-width: 64px; }
.meter .track { position: absolute; left: 0; right: 0; top: 4px; height: 2px; border-radius: 2px; background: var(--line-strong); }
.meter .pc { position: absolute; top: 0; width: 1px; height: 10px; background: var(--muted); opacity: .7; }
.meter .dot {
  position: absolute; top: 1px; width: 8px; height: 8px; margin-left: -4px; border-radius: 50%;
  background: var(--muted); box-shadow: 0 0 0 2px var(--surface);
}
.meter .dot.up { background: var(--up); }
.meter .dot.down { background: var(--down); }

/* ---------- layout ---------- */
.views { display: none; }
.grid {
  display: grid; gap: 0;
  grid-template-columns: minmax(0, 1.6fr) minmax(360px, 1fr);
  grid-template-rows: minmax(0, 1fr) auto;
  grid-template-areas: "lists brief" "alerts brief";
  height: calc(100vh - var(--top-h) - var(--strip-h, 112px));
  height: calc(100dvh - var(--top-h) - var(--strip-h, 112px));
}
.pane { min-width: 0; min-height: 0; }
.lists { grid-area: lists; display: flex; flex-direction: column; border-right: 1px solid var(--line); }
.alerts { grid-area: alerts; border-right: 1px solid var(--line); border-top: 1px solid var(--line); max-height: 34vh; overflow: auto; }
.brief { grid-area: brief; overflow: auto; background: var(--surface); }

/* ---------- watchlists ---------- */
.tabs {
  display: flex; gap: 2px; padding: 0 12px; border-bottom: 1px solid var(--line);
  overflow-x: auto; scrollbar-width: none; flex: none;
}
.tabs::-webkit-scrollbar { display: none; }
.tab {
  background: none; border: none; border-bottom: 2px solid transparent; padding: 12px 10px 10px;
  color: var(--muted); cursor: pointer; white-space: nowrap; font-weight: 500;
}
.tab:hover { color: var(--text); }
.tab[aria-selected="true"] { color: var(--text); border-bottom-color: var(--accent); }
.tab .n { font-weight: 400; color: var(--muted); margin-left: 5px; font-size: 12px; }

.table-wrap { overflow: auto; flex: 0 1 auto; min-height: 0; }
table.wl { width: 100%; border-collapse: collapse; }
.wl th {
  position: sticky; top: 0; background: var(--bg); z-index: 1;
  text-align: right; font-weight: 500; font-size: 12px; color: var(--muted);
  padding: 9px 12px; border-bottom: 1px solid var(--line); white-space: nowrap;
}

.wl td { padding: 9px 12px; border-bottom: 1px solid var(--line); text-align: right; white-space: nowrap; vertical-align: middle; }
.wl tr:hover td { background: var(--surface-2); }
.wl .sym { font-weight: 600; letter-spacing: .01em; }
.wl .co { display: block; font-size: 12px; color: var(--muted); font-weight: 400; max-width: 260px; overflow: hidden; text-overflow: ellipsis; }
.wl .note { display: block; font: italic 13px/1.35 var(--serif); color: var(--accent); white-space: normal; max-width: 340px; margin-top: 2px; background: none; border: none; padding: 0; text-align: left; cursor: text; }
.wl .note:hover { text-decoration: underline; text-decoration-color: var(--line-strong); }
.wl .last { font-weight: 500; font-size: 15px; transition: background-color .7s ease; border-radius: 3px; }
.wl .last.flash-up { background: var(--up-wash); transition: none; }
.wl .last.flash-down { background: var(--down-wash); transition: none; }
.wl td.range { width: 120px; }
.wl td.range .meter { width: 100px; margin-left: auto; }
.wl .missing { display: block; color: var(--down); font-size: 12px; }
.wl td.x { width: 36px; padding: 0 8px 0 0; }
.rm, .row-menu, .grip {
  background: none; border: none; color: var(--muted); cursor: pointer;
  width: 28px; height: 28px; border-radius: 4px; font-size: 16px; line-height: 1; padding: 0;
}
.rm:hover { color: var(--down); background: var(--down-wash); }
.row-menu { font-size: 18px; letter-spacing: .05em; }
.row-menu:hover, .row-menu[aria-expanded="true"] { color: var(--text); background: var(--surface-2); }
.grip { cursor: grab; touch-action: none; opacity: .35; font-size: 15px; }
.wl tr:hover .grip, .grip:focus-visible { opacity: 1; }
.grip:active { cursor: grabbing; }
@media (hover: none) { .grip { opacity: .6; } }
.wl th.grip-h, .wl td.grip-cell { width: 34px; padding: 0 0 0 10px !important; text-align: left; }
.wl td.grip-cell + td, .wl th.grip-h + th { padding-left: 4px !important; text-align: left; }
.wl tbody.sorting tr { transition: transform .15s ease; }
.wl tbody.sorting tr.dragging { transition: none; position: relative; z-index: 3; box-shadow: 0 6px 18px rgba(0,0,0,.25); }
.wl tr.dragging td { background: var(--surface-2); }
.pin-mark { color: var(--accent); font-size: 10px; vertical-align: 2px; }
.empty { padding: 28px 20px; color: var(--muted); max-width: 52ch; }
.alerts .empty { padding: 0 20px 18px; }
.empty b { color: var(--text); font-weight: 500; }

.add { position: relative; display: flex; gap: 8px; padding: 10px 20px; border-top: 1px solid var(--line); flex: none; }
.add input {
  flex: 1; min-width: 0; background: var(--surface); border: 1px solid var(--line); border-radius: 4px; padding: 7px 36px 7px 10px;
}
.add input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-wash); }
.add-kbd { position: absolute; right: 30px; top: 50%; transform: translateY(-50%); font: 12px var(--sans); color: var(--muted); border: 1px solid var(--line-strong); border-radius: 3px; padding: 0 6px; pointer-events: none; }
.add input:focus ~ .add-kbd, .add input:not(:placeholder-shown) ~ .add-kbd { display: none; }
.add input::placeholder { color: var(--muted); }
.suggest {
  position: absolute; left: 20px; right: 20px; bottom: calc(100% - 4px); z-index: 5;
  background: var(--surface); border: 1px solid var(--line-strong); border-radius: 6px; box-shadow: 0 8px 24px rgba(0,0,0,.18);
  list-style: none; margin: 0; padding: 4px; max-height: 280px; overflow: auto;
}
.suggest li { padding: 7px 10px; border-radius: 4px; cursor: pointer; display: flex; gap: 10px; align-items: baseline; }
.suggest li[aria-selected="true"], .suggest li:hover { background: var(--accent-wash); }
.suggest .s { font-weight: 600; }
.suggest .c { color: var(--muted); font-size: 12.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- section headings inside panes ---------- */
.pane-head { display: flex; align-items: baseline; gap: 12px; padding: 16px 20px 10px; }
.pane-head h2 { margin: 0; font: 500 19px/1.2 var(--serif); }
.pane-head .aside { margin-left: auto; font-size: 12.5px; color: var(--muted); }

/* ---------- alerts ---------- */
.alert-list { list-style: none; margin: 0; padding: 0 0 8px; }
.alert-list li { display: flex; align-items: center; gap: 12px; padding: 8px 20px; border-top: 1px solid var(--line); }
.alert-list .what { flex: 1; min-width: 0; }
.alert-list .what b { font-weight: 600; }
.alert-list .sub { display: block; font-size: 12.5px; color: var(--muted); }
.alert-list li.done .what { color: var(--muted); }
.alert-list .rm { opacity: .7; }
.notify-btn { border: 1px solid var(--line); background: none; border-radius: 4px; padding: 4px 9px; color: var(--muted); cursor: pointer; font-size: 12.5px; }

/* ---------- The Overnight ---------- */
.brief .pane-head { position: sticky; top: 0; background: var(--surface); z-index: 2; border-bottom: 1px solid var(--line); padding-bottom: 12px; }
.brief select {
  margin-left: auto; background: var(--surface); border: 1px solid var(--line); border-radius: 4px; padding: 4px 8px; font-size: 13px; max-width: 170px;
}
.ed { padding: 16px 20px 32px; }
.ed-re { font: italic 17px/1.45 var(--serif); margin: 0 0 4px; }
.ed-window { font-size: 12.5px; color: var(--muted); margin: 0 0 16px; }
.tiles { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0; border-top: 1px solid var(--line); margin-bottom: 22px; }
.tile { padding: 9px 0 9px; border-bottom: 1px solid var(--line); display: grid; grid-template-columns: 1fr auto; column-gap: 8px; align-items: baseline; }
.tile:nth-child(odd) { padding-right: 14px; border-right: 1px solid var(--line); }
.tile:nth-child(even) { padding-left: 14px; }
.tile .tl { font-size: 12.5px; color: var(--muted); }
.tile .tv { font-weight: 500; text-align: right; }
.tile .tc { grid-column: 1 / -1; font-size: 12.5px; font-weight: 500; text-align: right; }
.tile .tn { grid-column: 1 / -1; font-size: 11.5px; color: var(--muted); text-align: right; }
.ed h3 { font: 500 15px/1.3 var(--sans); margin: 0 0 8px; color: var(--muted); }
.five { list-style: none; margin: 0 0 22px; padding: 0; counter-reset: five; }
.five li { counter-increment: five; display: grid; grid-template-columns: 26px 1fr; padding: 12px 0; border-top: 1px solid var(--line); }
.five li::before { content: counter(five); font: 500 20px/1.1 var(--serif); color: var(--accent); }
.five h4, .item h4 { margin: 0 0 4px; font: 600 16px/1.3 var(--serif); }
.five p, .item p { margin: 0; font: 400 15px/1.6 var(--serif); }
.src { font-size: 12px; color: var(--muted); margin-top: 5px; }
.src a { color: var(--muted); text-decoration-color: var(--line-strong); text-underline-offset: 2px; }
.src a:hover { color: var(--text); }
.why { margin-top: 8px; padding-left: 10px; border-left: 2px solid var(--accent); font-size: 13.5px; line-height: 1.5; }
.why b { font-weight: 600; }
.next { margin: 0 0 22px; padding: 12px 14px; background: var(--surface-2); border-radius: 6px; }
.next table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.next td { padding: 5px 0; vertical-align: top; border-top: 1px solid var(--line); }
.next tr:first-child td { border-top: none; }
.next td.when { width: 92px; font-weight: 500; white-space: nowrap; padding-right: 10px; }
details.sec { border-top: 1px solid var(--line); }
details.sec > summary { cursor: pointer; padding: 12px 0; font: 500 16px/1.3 var(--serif); list-style: none; display: flex; align-items: baseline; gap: 8px; }
details.sec > summary::-webkit-details-marker { display: none; }
details.sec > summary::after { content: "+"; margin-left: auto; color: var(--muted); font-family: var(--sans); }
details.sec[open] > summary::after { content: "−"; }
details.sec > summary .n { font: 400 12.5px var(--sans); color: var(--muted); }
.item { padding: 0 0 14px; margin-bottom: 14px; border-bottom: 1px solid var(--line); }
.item:last-child { border-bottom: none; margin-bottom: 4px; }
.steel ul { margin: 0 0 8px; padding-left: 18px; font: 15px/1.6 var(--serif); }
.steel .read { font-size: 13.5px; padding-left: 10px; border-left: 2px solid var(--accent); }
table.rows { width: 100%; border-collapse: collapse; font-size: 13px; margin-bottom: 8px; }
table.rows th { text-align: left; font-weight: 500; color: var(--muted); padding: 4px 8px 4px 0; border-bottom: 1px solid var(--line-strong); }
table.rows td { padding: 6px 8px 6px 0; border-bottom: 1px solid var(--line); vertical-align: top; }
.ed-actions { display: flex; gap: 10px; margin-top: 20px; }
.btn {
  border: 1px solid var(--line-strong); background: var(--surface); border-radius: 4px; padding: 7px 14px;
  cursor: pointer; font-weight: 500; text-decoration: none; display: inline-block;
}
.btn:hover { border-color: var(--accent); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.ed-empty { padding: 24px 20px; color: var(--muted); max-width: 46ch; }

dialog.reader { width: min(980px, 96vw); height: 92vh; padding: 0; border: 1px solid var(--line-strong); border-radius: 8px; background: var(--surface); color: var(--text); }
dialog.reader::backdrop { background: rgba(8, 14, 24, .6); }
.reader-bar { display: flex; align-items: center; gap: 10px; padding: 8px 12px; border-bottom: 1px solid var(--line); }
.reader-bar .t { font: 500 15px var(--serif); }
.reader-bar .ghost:last-child { margin-left: auto; }
dialog.reader iframe { width: 100%; height: calc(100% - 46px); border: 0; background: #EFEDE8; }

/* ---------- toasts ---------- */
.toasts { position: fixed; right: 20px; bottom: 20px; z-index: 40; display: flex; flex-direction: column; gap: 8px; max-width: min(380px, calc(100vw - 40px)); }
.toast { display: flex; align-items: baseline; gap: 14px; background: var(--surface); border: 1px solid var(--line-strong); border-left: 3px solid var(--accent); border-radius: 4px; padding: 10px 14px; box-shadow: 0 8px 24px rgba(0,0,0,.2); font-size: 14px; }
.toast span { flex: 1; }
.toast.alert { border-left-color: var(--up); }
.toast.bad { border-left-color: var(--down); }

/* ---------- narrower screens ---------- */
@media (max-width: 1100px) {
  .grid { grid-template-columns: minmax(0, 1fr) minmax(320px, .9fr); }
  .wl .vol { display: none; }
}
@media (max-width: 820px) {
  :root { --top-h: 48px; }
  .top { padding: 0 14px; gap: 12px; }
  .brand { font-size: 13px; }
  .clock, .phase, .top-actions { display: none; }
  .status { justify-content: flex-end; }
  .strip { grid-auto-columns: minmax(150px, 46%); overflow-x: auto; scroll-snap-type: x mandatory; scrollbar-width: none; }
  .strip::-webkit-scrollbar { display: none; }
  .reading { scroll-snap-align: start; padding: 10px 14px; }
  .reading .val { font-size: 21px; }
  .reading .ends { font-size: 10.5px; }
  .views { display: flex; position: sticky; top: var(--top-h); z-index: 15; background: var(--surface); border-bottom: 1px solid var(--line); padding: 0 8px; }
  .views button { flex: 1; background: none; border: none; border-bottom: 2px solid transparent; padding: 11px 6px 9px; color: var(--muted); font-weight: 500; cursor: pointer; }
  .views button[aria-selected="true"] { color: var(--text); border-bottom-color: var(--accent); }
  .grid { display: block; height: auto; padding-bottom: 32px; }
  .pane { display: none; border: none !important; max-height: none !important; overflow: visible !important; }
  body[data-view="lists"] .lists, body[data-view="brief"] .brief, body[data-view="alerts"] .alerts { display: block; }
  .table-wrap { overflow: visible; }
  .wl th { top: calc(var(--top-h) + 43px); }
  .wl .range, .wl th.range, .wl .chgcol { display: none; }
  .lists, .strip { overflow-x: clip; }
  .wl .x { width: 32px; padding-right: 4px !important; }
  .wl th:first-child, .wl td:first-child { padding-left: 14px; }
  .wl td, .wl th { padding-left: 8px; padding-right: 8px; }
  .wl .co { max-width: 150px; }
  .add { padding: 10px 14px; }
  .brief .pane-head { top: calc(var(--top-h) + 43px); }
  .pane-head, .ed { padding-left: 14px; padding-right: 14px; }
  .alert-list li { padding: 8px 14px; }
  .toasts { right: 10px; left: 10px; bottom: calc(12px + env(safe-area-inset-bottom)); max-width: none; }
  .add-kbd { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; scroll-behavior: auto !important; }
}

/* ---------- list management ---------- */
.tab.new { color: var(--muted); font-weight: 400; }
.tab.new:hover { color: var(--accent); }
.tab-menu { position: sticky; right: 0; margin-left: auto; background: var(--bg); background: none; border: none; color: var(--muted); cursor: pointer; font-size: 18px; padding: 0 8px; border-radius: 4px; flex: none; }
.tab-menu:hover, .tab-menu[aria-expanded="true"] { color: var(--text); background: var(--surface-2); }
.inline-edit {
  font: inherit; color: var(--text); background: var(--surface); border: 1px solid var(--accent); border-radius: 4px;
  padding: 4px 8px; box-shadow: 0 0 0 3px var(--accent-wash); outline: none;
}
.tabs .inline-edit { margin: 6px 4px; width: 160px; font-weight: 500; }
.inline-edit.note-edit { display: block; width: min(340px, 100%); margin-top: 4px; font: italic 13px var(--serif); }

.pop {
  position: fixed; z-index: 50; min-width: 220px; max-width: min(340px, calc(100vw - 24px));
  background: var(--surface); border: 1px solid var(--line-strong); border-radius: 6px;
  box-shadow: 0 12px 32px rgba(0,0,0,.28); padding: 6px;
}
.pop.menu button {
  display: block; width: 100%; text-align: left; background: none; border: none; border-radius: 4px;
  padding: 8px 10px; cursor: pointer; color: var(--text); font-size: 14px;
}
.pop.menu button:hover, .pop.menu button:focus-visible { background: var(--accent-wash); outline: none; }
.pop.menu button[disabled] { color: var(--muted); opacity: .5; cursor: default; background: none; }
.pop.menu button.danger { color: var(--down); }
.pop .sep { height: 1px; background: var(--line); margin: 5px 4px; }
.pop .mh { font-size: 12px; color: var(--muted); padding: 6px 10px 2px; }
.pop.form { padding: 14px; width: 320px; }
.pop-head { margin-bottom: 10px; display: flex; flex-wrap: wrap; align-items: baseline; gap: 8px; }
.pop-head .muted { font-size: 12.5px; }
.pop-field { position: relative; width: 100%; }
.pop input, .pop select {
  width: 100%; height: 36px; padding: 0 10px; border: 1px solid var(--line-strong); border-radius: 4px; background: var(--bg); font-size: 14px;
}
.pop input:focus, .pop select:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-wash); }
.pop-row { display: grid; grid-template-columns: 1.4fr 1fr; gap: 8px; margin-bottom: 8px; }
.pop-text { margin: 0 0 12px; line-height: 1.5; }
.pop-actions { display: flex; gap: 8px; margin-top: 12px; }
.suggest.in-pop { left: 0; right: 0; top: calc(100% + 4px); bottom: auto; }
.btn.small { padding: 4px 10px; font-size: 13px; margin-left: 10px; }
.btn.danger { background: var(--down); border-color: var(--down); color: #fff; }
.linkish { background: none; border: none; padding: 0; color: var(--accent); cursor: pointer; font-weight: 500; text-decoration: underline; text-underline-offset: 2px; }
.hint { margin: 0; padding: 0 20px 10px; font-size: 13px; color: var(--muted); }

.reading { position: relative; }
.unpin {
  position: absolute; top: 8px; right: 10px; opacity: 0; background: none; border: none; color: var(--muted);
  width: 24px; height: 24px; border-radius: 4px; cursor: pointer; font-size: 15px; line-height: 1;
}
.reading:hover .unpin, .unpin:focus-visible { opacity: 1; }
.unpin:hover { color: var(--down); background: var(--down-wash); }

@media (max-width: 820px) {
  .pop { left: 0 !important; right: 0; bottom: 0; top: auto !important; max-width: none; width: auto !important;
         border-radius: 12px 12px 0 0; padding: 10px 10px calc(14px + env(safe-area-inset-bottom)); }
  .pop.menu button { padding: 12px 12px; font-size: 15px; }
  .pop.form { padding: 18px 16px calc(18px + env(safe-area-inset-bottom)); }
  .pop input, .pop select { height: 42px; font-size: 16px; }
  .wl th.grip-h, .wl td.grip-cell { padding-left: 4px !important; width: 28px; }
}
