/* 4,75 - components. */

/* ---------------------------------------------------------------- shell */

.app {
  position: fixed;
  inset: 0;
  display: grid;
  grid-template-columns: minmax(14rem, 21vw) 1fr minmax(14rem, 21vw);
  grid-template-rows: auto 1fr auto;
  padding: var(--pad);
  gap: var(--pad);
}
.app[hidden] { display: none; }

.status {
  grid-column: 1 / -1;
  grid-row: 1;
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
}

/* Deliberately quiet: you should be able to ignore it and just type. */
.status__avg {
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
  font-size: 0.9375rem;
  font-weight: 400;
  letter-spacing: 0.01em;
  color: var(--dim);
}
.status__avg #avgNow { color: var(--fg); font-weight: 500; }
.status__sep { color: var(--faint); }
.status__meta { display: flex; align-items: center; gap: 0.75rem; }

.sync {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--faint);
  transition: background var(--t-small) var(--glide);
}
.sync[data-state="saving"] { background: var(--fg); }
.sync[data-state="local"]  { background: var(--red-dim); }

/* ---------------------------------------------------------------- stage */

/* Three rows, and the middle one is the line. Whatever the entry step puts
   above or below it, the line itself never moves off the optical centre. */
.stage {
  grid-column: 2;
  grid-row: 2;
  display: grid;
  grid-template-rows: 1fr auto 1fr;
  justify-items: center;
  min-width: 0;
  min-height: 0;
}
.stage__top {
  align-self: end;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.875rem;
  width: 100%;
  padding-bottom: 1.25rem;
}
.stage .hint { align-self: start; padding-top: 1.5rem; }

.crumbs {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  min-height: 1.25rem;
  font-size: 0.75rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--dim);
}
.crumbs span + span::before {
  content: "·";
  margin-right: 0.5rem;
  color: var(--faint);
}

/* Fixed height so the layout never jumps between an empty screen and a
   two-digit grade - the number arrives, nothing else moves. */
.field-wrap {
  position: relative;
  width: 100%;
  height: clamp(5.5rem, 17vh, 11rem);
}

.field {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  background: none;
  border: 0;
  text-align: center;
  color: var(--fg);
  caret-color: var(--fg);
  font-variant-numeric: tabular-nums;
  transition: font-size var(--t-small) var(--glide);
}
.field::placeholder { color: var(--faint); }
.field:focus { outline: none; }

/* Typography changes shape with size: huge type gets tight tracking and
   near-zero leading, text-sized states relax back toward normal. */
.stage[data-state="idle"]  .field,
.stage[data-state="grade"] .field {
  font-size: clamp(5rem, 19vw, 14rem);
  font-weight: 200;
  letter-spacing: -0.045em;
  line-height: 0.88;
}
.stage[data-state="name"] .field,
.stage[data-state="date"] .field {
  font-size: clamp(1.75rem, 4.5vw, 3rem);
  font-weight: 300;
  letter-spacing: -0.015em;
  line-height: 1.15;
}

/* ------------------------------------------------- the line (signature) */
/* One hairline across the middle. It is not decoration: it is the 1-6
   scale, and the dot on it is where you actually stand. */

.scale {
  position: relative;
  width: min(46rem, 100%);
  height: 26px;
}
.scale__rail {
  position: absolute;
  top: 50%;
  left: 0; right: 0;
  height: 1px;
  background: linear-gradient(90deg,
    transparent, var(--hair) 12%, var(--hair) 88%, transparent);
}
.scale__target {
  position: absolute;
  top: 50%;
  width: 1px;
  height: 11px;
  margin-top: -5px;
  background: var(--faint);
}
.scale__target::after {
  content: attr(data-label);
  position: absolute;
  top: 15px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 0.625rem;
  letter-spacing: 0.12em;
  color: var(--faint);
  font-variant-numeric: tabular-nums;
}
.scale__dot,
.scale__ghostdot {
  position: absolute;
  top: 50%;
  left: 0;
  width: 7px; height: 7px;
  margin: -3.5px 0 0 -3.5px;
  border-radius: 50%;
  background: var(--fg);
  will-change: transform;
}
.scale__dot[data-ok="false"] { background: var(--red); }
.scale__dot[data-has="false"] { opacity: 0; }
.scale__ghostdot {
  background: none;
  box-shadow: inset 0 0 0 1px var(--dim);
  opacity: 0;
  transition: opacity var(--t-small) var(--arrive);
}
.scale__ghostdot[data-on="true"] { opacity: 1; }

.hint {
  min-height: 1.25rem;
  font-size: 0.8125rem;
  color: var(--dim);
  text-align: center;
  max-width: 34rem;
}
.hint kbd { font: inherit; color: var(--fg); }
.hint b { font-weight: 500; color: var(--fg); }

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

.dock {
  grid-column: 1 / -1;
  grid-row: 3;
  justify-self: center;
  display: flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.3125rem;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.045);
  border: 1px solid var(--hair-soft);
  backdrop-filter: blur(20px) saturate(160%);
  -webkit-backdrop-filter: blur(20px) saturate(160%);
}
.dock button {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 1rem;
  border-radius: 999px;
  font-size: 0.8125rem;
  color: var(--dim);
  transition: color var(--t-micro) var(--glide),
              background var(--t-micro) var(--glide),
              transform var(--t-micro) var(--glide);
}
.dock button:hover { color: var(--fg); background: var(--raise); }
.dock button:active { transform: scale(0.97); }
.dock kbd {
  font: inherit;
  font-size: 0.625rem;
  letter-spacing: 0.08em;
  padding: 0.0625rem 0.3125rem;
  border-radius: 5px;
  background: var(--raise-hi);
  color: var(--faint);
}

/* ---------------------------------------------------------- scoreboard */

.board {
  grid-column: 1;
  grid-row: 2;
  align-self: center;
  display: flex;
  flex-direction: column;
  gap: 0.375rem;
  max-height: 100%;
  overflow-y: auto;
  scrollbar-width: none;
}
.board::-webkit-scrollbar { display: none; }
.board__title { margin-bottom: 0.375rem; }

.alert {
  display: grid;
  grid-template-columns: 1.75rem 1fr auto;
  align-items: baseline;
  gap: 0.625rem;
  width: 100%;
  padding: 0.5rem 0.625rem;
  border-radius: 0.625rem;
  text-align: left;
  color: var(--dim);
  transition: background var(--t-micro) var(--glide),
              color var(--t-micro) var(--glide);
}
.alert:hover { background: var(--raise); color: var(--fg); }
.alert__bang {
  font-size: 0.8125rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: var(--faint);
}
.alert[data-sev="3"] .alert__bang { color: var(--red); }
.alert[data-sev="2"] .alert__bang { color: var(--red-dim); }
.alert__subject { font-size: 0.8125rem; color: inherit; }
.alert__what { display: block; font-size: 0.6875rem; color: var(--faint); }
.alert__grade { font-size: 0.9375rem; font-weight: 500; color: var(--fg); }
.alert[data-sev="3"] .alert__grade { color: var(--red); }

.board__empty { font-size: 0.8125rem; color: var(--faint); padding: 0.5rem 0.625rem; }

/* -------------------------------------------------------------- picker */

.picker {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;      /* the choice sits where the line was */
  gap: 1.5rem;
  padding: var(--pad);
  background: rgba(0, 0, 0, 0.86);
  backdrop-filter: blur(28px) saturate(140%);
  -webkit-backdrop-filter: blur(28px) saturate(140%);
}
.picker[hidden] { display: none; }
.picker__head {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.875rem;
  flex: none;
}
.picker__grid {
  flex: 0 1 auto;
  width: 100%;
  max-width: 76rem;
  display: grid;
  /* auto-fit, not auto-fill: when the filter leaves one match, the empty
     tracks collapse and that one tile lands in the middle of the screen. */
  grid-template-columns: repeat(auto-fit, minmax(11.5rem, 14rem));
  grid-auto-rows: minmax(6.25rem, auto);
  justify-content: center;
  gap: 0.625rem;
  overflow-y: auto;
  scrollbar-width: none;
  padding-bottom: 0.5rem;
}
.picker__grid::-webkit-scrollbar { display: none; }

.tile {
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.9375rem 1rem;
  text-align: left;
  border-radius: 1.125rem;
  background: var(--raise);
  border: 1px solid var(--hair-soft);
  transition: background var(--t-micro) var(--glide),
              border-color var(--t-micro) var(--glide),
              transform var(--t-small) var(--glide);
}
.tile:hover,
.tile[data-on="true"] {
  background: var(--raise-hi);
  border-color: var(--hair);
}
/* The armed tile says so, and says which key commits it. */
.tile[data-on="true"] {
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.34);
  background: var(--raise-hi);
}
.tile[data-on="true"]::after {
  content: "↵";
  position: absolute;
  top: 0.75rem;
  right: 0.9375rem;
  font-size: 0.875rem;
  color: var(--fg);
}
.tile:active { transform: scale(0.985); }
.tile__name {
  font-size: 1rem;
  font-weight: 400;
  letter-spacing: -0.01em;
  line-height: 1.2;
}
.tile__foot {
  display: flex;
  align-items: baseline;
  gap: 0.4375rem;
  font-size: 0.8125rem;
  color: var(--faint);
  font-variant-numeric: tabular-nums;
}
.tile__delta { color: var(--dim); }
.tile__delta[data-dir="up"]   { color: var(--fg); }
.tile__delta[data-dir="down"] { color: var(--red); }
.tile__key {
  margin-left: auto;
  font-size: 0.6875rem;
  letter-spacing: 0.06em;
  color: var(--dim);
  padding: 0.0625rem 0.375rem;
  border-radius: 5px;
  background: var(--raise-hi);
}
.tile--grade .tile__key { background: none; padding: 0; color: var(--faint); }
.tile--grade { align-items: flex-start; justify-content: center; }
.tile--grade .tile__name { font-size: 2rem; font-weight: 200; letter-spacing: -0.03em; }
.tile--grade[data-one="true"] .tile__name { color: var(--red); }

/* --------------------------------------------------------------- sheet */

.sheet { position: fixed; inset: 0; z-index: 30; display: grid; place-items: center; }
.sheet[hidden] { display: none; }
.sheet__scrim {
  position: absolute; inset: 0;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
}
.sheet__panel {
  position: relative;
  width: min(68rem, calc(100vw - 2 * var(--pad)));
  height: min(46rem, calc(100dvh - 2 * var(--pad)));
  display: flex;
  flex-direction: column;
  border-radius: 1.75rem;
  background: #0a0a0a;
  border: 1px solid var(--hair);
  box-shadow: 0 40px 120px rgba(0, 0, 0, 0.85);
  overflow: hidden;
}
.sheet__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.375rem 1.625rem 1.125rem;
  border-bottom: 1px solid var(--hair-soft);
}
.sheet__title {
  font-size: 1.0625rem;
  font-weight: 500;
  letter-spacing: -0.01em;
}
.x {
  font-size: 0.6875rem;
  letter-spacing: 0.12em;
  color: var(--faint);
  padding: 0.3125rem 0.5625rem;
  border-radius: 7px;
  background: var(--raise);
  transition: color var(--t-micro) var(--glide);
}
.x:hover { color: var(--fg); }
.sheet__body {
  flex: 1;
  overflow-y: auto;
  padding: 1.375rem 1.625rem 2rem;
}

/* --------------------------------------------------------- table sheet */

.subject-row {
  display: grid;
  grid-template-columns: minmax(8rem, 13rem) 4.5rem 1fr;
  align-items: center;
  gap: 1rem;
  padding: 0.75rem 0;
  border-bottom: 1px solid var(--hair-soft);
}
.subject-row__name { font-size: 0.9375rem; }
.subject-row__name small { display: block; font-size: 0.6875rem; color: var(--faint); }
.subject-row__avg {
  font-size: 0.9375rem;
  font-variant-numeric: tabular-nums;
  color: var(--dim);
}
.subject-row__avg b { color: var(--fg); font-weight: 500; }
.subject-row__grades { display: flex; flex-wrap: wrap; gap: 0.3125rem; }

.chip {
  position: relative;
  min-width: 2rem;
  padding: 0.25rem 0.5rem;
  border-radius: 0.5rem;
  background: var(--raise);
  font-size: 0.875rem;
  font-variant-numeric: tabular-nums;
  transition: background var(--t-micro) var(--glide), transform var(--t-micro) var(--glide);
}
.chip:hover { background: var(--raise-hi); }
.chip:active { transform: scale(0.94); }
.chip[data-one="true"] { color: var(--red); }
.chip[data-fix="true"]::after {
  content: "";
  position: absolute;
  top: 3px; right: 3px;
  width: 3px; height: 3px;
  border-radius: 50%;
  background: var(--dim);
}

/* ------------------------------------------------------ analysis sheet */

.verdict {
  font-size: clamp(1.25rem, 2.6vw, 1.75rem);
  font-weight: 300;
  letter-spacing: -0.02em;
  line-height: 1.32;
  margin-bottom: 1.5rem;
  max-width: 42rem;
}
.verdict b { font-weight: 500; }
.verdict[data-ok="false"] em { font-style: normal; color: var(--red); }

.plan { display: flex; flex-direction: column; gap: 0.5rem; margin-bottom: 2rem; }
.plan__row {
  display: grid;
  grid-template-columns: 1.5rem 1fr auto;
  gap: 0.875rem;
  align-items: baseline;
  padding: 0.75rem 0.875rem;
  border-radius: 0.75rem;
  background: var(--raise);
}
.plan__i { color: var(--faint); font-size: 0.8125rem; font-variant-numeric: tabular-nums; }
.plan__what { font-size: 0.9375rem; }
.plan__what small { display: block; color: var(--faint); font-size: 0.75rem; }
.plan__gain { font-size: 0.8125rem; color: var(--dim); font-variant-numeric: tabular-nums; }

.sim { display: flex; flex-direction: column; gap: 0.625rem; }
.sim__row {
  display: grid;
  grid-template-columns: minmax(7rem, 12rem) 1fr 1.5rem 2.5rem;
  align-items: center;
  gap: 1rem;
}
.sim__count {
  font-size: 0.8125rem;
  color: var(--faint);
  font-variant-numeric: tabular-nums;
  text-align: right;
}
.sim__name { font-size: 0.875rem; color: var(--dim); }
.sim__out { font-size: 0.875rem; font-variant-numeric: tabular-nums; text-align: right; }
/* The slider is the same hairline the whole app is built on. */
input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 1.25rem;
  background: none;
  cursor: pointer;
}
input[type="range"]::-webkit-slider-runnable-track { height: 1px; background: var(--hair); }
input[type="range"]::-moz-range-track { height: 1px; background: var(--hair); }
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 11px; height: 11px;
  margin-top: -5px;
  border-radius: 50%;
  background: var(--fg);
}
input[type="range"]::-moz-range-thumb {
  width: 11px; height: 11px;
  border: 0;
  border-radius: 50%;
  background: var(--fg);
}

.ai { margin-top: 2rem; padding-top: 1.5rem; border-top: 1px solid var(--hair-soft); }
.ai__text {
  font-size: 0.9375rem;
  line-height: 1.62;
  color: var(--dim);
  white-space: pre-wrap;
  max-width: 44rem;
}
.ai__text b, .ai__text strong { color: var(--fg); font-weight: 500; }

/* ------------------------------------------------------ settings sheet */

.set-group { margin-bottom: 2.25rem; }
.set-group > .label { margin-bottom: 0.875rem; display: block; }
.set-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.6875rem 0;
  border-bottom: 1px solid var(--hair-soft);
  font-size: 0.9375rem;
}
.set-row__note { font-size: 0.75rem; color: var(--faint); max-width: 26rem; }

.input {
  padding: 0.5rem 0.75rem;
  border-radius: 0.625rem;
  background: var(--raise);
  border: 1px solid var(--hair-soft);
  min-width: 6rem;
  transition: border-color var(--t-micro) var(--glide);
}
.input:focus { outline: none; border-color: var(--hair); }
.input--wide { width: 100%; }

.btn {
  padding: 0.5rem 1rem;
  border-radius: 999px;
  background: var(--raise);
  border: 1px solid var(--hair-soft);
  font-size: 0.8125rem;
  transition: background var(--t-micro) var(--glide), transform var(--t-micro) var(--glide);
}
.btn:hover { background: var(--raise-hi); }
.btn:active { transform: scale(0.97); }
.btn--solid { background: var(--fg); color: #000; border-color: var(--fg); }
.btn--solid:hover { background: #e8e8e8; }
.btn--danger { color: var(--red); }

.toggle {
  position: relative;
  width: 2.75rem; height: 1.625rem;
  border-radius: 999px;
  background: var(--raise-hi);
  transition: background var(--t-small) var(--glide);
  flex: none;
}
.toggle[aria-checked="true"] { background: var(--fg); }
.toggle::after {
  content: "";
  position: absolute;
  top: 3px; left: 3px;
  width: 1.25rem; height: 1.25rem;
  border-radius: 50%;
  background: #000;
  box-shadow: inset 0 0 0 1px var(--hair);
  transition: transform var(--t-small) var(--glide), background var(--t-small) var(--glide);
}
.toggle[aria-checked="true"]::after { transform: translateX(1.125rem); background: #000; box-shadow: none; }
.toggle[aria-checked="false"]::after { background: var(--dim); box-shadow: none; }

.subject-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.375rem 0.5rem 0.375rem 0.75rem;
  border-radius: 999px;
  background: var(--raise);
  font-size: 0.8125rem;
  margin: 0 0.375rem 0.375rem 0;
}
.subject-chip[data-counts="false"] { color: var(--faint); text-decoration: line-through; }
.subject-chip button { color: var(--faint); font-size: 1rem; line-height: 1; padding: 0 0.25rem; }
.subject-chip button:hover { color: var(--red); }

/* --------------------------------------------------------------- misc */

.lock {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: grid;
  place-items: center;
  background: var(--bg);
}
.lock[hidden] { display: none; }
.lock__inner { display: flex; flex-direction: column; align-items: center; gap: 1.5rem; }
.lock__dots { display: flex; gap: 0.875rem; }
.lock__dot {
  width: 0.6875rem; height: 0.6875rem;
  border-radius: 50%;
  box-shadow: inset 0 0 0 1px var(--faint);
  transition: background var(--t-micro) var(--glide);
}
.lock__dot[data-on="true"] { background: var(--fg); box-shadow: none; }
.lock__err { font-size: 0.8125rem; color: var(--red); min-height: 1.25rem; }

@keyframes shake {
  10%, 90% { transform: translateX(-2px); }
  30%, 70% { transform: translateX(4px); }
  50%      { transform: translateX(-4px); }
}
.shake { animation: shake 320ms var(--glide); }

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(var(--pad) + 4.5rem);
  transform: translate(-50%, 8px);
  z-index: 50;
  padding: 0.5625rem 1rem;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid var(--hair-soft);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  font-size: 0.8125rem;
  color: var(--fg);
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--t-small) var(--arrive), transform var(--t-small) var(--arrive);
}
.toast[data-on="true"] { opacity: 1; transform: translate(-50%, 0); }

.empty { color: var(--faint); font-size: 0.875rem; padding: 2rem 0; }

/* ------------------------------------------------------------ narrow */

@media (max-width: 900px) {
  .app {
    grid-template-columns: 1fr;
    grid-template-rows: auto 1fr auto auto;
    gap: 1rem;
  }
  .status { grid-column: 1; grid-row: 1; }
  .stage  { grid-column: 1; grid-row: 2; }
  .board  { grid-column: 1; grid-row: 3; align-self: end; max-height: 28dvh; }
  .dock   { grid-column: 1; grid-row: 4; }
  .subject-row { grid-template-columns: 1fr; gap: 0.5rem; }
  .sim__row { grid-template-columns: 1fr 1.5rem 2.5rem; }
  .sim__name { grid-column: 1 / -1; }
}

/* The same input follows you into the chooser, where it is a filter box
   rather than a display - so it drops the display sizing. */
.picker__head .field-wrap { height: auto; width: min(28rem, 80vw); }
.picker__head .field {
  position: static;
  height: auto;
  font-size: 1.5rem;
  font-weight: 300;
  letter-spacing: -0.012em;
  line-height: 1.3;
}

/* No physical keyboard, no point advertising its shortcuts. */
@media (pointer: coarse) {
  .dock kbd { display: none; }
  .dock button { padding: 0.5rem 0.875rem; }
}
