/* ==========================================================================
   Számláló — alkalmazás stílus
   Mobile-first, OLED-barát sötét téma. Tokenek: lásd dokumentacio/tervek/design-system.md
   ========================================================================== */

:root {
  color-scheme: dark;

  /* Felületek */
  --bg: #0b0d12;
  --surface: #141822;
  --surface-2: #1b2030;
  --surface-3: #242b3d;
  --border: rgba(255, 255, 255, 0.08);
  --border-strong: rgba(255, 255, 255, 0.16);

  /* Szöveg */
  --text: #f3f5f9;
  --text-2: #a3acbe;
  --text-3: #6b7589;

  /* Márka / akció */
  --accent: #d7ff4a;
  --accent-hover: #e6ff7a;
  --accent-ink: #0b0d12;
  --danger: #ff4d5e;
  --danger-ink: #fff;

  /* Fázis-identitás */
  --work: #ff7a45;
  --work-ink: #1a0a04;
  --rest: #3bd1f2;
  --rest-ink: #03141a;
  --prep: #a58bff;
  --prep-ink: #120a2a;

  /* Haladás a blokkon belül */
  --stage-start: #3ddc97;
  --stage-mid: #ffc53d;
  --stage-end: #ff4d5e;

  /* Geometria */
  --radius-sm: 10px;
  --radius: 16px;
  --radius-lg: 24px;
  --radius-pill: 999px;
  --touch: 48px;

  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 20px;
  --space-6: 24px;
  --space-8: 32px;

  --font: -apple-system, BlinkMacSystemFont, "SF Pro Display", "Segoe UI Variable Display", "Segoe UI", Roboto, Inter, system-ui, sans-serif;

  --shadow-1: 0 1px 2px rgba(0, 0, 0, 0.4), 0 8px 24px rgba(0, 0, 0, 0.35);
  --shadow-glow: 0 0 0 1px rgba(255, 255, 255, 0.04), 0 10px 40px -10px rgba(215, 255, 74, 0.45);

  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left: env(safe-area-inset-left, 0px);
  --safe-right: env(safe-area-inset-right, 0px);

  --ease-out: cubic-bezier(0.2, 0.8, 0.2, 1);
  --dur: 220ms;
}

/* --- Alap --- */
*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  height: 100%;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.4;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: none;
  touch-action: manipulation; /* dupla koppintásos zoom tiltása */
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  -webkit-user-select: none;
}

input,
textarea {
  user-select: text;
  -webkit-user-select: text;
}

button {
  font: inherit;
  color: inherit;
  touch-action: manipulation;
}

h1,
h2,
h3,
p {
  margin: 0;
}

ol,
ul {
  margin: 0;
  padding: 0;
  list-style: none;
}

.tnum {
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum" 1;
}

.sr-only {
  position: absolute;
  top: 0;
  left: 0;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  white-space: nowrap;
}

.noscript {
  padding: 24px;
  text-align: center;
}

.icon {
  width: 1.25em;
  height: 1.25em;
  display: inline-block;
  vertical-align: middle;
  flex: none;
}

/* --- App keret és nézetek --- */
.app {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

.view {
  display: flex;
  flex-direction: column;
  min-height: 100dvh;
  width: 100%;
  max-width: 600px;
  margin: 0 auto;
  animation: view-in 260ms var(--ease-out);
}

.view[hidden] {
  display: none;
}

@keyframes view-in {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: calc(var(--space-3) + var(--safe-top)) calc(var(--space-4) + var(--safe-right)) var(--space-3) calc(var(--space-4) + var(--safe-left));
  background: linear-gradient(to bottom, var(--bg) 70%, rgba(11, 13, 18, 0));
}

.topbar-title {
  flex: 1;
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -0.01em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.brand {
  flex: 1;
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

.brand-mark {
  width: 28px;
  height: 28px;
  border-radius: 9px;
  background: conic-gradient(from -90deg, var(--stage-start) 0 40%, var(--stage-mid) 40% 75%, var(--stage-end) 75% 100%);
  -webkit-mask: radial-gradient(circle at center, transparent 0 7px, #000 8px);
  mask: radial-gradient(circle at center, transparent 0 7px, #000 8px);
}

.brand-title {
  font-size: 24px;
  font-weight: 800;
  letter-spacing: -0.02em;
}

.view-body {
  flex: 1;
  padding: var(--space-2) calc(var(--space-4) + var(--safe-right)) var(--space-6) calc(var(--space-4) + var(--safe-left));
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}

.bottombar {
  position: sticky;
  bottom: 0;
  z-index: 5;
  padding: var(--space-3) calc(var(--space-4) + var(--safe-right)) calc(var(--space-4) + var(--safe-bottom)) calc(var(--space-4) + var(--safe-left));
  background: linear-gradient(to top, var(--bg) 60%, rgba(11, 13, 18, 0));
}

/* --- Gombok --- */
.btn {
  -webkit-appearance: none;
  appearance: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  min-height: var(--touch);
  padding: 0 var(--space-5);
  border: 1px solid transparent;
  border-radius: var(--radius-pill);
  background: var(--surface-2);
  color: var(--text);
  font-weight: 600;
  font-size: 16px;
  line-height: 1;
  cursor: pointer;
  transition: transform 120ms var(--ease-out), background-color var(--dur), color var(--dur), opacity var(--dur), box-shadow var(--dur);
}

.btn:active {
  transform: scale(0.96);
}

.btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.btn:disabled {
  opacity: 0.4;
  cursor: default;
  transform: none;
}

.btn-primary {
  background: var(--accent);
  color: var(--accent-ink);
  box-shadow: var(--shadow-glow);
}

.btn-primary:hover {
  background: var(--accent-hover);
}

.btn-danger {
  background: var(--danger);
  color: var(--danger-ink);
}

.btn-ghost {
  background: transparent;
  border-color: var(--border-strong);
  color: var(--text);
}

.btn-ghost:hover {
  background: var(--surface-2);
}

.btn-glass {
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(255, 255, 255, 0.1);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

.btn-icon {
  width: var(--touch);
  height: var(--touch);
  padding: 0;
  border-radius: 50%;
}

.btn-icon .icon {
  width: 24px;
  height: 24px;
}

.btn[hidden] {
  display: none;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

/* Telepítés-ikon: accent keret, hogy feltűnjön, de ne vegye el a figyelmet a csoportoktól */
.btn-install {
  border-color: var(--accent);
  color: var(--accent);
}

.btn-install:hover {
  background: rgba(215, 255, 74, 0.1);
}

.install-steps {
  margin: var(--space-3) 0 0;
  padding: 0;
  list-style: none;
  counter-reset: step;
  text-align: left;
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

.install-steps li {
  counter-increment: step;
  display: flex;
  align-items: center;
  gap: var(--space-3);
  line-height: 1.35;
}

.install-steps li::before {
  content: counter(step);
  flex: none;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--accent);
  color: var(--accent-ink);
  font-weight: 800;
  font-size: 14px;
}

.install-steps .icon {
  width: 20px;
  height: 20px;
  vertical-align: -4px;
  color: var(--accent);
}

.btn-sm {
  min-height: 40px;
  padding: 0 var(--space-4);
  font-size: 15px;
}

.btn-xl {
  min-height: 56px;
  font-size: 17px;
  font-weight: 700;
  padding: 0 var(--space-6);
}

.btn-block {
  width: 100%;
}

.btn-ico .icon {
  width: 22px;
  height: 22px;
}

/* --- Beviteli mezők --- */
.field {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.field-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-2);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.input {
  width: 100%;
  min-height: 52px;
  padding: 0 var(--space-4);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: 17px;
  font-weight: 600;
  outline: none;
  transition: border-color var(--dur), box-shadow var(--dur);
}

.input::placeholder {
  color: var(--text-3);
  font-weight: 500;
}

.input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(215, 255, 74, 0.18);
}

/* --- Kártyák --- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--space-4);
}

/* ==========================================================================
   Kezdőlap
   ========================================================================== */

.group-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

.group-card {
  position: relative;
  display: grid;
  grid-template-columns: 1fr auto;
  grid-template-areas:
    "head play"
    "strip play"
    "actions play";
  gap: var(--space-2) var(--space-3);
  padding: var(--space-4);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-1);
  transition: border-color var(--dur), transform 120ms var(--ease-out);
}

.group-card:active {
  transform: scale(0.99);
}

.group-card.is-last {
  border-color: rgba(215, 255, 74, 0.35);
}

.group-head {
  grid-area: head;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.group-name {
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -0.01em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.group-meta {
  font-size: 14px;
  color: var(--text-2);
  display: flex;
  gap: var(--space-2);
  align-items: center;
  flex-wrap: wrap;
}

.group-meta .dot {
  color: var(--text-3);
}

.badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: var(--radius-pill);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  background: rgba(215, 255, 74, 0.14);
  color: var(--accent);
}

.strip {
  grid-area: strip;
  display: flex;
  gap: 2px;
  height: 8px;
  border-radius: 4px;
  overflow: hidden;
  background: var(--surface-2);
}

.strip-seg {
  flex: var(--w) 1 0;
  min-width: 3px;
  border-radius: 2px;
}

.strip-seg.work {
  background: var(--work);
}

.strip-seg.rest {
  background: var(--rest);
}

.strip-seg.prep {
  background: var(--prep);
  opacity: 0.8;
}

.group-actions {
  grid-area: actions;
  display: flex;
  gap: var(--space-1);
  margin: 0 0 -6px -10px;
}

.group-actions .btn {
  color: var(--text-2);
  background: transparent;
}

.group-actions .btn:hover {
  color: var(--text);
  background: var(--surface-2);
}

.group-actions .btn-del:hover {
  color: var(--danger);
}

.group-play {
  grid-area: play;
  align-self: center;
  width: 64px;
  height: 64px;
  border-radius: 50%;
  padding: 0;
  background: var(--accent);
  color: var(--accent-ink);
  box-shadow: var(--shadow-glow);
}

.group-play .icon {
  width: 30px;
  height: 30px;
  margin-left: 3px;
}

.group-card-tap {
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: transparent;
  border: 0;
  padding: 0;
  cursor: pointer;
}

.group-card-tap:focus-visible {
  outline: 2px solid var(--accent);
}

.group-head,
.strip,
.group-actions,
.group-play {
  position: relative;
  z-index: 1;
}

.group-head,
.strip {
  pointer-events: none;
}

.empty {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  gap: var(--space-3);
  padding: var(--space-8) var(--space-4);
  color: var(--text-2);
}

.empty-art {
  width: 120px;
  height: 120px;
  border-radius: 50%;
  background: conic-gradient(from -90deg, var(--stage-start) 0 45%, var(--stage-mid) 45% 78%, var(--stage-end) 78% 100%);
  -webkit-mask: radial-gradient(circle at center, transparent 0 44px, #000 45px);
  mask: radial-gradient(circle at center, transparent 0 44px, #000 45px);
  opacity: 0.9;
  margin-bottom: var(--space-2);
}

.empty-title {
  font-size: 22px;
  font-weight: 800;
  color: var(--text);
  letter-spacing: -0.02em;
}

.empty-text {
  max-width: 300px;
  font-size: 15px;
}

/* ==========================================================================
   Szerkesztő
   ========================================================================== */

.editor-body {
  gap: var(--space-5);
}

.editor-summary {
  display: grid;
  grid-template-columns: 1fr 1fr;
  grid-template-areas:
    "a b"
    "strip strip";
  gap: var(--space-3) var(--space-4);
  padding: var(--space-4);
}

.summary-item {
  display: flex;
  flex-direction: column;
}

.summary-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-3);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.summary-value {
  font-size: 28px;
  font-weight: 800;
  letter-spacing: -0.03em;
  line-height: 1.1;
}

.summary-strip {
  grid-area: strip;
  display: flex;
  gap: 2px;
  height: 10px;
  border-radius: 5px;
  overflow: hidden;
  background: var(--surface-2);
}

.editor-section {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  flex-wrap: wrap;
}

.section-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--text-2);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.section-hint {
  font-size: 13px;
  color: var(--text-3);
}

/* Szegmentált kapcsoló */
.seg {
  display: inline-flex;
  padding: 3px;
  border-radius: var(--radius-pill);
  background: var(--surface-2);
  border: 1px solid var(--border);
}

.seg-btn {
  min-height: 40px;
  padding: 0 var(--space-4);
  border: 0;
  border-radius: var(--radius-pill);
  background: transparent;
  color: var(--text-2);
  font-weight: 700;
  font-size: 15px;
  cursor: pointer;
  transition: background-color var(--dur), color var(--dur);
}

.seg-btn.is-active.seg-work {
  background: var(--work);
  color: var(--work-ink);
}

.seg-btn.is-active.seg-rest {
  background: var(--rest);
  color: var(--rest-ink);
}

.seg-btn:focus-visible {
  outline: 2px solid var(--accent);
}

/* Előre beállított idők */
/* 6 oszlopos rács: 3 nagy preset (2-2 oszlop), majd 3 kicsi (2-2), végül 2 perc + Egyéni (3-3) */
.preset-grid {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: var(--space-2);
}

.preset-grid .preset {
  grid-column: span 2;
}

.preset-grid .preset:nth-child(7),
.preset-grid .preset:nth-child(8) {
  grid-column: span 3;
}

.preset {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0;
  min-height: 56px;
  padding: var(--space-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  transition: transform 120ms var(--ease-out), background-color var(--dur), border-color var(--dur);
}

.preset:active {
  transform: scale(0.95);
  background: var(--surface-2);
}

.preset:focus-visible {
  outline: 2px solid var(--accent);
}

.preset-num {
  font-size: 20px;
  font-weight: 800;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
}

.preset-unit {
  font-size: 12px;
  color: var(--text-2);
  font-weight: 600;
}

.preset-lg {
  min-height: 76px;
  border-width: 1px;
  background: linear-gradient(180deg, var(--surface-2), var(--surface));
}

.preset-lg .preset-num {
  font-size: 30px;
}

.preset-lg .preset-unit {
  font-size: 13px;
}

/* A gyors presetek a kiválasztott típus színét veszik fel */
.view-editor[data-next="work"] .preset-lg {
  border-color: rgba(255, 122, 69, 0.45);
}

.view-editor[data-next="work"] .preset-lg .preset-num {
  color: var(--work);
}

.view-editor[data-next="rest"] .preset-lg {
  border-color: rgba(59, 209, 242, 0.45);
}

.view-editor[data-next="rest"] .preset-lg .preset-num {
  color: var(--rest);
}

.preset-custom {
  border-style: dashed;
  border-color: var(--border-strong);
}

/* Blokk-lista */
.block-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.block-row {
  display: grid;
  grid-template-columns: auto 1fr auto;
  grid-template-areas: "idx main actions";
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-2) var(--space-2) var(--space-2) var(--space-3);
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 4px solid var(--type-color, var(--work));
  border-radius: var(--radius);
  animation: row-in 200ms var(--ease-out);
}

.block-row.work {
  --type-color: var(--work);
}

.block-row.rest {
  --type-color: var(--rest);
}

@keyframes row-in {
  from {
    opacity: 0;
    transform: translateY(4px);
  }
}

.block-idx {
  grid-area: idx;
  width: 28px;
  height: 28px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--surface-2);
  color: var(--text-2);
  font-size: 13px;
  font-weight: 700;
}

.block-main-wrap {
  grid-area: main;
  display: flex;
  align-items: center;
  gap: var(--space-3);
  min-width: 0;
  flex-wrap: wrap;
}

.block-main {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  min-width: 0;
  min-height: var(--touch);
  padding: 0;
  border: 0;
  background: transparent;
  color: inherit;
  text-align: left;
  cursor: pointer;
  border-radius: var(--radius-sm);
}

.block-main:focus-visible {
  outline: 2px solid var(--accent);
}

.block-time {
  flex: none;
  font-size: 24px;
  font-weight: 800;
  letter-spacing: -0.02em;
  min-width: 64px;
  white-space: nowrap;
}

.type-chip {
  flex: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
  min-height: 32px;
  padding: 0 12px 0 10px;
  border-radius: var(--radius-pill);
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  transition: background-color var(--dur), color var(--dur);
}

.type-chip::before {
  content: "";
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--type-color);
}

.type-chip:focus-visible {
  outline: 2px solid var(--accent);
}

.block-actions {
  grid-area: actions;
  display: flex;
  gap: 0;
  flex: none;
}

.block-actions .btn {
  width: 40px;
  height: 40px;
  min-height: 40px;
  color: var(--text-2);
  background: transparent;
}

.block-actions .btn:hover {
  color: var(--text);
  background: var(--surface-2);
}

.block-actions .btn:disabled {
  opacity: 0.2;
}

.block-actions .btn-del:hover {
  color: var(--danger);
}

/* Telefonon (≤ 479 px) két soros blokk: felül sorszám + idő + típus, alul a műveletek jobbra. */
@media (max-width: 479px) {
  .block-row {
    grid-template-columns: auto 1fr;
    grid-template-areas:
      "idx main"
      "actions actions";
    row-gap: var(--space-1);
    padding-bottom: var(--space-1);
  }

  .block-actions {
    justify-content: flex-end;
    margin-top: 2px;
    padding-top: 2px;
    border-top: 1px solid var(--border);
  }

  .block-actions .btn {
    width: 44px;
  }
}

.block-empty {
  padding: var(--space-6) var(--space-4);
  text-align: center;
  color: var(--text-3);
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius);
  font-size: 15px;
}

/* Beállítások */
.option-card {
  display: flex;
  flex-direction: column;
  padding: 0 var(--space-4);
}

.option-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: var(--space-2) var(--space-3);
  padding: var(--space-3) 0;
}

.option-text {
  flex: 1 1 150px;
  min-width: 0;
}

.option-row + .option-row {
  border-top: 1px solid var(--border);
}

.option-text {
  display: flex;
  flex-direction: column;
}

.option-label {
  font-weight: 700;
}

.option-hint {
  font-size: 13px;
  color: var(--text-3);
}

.stepper {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  padding: 2px;
  border-radius: var(--radius-pill);
  background: var(--surface-2);
  border: 1px solid var(--border);
}

.stepper-btn {
  width: 44px;
  height: 44px;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--text);
  display: grid;
  place-items: center;
  cursor: pointer;
}

.stepper-btn:active {
  background: var(--surface-3);
}

.stepper-btn:disabled {
  opacity: 0.3;
}

.stepper-btn .icon {
  width: 20px;
  height: 20px;
}

.stepper-value {
  min-width: 64px;
  text-align: center;
  font-weight: 800;
  font-size: 17px;
}

.editor-spacer {
  height: calc(var(--space-6) + var(--safe-bottom));
}

/* ==========================================================================
   Időtartam-választó lap (bottom sheet)
   ========================================================================== */

.sheet-backdrop {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  background: rgba(5, 6, 10, 0.72);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  animation: fade-in 180ms var(--ease-out);
}

.sheet-backdrop[hidden] {
  display: none;
}

@keyframes fade-in {
  from {
    opacity: 0;
  }
}

.sheet {
  width: 100%;
  max-width: 560px;
  padding: var(--space-3) var(--space-5) calc(var(--space-5) + var(--safe-bottom));
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-bottom: 0;
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
  animation: sheet-in 260ms var(--ease-out);
}

@keyframes sheet-in {
  from {
    transform: translateY(40px);
    opacity: 0;
  }
}

.sheet-handle {
  width: 40px;
  height: 4px;
  border-radius: 2px;
  background: var(--border-strong);
  margin: 0 auto;
}

.sheet-title {
  font-size: 18px;
  font-weight: 800;
  text-align: center;
  letter-spacing: -0.01em;
}

.duration-picker {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
}

.dp-col {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-1);
}

.dp-btn {
  width: 64px;
  height: 48px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface-2);
  color: var(--text);
  display: grid;
  place-items: center;
  cursor: pointer;
}

.dp-btn:active {
  background: var(--surface-3);
}

.dp-btn .icon {
  width: 22px;
  height: 22px;
}

.dp-input {
  width: 110px;
  height: 84px;
  margin: var(--space-1) 0 0;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg);
  color: var(--text);
  font: inherit;
  font-size: 48px;
  font-weight: 800;
  letter-spacing: -0.03em;
  text-align: center;
  -moz-appearance: textfield;
  appearance: textfield;
}

.dp-input::-webkit-outer-spin-button,
.dp-input::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

.dp-input:focus {
  outline: none;
  border-color: var(--accent);
}

.dp-input::selection {
  background: var(--accent);
  color: var(--accent-ink);
}

.dp-unit {
  font-size: 12px;
  font-weight: 700;
  color: var(--text-3);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: var(--space-1);
}

.dp-colon {
  font-size: 48px;
  font-weight: 800;
  color: var(--text-3);
  margin-top: -14px;
}

.sheet-type {
  align-self: center;
}

.sheet-type .seg-btn {
  min-width: 110px;
}

.sheet-error {
  color: var(--danger);
  font-size: 14px;
  text-align: center;
  font-weight: 600;
}

.sheet-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-3);
}

/* ==========================================================================
   Lejátszó
   ========================================================================== */

.view-player {
  position: relative;
  max-width: none;
  height: 100dvh;
  min-height: 0;
  overflow: hidden;
  --phase: var(--prep);
  --phase-ink: var(--prep-ink);
  --stage: var(--stage-start);
}

.view-player[data-phase="work"] {
  --phase: var(--work);
  --phase-ink: var(--work-ink);
}

.view-player[data-phase="rest"] {
  --phase: var(--rest);
  --phase-ink: var(--rest-ink);
}

.view-player[data-stage="mid"] {
  --stage: var(--stage-mid);
}

.view-player[data-stage="end"] {
  --stage: var(--stage-end);
}

.player-bg {
  position: absolute;
  inset: 0;
  z-index: 0;
  background:
    radial-gradient(120% 70% at 50% -10%, color-mix(in srgb, var(--phase) 32%, transparent), transparent 60%),
    radial-gradient(90% 50% at 50% 110%, color-mix(in srgb, var(--stage) 14%, transparent), transparent 60%),
    var(--bg);
  transition: background 600ms var(--ease-out);
}

.player-flash {
  position: absolute;
  inset: 0;
  z-index: 3;
  pointer-events: none;
  background: #fff;
  opacity: 0;
}

.view-player.is-flash .player-flash {
  animation: flash 650ms var(--ease-out);
}

@keyframes flash {
  0% {
    opacity: 0.85;
  }
  100% {
    opacity: 0;
  }
}

.player-top {
  position: relative;
  z-index: 2;
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: calc(var(--space-3) + var(--safe-top)) calc(var(--space-4) + var(--safe-right)) var(--space-2) calc(var(--space-4) + var(--safe-left));
}

.player-title-wrap {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
}

.player-group-name {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-2);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}

.player-round {
  font-size: 18px;
  font-weight: 800;
  letter-spacing: -0.01em;
}

.player-main {
  position: relative;
  z-index: 2;
  flex: 1;
  display: grid;
  grid-template-rows: 1fr auto;
  gap: var(--space-3);
  padding: 0 calc(var(--space-4) + var(--safe-right)) calc(var(--space-4) + var(--safe-bottom)) calc(var(--space-4) + var(--safe-left));
  min-height: 0;
}

/* A gyűrű a TÉNYLEGESEN maradt helyhez méreteződik (container query), nem a viewporthoz —
   iOS Safariban a böngészősávok miatt a dvh-alapú méret rálógott az infókártyákra. */
.player-stage {
  display: grid;
  place-items: center;
  min-height: 0;
  min-width: 0;
  align-self: stretch;
  justify-self: stretch;
  container-type: size;
}

.ring-wrap {
  position: relative;
  width: min(100cqw, 100cqh, 460px);
  aspect-ratio: 1;
  display: grid;
  place-items: center;
  container-type: inline-size;
}

.ring {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  transform: rotate(-90deg);
  overflow: visible;
}

.ring-track {
  fill: none;
  stroke: rgba(255, 255, 255, 0.08);
  stroke-width: 5.5;
}

.ring-progress {
  fill: none;
  stroke: var(--stage);
  stroke-width: 5.5;
  stroke-linecap: round;
  stroke-dasharray: 100;
  stroke-dashoffset: 0;
  filter: drop-shadow(0 0 6px color-mix(in srgb, var(--stage) 70%, transparent));
  transition: stroke 500ms var(--ease-out);
}

.ring-content {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  width: 78%;
  text-align: center;
}

.phase-label {
  display: inline-flex;
  align-items: center;
  padding: 6px 14px;
  border-radius: var(--radius-pill);
  background: var(--phase);
  color: var(--phase-ink);
  font-size: clamp(10px, 4.2cqw, 17px);
  font-weight: 800;
  letter-spacing: 0.12em;
  white-space: nowrap;
  transition: background-color 400ms var(--ease-out), color 400ms;
}

.clock {
  /* a gyűrű szélességéhez (cqw) arányos, így sosem lóg ki belőle */
  font-size: clamp(40px, 27cqw, 150px);
  font-weight: 800;
  letter-spacing: -0.05em;
  line-height: 1;
  color: var(--text);
  text-shadow: 0 0 40px color-mix(in srgb, var(--stage) 35%, transparent);
  transition: color 400ms var(--ease-out);
  margin: 4px 0 6px;
}

.view-player[data-stage="end"] .clock {
  color: var(--stage-end);
}

.view-player[data-stage="mid"] .clock {
  color: #fff;
}

.stage-pips {
  display: flex;
  gap: 8px;
}

.pip {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.14);
  transition: background-color 300ms, transform 300ms;
}

.view-player[data-stage="start"] .pip:nth-child(1),
.view-player[data-stage="mid"] .pip:nth-child(-n + 2),
.view-player[data-stage="end"] .pip:nth-child(-n + 3) {
  background: var(--stage);
}

/* Utolsó 5 mp: erős sürgetés — pulzálás + fényesebb gyűrű */
.view-player.is-urgent .clock {
  animation: pulse 1s var(--ease-out) infinite;
}

.view-player.is-urgent .ring-progress {
  stroke-width: 7;
  filter: drop-shadow(0 0 14px var(--stage));
}

.view-player.is-urgent .player-bg {
  animation: bg-pulse 1s ease-in-out infinite;
}

@keyframes pulse {
  0% {
    transform: scale(1.06);
  }
  35% {
    transform: scale(1);
  }
  100% {
    transform: scale(1);
  }
}

@keyframes bg-pulse {
  0%,
  100% {
    filter: brightness(1);
  }
  40% {
    filter: brightness(1.35);
  }
}

.view-player.is-paused .clock {
  opacity: 0.55;
  animation: none;
}

.view-player.is-paused .phase-label::after {
  content: " · SZÜNET";
}

.player-side {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

.info-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-2);
}

.info-card {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: var(--space-2) var(--space-3);
  min-height: 56px;
  justify-content: center;
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.07);
}

.info-card[hidden] {
  display: none;
}

.info-next {
  border-color: color-mix(in srgb, var(--next-color, var(--text-3)) 55%, transparent);
}

.info-next .info-value {
  color: var(--next-color, var(--text));
}

.info-label {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-3);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.info-value {
  font-size: 17px;
  font-weight: 800;
  letter-spacing: -0.01em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.session-bar {
  height: 4px;
  border-radius: 2px;
  background: rgba(255, 255, 255, 0.08);
  overflow: hidden;
}

.session-bar-fill {
  height: 100%;
  width: 0;
  border-radius: 2px;
  background: linear-gradient(90deg, var(--rest), var(--work));
  transition: width 300ms linear;
}

.controls {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: var(--space-3);
  padding-top: var(--space-1);
}

.btn-control {
  height: 64px;
  min-height: 64px;
  border-radius: var(--radius-pill);
  padding: 0;
}

.btn-control .icon {
  width: 28px;
  height: 28px;
}

/* A gomb btn-control is — a .btn-control.btn-main specifikusság kell a média-szabályokban, különben
   a .btn-control magassága felülírja, és ovális lesz. */
.btn-control.btn-main {
  width: 104px;
  height: 104px;
  min-height: 104px;
  aspect-ratio: 1;
  flex: none;
  border-radius: 50%;
  -webkit-tap-highlight-color: transparent;
  flex-direction: column;
  gap: 0;
  background: var(--accent);
  color: var(--accent-ink);
  box-shadow: 0 0 0 8px color-mix(in srgb, var(--accent) 16%, transparent), 0 16px 40px -10px color-mix(in srgb, var(--accent) 55%, transparent);
  font-size: 14px;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.btn-main .icon {
  width: 36px;
  height: 36px;
}

.view-player.is-running .btn-main {
  background: #fff;
  box-shadow: 0 0 0 8px rgba(255, 255, 255, 0.1), 0 16px 40px -10px rgba(255, 255, 255, 0.35);
}

.btn-stop {
  align-self: center;
  min-height: 44px;
  padding: 0 var(--space-5);
  background: transparent;
  border-color: rgba(255, 77, 94, 0.45);
  color: var(--danger);
  font-size: 15px;
}

.btn-stop:hover {
  background: rgba(255, 77, 94, 0.12);
}

.btn-stop .icon {
  width: 18px;
  height: 18px;
}

/* Alacsony álló kijelző (pl. Safari a címsorral és az alsó sávval): az alsó panel tömörebb,
   hogy a visszaszámláló gyűrű maradjon a domináns elem. */
@media (orientation: portrait) and (max-height: 760px) {
  .player-main {
    gap: var(--space-2);
  }

  .player-side {
    gap: var(--space-2);
  }

  .info-card {
    min-height: 46px;
    padding: 6px var(--space-3);
    gap: 0;
  }

  .info-label {
    font-size: 10px;
  }

  .info-value {
    font-size: 16px;
  }

  .btn-control.btn-main {
    width: 84px;
    height: 84px;
    min-height: 84px;
    font-size: 12px;
    box-shadow: 0 0 0 6px color-mix(in srgb, var(--accent) 16%, transparent), 0 12px 30px -10px color-mix(in srgb, var(--accent) 55%, transparent);
  }

  .btn-control.btn-main .icon {
    width: 30px;
    height: 30px;
  }

  .btn-control {
    height: 54px;
    min-height: 54px;
  }

  .btn-stop {
    min-height: 38px;
    font-size: 14px;
  }
}

/* Nagyon alacsony álló kijelző (iPhone SE + böngészősávok): csak a két legfontosabb infó marad,
   egy sorban — a hátralévő összidő és az ismétlés a fejlécben/sávon is követhető. */
@media (orientation: portrait) and (max-height: 600px) {
  .info-grid {
    grid-template-columns: 1fr 1fr;
  }

  .info-grid > .info-card:nth-child(n + 3) {
    display: none;
  }

  .info-card {
    min-height: 40px;
  }

  .btn-control.btn-main {
    width: 72px;
    height: 72px;
    min-height: 72px;
    font-size: 11px;
  }

  .btn-control.btn-main .icon {
    width: 26px;
    height: 26px;
  }

  .btn-control {
    height: 48px;
    min-height: 48px;
  }

  .player-group-name {
    display: none;
  }
}

/* Befejező képernyő */
.done-screen {
  position: absolute;
  inset: 0;
  z-index: 6;
  display: grid;
  place-items: center;
  padding: calc(var(--space-6) + var(--safe-top)) var(--space-5) calc(var(--space-6) + var(--safe-bottom));
  background: radial-gradient(90% 60% at 50% 0%, rgba(215, 255, 74, 0.22), transparent 60%), rgba(11, 13, 18, 0.94);
  animation: fade-in 300ms var(--ease-out);
}

.done-screen[hidden] {
  display: none;
}

.done-card {
  width: 100%;
  max-width: 420px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-4);
  text-align: center;
}

.done-badge {
  width: 96px;
  height: 96px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--accent);
  color: var(--accent-ink);
  box-shadow: var(--shadow-glow);
  animation: pop 500ms var(--ease-out);
}

.done-badge .icon {
  width: 52px;
  height: 52px;
  stroke-width: 3;
}

@keyframes pop {
  from {
    transform: scale(0.4);
    opacity: 0;
  }
}

.done-title {
  font-size: 32px;
  font-weight: 800;
  letter-spacing: -0.03em;
}

.done-sub {
  color: var(--text-2);
  font-size: 16px;
  margin-top: -8px;
}

.done-stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-3);
  width: 100%;
}

.done-stat {
  display: flex;
  flex-direction: column;
  padding: var(--space-4);
  border-radius: var(--radius-lg);
  background: var(--surface);
  border: 1px solid var(--border);
}

.done-stat-label {
  font-size: 12px;
  font-weight: 700;
  color: var(--text-3);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.done-stat-value {
  font-size: 34px;
  font-weight: 800;
  letter-spacing: -0.03em;
}

.done-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-3);
  width: 100%;
  margin-top: var(--space-2);
}

/* Fekvő: nagyobb számjegyek, oldalsó elrendezés */
@media (orientation: landscape) and (max-height: 620px) {
  .view-player {
    min-height: 100dvh;
  }

  .player-top {
    padding-top: calc(var(--space-2) + var(--safe-top));
    padding-bottom: 0;
  }

  .player-main {
    grid-template-rows: none;
    grid-template-columns: 1.15fr 1fr;
    align-items: center;
    gap: var(--space-4);
    padding-bottom: calc(var(--space-3) + var(--safe-bottom));
  }

  .ring-wrap {
    width: min(100cqw, 100cqh, 520px);
  }

  .player-side {
    justify-content: center;
    gap: var(--space-2);
  }

  .info-card {
    min-height: 50px;
  }

  .btn-control.btn-main {
    width: 88px;
    height: 88px;
    min-height: 88px;
  }

  .btn-control {
    height: 56px;
    min-height: 56px;
  }

  .btn-stop {
    min-height: 40px;
  }
}

/* Nagyon alacsony fekvő (pl. 844×390): a gyűrű dominál */
@media (orientation: landscape) and (max-height: 420px) {
  .info-grid {
    grid-template-columns: 1fr 1fr;
  }

  .btn-control.btn-main {
    width: 68px;
    height: 68px;
    min-height: 68px;
    font-size: 10px;
  }

  .btn-control.btn-main .icon {
    width: 24px;
    height: 24px;
  }

  .btn-control {
    height: 48px;
    min-height: 48px;
  }

  .info-card {
    min-height: 42px;
    padding: 4px var(--space-3);
  }

  .player-group-name {
    display: none;
  }
}

/* Nagy kijelző (tablet/asztali) */
@media (min-width: 900px) {
  .view-player .player-main {
    max-width: 1100px;
    margin: 0 auto;
    width: 100%;
  }
}

/* ==========================================================================
   SweetAlert2 témázás
   ========================================================================== */

.swal2-container {
  z-index: 100 !important;
}

.sz-swal.swal2-popup {
  background: var(--surface) !important;
  color: var(--text) !important;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-lg) !important;
  padding: var(--space-6) var(--space-5) var(--space-5) !important;
  width: min(92vw, 400px) !important;
  font-family: var(--font) !important;
}

.sz-swal .swal2-icon {
  margin: 0 auto var(--space-3);
  transform: scale(0.8);
}

.sz-swal .swal2-icon.swal2-warning {
  border-color: var(--stage-mid);
  color: var(--stage-mid);
}

.sz-swal .swal2-icon.swal2-question {
  border-color: var(--rest);
  color: var(--rest);
}

.sz-swal-title.swal2-title {
  font-size: 22px !important;
  font-weight: 800 !important;
  letter-spacing: -0.02em;
  color: var(--text) !important;
  padding: 0 !important;
}

.sz-swal-text.swal2-html-container {
  color: var(--text-2) !important;
  font-size: 15px !important;
  margin: var(--space-2) 0 0 !important;
}

.sz-swal-actions.swal2-actions {
  display: grid !important;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-3);
  width: 100%;
  margin: var(--space-5) 0 0 !important;
}

.sz-swal-actions.swal2-actions:has(.swal2-deny:not([style*="display: none"])),
.sz-swal-actions.swal2-actions:has(.swal2-cancel[style*="display: none"]) {
  grid-template-columns: 1fr;
}

.sz-swal-btn {
  margin: 0 !important;
  min-height: 52px !important;
}

.sz-toast.swal2-popup {
  padding: var(--space-3) var(--space-4) !important;
  width: auto !important;
  box-shadow: var(--shadow-1);
  margin-bottom: calc(var(--space-4) + var(--safe-bottom));
}

.sz-toast .swal2-title {
  font-size: 15px !important;
  font-weight: 700 !important;
}

.swal2-backdrop-show {
  background: rgba(5, 6, 10, 0.7) !important;
}

/* ==========================================================================
   Csökkentett mozgás
   ========================================================================== */

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }

  .view-player.is-urgent .clock {
    animation: none;
    text-decoration: underline;
    text-decoration-color: var(--stage-end);
    text-decoration-thickness: 0.06em;
    text-underline-offset: 0.08em;
  }

  .view-player.is-flash .player-flash {
    animation: none;
    opacity: 0.35;
    transition: opacity 0.01ms;
  }
}
