/* ==========================================================================
   Live Hard Tracker — Apple-styled design system
   ========================================================================== */

:root {
  /* Viewport aspect ratio for photo viewer / alignment canvas. Set from
     the first uploaded photo by JS; falls back to 4:5 for the upload UI
     before any photo exists. */
  --photo-aspect-ratio: 4 / 5;

  /* Apple system palette — light */
  --bg: #f5f5f7;
  --bg-elevated: #ffffff;
  --bg-secondary: rgba(118, 118, 128, 0.08);
  --bg-tertiary: rgba(118, 118, 128, 0.12);
  --bg-quaternary: rgba(118, 118, 128, 0.18);
  --text: #1d1d1f;
  --text-secondary: #6e6e73;
  --text-tertiary: #8e8e93;
  --separator: rgba(60, 60, 67, 0.12);
  --separator-strong: rgba(60, 60, 67, 0.24);

  /* Accent — orange (Live Hard energy) */
  --accent: #ff9500;
  --accent-hover: #ff8a00;
  --accent-soft: rgba(255, 149, 0, 0.12);
  --accent-soft-strong: rgba(255, 149, 0, 0.22);

  /* Semantic */
  --success: #34c759;
  --success-soft: rgba(52, 199, 89, 0.14);
  --danger: #ff3b30;
  --danger-soft: rgba(255, 59, 48, 0.12);
  --warning: #ff9500;
  --info: #007aff;

  /* Header */
  --header-bg: rgba(245, 245, 247, 0.72);
  --header-border: rgba(0, 0, 0, 0.08);

  /* Shadows */
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.04);
  --shadow-md: 0 6px 22px rgba(0, 0, 0, 0.06), 0 2px 6px rgba(0, 0, 0, 0.04);
  --shadow-lg: 0 22px 60px rgba(0, 0, 0, 0.18), 0 8px 22px rgba(0, 0, 0, 0.08);

  /* Radii */
  --r-sm: 10px;
  --r-md: 14px;
  --r-lg: 18px;
  --r-xl: 22px;
  --r-2xl: 28px;

  /* Motion */
  --ease: cubic-bezier(0.32, 0.72, 0, 1);
  --ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
}

html[data-theme="dark"] {
  --bg: #000000;
  --bg-elevated: #1c1c1e;
  --bg-secondary: rgba(118, 118, 128, 0.24);
  --bg-tertiary: rgba(118, 118, 128, 0.32);
  --bg-quaternary: rgba(118, 118, 128, 0.4);
  --text: #f5f5f7;
  --text-secondary: #a1a1a6;
  --text-tertiary: #6e6e73;
  --separator: rgba(84, 84, 88, 0.4);
  --separator-strong: rgba(84, 84, 88, 0.65);

  --accent: #ff9f0a;
  --accent-hover: #ffb340;
  --accent-soft: rgba(255, 159, 10, 0.16);
  --accent-soft-strong: rgba(255, 159, 10, 0.28);

  --success: #30d158;
  --success-soft: rgba(48, 209, 88, 0.18);
  --danger: #ff453a;
  --danger-soft: rgba(255, 69, 58, 0.16);

  --header-bg: rgba(28, 28, 30, 0.72);
  --header-border: rgba(255, 255, 255, 0.08);

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.6);
  --shadow-md: 0 6px 22px rgba(0, 0, 0, 0.5), 0 2px 6px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 22px 60px rgba(0, 0, 0, 0.7), 0 8px 22px rgba(0, 0, 0, 0.5);
}

@media (prefers-color-scheme: dark) {
  html[data-theme="auto"] {
    --bg: #000000;
    --bg-elevated: #1c1c1e;
    --bg-secondary: rgba(118, 118, 128, 0.24);
    --bg-tertiary: rgba(118, 118, 128, 0.32);
    --bg-quaternary: rgba(118, 118, 128, 0.4);
    --text: #f5f5f7;
    --text-secondary: #a1a1a6;
    --text-tertiary: #6e6e73;
    --separator: rgba(84, 84, 88, 0.4);
    --separator-strong: rgba(84, 84, 88, 0.65);

    --accent: #ff9f0a;
    --accent-hover: #ffb340;
    --accent-soft: rgba(255, 159, 10, 0.16);
    --accent-soft-strong: rgba(255, 159, 10, 0.28);

    --success: #30d158;
    --success-soft: rgba(48, 209, 88, 0.18);
    --danger: #ff453a;
    --danger-soft: rgba(255, 69, 58, 0.16);

    --header-bg: rgba(28, 28, 30, 0.72);
    --header-border: rgba(255, 255, 255, 0.08);

    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.6);
    --shadow-md: 0 6px 22px rgba(0, 0, 0, 0.5), 0 2px 6px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 22px 60px rgba(0, 0, 0, 0.7), 0 8px 22px rgba(0, 0, 0, 0.5);
  }
}

/* Reset & base
   ========================================================================== */

*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; }
[hidden] { display: none !important; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "SF Pro Text", "Helvetica Neue", Helvetica, Arial, sans-serif;
  font-size: 17px;
  line-height: 1.47;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  letter-spacing: -0.01em;
  min-height: 100vh;
  min-height: 100svh;
  transition: background 0.3s var(--ease), color 0.3s var(--ease);
}

button {
  font-family: inherit;
  font-size: inherit;
  color: inherit;
  background: none;
  border: 0;
  padding: 0;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  -webkit-appearance: none;
  appearance: none;
}

button:focus-visible,
input:focus-visible,
[tabindex]:focus-visible {
  outline: 2.5px solid var(--accent);
  outline-offset: 2px;
  border-radius: 6px;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

::selection { background: var(--accent-soft-strong); color: var(--text); }

/* Layout
   ========================================================================== */

.app {
  min-height: 100vh;
  min-height: 100svh;
  display: flex;
  flex-direction: column;
}

.main {
  flex: 1;
  width: 100%;
  max-width: 880px;
  margin: 0 auto;
  padding: 24px 20px 80px;
}

@media (min-width: 768px) {
  .main { padding: 32px 24px 120px; }
}

/* Header
   ========================================================================== */

.header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: var(--header-bg);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  backdrop-filter: saturate(180%) blur(20px);
  border-bottom: 1px solid var(--header-border);
}

.header-inner {
  max-width: 880px;
  margin: 0 auto;
  padding: 12px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-mark {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: var(--accent);
  color: white;
  display: grid;
  place-items: center;
  box-shadow: 0 4px 12px var(--accent-soft-strong);
}
.brand-mark svg { width: 20px; height: 20px; }

.brand-text { display: flex; flex-direction: column; line-height: 1.1; }
.brand-title { font-size: 15px; font-weight: 600; letter-spacing: -0.01em; }
.brand-subtitle { font-size: 12px; color: var(--text-tertiary); font-weight: 500; }

.header-actions { display: flex; gap: 4px; }

.icon-btn {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  color: var(--text-secondary);
  transition: background 0.18s var(--ease), color 0.18s var(--ease), transform 0.18s var(--ease-spring);
}
.icon-btn:hover { background: var(--bg-secondary); color: var(--text); }
.icon-btn:active { transform: scale(0.92); }
.icon-btn svg { width: 20px; height: 20px; }

.icon-btn .icon-moon { display: none; }
html[data-theme="dark"] .icon-btn .icon-sun { display: none; }
html[data-theme="dark"] .icon-btn .icon-moon { display: block; }
@media (prefers-color-scheme: dark) {
  html[data-theme="auto"] .icon-btn .icon-sun { display: none; }
  html[data-theme="auto"] .icon-btn .icon-moon { display: block; }
}

/* Boot loader
   ========================================================================== */

.boot {
  min-height: 50vh;
  display: grid;
  place-items: center;
  animation: fadeIn 0.3s var(--ease) both;
}

.boot-spinner {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 2.5px solid var(--bg-tertiary);
  border-top-color: var(--accent);
  animation: spin 0.8s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* Setup-needed screen
   ========================================================================== */

.setup {
  max-width: 640px;
  margin: 0 auto;
  padding: 40px 4px 80px;
  animation: fadeUp 0.5s var(--ease) both;
}

.setup-eyebrow {
  font-size: 13px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--accent);
  margin-bottom: 12px;
}

.setup-title {
  font-size: clamp(32px, 5vw, 44px);
  font-weight: 700;
  line-height: 1.1;
  letter-spacing: -0.03em;
  margin: 0 0 16px;
}

.setup-body {
  font-size: 17px;
  color: var(--text-secondary);
  margin: 0 0 32px;
  line-height: 1.5;
}

.setup-steps {
  list-style: none;
  padding: 0;
  margin: 0 0 32px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.setup-steps li {
  display: flex;
  gap: 16px;
  padding: 18px 20px;
  background: var(--bg-elevated);
  border-radius: var(--r-md);
  border: 1px solid var(--separator);
}

.setup-step-num {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--accent);
  color: white;
  display: grid;
  place-items: center;
  font-size: 13px;
  font-weight: 700;
  flex-shrink: 0;
}

.setup-step-title {
  font-size: 15px;
  font-weight: 600;
  margin-bottom: 4px;
  letter-spacing: -0.01em;
}

.setup-step-detail {
  font-size: 14px;
  color: var(--text-secondary);
  line-height: 1.5;
}

.setup-step-detail code {
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-size: 12.5px;
  background: var(--bg-secondary);
  padding: 1px 6px;
  border-radius: 5px;
  color: var(--text);
}

.setup-actions {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

/* Auth (login / signup) screen
   ========================================================================== */

.auth {
  max-width: 380px;
  margin: 0 auto;
  padding: 40px 0 60px;
  text-align: center;
  animation: fadeUp 0.5s var(--ease) both;
}

.auth-mark {
  width: 64px;
  height: 64px;
  border-radius: 18px;
  background: var(--accent);
  color: white;
  display: grid;
  place-items: center;
  margin: 0 auto 24px;
  box-shadow: 0 12px 32px var(--accent-soft-strong);
}
.auth-mark svg { width: 32px; height: 32px; }

.auth-title {
  font-size: 36px;
  font-weight: 700;
  letter-spacing: -0.03em;
  margin: 0 0 8px;
}

.auth-subtitle {
  font-size: 16px;
  color: var(--text-secondary);
  margin: 0 0 32px;
}

.btn-google {
  background: var(--bg-elevated);
  color: var(--text);
  border: 1.5px solid var(--separator-strong);
  font-weight: 500;
  box-shadow: var(--shadow-sm);
}
.btn-google:hover { background: var(--bg-secondary); }
.google-icon { width: 18px; height: 18px; }

.auth-divider {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 20px 0;
  color: var(--text-tertiary);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  font-weight: 600;
}
.auth-divider::before,
.auth-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--separator);
}

.auth-tabs {
  margin-bottom: 24px;
}

.auth-form {
  text-align: left;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.field-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  padding: 0 4px;
  letter-spacing: -0.01em;
}

.field input {
  font-family: inherit;
  font-size: 16px;
  padding: 14px 16px;
  border-radius: 12px;
  border: 1.5px solid var(--separator-strong);
  background: var(--bg-elevated);
  color: var(--text);
  transition: border-color 0.18s var(--ease), box-shadow 0.18s var(--ease);
  color-scheme: light dark;
  width: 100%;
}

.field input:focus {
  outline: 0;
  border-color: var(--accent);
  box-shadow: 0 0 0 4px var(--accent-soft);
}

.field-hint {
  font-size: 12px;
  color: var(--text-tertiary);
  padding: 0 4px;
  margin-top: 2px;
}

.auth-error {
  background: var(--danger-soft);
  color: var(--danger);
  padding: 12px 14px;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 500;
  text-align: center;
  animation: fadeIn 0.2s var(--ease);
}

.btn-full {
  width: 100%;
}

.auth-link {
  background: none;
  color: var(--accent);
  font-size: 14px;
  font-weight: 500;
  padding: 8px;
  border-radius: 6px;
  margin: 0 auto;
  display: block;
  transition: opacity 0.15s var(--ease);
}
.auth-link:hover { opacity: 0.7; }

.auth-fineprint {
  font-size: 13px;
  color: var(--text-tertiary);
  margin: 32px 0 0;
}

/* Account row in settings
   ========================================================================== */

.account-row {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 16px;
  background: var(--bg-secondary);
  border-radius: var(--r-md);
  margin-bottom: 8px;
}

.account-avatar {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--accent);
  color: white;
  display: grid;
  place-items: center;
  font-size: 18px;
  font-weight: 700;
  text-transform: uppercase;
  flex-shrink: 0;
}

.account-meta { flex: 1; min-width: 0; }
.account-email {
  font-size: 15px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.account-status {
  font-size: 12px;
  color: var(--success);
  margin-top: 2px;
  display: flex;
  align-items: center;
  gap: 6px;
}
.account-status::before {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
}

/* Welcome / onboarding
   ========================================================================== */

.welcome {
  padding: 60px 4px;
  text-align: center;
  animation: fadeUp 0.6s var(--ease) both;
}

.welcome-eyebrow {
  font-size: 13px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--accent);
  margin-bottom: 16px;
}

.welcome-title {
  font-size: clamp(40px, 7vw, 64px);
  font-weight: 700;
  line-height: 1.05;
  letter-spacing: -0.035em;
  margin: 0 0 24px;
}

.welcome-body {
  font-size: 19px;
  color: var(--text-secondary);
  max-width: 520px;
  margin: 0 auto 40px;
  line-height: 1.5;
}

.welcome-phases {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  max-width: 460px;
  margin: 0 auto 40px;
}
@media (min-width: 640px) {
  .welcome-phases { grid-template-columns: repeat(4, 1fr); }
}

.welcome-phase {
  padding: 18px 12px;
  background: var(--bg-elevated);
  border-radius: var(--r-md);
  border: 1px solid var(--separator);
  display: flex;
  flex-direction: column;
  gap: 4px;
  transition: transform 0.2s var(--ease-spring);
}
.welcome-phase:hover { transform: translateY(-2px); }
.welcome-phase-name { font-size: 14px; font-weight: 600; }
.welcome-phase-days { font-size: 12px; color: var(--text-tertiary); }

.welcome-fineprint { font-size: 13px; color: var(--text-tertiary); margin-top: 16px; }

/* Buttons
   ========================================================================== */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 22px;
  border-radius: 980px;
  font-size: 15px;
  font-weight: 600;
  letter-spacing: -0.01em;
  transition: background 0.18s var(--ease), color 0.18s var(--ease), transform 0.12s var(--ease-spring), box-shadow 0.18s var(--ease);
  white-space: nowrap;
}
.btn:active { transform: scale(0.96); }
.btn svg { width: 18px; height: 18px; }

.btn-primary {
  background: var(--accent);
  color: white;
  box-shadow: 0 6px 16px var(--accent-soft-strong);
}
.btn-primary:hover { background: var(--accent-hover); }
.btn-primary:disabled {
  background: var(--bg-tertiary);
  color: var(--text-tertiary);
  cursor: not-allowed;
  box-shadow: none;
}

.btn-secondary {
  background: var(--bg-secondary);
  color: var(--text);
}
.btn-secondary:hover { background: var(--bg-tertiary); }

.btn-danger {
  background: var(--danger);
  color: white;
}
.btn-danger:hover { background: #ff2d22; }

.btn-danger-soft {
  background: var(--danger-soft);
  color: var(--danger);
}
.btn-danger-soft:hover { background: rgba(255, 59, 48, 0.2); }

.btn-large {
  padding: 16px 32px;
  font-size: 17px;
}

/* Cards
   ========================================================================== */

.card {
  background: var(--bg-elevated);
  border-radius: var(--r-xl);
  padding: 24px;
  margin-bottom: 20px;
  box-shadow: var(--shadow-md);
  border: 1px solid var(--separator);
  animation: fadeUp 0.5s var(--ease) both;
}

@media (min-width: 640px) {
  .card { padding: 28px; }
}

.card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 22px;
  flex-wrap: wrap;
}

.card-eyebrow {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-tertiary);
  margin-bottom: 4px;
}

.card-title {
  margin: 0;
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.02em;
}

/* Hero
   ========================================================================== */

.hero {
  padding: 8px 4px 28px;
  animation: fadeUp 0.5s var(--ease) both;
}

.hero-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 28px;
}

.hero-meta { flex: 1; min-width: 0; }

.hero-eyebrow {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-tertiary);
  margin-bottom: 8px;
  letter-spacing: -0.01em;
}

.hero-title {
  margin: 0 0 6px;
  font-size: clamp(36px, 6vw, 52px);
  font-weight: 700;
  letter-spacing: -0.035em;
  line-height: 1.05;
  background: linear-gradient(135deg, var(--text) 0%, var(--text) 60%, var(--accent) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.hero-status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 980px;
  background: var(--success-soft);
  color: var(--success);
  font-size: 12px;
  font-weight: 600;
}

.hero-status::before {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
}

.hero-status.failed { background: var(--danger-soft); color: var(--danger); }
.hero-status.complete { background: var(--accent-soft); color: var(--accent); }

/* Progress ring */
.hero-ring {
  position: relative;
  width: 140px;
  height: 140px;
  flex-shrink: 0;
}

.hero-ring svg {
  width: 100%;
  height: 100%;
  transform: rotate(-90deg);
}

.ring-track {
  fill: none;
  stroke: var(--bg-tertiary);
  stroke-width: 8;
}

.ring-fill {
  fill: none;
  stroke: var(--accent);
  stroke-width: 8;
  stroke-linecap: round;
  stroke-dasharray: 326.7;
  stroke-dashoffset: 326.7;
  transition: stroke-dashoffset 0.8s var(--ease);
  filter: drop-shadow(0 0 8px var(--accent-soft-strong));
}

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

.ring-day-label { font-size: 11px; font-weight: 600; color: var(--text-tertiary); text-transform: uppercase; letter-spacing: 0.08em; }
.ring-day { font-size: 38px; font-weight: 700; line-height: 1; letter-spacing: -0.04em; }
.ring-of { font-size: 12px; color: var(--text-secondary); margin-top: 2px; }

/* Hero stats */
.hero-stats {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  padding: 16px;
  background: var(--bg-elevated);
  border-radius: var(--r-lg);
  border: 1px solid var(--separator);
  box-shadow: var(--shadow-sm);
}

@media (min-width: 640px) {
  .hero-stats { grid-template-columns: repeat(4, 1fr); }
}

.stat {
  text-align: center;
  padding: 6px 4px;
}

.stat + .stat { border-left: 1px solid var(--separator); }

@media (max-width: 639px) {
  .stat:nth-child(odd) + .stat { border-left: 1px solid var(--separator); }
  .stat:nth-child(3) { border-left: 0; }
}

.stat-value {
  font-size: 28px;
  font-weight: 700;
  letter-spacing: -0.03em;
  line-height: 1;
}

.stat-label {
  margin-top: 6px;
  font-size: 12px;
  color: var(--text-tertiary);
  font-weight: 500;
}

/* Tasks
   ========================================================================== */

.completion-badge {
  padding: 6px 12px;
  background: var(--bg-secondary);
  border-radius: 980px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  font-variant-numeric: tabular-nums;
}

.completion-badge.complete {
  background: var(--success-soft);
  color: var(--success);
}

.tasks {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

/* Shown above the checklist when editing a past day clicked from the calendar. */
.day-edit-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 14px;
  border-radius: var(--r-md);
  background: var(--accent-soft);
  border: 1px solid var(--accent-soft-strong);
}

.day-edit-banner-text {
  font-size: 13px;
  font-weight: 600;
  color: var(--accent);
}

.day-edit-back {
  flex-shrink: 0;
  border: 0;
  border-radius: 999px;
  padding: 6px 14px;
  background: var(--accent);
  color: #fff;
  font-family: inherit;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.15s var(--ease-spring), opacity 0.18s var(--ease);
}

.day-edit-back:hover { transform: scale(1.04); }
.day-edit-back:active { transform: scale(0.97); }

.task {
  display: flex;
  align-items: stretch;
  background: var(--bg-secondary);
  border-radius: var(--r-md);
  transition: background 0.18s var(--ease);
  overflow: hidden;
  user-select: none;
}

.task-main {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 8px 14px 16px;
  background: transparent;
  border: 0;
  text-align: left;
  cursor: default;
  min-width: 0;
  font: inherit;
  color: inherit;
}

.task-main[data-action] { cursor: pointer; }

/* Hovering the interactive body lightens the whole task — including
   behind the toggle on the right. */
.task:has(.task-main[data-action]:hover) { background: var(--bg-tertiary); }
.task.checked:has(.task-main[data-action]:hover) { background: var(--accent-soft-strong); }

.task-toggle {
  display: grid;
  place-items: center;
  padding: 0 18px;
  background: transparent;
  border: 0;
  cursor: pointer;
}

/* Toggle hover only changes the ring — no background change. */
.task-toggle:hover .task-check {
  border-color: var(--accent);
  transform: scale(1.08);
}
.task-toggle:active .task-check { transform: scale(0.92); }

.task-icon {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: var(--bg-elevated);
  color: var(--accent);
  display: grid;
  place-items: center;
  flex-shrink: 0;
  transition: background 0.2s var(--ease), color 0.2s var(--ease);
}
.task-icon svg { width: 20px; height: 20px; }

.task-body { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.task-label { font-size: 16px; font-weight: 500; letter-spacing: -0.01em; }
.task-detail { font-size: 13px; color: var(--text-tertiary); margin-top: 2px; }

.task-check {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  border: 2px solid var(--separator-strong);
  display: grid;
  place-items: center;
  flex-shrink: 0;
  transition: background 0.18s var(--ease), border-color 0.18s var(--ease), transform 0.2s var(--ease-spring);
}

.task-check svg {
  width: 14px;
  height: 14px;
  color: white;
  opacity: 0;
  transform: scale(0.5);
  transition: opacity 0.18s var(--ease), transform 0.2s var(--ease-spring);
}

.task.checked {
  background: var(--accent-soft);
}
.task.checked .task-icon {
  background: var(--accent);
  color: white;
}
.task.checked .task-check {
  background: var(--accent);
  border-color: var(--accent);
}
.task.checked .task-check svg {
  opacity: 1;
  transform: scale(1);
}
.task.checked .task-label {
  color: var(--text-secondary);
  text-decoration: line-through;
  text-decoration-color: var(--text-tertiary);
  text-decoration-thickness: 1.5px;
}

.task-actions {
  display: flex;
  gap: 10px;
  margin-top: 20px;
  padding-top: 20px;
  border-top: 1px solid var(--separator);
  flex-wrap: wrap;
}

/* Water log sheet
   ========================================================================== */

.water-progress {
  margin-bottom: 28px;
  padding: 20px;
  background: var(--bg-secondary);
  border-radius: var(--r-md);
}

.water-meta {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 12px;
}

.water-total {
  font-size: 32px;
  font-weight: 700;
  letter-spacing: -0.03em;
  font-variant-numeric: tabular-nums;
  line-height: 1;
}

.water-unit {
  font-size: 15px;
  font-weight: 500;
  color: var(--text-tertiary);
  letter-spacing: -0.01em;
}

.water-percent {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-tertiary);
  font-variant-numeric: tabular-nums;
}

.water-bar {
  height: 8px;
  background: var(--bg-tertiary);
  border-radius: 980px;
  overflow: hidden;
}

.water-bar-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 980px;
  transition: width 0.5s var(--ease);
}

.water-presets {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.water-chip {
  padding: 10px 18px;
  border-radius: 980px;
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  background: var(--bg-secondary);
  cursor: pointer;
  transition: background 0.15s var(--ease), transform 0.12s var(--ease-spring);
  white-space: nowrap;
}
.water-chip:hover { background: var(--bg-tertiary); }
.water-chip:active { transform: scale(0.96); }

.water-chip-custom {
  background: var(--accent-soft);
  color: var(--accent);
}
.water-chip-custom:hover { background: var(--accent-soft-strong); }

.water-chip-group {
  display: inline-flex;
  align-items: stretch;
  border-radius: 980px;
  overflow: hidden;
}
.water-chip-group .water-chip { border-radius: 0; padding-right: 12px; }

.water-chip-remove {
  display: grid;
  place-items: center;
  padding: 0 11px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s var(--ease), color 0.15s var(--ease);
  border-left: 1px solid rgba(255, 149, 0, 0.18);
  line-height: 1;
}
.water-chip-remove:hover { background: var(--danger); color: white; border-left-color: var(--danger); }

.water-custom-form {
  display: flex;
  gap: 10px;
  align-items: stretch;
  margin-bottom: 8px;
}

.water-custom-input {
  flex: 1;
  font-family: inherit;
  font-size: 16px;
  padding: 12px 16px;
  border-radius: 12px;
  border: 1.5px solid var(--separator-strong);
  background: var(--bg-elevated);
  color: var(--text);
  color-scheme: light dark;
  -webkit-appearance: none;
  appearance: none;
}
.water-custom-input:focus {
  outline: 0;
  border-color: var(--accent);
  box-shadow: 0 0 0 4px var(--accent-soft);
}

.water-custom-form .btn { padding: 12px 22px; }

/* Photo upload sheet
   ========================================================================== */

.photo-day-nav {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 16px;
}

.photo-day-nav .photo-day-line {
  flex: 1;
  text-align: center;
  font-size: 15px;
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--text);
  margin: 0;
}

.photo-day-nav-btn {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: var(--bg-secondary);
  color: var(--text);
  display: grid;
  place-items: center;
  cursor: pointer;
  transition: background 0.18s var(--ease), transform 0.12s var(--ease-spring), opacity 0.18s var(--ease);
  flex-shrink: 0;
}
.photo-day-nav-btn:hover:not(:disabled) { background: var(--bg-tertiary); }
.photo-day-nav-btn:active:not(:disabled) { transform: scale(0.92); }
.photo-day-nav-btn:disabled { opacity: 0.3; cursor: not-allowed; }
.photo-day-nav-btn svg { width: 18px; height: 18px; }

.photo-day-line {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-tertiary);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 12px;
}

.photo-preview {
  position: relative;
  width: 100%;
  aspect-ratio: var(--photo-aspect-ratio);
  border-radius: var(--r-md);
  background: var(--bg-secondary);
  overflow: hidden;
  margin-bottom: 16px;
  display: grid;
  place-items: center;
}

.photo-preview img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.photo-preview-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  color: var(--text-tertiary);
  text-align: center;
  padding: 24px;
}
.photo-preview-placeholder svg { width: 40px; height: 40px; opacity: 0.6; }
.photo-preview-placeholder span { font-size: 14px; }

/* Photo alignment view */
.photo-align-stage {
  margin-bottom: 16px;
}

.photo-align-canvas {
  position: relative;
  width: 100%;
  aspect-ratio: var(--photo-aspect-ratio);
  border-radius: var(--r-md);
  background: #000;
  overflow: hidden;
  margin-bottom: 14px;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}

.photo-align-img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  transform-origin: 0 0;
  pointer-events: none;
  will-change: transform;
}

.photo-align-target,
.photo-align-pin {
  position: absolute;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  margin-left: -13px;
  margin-top: -13px;
  pointer-events: none;
  transition: opacity 0.18s var(--ease), transform 0.12s var(--ease-spring);
  z-index: 2;
}

.photo-align-target {
  border: 2px dashed rgba(255, 255, 255, 0.55);
  background: rgba(255, 149, 0, 0.16);
  z-index: 1;
}
.photo-align-target::after {
  content: '';
  position: absolute;
  inset: 9px;
  border-radius: 50%;
  background: rgba(255, 149, 0, 0.6);
}

.photo-align-pin {
  background: var(--accent);
  box-shadow: 0 0 0 3px rgba(255, 149, 0, 0.25), 0 4px 12px rgba(0, 0, 0, 0.4);
  display: grid;
  place-items: center;
  pointer-events: auto;
  cursor: grab;
}
.photo-align-pin:active { cursor: grabbing; transform: scale(1.1); }

.photo-align-pin-num {
  color: white;
  font-size: 12px;
  font-weight: 700;
  line-height: 1;
}

.photo-align-pin.placeholder { opacity: 0; pointer-events: none; }

.photo-align-hint {
  position: absolute;
  left: 50%;
  bottom: 12px;
  transform: translateX(-50%);
  padding: 6px 14px;
  background: rgba(0, 0, 0, 0.55);
  color: white;
  border-radius: 980px;
  font-size: 12px;
  font-weight: 600;
  pointer-events: none;
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  transition: opacity 0.2s var(--ease);
  z-index: 3;
}
.photo-align-hint.hidden { opacity: 0; }

.photo-align-magnifier {
  position: fixed;
  width: 150px;
  height: 150px;
  border-radius: 50%;
  border: 3px solid white;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.25), 0 12px 32px rgba(0, 0, 0, 0.55);
  overflow: hidden;
  pointer-events: none;
  z-index: 200;
  background: #000;
  will-change: left, top;
}

.photo-align-magnifier-clone {
  position: absolute;
  top: 0;
  left: 0;
  transform-origin: 0 0;
  pointer-events: none;
}

.photo-align-magnifier-img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  transform-origin: 0 0;
}

.photo-align-magnifier-crosshair {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 0;
  height: 0;
  pointer-events: none;
  z-index: 2;
}
.photo-align-magnifier-crosshair::before,
.photo-align-magnifier-crosshair::after {
  content: '';
  position: absolute;
  background: rgba(255, 149, 0, 0.95);
  box-shadow: 0 0 4px rgba(0, 0, 0, 0.6);
}
.photo-align-magnifier-crosshair::before {
  left: -12px;
  top: -1px;
  height: 2px;
  width: 24px;
}
.photo-align-magnifier-crosshair::after {
  top: -12px;
  left: -1px;
  width: 2px;
  height: 24px;
}

.photo-align-reset-btn {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--bg-secondary);
  color: var(--text-secondary);
  display: grid;
  place-items: center;
  cursor: pointer;
  transition: background 0.18s var(--ease), transform 0.12s var(--ease-spring), color 0.18s var(--ease);
  flex-shrink: 0;
}
.photo-align-reset-btn:hover { background: var(--bg-tertiary); color: var(--text); }
.photo-align-reset-btn:active { transform: scale(0.92); }
.photo-align-reset-btn svg { width: 16px; height: 16px; }

.photo-align-controls {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 14px;
}

.photo-align-control {
  display: flex;
  align-items: center;
  gap: 12px;
}

.photo-align-control-label {
  flex-shrink: 0;
  width: 56px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
}

.photo-align-control input[type="range"] {
  flex: 1;
  -webkit-appearance: none;
  appearance: none;
  background: var(--bg-secondary);
  height: 6px;
  border-radius: 980px;
  outline: 0;
}
.photo-align-control input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--accent);
  cursor: pointer;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3);
}
.photo-align-control input[type="range"]::-moz-range-thumb {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--accent);
  cursor: pointer;
  border: 0;
}

.photo-align-mode {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  background: var(--bg-secondary);
  border-radius: var(--r-md);
  cursor: pointer;
  font-size: 13px;
  color: var(--text-secondary);
  margin-bottom: 14px;
}
.photo-align-mode input { accent-color: var(--accent); width: 18px; height: 18px; flex-shrink: 0; }

.photo-align-actions {
  display: flex;
  gap: 10px;
}
.photo-align-actions .btn { flex: 1; }

.photo-sheet-actions { display: block; }

/* Cut-out touch-up editor */
.photo-edit-stage {
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.photo-edit-canvas {
  display: block;
  /* Size to the image's own aspect ratio (no letterboxing). */
  width: auto;
  height: auto;
  max-width: 100%;
  max-height: 56vh;
  margin: 0 auto;
  border-radius: var(--r-md);
  background: var(--bg-secondary);
  cursor: crosshair;
  touch-action: none;
}
.photo-edit-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 12px;
}
.photo-edit-tools { display: flex; gap: 8px; }
.photo-edit-tool {
  border: 1px solid var(--separator-strong);
  background: var(--bg-secondary);
  color: var(--text);
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  padding: 8px 14px;
  border-radius: 999px;
  cursor: pointer;
  transition: background 0.15s var(--ease), color 0.15s var(--ease), border-color 0.15s var(--ease);
}
.photo-edit-tool.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
.photo-edit-brush {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1;
  min-width: 140px;
}
.photo-edit-brush-label { font-size: 13px; color: var(--text-tertiary); }
.photo-edit-brush input[type="range"] { flex: 1; accent-color: var(--accent); }
.photo-edit-actions {
  display: flex;
  gap: 10px;
  align-items: center;
}
.photo-edit-actions .btn { margin-left: auto; min-width: 140px; }
.photo-edit-saved {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-tertiary);
}

.photo-edit-magnifier-canvas {
  display: block;
  width: 150px;
  height: 150px;
}

.photo-progress { margin: 12px 0 16px; }
.photo-progress-bar {
  height: 6px;
  background: var(--bg-tertiary);
  border-radius: 980px;
  overflow: hidden;
}
.photo-progress-fill {
  height: 100%;
  width: 0;
  background: var(--accent);
  border-radius: 980px;
  transition: width 0.25s var(--ease);
}
.photo-progress-label {
  font-size: 12px;
  color: var(--text-tertiary);
  margin-top: 6px;
  text-align: center;
}

/* Photo timeline card
   ========================================================================== */

.photos-header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* Subtle indicator while cut-outs are being produced off the critical path. */
.photos-bg-status {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-tertiary);
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.photos-bg-status::before {
  content: '';
  width: 8px;
  height: 8px;
  border-radius: 50%;
  border: 1.5px solid var(--accent);
  border-top-color: transparent;
  animation: photos-bg-spin 0.7s linear infinite;
}
@keyframes photos-bg-spin { to { transform: rotate(360deg); } }

.photos-download-btn {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--bg-secondary);
  color: var(--text-secondary);
  cursor: pointer;
  display: grid;
  place-items: center;
  transition: background 0.15s var(--ease), color 0.15s var(--ease), transform 0.12s var(--ease-spring);
  -webkit-tap-highlight-color: transparent;
}
.photos-download-btn:hover { background: var(--bg-tertiary); color: var(--text); }
.photos-download-btn:active { transform: scale(0.92); }
.photos-download-btn:disabled { opacity: 0.4; cursor: not-allowed; }
.photos-download-btn svg { width: 18px; height: 18px; }

.video-progress-bar {
  width: 100%;
  height: 8px;
  background: var(--bg-secondary);
  border-radius: 980px;
  overflow: hidden;
  margin: 18px 0 22px;
}
.video-progress-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 980px;
  transition: width 0.2s var(--ease);
  width: 0%;
}

.photos-mode-pill {
  padding: 6px 14px;
  background: var(--accent-soft);
  color: var(--accent);
  border-radius: 980px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  cursor: pointer;
  transition: opacity 0.18s var(--ease), background 0.18s var(--ease), transform 0.12s var(--ease-spring);
  -webkit-tap-highlight-color: transparent;
}
.photos-mode-pill:hover { background: var(--accent-soft-strong); }
.photos-mode-pill:active { transform: scale(0.95); }
.photos-mode-pill.hidden { opacity: 0; pointer-events: none; }

/* Scope pill (Current / All time) — appears once a restart has left photos
   from an earlier run. Outlined so it reads as a filter, distinct from the
   solid mode pill beside it; fills in while "All time" is active. */
.photos-scope-pill {
  background: transparent;
  box-shadow: inset 0 0 0 1.5px var(--accent-soft-strong);
}
.photos-scope-pill.scope-all { background: var(--accent-soft); }
.photos-scope-pill.hidden { display: none; }

.photos-stage {
  display: grid;
  grid-template-columns: 1fr 78px;
  gap: 12px;
  align-items: stretch;
}

@media (min-width: 720px) {
  .photos-stage {
    grid-template-columns: minmax(280px, 380px) 1fr;
    gap: 20px;
  }
}

.photos-image-wrap {
  position: relative;
  width: 100%;
  aspect-ratio: var(--photo-aspect-ratio);
  border-radius: var(--r-md);
  background: var(--bg-secondary);
  overflow: hidden;
}

.photos-image {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  opacity: 0;
  transform-origin: 0 0;
  transition: opacity var(--photo-fade-ms, 240ms) var(--ease);
  pointer-events: none;
}

/* Fixed backdrop behind the cut-outs (shown only in remove-background +
   background-image mode). The cut-out layers paint on top of it. */
.photos-bg-layer {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: none;
  z-index: 0;
  transform-origin: center;
  pointer-events: none;
}

.photos-empty {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  color: var(--text-tertiary);
  text-align: center;
  padding: 20px;
}
.photos-empty svg { width: 36px; height: 36px; opacity: 0.55; }
.photos-empty-title { font-size: 14px; font-weight: 600; color: var(--text-secondary); }
.photos-empty-body { font-size: 12px; max-width: 220px; line-height: 1.4; }
.photos-image-wrap.has-photo .photos-empty { display: none; }

.photos-day-tag {
  position: absolute;
  left: 12px;
  bottom: 12px;
  padding: 6px 12px;
  background: rgba(0, 0, 0, 0.55);
  color: white;
  border-radius: 980px;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: -0.01em;
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  opacity: 0;
  transition: opacity 0.3s var(--ease);
}
.photos-image-wrap.has-photo .photos-day-tag { opacity: 1; }

.photos-side {
  /* The rail-frame inside is position: absolute so its tall (75-item)
     content can't propagate up and force the parent grid row taller. With
     the rail out of normal flow, .photos-side's intrinsic height is just
     the summary (mobile: 0). The grid row is then sized only by the
     image's aspect-ratio, and the rail fills the remaining space. */
  position: relative;
  min-width: 0;
  min-height: 0;
}

.photos-summary {
  display: none;
}

@media (min-width: 720px) {
  .photos-summary {
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding: 20px 22px;
    background: var(--bg-secondary);
    border-radius: var(--r-md);
    flex-shrink: 0;
  }
}

.photos-summary-day {
  font-size: 32px;
  font-weight: 700;
  letter-spacing: -0.03em;
  line-height: 1.05;
}

.photos-summary-date {
  font-size: 14px;
  color: var(--text-secondary);
  font-variant-numeric: tabular-nums;
  margin-top: 2px;
}

.photos-summary-phase {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--accent);
  margin-top: 10px;
}

.photos-summary-stats {
  font-size: 12px;
  color: var(--text-tertiary);
  margin-top: 8px;
  padding-top: 10px;
  border-top: 1px solid var(--separator);
  font-variant-numeric: tabular-nums;
}

.photos-rail-frame {
  /* Absolute fill of .photos-side. top is overwritten by JS to sit below
     the summary on desktop; defaults to 0 on mobile (where summary is
     display: none). bottom: 0 makes it stretch to fill the side's height,
     which is in turn locked to the image's aspect-ratio height. */
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  min-height: 0;
  background: var(--bg-secondary);
  border-radius: var(--r-md);
  overflow: hidden;
  display: flex;
}

.photos-rail-frame::before,
.photos-rail-frame::after {
  content: '';
  position: absolute;
  left: 0;
  right: 6px; /* don't overlap the scrollbar */
  height: 32px;
  pointer-events: none;
  z-index: 2;
}
.photos-rail-frame::before {
  top: 0;
  background: linear-gradient(to bottom, var(--bg-secondary), transparent);
}
.photos-rail-frame::after {
  bottom: 0;
  background: linear-gradient(to top, var(--bg-secondary), transparent);
}

.photos-rail {
  flex: 1;
  min-height: 0; /* same reason as the frame — keep overflow internal */
  overflow-y: auto;
  overflow-x: hidden;
  scrollbar-width: thin;
  scrollbar-color: var(--bg-quaternary) transparent;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  scroll-behavior: smooth; /* only affects programmatic scrolls */
}
.photos-rail::-webkit-scrollbar { width: 4px; }
.photos-rail::-webkit-scrollbar-track { background: transparent; }
.photos-rail::-webkit-scrollbar-thumb {
  background: var(--bg-quaternary);
  border-radius: 4px;
}

.photos-rail-track {
  position: relative;
}

/* Days without a photo: keep the number/date visible but dim and use a
   subtle gray dot so they read as "empty slot" rather than "uploaded". */
.photos-day-item:not(.has-photo) {
  color: var(--text-tertiary);
}
.photos-day-item:not(.has-photo) .photos-day-dot {
  background: var(--text-tertiary);
  opacity: 0.3;
}
.photos-day-item.future { opacity: 0.45; }

.photos-day-item {
  width: 100%;
  padding: 10px 0;
  text-align: center;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-tertiary);
  font-variant-numeric: tabular-nums;
  background: transparent;
  border: 0;
  cursor: pointer;
  transition: color 0.2s var(--ease), background 0.18s var(--ease), transform 0.2s var(--ease-spring);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  line-height: 1.1;
}

.photos-day-item .photos-day-num { font-size: 15px; font-weight: 700; }

.photos-day-date {
  display: none;
}

.photos-day-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--text-tertiary);
  opacity: 0.35;
}

.photos-day-item.has-photo { color: var(--text-secondary); }
.photos-day-item.has-photo .photos-day-dot { background: var(--accent); opacity: 1; }
.photos-day-item.active {
  color: var(--accent);
  transform: scale(1.08);
}
.photos-day-item.active .photos-day-dot { background: var(--accent); opacity: 1; }

@media (max-width: 540px) {
  .photos-stage { gap: 10px; }
  .photos-day-item .photos-day-num { font-size: 14px; }
}

@media (min-width: 720px) {
  .photos-day-item {
    flex-direction: row;
    justify-content: space-between;
    align-items: center;
    padding: 11px 16px;
    gap: 12px;
    text-align: left;
    border-radius: 0;
  }
  .photos-day-item .photos-day-num {
    font-size: 15px;
    min-width: 28px;
    text-align: left;
    color: var(--text);
  }
  .photos-day-item .photos-day-date {
    display: inline;
    flex: 1;
    font-size: 13px;
    color: var(--text-secondary);
    font-weight: 500;
    font-variant-numeric: tabular-nums;
  }
  .photos-day-item .photos-day-dot {
    width: 8px;
    height: 8px;
  }
  .photos-day-item:hover { background: var(--bg-tertiary); }
  .photos-day-item.active {
    transform: none;
    background: var(--accent-soft);
  }
  .photos-day-item.active .photos-day-num,
  .photos-day-item.active .photos-day-date { color: var(--accent); }
}

/* Calendar
   ========================================================================== */

.legend {
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
}

.legend-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--text-tertiary);
  font-weight: 500;
}

.legend-swatch {
  width: 12px;
  height: 12px;
  border-radius: 4px;
}
.legend-swatch.complete { background: var(--accent); }
.legend-swatch.today { background: transparent; border: 2px solid var(--accent); }
.legend-swatch.selected { background: transparent; box-shadow: 0 0 0 2px var(--accent); }
.legend-swatch.future { background: var(--bg-tertiary); }

.calendar {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(38px, 1fr));
  gap: 6px;
}

.cal-day {
  position: relative;
  aspect-ratio: 1;
  display: grid;
  place-items: center;
  border: 0;
  padding: 0;
  margin: 0;
  border-radius: 8px;
  background: var(--bg-secondary);
  font-family: inherit;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-tertiary);
  transition: transform 0.15s var(--ease-spring), background 0.18s var(--ease), color 0.18s var(--ease);
  cursor: default;
  font-variant-numeric: tabular-nums;
  -webkit-appearance: none;
  appearance: none;
}

button.cal-day { cursor: pointer; }
.cal-day:hover { transform: scale(1.08); z-index: 1; }
.cal-day.future { cursor: default; }
.cal-day.future:hover { transform: none; }

/* The day the checklist is currently editing (a past day clicked into). */
.cal-day.selected {
  box-shadow: 0 0 0 2px var(--bg-elevated), 0 0 0 4px var(--accent);
  z-index: 1;
}

.cal-day.complete {
  background: var(--accent);
  color: white;
  box-shadow: 0 2px 6px var(--accent-soft-strong);
}

.cal-day.today {
  background: var(--bg-elevated);
  color: var(--accent);
  border: 2px solid var(--accent);
}
.cal-day.today.complete {
  background: var(--accent);
  color: white;
}

.cal-day.failed {
  background: var(--danger-soft);
  color: var(--danger);
}

.cal-day.future {
  background: var(--bg-secondary);
  opacity: 0.6;
}

/* Journey overview
   ========================================================================== */

.year-deadline {
  font-size: 13px;
  color: var(--text-tertiary);
  font-variant-numeric: tabular-nums;
}

.journey {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.phase-row {
  display: grid;
  grid-template-columns: auto 1fr auto;
  grid-template-areas:
    "num info meta"
    "bar bar bar";
  align-items: center;
  column-gap: 16px;
  row-gap: 14px;
  padding: 16px;
  background: var(--bg-secondary);
  border-radius: var(--r-md);
  transition: background 0.18s var(--ease);
}

.phase-row.active {
  background: var(--accent-soft);
  border: 1px solid var(--accent-soft-strong);
}

.phase-row.complete {
  background: var(--success-soft);
}

.phase-num {
  grid-area: num;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--bg-tertiary);
  color: var(--text-secondary);
  display: grid;
  place-items: center;
  font-size: 14px;
  font-weight: 700;
  flex-shrink: 0;
}
.phase-row.active .phase-num { background: var(--accent); color: white; }
.phase-row.complete .phase-num { background: var(--success); color: white; }

.phase-info { grid-area: info; min-width: 0; }
.phase-eyebrow {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-tertiary);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 2px;
}
.phase-row.active .phase-eyebrow { color: var(--accent); }
.phase-row.complete .phase-eyebrow { color: var(--success); }

.phase-name { font-size: 16px; font-weight: 600; letter-spacing: -0.01em; }

.phase-meta-col {
  grid-area: meta;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 2px;
  text-align: right;
  flex-shrink: 0;
}

.phase-state {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}
.phase-row.active .phase-state { color: var(--accent); }
.phase-row.complete .phase-state { color: var(--success); }

.phase-meta { font-size: 12px; color: var(--text-tertiary); }
.phase-dates {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-secondary);
  font-variant-numeric: tabular-nums;
}
.phase-row.active .phase-dates { color: var(--accent); }
.phase-row.complete .phase-dates { color: var(--success); }

.phase-bar {
  grid-area: bar;
  width: 100%;
  height: 6px;
  background: var(--bg-tertiary);
  border-radius: 980px;
  overflow: hidden;
}

.phase-bar-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 980px;
  transition: width 0.6s var(--ease);
}
.phase-row.complete .phase-bar-fill { background: var(--success); }

@media (max-width: 540px) {
  .phase-row { column-gap: 10px; padding: 14px; }
  .phase-meta, .phase-dates { font-size: 11px; }
  .phase-state { font-size: 13px; }
}

/* Wait card
   ========================================================================== */

.wait-card { text-align: center; padding: 40px 28px; }

.wait-eyebrow {
  font-size: 12px;
  font-weight: 600;
  color: var(--info);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 12px;
}

.wait-title {
  font-size: 32px;
  font-weight: 700;
  letter-spacing: -0.03em;
  margin: 0 0 12px;
}

.wait-body {
  color: var(--text-secondary);
  max-width: 460px;
  margin: 0 auto 28px;
}

.wait-progress { max-width: 380px; margin: 0 auto 24px; }

.wait-progress-bar {
  height: 8px;
  background: var(--bg-tertiary);
  border-radius: 980px;
  overflow: hidden;
  margin-bottom: 10px;
}

.wait-progress-fill {
  height: 100%;
  background: var(--info);
  border-radius: 980px;
  transition: width 0.6s var(--ease);
}

.wait-progress-meta {
  display: flex;
  justify-content: space-between;
  font-size: 13px;
  color: var(--text-tertiary);
  font-variant-numeric: tabular-nums;
}

/* Settings sheet
   ========================================================================== */

.sheet {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: none;
  align-items: flex-end;
  justify-content: center;
}

.sheet[aria-hidden="false"] { display: flex; }

.sheet-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  animation: fadeIn 0.25s var(--ease);
}

.sheet-panel {
  position: relative;
  width: 100%;
  max-width: 560px;
  max-height: 92vh;
  background: var(--bg-elevated);
  border-radius: var(--r-2xl) var(--r-2xl) 0 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-lg);
  animation: slideUp 0.35s var(--ease);
}

@media (min-width: 640px) {
  .sheet { align-items: center; padding: 24px; }
  .sheet-panel { border-radius: var(--r-2xl); animation: scaleIn 0.25s var(--ease-spring); }
}

.sheet-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px;
  border-bottom: 1px solid var(--separator);
}

.sheet-header h2 {
  margin: 0;
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.sheet-body {
  flex: 1;
  overflow-y: auto;
  padding: 20px 24px 32px;
  -webkit-overflow-scrolling: touch;
}

.settings-group {
  margin-bottom: 28px;
}

.settings-group-title {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-tertiary);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 12px;
  padding: 0 4px;
}

/* Segmented control */
.segmented {
  display: flex;
  background: var(--bg-secondary);
  border-radius: 10px;
  padding: 3px;
  gap: 2px;
}

.segment {
  flex: 1;
  padding: 8px 12px;
  font-size: 14px;
  font-weight: 500;
  border-radius: 8px;
  color: var(--text);
  transition: background 0.18s var(--ease), box-shadow 0.18s var(--ease);
}

.segment.active {
  background: var(--bg-elevated);
  box-shadow: var(--shadow-sm);
  font-weight: 600;
}

.settings-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 4px;
}

.settings-toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 14px 16px;
  background: var(--bg-secondary);
  border-radius: var(--r-md);
  cursor: pointer;
}
.settings-toggle-text { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.settings-toggle-text .settings-hint { margin: 0; padding: 0; }
.settings-switch {
  flex-shrink: 0;
  width: 20px;
  height: 20px;
  accent-color: var(--accent);
  cursor: pointer;
}

.settings-label {
  font-size: 15px;
  font-weight: 500;
}

.text-input {
  font-family: inherit;
  font-size: 15px;
  padding: 8px 12px;
  border-radius: 8px;
  border: 1px solid var(--separator-strong);
  background: var(--bg-elevated);
  color: var(--text);
  color-scheme: light dark;
}

/* Space stacked toggle/option rows within a settings group. */
.settings-toggle-row + .settings-toggle-row,
.settings-toggle-row + .settings-row { margin-top: 10px; }

.bg-image-controls {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}
.bg-image-preview {
  width: 44px;
  height: 44px;
  object-fit: cover;
  border-radius: 8px;
  border: 1px solid var(--separator-strong);
}
.settings-mini-btn {
  border: 1px solid var(--separator-strong);
  background: var(--bg-elevated);
  color: var(--text);
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  padding: 7px 12px;
  border-radius: 8px;
  cursor: pointer;
  white-space: nowrap;
}
.settings-mini-btn-danger { color: var(--danger); }

/* Align background tool */
.bg-align-stage {
  position: relative;
  width: 100%;
  aspect-ratio: var(--photo-aspect-ratio, 4 / 5);
  margin: 0 auto 14px;
  border-radius: var(--r-md);
  overflow: hidden;
  background: var(--bg-secondary);
  touch-action: none;
  cursor: grab;
}
.bg-align-stage:active { cursor: grabbing; }
.bg-align-img,
.bg-align-ghost {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  pointer-events: none;
  user-select: none;
}
.bg-align-img { transform-origin: center; }
/* The ghost uses the alignment matrix, which assumes a top-left origin
   (same as the carousel's .photos-image). */
.bg-align-ghost { opacity: 0.25; transform-origin: 0 0; }
.bg-align-controls { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; }
.bg-align-controls input[type="range"] { flex: 1; accent-color: var(--accent); }
.bg-align-actions { display: flex; gap: 10px; }
.bg-align-actions .btn { flex: 1; }

.settings-hint {
  font-size: 13px;
  color: var(--text-tertiary);
  padding: 0 4px;
  margin: 6px 0 12px;
}

.settings-btn {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  width: 100%;
  padding: 14px 16px;
  background: var(--bg-secondary);
  border-radius: var(--r-md);
  margin-bottom: 8px;
  text-align: left;
  transition: background 0.18s var(--ease), transform 0.12s var(--ease-spring);
}

.settings-btn:hover { background: var(--bg-tertiary); }
.settings-btn:active { transform: scale(0.99); }

.settings-btn span:first-child { font-size: 15px; font-weight: 600; }
.settings-btn-detail { font-size: 13px; color: var(--text-tertiary); font-weight: 400; }

.settings-btn-danger { color: var(--danger); }
.settings-btn-danger:hover { background: var(--danger-soft); }

.settings-about {
  font-size: 13px;
  color: var(--text-tertiary);
  text-align: center;
  padding: 12px 4px;
  line-height: 1.6;
}

/* Confirm modal */
.sheet-modal { align-items: center; padding: 24px; }

.confirm-panel {
  position: relative;
  width: 100%;
  max-width: 380px;
  background: var(--bg-elevated);
  border-radius: var(--r-xl);
  padding: 28px 24px 20px;
  text-align: center;
  box-shadow: var(--shadow-lg);
  animation: scaleIn 0.25s var(--ease-spring);
}

.confirm-title { margin: 0 0 8px; font-size: 18px; font-weight: 700; letter-spacing: -0.01em; }
.confirm-body { margin: 0 0 22px; font-size: 14px; color: var(--text-secondary); }

.confirm-actions { display: flex; gap: 10px; }
.confirm-actions .btn { flex: 1; }

/* Toast */
.toast {
  position: fixed;
  bottom: 32px;
  left: 50%;
  transform: translateX(-50%) translateY(120%);
  background: var(--text);
  color: var(--bg-elevated);
  padding: 12px 20px;
  border-radius: 980px;
  font-size: 14px;
  font-weight: 500;
  box-shadow: var(--shadow-lg);
  z-index: 200;
  pointer-events: none;
  transition: transform 0.4s var(--ease-spring), opacity 0.2s var(--ease);
  opacity: 0;
  max-width: calc(100vw - 40px);
  text-align: center;
}

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

/* Animations
   ========================================================================== */

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes slideUp {
  from { transform: translateY(100%); }
  to { transform: translateY(0); }
}
@keyframes scaleIn {
  from { opacity: 0; transform: scale(0.92); }
  to { opacity: 1; transform: scale(1); }
}

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

/* Responsive tweaks
   ========================================================================== */

@media (max-width: 480px) {
  .hero-row { gap: 14px; margin-bottom: 22px; }
  .hero-meta { min-width: 0; }
  .hero-title { font-size: clamp(30px, 9vw, 40px); }
  .hero-ring { width: 104px; height: 104px; }
  .ring-day { font-size: 28px; }
  .ring-day-label { font-size: 10px; }
  .ring-of { font-size: 11px; }
  .card { padding: 20px; }
}
