/* Lodestar. Ink-blue night, brass accent. Hand-set atlas feel: hairlines, small caps, no gradients, no glass. */
:root {
  --bg: #0b0f15; --panel: #111823; --raised: #172131; --line: #2a364a; --ink: #e8e3d6; --mute: #9aa6b8;
  --accent: #e0a33a; --accent-ink: #1a1305; --good: #86cfa0; --warn: #e8c15a; --bad: #ee8a7a; --focus: #8cc4ff;
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", Georgia, serif;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --tap: 44px; --gut: 16px;
}
:root[data-theme="red"] {
  --bg: #080000; --panel: #120202; --raised: #1b0404; --line: #4a1410; --ink: #e04030; --mute: #b83a2c;
  --accent: #ff4a38; --accent-ink: #1a0200; --good: #e04030; --warn: #e04030; --bad: #ff6a58; --focus: #ff7a68;
}
:root[data-theme="paper"] {
  --bg: #f1eee6; --panel: #fbf9f3; --raised: #ffffff; --line: #cfc8b8; --ink: #1d2230; --mute: #566074;
  --accent: #a8620a; --accent-ink: #ffffff; --good: #1f7a45; --warn: #8a6200; --bad: #b3402e; --focus: #0b5cad;
}
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body { background: var(--bg); color: var(--ink); font: 17px/1.5 var(--sans); -webkit-text-size-adjust: 100%; overflow: hidden; }
h1, h2, h3 { font-family: var(--serif); font-weight: 600; line-height: 1.2; margin: 0 0 .4em; }
h1 { font-size: 1.5rem; } h2 { font-size: 1.25rem; } h3 { font-size: 1.05rem; }
p { margin: 0 0 .8em; }
a { color: var(--accent); text-underline-offset: 3px; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.muted { color: var(--mute); } .small { font-size: .875rem; } .num { font-variant-numeric: tabular-nums; }
.cap { font-size: .75rem; letter-spacing: .08em; text-transform: uppercase; color: var(--mute); }
.good { color: var(--good); } .warn { color: var(--warn); } .bad { color: var(--bad); }

/* frame: phone first. Full-screen sky, bottom tab bar (49 + safe area), bottom sheet with peek / half / full. */
:root { --hdr: 44px; --tab: 49px; --sat: env(safe-area-inset-top, 0px); --sab: env(safe-area-inset-bottom, 0px); --sal: env(safe-area-inset-left, 0px); --sar: env(safe-area-inset-right, 0px); --kb: 0px; }
html { overscroll-behavior: none; }
body { overscroll-behavior: none; touch-action: manipulation; -webkit-tap-highlight-color: transparent; }
.app { position: fixed; inset: 0; }
.bar { position: absolute; top: 0; left: 0; right: 0; z-index: 5; height: calc(var(--hdr) + var(--sat)); padding: var(--sat) max(8px, var(--sar)) 0 max(16px, var(--sal)); display: flex; align-items: center; gap: 8px; background: var(--panel); border-bottom: 1px solid var(--line); }
.brand { display: flex; align-items: center; gap: 8px; font: 600 1.15rem var(--serif); color: var(--ink); text-decoration: none; min-height: 44px; margin-right: auto; }
.brand svg { width: 22px; height: 22px; flex: none; }
.chip { background: var(--bg); color: var(--mute); border: 1px solid var(--line); border-radius: 4px; padding: 3px 8px; font-size: .75rem; white-space: nowrap; }
.iconbtn { min-width: 44px; min-height: 44px; background: none; border: 0; color: var(--ink); font: inherit; font-size: 1rem; cursor: pointer; border-radius: 4px; }
nav.tabs { position: fixed; left: 0; right: 0; bottom: 0; z-index: 6; display: grid; grid-template-columns: repeat(4, 1fr); height: calc(var(--tab) + var(--sab)); padding: 0 var(--sar) var(--sab) var(--sal); background: var(--panel); border-top: 1px solid var(--line); }
.tab { min-height: 44px; background: none; border: 0; border-top: 3px solid transparent; color: var(--mute); font: inherit; font-size: .8rem; letter-spacing: .02em; cursor: pointer; }
.tab[aria-current="page"] { color: var(--ink); border-top-color: var(--accent); }
main { position: absolute; left: 0; right: 0; top: calc(var(--hdr) + var(--sat)); bottom: calc(var(--tab) + var(--sab)); min-height: 0; }
#stage { position: absolute; inset: 0; background: #000; overflow: hidden; }
#sky { width: 100%; height: 100%; display: block; touch-action: none; -webkit-touch-callout: none; user-select: none; }
#nightveil { position: absolute; inset: 0; background: #f00; mix-blend-mode: multiply; pointer-events: none; display: none; }
:root[data-theme="red"] #nightveil { display: block; }
.hudbtns { position: absolute; top: 12px; right: max(12px, var(--sar)); display: flex; flex-direction: column; gap: 12px; z-index: 2; }
.hudbtns button { min-width: 44px; min-height: 44px; background: var(--bg); color: var(--ink); border: 1px solid var(--line); border-radius: 4px; font: inherit; font-size: 1.15rem; cursor: pointer; opacity: .92; }
.hudbtns button.txt { font-size: .75rem; }
.hudbtns button[aria-pressed="true"] { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
#prompt { position: absolute; top: 8px; left: max(12px, var(--sal)); right: 76px; background: var(--accent); color: var(--accent-ink); padding: 10px 12px; border-radius: 4px; font-weight: 600; display: none; z-index: 2; }
#prompt small { display: block; font-weight: 400; opacity: .9; }
#loading { position: absolute; inset: 0; display: grid; place-items: center; color: var(--mute); background: #000; text-align: center; padding: 24px; z-index: 3; }
#dock { position: absolute; left: 0; right: 0; bottom: var(--kb); z-index: 4; background: var(--panel); border-top: 1px solid var(--line); border-radius: 12px 12px 0 0; display: flex; flex-direction: column; height: 46%; transition: height .22s ease; box-shadow: none; }
#dock[data-state="peek"] { height: 84px; }
#dock[data-state="half"] { height: 46%; }
#dock[data-state="full"] { height: 100%; border-radius: 0; }
#dock.dragging { transition: none; }
#grab { flex: none; width: 100%; height: 28px; background: none; border: 0; cursor: grab; display: grid; place-items: center; touch-action: none; }
#grab span { width: 44px; height: 5px; border-radius: 3px; background: var(--line); display: block; }
#panel { flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; padding: 0 max(16px, var(--sar)) calc(24px + var(--sab)) max(16px, var(--sal)); -webkit-overflow-scrolling: touch; overflow-wrap: anywhere; }
#dock[data-state="peek"] #panel { overflow: hidden; }
@media (min-width: 900px), (orientation: landscape) and (max-height: 520px) and (min-width: 560px) {
  .brand { margin-right: 12px; }
  nav.tabs { position: static; display: flex; flex: 1; height: auto; padding: 0; border: 0; background: none; gap: 2px; z-index: auto; justify-content: flex-start; }
  .tab { padding: 0 14px; border-top: 0; border-bottom: 3px solid transparent; font-size: .95rem; }
  .tab[aria-current="page"] { border-bottom-color: var(--accent); }
  .bar > .chip { margin-left: auto; }
  main { bottom: 0; }
  #dock { top: 0; left: auto; right: 0; bottom: 0; width: 420px; height: auto !important; border-radius: 0; border-top: 0; border-left: 1px solid var(--line); }
  #dock[data-state] { height: auto; }
  #grab { display: none; }
  #stage { right: 420px; }
  .hudbtns { right: 12px; }
  #panel { padding-top: 16px; }
}
@media (orientation: landscape) and (max-height: 520px) and (min-width: 560px) { #dock { width: 44%; } #stage { right: 44%; } }

/* controls */
button.btn, a.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: var(--tap); padding: 0 18px; background: var(--accent); color: var(--accent-ink); border: 0; border-radius: 4px; font: inherit; font-weight: 600; cursor: pointer; text-decoration: none; }
button.btn.ghost, a.btn.ghost { background: none; color: var(--ink); border: 1px solid var(--line); font-weight: 500; }
button.btn.small { min-height: 44px; padding: 0 12px; font-size: .875rem; }
button[disabled] { opacity: .5; cursor: not-allowed; }
.row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin: 10px 0; }
.stack > * + * { margin-top: 10px; }
input[type=text], input[type=email], input[type=tel], input[type=number], input[type=datetime-local], input[type=date], select, textarea {
  width: 100%; min-height: var(--tap); background: var(--bg); color: var(--ink); border: 1px solid var(--line); border-radius: 4px; padding: 0 10px; font: inherit; }
textarea { padding: 8px 10px; min-height: 80px; }
label.f { display: block; font-size: .85rem; color: var(--mute); }
label.f > :is(input, select) { margin-top: 4px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.check { display: flex; align-items: center; gap: 10px; min-height: var(--tap); cursor: pointer; }
.check input { width: 22px; height: 22px; accent-color: var(--accent); flex: none; }
input[type=range] { width: 100%; min-height: var(--tap); accent-color: var(--accent); }

/* cards and lists, hairline plates */
.plate { border: 1px solid var(--line); border-radius: 4px; padding: 12px; background: var(--raised); }
.plate + .plate { margin-top: 10px; }
.list { list-style: none; margin: 0; padding: 0; }
.list li { border-top: 1px solid var(--line); }
.list li:last-child { border-bottom: 1px solid var(--line); }
.list button.item { display: flex; width: 100%; min-height: var(--tap); align-items: center; gap: 10px; padding: 6px 2px; background: none; border: 0; color: var(--ink); font: inherit; text-align: left; cursor: pointer; }
.list .dots { flex: 1; border-bottom: 1px dotted var(--line); align-self: center; margin: 0 4px; min-width: 12px; }
.day-n { font: 600 1.2rem var(--serif); width: 2.2ch; color: var(--accent); }
.box { display: inline-flex; gap: 2px; } .box i { width: 8px; height: 8px; border: 1px solid var(--mute); display: block; } .box i.on { background: var(--accent); border-color: var(--accent); }
.opts { display: grid; gap: 8px; margin: 10px 0; }
.opts button { min-height: var(--tap); background: var(--bg); color: var(--ink); border: 1px solid var(--line); border-radius: 4px; padding: 8px 12px; font: inherit; text-align: left; cursor: pointer; }
.opts button.right { border-color: var(--good); } .opts button.wrong { border-color: var(--bad); }
.bar-meter { height: 8px; background: var(--bg); border: 1px solid var(--line); border-radius: 2px; overflow: hidden; }
.bar-meter > i { display: block; height: 100%; background: var(--accent); }
.verdict { display: inline-block; padding: 2px 10px; border: 1px solid currentColor; border-radius: 3px; font-weight: 700; letter-spacing: .04em; }
table.t { width: 100%; border-collapse: collapse; font-size: .9rem; }
table.t th, table.t td { text-align: left; padding: 6px 4px; border-bottom: 1px solid var(--line); vertical-align: top; }
table.t th { color: var(--mute); font-weight: 500; font-size: .8rem; }
canvas.chart { width: 100%; height: 190px; display: block; border: 1px solid var(--line); border-radius: 4px; background: var(--bg); }
.nights { display: grid; gap: 4px; }
.nights button { display: grid; grid-template-columns: 5.2em 1fr 2.6em; align-items: center; gap: 8px; min-height: 36px; background: none; border: 0; color: var(--ink); font: inherit; font-size: .85rem; cursor: pointer; text-align: left; }

/* sheet (menus, about, settings) */
#sheet { position: fixed; inset: 0; background: rgba(0, 0, 0, .6); display: none; z-index: 10; }
#sheet.open { display: block; }
#sheet .inner { position: absolute; right: 0; top: 0; bottom: 0; width: min(520px, 100%); background: var(--panel); border-left: 1px solid var(--line); overflow-y: auto; padding: var(--gut); padding-bottom: 80px; }
#sheet .top { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.kbd { font: .8rem ui-monospace, Menlo, Consolas, monospace; border: 1px solid var(--line); border-bottom-width: 2px; border-radius: 3px; padding: 1px 6px; background: var(--bg); }
.toast { position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%); background: var(--raised); border: 1px solid var(--line); color: var(--ink); padding: 10px 16px; border-radius: 4px; z-index: 20; max-width: 90vw; }
.credit { font-size: .8rem; color: var(--mute); border-top: 1px solid var(--line); margin-top: 18px; padding-top: 10px; }
.cond { display: grid; grid-template-columns: auto 1fr; gap: 4px 12px; font-size: .9rem; }
@media (prefers-reduced-motion: reduce) { * { scroll-behavior: auto !important; transition: none !important; } }
