/* ---------------------------------------------------------------------------
   TrainTrack

   Monochrome by design. The only hues are pure black and pure white; every
   apparent grey is white or black at reduced alpha, so a dark screen stays at
   #000 and OLED pixels are genuinely off. No accent colour, no shadows, no
   gradients — nothing on screen competes with the set you are counting.
   --------------------------------------------------------------------------- */

:root {
  --bg: #000;
  --fg: #fff;

  /* Alpha ramps derived from the foreground, so both themes stay monochrome. */
  --line: rgb(255 255 255 / 16%);
  --line-strong: rgb(255 255 255 / 34%);
  --dim: rgb(255 255 255 / 55%);
  --faint: rgb(255 255 255 / 32%);
  --press: rgb(255 255 255 / 10%);

  --tap: 56px;
  --gutter: 20px;
  --radius: 0px;

  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;

  color-scheme: dark;
}

:root[data-theme="light"] {
  --bg: #fff;
  --fg: #000;
  --line: rgb(0 0 0 / 16%);
  --line-strong: rgb(0 0 0 / 34%);
  --dim: rgb(0 0 0 / 55%);
  --faint: rgb(0 0 0 / 32%);
  --press: rgb(0 0 0 / 8%);
  color-scheme: light;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--font);
  font-size: 17px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior-y: none;
}

body {
  min-height: 100dvh;
  /* Never let a long list slide sideways on a phone. */
  overflow-x: hidden;
}

h1, h2, h3 { font-weight: 600; margin: 0; letter-spacing: -0.02em; }
h1 { font-size: 26px; }
h2 { font-size: 19px; }
h3 { font-size: 16px; }
p  { margin: 0; }

a { color: inherit; text-decoration: underline; text-underline-offset: 3px; }

/* --------------------------------------------------------------- app frame */

.app {
  display: flex;
  flex-direction: column;
  min-height: 100dvh;
  max-width: 620px;
  margin: 0 auto;
  /* Sit clear of the home indicator and the fixed nav bar. */
  padding-bottom: calc(var(--tap) + env(safe-area-inset-bottom));
}

.app--bare { padding-bottom: env(safe-area-inset-bottom); }

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 52px;
  padding: env(safe-area-inset-top) var(--gutter) 0;
  padding-top: max(env(safe-area-inset-top), 8px);
}

.wordmark {
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.24em;
  text-transform: uppercase;
}

.main { flex: 1; padding: 8px var(--gutter) 32px; }
.main--flush { padding-left: 0; padding-right: 0; }

/* ------------------------------------------------------------------ bottom nav */

.nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 20;
  display: flex;
  background: var(--bg);
  border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
}

.nav a {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  min-height: var(--tap);
  text-decoration: none;
  color: var(--faint);
  font-size: 10px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.nav a.active { color: var(--fg); }
.nav a svg { width: 21px; height: 21px; }

/* ------------------------------------------------------------------ buttons */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-height: var(--tap);
  padding: 0 22px;
  border: 1px solid var(--fg);
  border-radius: var(--radius);
  background: transparent;
  color: var(--fg);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  user-select: none;
  transition: background-color .12s, opacity .12s;
}

.btn:active { background: var(--press); }
.btn:disabled { opacity: .35; cursor: default; }
.btn--filled { background: var(--fg); color: var(--bg); }
.btn--filled:active { opacity: .78; background: var(--fg); }
.btn--ghost { border-color: var(--line-strong); }
.btn--block { display: flex; width: 100%; }
.btn--small { min-height: 40px; padding: 0 14px; font-size: 14px; }

.btn-row { display: flex; gap: 10px; }
.btn-row > * { flex: 1; }

/* Focus is invisible until someone actually uses a keyboard. */
:focus-visible { outline: 2px solid var(--fg); outline-offset: 2px; }

/* ------------------------------------------------------- the start button */

.start {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: min(74vw, 290px);
  aspect-ratio: 1;
  margin: 0 auto;
  border: 2px solid var(--fg);
  border-radius: 50%;
  background: transparent;
  color: var(--fg);
  font: inherit;
  cursor: pointer;
  transition: background-color .14s, color .14s;
}

.start:active { background: var(--fg); color: var(--bg); }
.start__label { font-size: 30px; font-weight: 700; letter-spacing: 0.16em; }
.start__hint { font-size: 12px; letter-spacing: 0.14em; text-transform: uppercase; color: var(--dim); }
.start:active .start__hint { color: var(--bg); opacity: .7; }

.stage {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 40px;
  min-height: 62vh;
}

/* --------------------------------------------------------------- timers */

.clock {
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
  font-weight: 500;
  letter-spacing: -0.02em;
  line-height: 1;
}

.clock--hero { font-size: clamp(56px, 19vw, 92px); }
.clock--break { font-size: clamp(40px, 13vw, 62px); }
.clock--row { font-size: 15px; }

.stat-label {
  font-size: 11px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--dim);
}

.session-head {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 20px 0 4px;
}

/* The break panel inverts so it is unmistakable across a park at arm's length. */
.break-panel {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  margin: 16px 0;
  padding: 20px;
  border: 1px solid var(--fg);
  background: var(--fg);
  color: var(--bg);
}

.break-panel .stat-label { color: var(--bg); opacity: .68; }

/* ---------------------------------------------------------------- lists */

.list { display: flex; flex-direction: column; }

.row {
  display: flex;
  align-items: center;
  gap: 14px;
  width: 100%;
  min-height: var(--tap);
  padding: 13px var(--gutter);
  border: 0;
  border-bottom: 1px solid var(--line);
  background: transparent;
  color: inherit;
  font: inherit;
  text-align: left;
  text-decoration: none;
  cursor: pointer;
}

.row:active { background: var(--press); }
.row--static { cursor: default; }
.row--static:active { background: transparent; }
.row__body { flex: 1; min-width: 0; }
.row__title { font-weight: 500; }
.row__sub { font-size: 13px; color: var(--dim); margin-left: 10px; }
.row__meta { font-size: 14px; color: var(--dim); white-space: nowrap; font-variant-numeric: tabular-nums; }

.row__title, .row__sub { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.icon-box {
  display: grid;
  place-items: center;
  flex: none;
  width: 40px;
  height: 40px;
  border: 1px solid var(--line);
}

.icon-box svg { width: 24px; height: 24px; }
.icon-box--lg { width: 52px; height: 52px; }
.icon-box--lg svg { width: 30px; height: 30px; }

/* ---------------------------------------------------------------- forms */

.field { display: flex; flex-direction: column; gap: 7px; margin-bottom: 16px; }

.field label {
  font-size: 11px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--dim);
}

.input {
  width: 100%;
  min-height: var(--tap);
  padding: 0 14px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: transparent;
  color: var(--fg);
  font: inherit;
  /* 16px minimum stops iOS Safari zooming the viewport on focus. */
  font-size: 16px;
}

textarea.input { min-height: 88px; padding: 12px 14px; resize: vertical; line-height: 1.4; }
.input:focus { outline: none; border-color: var(--fg); }
.input::placeholder { color: var(--faint); }

select.input {
  appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, currentColor 50%),
                    linear-gradient(135deg, currentColor 50%, transparent 50%);
  background-position: calc(100% - 19px) 55%, calc(100% - 13px) 55%;
  background-size: 6px 6px, 6px 6px;
  background-repeat: no-repeat;
  padding-right: 38px;
}

/* --------------------------------------------------- the reps/sets stepper */

.stepper { display: flex; align-items: stretch; border: 1px solid var(--line-strong); }

.stepper button {
  width: 58px;
  border: 0;
  background: transparent;
  color: var(--fg);
  font: 300 30px/1 var(--font);
  cursor: pointer;
  user-select: none;
}

.stepper button:active { background: var(--press); }
.stepper button:disabled { opacity: .25; }

.stepper__value {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: var(--tap);
  border-inline: 1px solid var(--line-strong);
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
  font-size: 21px;
}

/* --------------------------------------------------------------- surfaces */

.card { border: 1px solid var(--line); padding: 18px var(--gutter); }
.section { margin-bottom: 28px; }

.section-title {
  padding: 22px var(--gutter) 8px;
  font-size: 11px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--dim);
}

.empty {
  padding: 56px var(--gutter);
  text-align: center;
  color: var(--dim);
  font-size: 15px;
}

.note {
  padding: 12px 14px;
  border: 1px solid var(--line-strong);
  font-size: 14px;
  line-height: 1.4;
}

.note--loud { border-color: var(--fg); }

.chip {
  display: inline-block;
  padding: 3px 9px;
  border: 1px solid var(--line-strong);
  font-size: 11px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--dim);
}

.stack { display: flex; flex-direction: column; gap: 12px; }
.inline { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.spread { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.muted { color: var(--dim); }
.small { font-size: 13px; }
.center { text-align: center; }
.nowrap { white-space: nowrap; }

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

.sheet-backdrop {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  background: rgb(0 0 0 / 62%);
}

:root[data-theme="light"] .sheet-backdrop { background: rgb(0 0 0 / 34%); }

.sheet {
  display: flex;
  flex-direction: column;
  max-height: 88dvh;
  background: var(--bg);
  border-top: 1px solid var(--line-strong);
  padding-bottom: env(safe-area-inset-bottom);
  animation: rise .18s ease-out;
}

@keyframes rise { from { transform: translateY(14px); } to { transform: none; } }

@media (prefers-reduced-motion: reduce) {
  .sheet { animation: none; }
  * { transition: none !important; }
}

.sheet__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px var(--gutter);
  border-bottom: 1px solid var(--line);
}

.sheet__body { flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch; }
.sheet__body--pad { padding: 18px var(--gutter); }
.sheet__foot { padding: 14px var(--gutter); border-top: 1px solid var(--line); }

.icon-btn {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  flex: none;
  border: 0;
  background: transparent;
  color: var(--fg);
  cursor: pointer;
  font-size: 22px;
  line-height: 1;
}

.icon-btn:active { background: var(--press); }

/* --------------------------------------------------------------- tables */

.table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }

table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { padding: 11px 10px; text-align: left; border-bottom: 1px solid var(--line); white-space: nowrap; }

th {
  font-size: 10px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--dim);
  font-weight: 600;
}

/* -------------------------------------------------------------- utility */

.spin {
  display: inline-block;
  width: 15px;
  height: 15px;
  border: 2px solid var(--faint);
  border-top-color: var(--fg);
  border-radius: 50%;
  animation: spin .7s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

.grow { flex: 1; }
.hidden { display: none; }

/* Blazor's built-in error strip, restyled to match. */
#blazor-error-ui {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 100;
  display: none;
  padding: 14px var(--gutter);
  background: var(--fg);
  color: var(--bg);
  font-size: 14px;
}

#blazor-error-ui .dismiss { float: right; cursor: pointer; font-weight: 700; }
