:root {
  color-scheme: dark;
  --bg: #101820;
  --panel: #17212b;
  --panel-strong: #1f2d3a;
  --text: #f8fafc;
  --muted: #9fb1c3;
  --line: #2d3a47;
  --accent: #34d399;
  --accent-strong: #10b981;
  --danger: #fb7185;
  --shadow: 0 18px 50px rgba(0, 0, 0, 0.28);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: radial-gradient(circle at top left, rgba(52, 211, 153, 0.14), transparent 35%), var(--bg);
  color: var(--text);
}

button,
input,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

.app {
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
  padding: 24px 0 40px;
}

.topbar,
.timer-surface,
.workspace,
.library,
.editor,
.block-form,
dialog {
  border: 1px solid var(--line);
  background: rgba(23, 33, 43, 0.92);
  box-shadow: var(--shadow);
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 18px;
  border-radius: 8px;
}

.brand {
  font-weight: 800;
  font-size: 1.25rem;
}

.subtle,
.timer-meta p,
.field span,
.timer-stats span {
  color: var(--muted);
}

.top-actions,
.controls,
.section-head,
.section-actions,
.dialog-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.timer-surface {
  margin-top: 18px;
  padding: 24px;
  border-radius: 8px;
}

.timer-meta,
.workspace {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 18px;
}

.timer-meta {
  align-items: start;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: clamp(1.8rem, 3vw, 3rem);
}

h2 {
  font-size: 1rem;
}

.pill,
.chip,
.icon-button,
.button,
.segment {
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--text);
  background: var(--panel-strong);
}

.pill {
  padding: 8px 12px;
  color: var(--accent);
  font-weight: 700;
}

.time-display {
  margin: 24px 0 18px;
  font-variant-numeric: tabular-nums;
  font-size: clamp(4rem, 13vw, 9rem);
  font-weight: 900;
  line-height: 0.95;
  letter-spacing: 0;
}

.progress-track {
  overflow: hidden;
  height: 14px;
  border-radius: 999px;
  background: #0b1117;
  border: 1px solid var(--line);
}

.progress-track.total {
  height: 8px;
  margin-top: 10px;
}

.progress-fill {
  width: 0%;
  height: 100%;
  background: var(--accent);
  transition: width 120ms linear, background-color 180ms ease;
}

.timer-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin: 20px 0;
}

.timer-stats div,
.interval-item,
.workout-item {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(31, 45, 58, 0.72);
}

.timer-stats strong {
  display: block;
  margin-top: 4px;
  font-variant-numeric: tabular-nums;
}

.button,
.chip,
.icon-button,
.segment {
  min-height: 40px;
  padding: 0 14px;
  font-weight: 700;
}

.button.primary,
.segment.active {
  border-color: transparent;
  background: var(--accent-strong);
  color: #04130d;
}

.chip.danger {
  color: var(--danger);
}

.workspace {
  grid-template-columns: 320px 1fr;
  margin-top: 18px;
  background: transparent;
  border: 0;
  box-shadow: none;
}

.library,
.editor {
  padding: 18px;
  border-radius: 8px;
}

.section-head {
  justify-content: space-between;
  margin-bottom: 14px;
}

.workout-list,
.interval-list {
  display: grid;
  gap: 10px;
}

.workout-item {
  width: 100%;
  color: inherit;
  text-align: left;
}

.workout-item.active {
  border-color: var(--accent);
}

.workout-item strong,
.interval-item strong {
  display: block;
}

.workout-item span,
.interval-item span {
  display: block;
  margin-top: 4px;
  color: var(--muted);
}

.editor {
  display: grid;
  gap: 14px;
}

.field {
  display: grid;
  gap: 6px;
}

input,
textarea {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #0b1117;
  color: var(--text);
  padding: 10px 12px;
}

textarea {
  resize: vertical;
}

.interval-item {
  display: grid;
  grid-template-columns: 10px 1fr auto;
  gap: 12px;
  align-items: center;
}

.interval-item.nested {
  margin-left: 22px;
  background: rgba(11, 17, 23, 0.52);
  box-shadow: none;
}

.swatch {
  width: 10px;
  height: 100%;
  min-height: 42px;
  border-radius: 999px;
  background: var(--accent);
}

.item-actions {
  display: flex;
  gap: 8px;
}

.item-actions button {
  min-width: 38px;
  min-height: 34px;
  border-radius: 6px;
  border: 1px solid var(--line);
  background: #0b1117;
  color: var(--text);
}

.block-form {
  display: grid;
  gap: 12px;
  padding: 14px;
  border-radius: 8px;
}

.segmented {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 10px;
}

dialog {
  width: min(560px, calc(100% - 32px));
  border-radius: 8px;
  color: var(--text);
  padding: 0;
}

dialog::backdrop {
  background: rgba(0, 0, 0, 0.72);
}

.dialog-body {
  display: grid;
  gap: 14px;
  padding: 18px;
}

.dialog-actions {
  justify-content: end;
}

@media (max-width: 820px) {
  .app {
    width: min(100% - 20px, 1180px);
    padding-top: 10px;
  }

  .topbar,
  .timer-meta,
  .workspace,
  .timer-stats {
    grid-template-columns: 1fr;
  }

  .topbar {
    align-items: stretch;
  }

  .top-actions,
  .controls {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
  }

  .timer-surface,
  .library,
  .editor {
    padding: 14px;
  }

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