:root {
  --bg: #0b0b0c;
  --fg: #0e0e10;
  --text: rgba(255,255,255,0.94);
  --text-dim: rgba(255,255,255,0.6);
  --glass: rgba(255,255,255,0.14);
  --glass-strong: rgba(255,255,255,0.2);
  --border: rgba(255,255,255,0.16);
  --shadow: 0 10px 30px rgba(0,0,0,0.35);
  --accent: #0a84ff; /* default iOS blue */
}

@media (prefers-color-scheme: light) {
  :root {
    --bg: #f2f2f7;
    --fg: #ffffff;
    --text: rgba(0,0,0,0.92);
    --text-dim: rgba(0,0,0,0.55);
    --glass: rgba(255,255,255,0.65);
    --glass-strong: rgba(255,255,255,0.85);
    --border: rgba(0,0,0,0.08);
    --shadow: 0 8px 24px rgba(0,0,0,0.10);
  }
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "SF Pro Display", Segoe UI, Roboto, Helvetica, Arial, "PingFang SC", "Hiragino Sans GB", "Noto Sans CJK SC", "Source Han Sans SC", "Microsoft YaHei", sans-serif;
  color: var(--text);
  background: radial-gradient(1200px 800px at 20% -10%, #1e2a44 0%, transparent 60%),
              radial-gradient(900px 700px at 120% 30%, #2a183e 0%, transparent 60%),
              linear-gradient(180deg, #0b0b0c 0%, #0b0b0c 100%);
  background-attachment: fixed;
  color-scheme: light dark;
}

#app { min-height: 100dvh; display: flex; flex-direction: column; }

/* Nav - iOS large title style */
.nav {
  position: sticky; top: 0; z-index: 50;
  display: grid; grid-template-columns: 1fr auto 1fr; align-items: center;
  padding: calc(env(safe-area-inset-top) + 12px) 16px 12px 16px;
  backdrop-filter: saturate(180%) blur(20px);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  background: color-mix(in oklab, var(--bg) 85%, transparent);
  border-bottom: 1px solid var(--border);
}
.nav-left, .nav-right { display: flex; align-items: center; gap: 8px; }
.nav-title {
  margin: 0; text-align: center;
  font-weight: 700; letter-spacing: -0.02em;
  font-size: clamp(20px, 4.8vw, 28px);
}

.content { flex: 1; padding: 16px; padding-bottom: calc(env(safe-area-inset-bottom) + 24px); }

/* Buttons */
.btn { 
  appearance: none; border: 0; border-radius: 12px; padding: 10px 14px;
  background: var(--glass-strong); color: var(--text);
  backdrop-filter: saturate(180%) blur(20px);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  box-shadow: inset 0 -1px 0 rgba(255,255,255,0.08), var(--shadow);
  transition: transform .08s ease, background .2s ease, opacity .2s ease;
}
.btn.primary { background: color-mix(in oklab, var(--accent) 90%, transparent); color: white; }
.btn.destructive { background: rgba(255, 59, 48, 0.18); color: #ff3b30; }
.btn.subtle { background: transparent; box-shadow: none; border: 1px solid var(--border); }
.btn.icon { width: 36px; height: 36px; padding: 0; display: inline-grid; place-items: center; border-radius: 18px; }
.btn.large { padding: 14px 18px; font-size: 16px; }
.btn.small { padding: 6px 10px; font-size: 13px; border-radius: 10px; }
.btn:active { transform: scale(0.98); }
.btn:disabled { opacity: 0.6; pointer-events: none; }

.icon-plus { font-size: 22px; line-height: 1; }

/* Empty State */
.empty { display: grid; place-items: center; min-height: calc(100dvh - 120px); }
.empty-card { 
  max-width: 520px; width: 100%; padding: 28px; text-align: center; border-radius: 20px; 
  border: 1px solid var(--border); box-shadow: var(--shadow);
}
.empty-emoji { font-size: 48px; margin-bottom: 12px; }
.empty-title { margin: 6px 0; font-size: clamp(18px, 5vw, 24px); font-weight: 700; }
.empty-desc { margin: 0 0 16px 0; color: var(--text-dim); }

/* Glass */
.glass {
  background: var(--glass);
  backdrop-filter: saturate(180%) blur(20px);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
}

/* Hero */
.hero {
  display: none; /* becomes flex when content present */
  align-items: center; justify-content: space-between; gap: 16px;
  border: 1px solid var(--border); border-radius: 22px; padding: 18px 20px; box-shadow: var(--shadow);
  margin-bottom: 18px;
}
.hero .hero-title { font-size: 16px; color: var(--text-dim); margin: 0 0 4px; }
.hero .hero-name { font-weight: 700; letter-spacing: -0.02em; font-size: clamp(20px, 5vw, 28px); margin: 0; }
.hero .hero-time { font-variant-numeric: tabular-nums; font-weight: 700; font-size: clamp(24px, 6.5vw, 40px); white-space: nowrap; }

/* Section head */
.section-head { display: flex; align-items: center; justify-content: space-between; margin: 6px 2px 10px; }
.section-title { margin: 0; font-size: 14px; text-transform: uppercase; letter-spacing: 0.12em; color: var(--text-dim); }

/* Card list */
.card-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 14px; }
.card { 
  position: relative; border-radius: 18px; border: 1px solid var(--border); padding: 16px; overflow: hidden; cursor: pointer; 
  box-shadow: var(--shadow); transition: transform .12s ease, background .2s ease, border-color .2s ease;
}
.card:active { transform: scale(0.99); }
.card .card-accent { position: absolute; inset: 0; opacity: 0.22; pointer-events: none; background: var(--accent); }
.card .card-title { margin: 0 0 8px 0; font-weight: 700; letter-spacing: -0.015em; }
.card .card-time { font-variant-numeric: tabular-nums; font-weight: 700; font-size: 22px; }
.card .card-sub { margin: 6px 0 0; color: var(--text-dim); font-size: 13px; }
.card.done { opacity: 0.7; }

/* Sheet */
.sheet { position: fixed; inset: 0; z-index: 100; }
.sheet .sheet-scrim { position: absolute; inset: 0; background: rgba(0,0,0,0.35); opacity: 0; transition: opacity .2s ease; }
.sheet .sheet-panel { position: absolute; inset-inline: 0; bottom: 0; border-radius: 18px 18px 0 0; border: 1px solid var(--border); padding-bottom: calc(env(safe-area-inset-bottom) + 12px); transform: translateY(100%); transition: transform .28s cubic-bezier(.2,.8,.2,1); box-shadow: var(--shadow); }
.sheet.show .sheet-scrim { opacity: 1; }
.sheet.show .sheet-panel { transform: translateY(0%); }
.sheet-grabber { width: 40px; height: 5px; border-radius: 3px; background: var(--border); margin: 8px auto; }
.sheet-head { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 8px; padding: 4px 14px 8px; }
.sheet-title { margin: 0; text-align: center; font-weight: 700; }
.form { display: grid; gap: 14px; padding: 6px 14px 16px; }
.field { display: grid; gap: 8px; }
.field.row { grid-template-columns: 1fr auto; align-items: center; gap: 16px; }
.label { font-size: 13px; color: var(--text-dim); }
.input { width: 100%; border: 1px solid var(--border); background: var(--glass-strong); color: var(--text); border-radius: 12px; padding: 12px 14px; outline: none; font: inherit; box-shadow: inset 0 -1px 0 rgba(255,255,255,0.06); }
.input:focus { border-color: color-mix(in oklab, var(--accent) 65%, var(--border)); }

/* Swatches */
.swatches { display: flex; gap: 10px; margin-top: 6px; }
.swatch { width: 28px; height: 28px; border-radius: 14px; border: 2px solid transparent; background: var(--accent); padding: 0; }
.swatch[aria-checked="true"], .swatch:focus { outline: none; border-color: var(--text); }
.swatch[data-color] { background: var(--dummy, #0a84ff); }
.swatch[data-color="#0a84ff"] { background: #0a84ff; }
.swatch[data-color="#30d158"] { background: #30d158; }
.swatch[data-color="#ff9f0a"] { background: #ff9f0a; }
.swatch[data-color="#ff375f"] { background: #ff375f; }
.swatch[data-color="#bf5af2"] { background: #bf5af2; }

/* Switch */
.switch { position: relative; width: 52px; height: 32px; border-radius: 16px; border: 1px solid var(--border); background: rgba(127,127,127,0.35); transition: background .2s ease; }
.switch .knob { position: absolute; top: 3px; left: 3px; width: 26px; height: 26px; border-radius: 13px; background: white; transition: left .2s ease, background .2s ease; box-shadow: 0 1px 3px rgba(0,0,0,0.25); }
.switch[aria-checked="true"] { background: color-mix(in oklab, var(--accent) 75%, transparent); }
.switch[aria-checked="true"] .knob { left: 23px; background: white; }

/* Detail */
.detail { position: fixed; inset: 0; z-index: 90; }
.detail .detail-scrim { position: absolute; inset: 0; background: rgba(0,0,0,0.35); opacity: 0; transition: opacity .2s ease; }
.detail .detail-card { position: absolute; inset: 10% 16px auto; border-radius: 22px; border: 1px solid var(--border); box-shadow: var(--shadow); overflow: clip; transform: translateY(20px); opacity: 0; transition: transform .24s ease, opacity .2s ease; }
.detail.show .detail-scrim { opacity: 1; }
.detail.show .detail-card { transform: translateY(0); opacity: 1; }
.detail-head { display: flex; align-items: center; gap: 8px; padding: 10px; }
.detail-head .spacer { flex: 1; }
.detail-body { padding: 8px 18px 18px; text-align: center; }
.detail-title { margin: 10px 0 6px; font-size: clamp(18px, 5vw, 28px); font-weight: 700; letter-spacing: -0.02em; }
.big-timer { font-variant-numeric: tabular-nums; font-weight: 800; letter-spacing: -0.02em; font-size: clamp(40px, 12vw, 100px); }
.detail-sub { margin: 10px 0 0; color: var(--text-dim); }

/* Completion */
.complete { position: fixed; inset: 0; z-index: 120; align-items: center; justify-content: center; }
.complete .complete-card { border: 1px solid var(--border); border-radius: 20px; padding: 18px 20px; text-align: center; box-shadow: var(--shadow); }
.complete .complete-emoji { font-size: 40px; margin-bottom: 8px; }
.complete .complete-text { font-weight: 700; margin-bottom: 10px; }

/* Toast */
.toast { position: fixed; left: 50%; bottom: calc(env(safe-area-inset-bottom) + 24px); transform: translateX(-50%);
  background: var(--glass-strong); color: var(--text); border: 1px solid var(--border); border-radius: 12px; padding: 10px 14px; box-shadow: var(--shadow); z-index: 140; }

/* Utils */
.hidden { display: none !important; }

/* Elevate hero when shown */
#nextUp:not(:empty) { display: flex; }

/* Responsive detail card full-screen for small devices */
@media (max-width: 540px) {
  .detail .detail-card { inset: 8% 10px auto; }
}
