@font-face { font-family: "Poppins"; font-weight: 700; font-style: normal; font-display: swap; src: url("/fonts/poppins-700.woff") format("woff"); }
@font-face { font-family: "Poppins"; font-weight: 500; font-style: normal; font-display: swap; src: url("/fonts/poppins-500.woff") format("woff"); }
@font-face { font-family: "Inter"; font-weight: 400; font-style: normal; font-display: swap; src: url("/fonts/inter-400.woff") format("woff"); }
@font-face { font-family: "Inter"; font-weight: 600; font-style: normal; font-display: swap; src: url("/fonts/inter-600.woff") format("woff"); }

:root {
  color-scheme: dark;
  --bg: #17153a;
  --bg-low: #110f2c;
  --panel: #252250;
  --field: #1b1942;
  --line: #3a366e;
  --text: #f4f1ff;
  --muted: #aaa5d8;
  --lilac: #c8c0ff;
  --lilac-ink: #1c1946;
  --amber: #ffc247;
  --amber-ink: #2b1c00;
  --coral: #ff7a6b;
  --coral-ink: #3a0c06;
  --ok: #7fe0b0;
  --radius: 28px;
  --radius-field: 16px;
  --display: "Poppins", "Inter", system-ui, sans-serif;
  --body: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100vh;
  min-height: 100svh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  color: var(--text);
  font: 400 1rem/1.5 var(--body);
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}
button, input, select { font: inherit; color: inherit; }
[hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }

:focus-visible { outline: 3px solid var(--lilac); outline-offset: 3px; border-radius: 8px; }
.skip { position: absolute; left: 12px; top: -60px; background: var(--amber); color: var(--amber-ink); padding: 10px 16px; border-radius: 12px; font-weight: 600; z-index: 20; }
.skip:focus { top: 12px; }

/* ---------- Top ---------- */
.top { width: 100%; max-width: 860px; margin: 0 auto; padding: 18px 20px 6px; display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.brand { font: 700 1.25rem/1 var(--display); color: var(--text); text-decoration: none; letter-spacing: -0.01em; }
.brand span { color: var(--amber); }

.modes { display: inline-flex; padding: 4px; gap: 2px; background: var(--bg-low); border: 1px solid var(--line); border-radius: 999px; }
.mode { border: 0; background: transparent; color: var(--muted); padding: 8px 16px; border-radius: 999px; font: 600 0.95rem/1 var(--body); cursor: pointer; }
.mode[aria-pressed="true"] { background: var(--text); color: var(--lilac-ink); }
.mode[data-busy="true"]::after { content: ""; display: inline-block; width: 7px; height: 7px; margin-left: 8px; border-radius: 50%; background: var(--amber); vertical-align: middle; }
.mode:not([aria-pressed="true"]):hover { color: var(--text); }

/* ---------- Scene med tid ---------- */
main { width: 100%; max-width: 860px; margin: 0 auto; padding: 0 20px 28px; flex: 1; }
.stage { text-align: center; padding: clamp(18px, 5vw, 44px) 0 clamp(18px, 4vw, 32px); }
.status { min-height: 1.6em; margin: 0 0 10px; font: 500 1rem/1.4 var(--display); color: var(--muted); }
.stage[data-state="ringing"] .status, .stage[data-state="done"] .status { color: var(--amber); font-size: 1.25rem; }

.clock { --size: clamp(3rem, 17vw, 8.6rem); font-size: var(--size); display: flex; justify-content: center; align-items: center; gap: 0.07em; font-family: var(--display); font-weight: 700; line-height: 1; }
.stage[data-len="7"] .clock { --size: clamp(2.2rem, 11.2vw, 6.2rem); }
.stage[data-len="8"] .clock { --size: clamp(2rem, 10vw, 5.6rem); }
.digits { display: inline-flex; align-items: center; gap: 0.07em; }
.stage[data-cs="1"] .clock { --size: clamp(2.6rem, 14.5vw, 7rem); }
.stage[data-len="7"][data-cs="1"] .clock { --size: clamp(2rem, 11vw, 5.2rem); }
.stage[data-len="8"][data-cs="1"] .clock { --size: clamp(1.8rem, 9.5vw, 4.6rem); }
.d.cs { font-size: 0.5em; align-self: flex-end; }
.dot { width: 0.1em; height: 0.1em; border-radius: 50%; background: var(--muted); align-self: flex-end; margin: 0 0.02em 0.06em; }

.d {
  position: relative; display: inline-grid; place-items: center;
  width: 0.78em; height: 1.18em; border-radius: 0.17em;
  background: var(--panel); border: 1px solid var(--line);
  color: var(--text); font-variant-numeric: tabular-nums; padding-top: 0.04em;
  transition: background-color 0.2s, color 0.2s, border-color 0.2s;
}
.d::after { content: ""; position: absolute; left: 0; right: 0; top: 50%; height: 0.025em; min-height: 2px; background: var(--bg); opacity: 0.7; pointer-events: none; }
.sep { display: inline-flex; flex-direction: column; justify-content: center; gap: 0.2em; width: 0.26em; align-items: center; }
.sep::before, .sep::after { content: ""; width: 0.1em; height: 0.1em; border-radius: 50%; background: var(--muted); }

.stage[data-state="paused"] .digits { animation: dim 1.6s ease-in-out infinite; }
.stage[data-state="ringing"] .d, .stage[data-state="done"] .d, .stage[data-goal="1"] .d { background: var(--amber); color: var(--amber-ink); border-color: var(--amber); }
.stage[data-state="ringing"] .d::after, .stage[data-state="done"] .d::after, .stage[data-goal="1"] .d::after { background: var(--amber-ink); opacity: 0.18; }
.stage[data-state="ringing"] .digits { animation: ring 0.9s ease-in-out infinite; }
@keyframes dim { 50% { opacity: 0.45; } }
@keyframes ring { 0%, 100% { transform: translateX(0) rotate(0); } 20% { transform: translateX(-4px) rotate(-1deg); } 40% { transform: translateX(4px) rotate(1deg); } 60% { transform: translateX(-3px) rotate(-0.6deg); } 80% { transform: translateX(3px) rotate(0.6deg); } }

.meter { width: min(100%, 520px); height: 8px; margin: clamp(18px, 3vw, 28px) auto 0; border-radius: 999px; background: var(--bg-low); border: 1px solid var(--line); overflow: hidden; }
.meter-fill { height: 100%; width: 100%; background: var(--amber); border-radius: 999px; transform-origin: left center; transition: transform 0.25s linear; }
.stage[data-state="paused"] .meter-fill { background: var(--lilac); }
.stage[data-state="idle"] .meter { opacity: 0.55; }

.ends { min-height: 1.5em; margin: 12px 0 0; color: var(--muted); font-size: 0.95rem; font-variant-numeric: tabular-nums; }

.start-area { margin-top: clamp(20px, 4vw, 34px); }
.start {
  width: min(100%, 440px); min-height: 92px; border: 0; cursor: pointer; border-radius: 999px;
  background: var(--amber); color: var(--amber-ink);
  font: 700 clamp(1.8rem, 6vw, 2.4rem)/1 var(--display); letter-spacing: 0.08em;
  box-shadow: 0 14px 36px rgba(255, 194, 71, 0.28), inset 0 -4px 0 rgba(43, 28, 0, 0.14);
  transition: transform 0.12s, box-shadow 0.12s, filter 0.12s;
}
.start:hover { filter: brightness(1.06); }
.start:active { transform: translateY(2px) scale(0.99); box-shadow: 0 8px 22px rgba(255, 194, 71, 0.22), inset 0 -2px 0 rgba(43, 28, 0, 0.14); }
.start-note { margin: 12px 0 0; font-size: 0.85rem; color: var(--muted); }

/* ---------- Kort med indstillinger ---------- */
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: clamp(20px, 4vw, 32px); }
.panel { display: grid; gap: 26px; }
.group { margin: 0; padding: 0; border: 0; min-width: 0; display: grid; gap: 10px; }
.group > legend, .label { font: 600 0.92rem/1.3 var(--body); color: var(--muted); padding: 0; margin: 0 0 2px; }
legend { float: left; width: 100%; }
legend + * { clear: both; }

.chips { display: flex; flex-wrap: wrap; gap: 10px; }
.chip, .pill { border: 1px solid var(--line); background: var(--field); color: var(--text); border-radius: 999px; padding: 11px 18px; font: 500 1rem/1 var(--display); cursor: pointer; min-height: 46px; }
.chip:hover, .pill:hover { border-color: var(--lilac); }
.chip[aria-checked="true"], .pill[aria-checked="true"] { background: var(--lilac); color: var(--lilac-ink); border-color: var(--lilac); }

.custom { display: flex; gap: 10px; flex-wrap: wrap; }
.field { min-height: 52px; padding: 0 16px; background: var(--field); border: 1px solid var(--line); border-radius: var(--radius-field); color: var(--text); width: 100%; }
.field:focus { border-color: var(--lilac); outline: none; box-shadow: 0 0 0 3px rgba(200, 192, 255, 0.35); }
.field::placeholder { color: #6f6ba3; }
.field.num { width: 120px; text-align: center; font-weight: 600; }
.custom select.field { width: auto; min-width: 150px; }
select.field { appearance: none; -webkit-appearance: none; padding-right: 44px; cursor: pointer; background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='18' height='18' viewBox='0 0 24 24' fill='none' stroke='%23aaa5d8' stroke-width='2.6' stroke-linecap='round' stroke-linejoin='round'><path d='M6 9l6 6 6-6'/></svg>"); background-repeat: no-repeat; background-position: right 14px center; }
select.field option { background: var(--field); color: var(--text); }
input[type=number].field { -moz-appearance: textfield; }
input[type=number].field::-webkit-outer-spin-button, input[type=number].field::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }

.sound { grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr); gap: 18px; align-items: start; }
.sound-row { display: flex; gap: 10px; }
.sound-vol { display: grid; gap: 10px; grid-template-rows: auto 52px; }
.sound-vol .label { margin: 0 0 2px; }
.sound-vol .range { align-self: center; }
@media (max-width: 620px) { .sound { grid-template-columns: 1fr; } }

.icon-btn { flex: none; width: 52px; height: 52px; display: inline-grid; place-items: center; border-radius: var(--radius-field); border: 1px solid var(--line); background: var(--bg); color: var(--text); cursor: pointer; }
.icon-btn:hover { border-color: var(--lilac); }
.icon-btn .ico-stop { display: none; }
.icon-btn[aria-pressed="true"] { background: var(--lilac); color: var(--lilac-ink); border-color: var(--lilac); }
.icon-btn[aria-pressed="true"] .ico-stop { display: block; }
.icon-btn[aria-pressed="true"] .ico-play { display: none; }

.range { -webkit-appearance: none; appearance: none; width: 100%; height: 28px; background: transparent; cursor: pointer; margin: 0; }
.range::-webkit-slider-runnable-track { height: 8px; border-radius: 999px; background: var(--bg-low); border: 1px solid var(--line); }
.range::-moz-range-track { height: 8px; border-radius: 999px; background: var(--bg-low); border: 1px solid var(--line); }
.range::-webkit-slider-thumb { -webkit-appearance: none; width: 26px; height: 26px; margin-top: -10px; border-radius: 50%; background: var(--lilac); border: 4px solid var(--panel); box-shadow: 0 0 0 1px var(--lilac); }
.range::-moz-range-thumb { width: 18px; height: 18px; border-radius: 50%; background: var(--lilac); border: 4px solid var(--panel); box-shadow: 0 0 0 1px var(--lilac); }

/* Kontakter */
.switch { display: flex; align-items: center; gap: 14px; cursor: pointer; min-height: 44px; position: relative; }
.switch input { position: absolute; z-index: 1; opacity: 0; width: 52px; height: 30px; margin: 0; cursor: pointer; }
.switch .track { flex: none; width: 52px; height: 30px; border-radius: 999px; background: var(--bg-low); border: 1px solid var(--line); position: relative; transition: background-color 0.18s, border-color 0.18s; }
.switch .track::after { content: ""; position: absolute; top: 3px; left: 3px; width: 22px; height: 22px; border-radius: 50%; background: var(--muted); transition: transform 0.18s, background-color 0.18s; }
.switch input:checked + .track { background: var(--lilac); border-color: var(--lilac); }
.switch input:checked + .track::after { transform: translateX(22px); background: var(--lilac-ink); }
.switch input:focus-visible + .track { outline: 3px solid var(--lilac); outline-offset: 3px; }
.switch input:disabled + .track, .switch input:disabled ~ .switch-text { opacity: 0.5; }
.switch-text { font-weight: 500; }

/* Flueben */
.check { display: flex; align-items: center; gap: 14px; cursor: pointer; min-height: 44px; position: relative; }
.check input { position: absolute; z-index: 1; opacity: 0; width: 28px; height: 28px; margin: 0; cursor: pointer; }
.check .box { flex: none; width: 28px; height: 28px; border-radius: 9px; border: 2px solid var(--muted); background: var(--bg-low); display: grid; place-items: center; transition: background-color 0.15s, border-color 0.15s; }
.check .box::after { content: ""; width: 7px; height: 13px; margin-top: -3px; border: solid var(--lilac-ink); border-width: 0 3px 3px 0; transform: rotate(45deg) scale(0); transition: transform 0.12s; }
.check input:checked + .box { background: var(--lilac); border-color: var(--lilac); }
.check input:checked + .box::after { transform: rotate(45deg) scale(1); }
.check input:focus-visible + .box { outline: 3px solid var(--lilac); outline-offset: 3px; }

.notify { gap: 4px; }
.n-row { display: grid; gap: 4px; padding: 6px 0; border-top: 1px solid rgba(58, 54, 110, 0.6); }
.n-row:first-of-type { border-top: 0; }
.n-extra { display: grid; gap: 10px; padding: 4px 0 8px 66px; }
@media (max-width: 520px) { .n-extra { padding-left: 0; } }
.inline { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.inline .field { flex: 1 1 200px; width: auto; }
.inline.center { justify-content: center; }
.hint { margin: 0; font-size: 0.88rem; color: var(--muted); }
.n-row > .hint { padding-left: 66px; }
.n-row > .hint:empty { display: none; }
@media (max-width: 520px) { .n-row > .hint { padding-left: 0; } }
.hint.indent { padding-left: 42px; }
.hint.ok { color: var(--ok); }
.hint.warn { color: var(--amber); }
.hint.err { color: var(--coral); }
.hint.center, .center { text-align: center; }

/* ---------- Knapper ---------- */
.btn { border: 1px solid var(--line); background: var(--field); color: var(--text); border-radius: 999px; min-height: 56px; padding: 0 26px; font: 700 1.05rem/1 var(--display); letter-spacing: 0.06em; cursor: pointer; transition: filter 0.12s, transform 0.12s; }
.btn:hover { filter: brightness(1.12); }
.btn:active { transform: translateY(1px); }
.btn.small { min-height: 48px; padding: 0 20px; font-size: 0.95rem; letter-spacing: 0.02em; font-weight: 500; flex: none; }
.btn.primary { background: var(--amber); border-color: var(--amber); color: var(--amber-ink); font-weight: 700; }
.btn.ghost { background: transparent; }
.btn.stop { background: var(--coral); border-color: var(--coral); color: var(--coral-ink); }
.btn.pause { background: var(--lilac); border-color: var(--lilac); color: var(--lilac-ink); }
.btn.lap { background: transparent; border-color: var(--lilac); color: var(--lilac); }
.btn:disabled { opacity: 0.4; cursor: not-allowed; filter: none; transform: none; }
.btn.extend { background: transparent; border-color: var(--lilac); color: var(--lilac); }
.btn.extend[aria-expanded="true"] { background: var(--field); }
.btn.danger { background: var(--coral); border-color: var(--coral); color: var(--coral-ink); }
.btn.big { min-height: 76px; font-size: 1.5rem; width: 100%; }

.run-buttons { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.run-buttons.single { grid-template-columns: 1fr; }
@media (max-width: 520px) { .run-buttons:not(.single) { grid-template-columns: 1fr 1fr; } .run-buttons .extend, .run-buttons .reset { grid-column: 1 / -1; } .btn { padding: 0 14px; } }
.run-buttons .btn { min-height: 64px; }

.extend { display: grid; gap: 12px; padding: 20px; border-radius: 20px; background: var(--field); border: 1px solid var(--line); }
.extend output { color: var(--amber); font-family: var(--display); font-weight: 700; margin-left: 4px; }
.range-ends { display: flex; justify-content: space-between; font-size: 0.8rem; color: var(--muted); margin-top: -4px; }
.run-summary { text-align: center; }

/* Stopur: rundetider */
.laps { display: grid; gap: 6px; }
.laps-head { display: flex; justify-content: space-between; align-items: baseline; }
.laps-head h2 { margin: 0; font: 700 1.05rem/1.3 var(--display); }
.lap-row { display: grid; grid-template-columns: 4.5rem 1fr 1fr; gap: 10px; padding: 10px 14px; border-radius: 14px; font-variant-numeric: tabular-nums; }
.lap-cols { padding-top: 0; padding-bottom: 0; color: var(--muted); font-size: 0.8rem; }
.lap-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; max-height: 340px; overflow: auto; }
.lap-list .lap-row { background: var(--field); border: 1px solid var(--line); }
.lap-row span:nth-child(n+2) { text-align: right; }
.lap-row.best { border-color: var(--ok); color: var(--ok); }
.lap-row.worst { border-color: var(--coral); color: var(--coral); }

.text-link { background: none; border: 0; padding: 0; color: var(--lilac); text-decoration: underline; text-underline-offset: 3px; cursor: pointer; font: inherit; }
.text-link:hover { color: var(--text); }

.foot { display: flex; gap: 22px; justify-content: center; flex-wrap: wrap; padding: 8px 20px 34px; font-size: 0.9rem; }
.foot a { color: var(--muted); }

/* ---------- Dialog ---------- */
dialog { width: min(680px, calc(100% - 24px)); max-height: calc(100svh - 32px); padding: 0; border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel); color: var(--text); }
dialog::backdrop { background: rgba(10, 8, 30, 0.72); }
dialog[open] { display: flex; flex-direction: column; }
.dialog-head { display: flex; align-items: start; justify-content: space-between; gap: 16px; padding: 22px 22px 12px 26px; margin: 0; }
.dialog-head h2 { margin: 0; font: 700 1.3rem/1.3 var(--display); }
.dialog-body { overflow: auto; padding: 4px 26px 26px; display: grid; gap: 12px; }
.dialog-body p { margin: 0; color: var(--muted); }
details { background: var(--field); border: 1px solid var(--line); border-radius: 18px; padding: 0 18px; }
summary { cursor: pointer; font: 700 1rem/1.3 var(--display); padding: 16px 0; list-style: none; display: flex; justify-content: space-between; align-items: center; }
summary::-webkit-details-marker { display: none; }
summary::after { content: ""; width: 10px; height: 10px; border-right: 2.5px solid var(--muted); border-bottom: 2.5px solid var(--muted); transform: rotate(45deg); transition: transform 0.15s; margin-right: 4px; }
details[open] summary::after { transform: rotate(-135deg); }
details > :not(summary) { margin: 0 0 16px; }
details ol, details ul { padding-left: 22px; display: grid; gap: 8px; }
details .note { color: var(--amber); font-size: 0.92rem; }
code { font: 500 0.88em/1.4 ui-monospace, "SF Mono", Menlo, Consolas, monospace; background: var(--bg-low); padding: 2px 6px; border-radius: 6px; word-break: break-all; }
pre { margin: 0; overflow: auto; background: var(--bg-low); padding: 14px; border-radius: 12px; }
pre code { padding: 0; background: none; word-break: normal; }

/* ---------- Toasts ---------- */
.toasts { position: fixed; left: 0; right: 0; bottom: max(18px, env(safe-area-inset-bottom)); display: flex; flex-direction: column; align-items: center; gap: 8px; pointer-events: none; z-index: 30; padding: 0 16px; }
.toast { background: var(--text); color: var(--lilac-ink); padding: 12px 18px; border-radius: 16px; font-weight: 600; font-size: 0.95rem; max-width: 520px; box-shadow: 0 10px 30px rgba(0, 0, 0, 0.35); animation: toast-in 0.2s ease-out; }
.toast.warn { background: var(--amber); color: var(--amber-ink); }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } }

/* ---------- Simple sider (bekræftelse, privatliv) ---------- */
body.simple { align-items: center; padding: 24px; }
.simple-card { width: min(640px, 100%); background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: clamp(22px, 5vw, 40px); display: grid; gap: 16px; align-content: start; }
.simple-card h1 { margin: 0; font: 700 1.7rem/1.25 var(--display); }
.simple-card h2 { margin: 12px 0 0; font: 700 1.1rem/1.3 var(--display); }
.simple-card p, .simple-card ul { margin: 0; color: var(--muted); }
.simple-card ul { padding-left: 22px; display: grid; gap: 6px; }
.simple-card a { color: var(--lilac); }
.simple-card .btn { width: fit-content; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
