/* Wiese · style.css (shell from nights 052–062) */
:root {
  --bg: #0b0f1a; --ui-text: #e8e3d6; --muted: #8d97ab; --amber: #f0b35b; --violet: #a98bff;
  --rabbit: #e4e1d6; --fox: #e0763a; --grass: #5fa37c;
  --panel-bg: rgba(9, 13, 24, 0.8); --panel-border: rgba(255, 255, 255, 0.1); --field: rgba(10, 14, 27, 0.92);
  --mono: ui-monospace, Menlo, "SF Mono", Consolas, "Liberation Mono", monospace;
  --dw: 0px;        /* width the chart drawer takes on the right (desktop, open) */
  --bar-h: 112px;   /* measured by app.js */
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; width: 100%; height: 100%; overflow: hidden; background: var(--bg); overscroll-behavior: none; }
body { font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; color: var(--ui-text); -webkit-tap-highlight-color: transparent;
  -webkit-user-select: none; user-select: none; }
button, input, select { font: inherit; color: inherit; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--amber); outline-offset: 2px; }
#cv:focus-visible { outline: none; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

#cv { position: fixed; left: 0; top: 0; width: 100vw; height: 100vh; height: 100dvh; display: block;
  touch-action: none; cursor: crosshair; background: var(--bg); }

a.home { position: fixed; top: calc(14px + env(safe-area-inset-top, 0px)); left: calc(14px + env(safe-area-inset-left, 0px)); z-index: 8;
  font-size: 12px; color: #8d9ab0; text-decoration: none; padding: 4px 7px; border-radius: 5px;
  background: rgba(6, 10, 22, 0.84); border: 1px solid var(--panel-border); }
a.home:hover, a.home:focus-visible { color: var(--amber); }

.stats { position: fixed; top: calc(14px + env(safe-area-inset-top, 0px)); right: calc(14px + var(--dw) + env(safe-area-inset-right, 0px)); z-index: 8;
  font-family: var(--mono); font-size: 11px; line-height: 1.5; color: var(--muted); padding: 4px 8px; border-radius: 6px;
  background: rgba(6, 10, 22, 0.84); border: 1px solid var(--panel-border); font-variant-numeric: tabular-nums; pointer-events: none;
  max-width: calc(100vw - var(--dw) - 140px); text-align: right; }
.stats b { color: var(--ui-text); font-weight: 500; }
.stats .r { color: var(--rabbit); }
.stats .f { color: var(--fox); }
.stats .w { color: var(--amber); }
.stats .note { color: var(--amber); }

.title-overlay { position: fixed; top: calc(14px + env(safe-area-inset-top, 0px)); left: calc((100vw - var(--dw)) / 2); transform: translateX(-50%); z-index: 9;
  text-align: center; pointer-events: none; opacity: 1; transition: opacity 1s ease; width: max-content;
  max-width: min(520px, calc(100vw - var(--dw) - 560px)); padding: 6px 18px; border-radius: 12px;
  background: rgba(8, 10, 18, 0.82); border: 1px solid var(--panel-border); }
.title-overlay.faded { opacity: 0; }
.title-overlay h1 { margin: 0; font-size: 17px; font-weight: 600; letter-spacing: 0.06em; color: #f0e2c4; text-shadow: 0 1px 12px rgba(0,0,0,0.95); }
.title-overlay p { margin: 1px 0 0; font-size: 11.5px; color: #b3bccb; text-shadow: 0 1px 10px rgba(0,0,0,0.95); }
@media (max-width: 80rem) {
  .title-overlay { top: calc(62px + env(safe-area-inset-top, 0px)); max-width: calc(100vw - var(--dw) - 28px); }
}

/* ---------- toolbar ---------- */
.bar { position: fixed; z-index: 8; left: calc((100vw - var(--dw)) / 2); transform: translateX(-50%); bottom: calc(12px + env(safe-area-inset-bottom, 0px));
  display: flex; flex-direction: column; align-items: stretch; gap: 5px; padding: 6px; border-radius: 11px;
  background: var(--panel-bg); border: 1px solid var(--panel-border); width: max-content; max-width: calc(100vw - var(--dw) - 24px); }
.row { display: flex; flex-wrap: wrap; justify-content: center; align-items: center; gap: 5px; }
.sep { width: 1px; align-self: stretch; background: var(--panel-border); margin: 0 3px; }
.btn { flex: 0 0 auto; min-height: 38px; min-width: 38px; padding: 0 10px; display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border: 1px solid var(--panel-border); background: rgba(18, 24, 38, 0.7); border-radius: 8px; font-size: 13px; color: var(--ui-text); cursor: pointer; white-space: nowrap;
  touch-action: manipulation; }
.btn:hover { border-color: rgba(255,255,255,0.24); }
.btn.tog[aria-pressed="true"] { color: var(--violet); border-color: rgba(169,139,255,0.6); background: rgba(30,24,48,0.75); }
.btn.mode[aria-pressed="true"] { color: #f6e6c2; border-color: rgba(240,179,91,0.75); background: rgba(44, 32, 16, 0.8); }
.btn[aria-expanded="true"] { color: var(--amber); border-color: rgba(240,179,91,0.6); }
.btn.warm.on { color: #10131c; background: #d99a4a; border-color: #d99a4a; }
.btn.cool.on { color: #0c1420; background: #8fb3d9; border-color: #8fb3d9; }
.btn.flash { color: var(--amber); border-color: rgba(240,179,91,0.7); }
.btn .short { display: none; }

/* ---------- panels ---------- */
.panel { position: fixed; z-index: 20; display: flex; flex-direction: column; border-radius: 12px; background: rgba(8, 12, 22, 0.95);
  border: 1px solid rgba(255,255,255,0.14); box-shadow: 0 10px 40px rgba(0,0,0,0.6); }
.help { top: calc(14px + env(safe-area-inset-top, 0px)); right: calc(14px + var(--dw) + env(safe-area-inset-right, 0px));
  max-height: calc(100vh - var(--bar-h) - 40px); max-height: calc(100dvh - var(--bar-h) - 40px); width: min(460px, calc(100vw - var(--dw) - 28px)); }
.inspector { top: calc(52px + env(safe-area-inset-top, 0px)); left: calc(14px + env(safe-area-inset-left, 0px)); width: 268px;
  max-height: calc(100vh - var(--bar-h) - 80px); max-height: calc(100dvh - var(--bar-h) - 80px); }
.inspector.right { left: auto; right: calc(14px + var(--dw) + env(safe-area-inset-right, 0px)); }
.msg.note { top: auto; bottom: calc(var(--bar-h) + 24px + env(safe-area-inset-bottom, 0px)); transform: translateX(-50%); pointer-events: none; font-size: 12px; padding: 7px 12px; }
.panel-head { display: flex; align-items: center; justify-content: space-between; padding: 6px 8px 6px 14px; border-bottom: 1px solid var(--panel-border); }
.panel-head h2 { margin: 0; font-size: 15px; font-weight: 600; letter-spacing: 0.04em; color: #f0e2c4; }
.panel-head .btn { min-height: 32px; padding: 0 10px; font-size: 12px; }
.panel-body { overflow: auto; padding: 6px 14px 14px; font-size: 12.5px; line-height: 1.45; -webkit-user-select: text; user-select: text; }
.panel-body h3 { margin: 12px 0 4px; font-size: 11px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--amber); font-weight: 600; }
.panel-body p { margin: 6px 0; color: #b3bccb; }
.panel-body dl { margin: 0; display: grid; grid-template-columns: max-content 1fr; gap: 3px 12px; }
.panel-body dt { font-family: var(--mono); font-size: 12px; color: var(--ui-text); }
.panel-body dd { margin: 0; color: var(--muted); }
.panel-body code { font-family: var(--mono); font-size: 12px; color: var(--ui-text); }

/* inspector body */
.ins-facts { display: grid; grid-template-columns: max-content 1fr; gap: 1px 10px; margin: 4px 0 8px; font-family: var(--mono); font-size: 11.5px; }
.ins-facts span:nth-child(odd) { color: var(--muted); }
.ins-gene { display: grid; grid-template-columns: 76px 1fr 44px; align-items: center; gap: 8px; margin: 3px 0; font-size: 11.5px; }
.ins-gene .n { color: var(--muted); }
.ins-gene .v { font-family: var(--mono); text-align: right; color: var(--ui-text); font-variant-numeric: tabular-nums; }
.gbar { position: relative; height: 8px; border-radius: 4px; background: rgba(255,255,255,0.08); overflow: visible; }
.gbar i { position: absolute; left: 0; top: 0; bottom: 0; border-radius: 4px; background: #8fa7c2; }
.gbar b { position: absolute; top: -3px; bottom: -3px; width: 2px; margin-left: -1px; background: var(--amber); border-radius: 1px; }
.ins-note { margin: 8px 0 0; font-size: 11px; color: var(--muted); }
.ebar { height: 6px; border-radius: 3px; background: rgba(255,255,255,0.08); margin-top: 3px; }
.ebar i { display: block; height: 100%; border-radius: 3px; background: #7fbf8e; }

/* ---------- chart drawer ---------- */
.drawer { position: fixed; z-index: 7; right: 0; top: 0; bottom: 0; width: 340px; overflow-y: auto; overflow-x: hidden;
  padding: calc(10px + env(safe-area-inset-top, 0px)) calc(12px + env(safe-area-inset-right, 0px)) 12px 12px;
  background: rgba(8, 11, 20, 0.92); border-left: 1px solid var(--panel-border); -webkit-overflow-scrolling: touch; overscroll-behavior: contain; }
.chart { margin: 0 0 10px; }
.chart h3 { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin: 0 0 4px; font-size: 11px; text-transform: uppercase;
  letter-spacing: 0.08em; color: var(--amber); font-weight: 600; }
.chart h3 label { cursor: default; }
.legend { text-transform: none; letter-spacing: 0; font-weight: 400; color: var(--muted); font-size: 11px; display: inline-flex; align-items: center; gap: 4px; }
.sw { display: inline-block; width: 9px; height: 3px; border-radius: 1px; margin-left: 4px; vertical-align: middle; }
.sw.g { background: var(--grass); height: 8px; opacity: 0.6; }
.sw.r { background: var(--rabbit); }
.sw.f { background: var(--fox); }
.chart canvas { display: block; width: 100%; height: 132px; border-radius: 6px; background: rgba(255,255,255,0.025); }
#chDrift { height: 168px; }
#chHist { height: 118px; }
select { font-size: 12px; text-transform: none; letter-spacing: 0; padding: 3px 6px; border-radius: 6px; border: 1px solid var(--panel-border);
  background: var(--field); color: var(--ui-text); }
.log { list-style: none; margin: 0; padding: 0; font-family: var(--mono); font-size: 11px; line-height: 1.5; color: #b3bccb; min-height: 6em; }
.log li { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.log .t { color: var(--muted); margin-right: 6px; }
.log .k-drought { color: #e3a65a; } .log .k-rain { color: #9cc1e8; } .log .k-extinct { color: #f08a7a; }
.log .k-migrants { color: #b8a6ff; } .log .k-record { color: #c9e3a0; }

.msg { position: fixed; z-index: 10; left: 50%; top: 50%; transform: translate(-50%, -50%); max-width: calc(100vw - 40px);
  font-family: var(--mono); font-size: 13px; line-height: 1.5; color: var(--ui-text); text-align: center; padding: 12px 16px; border-radius: 8px;
  background: rgba(6, 10, 22, 0.9); border: 1px solid var(--panel-border); }

@media (prefers-reduced-motion: reduce) { .title-overlay { transition: none; } }

/* ---------- below 60rem the drawer becomes a bottom sheet above the toolbar ---------- */
@media (max-width: 60rem) {
  .drawer { top: auto; left: 8px; right: 8px; width: auto; bottom: calc(var(--bar-h) + 14px + env(safe-area-inset-bottom, 0px));
    max-height: 44vh; max-height: 44dvh; border: 1px solid var(--panel-border); border-radius: 12px; padding: 8px 10px; }
  .chart canvas { height: 104px; }
  #chDrift { height: 132px; }
  #chHist { height: 96px; }
}

/* ---------- phone ---------- */
@media (max-width: 34rem) {
  a.home { top: calc(10px + env(safe-area-inset-top, 0px)); left: calc(10px + env(safe-area-inset-left, 0px)); }
  .stats { top: calc(10px + env(safe-area-inset-top, 0px)); right: calc(10px + env(safe-area-inset-right, 0px));
    max-width: calc(100vw - 122px); font-size: 10px; line-height: 1.4; padding: 3px 6px; }
  .title-overlay { top: calc(52px + env(safe-area-inset-top, 0px)); left: 10px; right: 10px; transform: none; width: auto; max-width: none;
    padding: 5px 12px; border-radius: 9px; background: rgba(8,10,18,0.8); transition: opacity 0.5s ease; }
  .title-overlay h1 { font-size: 15px; }
  .title-overlay p { font-size: 10.5px; margin-top: 1px; }
  .bar { left: calc(6px + env(safe-area-inset-left, 0px)); right: calc(6px + env(safe-area-inset-right, 0px)); transform: none; width: auto;
    bottom: calc(6px + env(safe-area-inset-bottom, 0px)); max-width: none; gap: 4px; padding: 5px; }
  .row { gap: 4px; flex-wrap: nowrap; justify-content: space-between; }
  .sep { display: none; }
  .btn { flex: 1 1 0; min-width: 0; min-height: 38px; padding: 0 1px; font-size: 11px; }
  .btn .long { display: none; }
  .btn .short { display: inline; }
  .inspector { top: calc(48px + env(safe-area-inset-top, 0px)); left: 8px; right: 8px; width: auto; max-height: 52vh; max-height: 52dvh; }
  .inspector .panel-body { padding: 4px 12px 10px; }
  .help { top: auto; bottom: calc(var(--bar-h) + 12px + env(safe-area-inset-bottom, 0px)); right: 8px; left: 8px; width: auto;
    max-height: 56vh; max-height: 56dvh; }
  .drawer { left: 6px; right: 6px; bottom: calc(var(--bar-h) + 10px + env(safe-area-inset-bottom, 0px)); max-height: 36vh; max-height: 36dvh; padding: 6px 8px; }
  .chart { margin-bottom: 6px; }
  .chart canvas { height: 84px; }
  #chDrift { height: 108px; }
  #chHist { height: 80px; }
  .inspector.right { left: 8px; right: 8px; }
}
@media (max-width: 34rem) and (prefers-reduced-motion: reduce) { .title-overlay { transition: none; } }
