:root {
  color-scheme: dark;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: #f1f7f7;
  background: #0b202e;
  --panel: #112c3c;
  --edge: #2b4d60;
  --muted: #c0d2db;
  --water: #96e1f1;
  --warm: #ffd98b;
}

*, *::before, *::after { box-sizing: border-box; }
body { margin: 0; min-width: 280px; background: radial-gradient(ellipse at 18% 6%, #15374b, #0b202e 68%); }
h1, h2, h3, p, dl, dd { margin: 0; }
a, button { color: inherit; }
button { font: inherit; }
[hidden] { display: none !important; }
:focus-visible { outline: 3px solid var(--warm); outline-offset: 3px; }

.shell { max-width: 1230px; margin-inline: auto; padding-inline: clamp(14px, 4vw, 42px); }
.site-head { background: #0b202e; border-bottom: 1px solid #244655; }
.site-inner { min-height: 52px; display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.brand { font-size: 1rem; font-weight: 800; letter-spacing: -.035em; text-decoration: none; white-space: nowrap; }
.brand span { color: var(--water); }
.site-inner nav { display: flex; gap: clamp(14px, 3vw, 27px); }
.site-inner nav a { display: grid; align-items: center; min-height: 44px; color: var(--muted); font-size: .8rem; text-decoration: none; }
.site-inner nav a:hover { color: #fff; text-decoration: underline; }

.lab { padding-block: clamp(21px, 3vw, 33px) 50px; }
.intro { display: flex; align-items: end; justify-content: space-between; gap: 10px; margin-bottom: 19px; }
h1 { font-size: clamp(2.35rem, 5.6vw, 4.1rem); line-height: 1; letter-spacing: -.066em; }
h1 span { display: block; margin-top: 6px; color: var(--water); font-size: .32em; letter-spacing: -.015em; }
.intro p { margin-top: 8px; color: var(--muted); font-size: clamp(.86rem, 2vw, 1rem); line-height: 1.45; }
.intro strong { color: #f8f2e2; }
.clock { display: grid; flex-shrink: 0; text-align: right; color: var(--muted); font-size: .78rem; }
.clock time { color: var(--warm); font-size: clamp(1.65rem, 4vw, 2.95rem); font-weight: 800; line-height: 1.08; letter-spacing: -.06em; font-variant-numeric: tabular-nums; }

.indicators { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 9px; margin-bottom: 13px; }
.indicators > div { min-height: 83px; padding: 10px 13px; border: 1px solid var(--edge); border-radius: 11px; background: #113044; }
dt { color: var(--muted); font-size: .78rem; }
.indicators dd { margin-top: 2px; font-size: clamp(1.17rem, 3vw, 1.6rem); font-weight: 780; line-height: 1.13; font-variant-numeric: tabular-nums; letter-spacing: -.04em; }
.indicators dd small { font-size: .68em; color: var(--muted); font-weight: 600; white-space: nowrap; }
.indicators > div > small { display: block; margin-top: 4px; color: var(--muted); font-size: .72rem; }
progress { display: block; width: 100%; appearance: none; border: 0; border-radius: 10px; overflow: hidden; height: 5px; background: #335365; }
progress::-webkit-progress-bar { background: #335365; }
progress::-webkit-progress-value { background: var(--fill, var(--water)); }
progress::-moz-progress-bar { background: var(--fill, var(--water)); }
#tank-progress { margin-top: 9px; }
#mission-progress { margin-top: 10px; --fill: var(--warm); }

.workspace { display: grid; grid-template-columns: minmax(0, 1fr) minmax(294px, .45fr); grid-template-rows: auto auto 1fr; align-items: start; gap: 13px; }
.controls { grid-area: 1 / 2; }
.scene { grid-area: 1 / 1 / span 2; }
.meter { grid-area: 2 / 2 / span 2; }
.history { grid-area: 3 / 1; }
.card { min-width: 0; background: var(--panel); border: 1px solid var(--edge); border-radius: 13px; padding: 14px; }
.card-head { display: flex; justify-content: space-between; align-items: baseline; gap: 9px; }
.card-head h2, .history summary { font-size: 1rem; font-weight: 750; letter-spacing: -.015em; }
.card-head > span, .pace { color: var(--muted); font-size: .76rem; }
.pace { margin-top: 6px; }
.load-states { display: grid; grid-template-columns: 1fr 1fr; gap: 7px; margin-block: 12px 10px; }
.load-states > div { padding: 7px 8px; background: #0d2534; border-radius: 7px; }
.load-states dd { margin-top: 2px; font-weight: 700; font-size: .84rem; line-height: 1.25; }
[data-condition="good"] { color: #ade7c0; }
[data-condition="danger"] { color: #ffbcad; }
[data-condition="warning"] { color: var(--warm); }
.actions, .result-actions { display: flex; flex-wrap: wrap; gap: 7px; }
.actions button { flex: 1 1 100px; }
.primary, .secondary { min-height: 44px; border: 1px solid #527080; border-radius: 8px; padding: 7px 10px; background: #1a3a4c; font-size: .83rem; font-weight: 750; cursor: pointer; }
.primary { border-color: var(--warm); background: var(--warm); color: #182831; }
.primary:hover:enabled { background: #fceac2; }
.secondary:not(.primary):hover:enabled { background: #255269; }
button:disabled { cursor: default; opacity: .55; }
.hint { min-height: 3.85em; margin-top: 9px; padding: 7px 9px; border: 1px solid #375b6b; border-radius: 7px; background: #122f3e; color: var(--muted); font-size: .82rem; line-height: 1.35; }
.hint[data-tone="good"] { color: #bfebcc; border-color: #417663; background: #194038; }
.hint[data-tone="warning"] { color: #ffe1a6; border-color: #896e44; background: #393227; }
.hint[data-tone="danger"] { color: #ffd3c8; border-color: #88594f; background: #3e2e2d; }
.link-button { min-height: 44px; padding: 5px 0 0; border: 0; background: transparent; color: var(--muted); font-size: .8rem; text-decoration: underline; text-underline-offset: 3px; cursor: pointer; }

.scene { overflow: hidden; padding: 0; }
.scene .card-head { align-items: center; padding: 2px 14px; min-height: 47px; }
.scene-tools { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: .76rem; }
.scene-tools .link-button { padding: 0; font-size: inherit; }
.diorama { position: relative; overflow: hidden; isolation: isolate; height: clamp(280px, 38vw, 425px); background: linear-gradient(168deg, #6f9eb5, #2b657f 62%, #164251); }
#scene-canvas, .scene-labels, .diagram { position: absolute; inset: 0; width: 100%; height: 100%; }
#scene-canvas { cursor: pointer; }
.scene-labels { pointer-events: none; }
.scene-labels span { position: absolute; transform: translate(-50%, -100%); padding: 4px 8px; border: 1px solid #a8d2df9c; border-radius: 6px; background: #102a3ae8; color: #fff; font-size: .7rem; font-weight: 730; white-space: nowrap; }
.scene-labels [data-selected] { background: var(--warm); color: #182831; border-color: var(--warm); }
.diorama[data-renderer="fallback"] :is(#scene-canvas, .scene-labels), .diorama[data-renderer="3d"] .diagram { display: none; }
.diagram { display: flex; flex-wrap: wrap; justify-content: center; align-content: center; gap: 9px; padding: 14px; }
.diagram div { padding: 8px 10px; background: #102a3a; border: 1px solid #699bb3; border-radius: 7px; overflow-wrap: anywhere; }
.diagram strong, .diagram span { display: block; font-size: .8rem; }
.diagram span { margin-top: 4px; color: var(--muted); font-size: .72rem; }
.components { display: flex; flex-wrap: wrap; gap: 3px; padding: 7px 9px; }
.components button { min-height: 44px; border: 1px solid transparent; border-radius: 7px; background: transparent; padding: 4px 8px; color: var(--muted); font-size: .75rem; font-weight: 670; cursor: pointer; }
.components [aria-pressed="true"] { background: #33423b; border-color: #9a8150; color: var(--warm); }
.components button:hover { border-color: #628093; }
.meter h3 { color: var(--water); font-size: 1.17rem; margin-top: 9px; }
.meter p { margin-top: 3px; color: var(--muted); font-size: .78rem; line-height: 1.42; }
.meter dl { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px; margin-top: 9px; }
.meter dl > div { background: #0d2534; border-radius: 7px; padding: 7px; }
.meter dd { margin-top: 2px; font-size: .91rem; font-weight: 750; font-variant-numeric: tabular-nums; }
.history summary { min-height: 30px; cursor: pointer; }
.chart-keys { display: flex; justify-content: space-between; gap: 8px; color: var(--water); font-size: .75rem; }
.chart-keys span + span { color: var(--warm); }
#history-chart { display: block; width: 100%; height: 132px; }
.muted { color: var(--muted); font-size: .78rem; line-height: 1.42; }
.events { list-style: none; margin: 0; padding: 0; }
.events li { display: flex; gap: 10px; padding-block: 5px; border-top: 1px solid var(--edge); color: var(--muted); font-size: .8rem; }
.events time { color: var(--warm); font-variant-numeric: tabular-nums; }

.results { margin-top: 13px; padding: clamp(12px, 2.4vw, 23px); }
.results .card-head h2 { font-size: clamp(1.05rem, 2.6vw, 1.4rem); }
.results > p { margin-top: 9px; line-height: 1.45; }
.comparison { margin-block: 11px; border: 1px solid var(--edge); border-radius: 8px; overflow: hidden; }
.comparison :is(.comparison-head, .comparison-row) { display: grid; grid-template-columns: 1.05fr 1fr 1fr; border-bottom: 1px solid var(--edge); }
.comparison :is(.comparison-head, .comparison-row) > * { min-width: 0; padding: 8px 10px; font-size: .85rem; line-height: 1.3; }
.comparison .comparison-head { background: #183b4e; font-weight: 760; }
.comparison small { color: var(--muted); font-size: .72rem; font-weight: 500; }
.comparison .comparison-row:last-child { border-bottom: 0; }
.comparison [role="cell"] { color: var(--muted); font-variant-numeric: tabular-nums; }
.result-actions { margin-top: 13px; }
.quick-controls { display: none; }

@media (max-width: 760px) {
  .workspace { display: flex; flex-direction: column; gap: 10px; }
  .workspace > * { width: 100%; }
  .diorama { height: clamp(212px, 64vw, 400px); }
  body[data-active="true"] .lab { padding-bottom: calc(105px + env(safe-area-inset-bottom)); }
  .quick-controls { display: block; position: fixed; z-index: 2; inset: auto 0 0; padding: 7px max(14px, env(safe-area-inset-right)) max(8px, env(safe-area-inset-bottom)) max(14px, env(safe-area-inset-left)); background: #0e2735; border-top: 1px solid #537487; }
  .quick-controls p { margin-bottom: 4px; font-size: .76rem; font-weight: 690; color: var(--muted); }
  .hint { min-height: 0; }
}

@media (max-width: 480px) {
  .site-inner { min-height: 46px; }
  .intro { margin-bottom: 12px; align-items: start; }
  .clock { margin-top: 3px; }
  .indicators { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px; margin-bottom: 9px; }
  .indicators > div { min-height: 60px; padding: 7px 9px; }
  #tank-progress { margin-top: 6px; }
  .card { border-radius: 10px; }
  .scene-labels span { padding: 3px 5px; font-size: .61rem; }
  .components { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); padding-inline: 6px; gap: 2px; }
  .components button { padding-inline: 2px; font-size: .71rem; }
  .comparison { display: grid; gap: 5px; border: 0; }
  .comparison .comparison-head { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
  .comparison .comparison-row { grid-template-columns: repeat(2, minmax(0, 1fr)); border: 1px solid var(--edge); border-radius: 7px; }
  .comparison .comparison-row:last-child { border-bottom: 1px solid var(--edge); }
  .comparison .comparison-row > strong { grid-column: 1 / -1; padding-bottom: 0; }
  .comparison [role="cell"]::before { display: block; margin-bottom: 2px; font-size: .69rem; font-weight: 760; color: var(--water); }
  .comparison [id^="your-"]::before { content: "Percobaanmu" / ""; }
  .comparison [id^="night-"]::before { content: "Jadwal malam" / ""; }
}
