:root {
  --orange: #e85d2a;
  --blue: #165a94;
  --green: #22a055;
  --amber: #f59e0b;

  --bg: #f3f4f7;
  --surface: #ffffff;
  --surface-alt: #e8eaef;
  --surface-tint: #f8f9fb;
  --text: #14161a;
  --text-secondary: #626875;
  --text-tertiary: #8e95a3;
  --border: rgba(20, 22, 26, 0.09);
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0e0f12;
    --surface: #181a20;
    --surface-alt: #242731;
    --surface-tint: #1f222a;
    --text: #f3f4f6;
    --text-secondary: #9ca3af;
    --text-tertiary: #6b7280;
    --border: rgba(255, 255, 255, 0.09);
    --shadow: none;
  }
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Helvetica Neue", sans-serif;
  -webkit-font-smoothing: antialiased;
}

.hidden {
  display: none !important;
}

.app-shell {
  max-width: 520px;
  margin: 0 auto;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
}

.view {
  display: none;
  flex: 1;
  min-height: 0;
  flex-direction: column;
}

.view.active {
  display: flex;
}

/* HEADER */
.top-header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: calc(env(safe-area-inset-top) + 10px) 16px 10px;
}

.date-nav-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.icon-btn {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: none;
  background: var(--surface-alt);
  color: var(--text);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
}

.date-trigger {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: transparent;
  border: none;
  color: var(--text);
  padding: 4px 8px;
  border-radius: 10px;
  cursor: pointer;
  text-align: left;
}

.accent-icon {
  color: var(--orange);
  flex-shrink: 0;
}

.date-trigger-text {
  display: flex;
  flex-direction: column;
  line-height: 1.2;
}

.date-main {
  font-size: 16px;
  font-weight: 700;
}

.date-sub {
  font-size: 12px;
  color: var(--text-secondary);
}

.date-sub.is-today {
  color: var(--orange);
  font-weight: 600;
}

.header-spacer {
  flex: 1;
}

.pill-btn {
  border: none;
  background: rgba(232, 93, 42, 0.14);
  color: var(--orange);
  font-size: 12px;
  font-weight: 700;
  padding: 6px 11px;
  border-radius: 999px;
  cursor: pointer;
}

.check-btn {
  width: 36px;
  height: 36px;
  border: none;
  background: transparent;
  color: var(--text-secondary);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.check-btn.done {
  color: var(--green);
}

/* WEEK STRIP */
.week-strip {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 6px;
  margin-top: 10px;
}

.week-day-btn {
  border: 1.5px solid transparent;
  background: var(--surface-alt);
  border-radius: 12px;
  padding: 7px 2px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  cursor: pointer;
  color: var(--text);
}

.week-day-btn.is-today:not(.selected) {
  border-color: var(--orange);
}

.week-day-btn.selected {
  background: var(--orange);
  color: #fff;
}

.week-day-btn.selected.recovery {
  background: var(--blue);
}

.week-wd {
  font-size: 11px;
  font-weight: 600;
  opacity: 0.75;
}

.week-day-btn.selected .week-wd {
  opacity: 0.95;
}

.week-num {
  font-size: 15px;
  font-weight: 700;
}

.week-dot {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--orange);
}

.week-dot.recovery { background: var(--blue); }
.week-dot.done { background: var(--green); }
.week-day-btn.selected .week-dot { background: rgba(255, 255, 255, 0.92); }
.week-day-btn.selected .week-dot.done { background: #86efac; }

/* SCROLL CONTENT */
.scroll-content {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 14px 16px 20px;
}

.loading-box {
  text-align: center;
  padding: 40px 16px;
  color: var(--text-secondary);
}

.banner {
  display: flex;
  align-items: center;
  gap: 8px;
  border-radius: 12px;
  padding: 10px 12px;
  margin-bottom: 10px;
  font-size: 13px;
  font-weight: 600;
}

.banner.recovery {
  background: rgba(22, 90, 148, 0.14);
  color: #4ea1ea;
}

@media (prefers-color-scheme: light) {
  .banner.recovery {
    color: var(--blue);
  }
}

.banner.cycled {
  background: var(--surface);
  color: var(--text-secondary);
  font-weight: 500;
  font-size: 12px;
  border: 1px solid var(--border);
}

/* SECTION CARDS */
.card {
  background: var(--surface);
  border-radius: 16px;
  padding: 14px;
  margin-bottom: 12px;
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
}

.card.guidance {
  background: var(--surface-tint);
}

.sec-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 6px;
}

.sec-title {
  font-size: 15px;
  font-weight: 750;
  color: var(--orange);
  letter-spacing: 0.01em;
}

.sec-title.recovery {
  color: var(--blue);
}

@media (prefers-color-scheme: dark) {
  .sec-title.recovery {
    color: #5eaef2;
  }
}

.sec-title.guidance {
  color: var(--text);
}

.sec-timer-btn {
  border: none;
  background: rgba(232, 93, 42, 0.14);
  color: var(--orange);
  font-size: 11px;
  font-weight: 700;
  padding: 4px 9px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  cursor: pointer;
  flex-shrink: 0;
}

.sec-tag {
  display: inline-block;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-secondary);
  background: var(--surface-alt);
  padding: 3px 8px;
  border-radius: 999px;
  margin-bottom: 8px;
}

.sec-lines {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.wo-line {
  font-size: 14.5px;
  line-height: 1.42;
  word-break: break-word;
}

.wo-line.bold {
  font-weight: 650;
}

.wo-line.italic {
  font-style: italic;
  color: var(--text-secondary);
}

.source-footer {
  text-align: center;
  font-size: 11px;
  color: var(--text-tertiary);
  padding: 4px 0 10px;
}

/* TIMER */
.timer-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: calc(env(safe-area-inset-top) + 12px) 16px 8px;
}

.timer-header h1 {
  margin: 0;
  font-size: 24px;
  font-weight: 800;
}

.timer-scroll {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.segmented {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  background: var(--surface-alt);
  padding: 3px;
  border-radius: 12px;
}

.seg-btn {
  border: none;
  background: transparent;
  color: var(--text-secondary);
  font-size: 14px;
  font-weight: 650;
  padding: 8px 4px;
  border-radius: 9px;
  cursor: pointer;
}

.seg-btn.active {
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 1px 2px rgba(0,0,0,0.12);
}

.timer-display-card {
  margin-bottom: 0;
  padding: 16px;
}

.timer-meta-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.phase-badge {
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.08em;
  padding: 4px 10px;
  border-radius: 999px;
}

.phase-idle { background: var(--surface-alt); color: var(--text-secondary); }
.phase-prep { background: rgba(245, 158, 11, 0.18); color: var(--amber); }
.phase-work { background: rgba(232, 93, 42, 0.18); color: var(--orange); }
.phase-rest { background: rgba(22, 90, 148, 0.22); color: #5eaef2; }
.phase-finished { background: rgba(34, 160, 85, 0.18); color: var(--green); }

.timer-round-label {
  font-size: 13px;
  font-weight: 650;
  color: var(--text-secondary);
  font-variant-numeric: tabular-nums;
}

.ring-container {
  position: relative;
  width: 220px;
  height: 220px;
  margin: 10px auto 4px;
}

.progress-ring {
  width: 220px;
  height: 220px;
  transform: rotate(-90deg);
}

.ring-track {
  fill: none;
  stroke: var(--surface-alt);
  stroke-width: 11;
}

.ring-arc {
  fill: none;
  stroke: var(--orange);
  stroke-width: 11;
  stroke-linecap: round;
  transition: stroke-dashoffset 0.1s linear, stroke 0.2s ease;
}

.ring-center {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 0 18px;
}

.timer-digits {
  font-size: 54px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em;
  line-height: 1;
}

.timer-prep-hint {
  margin-top: 6px;
  font-size: 12px;
  color: var(--text-secondary);
}

.transport-row {
  display: flex;
  gap: 10px;
}

.primary-btn {
  flex: 1;
  border: none;
  background: var(--orange);
  color: #fff;
  font-size: 16px;
  font-weight: 700;
  padding: 15px;
  border-radius: 14px;
  cursor: pointer;
}

.primary-btn.running {
  background: #d97706;
}

.secondary-btn {
  width: 110px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-size: 15px;
  font-weight: 650;
  padding: 15px;
  border-radius: 14px;
  cursor: pointer;
}

.secondary-btn:disabled {
  opacity: 0.45;
  cursor: default;
}

.config-card {
  margin-bottom: 0;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.config-card.locked {
  opacity: 0.55;
  pointer-events: none;
}

.config-title {
  font-size: 13px;
  font-weight: 700;
  margin-bottom: 8px;
}

.chip-scroll {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 2px;
  margin-bottom: 10px;
}

.chip-group {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.chip {
  border: none;
  background: var(--surface-alt);
  color: var(--text);
  font-size: 12px;
  font-weight: 650;
  padding: 6px 11px;
  border-radius: 999px;
  cursor: pointer;
  white-space: nowrap;
}

.chip.active {
  background: rgba(232, 93, 42, 0.16);
  color: var(--orange);
}

.config-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-size: 14px;
}

.adjust-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  font-size: 14px;
  margin-top: 8px;
}

.adjust-controls {
  display: flex;
  align-items: center;
  gap: 5px;
}

.adj-btn {
  border: none;
  background: var(--surface-alt);
  color: var(--text);
  font-size: 12px;
  font-weight: 700;
  padding: 6px 8px;
  border-radius: 8px;
  cursor: pointer;
}

.adj-val {
  min-width: 52px;
  text-align: center;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.divider {
  height: 1px;
  background: var(--border);
}

.total-duration {
  font-size: 12px;
  color: var(--text-secondary);
  margin-top: 8px;
  font-variant-numeric: tabular-nums;
}

/* TAB BAR */
.tab-bar {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  background: var(--surface);
  border-top: 1px solid var(--border);
  padding: 6px 12px calc(env(safe-area-inset-bottom) + 6px);
}

.tab-btn {
  border: none;
  background: transparent;
  color: var(--text-secondary);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  font-size: 11px;
  font-weight: 600;
  padding: 4px 0;
  cursor: pointer;
}

.tab-btn.active {
  color: var(--orange);
}

/* CALENDAR MODAL */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  z-index: 100;
}

.modal-sheet {
  width: 100%;
  max-width: 520px;
  background: var(--surface);
  border-radius: 22px 22px 0 0;
  padding: 16px 16px calc(env(safe-area-inset-bottom) + 18px);
  max-height: 92dvh;
  overflow-y: auto;
}

.modal-top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}

.modal-top-bar h2 {
  margin: 0;
  font-size: 17px;
  font-weight: 700;
}

.text-btn {
  border: none;
  background: transparent;
  color: var(--text);
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  padding: 4px 6px;
}

.text-btn.accent {
  color: var(--orange);
}

.cal-month-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}

.cal-title-group {
  display: flex;
  align-items: center;
  gap: 8px;
}

.cal-month-label {
  font-size: 18px;
  font-weight: 750;
}

.cal-year-select {
  font-size: 16px;
  font-weight: 700;
  color: var(--orange);
  background: var(--surface-alt);
  border: none;
  border-radius: 8px;
  padding: 4px 8px;
}

.cal-weekdays {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  text-align: center;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 8px;
}

.cal-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 6px;
}

.cal-cell {
  height: 44px;
  border-radius: 10px;
  border: 1.5px solid transparent;
  background: var(--surface-alt);
  color: var(--text);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 550;
}

.cal-cell.is-today:not(.selected) {
  border-color: var(--orange);
  color: var(--orange);
  font-weight: 750;
}

.cal-cell.selected {
  background: var(--orange);
  color: #fff;
  font-weight: 750;
}

.cal-cell.selected.recovery {
  background: var(--blue);
}

.cal-cell-dot {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--orange);
}

.cal-cell-dot.recovery { background: var(--blue); }
.cal-cell-dot.done { background: var(--green); }
.cal-cell-dot.cycled { opacity: 0.55; }
.cal-cell.selected .cal-cell-dot { background: #fff; opacity: 1; }
.cal-cell.selected .cal-cell-dot.done { background: #86efac; }

.cal-legend {
  margin-top: 16px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}

.legend-items {
  display: flex;
  gap: 16px;
  font-size: 12px;
  color: var(--text-secondary);
}

.legend-items span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
}

.dot.orange { background: var(--orange); }
.dot.blue { background: var(--blue); }
.dot.green { background: var(--green); }

.cal-range-info {
  margin: 8px 0 0;
  font-size: 12px;
  line-height: 1.4;
  color: var(--text-secondary);
}

/* INTRO COLLAGE OVERLAY */
.intro-overlay {
  position: fixed;
  inset: 0;
  z-index: 200;
  background: #0e0f12;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  transition: opacity 0.45s ease, visibility 0.45s ease;
}

.intro-overlay.fade-out {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.intro-slides {
  position: absolute;
  inset: 0;
  overflow: hidden;
}

.intro-slide {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: 0;
  transform: scale(1);
  transition: opacity 0.45s ease;
}

.intro-slide.active {
  opacity: 1;
  animation: introKenBurns 1.4s ease-out forwards;
}

@keyframes introKenBurns {
  from { transform: scale(1.0); }
  to { transform: scale(1.06); }
}

.intro-scrim {
  position: absolute;
  inset: 0;
  background: linear-gradient(
    to bottom,
    rgba(14, 15, 18, 0.55) 0%,
    rgba(14, 15, 18, 0.05) 30%,
    rgba(14, 15, 18, 0.15) 75%,
    rgba(14, 15, 18, 0.65) 100%
  );
  pointer-events: none;
}

.intro-hud {
  position: relative;
  z-index: 2;
  height: 100%;
  max-width: 520px;
  width: 100%;
  margin: 0 auto;
  padding: calc(env(safe-area-inset-top) + 14px) 16px calc(env(safe-area-inset-bottom) + 22px);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.intro-top-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.intro-brand-pill {
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.12em;
  color: #fff;
  background: rgba(232, 93, 42, 0.9);
  padding: 6px 12px;
  border-radius: 999px;
}

.intro-skip-btn {
  border: 1px solid rgba(255, 255, 255, 0.25);
  background: rgba(14, 15, 18, 0.55);
  backdrop-filter: blur(8px);
  color: #fff;
  font-size: 12px;
  font-weight: 600;
  padding: 6px 12px;
  border-radius: 999px;
  cursor: pointer;
}

.intro-progress-bars {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 6px;
}

.intro-bar {
  height: 3px;
  background: rgba(255, 255, 255, 0.25);
  border-radius: 999px;
  overflow: hidden;
}

.intro-bar-fill {
  display: block;
  height: 100%;
  width: 0%;
  background: var(--orange);
}

.intro-bar.done .intro-bar-fill {
  width: 100%;
}

.intro-bar.active .intro-bar-fill {
  animation: introProgress 1.1s linear forwards;
}

@keyframes introProgress {
  from { width: 0%; }
  to { width: 100%; }
}
