:root {
  color-scheme: dark;
  --ink: #081a27;
  --ink-soft: #102b3c;
  --panel: #132f40;
  --panel-light: #18394b;
  --line: rgba(220, 235, 232, 0.14);
  --text: #f5f1e8;
  --muted: #9bb0b7;
  --paper: #eef0e7;
  --lime: #b9f55c;
  --lime-dark: #7fc22a;
  --cyan: #54d7df;
  --orange: #ff9c5a;
  --red: #ff6f6f;
  --shadow: 0 24px 70px rgba(0, 0, 0, 0.24);
  --radius: 22px;
  --mono: "SFMono-Regular", "Cascadia Code", "Roboto Mono", Consolas, monospace;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-synthesis: none;
}

* {
  box-sizing: border-box;
}

html {
  background: var(--ink);
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  min-height: 100svh;
  background:
    radial-gradient(circle at 12% 0%, rgba(84, 215, 223, 0.1), transparent 35rem),
    var(--ink);
  color: var(--text);
}

button,
input,
select {
  font: inherit;
}

button,
select,
label.file-button {
  -webkit-tap-highlight-color: transparent;
}

button {
  color: inherit;
}

button:focus-visible,
input:focus-visible,
select:focus-visible,
label.file-button:focus-within {
  outline: 3px solid var(--cyan);
  outline-offset: 3px;
}

.app-shell {
  min-height: 100vh;
  min-height: 100svh;
  padding-bottom: 98px;
}

.topbar {
  position: relative;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: min(1180px, calc(100% - 40px));
  height: 82px;
  margin: 0 auto;
  border-bottom: 1px solid var(--line);
}

.brand {
  display: inline-flex;
  gap: 11px;
  align-items: center;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--text);
  font-size: 1.06rem;
  font-weight: 760;
  letter-spacing: -0.02em;
}

button.brand {
  cursor: pointer;
}

.brand-mark {
  display: grid;
  width: 39px;
  height: 39px;
  place-items: center;
  border: 1px solid rgba(185, 245, 92, 0.55);
  border-radius: 12px;
  color: var(--lime);
  font: 700 0.84rem var(--mono);
}

.bit-convention {
  display: flex;
  gap: 9px;
  align-items: center;
  color: var(--muted);
  font: 0.76rem var(--mono);
}

.bit-convention strong {
  color: var(--lime);
  font-weight: 650;
}

.bit-convention i {
  font-style: normal;
  opacity: 0.45;
}

.bottom-nav {
  position: fixed;
  z-index: 20;
  right: 0;
  bottom: 0;
  left: 0;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  padding: 10px max(18px, env(safe-area-inset-left)) calc(10px + env(safe-area-inset-bottom)) max(18px, env(safe-area-inset-right));
  border-top: 1px solid var(--line);
  background: rgba(8, 26, 39, 0.92);
  backdrop-filter: blur(20px);
}

.bottom-nav button {
  display: flex;
  gap: 8px;
  align-items: center;
  justify-content: center;
  min-height: 52px;
  border: 0;
  border-radius: 14px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-size: 0.84rem;
  font-weight: 700;
}

.bottom-nav button span {
  font-size: 1.25rem;
}

.bottom-nav button.active {
  background: var(--panel-light);
  color: var(--lime);
}

main {
  width: min(1180px, calc(100% - 40px));
  margin: 0 auto;
}

.eyebrow {
  margin: 0 0 10px;
  color: var(--lime);
  font: 700 0.73rem/1.3 var(--mono);
  letter-spacing: 0.13em;
  text-transform: uppercase;
}

.hero {
  padding: clamp(54px, 9vw, 118px) 0 clamp(48px, 7vw, 88px);
}

.hero h1,
.stats-header h1,
.summary-hero h1 {
  max-width: 900px;
  margin: 0;
  color: var(--text);
  font-size: clamp(2.65rem, 7vw, 6.8rem);
  font-weight: 730;
  letter-spacing: -0.072em;
  line-height: 0.94;
}

.hero h1 span {
  color: #7c929b;
}

.hero > p:last-child {
  max-width: 610px;
  margin: 28px 0 0;
  color: var(--muted);
  font-size: clamp(1rem, 2vw, 1.24rem);
  line-height: 1.55;
}

.panel,
.goal-card {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(16, 43, 60, 0.68);
  box-shadow: var(--shadow);
}

.mode-panel,
.trend-panel,
.items-panel,
.data-panel,
.session-breakdown {
  padding: clamp(20px, 4vw, 40px);
}

.section-heading {
  display: flex;
  gap: 24px;
  align-items: flex-end;
  justify-content: space-between;
  margin-bottom: 28px;
}

.section-heading h2,
.section-heading h3 {
  margin: 0;
  font-size: clamp(1.35rem, 3vw, 2.1rem);
  letter-spacing: -0.04em;
}

.section-heading h3 {
  font-size: 1rem;
  letter-spacing: -0.01em;
}

.section-heading.small {
  margin: 24px 0 4px;
}

.start-button,
.secondary-button,
.danger-button,
.continue-button {
  min-height: 54px;
  padding: 0 25px;
  border: 0;
  border-radius: 15px;
  cursor: pointer;
  font-weight: 760;
}

.start-button,
.continue-button {
  background: var(--lime);
  color: #102013;
  box-shadow: 0 10px 30px rgba(185, 245, 92, 0.15);
}

.start-button:hover,
.continue-button:hover {
  background: #cbff78;
}

.start-button.compact {
  min-width: 132px;
}

.mobile-start {
  display: none;
  width: 100%;
  margin-top: 18px;
  justify-content: space-between;
}

.mode-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.mode-card {
  position: relative;
  display: flex;
  min-height: 177px;
  padding: 20px;
  flex-direction: column;
  align-items: flex-start;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 17px;
  background: rgba(8, 26, 39, 0.52);
  text-align: left;
  cursor: pointer;
  transition: border-color 140ms ease, background 140ms ease, transform 140ms ease;
}

.mode-card:hover {
  border-color: rgba(185, 245, 92, 0.45);
  background: rgba(24, 57, 75, 0.9);
  transform: translateY(-2px);
}

.mode-card.selected {
  border-color: var(--lime);
  background: linear-gradient(145deg, rgba(185, 245, 92, 0.13), rgba(24, 57, 75, 0.85));
}

.mode-card.selected::after {
  position: absolute;
  top: 15px;
  right: 15px;
  display: grid;
  width: 23px;
  height: 23px;
  place-items: center;
  border-radius: 50%;
  background: var(--lime);
  color: var(--ink);
  content: "✓";
  font-size: 0.75rem;
  font-weight: 900;
}

.mode-card.mixed {
  grid-column: span 2;
}

.mode-topline {
  display: flex;
  width: 100%;
  min-height: 26px;
  gap: 8px;
  align-items: center;
}

.mode-group,
.recommended {
  color: var(--cyan);
  font: 650 0.68rem var(--mono);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.recommended {
  padding: 4px 7px;
  border-radius: 20px;
  background: rgba(185, 245, 92, 0.1);
  color: var(--lime);
  letter-spacing: 0;
  text-transform: none;
}

.mode-card strong {
  margin-top: 13px;
  font-size: 1.08rem;
  letter-spacing: -0.025em;
}

.mode-card > span:nth-of-type(2) {
  margin-top: 5px;
  color: var(--muted);
  font-size: 0.83rem;
  line-height: 1.4;
}

.mode-card .status {
  display: flex;
  gap: 7px;
  align-items: center;
  margin-top: auto;
  padding-top: 18px;
  color: var(--muted);
  font-size: 0.69rem;
}

.mode-card .status::before {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #70828a;
  content: "";
}

.mode-card .status.reached::before {
  background: var(--lime);
  box-shadow: 0 0 9px var(--lime);
}

.mode-card .status.working::before {
  background: var(--orange);
}

.recent-panel {
  margin-top: 18px;
  padding: clamp(20px, 4vw, 40px);
}

.recent-list {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.recent-list > div {
  display: grid;
  gap: 5px;
  padding: 17px;
  border: 1px solid var(--line);
  border-radius: 15px;
}

.recent-list span,
.recent-list small {
  color: var(--muted);
  font-size: 0.74rem;
}

.recent-list strong {
  font-size: 0.95rem;
}

.empty-copy {
  color: var(--muted);
}

/* Trainer */
.trainer-shell {
  min-height: 100vh;
  min-height: 100svh;
  overflow: hidden;
  background:
    radial-gradient(circle at 50% 35%, rgba(84, 215, 223, 0.08), transparent 30rem),
    var(--ink);
}

.trainer-header {
  display: grid;
  width: min(1040px, calc(100% - 36px));
  height: 78px;
  margin: 0 auto;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  border-bottom: 1px solid var(--line);
}

.stop-button {
  display: inline-flex;
  width: max-content;
  min-height: 42px;
  padding: 0 12px;
  gap: 8px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
}

.stop-button:hover {
  color: var(--text);
}

.trainer-mode {
  display: grid;
  justify-items: center;
}

.trainer-mode small {
  color: var(--cyan);
  font: 0.64rem var(--mono);
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.trainer-mode strong {
  margin-top: 3px;
  font-size: 0.9rem;
}

.trainer-metrics {
  display: flex;
  gap: 14px;
  justify-content: flex-end;
  color: var(--muted);
  font: 0.75rem var(--mono);
}

.trainer-metrics span:first-child {
  color: var(--text);
}

.trainer-main {
  display: grid;
  width: min(840px, calc(100% - 36px));
  min-height: calc(100svh - 78px);
  margin: 0 auto;
  padding: 15px 0 max(18px, env(safe-area-inset-bottom));
  grid-template-rows: auto minmax(260px, 1fr) auto;
}

.trainer-context {
  display: flex;
  min-height: 42px;
  gap: 12px;
  align-items: center;
  justify-content: space-between;
}

.persistent-convention {
  color: var(--muted);
  font: 0.68rem var(--mono);
}

.last-result {
  padding: 7px 11px;
  border: 1px solid var(--line);
  border-radius: 50px;
  color: var(--muted);
  font: 0.68rem var(--mono);
}

.last-result.correct {
  border-color: rgba(185, 245, 92, 0.35);
  color: var(--lime);
}

.last-result.incorrect {
  border-color: rgba(255, 111, 111, 0.35);
  color: var(--red);
}

.question-card {
  display: flex;
  min-height: 310px;
  padding: 30px 20px;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.instruction {
  margin: 0 0 clamp(14px, 4vh, 34px);
  color: var(--muted);
  font-size: 0.9rem;
}

.prompt {
  color: var(--text);
  font-family: var(--mono);
  font-size: clamp(3.8rem, 12vw, 8.6rem);
  font-weight: 700;
  letter-spacing: -0.06em;
  line-height: 1;
  text-align: center;
  text-shadow: 0 0 45px rgba(84, 215, 223, 0.08);
}

.prompt.hex-byte {
  color: var(--cyan);
}

.prompt.binary {
  font-size: clamp(2.5rem, 9vw, 6.1rem);
  letter-spacing: 0.03em;
  word-spacing: 0.3em;
}

.question-prompt {
  max-width: 780px;
  font-family: inherit;
  font-size: clamp(2rem, 7vw, 4.7rem);
  font-weight: 690;
  letter-spacing: -0.052em;
  line-height: 1.08;
}

.bit-list-prompt {
  display: flex;
  flex-wrap: wrap;
  gap: clamp(10px, 2vw, 18px);
  justify-content: center;
  font-size: clamp(2.1rem, 8vw, 5.4rem);
  letter-spacing: -0.04em;
}

.bit-list-prompt span {
  color: var(--cyan);
}

.answer-slots {
  display: flex;
  min-height: 54px;
  margin-top: clamp(24px, 5vh, 48px);
  gap: 6px;
  align-items: center;
  justify-content: center;
}

.answer-slot {
  display: grid;
  width: clamp(34px, 7vw, 52px);
  height: clamp(44px, 8vw, 60px);
  place-items: center;
  border-bottom: 2px solid #4b6570;
  color: #718991;
  font: 700 clamp(1.25rem, 4vw, 2rem) var(--mono);
}

.answer-slot.filled {
  border-color: var(--lime);
  color: var(--text);
}

.answer-slot.wrong {
  border-color: var(--red);
  background: rgba(255, 111, 111, 0.09);
  color: var(--red);
}

.answer-slot.group-gap {
  margin-left: 13px;
}

.answer-prefix {
  margin-right: 2px;
  color: var(--muted);
  font: 1.15rem var(--mono);
}

.bit-answer-slots {
  flex-wrap: wrap;
  gap: 8px;
}

.bit-answer {
  display: grid;
  min-width: 48px;
  height: 48px;
  padding: 0 12px;
  place-items: center;
  border: 1px dashed #4b6570;
  border-radius: 13px;
  color: #718991;
  font: 700 1rem var(--mono);
}

.bit-answer.filled {
  border-style: solid;
  border-color: var(--lime);
  color: var(--text);
}

.bit-answer.wrong {
  border-color: var(--red);
  color: var(--red);
}

.answer-hint {
  margin-top: clamp(26px, 6vh, 58px);
  color: #6f858e;
  font: 0.78rem var(--mono);
  letter-spacing: 0.2em;
}

.keyboard-copy {
  margin-top: 16px;
  color: #607780;
  font-size: 0.7rem;
}

.input-dock {
  align-self: end;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 20px;
  background: rgba(16, 43, 60, 0.7);
  box-shadow: 0 -16px 50px rgba(0, 0, 0, 0.12);
}

.keypad {
  display: grid;
  gap: 8px;
}

.keypad button,
.yes-no-pad button {
  min-height: 56px;
  border: 1px solid var(--line);
  border-radius: 13px;
  background: var(--panel-light);
  color: var(--text);
  cursor: pointer;
  font: 700 1rem var(--mono);
  touch-action: manipulation;
}

.keypad button:active,
.yes-no-pad button:active {
  border-color: var(--lime);
  background: #244d5c;
  transform: translateY(1px);
}

.keypad button:disabled {
  opacity: 0.26;
}

.binary-pad {
  grid-template-columns: 1fr 1fr 0.55fr;
}

.binary-pad button {
  min-height: 76px;
  font-size: 1.7rem;
}

.hex-pad {
  grid-template-columns: repeat(8, minmax(0, 1fr));
}

.hex-pad .erase-key {
  grid-column: span 8;
  min-height: 44px;
}

.bit-pad {
  grid-template-columns: repeat(8, minmax(0, 1fr));
}

.bit-pad .erase-key {
  grid-column: span 8;
  min-height: 44px;
}

.erase-key {
  color: var(--muted) !important;
}

.yes-no-pad {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.yes-no-pad button {
  display: flex;
  min-height: 85px;
  gap: 12px;
  align-items: center;
  justify-content: center;
  color: var(--lime);
  font-family: inherit;
  font-size: 1rem;
}

.yes-no-pad kbd {
  display: grid;
  width: 38px;
  height: 38px;
  place-items: center;
  border: 1px solid rgba(185, 245, 92, 0.45);
  border-radius: 9px;
  background: rgba(8, 26, 39, 0.55);
  font: 700 1rem var(--mono);
  box-shadow: inset 0 -2px rgba(0, 0, 0, 0.25);
}

.showing-feedback {
  grid-template-rows: auto 1fr;
}

.feedback-card {
  align-self: center;
  width: min(620px, 100%);
  margin: 24px auto;
  padding: clamp(27px, 6vw, 52px);
  border: 1px solid rgba(255, 111, 111, 0.32);
  border-radius: 24px;
  background: linear-gradient(145deg, rgba(255, 111, 111, 0.07), rgba(16, 43, 60, 0.86));
  box-shadow: var(--shadow);
  text-align: center;
}

.error-label {
  color: var(--red);
}

.feedback-card h2 {
  margin: 0;
  color: var(--muted);
  font-size: 0.94rem;
  font-weight: 550;
}

.correct-answer {
  margin: 17px 0 24px;
  color: var(--lime);
  font: 750 clamp(2.5rem, 9vw, 5.5rem)/1 var(--mono);
  letter-spacing: 0.02em;
}

.binary-comparison {
  padding: 16px;
  border-radius: 14px;
  background: rgba(8, 26, 39, 0.45);
}

.binary-comparison > span {
  color: var(--muted);
  font-size: 0.71rem;
}

.binary-comparison .answer-slots {
  margin-top: 10px;
}

.entered-answer {
  color: var(--muted);
}

.entered-answer strong {
  color: var(--red);
  font-family: var(--mono);
}

.continue-button {
  display: block;
  width: 100%;
  margin-top: 24px;
}

.feedback-card > small {
  display: block;
  margin-top: 11px;
  color: var(--muted);
}

/* Summary */
.summary-shell {
  min-height: 100vh;
  min-height: 100svh;
  padding-bottom: 60px;
}

.summary-main {
  width: min(760px, calc(100% - 40px));
  margin: 0 auto;
}

.summary-hero {
  padding: clamp(48px, 9vw, 90px) 0 40px;
  text-align: center;
}

.summary-hero h1 {
  font-size: clamp(3rem, 10vw, 6rem);
}

.summary-hero > p:last-child {
  color: var(--muted);
}

.summary-grid,
.stats-summary {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}

.summary-grid > div,
.stats-summary > div {
  display: grid;
  min-height: 105px;
  padding: 18px;
  place-content: center;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: rgba(16, 43, 60, 0.65);
  text-align: center;
}

.summary-grid small,
.stats-summary small {
  color: var(--muted);
  font-size: 0.71rem;
}

.summary-grid strong,
.stats-summary strong {
  margin-top: 5px;
  color: var(--lime);
  font: 720 clamp(1.3rem, 4vw, 2rem) var(--mono);
}

.session-breakdown {
  margin-top: 14px;
}

.breakdown-row {
  display: grid;
  padding: 13px 0;
  grid-template-columns: 1fr auto;
  gap: 3px 20px;
  border-bottom: 1px solid var(--line);
}

.breakdown-row:last-child {
  border-bottom: 0;
}

.breakdown-row span {
  grid-row: span 2;
  align-self: center;
}

.breakdown-row strong {
  color: var(--cyan);
  font-family: var(--mono);
  text-align: right;
}

.breakdown-row small {
  color: var(--muted);
  text-align: right;
}

.summary-actions {
  display: grid;
  gap: 10px;
  margin-top: 20px;
}

.secondary-button,
label.secondary-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--line);
  background: var(--panel-light);
  color: var(--text);
}

.text-button {
  min-height: 44px;
  border: 0;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
}

/* Statistics */
.stats-header {
  display: grid;
  padding: clamp(54px, 8vw, 100px) 0 42px;
  grid-template-columns: 1fr auto;
  align-items: end;
}

.stats-header > .eyebrow {
  grid-column: 1 / -1;
}

.stats-header h1 {
  font-size: clamp(2.8rem, 7vw, 6.2rem);
}

.drill-select {
  display: grid;
  min-width: 270px;
  gap: 7px;
  color: var(--muted);
  font-size: 0.73rem;
}

.drill-select select {
  min-height: 52px;
  padding: 0 42px 0 14px;
  border: 1px solid var(--line);
  border-radius: 13px;
  background: var(--panel) linear-gradient(45deg, transparent 50%, var(--muted) 50%) right 18px center / 7px 7px no-repeat;
  color: var(--text);
  appearance: none;
}

.stats-summary {
  margin-bottom: 12px;
}

.stats-summary > div {
  min-height: 130px;
}

.goal-card {
  display: grid;
  margin-bottom: 16px;
  padding: clamp(20px, 3vw, 31px);
  grid-template-columns: 1fr auto;
  gap: 20px;
  border-color: rgba(255, 156, 90, 0.23);
}

.goal-card.reached {
  border-color: rgba(185, 245, 92, 0.4);
  background: linear-gradient(140deg, rgba(185, 245, 92, 0.1), rgba(16, 43, 60, 0.65));
}

.goal-card > div:first-child {
  display: grid;
  gap: 5px;
}

.goal-card small {
  color: var(--muted);
}

.goal-card > div:first-child strong {
  font-size: 1.25rem;
}

.goal-values {
  display: flex;
  gap: 8px;
  align-items: center;
}

.goal-values span {
  padding: 8px 11px;
  border: 1px solid var(--line);
  border-radius: 50px;
  color: var(--orange);
  font: 0.73rem var(--mono);
}

.goal-card.reached .goal-values span {
  color: var(--lime);
}

.goal-form {
  display: grid;
  max-height: 0;
  grid-column: 1 / -1;
  grid-template-columns: 1fr 1fr auto;
  gap: 10px;
  overflow: hidden;
  opacity: 0;
  transition: max-height 180ms ease, opacity 180ms ease;
}

.goal-card:hover .goal-form,
.goal-form:focus-within {
  max-height: 100px;
  opacity: 1;
}

.goal-form label {
  display: grid;
  gap: 5px;
  color: var(--muted);
  font-size: 0.69rem;
}

.goal-form input {
  min-height: 43px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--ink);
  color: var(--text);
}

.goal-form button {
  align-self: end;
  min-height: 43px;
  padding: 0 16px;
  border: 0;
  border-radius: 10px;
  background: var(--cyan);
  color: var(--ink);
  cursor: pointer;
  font-weight: 750;
}

.all-time-note {
  grid-column: 1 / -1;
}

.trend-panel,
.items-panel,
.data-panel {
  margin-top: 16px;
}

.chart-wrap {
  width: 100%;
}

.chart-wrap svg {
  display: block;
  width: 100%;
  height: auto;
  max-height: 245px;
  overflow: visible;
}

.chart-axis {
  stroke: rgba(220, 235, 232, 0.15);
  stroke-width: 1;
}

.chart-line {
  fill: none;
  stroke-width: 3;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.chart-line.time {
  stroke: var(--lime);
}

.chart-line.error {
  stroke: var(--orange);
}

.chart-area {
  opacity: 0.08;
}

.chart-area.time {
  fill: var(--lime);
}

.chart-area.error {
  fill: var(--orange);
}

.chart-point {
  stroke: var(--ink-soft);
  stroke-width: 3;
}

.chart-point.time {
  fill: var(--lime);
}

.chart-point.error {
  fill: var(--orange);
}

.chart-labels {
  display: flex;
  justify-content: space-between;
  margin-top: 4px;
  color: var(--muted);
  font: 0.68rem var(--mono);
}

.chart-divider {
  height: 1px;
  margin-top: 24px;
  background: var(--line);
}

.chart-empty {
  display: grid;
  min-height: 150px;
  place-items: center;
  border: 1px dashed var(--line);
  border-radius: 14px;
  color: var(--muted);
  font-size: 0.84rem;
}

.item-table {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 14px;
}

.item-row {
  display: grid;
  min-height: 55px;
  padding: 0 17px;
  grid-template-columns: minmax(100px, 1.4fr) 1fr 0.8fr 0.6fr;
  gap: 12px;
  align-items: center;
  border-bottom: 1px solid var(--line);
  font-size: 0.82rem;
}

.item-row:last-child {
  border-bottom: 0;
}

.item-header {
  min-height: 39px;
  background: rgba(8, 26, 39, 0.45);
  color: var(--muted);
  font-size: 0.67rem;
}

.item-row > span {
  position: relative;
  z-index: 1;
}

.item-row strong {
  font-family: var(--mono);
}

.item-row i {
  position: absolute;
  z-index: -1;
  top: -7px;
  bottom: -7px;
  left: -7px;
  width: var(--bar);
  border-radius: 5px;
  background: rgba(84, 215, 223, 0.08);
}

.weak-label {
  margin-left: 7px;
  padding: 3px 6px;
  border-radius: 6px;
  background: rgba(255, 156, 90, 0.13);
  color: var(--orange);
  font-size: 0.58rem;
  text-transform: uppercase;
}

.data-panel > p {
  max-width: 650px;
  color: var(--muted);
  line-height: 1.55;
}

.data-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 9px;
  margin-top: 21px;
}

.data-actions > * {
  min-height: 48px;
  padding: 0 17px;
  border-radius: 12px;
  cursor: pointer;
  font-size: 0.79rem;
  font-weight: 700;
}

.file-button input {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  opacity: 0;
}

.danger-button {
  border: 1px solid rgba(255, 111, 111, 0.25);
  background: transparent;
  color: var(--red);
}

.data-message {
  min-height: 20px;
  color: var(--lime) !important;
  font-size: 0.78rem;
}

@media (min-width: 880px) {
  .app-shell {
    padding-bottom: 40px;
  }

  .bottom-nav {
    position: absolute;
    top: 15px;
    right: max(20px, calc((100vw - 1180px) / 2));
    bottom: auto;
    left: auto;
    width: auto;
    grid-template-columns: repeat(2, auto);
    padding: 0;
    border: 0;
    background: transparent;
    backdrop-filter: none;
  }

  .bottom-nav button {
    min-height: 50px;
    padding: 0 15px;
  }

  .topbar {
    padding-right: 285px;
  }

  .bit-convention {
    margin-left: auto;
  }
}

@media (max-width: 879px) {
  .mode-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .mode-card.mixed {
    grid-column: span 2;
  }

  .stats-header {
    grid-template-columns: 1fr;
    gap: 26px;
  }

  .drill-select {
    width: 100%;
  }

  .goal-form {
    max-height: 100px;
    opacity: 1;
  }
}

@media (max-width: 620px) {
  .topbar,
  main,
  .trainer-header,
  .trainer-main,
  .summary-main {
    width: calc(100% - 28px);
  }

  .topbar {
    height: 70px;
  }

  .bit-convention > span:first-child,
  .bit-convention i,
  .bit-convention > span:last-child {
    display: none;
  }

  .hero {
    padding: 48px 0 40px;
  }

  .hero h1,
  .stats-header h1 {
    font-size: clamp(2.55rem, 14vw, 4.5rem);
  }

  .hero > p:last-child {
    margin-top: 21px;
    font-size: 0.98rem;
  }

  .mode-panel {
    padding: 15px;
    border-right: 0;
    border-left: 0;
    border-radius: 0;
    box-shadow: none;
  }

  .section-heading .start-button.compact {
    display: none;
  }

  .mobile-start {
    display: flex;
  }

  .mode-grid {
    grid-template-columns: 1fr;
  }

  .mode-card,
  .mode-card.mixed {
    min-height: 150px;
    grid-column: span 1;
  }

  .recent-list {
    grid-template-columns: 1fr;
  }

  .trainer-header {
    height: 66px;
    grid-template-columns: auto 1fr auto;
  }

  .stop-button span,
  .trainer-mode small,
  .trainer-metrics span:last-child {
    display: none;
  }

  .stop-button {
    width: 40px;
    padding: 0;
    justify-content: center;
    font-size: 1.2rem;
  }

  .trainer-mode {
    justify-items: start;
    padding-left: 12px;
  }

  .trainer-mode strong {
    font-size: 0.78rem;
  }

  .trainer-main {
    min-height: calc(100svh - 66px);
    padding-top: 8px;
    grid-template-rows: auto minmax(225px, 1fr) auto;
  }

  .trainer-context {
    min-height: 36px;
  }

  .persistent-convention,
  .last-result {
    font-size: 0.61rem;
  }

  .question-card {
    min-height: 245px;
    padding: 17px 0;
  }

  .instruction {
    margin-bottom: 18px;
    font-size: 0.76rem;
  }

  .prompt {
    font-size: clamp(3.4rem, 21vw, 6.2rem);
  }

  .prompt.binary {
    font-size: clamp(2.2rem, 11.5vw, 4rem);
  }

  .question-prompt {
    font-size: clamp(1.85rem, 9.5vw, 3.2rem);
  }

  .bit-list-prompt {
    font-size: clamp(2rem, 11vw, 3.7rem);
  }

  .answer-slots {
    margin-top: 25px;
    gap: 4px;
  }

  .answer-slot {
    width: clamp(31px, 9.4vw, 42px);
    height: 44px;
  }

  .answer-slot.group-gap {
    margin-left: 7px;
  }

  .keyboard-copy {
    display: none;
  }

  .input-dock {
    padding: 8px;
    border-radius: 16px;
  }

  .hex-pad {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .hex-pad button {
    min-height: 48px;
  }

  .hex-pad .erase-key {
    grid-column: span 4;
    min-height: 40px;
  }

  .bit-pad {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .bit-pad .erase-key {
    grid-column: span 4;
    min-height: 40px;
  }

  .binary-pad button {
    min-height: 66px;
  }

  .yes-no-pad button {
    min-height: 74px;
  }

  .feedback-card {
    margin: 12px auto;
    padding: 24px 17px;
  }

  .correct-answer {
    font-size: clamp(2.2rem, 11vw, 4rem);
  }

  .summary-grid,
  .stats-summary {
    gap: 6px;
  }

  .summary-grid > div,
  .stats-summary > div {
    min-height: 89px;
    padding: 10px 5px;
  }

  .summary-grid small,
  .stats-summary small {
    font-size: 0.62rem;
  }

  .summary-grid strong,
  .stats-summary strong {
    font-size: clamp(1rem, 5vw, 1.35rem);
  }

  .stats-header {
    padding: 46px 0 32px;
  }

  .goal-card {
    grid-template-columns: 1fr;
  }

  .goal-values {
    flex-wrap: wrap;
  }

  .goal-form {
    max-height: none;
    grid-column: auto;
    grid-template-columns: 1fr 1fr;
  }

  .goal-form button {
    grid-column: 1 / -1;
  }

  .all-time-note {
    grid-column: auto;
  }

  .trend-panel,
  .items-panel,
  .data-panel {
    padding: 20px 14px;
  }

  .item-row {
    padding: 0 10px;
    grid-template-columns: 1fr 0.9fr 0.75fr;
    gap: 7px;
    font-size: 0.72rem;
  }

  .item-row > span:last-child {
    display: none;
  }

  .weak-label {
    display: block;
    width: max-content;
    margin: 3px 0 0;
  }

  .data-actions {
    display: grid;
  }
}

@media (max-height: 700px) and (max-width: 620px) {
  .trainer-header {
    height: 58px;
  }

  .trainer-main {
    min-height: calc(100svh - 58px);
  }

  .trainer-context {
    min-height: 30px;
  }

  .question-card {
    min-height: 190px;
    padding: 8px 0;
  }

  .instruction {
    margin-bottom: 10px;
  }

  .answer-slots {
    margin-top: 17px;
  }

  .hex-pad button,
  .bit-pad button {
    min-height: 40px;
  }

  .yes-no-pad button,
  .binary-pad button {
    min-height: 56px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
  }
}
