:root {
  --bg: #f5f1e8; --card: #fffdf8; --ink: #17241f; --muted: #6c756f; --accent: #134e42; --gold: #b08a3c;
  --line: color-mix(in srgb, var(--ink) 11%, transparent); --soft: color-mix(in srgb, var(--accent) 9%, transparent);
  --dock: 0px; --serif: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
}
* { box-sizing: border-box; margin: 0; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body { background: var(--bg); color: var(--ink); font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; min-height: 100vh; }
button, input { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: none; padding: 0; -webkit-tap-highlight-color: transparent; }
button:focus-visible, input:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }
button:disabled { opacity: .35; cursor: default; }
ol, ul { list-style: none; padding: 0; }

.top { position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: 8px; padding: 10px max(16px, calc(50vw - 490px)); background: color-mix(in srgb, var(--bg) 92%, transparent); backdrop-filter: blur(8px); border-bottom: 1px solid var(--line); }
.brand { display: flex; align-items: center; gap: 8px; font: 600 17px var(--serif); margin-right: auto; white-space: nowrap; }
.brand svg { width: 26px; height: 26px; fill: var(--gold); stroke: var(--accent); stroke-width: 1.2; }
.pill { display: inline-flex; align-items: center; gap: 6px; padding: 7px 12px; border-radius: 99px; background: var(--accent); color: #fff; font-weight: 600; font-size: 14px; white-space: nowrap; max-width: 46vw; }
.pill span { overflow: hidden; text-overflow: ellipsis; }
.pill svg { width: 12px; height: 12px; fill: none; stroke: currentColor; stroke-width: 1.6; flex: none; }
.pill.ghost { background: none; color: var(--accent); border: 1px solid var(--line); }

main { max-width: 620px; margin: 0 auto; padding: 18px 16px calc(var(--dock) + 32px); }
section { display: grid; gap: 14px; scroll-margin-top: 70px; }
section > div, .tiles { display: grid; gap: 14px; align-content: start; min-width: 0; }
h1 { font: 600 26px/1.2 var(--serif); letter-spacing: -.01em; }
h2 { font: 600 15px/1.3 system-ui, sans-serif; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; }
.lead { font: 17px/1.5 var(--serif); color: var(--muted); }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 18px; padding: 18px; display: grid; gap: 12px; }
.eyebrow { font-size: 13px; color: var(--muted); letter-spacing: .03em; }
.eyebrow::first-letter, #tb-title::first-letter { text-transform: uppercase; }
.note { font-size: 13.5px; color: var(--muted); }
.note:empty, .msg:empty { display: none; }
.msg { font-size: 14.5px; padding: 10px 12px; border-radius: 12px; background: color-mix(in srgb, var(--gold) 16%, transparent); }
.msg.kind { background: var(--soft); }
.link { color: var(--accent); font-weight: 600; font-size: 14px; text-decoration: underline; text-underline-offset: 3px; justify-self: start; }
.back { justify-self: start; color: var(--accent); font-weight: 600; padding: 6px 12px 6px 8px; border-radius: 99px; border: 1px solid var(--line); }
.back::before { content: "‹ "; }
.btn { background: var(--accent); color: #fff; font-weight: 600; padding: 12px 18px; border-radius: 12px; text-align: center; }
.btn.ghost { background: none; color: var(--accent); border: 1px solid var(--line); }

.hero { gap: 4px; background: linear-gradient(160deg, var(--accent), color-mix(in srgb, var(--accent) 78%, #000)); color: #fff; border: 0; padding: 22px; }
.hero .eyebrow, .hero .next, .hero .dayrow { color: rgba(255, 255, 255, .78); }
.now { font: 600 19px var(--serif); }
.count { font: 600 clamp(46px, 14vw, 64px)/1.05 var(--serif); font-variant-numeric: tabular-nums; letter-spacing: -.01em; white-space: nowrap; }
.next { font-size: 15px; white-space: nowrap; }
.dayrow { display: flex; align-items: center; gap: 10px; margin-top: 12px; font-size: 13px; flex-wrap: wrap; }
.dayrow input { background: rgba(255, 255, 255, .12); border: 1px solid rgba(255, 255, 255, .25); color: #fff; border-radius: 9px; padding: 5px 8px; font-size: 14px; color-scheme: dark; }
.hero .link { color: #fff; }

.rows { padding: 6px 18px; gap: 0; }
.rows li { display: flex; justify-content: space-between; align-items: baseline; padding: 12px 0; border-bottom: 1px solid var(--line); }
.rows li:last-child { border: 0; }
.nm { font-weight: 500; }
.tm { font: 600 20px var(--serif); font-variant-numeric: tabular-nums; white-space: nowrap; }
.rows li.cur { margin: 0 -10px; padding: 12px 10px; border-radius: 12px; background: var(--soft); border-color: transparent; box-shadow: inset 3px 0 0 var(--gold); }
.rows li.cur .nm { font-weight: 700; color: var(--accent); }

.tile { text-align: left; background: var(--card); border: 1px solid var(--line); border-radius: 16px; padding: 14px 16px; display: grid; gap: 2px; }
.tile b { font: 600 18px var(--serif); }
.tile span { font-size: 13.5px; color: var(--muted); }
.tile:hover { border-color: var(--gold); }

.qibla { justify-items: center; text-align: center; }
#compass { width: min(100%, 320px); height: auto; }
#compass text { text-anchor: middle; fill: var(--muted); font: 9px system-ui, sans-serif; }
#compass .lt { font: 600 13px var(--serif); fill: var(--ink); }
#compass .lt.n { fill: var(--gold); }
.rim { fill: none; stroke: var(--line); stroke-width: 1.5; }
.tk { stroke: var(--muted); stroke-width: .7; opacity: .6; }
.tk.big { stroke: var(--ink); stroke-width: 1.2; opacity: 1; }
.lub { fill: var(--ink); }
#dial { transition: transform .15s linear; }
.shaft { stroke: var(--accent); stroke-width: 2.4; stroke-linecap: round; }
.mark { fill: var(--ink); }
.band { fill: var(--gold); }
.hub { fill: var(--card); stroke: var(--accent); stroke-width: 2; }
.qread { display: grid; gap: 4px; justify-items: center; }
.big { font: 600 54px/1 var(--serif); font-variant-numeric: tabular-nums; }
.dir { font: 17px var(--serif); color: var(--accent); }
.kv { display: flex; justify-content: space-between; gap: 16px; align-items: baseline; width: 100%; }
.qread .kv { justify-content: center; }
.kv b { font: 600 20px var(--serif); white-space: nowrap; font-variant-numeric: tabular-nums; }
.kv.total b { font-size: 28px; color: var(--accent); }
.hint { font-weight: 600; margin-top: 6px; }
.facing .hint { color: var(--accent); }

.form label, .lbl { display: grid; gap: 5px; font-size: 14px; color: var(--muted); }
.form input { width: 100%; padding: 11px 12px; border: 1px solid var(--line); border-radius: 11px; background: var(--bg); color: var(--ink); font-size: 17px; min-width: 0; }
.pair { display: grid; grid-template-columns: 1.6fr 1fr; gap: 10px; align-items: end; }
#qz-age, #qz-span { display: grid; gap: 12px; }
.seg { display: inline-grid; grid-auto-flow: column; grid-auto-columns: 1fr; background: var(--bg); border: 1px solid var(--line); border-radius: 11px; padding: 3px; }
.seg button { padding: 8px 12px; border-radius: 8px; font-size: 14px; font-weight: 600; color: var(--muted); }
.seg [aria-pressed="true"] { background: var(--card); color: var(--accent); box-shadow: 0 1px 2px var(--line); }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { padding: 8px 13px; border-radius: 99px; border: 1px solid var(--line); font-size: 14.5px; white-space: nowrap; }
.chip[aria-pressed="true"], .opt[aria-pressed="true"] { background: var(--soft); border-color: var(--accent); color: var(--accent); font-weight: 600; }
.opt { text-align: left; display: grid; padding: 12px 14px; border: 1px solid var(--line); border-radius: 12px; }
.opt span { font-size: 13.5px; color: var(--muted); }
.step { width: 38px; height: 38px; border-radius: 50%; border: 1px solid var(--line); font-size: 20px; line-height: 1; color: var(--accent); flex: none; }
.planrow { display: flex; align-items: center; gap: 12px; justify-content: space-between; font-weight: 600; text-align: center; }
.end { font: 600 20px/1.3 var(--serif); color: var(--accent); }

.ringbox { display: grid; grid-template-columns: 120px 1fr; gap: 16px; align-items: center; }
.ringbox svg { width: 120px; }
.ringbox circle { fill: none; stroke-width: 9; }
.ring-bg { stroke: var(--soft); }
#ring-arc { stroke: var(--gold); stroke-linecap: round; transition: stroke-dasharray .3s; }
.ringbox div { display: grid; }
.ringbox span, .ringbox small { color: var(--muted); font-size: 13.5px; }
.ringbox b { font: 600 34px/1.1 var(--serif); font-variant-numeric: tabular-nums; white-space: nowrap; }
#qz-rows li { display: grid; grid-template-columns: 1fr auto auto; gap: 4px 8px; align-items: center; padding: 10px 0; border-top: 1px solid var(--line); }
#qz-rows .lf { font-variant-numeric: tabular-nums; color: var(--muted); font-size: 14px; white-space: nowrap; grid-column: 1; }
#qz-rows .nm { grid-column: 1; }
.plus { grid-row: 1 / span 2; grid-column: 2; background: var(--accent); color: #fff; font-weight: 600; font-size: 14px; padding: 10px 12px; border-radius: 11px; white-space: nowrap; }
.undo { grid-row: 1 / span 2; grid-column: 3; font-size: 13px; color: var(--muted); text-decoration: underline; padding: 8px 2px; }

.bar { display: flex; flex-wrap: wrap; gap: 10px; justify-content: space-between; align-items: center; }
.nav { display: flex; align-items: center; gap: 10px; }
.nav b { min-width: 132px; text-align: center; white-space: nowrap; font-size: 15px; }
.tbl { padding: 6px 8px; overflow-x: auto; }
table { border-collapse: collapse; width: 100%; font-variant-numeric: tabular-nums; }
th, td { padding: 8px 3px; text-align: center; font-size: 13px; white-space: nowrap; border-bottom: 1px solid var(--line); }
thead th { color: var(--muted); font-weight: 600; font-size: 11.5px; }
tbody th { text-align: left; color: var(--muted); font-weight: 500; }
tbody tr:last-child > * { border: 0; }
tr.cur > * { background: var(--soft); color: var(--accent); font-weight: 700; }
.adj li { display: flex; align-items: center; gap: 10px; padding: 7px 0; }
.adj .nm { margin-right: auto; }
.adj output { min-width: 74px; text-align: center; font-variant-numeric: tabular-nums; white-space: nowrap; }

#dock { position: fixed; left: 50%; bottom: 0; transform: translateX(-50%); width: min(100%, 620px); z-index: 6; background: var(--ink); color: #f5f1e8; padding: 14px 16px calc(14px + env(safe-area-inset-bottom)); border-radius: 18px 18px 0 0; display: grid; gap: 8px; box-shadow: 0 -8px 30px rgba(0, 0, 0, .18); }
#dock .eyebrow { color: #d9b56a; text-transform: uppercase; letter-spacing: .08em; font-size: 11.5px; font-weight: 700; }
#dock-cap { font-size: 15px; line-height: 1.45; }
#dock div { display: flex; gap: 8px; flex-wrap: wrap; }
#dock .btn { padding: 9px 16px; font-size: 14.5px; background: #d9b56a; color: #17241f; }
#dock .btn.ghost { background: none; color: #f5f1e8; border-color: rgba(255, 255, 255, .28); }

@media (min-width: 900px) {
  main { max-width: 980px; }
  .home { grid-template-columns: 1.15fr .85fr; gap: 22px; align-items: start; }
  section:not(.home) { max-width: 620px; margin: 0 auto; }
  .qibla { grid-template-columns: 320px 1fr; align-items: center; }
}
@media (max-width: 380px) {
  .card { padding: 15px; }
  .brand span { display: none; }
  th, td { font-size: 12px; padding: 8px 1px; }
  .plus { padding: 10px 9px; font-size: 13px; }
}
