:root {
  color-scheme: dark;
  --bg: #0b1220;
  --surface: #0f172a;
  --surface-strong: #111d33;
  --surface-soft: rgba(30, 41, 59, 0.72);
  --border: rgba(148, 163, 184, 0.18);
  --border-strong: rgba(56, 189, 248, 0.42);
  --text: #f8fafc;
  --muted: #94a3b8;
  --muted-strong: #cbd5e1;
  --primary: #0ea5e9;
  --primary-strong: #2563eb;
  --primary-soft: rgba(14, 165, 233, 0.14);
  --primary-glow: rgba(14, 165, 233, 0.28);
  --success: #22c55e;
  --warning: #f59e0b;
  --danger: #ef4444;
  --radius: 1.35rem;
  --radius-small: 0.9rem;
  --radius-pill: 999px;
  --topbar-height: clamp(3.75rem, 7.5vh, 4.8rem);
  --font: Inter, ui-sans-serif, "Segoe UI Variable", "Segoe UI", system-ui,
    -apple-system, BlinkMacSystemFont, sans-serif;
}

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

html {
  min-height: 100%;
  background: var(--bg);
  -webkit-text-size-adjust: 100%;
}

body {
  min-width: 280px;
  min-height: 100vh;
  min-height: 100dvh;
  margin: 0;
  overflow: hidden;
  color: var(--text);
  background:
    radial-gradient(circle at 12% -18%, rgba(37, 99, 235, 0.24), transparent 40%),
    radial-gradient(circle at 88% 116%, rgba(14, 165, 233, 0.16), transparent 38%),
    var(--bg);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

button,
input,
select {
  font: inherit;
}

button,
a {
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

button {
  color: inherit;
}

a {
  color: inherit;
}

[hidden] {
  display: none !important;
}

.app-shell {
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
  padding:
    env(safe-area-inset-top, 0)
    env(safe-area-inset-right, 0)
    env(safe-area-inset-bottom, 0)
    env(safe-area-inset-left, 0);
}

.topbar {
  position: relative;
  z-index: 10;
  display: flex;
  flex: 0 0 var(--topbar-height);
  align-items: center;
  justify-content: space-between;
  min-height: var(--topbar-height);
  padding: 0 clamp(0.75rem, 2.5vw, 1.5rem);
  border-bottom: 1px solid var(--border);
  background: rgba(11, 18, 32, 0.84);
  box-shadow: 0 0.6rem 2rem rgba(2, 6, 23, 0.18);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.7rem;
  min-width: 0;
  color: var(--text);
  text-decoration: none;
}

.brand__mark {
  display: grid;
  width: clamp(2.2rem, 5.5vh, 2.8rem);
  height: clamp(2.2rem, 5.5vh, 2.8rem);
  flex: 0 0 auto;
  place-items: center;
  border: 1px solid rgba(125, 211, 252, 0.36);
  border-radius: 0.85rem;
  background: linear-gradient(145deg, var(--primary), var(--primary-strong));
  box-shadow: 0 0.55rem 1.4rem rgba(37, 99, 235, 0.28);
}

.brand__mark svg {
  width: 78%;
  height: 78%;
  overflow: visible;
  fill: none;
  stroke: #fff;
  stroke-width: 2.7;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.brand__text {
  display: flex;
  flex-direction: column;
  min-width: 0;
  line-height: 1.08;
}

.brand__text strong {
  font-size: clamp(1.02rem, 2.6vw, 1.25rem);
  font-weight: 850;
  letter-spacing: -0.025em;
}

.brand__text small {
  margin-top: 0.18rem;
  overflow: hidden;
  color: var(--muted);
  font-size: clamp(0.68rem, 1.7vw, 0.8rem);
  font-weight: 650;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.topbar__actions {
  display: flex;
  align-items: center;
  gap: clamp(0.35rem, 1.2vw, 0.55rem);
}

.icon-button,
.return-button {
  min-height: 2.65rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-small);
  background: rgba(30, 41, 59, 0.68);
  box-shadow: 0 0.35rem 1.1rem rgba(2, 6, 23, 0.12);
  transition:
    border-color 150ms ease,
    background-color 150ms ease,
    transform 150ms ease;
}

.icon-button {
  display: inline-grid;
  width: 2.65rem;
  flex: 0 0 2.65rem;
  padding: 0;
  place-items: center;
  cursor: pointer;
}

.return-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  padding: 0.6rem 0.85rem;
  color: #e0f2fe;
  font-size: 0.86rem;
  font-weight: 800;
  text-decoration: none;
}

.icon-button:hover,
.return-button:hover {
  border-color: rgba(56, 189, 248, 0.45);
  background: rgba(30, 64, 175, 0.26);
}

.icon-button:active,
.return-button:active,
.mode-button:active,
.action-button:active,
.presets button:active {
  transform: translateY(1px) scale(0.985);
}

.icon {
  width: 1.25rem;
  height: 1.25rem;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.9;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.icon--sound-off,
.icon--collapse,
.sound-button[aria-pressed="false"] .icon--sound-on,
body.is-fullscreen .icon--expand {
  display: none;
}

.sound-button[aria-pressed="false"] .icon--sound-off,
body.is-fullscreen .icon--collapse {
  display: block;
}

.app-main {
  display: flex;
  flex: 1 1 auto;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  padding: clamp(0.55rem, 1.8vh, 1rem) clamp(0.55rem, 2vw, 1.25rem)
    clamp(0.4rem, 1vh, 0.75rem);
}

.mode-switcher {
  display: grid;
  width: min(100%, 52rem);
  flex: 0 0 auto;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: clamp(0.35rem, 1vw, 0.55rem);
  margin: 0 auto clamp(0.55rem, 1.5vh, 0.9rem);
  padding: 0.3rem;
  border: 1px solid var(--border);
  border-radius: 1.05rem;
  background: rgba(15, 23, 42, 0.68);
  box-shadow: 0 0.65rem 2rem rgba(2, 6, 23, 0.18);
}

.mode-button {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  min-width: 0;
  min-height: clamp(2.7rem, 6.4vh, 3.25rem);
  padding: 0.55rem 0.7rem;
  border: 1px solid transparent;
  border-radius: 0.78rem;
  color: var(--muted-strong);
  background: transparent;
  font-size: clamp(0.76rem, 2vw, 0.9rem);
  font-weight: 750;
  cursor: pointer;
  transition:
    color 150ms ease,
    background-color 150ms ease,
    border-color 150ms ease,
    transform 150ms ease;
}

.mode-button:hover:not(:disabled) {
  color: #fff;
  background: rgba(51, 65, 85, 0.66);
}

.mode-button.is-active {
  border-color: rgba(56, 189, 248, 0.48);
  color: #fff;
  background: linear-gradient(
    135deg,
    rgba(14, 165, 233, 0.24),
    rgba(37, 99, 235, 0.22)
  );
  box-shadow:
    inset 0 0 0 1px rgba(125, 211, 252, 0.06),
    0 0.35rem 1rem rgba(14, 165, 233, 0.1);
}

.mode-button .icon {
  width: 1.15rem;
  height: 1.15rem;
  flex: 0 0 auto;
}

.mode-button small {
  position: absolute;
  top: 0.12rem;
  right: 0.24rem;
  color: #7dd3fc;
  font-size: 0.48rem;
  font-weight: 850;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

.mode-button:disabled {
  opacity: 0.42;
  cursor: not-allowed;
}

.stage {
  position: relative;
  display: flex;
  flex: 1 1 auto;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background:
    linear-gradient(180deg, rgba(30, 41, 59, 0.32), rgba(15, 23, 42, 0.68)),
    var(--surface);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.025),
    0 1.3rem 3.5rem rgba(2, 6, 23, 0.26);
  isolation: isolate;
}

.stage::before {
  position: absolute;
  z-index: -1;
  top: -20%;
  left: 50%;
  width: min(58rem, 86vw);
  height: min(24rem, 55vh);
  border-radius: 50%;
  background: radial-gradient(
    circle,
    rgba(14, 165, 233, 0.13),
    transparent 68%
  );
  content: "";
  transform: translateX(-50%);
  pointer-events: none;
}

.stage.is-ending {
  border-color: rgba(245, 158, 11, 0.45);
  box-shadow:
    inset 0 0 0 1px rgba(245, 158, 11, 0.08),
    0 0 3rem rgba(245, 158, 11, 0.1);
}

.stage.is-finished {
  border-color: rgba(239, 68, 68, 0.52);
  animation: finish-pulse 1.4s ease-in-out 2;
}

.tool-view {
  display: none;
  width: 100%;
  min-width: 0;
  min-height: 0;
  padding: clamp(0.8rem, 2vh, 1.4rem) clamp(0.8rem, 3vw, 2rem);
  overflow: auto;
  overscroll-behavior: contain;
}

.tool-view.is-active {
  display: flex;
  animation: view-in 180ms ease-out both;
}

.clock-view {
  align-items: center;
  justify-content: center;
  flex-direction: column;
  text-align: center;
}

.timer-view,
.stopwatch-view {
  align-items: center;
  justify-content: center;
  flex-direction: column;
}

.eyebrow {
  margin: 0;
  color: #7dd3fc;
  font-size: clamp(0.72rem, 1.8vw, 0.92rem);
  font-weight: 850;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.clock-display {
  display: flex;
  align-items: flex-start;
  justify-content: center;
  margin: clamp(0.35rem, 1.5vh, 0.8rem) 0 0;
  color: #fff;
  font-size: clamp(5rem, min(26vw, 29vh), 19rem);
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.075em;
  line-height: 0.82;
  text-shadow:
    0 0 2.2rem rgba(14, 165, 233, 0.1),
    0 0.35rem 1rem rgba(2, 6, 23, 0.24);
}

.clock-display__seconds {
  min-width: 1.1em;
  margin: 0.02em 0 0 0.16em;
  color: #38bdf8;
  font-size: 0.22em;
  font-weight: 750;
  letter-spacing: -0.02em;
  line-height: 1;
  text-align: left;
}

.date-display {
  margin: clamp(0.85rem, 2.4vh, 1.45rem) 0 0;
  color: var(--muted-strong);
  font-size: clamp(0.92rem, 2.8vw, 1.3rem);
  font-weight: 650;
  letter-spacing: 0.01em;
}

.view-heading {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.7rem;
  margin-bottom: clamp(0.25rem, 1vh, 0.5rem);
}

.status-pill {
  margin: 0;
  padding: 0.27rem 0.6rem;
  border: 1px solid rgba(148, 163, 184, 0.22);
  border-radius: var(--radius-pill);
  color: var(--muted-strong);
  background: rgba(51, 65, 85, 0.52);
  font-size: clamp(0.65rem, 1.8vw, 0.78rem);
  font-weight: 750;
}

.status-pill[data-status="running"] {
  border-color: rgba(34, 197, 94, 0.3);
  color: #bbf7d0;
  background: rgba(22, 101, 52, 0.22);
}

.status-pill[data-status="paused"] {
  border-color: rgba(245, 158, 11, 0.34);
  color: #fde68a;
  background: rgba(146, 64, 14, 0.22);
}

.status-pill[data-status="finished"] {
  border-color: rgba(239, 68, 68, 0.38);
  color: #fecaca;
  background: rgba(153, 27, 27, 0.26);
}

.time-display {
  display: flex;
  align-items: baseline;
  justify-content: center;
  width: 100%;
  min-height: 0.9em;
  margin: 0;
  color: #fff;
  font-size: clamp(5.3rem, min(31vw, 36vh), 21rem);
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.07em;
  line-height: 0.86;
  text-align: center;
  text-shadow: 0 0.3rem 1rem rgba(2, 6, 23, 0.22);
}

.time-display__fraction {
  min-width: 0.88em;
  color: #38bdf8;
  font-size: 0.28em;
  font-weight: 750;
  letter-spacing: -0.03em;
}

.stopwatch-view .time-display {
  font-size: clamp(5.8rem, min(33vw, 39vh), 23rem);
}

.timer-view[data-state="running"] .time-display,
.stopwatch-view[data-state="running"] .time-display {
  font-size: clamp(6rem, min(35vw, 45vh), 26rem);
}

.timer-view[data-state="running"] .view-heading,
.stopwatch-view[data-state="running"] .view-heading {
  margin-bottom: 0;
}

.timer-setup {
  display: flex;
  width: min(100%, 46rem);
  align-items: end;
  justify-content: center;
  gap: clamp(0.8rem, 2.5vw, 1.5rem);
  margin-top: clamp(0.55rem, 1.7vh, 1rem);
}

.duration-fields {
  display: flex;
  flex: 0 0 auto;
  align-items: end;
  justify-content: center;
  gap: 0.45rem;
}

.duration-field {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  color: var(--muted);
  font-size: 0.7rem;
  font-weight: 750;
  letter-spacing: 0.04em;
  text-align: center;
  text-transform: uppercase;
}

.duration-field input {
  width: clamp(4.4rem, 12vw, 5.8rem);
  min-height: 3.1rem;
  padding: 0.42rem 0.25rem;
  border: 1px solid var(--border);
  border-radius: 0.8rem;
  outline: none;
  color: var(--text);
  background: rgba(11, 18, 32, 0.8);
  font-size: clamp(1.1rem, 3vw, 1.35rem);
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  text-align: center;
  transition:
    border-color 150ms ease,
    box-shadow 150ms ease;
}

.duration-field input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 0.22rem rgba(14, 165, 233, 0.16);
}

.duration-separator {
  padding-bottom: 0.55rem;
  color: var(--muted);
  font-size: 1.65rem;
  font-weight: 800;
}

.presets {
  display: grid;
  flex: 1 1 auto;
  grid-template-columns: repeat(5, minmax(3.25rem, 1fr));
  gap: 0.4rem;
}

.presets button {
  min-height: 3.1rem;
  padding: 0.45rem 0.5rem;
  border: 1px solid var(--border);
  border-radius: 0.78rem;
  color: var(--muted-strong);
  background: rgba(30, 41, 59, 0.62);
  font-size: clamp(0.72rem, 1.8vw, 0.84rem);
  font-weight: 750;
  white-space: nowrap;
  cursor: pointer;
  transition:
    border-color 150ms ease,
    color 150ms ease,
    background-color 150ms ease,
    transform 150ms ease;
}

.presets button:hover,
.presets button.is-active {
  border-color: rgba(56, 189, 248, 0.48);
  color: #e0f2fe;
  background: var(--primary-soft);
}

.main-actions {
  display: grid;
  width: min(100%, 34rem);
  flex: 0 0 auto;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.65rem;
  margin-top: clamp(0.75rem, 2vh, 1.2rem);
}

.main-actions--centered {
  margin-top: clamp(1.4rem, 4vh, 2.5rem);
}

.timer-view[data-state="running"] .main-actions,
.stopwatch-view[data-state="running"] .main-actions {
  width: auto;
  grid-template-columns: minmax(8.5rem, 11rem) auto;
  gap: 0.45rem;
  margin-top: clamp(0.35rem, 1vh, 0.65rem);
}

.action-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.55rem;
  min-height: clamp(3.15rem, 7vh, 3.85rem);
  padding: 0.75rem 1rem;
  border: 1px solid transparent;
  border-radius: 0.95rem;
  font-size: clamp(0.85rem, 2.2vw, 0.98rem);
  font-weight: 800;
  cursor: pointer;
  transition:
    border-color 150ms ease,
    background-color 150ms ease,
    box-shadow 150ms ease,
    transform 150ms ease;
}

.action-button--primary {
  border-color: rgba(125, 211, 252, 0.26);
  color: #fff;
  background: linear-gradient(135deg, var(--primary), var(--primary-strong));
  box-shadow: 0 0.65rem 1.6rem rgba(37, 99, 235, 0.25);
}

.action-button--primary:hover {
  box-shadow:
    0 0.75rem 1.8rem rgba(37, 99, 235, 0.34),
    0 0 0 1px rgba(125, 211, 252, 0.12);
}

.action-button--secondary {
  border-color: var(--border);
  color: var(--muted-strong);
  background: rgba(30, 41, 59, 0.72);
}

.action-button--secondary:hover {
  border-color: rgba(148, 163, 184, 0.35);
  color: #fff;
  background: rgba(51, 65, 85, 0.76);
}

.timer-view[data-state="running"] .action-button,
.stopwatch-view[data-state="running"] .action-button {
  min-height: 2.75rem;
  padding: 0.45rem 0.8rem;
  border-radius: 0.8rem;
  font-size: 0.82rem;
}

.timer-view[data-state="running"] .action-button--secondary,
.stopwatch-view[data-state="running"] .action-button--secondary {
  width: 2.75rem;
  padding: 0;
}

.timer-view[data-state="running"] .action-button--secondary span,
.stopwatch-view[data-state="running"] .action-button--secondary span {
  display: none;
}

.timer-view[data-state="running"] .action-button .icon,
.stopwatch-view[data-state="running"] .action-button .icon {
  width: 1.05rem;
  height: 1.05rem;
}

.action-icon--pause,
.action-button.is-running .action-icon--play {
  display: none;
}

.action-button.is-running .action-icon--pause {
  display: block;
}

.sr-only {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}

/* Chrono multiphases ------------------------------------------------------ */

.multiphase-view {
  position: relative;
  padding: 0;
  --phase-background: #166534;
  --phase-foreground: #ffffff;
  --phase-muted: rgba(255, 255, 255, 0.76);
  --phase-panel: rgba(0, 0, 0, 0.19);
  --phase-border: rgba(255, 255, 255, 0.28);
}

.multiphase-view[data-state="editing"] {
  align-items: stretch;
  justify-content: flex-start;
}

.multiphase-view[data-state="running"],
.multiphase-view[data-state="paused"],
.multiphase-view[data-state="finished"] {
  overflow: hidden;
  color: var(--phase-foreground);
  background: var(--phase-background);
  transition:
    color 180ms ease,
    background-color 180ms ease;
}

.multiphase-editor {
  width: min(100%, 72rem);
  margin: 0 auto;
  padding: clamp(1rem, 2.5vw, 2rem);
}

.multiphase-editor__heading {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 1.25rem;
  margin-bottom: 1.15rem;
}

.multiphase-editor__heading h1 {
  margin: 0.28rem 0 0;
  color: var(--text);
  font-size: clamp(1.35rem, 3vw, 2rem);
  line-height: 1.15;
}

.multiphase-editor__heading p:not(.eyebrow) {
  max-width: 46rem;
  margin: 0.38rem 0 0;
  color: var(--muted);
  font-size: clamp(0.8rem, 1.8vw, 0.92rem);
}

.program-summary {
  display: flex;
  flex: 0 0 auto;
  flex-direction: column;
  align-items: flex-end;
  padding: 0.65rem 0.85rem;
  border: 1px solid var(--border-strong);
  border-radius: 0.85rem;
  background: var(--primary-soft);
  line-height: 1.05;
}

.program-summary strong {
  color: #e0f2fe;
  font-size: clamp(1.2rem, 3vw, 1.55rem);
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.04em;
}

.program-summary span {
  margin-top: 0.28rem;
  color: #7dd3fc;
  font-size: 0.7rem;
  font-weight: 750;
}

.program-toolbar {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 0.8rem;
}

.program-name-field,
.phase-name-field,
.block-name-field {
  display: flex;
  min-width: 0;
  flex-direction: column;
  gap: 0.28rem;
}

.program-name-field {
  width: min(100%, 30rem);
}

.program-name-field > span,
.phase-name-field > span {
  color: var(--muted);
  font-size: 0.67rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.program-name-field input,
.block-name-field input,
.phase-name-field input,
.repeat-field input,
.phase-duration input {
  min-width: 0;
  border: 1px solid var(--border);
  outline: none;
  color: var(--text);
  background: rgba(11, 18, 32, 0.76);
  font-weight: 720;
  transition:
    border-color 150ms ease,
    box-shadow 150ms ease;
}

.program-name-field input:focus,
.block-name-field input:focus,
.phase-name-field input:focus,
.repeat-field input:focus,
.phase-duration input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 0.2rem rgba(14, 165, 233, 0.14);
}

.program-name-field input {
  min-height: 2.75rem;
  padding: 0.58rem 0.72rem;
  border-radius: 0.72rem;
  font-size: 0.96rem;
}

.program-toolbar__actions,
.row-actions {
  display: flex;
  flex: 0 0 auto;
  align-items: center;
  gap: 0.3rem;
}

.small-button,
.row-actions button,
.add-phase-button {
  border: 1px solid var(--border);
  color: var(--muted-strong);
  background: rgba(30, 41, 59, 0.66);
  font-weight: 750;
  cursor: pointer;
  transition:
    border-color 150ms ease,
    color 150ms ease,
    background-color 150ms ease,
    transform 150ms ease;
}

.small-button:hover,
.row-actions button:hover,
.add-phase-button:hover {
  border-color: rgba(56, 189, 248, 0.5);
  color: #fff;
  background: rgba(14, 165, 233, 0.13);
}

.small-button:active,
.row-actions button:active,
.add-phase-button:active,
.player-icon-button:active {
  transform: translateY(1px) scale(0.98);
}

.small-button {
  min-height: 2.6rem;
  padding: 0.55rem 0.78rem;
  border-radius: 0.72rem;
  font-size: 0.78rem;
}

.small-button--add {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  min-height: 3.15rem;
  padding-inline: 1rem;
}

.small-button--add .icon {
  width: 1.05rem;
  height: 1.05rem;
}

.blocks-list {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.empty-program,
.empty-phases {
  color: var(--muted);
  text-align: center;
}

.empty-program {
  display: flex;
  min-height: 8rem;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 0.25rem;
  padding: 1.25rem;
  border: 1px dashed var(--border);
  border-radius: 1rem;
  background: rgba(15, 23, 42, 0.42);
}

.empty-program strong {
  color: var(--muted-strong);
}

.empty-program span {
  font-size: 0.82rem;
}

.empty-phases {
  margin: 0;
  padding: 1rem;
  border-bottom: 1px solid rgba(148, 163, 184, 0.1);
  font-size: 0.78rem;
}

.sequence-block {
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 1rem;
  background: rgba(15, 23, 42, 0.72);
  box-shadow: 0 0.65rem 1.8rem rgba(2, 6, 23, 0.12);
}

.sequence-block__header {
  display: grid;
  grid-template-columns: auto minmax(8rem, 1fr) auto auto;
  align-items: center;
  gap: 0.65rem;
  padding: 0.62rem 0.72rem;
  border-bottom: 1px solid var(--border);
  background: rgba(30, 41, 59, 0.48);
}

.block-number {
  padding: 0.28rem 0.48rem;
  border-radius: 0.48rem;
  color: #7dd3fc;
  background: rgba(14, 165, 233, 0.12);
  font-size: 0.68rem;
  font-weight: 850;
  white-space: nowrap;
}

.block-name-field input {
  width: 100%;
  min-height: 2.4rem;
  padding: 0.42rem 0.58rem;
  border-radius: 0.62rem;
  font-size: 0.85rem;
}

.repeat-field {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  color: var(--muted);
  font-size: 0.67rem;
  font-weight: 750;
  white-space: nowrap;
}

.repeat-field__control {
  display: flex;
  align-items: center;
  gap: 0.2rem;
}

.repeat-field input {
  width: 3.4rem;
  min-height: 2.4rem;
  padding: 0.36rem;
  border-radius: 0.62rem;
  font-size: 0.88rem;
  text-align: center;
}

.repeat-field b {
  color: var(--muted-strong);
  font-size: 0.9rem;
}

.row-actions button {
  display: inline-grid;
  width: 2.35rem;
  height: 2.35rem;
  padding: 0;
  place-items: center;
  border-radius: 0.62rem;
}

.row-actions .icon {
  width: 1rem;
  height: 1rem;
}

.row-actions button:disabled {
  opacity: 0.28;
  pointer-events: none;
}

.row-actions button.danger-action:hover {
  border-color: rgba(248, 113, 113, 0.45);
  color: #fecaca;
  background: rgba(239, 68, 68, 0.12);
}

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

.phase-row {
  display: grid;
  grid-template-columns: auto minmax(8rem, 1fr) auto auto;
  align-items: end;
  gap: 0.65rem;
  padding: 0.68rem 0.72rem;
  border-bottom: 1px solid rgba(148, 163, 184, 0.1);
}

.phase-color-field {
  position: relative;
  display: grid;
  width: 2.75rem;
  height: 2.75rem;
  place-items: center;
  overflow: hidden;
  border: 2px solid rgba(255, 255, 255, 0.18);
  border-radius: 0.78rem;
  background: #16a34a;
  box-shadow: 0 0.35rem 0.85rem rgba(2, 6, 23, 0.2);
  cursor: pointer;
}

.phase-color-field::after {
  position: absolute;
  right: 0.28rem;
  bottom: 0.28rem;
  width: 0.42rem;
  height: 0.42rem;
  border: 1px solid rgba(255, 255, 255, 0.7);
  border-radius: 50%;
  background: currentColor;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.35);
  content: "";
  pointer-events: none;
}

.phase-color-field input {
  position: absolute;
  inset: -0.4rem;
  width: calc(100% + 0.8rem);
  height: calc(100% + 0.8rem);
  padding: 0;
  border: 0;
  opacity: 0;
  cursor: pointer;
}

.phase-name-field input {
  width: 100%;
  min-height: 2.75rem;
  padding: 0.5rem 0.62rem;
  border-radius: 0.68rem;
  font-size: 0.88rem;
}

.phase-duration {
  display: flex;
  align-items: flex-end;
  gap: 0.3rem;
}

.phase-duration > span {
  padding-bottom: 0.48rem;
  color: var(--muted);
  font-size: 1rem;
  font-weight: 800;
}

.phase-duration label {
  display: flex;
  flex-direction: column;
  gap: 0.26rem;
  color: var(--muted);
  font-size: 0.62rem;
  font-weight: 800;
  text-align: center;
  text-transform: uppercase;
}

.phase-duration input {
  width: 3.65rem;
  min-height: 2.75rem;
  padding: 0.4rem 0.25rem;
  border-radius: 0.68rem;
  font-size: 0.88rem;
  text-align: center;
}

.phase-row__actions {
  min-height: 2.75rem;
}

.add-phase-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  min-height: 2.4rem;
  margin: 0.58rem 0.72rem 0.68rem;
  padding: 0.42rem 0.7rem;
  border-style: dashed;
  border-radius: 0.68rem;
  font-size: 0.75rem;
}

.add-phase-button .icon {
  width: 0.95rem;
  height: 0.95rem;
}

.editor-bottom-bar {
  position: sticky;
  z-index: 5;
  bottom: -1px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.8rem;
  margin-top: 0.9rem;
  padding: 0.7rem;
  border: 1px solid var(--border);
  border-radius: 1rem;
  background: rgba(11, 18, 32, 0.92);
  box-shadow: 0 -0.7rem 2rem rgba(2, 6, 23, 0.2);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
}

.start-program-button {
  min-width: min(100%, 16rem);
}

.multiphase-player {
  position: absolute;
  inset: 0;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto auto;
  gap: clamp(0.25rem, 1.2vh, 0.7rem);
  width: 100%;
  height: 100%;
  padding: clamp(0.7rem, 2vw, 1.35rem);
  overflow: hidden;
}

.player-topline {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.player-program-name,
.player-progress,
.player-block-info,
.player-next,
.player-phase-name {
  margin: 0;
}

.player-program-name {
  max-width: 60%;
  overflow: hidden;
  font-size: clamp(0.72rem, 1.8vw, 0.92rem);
  font-weight: 760;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.player-progress {
  padding: 0.32rem 0.62rem;
  border: 1px solid var(--phase-border);
  border-radius: var(--radius-pill);
  background: var(--phase-panel);
  font-size: clamp(0.66rem, 1.6vw, 0.82rem);
  font-weight: 800;
  white-space: nowrap;
}

.player-center {
  display: flex;
  min-height: 0;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  text-align: center;
}

.player-phase-name {
  max-width: 94%;
  overflow: hidden;
  font-size: clamp(1.8rem, min(6vw, 8vh), 5.5rem);
  font-weight: 900;
  letter-spacing: -0.045em;
  line-height: 1.02;
  text-overflow: ellipsis;
  white-space: nowrap;
  text-shadow: 0 0.2rem 0.7rem rgba(0, 0, 0, 0.12);
}

.player-time {
  display: flex;
  min-width: 0;
  align-items: center;
  justify-content: center;
  margin: clamp(0.1rem, 1vh, 0.5rem) 0;
  font-size: clamp(7rem, min(39vw, 54vh), 32rem);
  font-weight: 900;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.085em;
  line-height: 0.82;
  text-shadow: 0 0.35rem 1rem rgba(0, 0, 0, 0.16);
}

.player-block-info {
  color: var(--phase-muted);
  font-size: clamp(0.78rem, 2vw, 1.05rem);
  font-weight: 760;
}

.player-next {
  justify-self: center;
  max-width: min(100%, 38rem);
  overflow: hidden;
  padding: 0.42rem 0.75rem;
  border: 1px solid var(--phase-border);
  border-radius: var(--radius-pill);
  color: var(--phase-muted);
  background: var(--phase-panel);
  font-size: clamp(0.68rem, 1.7vw, 0.85rem);
  font-weight: 720;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.player-actions {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: clamp(0.35rem, 1.1vw, 0.6rem);
}

.player-main-button,
.player-icon-button {
  border: 1px solid var(--phase-border);
  color: var(--phase-foreground);
  background: var(--phase-panel);
  box-shadow: 0 0.5rem 1.4rem rgba(0, 0, 0, 0.1);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

.player-main-button {
  min-width: clamp(8rem, 19vw, 11rem);
  min-height: clamp(2.7rem, 6.5vh, 3.5rem);
}

.player-main-button:hover,
.player-icon-button:hover {
  border-color: currentColor;
  background: var(--phase-panel);
}

.player-icon-button {
  display: inline-grid;
  width: clamp(2.7rem, 6.5vh, 3.5rem);
  height: clamp(2.7rem, 6.5vh, 3.5rem);
  flex: 0 0 auto;
  padding: 0;
  place-items: center;
  border-radius: 0.9rem;
  cursor: pointer;
}

.player-icon-button .icon {
  width: 1.1rem;
  height: 1.1rem;
}

.player-icon-button:disabled {
  opacity: 0.32;
  cursor: not-allowed;
}

.multiphase-view[data-state="paused"] .player-main-button .action-icon--pause,
.multiphase-view[data-state="finished"] .player-main-button .action-icon--pause {
  display: none;
}

.multiphase-view[data-state="paused"] .player-main-button .action-icon--play,
.multiphase-view[data-state="finished"] .player-main-button .action-icon--play {
  display: block;
}

.multiphase-view[data-state="finished"] .player-next {
  visibility: hidden;
}

body.is-multiphase-playing .mode-switcher,
body.is-multiphase-playing .app-footer {
  display: none;
}

body.is-multiphase-playing .app-main {
  padding-top: clamp(0.35rem, 1vh, 0.55rem);
  padding-bottom: clamp(0.35rem, 1vh, 0.55rem);
}

body.is-multiphase-playing .stage {
  border-color: var(--phase-border);
}

.app-footer {
  display: flex;
  width: 100%;
  flex: 0 0 auto;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  min-height: clamp(1.7rem, 4vh, 2.35rem);
  padding: clamp(0.3rem, 0.8vh, 0.5rem) 0.2rem 0;
  color: var(--muted);
  font-size: clamp(0.62rem, 1.5vw, 0.74rem);
}

.keyboard-help,
.app-signature {
  margin: 0;
}

.keyboard-help {
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

kbd {
  padding: 0.12rem 0.34rem;
  border: 1px solid var(--border);
  border-bottom-color: rgba(148, 163, 184, 0.35);
  border-radius: 0.32rem;
  color: var(--muted-strong);
  background: rgba(30, 41, 59, 0.76);
  box-shadow: 0 1px 0 rgba(148, 163, 184, 0.15);
  font-family: inherit;
  font-size: 0.9em;
  font-weight: 700;
}

.app-signature {
  white-space: nowrap;
}

.app-signature a {
  color: #7dd3fc;
  font-weight: 750;
  text-decoration: none;
}

.toast {
  position: fixed;
  z-index: 100;
  right: max(1rem, env(safe-area-inset-right));
  bottom: max(1rem, env(safe-area-inset-bottom));
  max-width: min(28rem, calc(100vw - 2rem));
  padding: 0.8rem 1rem;
  border: 1px solid rgba(125, 211, 252, 0.28);
  border-radius: 0.85rem;
  color: #e0f2fe;
  background: rgba(15, 23, 42, 0.96);
  box-shadow: 0 1rem 3rem rgba(2, 6, 23, 0.42);
  font-size: 0.85rem;
  font-weight: 650;
  animation: toast-in 180ms ease-out both;
}

button:focus-visible,
a:focus-visible,
input:focus-visible {
  outline: 3px solid rgba(56, 189, 248, 0.58);
  outline-offset: 3px;
}

@keyframes view-in {
  from {
    opacity: 0;
    transform: translateY(0.3rem);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes toast-in {
  from {
    opacity: 0;
    transform: translateY(0.5rem);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes finish-pulse {
  50% {
    box-shadow:
      inset 0 0 0 1px rgba(239, 68, 68, 0.12),
      0 0 4rem rgba(239, 68, 68, 0.18);
  }
}

@media (max-width: 720px) {
  .return-button span {
    display: none;
  }

  .return-button {
    width: 2.65rem;
    padding: 0;
  }

  .mode-button {
    gap: 0.3rem;
    padding-inline: 0.35rem;
  }

  .timer-setup {
    flex-direction: column;
    align-items: center;
  }

  .presets {
    width: 100%;
  }

  .sequence-block__header {
    grid-template-columns: auto minmax(0, 1fr) auto;
  }

  .sequence-block__header > .row-actions {
    grid-column: 1 / -1;
    justify-content: flex-end;
  }

  .phase-row {
    grid-template-columns: auto minmax(0, 1fr) auto;
  }

  .phase-row__actions {
    grid-column: 1 / -1;
    justify-content: flex-end;
  }
}

@media (max-width: 540px) {
  .brand__text small {
    display: none;
  }

  .mode-switcher {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .mode-button {
    min-height: 2.55rem;
  }

  .presets {
    grid-template-columns: repeat(5, minmax(0, 1fr));
  }

  .presets button {
    min-height: 2.75rem;
    padding-inline: 0.2rem;
  }

  .main-actions {
    gap: 0.5rem;
  }

  .action-button {
    padding-inline: 0.55rem;
  }

  .keyboard-help {
    display: none;
  }

  .app-footer {
    justify-content: center;
  }

  .multiphase-editor {
    padding: 0.8rem 0.65rem;
  }

  .multiphase-editor__heading {
    align-items: stretch;
    flex-direction: column;
    gap: 0.65rem;
  }

  .program-summary {
    align-items: center;
    flex-direction: row;
    justify-content: space-between;
  }

  .program-summary span {
    margin: 0;
  }

  .program-toolbar {
    align-items: stretch;
    flex-direction: column;
    gap: 0.55rem;
  }

  .program-name-field {
    width: 100%;
  }

  .program-toolbar__actions {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .sequence-block__header {
    grid-template-columns: auto minmax(0, 1fr);
    gap: 0.5rem;
  }

  .repeat-field {
    justify-content: space-between;
  }

  .sequence-block__header > .row-actions {
    grid-column: auto;
    justify-content: flex-end;
  }

  .phase-row {
    grid-template-columns: auto minmax(0, 1fr);
    gap: 0.55rem;
  }

  .phase-duration {
    grid-column: 1 / -1;
    justify-content: flex-end;
  }

  .phase-row__actions {
    grid-column: 1 / -1;
  }

  .editor-bottom-bar {
    align-items: stretch;
    flex-direction: column;
  }

  .start-program-button {
    width: 100%;
  }

  .player-phase-name {
    white-space: normal;
  }

  .player-time {
    font-size: clamp(5.7rem, min(39vw, 43vh), 13rem);
  }

  .player-program-name {
    max-width: 52%;
  }
}

@media (max-width: 360px) {
  .sound-button {
    display: none;
  }

  .tool-view {
    padding-inline: 0.55rem;
  }

  .action-button span {
    font-size: 0.78rem;
  }

  .row-actions {
    gap: 0.18rem;
  }

  .row-actions button {
    width: 2.2rem;
    height: 2.2rem;
  }

  .player-actions {
    gap: 0.25rem;
  }

  .player-main-button {
    min-width: 6.8rem;
  }
}

@media (orientation: landscape) and (max-height: 650px) {
  :root {
    --topbar-height: 3.35rem;
  }

  .brand__mark {
    width: 2.15rem;
    height: 2.15rem;
    border-radius: 0.68rem;
  }

  .brand__text small {
    display: none;
  }

  .icon-button,
  .return-button {
    min-height: 2.25rem;
  }

  .icon-button {
    width: 2.25rem;
  }

  .app-main {
    padding-top: 0.4rem;
    padding-bottom: 0.25rem;
  }

  .mode-switcher {
    margin-bottom: 0.4rem;
    padding: 0.2rem;
  }

  .mode-button {
    min-height: 2.2rem;
    padding-block: 0.35rem;
  }

  .tool-view {
    padding-block: 0.45rem;
  }

  .clock-display {
    font-size: clamp(4.8rem, min(23vw, 37vh), 12rem);
  }

  .date-display {
    margin-top: 0.65rem;
  }

  .time-display {
    font-size: clamp(4.8rem, min(27vw, 38vh), 12rem);
  }

  .stopwatch-view .time-display {
    font-size: clamp(5.2rem, min(29vw, 41vh), 13rem);
  }

  .timer-view[data-state="running"] .time-display,
  .stopwatch-view[data-state="running"] .time-display {
    font-size: clamp(5.5rem, min(32vw, 47vh), 15rem);
  }

  .timer-setup {
    flex-direction: row;
    align-items: end;
    margin-top: 0.35rem;
  }

  .duration-field {
    gap: 0.15rem;
  }

  .duration-field input,
  .presets button {
    min-height: 2.5rem;
  }

  .main-actions {
    margin-top: 0.55rem;
  }

  .main-actions--centered {
    margin-top: 1rem;
  }

  .action-button {
    min-height: 2.7rem;
    padding-block: 0.45rem;
  }

  .app-footer {
    min-height: 1.35rem;
    padding-top: 0.15rem;
  }

  .multiphase-player {
    grid-template-rows: auto minmax(0, 1fr) auto auto;
    padding: 0.5rem 0.7rem;
  }

  .player-phase-name {
    font-size: clamp(1.5rem, min(5vw, 8vh), 3rem);
  }

  .player-time {
    font-size: clamp(6rem, min(36vw, 55vh), 18rem);
  }

  .player-main-button,
  .player-icon-button {
    min-height: 2.5rem;
  }

  .player-icon-button {
    width: 2.5rem;
    height: 2.5rem;
  }
}

@media (hover: none), (pointer: coarse) {
  .icon-button,
  .return-button {
    min-width: 2.75rem;
    min-height: 2.75rem;
  }

  .mode-button,
  .action-button,
  .presets button {
    min-height: 2.9rem;
  }
}

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