:root {
  --bg: #0e1116; --panel: #171c24; --line: #262d38; --text: #e8ecf2; --muted: #8b95a5;
  --green: #3ecf8e; --red: #ff5d5d; --amber: #f5b13d; --blue: #5aa2ff;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body {
  font: 16px/1.35 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
  max-width: 640px; margin: 0 auto; padding-bottom: 40px;
}
[hidden] { display: none !important; }
.top { display: flex; align-items: center; justify-content: space-between; padding: 12px 16px; }
.top h1 { font-size: 18px; margin: 0; font-weight: 600; }
main { padding: 0 12px; display: flex; flex-direction: column; gap: 12px; }
h2 { margin: 0 0 8px; font-size: 18px; }

.panel { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 14px; }
.panel label { display: block; margin: 10px 0 4px; color: var(--muted); font-size: 14px; }
.muted { color: var(--muted); font-size: 14px; }

select, input {
  width: 100%; min-height: 48px; font-size: 17px; color: var(--text); background: #0b0e13;
  border: 1px solid var(--line); border-radius: 10px; padding: 8px 12px;
}
button {
  font: inherit; color: var(--text); border: 1px solid var(--line); background: #1f2631;
  border-radius: 12px; min-height: 52px; padding: 10px 14px; cursor: pointer; width: 100%;
}
button:active { filter: brightness(1.25); }
button:disabled { opacity: .4; }
button.icon { width: 48px; min-height: 48px; font-size: 24px; }
button.secondary { margin-top: 8px; }
button.danger { color: var(--red); }
button.main { min-height: 96px; font-size: 30px; font-weight: 700; border: 0; letter-spacing: .5px; }
button.main.go { background: var(--green); color: #06130d; }
button.main.stop { background: var(--amber); color: #1c1200; }
button.main.danger { background: var(--red); color: #200505; min-height: 52px; font-size: 17px; }
.panel button.main { margin-top: 14px; min-height: 72px; font-size: 24px; }

.row3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.row3 button { margin: 0; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 14px; }
.row2 button { margin: 0; }

.global { text-align: center; }
.big { font-size: 52px; font-weight: 700; font-variant-numeric: tabular-nums; line-height: 1.05; }
.delay { font-size: 24px; font-weight: 700; margin-top: 4px; }
.delay.late { color: var(--red); } .delay.early { color: var(--green); } .delay.ok { color: var(--muted); }
.paused .big { color: var(--amber); }

.current .curname { font-size: 20px; font-weight: 600; margin: 4px 0; }
.counter { font-size: 56px; font-weight: 700; font-variant-numeric: tabular-nums; line-height: 1.1; }
.counter .muted { font-size: 20px; font-weight: 400; margin-left: 8px; }
.counter.over, .counter.over .muted { color: var(--red); }
.counter.gap { color: var(--muted); }
.next { list-style: none; padding: 0; margin: 10px 0 0; border-top: 1px solid var(--line); }
.next li { padding: 6px 0; color: var(--muted); font-size: 15px; display: flex; justify-content: space-between; gap: 8px; }

.lista { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.lista .grupo { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: 1px; margin: 10px 4px 0; }
.lista .gap { color: var(--muted); font-size: 13px; padding: 0 12px; }
.lista .parte { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; }
.lista .parte.cur { border-color: var(--blue); }
.lista .parte.skipped { opacity: .55; }
.lista .top1 { display: flex; justify-content: space-between; gap: 10px; font-weight: 600; }
.lista .meta { color: var(--muted); font-size: 13px; margin-top: 4px; display: flex; flex-wrap: wrap; gap: 4px 14px; font-variant-numeric: tabular-nums; }
.diff.late { color: var(--red); } .diff.early { color: var(--green); }
.top1 .hora { color: var(--blue); font-variant-numeric: tabular-nums; min-width: 46px; }
.top1 .nom { flex: 1; }
.top1 .diff { white-space: nowrap; font-variant-numeric: tabular-nums; }

.edpartes { display: flex; flex-direction: column; gap: 8px; margin: 10px 0; }
.edrow { display: grid; grid-template-columns: 1fr 70px; gap: 6px; background: #0b0e13; border: 1px solid var(--line); border-radius: 10px; padding: 8px; }
.edrow .tools { grid-column: 1 / -1; display: grid; grid-template-columns: 1.5fr .7fr repeat(3, .6fr); gap: 6px; }
.edrow .tools input, .edrow .tools button, .edrow .tools select { min-height: 40px; margin: 0; padding: 4px; }

#toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); background: #2b3340; color: var(--text);
  padding: 10px 18px; border-radius: 20px; opacity: 0; pointer-events: none; transition: opacity .2s; z-index: 10; }
#toast.show { opacity: 1; }
dialog { background: var(--panel); color: var(--text); border: 1px solid var(--line); border-radius: 14px; width: min(92vw, 420px); padding: 16px; }
dialog::backdrop { background: rgba(0, 0, 0, .65); }
dialog p { margin: 0 0 4px; font-size: 17px; }
dialog button { margin-top: 8px; }
dialog .row2 button { margin-top: 0; }
