/* Dark-first. Hierarchy comes from surface tone and spacing, not outlines.
   Mono and uppercase are rationed: key-caps, display codes, counts, area names.
   Palette read off the instrument — black body, yellow base wrap, red LED,
   white primary silkscreen, amber SHIFT silkscreen. */
:root {
  --bg: #08080A;
  --s1: #121216;
  --s2: #1B1B21;
  --s3: #24242C;
  --hair: rgba(255, 255, 255, .06);

  --fg: #F4F4F6;
  --fg2: #9A9AA4;
  --fg3: #5E5E68;

  /* Three jobs, three colours, and they never borrow from each other.

     THE INSTRUMENT — bright, inline, inside an answer. This is the panel's own
     code: white silkscreen is a button, amber silkscreen is the SHIFT layer, the
     display is red. Faithful, and it is what makes an answer readable at a glance.
     THE ACCENT — yellow, and only ever "where you are": the current area, focus,
     the caret. Nothing else may use it, or it stops meaning anything.
     STORAGE — the 3px edge. Same hue families so the sense carries, but muted, so
     the structural layer sits below the content layer instead of fighting it. */

  --amber: #F5A524;
  --led: #FF4B33;
  --yellow: #E3E62B;

  --sc-pattern: #4E7BC4;
  --sc-sample: #C07D1E;
  --sc-efct: #7E64C0;
  --sc-none: #C0453A;

  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, monospace;
  --dock: 80px;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html { background: var(--bg); }

body {
  margin: 0;
  padding-bottom: calc(var(--dock) + env(safe-area-inset-bottom));
  background: var(--bg);
  color: var(--fg);
  font: 400 16px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: none;
}

button { font: inherit; color: inherit; background: none; border: 0; padding: 0; }

/* ---------- area rail ---------- */

#rail {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  gap: 2px;
  padding: max(10px, env(safe-area-inset-top)) 10px 10px;
  background: rgba(8, 8, 10, .88);
  backdrop-filter: saturate(150%) blur(16px);
  overflow-x: auto;
  scrollbar-width: none;
}
#rail::-webkit-scrollbar { display: none; }

/* Glyph only, except for the area you are in — compact, and the board teaches
   the glyphs by showing each one next to its name. */
.rl {
  flex: none;
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 8px 10px;
  color: var(--fg3);
  border-radius: 999px;
  white-space: nowrap;
  transition: color .15s, background .15s;
}
.rl svg { width: 17px; height: 17px; flex: none; }
.rl b {
  display: none;
  font-size: 12.5px;
  font-weight: 600;
  letter-spacing: .1em;
}
.rl.on { color: var(--yellow); background: rgba(227, 230, 43, .12); padding-right: 13px; }
.rl.on b { display: block; }

/* ---------- layout ---------- */

#view { padding: 6px 14px 0; }

.lab {
  font-size: 12px;
  font-weight: 500;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--fg3);
  margin: 26px 2px 10px;
}

/* ---------- board ---------- */

.area {
  margin: 30px 0 0;
  padding-top: 26px;
  border-top: 1px solid var(--hair);
  scroll-margin-top: 56px;
}
.area:first-of-type { margin-top: 18px; padding-top: 0; border-top: 0; }

.ahead { display: flex; align-items: center; gap: 11px; margin-bottom: 12px; }
.ahead svg { width: 21px; height: 21px; flex: none; color: var(--fg); }
.ahead h2 {
  margin: 0;
  font-size: 16px;
  font-weight: 600;
  letter-spacing: .17em;
  text-transform: uppercase;
  color: var(--fg);
}
.goals {
  display: flex;
  gap: 7px;
  overflow-x: auto;
  padding: 2px 14px 4px;
  margin: 0 -14px;
  scrollbar-width: none;
}
.goals::-webkit-scrollbar { display: none; }
.goals a {
  flex: none;
  padding: 9px 14px;
  font-size: 14px;
  color: var(--fg);
  background: var(--s1);
  border-radius: 999px;
  text-decoration: none;
  white-space: nowrap;
}
.goals a:active { background: var(--s2); }

.tiles { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }

.refs {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 6px 10px;
  margin: 11px 2px 0;
  font-size: 13px;
}
.refs b {
  font-size: 11px;
  font-weight: 500;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--fg3);
}
.refs a { color: var(--fg2); text-decoration: none; }
.refs a i { font-style: normal; color: var(--fg3); margin-left: 4px; font-size: 11px; }

.tile {
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  min-height: 62px;
  padding: 12px 13px 10px;
  background: var(--s1);
  border-radius: 14px;
  text-decoration: none;
  color: var(--fg);
  transition: background .15s;
}
.tile:active { background: var(--s2); }
.tile b { font-size: 15px; font-weight: 500; line-height: 1.3; }
.tile span {
  align-self: flex-end;
  font: 500 11.5px/1 var(--mono);
  color: var(--fg3);
  margin-top: 8px;
}

.tile.lead {
  grid-column: 1 / -1;
  min-height: 76px;
  padding: 15px 16px 13px;
  background: var(--s2);
}
.tile.lead b { font-size: 18px; letter-spacing: -.01em; }
.tile.lead span { position: absolute; top: 15px; right: 15px; margin: 0; }

/* ---------- section view ---------- */

.shead { padding: 10px 0 20px; }
.back {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  margin-bottom: 14px;
  font-size: 13px;
  font-weight: 500;
  letter-spacing: .06em;
  color: var(--fg2);
}
.back svg { width: 14px; height: 14px; }
.shead h1 {
  display: flex;
  align-items: baseline;
  gap: 10px;
  margin: 0;
  font-size: 27px;
  font-weight: 600;
  letter-spacing: -.015em;
  line-height: 1.15;
}
.shead h1 span { font: 500 13px/1 var(--mono); color: var(--fg3); }
.shead p { margin: 11px 0 0; font-size: 14.5px; line-height: 1.55; color: var(--fg2); }

.scope {
  display: flex; align-items: center; gap: 9px;
  margin: 12px 0 0;
  font-size: 12.5px;
  color: var(--fg3);
}
.scope::before { content: ""; flex: none; width: 3px; height: 13px; border-radius: 2px; }
.scope.sc-pattern::before { background: var(--sc-pattern); }
.scope.sc-sample::before  { background: var(--sc-sample); }
.scope.sc-efct::before    { background: var(--sc-efct); }
.scope.sc-none::before    { background: var(--sc-none); }

/* ---------- rows ---------- */

.row {
  position: relative;
  padding: 14px 16px;
  margin-bottom: 8px;
  background: var(--s1);
  border-radius: 14px;
}
.row.sc-pattern { box-shadow: inset 3px 0 0 var(--sc-pattern); }
.row.sc-sample  { box-shadow: inset 3px 0 0 var(--sc-sample); }
.row.sc-efct    { box-shadow: inset 3px 0 0 var(--sc-efct); }
.row.sc-none    { box-shadow: inset 3px 0 0 var(--sc-none); }
.row.top { background: var(--s2); }

.rq { font-size: 16.5px; line-height: 1.35; font-weight: 500; letter-spacing: -.005em; }

.conf {
  display: inline-block;
  margin-top: 10px;
  padding: 6px 11px;
  font-size: 11px;
  font-weight: 500;
  letter-spacing: .05em;
  color: var(--fg2);
  background: var(--s2);
  border-radius: 7px;
  box-shadow: inset 0 0 0 1px var(--hair);
}
.conf.on { color: var(--fg); background: var(--s3); box-shadow: none; }

#toast {
  position: fixed;
  left: 14px; right: 14px;
  bottom: calc(var(--dock) + 14px + env(safe-area-inset-bottom));
  z-index: 40;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 13px 10px 13px 16px;
  font-size: 14px;
  color: var(--fg);
  background: var(--s3);
  border-radius: 13px;
  box-shadow: 0 8px 28px rgba(0, 0, 0, .55);
}
#toast[hidden] { display: none; }
#toast span { flex: 1; }
#toast button {
  flex: none;
  padding: 8px 13px;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: .04em;
  color: var(--fg);
  border-radius: 9px;
}

.range {
  margin-top: 7px;
  font: 500 12px/1.4 var(--mono);
  letter-spacing: .03em;
  color: var(--fg2);
}
.led.code { margin-left: 8px; vertical-align: 1px; }

.todo {
  display: flex;
  align-items: baseline;
  margin: 22px 2px 0;
  font-size: 13.5px;
  color: var(--fg2);
  text-decoration: none;
}
.todo i { margin-left: auto; font-style: normal; color: var(--fg3); }

/* an instruction is spoken in the app's full voice; an explanation steps back */
.ra { margin-top: 9px; font-size: 14.5px; line-height: 1.85; }
.ra.fact { color: var(--fg2); }
.ra.tall { line-height: 2.2; }

.rn { margin-top: 9px; font-size: 13px; line-height: 1.45; color: var(--fg3); }

/* A manual entry not yet tried on the unit. Far enough from the title to read as a
   mark rather than punctuation, and explained once in the key on the board. */
.unv {
  display: inline-block;
  width: 6px; height: 6px;
  margin-left: 11px;
  vertical-align: 3px;
  border-radius: 50%;
  background: var(--fg2);
}

.rsec {
  display: inline-block;
  margin-top: 10px;
  font-size: 12px;
  font-weight: 500;
  letter-spacing: .04em;
  color: var(--fg3);
  text-decoration: none;
}

/* ---------- key-caps, screens, LED ---------- */

kbd {
  display: inline-block;
  padding: 3px 7px 4px;
  font: 500 12px/1.2 var(--mono);
  letter-spacing: .02em;
  color: #fff;
  background: var(--s3);
  border-radius: 6px;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .09), 0 2px 0 rgba(0, 0, 0, .55);
  white-space: nowrap;
  vertical-align: 2px;
}
kbd s {
  display: block;
  margin-top: 2px;
  font-size: 8.5px;
  letter-spacing: .04em;
  color: var(--amber);
  text-decoration: none;
}

.scr {
  display: inline-block;
  padding: 3px 7px;
  font: 500 11.5px/1.2 var(--mono);
  font-style: normal;
  letter-spacing: .05em;
  color: var(--amber);
  background: rgba(245, 165, 36, .1);
  border-radius: 6px;
  white-space: nowrap;
  vertical-align: 2px;
}

.led {
  display: inline-block;
  padding: 3px 7px;
  font: 500 12px/1.2 var(--mono);
  font-style: normal;
  letter-spacing: .03em;
  color: var(--led);
  background: rgba(255, 75, 51, .1);
  border-radius: 6px;
  text-shadow: 0 0 9px rgba(255, 75, 51, .5);
  white-space: nowrap;
  vertical-align: 2px;
}

.op { font-style: normal; color: var(--fg3); padding: 0 2px; }
.sep { font-style: normal; color: var(--fg3); padding: 0 4px; }
.arw { font-style: normal; color: var(--fg2); }

/* ---------- results ---------- */

.pills {
  display: flex;
  gap: 7px;
  overflow-x: auto;
  padding: 4px 14px 14px;
  margin: 0 -14px;
  scrollbar-width: none;
}
.pills::-webkit-scrollbar { display: none; }

.pill {
  flex: none;
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 9px 14px;
  font-size: 14px;
  font-weight: 500;
  color: var(--fg2);
  background: var(--s1);
  border-radius: 999px;
  white-space: nowrap;
}
.pill span { font: 500 11.5px/1 var(--mono); color: var(--fg3); }
.pill.on { color: var(--yellow); background: rgba(227, 230, 43, .13); }
.pill.on span { color: var(--yellow); opacity: .7; }

.ghead {
  display: flex;
  align-items: baseline;
  gap: 9px;
  margin: 26px 3px 11px;
  font-size: 13.5px;
  font-weight: 600;
  letter-spacing: .02em;
  color: var(--fg);
}
.ghead span { font: 500 11.5px/1 var(--mono); color: var(--fg3); }
.gdesc { margin: -4px 3px 12px; font-size: 13.5px; line-height: 1.5; color: var(--fg3); }

.more {
  display: block;
  width: 100%;
  padding: 13px;
  margin-bottom: 8px;
  font-size: 13.5px;
  font-weight: 500;
  color: var(--fg2);
  background: var(--s1);
  border-radius: 14px;
}

.empty { padding: 26px 4px; font-size: 15.5px; line-height: 1.65; color: var(--fg2); }
.empty b { color: var(--fg); font-weight: 500; }

.chipline { display: flex; flex-wrap: wrap; gap: 7px; }
.chip {
  max-width: 100%;
  padding: 9px 13px;
  font-size: 14px;
  color: var(--fg2);
  background: var(--s1);
  border-radius: 999px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ---------- legend + footer ---------- */

.legend { display: flex; flex-wrap: wrap; gap: 8px 16px; margin: 2px 2px 0; }
.legend span { display: flex; align-items: center; gap: 7px; font-size: 12.5px; color: var(--fg2); }
.legend i { flex: none; width: 3px; height: 13px; border-radius: 2px; }
.legend i.dot { width: 6px; height: 6px; border-radius: 50%; background: var(--fg2); }

.foot {
  display: flex; align-items: center; justify-content: space-between;
  margin: 34px 2px 10px;
  font-size: 12.5px;
  color: var(--fg3);
}
.foot label { display: flex; align-items: center; gap: 8px; }
.foot input { width: 16px; height: 16px; accent-color: var(--fg3); }
.foot span { font: 500 11.5px/1 var(--mono); }

/* ---------- dock ---------- */

#dock {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  z-index: 30;
  padding: 12px 14px calc(12px + env(safe-area-inset-bottom));
  background: linear-gradient(to top, var(--bg) 62%, rgba(8, 8, 10, 0));
}

#field {
  position: relative;
  display: flex;
  align-items: center;
  background: var(--s2);
  border-radius: 15px;
  box-shadow: 0 0 0 1px var(--hair);
}
#field:focus-within { box-shadow: 0 0 0 1.5px var(--yellow); }
#field > svg { flex: none; width: 17px; height: 17px; margin-left: 15px; color: var(--fg3); }

#q {
  flex: 1;
  min-width: 0;
  height: 52px;
  padding: 0 8px 0 11px;
  font-size: 16px;
  color: var(--fg);
  background: none;
  border: 0;
  appearance: none;
  caret-color: var(--yellow);
}
#q:focus { outline: none; }
#q::placeholder { color: var(--fg3); }
#q::-webkit-search-cancel-button { display: none; }

#clear {
  flex: none;
  width: 44px; height: 44px;
  margin-right: 4px;
  font-size: 22px;
  color: var(--fg2);
  display: none;
}
#clear.on { display: block; }
