:root {
  /* Small text sizes; raised to at least 12 px on phones for legibility. */
  --fs-9: 9px; --fs-10: 10px; --fs-11: 11px;
  --bg: #000;
  --tint: 255, 255, 255; /* rgb of light overlays; themes flip it */
  --fg: #f4f7f5;
  --muted: rgba(244, 247, 245, .72);
  /* Glassmorphism: the outer frame is a slightly darker glass than the inner content pane. */
  --glass: rgba(14, 24, 30, .34);
  --glass-inner: rgba(57, 66, 71, .2);
  --glass-solid: rgba(14, 24, 30, .62);
  --line: rgba(var(--tint), .14);
  --line-strong: rgba(var(--tint), .26);
  --surface: rgba(var(--tint), .08);
  --surface-hover: rgba(var(--tint), .16);
  --well: rgba(var(--tint), .05);
  --sheen: linear-gradient(135deg, rgba(var(--tint), .14) 0%, rgba(var(--tint), .04) 40%, rgba(var(--tint), 0) 62%);
  --sheen-soft: linear-gradient(160deg, rgba(var(--tint), .07) 0%, rgba(var(--tint), 0) 55%);
  --edge-hi: inset 0 1px 0 rgba(var(--tint), .24), inset 0 -1px 0 rgba(var(--tint), .05);
  --edge-hi-sm: inset 0 1px 0 rgba(var(--tint), .16);
  --shadow: 0 8px 32px rgba(0, 0, 0, .35);
  --accent: #7fe0c0;
  --gain: #4ade80;
  --loss: #f87171;
  --radius: 28px;
  --radius-inner: 20px;
  --gap: 14px;
  --spring: cubic-bezier(.34, 1.56, .64, 1);
  --blur: blur(28px) saturate(180%);
  --font: "Fira Code", ui-monospace, monospace;
}
* { box-sizing: border-box; }
html { background: var(--bg); }
body {
  margin: 0; color: var(--fg); font-family: var(--font); font-weight: 400;
  min-height: 100vh; display: flex; flex-direction: column;
}
body::before {
  content: ""; position: fixed; inset: 0; z-index: -1;
  background: var(--bg-color, #000) var(--bg-image, url("../assets/bg.jpg")) center / cover no-repeat;
}
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 8px; }
[hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.skip-link { position: absolute; left: 12px; top: -60px; z-index: 100; background: #000; padding: 8px 12px; border-radius: 8px; color: var(--fg); }
.skip-link:focus { top: 12px; }
.muted { color: var(--muted); }

/* ---------- glass ---------- */
.glass, .module, .menu, .editor {
  background: var(--sheen), var(--glass);
  -webkit-backdrop-filter: var(--blur); backdrop-filter: var(--blur);
  border: 1px solid var(--line);
  border-top-color: rgba(var(--tint), .28);
  border-left-color: rgba(var(--tint), .2);
  box-shadow: var(--shadow), var(--edge-hi);
}

/* ---------- top bar ---------- */
.topbar { display: flex; align-items: center; justify-content: space-between; padding: 12px 16px 0; position: relative; z-index: 20; }
.topbar h1 { margin: 0; font-weight: 300; font-size: 15px; letter-spacing: .02em; color: var(--muted); }
.menu-wrap { position: relative; }
.status-chip { margin: 0 auto 0 12px; padding: 4px 10px; border-radius: 999px; font-size: 12px; background: var(--glass-solid); border: 1px solid var(--line-strong); color: var(--fg); max-width: 60%; }
.status-chip.warn { border-color: var(--loss); }
.icon-btn {
  display: inline-grid; place-items: center; min-width: 36px; height: 36px; padding: 0 8px;
  border-radius: 12px; border: 1px solid var(--line); background: var(--surface); box-shadow: var(--edge-hi-sm); cursor: pointer;
  transition: background .2s, transform .3s var(--spring);
}
.icon-btn:hover { background: var(--surface-hover); }
.icon-btn:active { transform: scale(.92); }
.icon-btn.small { min-width: 28px; height: 28px; border-radius: 9px; font-size: 14px; }
.icon-btn:disabled { opacity: .35; cursor: default; }
.menu-btn { width: 44px; height: 44px; gap: 4px; align-content: center; }
.menu-btn span { display: block; width: 18px; height: 2px; background: var(--fg); border-radius: 2px; transition: transform .35s var(--spring), opacity .2s; }
.menu-btn[aria-expanded="true"] span:nth-child(1) { transform: translateY(6px) rotate(45deg); }
.menu-btn[aria-expanded="true"] span:nth-child(2) { opacity: 0; }
.menu-btn[aria-expanded="true"] span:nth-child(3) { transform: translateY(-6px) rotate(-45deg); }
.menu {
  position: absolute; right: 0; top: 52px; min-width: 220px; padding: 8px; border-radius: 18px;
  display: flex; flex-direction: column; gap: 2px; background: var(--sheen), var(--glass-solid);
}
.menu-item { text-align: left; padding: 10px 12px; border: 0; border-radius: 10px; background: transparent; cursor: pointer; }
.menu-item:hover, .menu-item:focus-visible { background: var(--surface-hover); }
.menu-group { display: flex; flex-direction: column; border-top: 1px solid var(--line); margin-top: 6px; padding-top: 6px; }
.menu-label { font-size: 12px; color: var(--muted); padding: 4px 12px; }
.menu-item.lang[aria-checked="true"]::after { content: " ✓"; color: var(--accent); }

/* ---------- grid ---------- */
.grid {
  flex: 1; display: grid; gap: var(--gap); padding: var(--gap) 16px 16px;
  grid-template-columns: 1fr; grid-auto-rows: 190px;
}
.grid:focus { outline: none; }
.empty-msg { text-align: center; color: var(--muted); padding: 40px 16px; }
@media (min-width: 900px) and (orientation: landscape) {
  .grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
    grid-template-rows: repeat(3, minmax(0, 1fr));
    grid-auto-rows: unset; height: calc(100vh - 56px); min-height: 560px;
  }
  .module { grid-column: var(--x) / span var(--w); grid-row: var(--y) / span var(--h); }
}
@media not ((min-width: 900px) and (orientation: landscape)) {
  :root { --fs-9: 12px; --fs-10: 12px; --fs-11: 12px; }
  .module { grid-row: span var(--h); }
}

/* ---------- module frame ---------- */
.module {
  position: relative; min-width: 0; min-height: 0; border-radius: var(--radius);
  padding: clamp(8px, 1vw, 12px); display: flex; flex-direction: column; align-items: center; gap: 6px;
}
.module h2 { margin: 0; font-size: inherit; line-height: 1; }
.module-title {
  background: none; border: 0; cursor: pointer; padding: 4px 10px; border-radius: 10px;
  font-weight: 300; font-size: clamp(14px, 1.2vw, 18px); letter-spacing: -.01em;
  transition: color .2s, background .2s;
}
.module-title:hover { background: rgba(var(--tint), .08); }
.module-title[aria-expanded="true"] { color: var(--accent); }
.inner {
  flex: 1 1 0; min-height: 0; align-self: stretch; border-radius: var(--radius-inner);
  background: var(--sheen-soft), var(--glass-inner); border: 1px solid var(--line); box-shadow: var(--edge-hi-sm), 0 2px 12px rgba(0, 0, 0, .12);
  overflow: hidden; position: relative; container-type: size;
}
.face { position: absolute; inset: 0; padding: 12px; overflow: auto; display: flex; flex-direction: column; }
.face.explain { justify-content: center; font-size: 14px; line-height: 1.6; }
.face.explain p { margin: 0 0 8px; }
.face.explain .hint { color: var(--muted); font-size: 12px; }

/* ---------- controls ---------- */
.field {
  min-width: 0; padding: 6px 10px; border-radius: 10px; border: 1px solid var(--line-strong);
  background: var(--well); box-shadow: inset 0 1px 3px rgba(0, 0, 0, .18);
  transition: border-color .2s, background .2s;
}
.field:hover { background: rgba(var(--tint), .08); }
.field:focus-visible { border-color: var(--accent); }
.field::placeholder, .notes-area::placeholder { color: rgba(var(--tint), .45); }
select.field option { background: var(--option-bg, #18242b); color: var(--fg); }
.btn {
  padding: 8px 14px; border-radius: 12px; border: 1px solid var(--line-strong); background: var(--surface);
  box-shadow: var(--edge-hi-sm); cursor: pointer; transition: background .2s, transform .3s var(--spring);
}
.btn:hover { background: var(--surface-hover); }
.btn:active { transform: scale(.95); }
.btn:disabled { opacity: .4; cursor: not-allowed; }
.btn.primary { background: rgba(127, 224, 192, .18); border-color: rgba(127, 224, 192, .5); }
.btn.danger { border-color: rgba(248, 113, 113, .5); }
.btn.small { padding: 4px 10px; font-size: 13px; }
.chip { padding: 4px 10px; border-radius: 999px; border: 1px solid var(--line-strong); background: var(--well); box-shadow: var(--edge-hi-sm); transition: background .2s; cursor: pointer; font-size: 12px; }
.chip:hover { background: var(--surface-hover); }
.chip[aria-pressed="true"] { background: rgba(127, 224, 192, .2); border-color: var(--accent); }

/* ---------- shared ring / spark ---------- */
.ring-bg { fill: none; stroke: rgba(var(--tint), .1); stroke-width: 4; }
.ring-fg { fill: none; stroke: var(--accent); stroke-width: 4; stroke-linecap: round; transform: rotate(-90deg); transform-origin: 50% 50%; transition: stroke-dashoffset .3s linear; }
.spark { width: 100%; height: 40px; flex: 1 1 30px; min-height: 24px; overflow: visible; }
.spark-line { fill: none; stroke: var(--accent); stroke-width: 2; vector-effect: non-scaling-stroke; stroke-linejoin: round; }
.gain .spark-line { stroke: var(--gain); }
.loss .spark-line { stroke: var(--loss); }

/* ---------- clock ---------- */
.clock { position: relative; flex: 1; display: grid; place-items: center; }
.clock-ring { position: absolute; height: 100%; max-width: 100%; aspect-ratio: 1; }
.clock-ring .ring-fg { transition: none; }
.clock-text { text-align: center; position: relative; }
.clock-time { font-size: clamp(26px, 3.2vw, 46px); font-weight: 300; line-height: 1; }
.clock-date { font-size: 12px; color: var(--muted); margin-top: 6px; }

/* ---------- markets ---------- */
.markets { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; font-size: 12px; }
.mk-row { display: grid; grid-template-columns: minmax(110px, 1.1fr) 44px minmax(60px, 2fr) minmax(120px, 1.4fr); gap: 8px; align-items: center; }
.mk-name { display: flex; align-items: center; gap: 6px; white-space: nowrap; overflow: hidden; }
.mk-name strong { font-weight: 500; }
.mk-city, .mk-local { color: var(--muted); }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--loss); flex: none; }
.is-open .dot { background: var(--gain); box-shadow: 0 0 0 0 rgba(74, 222, 128, .6); }
.module.awake .is-open .dot { animation: pulse 2s 2; }
@keyframes pulse { 70% { box-shadow: 0 0 0 7px rgba(74, 222, 128, 0); } 100% { box-shadow: 0 0 0 0 rgba(74, 222, 128, 0); } }
.mk-state { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--loss); }
.is-open .mk-state { color: var(--gain); }
.mk-bar { position: relative; height: 8px; border-radius: 4px; background: rgba(var(--tint), .08); }
.mk-seg { position: absolute; top: 0; bottom: 0; border-radius: 4px; background: rgba(248, 113, 113, .55); transition: left .6s var(--spring), width .6s var(--spring); }
.is-open .mk-seg { background: rgba(74, 222, 128, .7); }
.mk-now { position: absolute; top: -3px; bottom: -3px; width: 2px; background: var(--fg); border-radius: 1px; z-index: 1; transition: left 1s linear; }


/* ---------- calculator ---------- */
.calc { flex: 1; display: flex; flex-direction: column; gap: 8px; border-radius: 12px; }
.calc-display { text-align: right; padding: 6px 8px; border-radius: 12px; background: var(--well); border: 1px solid var(--line); box-shadow: inset 0 1px 4px rgba(0, 0, 0, .18); min-height: 58px; }
.calc-expr { font-size: clamp(18px, 1.8vw, 26px); word-break: break-all; transform-origin: right center; }
.calc-res { display: block; font-size: 13px; color: var(--muted); min-height: 1.2em; }
.calc-pad { flex: 1; display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; min-height: 0; }
.calc-key { border: 1px solid var(--line); border-radius: 12px; background: var(--surface); box-shadow: var(--edge-hi-sm); cursor: pointer; min-height: 30px; font-size: 16px; transition: background .15s, transform .25s var(--spring); }
.calc-key:hover { background: var(--surface-hover); }
.calc-key:active { transform: scale(.9); }
.calc-key.op { color: var(--accent); }

/* ---------- notes ---------- */
.notes { flex: 1; display: flex; flex-direction: column; gap: 10px; min-height: 0; }
.notes-area { flex: 1 1 40%; min-height: 60px; resize: none; padding: 8px 10px; border-radius: 12px; border: 1px solid var(--line); background: var(--well); box-shadow: inset 0 1px 4px rgba(0, 0, 0, .18); line-height: 1.5; }
.todo { flex: 1 1 60%; display: flex; flex-direction: column; gap: 6px; min-height: 0; }
.todo-list { list-style: none; margin: 0; padding: 0; overflow: auto; flex: 1; display: flex; flex-direction: column; gap: 4px; }
.todo-list li { display: flex; align-items: center; gap: 8px; padding: 4px 6px; border-radius: 10px; background: var(--well); font-size: 13px; }
.todo-list label { flex: 1; overflow-wrap: anywhere; cursor: pointer; transition: color .3s; }
.todo-list li.done label { text-decoration: line-through; color: var(--muted); }
.todo-list input[type="checkbox"] { accent-color: var(--gain); width: 16px; height: 16px; }
.todo-form { display: flex; gap: 6px; }
.todo-form .field { flex: 1; }

/* ---------- timer ---------- */
.timer { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 6px; min-height: 0; }
.timer-modes { display: flex; gap: 4px; flex-wrap: wrap; justify-content: center; align-items: center; }
.field.num { width: 64px; padding: 3px 6px; font-size: 12px; }
.timer-dial { position: relative; flex: 1; min-height: 50px; aspect-ratio: 1; display: grid; place-items: center; }
.timer-dial svg { position: absolute; inset: 0; width: 100%; height: 100%; }
.timer-time { font-size: clamp(16px, 1.6vw, 26px); position: relative; }
.timer-break .ring-fg { stroke: #93c5fd; }
.timer-actions { display: flex; gap: 6px; }

/* ---------- currency ---------- */
.fx { flex: 1; display: flex; flex-direction: column; gap: 6px; min-height: 0; }
.fx-row { display: grid; grid-template-columns: minmax(60px, 1.4fr) minmax(60px, 1fr) auto minmax(60px, 1fr); gap: 4px; align-items: center; }
.fx-result { font-size: clamp(18px, 1.8vw, 26px); font-weight: 300; }
.fx-meta, .wx-meta { font-size: var(--fs-11); color: var(--muted); }
.gain .fx-meta { color: var(--gain); }
.loss .fx-meta { color: var(--loss); }

/* ---------- weather ---------- */
.wx { flex: 1; display: flex; flex-direction: column; gap: 6px; min-height: 0; }
.wx-form { display: flex; gap: 4px; }
.wx-form .field { flex: 1; }
.wx-now { display: flex; align-items: center; gap: 10px; }
.wx-icon { font-size: clamp(28px, 3vw, 42px); line-height: 1; }
.wx-temp { font-size: clamp(22px, 2.4vw, 34px); font-weight: 300; line-height: 1; }
.wx-desc { font-size: var(--fs-11); color: var(--muted); }

/* ---------- cat ---------- */
.cat-cave { position: relative; flex: 1; display: grid; place-items: end center; overflow: hidden; }
.cat-arch {
  position: absolute; bottom: 0; width: 82%; height: 82%; border-radius: 50% 50% 0 0 / 60% 60% 0 0;
  background: radial-gradient(ellipse at 50% 90%, rgba(0, 0, 0, .65), rgba(0, 0, 0, .25) 70%, transparent 72%);
}
.cat { position: relative; width: min(70%, 150px); aspect-ratio: 4 / 3; border: 0; background: none; padding: 0; cursor: pointer; border-radius: 16px; }
.cat-svg { width: 100%; height: 100%; overflow: visible; }
.cat-body, .cat-face, .cat-ear, .cat-paw { fill: #e7a15b; }
.cat-ear { stroke: #e7a15b; stroke-linejoin: round; stroke-width: 2; }
.cat-tail { fill: none; stroke: #e7a15b; stroke-width: 7; stroke-linecap: round; }
.cat-eyes ellipse { fill: #1d2a22; transform-box: fill-box; transform-origin: center; }
.module.awake .cat-eyes ellipse { animation: blink 2.5s 2; }
.cat-nose { fill: #b5654a; }
.cat-whisker { stroke: rgba(255,255,255,.6); stroke-width: 1; }
.cat-tail-g { transform-origin: 92px 70px; }
.module.awake .cat-tail-g { animation: tail 2.4s ease-in-out 2; }
.cat-body { transform-origin: 70px 80px; }
.module.awake .cat-body { animation: breathe 2.4s ease-in-out 2; }
.cat-head { transform-origin: 51px 60px; }
@keyframes blink { 0%, 92%, 100% { transform: scaleY(1); } 95% { transform: scaleY(.1); } }
@keyframes tail { 0%, 100% { transform: rotate(0); } 50% { transform: rotate(14deg); } }
@keyframes breathe { 0%, 100% { transform: scaleY(1); } 50% { transform: scaleY(1.05); } }
.cat.stretch .cat-svg { animation: stretch 1.6s var(--spring); transform-origin: 50% 100%; }
@keyframes stretch { 0% { transform: none; } 35% { transform: scale(1.3, .75); } 65% { transform: scale(.9, 1.15); } 100% { transform: none; } }
.cat.purr .cat-head { animation: purr .12s linear 10; }
@keyframes purr { 50% { transform: translateX(1px) rotate(1deg); } }
.cat-heart { position: absolute; bottom: 45%; color: #fb7185; font-size: 16px; pointer-events: none; }
.cat-ghost { position: fixed; left: 0; top: 0; z-index: 50; pointer-events: none; will-change: transform; }
.cat-ghost.land .cat-svg { animation: stretch 1.2s var(--spring); transform-origin: 50% 100%; }

/* ---------- editor dialog ---------- */
.editor {
  width: min(1100px, calc(100vw - 32px)); max-height: calc(100vh - 48px); padding: 0; border-radius: var(--radius);
  color: var(--fg); background: var(--sheen), var(--glass-solid); display: flex; flex-direction: column; overflow: hidden;
}
.editor:not([open]) { display: none; }
.editor::backdrop { background: rgba(0, 0, 0, .3); -webkit-backdrop-filter: blur(10px) saturate(140%); backdrop-filter: blur(10px) saturate(140%); }
.editor-head { display: flex; align-items: center; justify-content: space-between; padding: 18px 22px; border-bottom: 1px solid var(--line); }
.editor-head h2 { margin: 0; font-weight: 300; font-size: 20px; }
.editor-body { overflow: auto; padding: 18px 22px 24px; }
.editor-cat h3, .editor-sub { font-weight: 400; font-size: 15px; color: var(--accent); margin: 18px 0 10px; }
.editor-cat:first-child h3 { margin-top: 0; }
.editor-sub { font-size: 17px; color: var(--fg); border-top: 1px solid var(--line); padding-top: 18px; }
.editor-cats { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 0 22px; }
.cap { display: flex; align-items: center; gap: 10px; font-size: 13px; color: var(--muted); }
.cap-bar { width: 160px; height: 8px; border-radius: 4px; background: rgba(var(--tint), .1); overflow: hidden; }
.cap-bar span { display: block; height: 100%; background: var(--accent); border-radius: 4px; transition: width .5s var(--spring); }
.editor-msg { color: var(--loss); font-size: 13px; min-height: 1em; margin: 4px 0; }
.placed { list-style: none; padding: 0; margin: 0 0 12px; display: flex; flex-direction: column; gap: 6px; }
.placed-item { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding: 8px 10px; border-radius: 14px; background: var(--well); border: 1px solid var(--line); box-shadow: var(--edge-hi-sm); }
.placed-name { flex: 1 1 160px; }
.size-field { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; color: var(--muted); }
.size-field .field { padding: 3px 6px; color: var(--fg); }
.avail { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 8px; }
.avail-card { padding: 12px; border-radius: 16px; background: var(--sheen-soft), var(--well); border: 1px solid var(--line); box-shadow: var(--edge-hi-sm); transition: transform .3s var(--spring), background .2s; }
.avail-card:hover { transform: translateY(-2px); background: var(--sheen-soft), var(--surface); }
.avail-card h4 { margin: 0 0 6px; font-weight: 400; }
.avail-card p { margin: 0 0 10px; font-size: 12px; line-height: 1.5; color: var(--muted); }

/* ---------- refinements ---------- */
.topbar h1 { color: var(--fg); text-shadow: 0 1px 8px rgba(0, 0, 0, .6); }
.calc-key.op { font-size: 20px; }
.timer-time { font-size: clamp(13px, 11cqh, 26px); }
@container (max-width: 460px) {
  .mk-row { grid-template-columns: 1fr auto; row-gap: 3px; }
  .mk-city { display: none; }
  .mk-bar { grid-column: 1 / -1; order: 3; height: 6px; }
  .mk-state { grid-column: 1 / -1; order: 4; font-size: var(--fs-11); }
  .markets { gap: 10px; }
}
@media not ((min-width: 900px) and (orientation: landscape)) {
  .mod-markets, .mod-history { grid-row: span 2; }
}
@container (min-aspect-ratio: 2 / 1) {
  .timer { display: grid; grid-template-columns: auto 1fr; grid-template-rows: 1fr 1fr; grid-template-areas: "dial modes" "dial actions"; gap: 8px 14px; align-items: center; }
  .timer-dial { grid-area: dial; height: 100%; min-height: 0; }
  .timer-modes { grid-area: modes; align-self: end; }
  .timer-actions { grid-area: actions; align-self: start; justify-content: center; }
  .timer-time { font-size: clamp(14px, 16cqh, 30px); }
}
.mk-row { grid-template-columns: minmax(96px, 1fr) 44px minmax(60px, 1.5fr) minmax(150px, 1.7fr); }
@container (max-width: 640px) { .mk-city { display: none; } }
@container (max-width: 460px) { .markets { gap: 6px; } .mk-row { grid-template-columns: 1fr auto; } }
.clock-time { font-size: clamp(18px, 19cqmin, 46px); }
.clock-date { font-size: clamp(var(--fs-9), 5.5cqmin, 12px); }
.bm-list { list-style: none; margin: 0; padding: 0; overflow: auto; flex: 1; display: flex; flex-wrap: wrap; gap: 6px; align-content: flex-start; }
.bm-list li { display: flex; align-items: center; gap: 4px; padding: 2px 4px 2px 10px; border-radius: 999px; background: rgba(var(--tint), .06); border: 1px solid var(--line); font-size: 13px; }
.bm-list a { color: var(--accent); text-decoration: none; }
.bm-list a:hover { text-decoration: underline; }

/* ---------- calendar ---------- */
.cal { flex: 1; display: flex; flex-direction: column; gap: 6px; min-height: 0; font-size: 12px; }
.cal-head { display: flex; align-items: center; justify-content: space-between; gap: 6px; }
.cal-title { font-size: 13px; text-align: center; flex: 1; text-transform: capitalize; }
.cal-tools { display: flex; gap: 4px; justify-content: center; flex-wrap: wrap; }
.cal-body { flex: 1 1 auto; min-height: 0; overflow: auto; }
.cal-month { display: grid; grid-template-columns: 22px repeat(7, 1fr); gap: 2px; height: 100%; grid-auto-rows: minmax(20px, 1fr); align-items: stretch; }
.cal-dow, .cal-wk { display: grid; place-items: center; font-size: var(--fs-10); }
.cal-cell {
  position: relative; border: 1px solid transparent; border-radius: 8px; background: var(--well);
  cursor: pointer; padding: 0; font-size: 12px; transition: background .2s, transform .3s var(--spring), border-color .2s;
}
.cal-cell:hover { background: rgba(var(--tint), .12); transform: scale(1.06); }
.cal-cell.out { opacity: .4; }
.cal-cell.today { border-color: var(--accent); color: var(--accent); }
.cal-cell.selected { background: rgba(127, 224, 192, .22); }
.cal-cell.has::after { content: ""; position: absolute; left: 50%; bottom: 2px; width: 4px; height: 4px; margin-left: -2px; border-radius: 50%; background: var(--accent); }
.cal-week { display: grid; grid-template-rows: repeat(7, minmax(18px, 1fr)); gap: 2px; height: 100%; }
.cal-cell.wk-day { display: flex; align-items: center; gap: 8px; padding: 0 8px; text-align: left; min-height: 0; }
.cal-cell.wk-day.has::after { left: auto; right: 8px; bottom: 50%; margin: 0 0 -2px; }
.wk-name { width: 60px; flex: none; }
.wk-items { color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cal-day { flex: none; display: flex; flex-direction: column; gap: 4px; border-top: 1px solid var(--line); padding-top: 6px; max-height: 45%; min-height: 0; }
.cal.is-week .cal-day { max-height: 38%; }
/* Phone: give the calendar a third row so the whole week (incl. Sunday) fits without scrolling. */
@media not ((min-width: 900px) and (orientation: landscape)) { .mod-calendar { grid-row: span 3; } }
.cal-day-title { color: var(--muted); }
.cal-entries { list-style: none; margin: 0; padding: 0; overflow: auto; display: flex; flex-direction: column; gap: 3px; }
.cal-entries li { display: flex; align-items: center; justify-content: space-between; gap: 6px; padding: 2px 4px 2px 8px; border-radius: 8px; background: var(--well); overflow-wrap: anywhere; }

/* ---------- scientific calculator ---------- */
.sci-top { display: flex; gap: 8px; align-items: stretch; }
.sci-top .calc-display { flex: 1; }
.sci-deg { align-self: center; min-width: 52px; }
.sci-main { flex: 1; display: grid; grid-template-columns: 1fr minmax(110px, 30%); gap: 8px; min-height: 0; }
.sci-pad { display: grid; grid-template-columns: repeat(7, 1fr); gap: 5px; min-height: 0; }
.sci-pad .calc-key { min-height: 24px; font-size: clamp(12px, 1.1vw, 16px); }
.calc-key.fn { color: #c4b5fd; font-size: clamp(11px, .95vw, 14px); }
.calc-key.eq { background: rgba(127, 224, 192, .2); }
.sci-hist { list-style: none; margin: 0; padding: 0; overflow: auto; display: flex; flex-direction: column; gap: 4px; }
.sci-hist-item { width: 100%; display: flex; flex-direction: column; align-items: flex-end; gap: 1px; padding: 4px 8px; border-radius: 10px; border: 1px solid var(--line); background: var(--well); cursor: pointer; font-size: 12px; overflow-wrap: anywhere; text-align: right; }
.sci-hist-item:hover { background: rgba(var(--tint), .1); }
@container (max-width: 420px) {
  .sci-main { grid-template-columns: 1fr; grid-template-rows: 1fr auto; }
  .sci-hist { max-height: 60px; }
}

/* ---------- financial history ---------- */
.hs { flex: 1; display: flex; flex-direction: column; gap: 8px; min-height: 0; }
.hs-nav { display: flex; align-items: center; gap: 8px; }
.hs-line { position: relative; flex: 1; height: 22px; }
.hs-line::before { content: ""; position: absolute; left: 0; right: 0; top: 50%; height: 2px; margin-top: -1px; background: var(--line-strong); border-radius: 1px; }
.hs-axis { position: absolute; top: 100%; left: 0; font-size: var(--fs-9); }
.hs-axis.end { left: auto; right: 0; }
.hs-dot {
  position: absolute; top: 50%; width: 12px; height: 12px; margin: -6px 0 0 -6px; padding: 0; border-radius: 50%;
  border: 2px solid var(--accent); background: var(--dot-bg, rgba(18, 28, 34, .9)); cursor: pointer; transition: transform .35s var(--spring), background .2s;
}
.hs-dot:hover { transform: scale(1.4); }
.hs-dot.on { background: var(--accent); transform: scale(1.5); box-shadow: 0 0 10px var(--accent); }
.hs-card { flex: 1; display: flex; gap: 12px; min-height: 0; }
.hs-side { flex: none; width: clamp(70px, 26%, 140px); display: flex; flex-direction: column; gap: 4px; }
.hs-year { font-size: clamp(20px, 2.4vw, 34px); font-weight: 300; line-height: 1; color: var(--accent); }
.hs-pic { width: 100%; flex: 1; min-height: 24px; max-height: 70px; overflow: visible; }
.hs-path { fill: none; stroke: var(--accent); stroke-width: 2.5; stroke-dasharray: 100; stroke-linejoin: round; stroke-linecap: round; }
.kind-crash .hs-path, .kind-crisis .hs-path { stroke: var(--loss); }
.kind-bubble .hs-path { stroke: #fbbf24; }
.kind-milestone .hs-path { stroke: var(--gain); }
.hs-copy { flex: 1; min-width: 0; overflow: auto; }
.hs-title { margin: 0 0 4px; font-weight: 400; font-size: 14px; }
.hs-text { margin: 0; font-size: 12px; line-height: 1.55; color: var(--muted); }
@container (max-width: 360px) { .hs-card { flex-direction: column; } .hs-side { width: 100%; flex-direction: row; align-items: center; } .hs-pic { height: 30px; } }

/* ---------- quote ---------- */
.qt-wrap { flex: 1; display: flex; flex-direction: column; justify-content: center; align-items: center; gap: 8px; min-height: 0; }
.qt { position: relative; margin: 0; text-align: center; overflow: auto; }
.qt-mark { display: block; font-family: Georgia, 'Times New Roman', serif; font-size: clamp(28px, 18cqmin, 52px); line-height: .7; color: var(--accent); opacity: .7; }
.qt blockquote { margin: 0; }
.qt-text { margin: 0; font-size: clamp(var(--fs-11), 6cqmin, 16px); line-height: 1.45; min-height: 2.9em; }
.qt-by { margin: 6px 0 0; font-size: var(--fs-11); color: var(--muted); }

/* ---------- bird ---------- */
.bird-nest { position: relative; flex: 1; overflow: hidden; display: grid; place-items: center; }
.bird-sun { position: absolute; right: 12%; top: 10%; width: 22%; aspect-ratio: 1; border-radius: 50%; background: radial-gradient(circle, rgba(253, 224, 71, .5), rgba(253, 224, 71, 0) 70%); }
.module.awake .bird-sun { animation: breathe 4.8s ease-in-out 1; }
.bird-branch { position: absolute; left: -5%; right: 15%; top: 64%; height: 8px; border-radius: 4px; background: #7c5a3c; transform: rotate(-4deg); }
.leaf { position: absolute; width: 16px; height: 9px; border-radius: 0 100%; background: #4ade80; opacity: .8; }
.leaf.l1 { left: 12%; top: -8px; transform: rotate(-20deg); }
.leaf.l2 { left: 30%; top: 5px; transform: rotate(160deg); }
.leaf.l3 { left: 85%; top: -7px; transform: rotate(-35deg); }
.bird { position: relative; width: min(46%, 100px); aspect-ratio: 5 / 4; border: 0; background: none; padding: 0; cursor: pointer; border-radius: 16px; margin-top: -8%; }
.bird-svg { width: 100%; height: 100%; overflow: visible; }
.bird-body, .bird-head { fill: #60a5fa; }
.bird-tail, .bird-wing { fill: #3b82f6; }
.bird-belly { fill: #fde68a; }
.bird-eye { fill: #0f172a; transform-box: fill-box; transform-origin: center; }
.module.awake .bird-eye { animation: blink 2.4s 2; }
.bird-beak { fill: #f59e0b; transform-box: fill-box; transform-origin: left center; }
.bird-leg { stroke: #f59e0b; stroke-width: 2.5; stroke-linecap: round; }
.bird-head-g { transform-box: fill-box; transform-origin: 30% 90%; }
.module.awake .bird-head-g { animation: bob 2.4s ease-in-out 2; }
.bird-wing-g { transform-box: fill-box; transform-origin: 20% 40%; }
.bird.sing .bird-beak { animation: chirp .18s ease-in-out 8 alternate; }
.bird.sing .bird-head-g { animation: bob .5s ease-in-out 3; }
.bird.flying .bird-wing-g { animation: flap .16s ease-in-out infinite alternate; }
.bird.flying .bird-leg { opacity: 0; }
.bird.perch .bird-head-g { animation: look 1.8s ease-in-out; }
.bird-note { position: absolute; top: 30%; color: #fde68a; font-size: 16px; pointer-events: none; }
.bird-ghost { position: fixed; left: 0; top: 0; z-index: 50; pointer-events: none; will-change: transform; margin: 0; }
@keyframes bob { 0%, 100% { transform: rotate(0); } 50% { transform: rotate(-8deg) translateY(1px); } }
@keyframes chirp { to { transform: scaleY(1.6) rotate(-8deg); } }
@keyframes flap { from { transform: rotate(25deg) scaleY(1.1); } to { transform: rotate(-55deg) scaleY(.7); } }
@keyframes look { 0%, 100% { transform: none; } 30% { transform: scaleX(-1); } 60% { transform: rotate(-12deg); } }

/* ---------- aquarium ---------- */
.aq-tank { flex: 1; position: relative; padding: 0; border: 0; border-radius: 14px; background: none; cursor: copy; overflow: hidden; min-height: 0; }
.aq-canvas { position: absolute; inset: 0; display: block; }

/* ---------- settings ---------- */
.settings { width: min(560px, calc(100vw - 32px)); }
.set-body { display: flex; flex-direction: column; gap: 14px; align-items: flex-start; }
.set-group { width: 100%; margin: 0; padding: 12px 14px; border: 1px solid var(--line); border-radius: 16px; display: flex; flex-direction: column; gap: 10px; }
.set-group legend { padding: 0 6px; color: var(--accent); font-size: 14px; }
.set-row { display: flex; flex-wrap: wrap; gap: 8px 16px; align-items: center; }
.set-radio { display: inline-flex; gap: 6px; align-items: center; cursor: pointer; font-size: 13px; }
.set-radio input { accent-color: var(--accent); }
.set-field { display: flex; align-items: center; justify-content: space-between; gap: 12px; font-size: 13px; }
.set-color { width: 44px; height: 30px; padding: 2px; border-radius: 8px; border: 1px solid var(--line-strong); background: transparent; cursor: pointer; }
.set-range { display: inline-flex; align-items: center; gap: 8px; }
.set-range input { accent-color: var(--accent); width: 160px; }
.set-note { font-size: 12px; }
.editor-cats .editor-cat h3 { margin-top: 0; }

/* ---------- settings: themes ---------- */
.theme-row { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 10px; }
.theme-card {
  display: flex; flex-direction: column; gap: 6px; padding: 8px; border-radius: 14px; cursor: pointer; text-align: left;
  border: 1px solid var(--line-strong); background: var(--well); transition: transform .35s var(--spring), border-color .2s;
}
.theme-card:hover { transform: translateY(-3px) rotate(-1deg); }
.theme-card[aria-pressed="true"] { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-soft, rgba(127, 224, 192, .2)); }
.tc-swatch { position: relative; display: block; height: 54px; border-radius: 10px; background: var(--tc-bg); overflow: hidden; }
.tc-swatch::before { content: ""; position: absolute; inset: 8px 10px; border-radius: 8px; background: var(--tc-panel); opacity: .9; border: 1px solid color-mix(in srgb, var(--tc-fg) 25%, transparent); }
.tc-line { position: absolute; left: 18px; right: 18px; top: 30px; height: 2px; background: var(--tc-accent); transform: skewY(-12deg); border-radius: 2px; }
.tc-dot { position: absolute; right: 16px; top: 16px; width: 8px; height: 8px; border-radius: 50%; background: var(--tc-fg); }
.tc-name { font-family: var(--tc-font); font-size: 14px; }
.theme-paper .tc-swatch { background-image: repeating-linear-gradient(0deg, rgba(0, 0, 0, .03) 0 1px, transparent 1px 3px); }
.theme-terminal .tc-line { box-shadow: 0 0 6px var(--tc-accent); }

/* ---------- theme: paper (printed look) ---------- */
html[data-theme="paper"] {
  --tint: 43, 38, 32; --bg: #efe5cf;
  --sheen: none; --sheen-soft: none; --blur: none;
  --edge-hi: inset 0 0 0 3px rgba(251, 246, 234, 1), inset 0 0 0 4px rgba(43, 38, 32, .35);
  --edge-hi-sm: none; --shadow: 2px 3px 0 rgba(43, 38, 32, .14);
  --line: rgba(43, 38, 32, .3); --line-strong: rgba(43, 38, 32, .45);
  --gain: #2e6b30; --loss: #a3261b;
  --radius: 6px; --radius-inner: 3px;
  --option-bg: #fbf6ea; --dot-bg: #fbf6ea;
}
html[data-theme="paper"] .glass, html[data-theme="paper"] .module, html[data-theme="paper"] .menu, html[data-theme="paper"] .editor {
  border-color: rgba(43, 38, 32, .55);
}
html[data-theme="paper"][data-bg="image"] body::before { background-size: 240px 240px; background-repeat: repeat; }
html[data-theme="paper"] .module-title { font-variant: small-caps; letter-spacing: .06em; font-weight: 400; }
html[data-theme="paper"] .topbar h1 { text-shadow: none; font-style: italic; }
html[data-theme="paper"] .inner { box-shadow: none; border-style: dashed; }
html[data-theme="paper"] .spark-line, html[data-theme="paper"] .hs-path, html[data-theme="paper"] .ring-fg, html[data-theme="paper"] .chart-ink {
  filter: url(#ink-print); stroke-linecap: round;
}
html[data-theme="paper"] .editor::backdrop { background: rgba(60, 50, 30, .25); backdrop-filter: none; }
html[data-theme="paper"] .btn.primary { background: rgba(139, 46, 30, .12); border-color: rgba(139, 46, 30, .6); }
html[data-theme="paper"] .chip[aria-pressed="true"], html[data-theme="paper"] .cal-cell.selected { background: rgba(139, 46, 30, .14); }
html[data-theme="paper"] .field { box-shadow: none; border-style: solid none; border-radius: 0; background: transparent; }

/* ---------- theme: terminal (phosphor CRT) ---------- */
html[data-theme="terminal"] {
  --tint: 125, 255, 154; --bg: #000; --radius: 4px; --radius-inner: 2px;
  --sheen: none; --sheen-soft: none; --blur: none; --shadow: 0 0 18px rgba(57, 255, 106, .12);
  --edge-hi: none; --edge-hi-sm: none; --line: rgba(125, 255, 154, .3); --line-strong: rgba(125, 255, 154, .5);
  --gain: #39ff6a; --loss: #ff5f56; --option-bg: #001a0a; --dot-bg: #001a0a;
}
html[data-theme="terminal"] body { text-shadow: 0 0 4px rgba(57, 255, 106, .55); font-size-adjust: .56; }
html[data-theme="terminal"] body::after {
  content: ""; position: fixed; inset: 0; z-index: 90; pointer-events: none;
  background: repeating-linear-gradient(0deg, rgba(0, 0, 0, .22) 0 1px, transparent 1px 3px);
}
html[data-theme="terminal"].theme-awake body::after { animation: crt-flicker 4.8s steps(1) 1; }
@keyframes crt-flicker { 0%, 100% { opacity: 1; } 47% { opacity: .85; } 48% { opacity: 1; } }
html[data-theme="terminal"] .module-title::before { content: "> "; color: var(--accent); }
html[data-theme="terminal"] .module-title::after { content: "_"; }
html[data-theme="terminal"].theme-awake .module-title::after { animation: blink-cursor 1.2s steps(1) 4; }
@keyframes blink-cursor { 50% { opacity: 0; } }
html[data-theme="terminal"] .spark-line, html[data-theme="terminal"] .hs-path, html[data-theme="terminal"] .chart-ink { filter: drop-shadow(0 0 3px var(--accent)); }
html[data-theme="terminal"] .glass, html[data-theme="terminal"] .module, html[data-theme="terminal"] .menu, html[data-theme="terminal"] .editor { border-style: double; border-width: 3px; }

/* ---------- theme: aurora ---------- */
html[data-theme="aurora"] { --radius: 32px; }
html[data-theme="aurora"] body::before { animation: aurora-drift 40s ease-in-out infinite alternate; animation-play-state: paused; background-size: 140% 140%; }
html[data-theme="aurora"].theme-awake body::before { animation-play-state: running; }
@keyframes aurora-drift { from { background-position: 0% 0%; } to { background-position: 100% 60%; } }

/* ---------- interest rates & inflation ---------- */
.rt { flex: 1; display: flex; flex-direction: column; gap: 6px; min-height: 0; }
.rt-tiles { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; }
.rt-tile { display: flex; flex-direction: column; gap: 1px; padding: 4px 8px; border-radius: 10px; background: var(--well); border: 1px solid var(--line); min-width: 0; }
.rt-label, .rt-sub { font-size: var(--fs-10); color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rt-value { font-size: clamp(14px, 1.5vw, 22px); font-weight: 300; line-height: 1.15; }
.rt-tile.gain .rt-value { color: var(--gain); }
.rt-tile.loss .rt-value { color: var(--loss); }
.rt-plot { position: relative; flex: 1 1 40px; min-height: 36px; margin: 0 0 12px 30px; }
.rt-chart { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; }
.rt-zero { stroke: var(--line-strong); stroke-width: 1; vector-effect: non-scaling-stroke; }
.rt-grid line { stroke: var(--line); stroke-dasharray: 3 4; vector-effect: non-scaling-stroke; }
.rt-rate, .rt-inf { fill: none; stroke-width: 2; vector-effect: non-scaling-stroke; stroke-linejoin: round; }
.rt-rate { stroke: var(--accent); }
.rt-inf { stroke: #fbbf24; }
.rt-dot { fill: #fbbf24; }
.rt-axis { position: absolute; inset: 0; pointer-events: none; font-size: var(--fs-9); color: var(--muted); }
.rt-yr { position: absolute; right: calc(100% + 4px); top: -5px; white-space: nowrap; }
.rt-yr.low { top: auto; bottom: -5px; }
.rt-x { position: absolute; top: calc(100% + 2px); transform: translateX(-50%); }
.rt-legend { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px; font-size: var(--fs-11); }
.rt-key::before { content: ""; display: inline-block; width: 14px; height: 2px; margin-right: 5px; vertical-align: middle; background: var(--accent); }
.rt-key.inf::before { background: #fbbf24; }
.rt-legend .chip:first-of-type { margin-left: auto; }
html[data-theme="paper"] .rt-inf, html[data-theme="paper"] .rt-key.inf::before { stroke: #3d5a80; background: #3d5a80; }
html[data-theme="paper"] .rt-dot { fill: #3d5a80; }
@container (max-height: 150px) { .rt-sub { display: none; } }

/* ---------- radio ---------- */
.rd { flex: 1; display: flex; flex-direction: column; gap: 5px; min-height: 0; }
.rd-dial { position: relative; height: 22px; flex: none; border-radius: 8px; background: var(--well); border: 1px solid var(--line); overflow: hidden;
  background-image: repeating-linear-gradient(90deg, var(--line) 0 1px, transparent 1px 6px); background-size: 100% 40%; background-repeat: no-repeat; background-position: bottom; }
.rd-tick { position: absolute; top: 3px; width: 2px; height: 7px; margin-left: -1px; background: var(--muted); border-radius: 1px; }
.rd-needle { position: absolute; top: 0; bottom: 0; width: 2px; margin-left: -1px; background: var(--loss); box-shadow: 0 0 6px var(--loss); }
.rd-info { text-align: center; min-width: 0; }
.rd-name { font-size: clamp(13px, 1.3vw, 18px); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rd-tag, .rd-state { font-size: var(--fs-11); color: var(--muted); text-align: center; min-height: 1.2em; }
.rd.on .rd-state { color: var(--gain); }
.rd-bars { flex: 1 1 10px; min-height: 8px; display: flex; align-items: flex-end; justify-content: center; gap: 3px; }
.rd-bars span { width: 6px; height: 12%; border-radius: 3px 3px 1px 1px; background: var(--accent); opacity: .35; transition: height .4s var(--spring), opacity .3s; }
.rd.on .rd-bars span { opacity: .9; animation: rd-eq calc(.55s + var(--i) * .07s) ease-in-out infinite alternate; animation-delay: calc(var(--i) * -.13s); }
.rd.wait .rd-bars span { animation: rd-wait 1s ease-in-out infinite; animation-delay: calc(var(--i) * .08s); opacity: .6; }
@keyframes rd-eq { 0% { height: 15%; } 40% { height: 85%; } 70% { height: 40%; } 100% { height: 65%; } }
@keyframes rd-wait { 0%, 100% { height: 12%; } 50% { height: 40%; } }
.rd-ctrl { display: flex; align-items: center; justify-content: center; gap: 6px; }
.rd-play { width: 40px; height: 40px; border-radius: 50%; font-size: 13px; }
.rd.on .rd-play { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft, rgba(127, 224, 192, .2)); }
.rd-vol { width: 30%; min-width: 50px; accent-color: var(--accent); }
.rd-select { font-size: 12px; padding: 3px 8px; }
@container (max-height: 160px) { .rd-tag, .rd-select { display: none; } }

/* ---------- plant ---------- */
.pl { flex: 1; display: flex; flex-direction: column; gap: 6px; min-height: 0; }
.pl-stage { position: relative; flex: 1; min-height: 40px; }
.pl-svg { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; }
.pl-pot { fill: #b5653d; }
.pl-rim { fill: #c97a4f; }
.pl-soil { fill: #4a3426; }
.pl-stem { fill: none; stroke: #4c9a50; stroke-linecap: round; transition: d .8s var(--spring); }
.pl-leaf { fill: #5cbf63; transform-box: fill-box; transform-origin: left center; }
.module.awake .pl-leaf { animation: pl-leaf 2.4s ease-in-out 2; animation-delay: calc(var(--d) * .1); }
.pl-vein { stroke: #3f8a45; stroke-width: .5; fill: none; }
.pl-sway { transform-box: view-box; transform-origin: 50px 92px; }
.module.awake .pl-sway { animation: pl-sway 4.8s ease-in-out 1; }
.pl-sway.sad .pl-leaf { fill: #a8a35a; animation: none; }
.pl-sway.sad .pl-stem { stroke: #8a8a4a; }
.pl-sway.sad { animation-duration: 9s; }
.pl-petal { fill: #f472b6; }
.pl-core { fill: #fde047; }
.pl-drop { fill: #7cc4ff; }
@keyframes pl-sway { 0%, 100% { transform: rotate(-1.5deg); } 50% { transform: rotate(1.5deg); } }
@keyframes pl-leaf { 0%, 100% { transform: rotate(0); } 50% { transform: rotate(-6deg); } }
.pl-foot { display: flex; align-items: center; gap: 8px; }
.pl-info { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.pl-status { font-size: var(--fs-11); color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pl-meter { display: block; height: 5px; border-radius: 3px; background: var(--well); border: 1px solid var(--line); overflow: hidden; }
.pl-meter span { display: block; height: 100%; background: #7cc4ff; border-radius: 3px; transition: width .8s var(--spring); }
.pl-meter.low span { background: var(--loss); }
.pl-water { flex: none; }

/* ---------- resize handle ---------- */
.resize-handle {
  position: absolute; right: 6px; bottom: 6px; width: 22px; height: 22px; padding: 0; border: 0; border-radius: 8px;
  background: transparent; cursor: nwse-resize; opacity: 0; transition: opacity .2s, background .2s; touch-action: none; z-index: 2;
}
.resize-handle::before {
  content: ""; position: absolute; right: 5px; bottom: 5px; width: 10px; height: 10px;
  border-right: 2px solid var(--muted); border-bottom: 2px solid var(--muted); border-bottom-right-radius: 4px;
}
.module:hover .resize-handle, .resize-handle:focus-visible, .module.resizing .resize-handle { opacity: 1; }
.resize-handle:hover { background: var(--surface-hover); }
.module.resizing { z-index: 5; box-shadow: var(--shadow), 0 0 0 2px var(--accent); }
.module.resizing .inner { pointer-events: none; }
@media not ((min-width: 900px) and (orientation: landscape)) { .resize-handle { display: none; } }
@media (hover: none) { .resize-handle { opacity: .7; } }

/* ---------- world map ---------- */
.wm { flex: 1; display: flex; flex-direction: column; gap: 6px; min-height: 0; }
.wm-stage { position: relative; flex: 1; min-height: 60px; }
.wm-map { position: absolute; inset: 0; width: 100%; height: 100%; }
.wm-sea { fill: rgba(var(--tint), .03); }
.wm-grid { stroke: var(--line); stroke-width: .25; fill: none; }
.wm-land { fill: rgba(var(--tint), .16); stroke: rgba(var(--tint), .35); stroke-width: .25; stroke-linejoin: round; }
.wm-night { fill: rgba(0, 8, 30, .38); transition: d 1s linear; }
.wm-exch rect { fill: var(--loss); stroke: rgba(0, 0, 0, .5); stroke-width: .3; }
.wm-exch.is-open rect { fill: var(--gain); }
.wm-exch text { font-size: 4px; fill: var(--fg); paint-order: stroke; stroke: rgba(0, 0, 0, .55); stroke-width: .8px; }
.wm-exch, .wm-q { cursor: pointer; outline: none; }
.wm-exch:focus-visible rect, .wm-q:focus-visible { stroke: var(--accent); stroke-width: .8; }
.wm-q { fill: rgba(251, 146, 60, .45); stroke: #fb923c; stroke-width: .3; transition: fill .2s; }
.wm-q.big { fill: rgba(248, 113, 113, .5); stroke: var(--loss); }
.wm-q:hover { fill: rgba(251, 146, 60, .9); }
.wm-ripple { fill: none; stroke: #fb923c; stroke-width: .35; pointer-events: none; transform-box: fill-box; transform-origin: center; opacity: 0; }
.module.awake .wm-ripple { animation: wm-ripple 2.4s ease-out 2; }
@keyframes wm-ripple { from { transform: scale(1); opacity: .9; } to { transform: scale(3.2); opacity: 0; } }
.wm-tip { position: absolute; left: 6px; bottom: 4px; right: 6px; font-size: var(--fs-11); color: var(--fg); text-shadow: 0 1px 4px rgba(0, 0, 0, .6); pointer-events: none; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.wm-bar { display: flex; flex-wrap: wrap; gap: 4px; justify-content: center; }
html[data-theme="paper"] .wm-night { fill: rgba(43, 38, 32, .12); }
html[data-theme="paper"] .wm-tip, html[data-theme="paper"] .wm-exch text { text-shadow: none; stroke: #fbf6ea; }
.wm-wx text { font-size: 4.2px; pointer-events: none; }
.wm-wxi { pointer-events: bounding-box; }
.wm-wx-t { fill: var(--fg); paint-order: stroke; stroke: rgba(0, 0, 0, .55); stroke-width: .8px; }
html[data-theme="paper"] .wm-wx-t { stroke: #fbf6ea; }

/* ---------- news ---------- */
.nw { flex: 1; display: flex; flex-direction: column; gap: 6px; min-height: 0; }
.nw-list { list-style: none; margin: 0; padding: 0 2px 0 0; flex: 1; min-height: 0; overflow-y: auto; display: flex; flex-direction: column; gap: 2px; scrollbar-width: thin; }
.nw-item { padding: 6px 8px; border-radius: 10px; transition: background .2s; }
.nw-item:hover, .nw-item:focus-within { background: var(--surface-hover); }
.nw-link { color: var(--fg); text-decoration: none; display: flex; flex-direction: column; gap: 1px; }
.nw-link:hover .nw-title { text-decoration: underline; text-underline-offset: 2px; }
.nw-top { font-size: var(--fs-11); color: var(--accent); }
.nw-title { font-size: 13px; line-height: 1.35; }
.nw-meta { font-size: var(--fs-11); color: var(--muted); }
.nw-new { box-shadow: inset 2px 0 0 var(--accent); }
.nw-foot { display: flex; align-items: center; justify-content: space-between; gap: 6px; }
.nw-reload:disabled { opacity: .5; }

/* ---------- fear & greed ---------- */
.fg { flex: 1; display: flex; flex-direction: column; gap: 3px; min-height: 0; }
.fg-dial { position: relative; flex: 1; min-height: 34px; }
.fg-gauge { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; }
.fg-zone { fill: none; stroke-width: 14; opacity: .35; transition: opacity .4s, stroke-width .4s var(--spring); }
.fg-zone.active { opacity: 1; stroke-width: 17; }
.fg-needle line { stroke: var(--fg); stroke-width: 3; stroke-linecap: round; }
.fg-needle circle { fill: var(--fg); }
.fg-read { display: flex; align-items: baseline; justify-content: center; gap: 8px; }
.fg-value { font-size: 22px; font-weight: 500; line-height: 1; }
.gain .fg-value { color: var(--gain); }
.loss .fg-value { color: var(--loss); }
.fg-label { font-size: 13px; }
.fg-hist { display: flex; gap: 4px; justify-content: space-between; }
.fg-row { flex: 1; display: flex; flex-direction: column; align-items: center; padding: 2px 4px; border-radius: 8px; background: var(--well); border: 1px solid var(--line); min-width: 0; }
.fg-row-l { font-size: var(--fs-10); color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.fg-row-v { font-size: 13px; }
.fg-row.z-extremeFear .fg-row-v, .fg-row.z-fear .fg-row-v { color: var(--loss); }
.fg-row.z-greed .fg-row-v, .fg-row.z-extremeGreed .fg-row-v { color: var(--gain); }
.fg-spark { height: 22px; flex: none; min-height: 0; }
@container (max-height: 230px) { .fg-spark { display: none; } }

/* ---------- watchlist ---------- */
.wl { flex: 1; display: flex; flex-direction: column; gap: 6px; min-height: 0; }
.wl-add { position: relative; }
.wl-form .field { width: 100%; }
.wl-sugg { position: absolute; left: 0; right: 0; top: calc(100% + 4px); z-index: 3; list-style: none; margin: 0; padding: 4px; border-radius: 12px; background: var(--sheen), var(--glass-solid); border: 1px solid var(--line-strong); box-shadow: var(--shadow); max-height: 180px; overflow-y: auto; }
.wl-opt { padding: 6px 8px; border-radius: 8px; cursor: pointer; font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.wl-opt:hover, .wl-opt:focus { background: var(--surface-hover); outline: none; }
.wl.suggesting .wl-list, .wl.suggesting .wl-empty { opacity: .08; transition: opacity .2s; }
.wl-list { transition: opacity .2s; list-style: none; margin: 0; padding: 0; flex: 1; min-height: 0; overflow-y: auto; display: flex; flex-direction: column; gap: 3px; scrollbar-width: thin; }
.wl-row { display: grid; grid-template-columns: minmax(0, 1fr) 54px auto auto; align-items: center; gap: 6px; padding: 5px 6px; border-radius: 10px; background: var(--well); border: 1px solid var(--line); }
.wl-id { display: flex; flex-direction: column; min-width: 0; }
.wl-id strong { font-weight: 500; font-size: 13px; }
.wl-name { font-size: var(--fs-10); color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.wl-spark { width: 54px; height: 22px; overflow: visible; }
.wl-px { display: flex; flex-direction: column; align-items: flex-end; font-variant-numeric: tabular-nums; }
.wl-price { font-size: 13px; padding: 0 3px; border-radius: 4px; }
.wl-ch { font-size: var(--fs-10); color: var(--muted); }
.wl-row.gain .wl-ch { color: var(--gain); }
.wl-row.loss .wl-ch { color: var(--loss); }
.wl-btns { display: flex; gap: 2px; opacity: .35; transition: opacity .2s; }
.wl-row:hover .wl-btns, .wl-row:focus-within .wl-btns { opacity: 1; }
@media (hover: none) { .wl-btns { opacity: .8; } }
.wl-empty { font-size: 12px; text-align: center; margin: auto 0; }
@container (max-width: 250px) { .wl-spark { display: none; } .wl-row { grid-template-columns: minmax(0, 1fr) auto auto; } }

/* ---------- portfolio ---------- */
.pf-head { display: flex; justify-content: center; flex: 0 1 auto; min-height: 0; }
.pf-chart { position: relative; width: min(100%, 150px); aspect-ratio: 1; }
.pf-donut { width: 100%; height: 100%; overflow: visible; }
.pf-track { fill: none; stroke: rgba(var(--tint), .08); stroke-width: 9; }
.pf-seg { fill: none; stroke-width: 9; stroke-linecap: butt; transition: stroke-width .3s var(--spring); cursor: default; }
.pf-seg:hover { stroke-width: 12; }
.pf-center { position: absolute; inset: 16%; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; pointer-events: none; font-variant-numeric: tabular-nums; }
.pf-total { font-size: 15px; font-weight: 500; }
.pf-pl, .pf-day { font-size: var(--fs-10); color: var(--muted); white-space: nowrap; }
.pf-pl { font-size: 12px; pointer-events: auto; }
.pf-pl.gain, .pf-day.gain { color: var(--gain); }
.pf-pl.loss, .pf-day.loss { color: var(--loss); }
.pf-row { grid-template-columns: 8px minmax(0, 1fr) auto auto; }
.pf-dot { width: 8px; height: 8px; border-radius: 50%; }
.pf-draft { display: grid; grid-template-columns: auto 1fr 1fr auto auto; gap: 4px; align-items: center; }
.pf-draft .field { min-width: 0; width: 100%; }
.pf-draft-l { font-size: 13px; font-weight: 500; }
.pf-err { grid-column: 1 / -1; font-size: var(--fs-11); color: var(--loss); }
.pf-err:empty { display: none; }
.wl.suggesting .pf-head { opacity: .08; }
@container (max-height: 300px) { .pf-chart { width: min(100%, 92px); } .pf-total { font-size: 12px; } .pf-day { display: none; } }

/* ---------- motion policy: honour "reduce motion" (see js/lib/motion.js) ---------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 1ms !important; animation-delay: 0s !important; animation-iteration-count: 1 !important; transition-duration: 1ms !important; transition-delay: 0s !important; scroll-behavior: auto !important; }
}
