/* Allo by Josh Puckett (https://allo.joshpuckett.me), SIL Open Font License 1.1, see fonts/OFL.txt.
   "Friendly" build: variable weight + optical size, roundness fixed at 50, about half the size. */
@font-face {
  font-family: "Allo";
  src: url("fonts/AlloVariableFriendly.woff2") format("woff2");
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}

:root {
  --page: #fdfdfd;
  --card: #121212;
  --panel: #1a1a1a;
  --row: #161616;
  --input: #0d0d0d;
  --line: #262626;
  --line-strong: #2e2e2e;
  --text: #ececec;
  --muted: #8b8b8b;
  --faint: #5c5c5c;
  --blue: #379efa;
  --green: #35da67;
  --pink: #fe57b2;
  --purple: #ac6eff;
  --orange: #fb8419;
  --ease-out: cubic-bezier(.23, 1, .32, 1);
  --ease-in-out: cubic-bezier(.77, 0, .175, 1);
  --ease-drawer: cubic-bezier(.32, .72, 0, 1);
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--page);
  color: var(--text);
  font-family: "Allo", ui-sans-serif, system-ui, -apple-system, "SF Pro Text", sans-serif;
  font-size: 14px;
  line-height: 20px;
  -webkit-font-smoothing: antialiased;
}
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; }
.muted { color: var(--muted); }
.tnum { font-variant-numeric: tabular-nums; }

.stage {
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 24px 16px;
}

/* ---------- Card ---------- */
.card {
  contain: layout paint;
  width: min(620px, 100%);
  background: var(--card);
  border-radius: 22px;
  box-shadow:
    0 0 0 1px rgba(0,0,0,.04),
    0 2px 4px rgba(0,0,0,.06),
    0 18px 40px -8px rgba(0,0,0,.28);
  overflow: hidden;
}
.card-inner { padding: 12px 12px 0; }

.i {
  width: 16px; height: 16px; flex: none;
  fill: none; stroke: currentColor; stroke-width: 1.75;
  stroke-linecap: round; stroke-linejoin: round;
}

/* collapsible wrappers (height animated from JS) */
.collapse { overflow: hidden; }

/* ---------- Panel ---------- */
.panel {
  background: var(--panel);
  border: 1px solid #222;
  border-radius: 16px;
  padding: 6.5px 10px 8px 9.5px;
  margin-bottom: 11px;
  font-size: 13px;
}
.panel-head {
  display: flex; align-items: center; justify-content: space-between;
  height: 26px; padding-inline: 2px 1px;
  transition: opacity .18s var(--ease-out);
}
/* header steps back while the callout is up (fully when the label sits inside the header row) */
.panel-head.dim { opacity: .3; transition-duration: .12s; }
.panel-head.away { opacity: 0; transition-duration: .12s; }

/* ---------- Segment callout (leader line + diamond + label) ---------- */
.callout { position: fixed; inset: 0; pointer-events: none; z-index: 9; }
.callout-svg { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; }
#coPath { fill: none; stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; transition: stroke .2s ease; }
#coRect { transform-box: fill-box; transform-origin: center; transform: rotate(45deg); transition: fill .2s ease; }
.callout-pos { position: absolute; left: 0; top: 0; will-change: transform; }
.callout-text { white-space: nowrap; }
.co-t1 { font-size: 13.2px; line-height: 16px; color: #161616; font-weight: 500; }
.co-v { margin-inline-start: 7px; color: #8a8a8a; font-weight: 400; font-variant-numeric: tabular-nums; }
.co-t2 { font-size: 11.6px; line-height: 15px; color: #7a7a7a; font-variant-numeric: tabular-nums; margin-top: 1px; }
/* fallback when there's no room above the card: label sits in the dark header row */
.callout.inside .co-t1 { color: var(--text); }
.callout.inside .co-v, .callout.inside .co-t2 { color: var(--muted); }
.callout.flip .callout-text { text-align: right; }
.panel-title { display: inline-flex; align-items: center; gap: 7px; color: var(--text); font-size: 13.2px; }
.panel-title .i { color: #9a9a9a; width: 14px; height: 14px; stroke-width: 2; }

.bar {
  position: relative;
  height: 45.5px;
  touch-action: pan-y;              /* horizontal finger drags scrub the bar instead of panning */
  -webkit-user-select: none; user-select: none;
  -webkit-touch-callout: none;
  margin-top: 6.5px;
  margin-inline: .5px 0;
  border-radius: 7px;
}
.bar canvas { position: absolute; display: block; }
#barCanvas { inset: 0; width: 100%; height: 100%; z-index: 1; }
/* outer bloom: pre-blurred sprites drawn into a small canvas under the bar (no live CSS filter) */
#barGlow {
  inset: -18px; width: calc(100% + 36px); height: calc(100% + 36px);
  pointer-events: none;
  z-index: 0;
}

.legend {
  list-style: none; margin: 9.25px 0 0; padding: 0; font-size: 13.2px;
  display: grid; grid-template-columns: 1fr 1fr; column-gap: 12px; row-gap: 0;
}
.legend li {
  display: flex; align-items: center; gap: 0;
  height: 26.3px; padding: 0 5px 0 4px;
  border-radius: 6px;
  color: var(--text);
  cursor: default;
  transition: background-color .15s ease;
}
.legend .sw { width: 6.5px; height: 6.5px; border-radius: 1.5px; margin-right: 9px; flex: none; }
.legend .lbl { flex: 1; }
.legend .val { color: var(--muted); font-variant-numeric: tabular-nums; }

.panel-foot {
  display: flex; align-items: center; justify-content: space-between;
  margin-top: 9.5px; height: 27px; padding-left: 6px; font-size: 12.8px;
}
.msgs { position: relative; }
.compact {
  height: 27px; padding: 0 10px; border-radius: 7px;
  background: #262626; color: var(--text);
  display: inline-flex; align-items: center; gap: 6px;
  transition: background-color .15s ease, color .2s ease, transform .16s var(--ease-out);
}
.compact:active { transform: scale(.97); }
.compact[disabled] { cursor: default; background: #212121; color: var(--faint); }
.compact[disabled] .muted { color: #4a4a4a; }
.compact[disabled]:active { transform: none; }

/* ---------- Tool rows ---------- */
.rows { display: flex; flex-direction: column; }
.row-wrap { overflow: hidden; }
.row {
  display: flex; align-items: center;
  height: 31px; margin-bottom: 5px;
  padding: 0 8.5px 0 8px;
  font-size: 13.6px;
  background: var(--row);
  border: 1px solid #222;
  border-radius: 10px;
  white-space: nowrap;
}
.rows .row-wrap:last-child .row { margin-bottom: 10px; }
.row .i { margin-right: 11px; transition: opacity .3s ease; }
.row .name { color: var(--text); font-weight: 500; margin-right: 9px; transition: color .3s ease; }
.row .detail { color: var(--muted); flex: 1; overflow: hidden; text-overflow: ellipsis; transition: color .3s ease; }
.row .end { flex: none; display: grid; place-items: center end; min-width: 16px; }
.row .num { font-variant-numeric: tabular-nums; transition: color .35s ease; }
.row.done .name { color: #6d6d6d; }
.row.done .detail { color: #4e4e4e; }
.row.done .i { opacity: .45; }
.row.done.settled .num { color: #4e4e4e !important; }

.spin { width: 13.5px; height: 13.5px; animation: spin .75s linear infinite; }
.spin circle { fill: none; stroke-width: 1.6; }
.spin .t { stroke: #333; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Input ---------- */
.input {
  display: flex; align-items: center;
  height: 49px;
  background: var(--input);
  border: 1px solid #2a2a2a;
  border-radius: 14px;
  padding: 0 9px 0 11px;
  transition: border-color .2s ease;
}
.input:focus-within { border-color: #343434; }
.icon-btn {
  width: 28px; height: 28px; display: grid; place-items: center;
  border-radius: 8px; color: #d9d9d9;
  transition: background-color .15s ease, color .15s ease, transform .16s var(--ease-out);
}
.icon-btn:active { transform: scale(.95); }
.icon-btn .i { width: 17px; height: 17px; }
.icon-btn.dim { color: #6a6a6a; margin-right: 15px; }
.icon-btn.plus .i { width: 24px; height: 24px; stroke-width: 1.5; }
.input > .icon-btn:first-child { margin-right: 13px; }

.field { position: relative; flex: 1; height: 100%; }
.field input {
  width: 100%; height: 100%;
  background: transparent; border: 0; outline: 0;
  color: var(--text); caret-color: #f2f2f2;
  font: inherit; font-size: 15.2px; padding: 0;
}
.field input::placeholder { color: #6b6b6b; }
.field.busy input { visibility: hidden; }
.fake-caret {
  position: absolute; left: 0; top: 50%;
  width: 1.5px; height: 18px; margin-top: -9px;
  background: var(--text); border-radius: 1px;
  pointer-events: none;
  animation: caret-blink 1.06s steps(1, end) infinite;
}
.fake-caret.typing { animation: none; }
@keyframes caret-blink { 50% { opacity: 0; } }
.status { position: absolute; inset: 0; pointer-events: none; font-size: 15.2px; }
.status span {
  position: absolute; left: 0; top: 50%; transform: translateY(-50%);
  white-space: nowrap; color: #747474;
}
.status b { font-weight: 400; color: var(--text); }

/* ---------- Footer ---------- */
.foot {
  display: flex; align-items: center; justify-content: flex-end;
  height: 44px; gap: 4px;
  padding-right: 0; margin-right: -1px;
}
.chip {
  height: 28px; padding: 0 10px; border-radius: 8px;
  display: inline-flex; align-items: center; gap: 9px;
  color: var(--text); font-size: 14.3px;
  transition: background-color .15s ease, transform .16s var(--ease-out);
}

.chip:active { transform: scale(.97); }
.chip + .chip { margin-left: 0; }
.ring-btn {
  width: 30px; height: 30px; margin-left: 11px;
  display: grid; place-items: center; border-radius: 8px;
  position: relative;
  transition: background-color .15s ease, transform .16s var(--ease-out);
}
.ring-btn:active { transform: scale(.95); }
.ring-btn svg { width: 23px; height: 23px; transform: rotate(-90deg); position: relative; overflow: visible; }
.ring-track { fill: none; stroke: #2b2b2b; stroke-width: 2.3; }
.ring-arc {
  fill: none; stroke: var(--blue); stroke-width: 2.3; stroke-linecap: butt;
}
/* incoming tokens: drawn in the category colour at the arc's leading edge, then folded into blue */
.ring-delta { fill: none; stroke-width: 2.3; stroke-linecap: butt; }

/* ---------- FX + chrome ---------- */
#fx { position: fixed; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 10; }
.replay {
  position: fixed; top: 14px; right: 14px;
  font-size: 13px; color: #a3a3a3; padding: 6px 12px; border-radius: 999px;
  transition: color .15s ease, background-color .15s ease;
}

:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; }
.field input:focus-visible { outline: none; }

@media (max-width: 520px) {
  .legend { grid-template-columns: 1fr; }
  /* 16px stops iOS from zooming the page when the input is focused */
  .field input, .status { font-size: 16px; }
  .foot .chip:first-child .muted { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  .spin { animation-duration: 2.4s; }
}

@media (hover: hover) and (pointer: fine) {
  .legend li:hover { background: #222; }
  .compact:not([disabled]):hover { background: #2d2d2d; }
  .icon-btn:hover { background: #1c1c1c; }
  .chip:hover { background: #1c1c1c; }
  .ring-btn:hover { background: #222; }
  .replay:hover { color: #3a3a3a; background: #f0f0f0; }
}
