:root {
  color-scheme: dark;
  --bg: #0a0d12;
  --panel: #0f131a;
  --panel-elevated: #141922;
  --accent: #5fe3c1;
  --accent-strong: #7bf5d6;
  --accent-rgb: 95, 227, 193;
  --accent-strong-rgb: 123, 245, 214;
  --text: #e6edf3;
  --text-muted: #94a3b8;
  --stroke: rgba(148, 163, 184, 0.2);
  --shadow: 0 16px 36px rgba(0, 0, 0, 0.45);
  --progress: 0deg;
  --ring-thickness: 16px;
  --core-size: min(333px, 70vw);
  --label-y: 70%;
}

@font-face {
  font-family: "Material Icons";
  font-style: normal;
  font-weight: 400;
  src: url("fonts/material-icons.woff2") format("woff2");
  font-display: swap;
}

@font-face {
  font-family: "Material Icons Outlined";
  font-style: normal;
  font-weight: 400;
  src: url("fonts/material-icons-outlined.woff2") format("woff2");
  font-display: swap;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

* {
  scrollbar-width: thin;
  scrollbar-color: rgba(148, 163, 184, 0.45) rgba(8, 11, 16, 0.35);
}

*::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}

*::-webkit-scrollbar-track {
  background: rgba(8, 11, 16, 0.35);
  border-radius: 999px;
}

*::-webkit-scrollbar-thumb {
  background: rgba(148, 163, 184, 0.45);
  border-radius: 999px;
  border: 2px solid rgba(8, 11, 16, 0.35);
}

*::-webkit-scrollbar-thumb:hover {
  background: rgba(148, 163, 184, 0.7);
}

body {
  min-height: 100vh;
  font-family: "Inter", "Segoe UI", sans-serif;
  background: linear-gradient(180deg, #0b1017 0%, #07090d 100%);
  color: var(--text);
  display: flex;
  align-items: stretch;
  justify-content: stretch;
  padding: 0;
  overflow-x: hidden;
  position: relative;
  transition: background 1.2s ease;
}

.app {
  width: 100%;
  min-height: 100vh;
  display: grid;
  gap: 24px;
  animation: fadeIn 0.6s ease;
  position: relative;
  z-index: 1;
}

.timer-card {
  background: transparent;
  border-radius: 0;
  padding: clamp(20px, 4vw, 32px);
  border: none;
  box-shadow: none;
  display: block;
  position: relative;
  min-height: 100vh;
}

.top-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  transition: opacity 0.2s ease;
  position: relative;
  z-index: 5;
}

.top-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.mode-hint {
  margin-top: 12px;
  min-height: 14px;
  text-align: center;
  font-size: 14px;
  text-transform: uppercase;
  letter-spacing: 0.2em;
  color: var(--text-muted);
  opacity: 0;
  transform: translateY(-6px);
  transition: opacity 0.35s ease, transform 0.35s ease;
  pointer-events: none;
}

.mode-hint.is-visible {
  opacity: 1;
  transform: translateY(0);
}

.timer-face {
  width: calc(var(--core-size) + (var(--ring-thickness) * 2));
  aspect-ratio: 1;
  border-radius: 50%;
  margin: 0;
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  display: grid;
  place-items: center;
  background: conic-gradient(var(--accent-strong) var(--progress), rgba(255, 255, 255, 0.06) 0deg);
  transition: background 0.3s ease, transform 0.12s ease, box-shadow 1s ease;
  cursor: pointer;
  z-index: 2;
  user-select: none;
}

.timer-face:hover {
  box-shadow: 0 0 0 1px rgba(var(--accent-rgb), 0.18);
}

.timer-face:active {
  transform: translate(-50%, -50%) scale(0.992);
}

.timer-face:focus-visible {
  outline: 1px solid rgba(var(--accent-rgb), 0.4);
  outline-offset: 8px;
}

.timer-face::before {
  content: "";
  position: absolute;
  inset: var(--ring-thickness);
  border-radius: 50%;
  background: radial-gradient(circle at top, #141c26 0%, #0b1017 70%);
  box-shadow: inset 0 0 25px rgba(0, 0, 0, 0.7);
  z-index: 2;
}

.timer-face::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 50%;
  border: 1px solid rgba(var(--accent-strong-rgb), 0.35);
  opacity: 0;
  pointer-events: none;
  z-index: 1;
  transition: opacity 1.5s ease;
}

.completion-wave {
  position: absolute;
  inset: -2px;
  border-radius: 50%;
  border: 1px solid rgba(var(--accent-strong-rgb), 0.3);
  opacity: 0;
  pointer-events: none;
  z-index: 1;
  transition: opacity 1.5s ease;
}

.completion-wave::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 50%;
  border: 1px solid rgba(var(--accent-strong-rgb), 0.2);
  opacity: 0;
  transition: opacity 1.5s ease;
}

.steady-glow {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  opacity: 0;
  pointer-events: none;
  z-index: 0;
  box-shadow:
    0 0 calc(10px + var(--ring-thickness)) rgba(var(--accent-strong-rgb), 0.24),
    0 0 calc(26px + var(--ring-thickness)) rgba(var(--accent-strong-rgb), 0.18),
    0 0 calc(44px + var(--ring-thickness)) rgba(var(--accent-strong-rgb), 0.12);
  transition: opacity 1s ease;
}

.face-content {
  position: absolute;
  inset: var(--ring-thickness);
  text-align: center;
  z-index: 3;
}

.time-display {
  font-size: clamp(28px, calc(var(--core-size) * 0.16), 56px);
  line-height: 1.1;
  max-width: calc(var(--core-size) - 32px);
  padding: 0 8px;
  font-variant-numeric: tabular-nums;
  color: #fff;
  letter-spacing: 0.06em;
  text-shadow:
    2px  0   0 #000,
   -2px  0   0 #000,
    0    2px  0 #000,
    0   -2px  0 #000;
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  transition: color 0.6s ease, text-shadow 0.6s ease, opacity 0.7s ease;
  user-select: none;
}

.time-display.complete {
  font-size: clamp(22px, 6vw, 40px);
  letter-spacing: 0.2em;
  animation: completeTextPulse 2.4s ease-in-out infinite;
}

.time-display.is-fading {
  opacity: 0;
}

.label-stack {
  position: absolute;
  top: var(--label-y);
  left: 50%;
  transform: translate(-50%, -50%);
  display: grid;
  gap: 6px;
  justify-items: center;
  min-width: 120px;
  user-select: none;
}

.mode-toggle {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  background: rgba(11, 15, 20, 0.6);
  border-radius: 14px;
  padding: 4px;
  gap: 6px;
  border: 1px solid rgba(148, 163, 184, 0.14);
}

.mode-toggle.small {
  width: 168px;
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.mode-btn {
  font-family: inherit;
  font-size: 14px;
  padding: 9px 12px;
  border-radius: 10px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.2s ease;
  display: grid;
  place-items: center;
}

.mode-btn.active {
  background: rgba(var(--accent-strong-rgb), 0.16);
  border-color: rgba(var(--accent-strong-rgb), 0.35);
  color: var(--accent-strong);
}

.mode-btn:not(.active):hover,
.mode-btn:not(.active):focus-visible {
  background: rgba(148, 163, 184, 0.12);
  border-color: rgba(148, 163, 184, 0.35);
  color: var(--text);
  box-shadow: 0 0 12px rgba(148, 163, 184, 0.2);
}

.mode-btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

.inputs {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.inputs label {
  display: grid;
  gap: 6px;
  color: var(--text-muted);
  font-size: 13px;
  min-width: 0;
}

.inputs input {
  font-size: 16px;
  padding: 9px 12px;
  background: var(--panel-elevated);
  border: 1px solid rgba(148, 163, 184, 0.18);
  border-radius: 10px;
  color: var(--text);
  transition: border 0.2s ease;
  font-variant-numeric: tabular-nums;
  width: 100%;
  max-width: 100%;
  min-width: 0;
}

.inputs input:focus {
  outline: none;
  border-color: rgba(var(--accent-strong-rgb), 0.5);
  box-shadow: 0 0 0 2px rgba(var(--accent-strong-rgb), 0.15);
}

.inputs input:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.pomodoro-inputs {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
}

.pomodoro-group,
.timer-group {
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: end;
  gap: 12px;
}

.group-label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-width: 28px;
  justify-content: center;
  align-self: end;
  text-align: center;
  font-size: 12px;
  text-transform: uppercase;
  color: var(--text-muted);
}

.settings-icon {
  font-size: 20px;
  color: rgba(230, 237, 243, 0.25);
  margin-bottom: 10px;
}

.pomodoro-time {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.pomodoro-inputs label {
  display: grid;
  gap: 6px;
  color: var(--text-muted);
  font-size: 13px;
  min-width: 0;
}

.pomodoro-inputs input {
  font-size: 14px;
  padding: 9px 12px;
  background: var(--panel-elevated);
  border: 1px solid rgba(148, 163, 184, 0.18);
  border-radius: 10px;
  color: var(--text);
  transition: border 0.2s ease;
  font-variant-numeric: tabular-nums;
  width: 100%;
  max-width: 100%;
  min-width: 0;
}

.pomodoro-inputs input:focus {
  outline: none;
  border-color: rgba(var(--accent-strong-rgb), 0.5);
  box-shadow: 0 0 0 2px rgba(var(--accent-strong-rgb), 0.15);
}

.stats-summary {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.summary-item {
  display: grid;
  gap: 4px;
}

.summary-value {
  font-size: 16px;
  font-weight: 600;
  letter-spacing: 0.08em;
}

.summary-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--text-muted);
}

.history-list {
  display: grid;
  gap: 8px;
  overflow-y: auto;
  min-height: 0;
  padding-right: 6px;
  align-content: start;
  grid-auto-rows: minmax(36px, auto);
}

.timeline-item {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 10px;
  font-size: 12px;
  color: var(--text-muted);
  border-bottom: 1px solid rgba(148, 163, 184, 0.1);
  min-height: 36px;
  padding: 6px 0;
}

.timeline-item.is-new {
  color: var(--text);
  animation: timelineReveal 0.6s ease both;
  will-change: transform, opacity;
}

.timeline-item:last-child {
  border-bottom: none;
  padding-bottom: 0;
}

.timeline-icon {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 14px;
  color: var(--text);
  justify-self: center;
}

.timeline-duration {
  font-size: 12px;
  letter-spacing: 0.1em;
  color: var(--text);
  text-align: center;
  justify-self: center;
}

.timeline-time {
  font-size: 11px;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  justify-self: center;
}

.stats-panel {
  position: fixed;
  top: 50%;
  right: clamp(16px, 4vw, 36px);
  width: min(320px, 40vw);
  height: min(520px, 70vh);
  background: transparent;
  border: none;
  border-radius: 0;
  box-shadow: none;
  display: grid;
  gap: 16px;
  grid-template-rows: auto 1fr auto;
  padding: 12px 8px;
  transform: translate(0, -50%);
  transition: opacity 0.35s ease;
  opacity: 0;
  z-index: 8;
  overflow: hidden;
  pointer-events: none;
}

.stats-panel.is-open {
  opacity: 1;
  pointer-events: auto;
}

.stats-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(6, 9, 13, 0.35);
  backdrop-filter: blur(8px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.35s ease;
  z-index: 7;
}

.stats-backdrop.is-open {
  opacity: 1;
  pointer-events: auto;
}

@media (min-width: 721px) {
  .stats-backdrop {
    background: transparent;
    backdrop-filter: none;
  }

  .stats-backdrop.is-open {
    opacity: 0;
    pointer-events: none;
  }
}

.stats-footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  padding-top: 6px;
}

.text-btn {
  background: transparent;
  border: 1px solid rgba(148, 163, 184, 0.28);
  color: var(--text-muted);
  font-size: 11px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  padding: 8px 12px;
  border-radius: 999px;
  cursor: pointer;
  transition: color 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
}

.text-btn:hover,
.text-btn:focus-visible {
  color: var(--text);
  border-color: rgba(var(--accent-strong-rgb), 0.5);
  box-shadow: 0 0 14px rgba(var(--accent-strong-rgb), 0.2);
}

.text-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  border-color: rgba(148, 163, 184, 0.16);
  box-shadow: none;
}

.ghost-btn {
  background: transparent;
  border: 1px solid rgba(148, 163, 184, 0.2);
  color: var(--text-muted);
  padding: 10px 12px;
  border-radius: 12px;
  cursor: pointer;
  transition: border 0.2s ease, color 0.2s ease;
}

.ghost-btn:hover {
  border-color: rgba(var(--accent-strong-rgb), 0.35);
  color: var(--text);
}

.floating-btn {
  position: fixed;
  bottom: calc(24px + env(safe-area-inset-bottom, 0px));
  right: calc(24px + env(safe-area-inset-right, 0px));
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 1px solid rgba(148, 163, 184, 0.2);
  background: rgba(8, 11, 16, 0.7);
  color: var(--text-muted);
  display: grid;
  place-items: center;
  cursor: pointer;
  transition: border 0.2s ease, color 0.2s ease, transform 0.2s ease, opacity 0.2s ease;
  z-index: 6;
}

.floating-btn:hover {
  border-color: rgba(var(--accent-strong-rgb), 0.35);
  color: var(--text);
  transform: translateY(-2px);
}

.floating-btn.is-active {
  border-color: rgba(var(--accent-strong-rgb), 0.45);
  color: var(--accent-strong);
}

button {
  font-family: inherit;
}

.material-icons,
.material-icons-outlined {
  font-family: "Material Icons";
  font-weight: normal;
  font-style: normal;
  font-size: 18px;
  line-height: 1;
  letter-spacing: normal;
  text-transform: none;
  display: inline-block;
  white-space: nowrap;
  word-wrap: normal;
  direction: ltr;
  -webkit-font-feature-settings: "liga";
  -webkit-font-smoothing: antialiased;
}

.material-icons-outlined {
  font-family: "Material Icons Outlined";
}

.mode-icon {
  width: 18px;
  height: 18px;
  display: block;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.6;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.icon-line {
  display: block;
}

.icon-fill {
  display: none;
}

.mode-btn.active .icon-line {
  display: none;
}

.mode-btn.active .icon-fill {
  display: block;
}

.mode-btn.active .mode-icon {
  fill: currentColor;
  stroke: none;
}

.icon-btn {
  background: transparent;
  border: 1px solid rgba(148, 163, 184, 0.2);
  color: var(--text-muted);
  width: 36px;
  height: 36px;
  border-radius: 999px;
  display: grid;
  place-items: center;
  cursor: pointer;
  transition: border 0.2s ease, color 0.2s ease, background 0.2s ease;
}

.icon-btn.small {
  width: 32px;
  height: 32px;
}

.icon-btn:hover,
.icon-btn:focus-visible {
  color: var(--text);
  border-color: rgba(var(--accent-strong-rgb), 0.35);
}

.icon-btn.is-active {
  color: var(--accent-strong);
  border-color: rgba(var(--accent-strong-rgb), 0.45);
  background: rgba(var(--accent-strong-rgb), 0.12);
}

.settings {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  z-index: 10;
}

.settings.hidden {
  display: none;
}

.settings-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(4, 6, 10, 0.6);
  backdrop-filter: blur(6px);
}

.settings-panel {
  position: relative;
  width: min(420px, 94vw);
  background: var(--panel);
  border-radius: 20px;
  padding: 20px;
  padding-bottom: calc(20px + env(safe-area-inset-bottom, 0px));
  border: 1px solid rgba(148, 163, 184, 0.16);
  box-shadow: var(--shadow);
  display: grid;
  gap: 18px;
  max-height: 85vh;
  overflow-y: auto;
}

.confirm {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  z-index: 12;
}

.confirm.hidden {
  display: none;
}

.confirm-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(4, 6, 10, 0.6);
  backdrop-filter: blur(6px);
}

.confirm-panel {
  position: relative;
  width: min(360px, 88vw);
  background: var(--panel);
  border-radius: 18px;
  padding: 20px;
  padding-bottom: calc(20px + env(safe-area-inset-bottom, 0px));
  border: 1px solid rgba(148, 163, 184, 0.16);
  box-shadow: var(--shadow);
  display: grid;
  gap: 12px;
  z-index: 1;
}

.confirm-title {
  font-size: 12px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.confirm-message {
  font-size: 13px;
  line-height: 1.5;
  color: var(--text);
}

.confirm-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 6px;
}

.confirm-btn {
  border: 1px solid rgba(148, 163, 184, 0.24);
  background: transparent;
  color: var(--text-muted);
  padding: 8px 14px;
  border-radius: 999px;
  font-size: 12px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  cursor: pointer;
  transition: border 0.2s ease, color 0.2s ease, box-shadow 0.2s ease;
}

.confirm-btn:hover,
.confirm-btn:focus-visible {
  color: var(--text);
  border-color: rgba(var(--accent-strong-rgb), 0.4);
  box-shadow: 0 0 14px rgba(var(--accent-strong-rgb), 0.18);
}

.confirm-btn.primary {
  background: rgba(var(--accent-strong-rgb), 0.2);
  color: var(--accent-strong);
  border-color: rgba(var(--accent-strong-rgb), 0.5);
}

.confirm-btn.primary:hover,
.confirm-btn.primary:focus-visible {
  box-shadow: 0 0 18px rgba(var(--accent-strong-rgb), 0.3);
}

.settings-section {
  display: grid;
  gap: 12px;
  padding: 12px 0;
  border-top: 1px solid rgba(148, 163, 184, 0.08);
}

.settings-section:first-of-type {
  border-top: none;
  padding-top: 4px;
}

.settings-hint {
    color: color-mix(
    in srgb,
    var(--text-muted) 50%,
    transparent
  );
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.16em;
}

.toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.toggle-label {
  color: var(--text-muted);
  font-size: 13px;
}

.toggle {
  position: relative;
  width: 44px;
  height: 24px;
  display: inline-block;
}

.toggle input {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

.toggle-track {
  position: absolute;
  inset: 0;
  border-radius: 999px;
  background: rgba(148, 163, 184, 0.2);
  border: 1px solid rgba(148, 163, 184, 0.25);
  transition: background 0.2s ease, border 0.2s ease;
}

.toggle-track::after {
  content: "";
  position: absolute;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  top: 2px;
  left: 2px;
  background: #0b1017;
  border: 1px solid rgba(255, 255, 255, 0.12);
  transition: transform 0.2s ease, background 0.2s ease;
}

.toggle input:checked + .toggle-track {
  background: rgba(var(--accent-rgb), 0.25);
  border-color: rgba(var(--accent-rgb), 0.35);
}

.toggle input:checked + .toggle-track::after {
  transform: translateX(20px);
  background: var(--accent);
}

.toggle input:focus-visible + .toggle-track {
  box-shadow: 0 0 0 2px rgba(var(--accent-strong-rgb), 0.2);
}

.swatches {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-around;
  gap: 10px;
}

.swatch {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.2);
  background: var(--swatch);
  cursor: pointer;
  transition: transform 0.15s ease, border 0.2s ease, box-shadow 0.2s ease;
}

.swatch:hover {
  transform: scale(1.05);
}

.swatch.is-active {
  border-color: rgba(255, 255, 255, 0.7);
  box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.12);
}

.swatch:focus-visible {
  outline: 2px solid rgba(var(--accent-strong-rgb), 0.4);
  outline-offset: 3px;
}

.ring-options {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.ring-option {
  background: transparent;
  border: 1px solid rgba(148, 163, 184, 0.2);
  color: var(--text-muted);
  padding: 8px 10px;
  border-radius: 10px;
  font-size: 13px;
  cursor: pointer;
  transition: border 0.2s ease, color 0.2s ease, background 0.2s ease;
}

.ring-option:hover {
  border-color: rgba(var(--accent-strong-rgb), 0.35);
  color: var(--text);
}

.ring-option.is-active {
  background: rgba(var(--accent-strong-rgb), 0.16);
  border-color: rgba(var(--accent-strong-rgb), 0.35);
  color: var(--accent-strong);
}

.ring-option:focus-visible {
  outline: 2px solid rgba(var(--accent-strong-rgb), 0.4);
  outline-offset: 2px;
}

.save-btn {
  width: 100%;
  padding: 10px 12px;
  border-radius: 12px;
  border: none;
  background: linear-gradient(140deg, var(--accent), var(--accent-strong));
  color: #041318;
  font-weight: 600;
  cursor: pointer;
}

.save-btn:hover {
  box-shadow: 0 10px 20px rgba(var(--accent-strong-rgb), 0.2);
}

.save-btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
  box-shadow: none;
}

.phase-label {
  font-size: 11px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--text-muted);
  min-height: 14px;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

body.is-running .timer-face {
  box-shadow: 0 0 0 1px rgba(var(--accent-rgb), 0.3),
    0 0 18px rgba(var(--accent-rgb), 0.12);
}

body.is-running .top-row {
  opacity: 0.4;
}

body.is-running .floating-btn {
  opacity: 0.4;
}

body.has-ended .top-row {
  opacity: 0.4;
}

body.has-ended .floating-btn {
  opacity: 0.4;
}

body.is-running.hide-controls .top-row {
  opacity: 0;
  pointer-events: none;
}

body.is-running.hide-controls .floating-btn {
  opacity: 0;
  pointer-events: none;
}

body.has-ended.hide-controls .top-row {
  opacity: 0;
  pointer-events: none;
}

body.has-ended.hide-controls .floating-btn {
  opacity: 0;
  pointer-events: none;
}

body.has-ended .timer-face {
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.22);
  background: conic-gradient(
    rgba(var(--accent-strong-rgb), 0.45) var(--progress),
    rgba(255, 255, 255, 0.05) 0deg
  );
  animation: finishGlow 2.8s ease-in-out infinite;
}
body.has-ended .timer-face::after {
  opacity: 1;
  animation: wave 2.4s ease-out infinite;
}

body::before,
body::after {
  content: "";
  position: fixed;
  width: 140vmax;
  height: 140vmax;
  top: 50%;
  left: 50%;
  border-radius: 50%;
  background: radial-gradient(
    circle,
    rgba(255, 255, 255, 0) 56%,
    rgba(255, 255, 255, 0.16) 60%,
    rgba(255, 255, 255, 0) 64%
  );
  opacity: 0;
  transform: translate(-50%, -50%) scale(0.6);
  pointer-events: none;
  z-index: 0;
  transition: opacity 0.8s ease;
}

body.has-ended {
  background:
    radial-gradient(circle at center, rgba(255, 255, 255, 0.04), rgba(7, 9, 13, 0) 58%),
    linear-gradient(180deg, #0b1017 0%, #07090d 100%);
}

body.has-ended::before {
  animation: centerRipple 3.6s ease-out infinite both;
}

body.has-ended::after {
  animation: centerRipple 3.6s ease-out infinite both;
  animation-delay: 1.8s;
}

body.has-ended .completion-wave {
  opacity: 1;
  animation: pulseRing 2.6s ease-out infinite;
}

body.has-ended .completion-wave::after {
  opacity: 1;
  animation: pulseRing 2.6s ease-out infinite;
  animation-delay: 1.3s;
}

body.has-ended .timer-face:hover {
  animation: none;
}

body.has-ended .timer-face:hover::after {
  animation: none;
  opacity: 1;
}

body.has-ended .timer-face:hover .completion-wave,
body.has-ended .timer-face:hover .completion-wave::after {
  animation: none;
  opacity: 1;
}

body.has-ended .timer-face:hover .steady-glow {
  opacity: 1;
}

@keyframes wave {
  0% {
    transform: scale(1);
    opacity: 0.55;
  }
  70% {
    transform: scale(1.05);
    opacity: 0;
  }
  100% {
    transform: scale(1.05);
    opacity: 0;
  }
}

@keyframes pulseRing {
  0% {
    transform: scale(1);
    opacity: 0.45;
  }
  70% {
    transform: scale(1.08);
    opacity: 0;
  }
  100% {
    transform: scale(1.08);
    opacity: 0;
  }
}

@keyframes finishGlow {
  0% {
    box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.2),
      0 0 18px rgba(var(--accent-rgb), 0.16);
  }
  50% {
    box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.32),
      0 0 32px rgba(var(--accent-rgb), 0.28);
  }
  100% {
    box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.2),
      0 0 18px rgba(var(--accent-rgb), 0.16);
  }
}

@keyframes completeTextPulse {
  0% {
    color: #ffffff;
    text-shadow:
      2px 0 0 #000,
      -2px 0 0 #000,
      0 2px 0 #000,
      0 -2px 0 #000,
      0 0 10px rgba(255, 255, 255, 0.12);
  }
  50% {
    color: var(--text);
    text-shadow:
      2px 0 0 #000,
      -2px 0 0 #000,
      0 2px 0 #000,
      0 -2px 0 #000,
      0 0 16px rgba(255, 255, 255, 0.28);
  }
  100% {
    color: #ffffff;
    text-shadow:
      2px 0 0 #000,
      -2px 0 0 #000,
      0 2px 0 #000,
      0 -2px 0 #000,
      0 0 10px rgba(255, 255, 255, 0.12);
  }
}

@keyframes centerRipple {
  0% {
    transform: translate(-50%, -50%) scale(0.6);
    opacity: 0;
  }
  12% {
    opacity: 0.12;
  }
  70% {
    transform: translate(-50%, -50%) scale(1.1);
    opacity: 0;
  }
  100% {
    transform: translate(-50%, -50%) scale(1.1);
    opacity: 0;
  }
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes timelineReveal {
  from {
    opacity: 0;
    transform: translateY(-8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

@media (max-width: 720px) {
  .mode-toggle.small {
    width: 150px;
  }

  .stats-summary {
    grid-template-columns: 1fr;
  }

  .pomodoro-time {
    grid-template-columns: 1fr;
  }

  .floating-btn {
    right: calc(16px + env(safe-area-inset-right, 0px));
    bottom: calc(16px + env(safe-area-inset-bottom, 0px));
  }

  .stats-panel {
    width: min(320px, 88vw);
    right: calc(16px + env(safe-area-inset-right, 0px));
    bottom: calc(90px + env(safe-area-inset-bottom, 0px));
    top: auto;
    transform: translate(0, 0);
    height: min(420px, 60vh);
  }
}

@media (max-width: 640px) {
  :root {
    --core-size: min(300px, 78vw);
  }

  .top-row {
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    flex-wrap: nowrap;
    gap: 10px;
  }

  .top-actions {
    justify-content: flex-end;
    flex-wrap: nowrap;
    gap: 8px;
  }

  .mode-toggle.small {
    width: 150px;
  }

  .timer-card {
    min-height: 100vh;
    padding-bottom: calc(90px + env(safe-area-inset-bottom, 0px));
  }

  .timer-face {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    margin: 0;
  }

  .timer-face:active {
    transform: translate(-50%, -50%) scale(0.992);
  }
}

@media (max-height: 680px) {
  :root {
    --core-size: min(260px, 72vw);
  }
}
