:root {
  --bg: #111214;
  --surface: rgba(255, 255, 255, 0.055);
  --surface-strong: rgba(255, 255, 255, 0.08);
  --text: #f6f3eb;
  --muted: #b6b2aa;
  --faint: #6f706c;
  --line: rgba(255, 255, 255, 0.11);
  --accent: #a6df83;
  --warn: #f1c76b;
  --frame: min(100vw, 520px);
  --pad: clamp(18px, 5vw, 26px);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto,
    sans-serif;
  letter-spacing: 0;
}

body {
  min-height: 100dvh;
  overflow: hidden;
}

button {
  color: inherit;
  font: inherit;
}

.app {
  width: var(--frame);
  height: 100dvh;
  margin: 0 auto;
  overflow: hidden;
  background:
    linear-gradient(rgba(255, 255, 255, 0.026) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.026) 1px, transparent 1px),
    var(--bg);
  background-size: 32px 32px;
}

.hidden {
  display: none !important;
}

.start-screen,
.lesson-screen {
  height: 100%;
  padding: calc(22px + env(safe-area-inset-top)) var(--pad)
    calc(18px + env(safe-area-inset-bottom));
}

.start-screen {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.topline {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.start-copy {
  margin-top: auto;
  margin-bottom: 38px;
}

h1 {
  margin: 0;
  font-size: clamp(34px, 11vw, 56px);
  line-height: 1;
  font-weight: 780;
  letter-spacing: 0;
}

.start-copy p {
  max-width: 300px;
  margin: 18px 0 0;
  color: var(--muted);
  font-size: 16px;
  line-height: 1.45;
}

.start-button {
  width: 100%;
  min-height: 64px;
  border: 0;
  border-radius: 18px;
  background: var(--accent);
  color: #11150f;
  font-size: 18px;
  font-weight: 900;
  cursor: pointer;
  touch-action: manipulation;
}

.start-actions {
  display: grid;
  gap: 12px;
}

.spotify-panel {
  display: grid;
  gap: 9px;
}

.spotify-status {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

.spotify-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.spotify-button {
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 13px;
  background: var(--surface);
  font-size: 12px;
  font-weight: 720;
  cursor: pointer;
  touch-action: manipulation;
}

.spotify-button:disabled {
  opacity: 0.42;
}

.lesson-screen {
  display: grid;
  grid-template-rows: auto auto 1fr auto;
  gap: 8px;
}

.lesson-header {
  display: grid;
  grid-template-columns: 40px minmax(0, 1fr) auto;
  align-items: start;
  gap: 10px;
}

.phase-heading {
  min-width: 0;
}

.lesson-header h1 {
  margin-top: 3px;
  font-size: clamp(18px, 5.4vw, 26px);
  font-weight: 700;
  overflow-wrap: anywhere;
}

.header-status {
  margin-top: 3px;
  color: var(--text);
  font-size: clamp(16px, 4.8vw, 22px);
  font-weight: 720;
  line-height: 1.08;
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

.phase-menu-button {
  width: 34px;
  height: 34px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
  font-size: 21px;
  line-height: 1;
  cursor: pointer;
}

.corner-stack {
  width: 138px;
  display: grid;
  justify-items: end;
  gap: 6px;
}

.corner-status {
  width: 86px;
  display: grid;
  justify-items: end;
  gap: 6px;
  padding-top: 0;
}

.timer-card,
.notion-card {
  border: 0;
  border-radius: 0;
  background: transparent;
  backdrop-filter: none;
}

.timer-card {
  display: none;
  padding: 0;
}

.mini-timer {
  color: rgba(246, 243, 235, 0.9);
  font-size: 19px;
  line-height: 1;
  font-weight: 720;
  letter-spacing: 0;
  font-variant-numeric: tabular-nums;
}

.progress {
  width: 86px;
  height: 3px;
  margin-top: 0;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
}

.progress-fill {
  width: 0%;
  height: 100%;
  border-radius: inherit;
  background: var(--accent);
  transition: width 180ms linear;
}

.timer-note {
  margin-top: 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.notion-card {
  min-height: 0;
  overflow: hidden;
  padding: 0;
  scrollbar-width: none;
}

.notion-card::-webkit-scrollbar {
  display: none;
}

.notion-card h2 {
  margin: 0 0 14px;
  font-size: 16px;
  line-height: 1.25;
  font-weight: 700;
  letter-spacing: 0;
}

.notion-card p {
  margin: 0 0 16px;
  color: var(--muted);
  font-size: 15px;
  line-height: 1.6;
}

.notion-card ul {
  margin: 0;
  padding-left: 22px;
}

.notion-card li {
  margin: 11px 0;
  font-size: 15px;
  line-height: 1.5;
}

.interval-focus {
  margin: 2px 0 12px;
}

.interval-label {
  color: var(--muted);
  font-size: 12px;
  font-weight: 750;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.interval-title {
  margin-top: 5px;
  font-size: clamp(21px, 6.4vw, 30px);
  line-height: 1.02;
  font-weight: 740;
}

.interval-ring {
  --ring-progress: 0deg;
  width: min(39vw, 148px);
  aspect-ratio: 1;
  margin: 12px auto 0;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background:
    radial-gradient(circle at center, var(--bg) 0 57%, transparent 58%),
    conic-gradient(var(--accent) var(--ring-progress), rgba(255, 255, 255, 0.09) 0);
}

.interval-clock-wrap {
  display: grid;
  justify-items: center;
  gap: 5px;
}

.interval-clock {
  font-size: clamp(28px, 9.6vw, 42px);
  line-height: 1;
  font-weight: 760;
  font-variant-numeric: tabular-nums;
}

.interval-clock-label {
  color: var(--muted);
  font-size: 11px;
  font-weight: 720;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.interval-bar {
  display: none;
}

.interval-fill {
  width: 0%;
  height: 100%;
  border-radius: inherit;
  background: var(--accent);
  transition: width 180ms linear;
}

.interval-next {
  margin-top: 9px;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.45;
  text-align: center;
}

.interval-focus.rest .interval-ring {
  background:
    radial-gradient(circle at center, var(--bg) 0 57%, transparent 58%),
    conic-gradient(var(--warn) var(--ring-progress), rgba(255, 255, 255, 0.09) 0);
}

.notion-card .exercise-list {
  display: grid;
  gap: 4px;
  margin: 10px 0 0;
  padding: 0;
  list-style: none;
}

.notion-card .exercise-item {
  display: grid;
  grid-template-columns: 28px 1fr;
  align-items: center;
  gap: 10px;
  min-height: 36px;
  border-left: 2px solid transparent;
  padding: 5px 0 5px 10px;
  margin: 0;
  color: var(--muted);
  font-size: 15px;
  line-height: 1.2;
}

.exercise-number {
  display: grid;
  place-items: center;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.07);
  color: var(--faint);
  font-size: 12px;
  font-weight: 760;
  font-variant-numeric: tabular-nums;
}

.notion-card .exercise-item.active {
  border-color: var(--accent);
  color: var(--text);
}

.notion-card .exercise-item.active .exercise-number {
  background: var(--accent);
  color: #11150f;
}

.interval-focus.rest ~ .exercise-list .exercise-item.active {
  border-color: var(--warn);
}

.interval-focus.rest ~ .exercise-list .exercise-item.active .exercise-number {
  background: var(--warn);
}

.callout {
  margin-top: 12px;
  padding: 0 0 0 13px;
  border-left: 2px solid rgba(166, 223, 131, 0.75);
  border-radius: 0;
  background: transparent;
  color: rgba(246, 243, 235, 0.88);
  font-size: 15px;
  line-height: 1.55;
}

.controls {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 7px;
}

.control-button {
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 13px;
  background: var(--surface);
  font-size: 13px;
  font-weight: 720;
  cursor: pointer;
  touch-action: manipulation;
}

.control-button.primary {
  border-color: transparent;
  background: var(--accent);
  color: #11150f;
}

.control-button:disabled {
  opacity: 0.38;
}

.now-playing {
  width: 138px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 34px;
  align-items: center;
  gap: 6px;
  color: var(--muted);
  font-size: 10px;
  line-height: 1.1;
}

.now-cover {
  width: 34px;
  height: 34px;
  border-radius: 8px;
  object-fit: cover;
  background: var(--surface);
}

.now-text {
  min-width: 0;
}

.now-text div {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

#spotifyTrack {
  color: var(--text);
  font-weight: 720;
}

.now-controls {
  grid-column: 1 / -1;
  justify-self: end;
  display: grid;
  grid-template-columns: repeat(2, 24px);
  gap: 4px;
}

.now-controls button {
  width: 24px;
  height: 22px;
  border: 0;
  border-radius: 6px;
  background: var(--surface);
  font-size: 12px;
  cursor: pointer;
}

.phase-sheet {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  align-items: end;
  background: rgba(0, 0, 0, 0.45);
}

.sheet-panel {
  width: min(100vw, 520px);
  max-height: 72dvh;
  margin: 0 auto;
  border: 1px solid var(--line);
  border-radius: 22px 22px 0 0;
  background: rgba(20, 21, 23, 0.96);
  padding: 14px var(--pad) calc(18px + env(safe-area-inset-bottom));
  overflow-y: auto;
}

.sheet-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}

.sheet-header button {
  width: 34px;
  height: 34px;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: var(--surface);
  font-size: 20px;
}

.phase-list {
  display: grid;
  gap: 7px;
}

.phase-option {
  min-height: 46px;
  border: 1px solid var(--line);
  border-radius: 13px;
  background: transparent;
  color: var(--text);
  text-align: left;
  padding: 9px 11px;
}

.phase-option.active {
  border-color: var(--accent);
  background: rgba(166, 223, 131, 0.1);
}

.phase-option span {
  display: block;
  color: var(--muted);
  font-size: 11px;
  margin-top: 2px;
}

.start-button:active,
.control-button:active,
.spotify-button:active {
  transform: scale(0.98);
}

.flash {
  position: fixed;
  inset: 0;
  z-index: 5;
  pointer-events: none;
  opacity: 0;
  background: rgba(152, 226, 111, 0.22);
}

.flash.show {
  animation: flash 560ms ease-out;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(88px + env(safe-area-inset-bottom));
  z-index: 6;
  width: min(calc(100vw - 36px), 484px);
  transform: translate(-50%, 10px);
  opacity: 0;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 12px 14px;
  background: rgba(28, 29, 31, 0.94);
  color: var(--text);
  font-size: 14px;
  font-weight: 800;
  pointer-events: none;
  transition: opacity 160ms ease, transform 160ms ease;
}

.toast.show {
  opacity: 1;
  transform: translate(-50%, 0);
}

@keyframes flash {
  0% {
    opacity: 0;
  }
  18% {
    opacity: 1;
  }
  100% {
    opacity: 0;
  }
}

@media (max-width: 360px) {
  .control-button {
    min-height: 40px;
    font-size: 12px;
  }

  .corner-status {
    width: 78px;
  }

  .progress {
    width: 78px;
  }

  .corner-stack,
  .now-playing {
    width: 124px;
  }
}

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