@font-face {
  font-family: "Inter";
  src: url("/fonts/inter-latin-wght-normal.woff2") format("woff2");
  font-weight: 100 900;
  font-display: swap;
}

:root {
  --bg: #000;
  --fg: #F2F2EF;
  --fg2: #B5B5B0;
  --fg3: #7A7A76;
  --line: #2A2A28;
  --line2: #3C3C39;
  --dim: 1;
  --ease: cubic-bezier(.2, .7, .2, 1);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }
html, body { height: 100%; margin: 0; background: var(--bg); color: var(--fg); overflow: hidden; overscroll-behavior: none; }
body {
  font-family: "Inter", -apple-system, "SF Pro Text", "Helvetica Neue", Arial, sans-serif;
  font-variant-numeric: tabular-nums lining-nums;
  font-feature-settings: "tnum" 1, "lnum" 1;
  -webkit-font-smoothing: antialiased;
  -webkit-user-select: none; user-select: none; touch-action: manipulation;
}
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; }
.faint { color: var(--fg3); }

/* ---------- frame ---------- */
#app {
  height: 100%;
  display: grid; grid-template-rows: auto minmax(0, 1fr) auto; gap: 1.6vh;
  padding: max(env(safe-area-inset-top), 18px) max(env(safe-area-inset-right), 30px) max(env(safe-area-inset-bottom), 16px) max(env(safe-area-inset-left), 30px);
  filter: brightness(var(--dim)); transition: filter 3s linear;
}

/* ---------- top ---------- */
.top { display: grid; grid-template-columns: 1fr auto 1fr; align-items: start; gap: 24px; }
.status { display: flex; align-items: center; gap: 12px; min-width: 0; font-size: clamp(15px, 2.3vh, 20px); }
.road { color: var(--fg2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dot { width: 11px; height: 11px; border-radius: 50%; border: 1.5px solid var(--fg3); flex: none; transition: all .6s; }
.dot[data-state="good"] { background: var(--fg); border-color: var(--fg); }
.dot[data-state="weak"] { background: linear-gradient(90deg, var(--fg2) 50%, transparent 50%); border-color: var(--fg2); }
.chip { border: 1px solid var(--line2); border-radius: 99px; padding: 2px 10px; font-size: 13px; color: var(--fg3); }
.alert { justify-self: center; border: 1px solid var(--line2); border-radius: 99px; padding: 6px 16px; font-size: clamp(14px, 2vh, 18px); color: var(--fg2); white-space: nowrap; }
.alert.strong { background: var(--fg); color: #000; border-color: var(--fg); font-weight: 500; }
.clock { justify-self: end; text-align: right; }
.date { font-size: clamp(15px, 2.4vh, 22px); color: var(--fg2); font-weight: 400; letter-spacing: .005em; }
.time { font-size: clamp(44px, 8.4vh, 78px); font-weight: 250; line-height: 1; letter-spacing: -.01em; margin-top: .4vh; }

/* ---------- main ---------- */
.main { display: grid; grid-template-columns: minmax(0, 1.04fr) minmax(0, 1fr); gap: clamp(20px, 3.4vw, 48px); min-height: 0; border-top: 1px solid var(--line); padding-top: 1.8vh; }
.drive { display: flex; flex-direction: column; justify-content: space-between; min-height: 0; }
.speedrow { display: flex; align-items: center; gap: clamp(18px, 3vw, 40px); }
.speed { display: flex; flex-direction: column; line-height: .86; }
#speed { font-size: min(27vh, 17vw); font-weight: 200; letter-spacing: -.035em; transition: color .6s, font-weight .6s; min-width: 2ch; }
.unit { font-size: clamp(18px, 3vh, 28px); color: var(--fg3); font-weight: 400; margin-top: 1.2vh; letter-spacing: .02em; }
body.over #speed { color: #fff; font-weight: 300; }

.sign {
  flex: none; width: clamp(104px, 12.5vw, 156px); aspect-ratio: 4 / 5; background: var(--fg); color: #000;
  border-radius: 14px; border: 4px solid var(--fg); outline: 2px solid #000; outline-offset: -8px;
  display: flex; flex-direction: column; align-items: center; justify-content: space-between; padding: 10px 6px 8px; text-align: center;
}
.sign-top { font-size: clamp(11px, 1.7vh, 15px); font-weight: 600; line-height: 1.1; letter-spacing: .01em; margin-top: 4px; }
.sign-num { font-size: clamp(50px, 8.4vh, 84px); font-weight: 600; line-height: 1; letter-spacing: -.03em; margin-bottom: 2px; }
body.over .sign { animation: pulse 2.2s ease-in-out infinite; }
@keyframes pulse { 0%, 100% { box-shadow: 0 0 0 0 rgba(242, 242, 239, 0); } 50% { box-shadow: 0 0 0 9px rgba(242, 242, 239, .22); } }

/* compass */
.compass-wrap { display: flex; align-items: center; gap: 18px; }
#compass { width: min(36vh, 30vw); height: min(36vh, 30vw); flex: none; overflow: visible; }
.ring { fill: none; stroke: var(--line2); stroke-width: 1; }
.tick { stroke: var(--fg3); stroke-width: 1; }
.tick-m { stroke: var(--fg2); stroke-width: 1.6; }
.lbl { fill: var(--fg2); font-weight: 500; }
.lbl-s { fill: var(--fg3); font-weight: 400; }
.lbl-n { fill: var(--fg); font-weight: 700; }
.north-mark { fill: var(--fg); }
.lubber { fill: var(--fg); }
.hdg-num { fill: var(--fg); font-size: 34px; font-weight: 300; letter-spacing: -.01em; font-variant-numeric: tabular-nums lining-nums; }
.hdg-card { fill: var(--fg2); font-size: 16px; font-weight: 500; letter-spacing: .04em; }
.hdg-src { fill: var(--fg3); font-size: 11px; font-weight: 400; }

/* ---------- side column ---------- */
.side { display: flex; flex-direction: column; gap: 2vh; min-height: 0; }

.ahead {
  border: 1px solid var(--line); border-radius: 18px; padding: 14px 20px 16px; position: relative; overflow: hidden; min-height: clamp(88px, 15vh, 140px);
  transition: background .5s, color .5s, border-color .5s;
}
.ahead-head { font-size: clamp(13px, 1.9vh, 17px); opacity: .6; font-weight: 500; }
.ahead-change { display: none; align-items: center; gap: 22px; margin-top: 6px; }
.ahead-quiet { display: none; margin-top: 10px; font-size: clamp(16px, 2.3vh, 22px); color: var(--fg3); }
.ahead[data-state="change"] { border-color: var(--line2); }
.ahead[data-state="change"] .ahead-change { display: flex; }
.ahead[data-state="clear"] .ahead-quiet[data-for="clear"], .ahead[data-state="unknown"] .ahead-quiet[data-for="unknown"] { display: block; }
.mini-sign { flex: none; width: clamp(54px, 8vh, 78px); aspect-ratio: 4 / 5; background: var(--fg); color: #000; border: 3px solid #000; outline: 1.5px solid var(--fg); border-radius: 9px; display: grid; place-items: center; font-size: clamp(26px, 4.4vh, 40px); font-weight: 600; letter-spacing: -.02em; }
.ahead-dist .big { font-size: clamp(38px, 6.8vh, 64px); font-weight: 300; line-height: 1; letter-spacing: -.02em; }
.ahead-dist .u { font-size: .38em; margin-left: .3em; opacity: .65; font-weight: 400; }
.ahead-dist .msg { font-size: clamp(14px, 2vh, 18px); opacity: .65; margin-top: 4px; }
.bar { position: absolute; left: 0; right: 0; bottom: 0; height: 3px; background: transparent; display: none; }
.bar i { display: block; height: 100%; width: 0; background: currentColor; opacity: .55; transition: width 1s linear; }
.ahead[data-state="change"] .bar { display: block; }
.ahead.urgent { background: var(--fg); color: #000; border-color: var(--fg); }
.ahead.flash { animation: flash 3s ease-out; }
@keyframes flash {
  0%, 60% { background: var(--fg); color: #000; border-color: var(--fg); }
  100% { background: transparent; color: var(--fg); border-color: var(--line2); }
}

.slot { flex: 1; min-height: 0; display: flex; flex-direction: column; gap: 2.2vh; overflow: hidden; }
.panel { display: flex; flex-direction: column; min-height: 0; }
.panel-head { font-size: clamp(13px, 1.9vh, 17px); color: var(--fg3); font-weight: 500; display: flex; gap: 10px; }

.idle { flex: 1 1 0; justify-content: center; overflow: hidden; transition: opacity .5s; }
body.lyrics-on .idle { flex: 0 0 0; opacity: 0; }
body.lyrics-on .music { flex: 1 1 auto; }
#tideChart { width: 100%; max-height: 100%; margin-top: 1vh; }
.tbase { stroke: var(--line); stroke-width: 1; }
.tcurve { fill: none; stroke: var(--fg2); stroke-width: 2; stroke-linejoin: round; }
.tp { fill: var(--fg); }
.tt { fill: var(--fg3); font-size: 11px; }
.tnow { stroke: var(--fg); stroke-width: 1; stroke-dasharray: 2 3; }

.music { order: -1; flex: 0 1 auto; min-height: 0; gap: 1.6vh; max-height: 0; opacity: 0; overflow: hidden; visibility: hidden; transition: max-height .7s var(--ease), opacity .6s var(--ease), visibility .6s; }
body.music-on .music { max-height: 80vh; opacity: 1; visibility: visible; }
.np { display: flex; gap: 22px; align-items: center; }
#art { width: clamp(96px, 17vh, 148px); height: clamp(96px, 17vh, 148px); border-radius: 10px; object-fit: cover; background: #111; flex: none; }
.np-meta { min-width: 0; flex: 1; }
.title { font-size: clamp(20px, 3.2vh, 30px); font-weight: 500; line-height: 1.15; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.artist { font-size: clamp(15px, 2.3vh, 21px); color: var(--fg2); margin-top: 4px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.prog { height: 3px; background: var(--line); border-radius: 2px; margin-top: 2vh; overflow: hidden; }
.prog i { display: block; height: 100%; width: 0; background: var(--fg); }
.ptimes { display: flex; justify-content: space-between; font-size: 13px; color: var(--fg3); margin-top: 6px; }
.ctl { display: flex; justify-content: center; gap: clamp(20px, 4vw, 44px); }
.ctl button { width: 64px; height: 64px; border-radius: 50%; display: grid; place-items: center; border: 1px solid var(--line2); transition: background .2s, transform .15s; }
.ctl button:active { transform: scale(.94); background: #1a1a19; }
.ctl svg { width: 26px; height: 26px; fill: var(--fg); }
#play { width: 76px; height: 76px; background: var(--fg); border-color: var(--fg); }
#play svg { fill: #000; width: 30px; height: 30px; }
#play .i-pause { display: none; } #play.is-playing .i-play { display: none; } #play.is-playing .i-pause { display: block; }

.lyrics { flex: 0 0 0; min-height: 0; overflow: hidden; position: relative; opacity: 0; transition: flex-basis .6s var(--ease), opacity .6s;
  -webkit-mask-image: linear-gradient(transparent, #000 20%, #000 80%, transparent); mask-image: linear-gradient(transparent, #000 20%, #000 80%, transparent); }
.lyrics.on { flex: 1 1 0; opacity: 1; }
.lyr-list { transition: transform .55s var(--ease); will-change: transform; }
.ly { font-size: clamp(19px, 3vh, 28px); font-weight: 500; color: var(--fg3); padding: .32em 9% .32em 0; line-height: 1.2; transform-origin: left center; transition: color .4s, transform .5s var(--ease), opacity .4s; opacity: .55; }
.ly[data-d="0"] { color: var(--fg); transform: scale(1.1); opacity: 1; }
.ly[data-d="1"] { opacity: .8; }

/* ---------- bottom ---------- */
.bottom { display: grid; grid-template-columns: auto minmax(0, 1.25fr) minmax(0, .9fr) auto; gap: clamp(14px, 2.4vw, 34px); align-items: center; border-top: 1px solid var(--line); padding-top: 1.6vh; }
.cell { min-width: 0; }
.main-line { font-size: clamp(22px, 3.6vh, 34px); font-weight: 300; line-height: 1.1; white-space: nowrap; }
.main-line .k { color: var(--fg2); font-size: .58em; font-weight: 500; margin-right: .35em; }
.main-line .sub { color: var(--fg2); font-size: .5em; margin-left: .6em; font-weight: 400; }
.cell .faint { font-size: clamp(13px, 1.9vh, 16px); margin-top: 4px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.note { display: inline-block; margin-top: 6px; border: 1px solid var(--line2); border-radius: 99px; padding: 2px 12px; font-size: 13px; color: var(--fg2); }
.sun { display: flex; align-items: center; gap: 14px; }
#sunArc { width: clamp(70px, 7.6vw, 96px); flex: none; }
.sbase { stroke: var(--line); stroke-width: 1; }
.sarc { fill: none; stroke: var(--fg3); stroke-width: 1.4; stroke-dasharray: 1 3.5; }
#sunDot { fill: var(--fg3); transition: fill .6s; }
#sunDot.up { fill: var(--fg); }
.pair { display: flex; gap: 16px; }
.pair b { display: block; font-size: clamp(20px, 3.2vh, 30px); font-weight: 400; }
.pair span { display: block; font-size: 13px; color: var(--fg3); margin-top: 2px; }

.actions { display: flex; gap: 8px; }
.btn { min-height: 56px; min-width: 56px; padding: 0 16px; border: 1px solid var(--line2); border-radius: 14px; display: inline-flex; align-items: center; justify-content: center; gap: 8px; font-size: 16px; font-weight: 500; transition: opacity .3s, background .2s; }
.btn svg { width: 22px; height: 22px; flex: none; }
.btn.icon { padding: 0; width: 56px; }
.btn.solid { background: var(--fg); color: #000; border-color: var(--fg); }
.btn:active { background: #1a1a19; } .btn.solid:active { background: var(--fg2); }
.btn:disabled { opacity: .28; pointer-events: none; }

/* ---------- sheets ---------- */
#scrim { position: fixed; inset: 0; background: rgba(0, 0, 0, .66); opacity: 0; pointer-events: none; transition: opacity .35s; z-index: 20; }
#scrim.open { opacity: 1; pointer-events: auto; }
.sheet {
  position: fixed; left: 50%; bottom: 0; width: min(680px, 94vw); max-height: 92vh; overflow: auto; z-index: 21;
  background: #080807; border: 1px solid var(--line2); border-bottom: 0; border-radius: 24px 24px 0 0;
  padding: 26px 28px max(26px, env(safe-area-inset-bottom)); transform: translate(-50%, 104%); transition: transform .45s var(--ease);
}
.sheet.wide { width: min(760px, 96vw); }
.sheet.open { transform: translate(-50%, 0); }
.sheet h2 { margin: 0 0 14px; font-size: 26px; font-weight: 500; }
.sheet p { margin: 0 0 12px; font-size: 16px; }
.sheet-actions { display: flex; gap: 12px; justify-content: flex-end; margin-top: 18px; }
.stats { display: grid; grid-template-columns: 1fr 1fr; gap: 20px 28px; margin: 0; }
.stats dt { font-size: 14px; color: var(--fg3); } .stats dd { margin: 4px 0 0; font-size: 34px; font-weight: 300; }
.grid { display: grid; grid-template-columns: repeat(6, 1fr); gap: 10px; }
.grid button { min-height: 64px; border: 1px solid var(--line2); border-radius: 14px; font-size: 24px; font-weight: 400; }
.grid button:active { background: var(--fg); color: #000; }
.rows { display: flex; flex-direction: column; }
.row { display: flex; align-items: center; justify-content: space-between; gap: 16px; min-height: 64px; border-bottom: 1px solid var(--line); font-size: 18px; }
.row.disabled { opacity: .35; pointer-events: none; }
.row em { font-style: normal; font-size: 14px; margin-left: 8px; }
.seg { display: inline-flex; border: 1px solid var(--line2); border-radius: 12px; overflow: hidden; flex: none; }
.seg button { min-height: 52px; min-width: 88px; padding: 0 18px; font-size: 16px; }
.seg button + button { border-left: 1px solid var(--line2); }
.seg button[aria-pressed="true"] { background: var(--fg); color: #000; }
.seg button:active { background: var(--fg2); color: #000; }
.row input[type="text"], .row input[type="password"] { min-height: 52px; width: 56%; background: transparent; border: 1px solid var(--line2); border-radius: 12px; color: var(--fg); padding: 0 16px; font: inherit; font-size: 17px; }
.row input[type="range"] { width: 56%; height: 52px; accent-color: var(--fg); }

/* ---------- overlays ---------- */
#start { position: fixed; inset: 0; z-index: 40; background: #000; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 20px; font-size: 22px; color: var(--fg2); transition: opacity .7s; }
#start svg { width: 72px; height: 72px; color: var(--fg); }
#start.gone { opacity: 0; pointer-events: none; }
#rotate { display: none; position: fixed; inset: 0; z-index: 50; background: #000; align-items: center; justify-content: center; text-align: center; font-size: 24px; color: var(--fg2); padding: 40px; }
@media (orientation: portrait) { #rotate { display: flex; } }

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
