/* KiTimer — dark presenter screen. Contrast (on #111): text #fff 18.9:1, #b3b3b3 9.5:1, orange #f39c12
   8.9:1, red #ff6b5b 6.3:1. The state is always in WORDS too (RUNNING / PAUSED / TIME UP!), never colour
   alone (WCAG 1.4.1). */
:root {
  --bg: #111;
  --text: #fff;
  --dim: #b3b3b3;
  --warn: #f39c12;
  --up: #ff6b5b;
  --panel: #1e1e1e;
  --line: #3a3a3a;
  --accent: #4ea3ff;
  color-scheme: dark;
}
[hidden] { display: none !important; }
* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
}

.screen {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 16px;
  text-align: center;
}

/* ── The timer ── */
.timer-label { font-size: clamp(1.25rem, 5vh, 3rem); color: var(--dim); font-weight: 600; max-width: 90vw;
  overflow-wrap: anywhere; min-height: 1.2em; }
.clock {
  font-family: ui-monospace, 'SF Mono', 'Roboto Mono', Menlo, Consolas, monospace;
  font-variant-numeric: tabular-nums;
  font-weight: 700;
  font-size: min(28vh, 22vw);
  line-height: 1;
  margin: 4vh 0;
  letter-spacing: -0.02em;
  transition: color .4s;
}
.status { font-size: clamp(1rem, 4.5vh, 2.5rem); font-weight: 700; letter-spacing: .2em; color: var(--dim); min-height: 1.2em; }
.warn .clock, .warn .status { color: var(--warn); }
.up .clock, .up .status { color: var(--up); }

.corner { position: fixed; top: calc(12px + env(safe-area-inset-top, 0px)); right: calc(12px + env(safe-area-inset-right, 0px));
  display: flex; gap: 6px; }
.icon-btn {
  background: transparent; border: 0; color: #8a8a8a; /* 5.4:1 on #111 */
  min-width: 44px; min-height: 44px; border-radius: 8px; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center;
}
.icon-btn:hover { color: var(--text); background: #222; }
.icon-btn:focus-visible, .btn:focus-visible, .link-btn:focus-visible, input:focus-visible {
  outline: 3px solid var(--accent); outline-offset: 2px;
}
.icon-btn.small { min-width: 40px; min-height: 40px; font-size: 1.6rem; color: var(--dim); }

/* ── Landing ── */
.landing-title { font-size: 2.5rem; margin: 0 0 24px; }
.code-form { width: min(420px, 100%); text-align: left; }
.code-form label, .set-form label { display: block; font-weight: 600; margin-bottom: 6px; }
.code-row { display: flex; gap: 8px; }
input {
  flex: 1; min-width: 0; font: inherit; font-size: 1.25rem; padding: 10px 12px;
  background: #222; color: var(--text); border: 2px solid #6b6b6b; border-radius: 8px;
}
#code-input { font-family: ui-monospace, Menlo, Consolas, monospace; letter-spacing: .1em; }
.hint { color: var(--dim); font-size: .95rem; }
.hint code, .code-form code { color: var(--text); }
.error { color: var(--up); min-height: 1.2em; }
.recent { width: min(420px, 100%); text-align: left; margin-top: 16px; }
.recent h2 { font-size: 1rem; color: var(--dim); }
.recent ul { list-style: none; padding: 0; margin: 0; }
.recent a { display: block; padding: 10px 12px; border: 1px solid var(--line); border-radius: 8px; margin-bottom: 6px;
  color: var(--text); text-decoration: none; }
.recent a:hover { border-color: var(--accent); }
.recent .code { font-family: ui-monospace, Menlo, Consolas, monospace; color: var(--dim); margin-left: 8px; }

/* ── Buttons ── */
.btn {
  font: inherit; font-weight: 600; padding: 10px 16px; min-height: 44px; border-radius: 8px; cursor: pointer;
  background: #2a2a2a; color: var(--text); border: 1px solid #5a5a5a;
}
.btn:hover { background: #333; }
.btn-primary { background: #1f6fd1; border-color: #1f6fd1; } /* white on #1f6fd1: 4.9:1 */
.btn-primary:hover { background: #1a5fb4; }
.btn:disabled { opacity: .55; cursor: default; }
.btn-big { flex: 1; font-size: 1.15rem; min-height: 52px; }
.link-btn { background: none; border: 0; padding: 0; font: inherit; color: var(--accent); text-decoration: underline; cursor: pointer; }

/* ── Controls panel ── */
.backdrop { position: fixed; inset: 0; background: rgba(0,0,0,.6); }
.panel {
  position: fixed; left: 50%; top: 50%; transform: translate(-50%, -50%);
  width: min(460px, calc(100vw - 32px)); max-height: calc(100vh - 32px); overflow: auto;
  background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 16px 20px 20px;
  text-align: left;
}
.panel-head { display: flex; align-items: center; justify-content: space-between; }
.panel-head h2 { font-size: 1.2rem; margin: 0; }
.panel-clock { font-family: ui-monospace, Menlo, Consolas, monospace; font-variant-numeric: tabular-nums;
  font-size: 2.5rem; font-weight: 700; text-align: center; margin: 12px 0; }
.control-row { display: flex; gap: 8px; flex-wrap: wrap; }
.set-form { margin-top: 18px; }
.who { color: var(--dim); font-size: .9rem; margin: 16px 0 0; overflow-wrap: anywhere; }
