/* First-run setup */
.setup-screen {
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
  background:
    linear-gradient(180deg, color-mix(in oklch, var(--bg) 78%, var(--surface)) 0%, var(--bg-2) 100%);
}
.setup-shell {
  display: grid;
  height: 100vh;
  height: 100dvh;
  grid-template-rows: auto minmax(0, 1fr);
}
.setup-rail {
  display: grid;
  gap: 14px;
  padding: max(18px, calc(var(--safe-t) + 14px)) 16px 14px;
  border-bottom: 1px solid var(--line);
  background: color-mix(in oklch, var(--surface) 94%, var(--bg));
}
.setup-site-link { justify-self: start; }
.setup-brand {
  color: var(--brand);
  font-family: var(--mono);
  font-size: 12px;
  font-weight: 600;
}
.setup-rail h1 {
  max-width: 560px;
  margin-top: 7px;
  color: var(--ink);
  font-size: 28px;
  font-weight: 700;
  line-height: 1.04;
  letter-spacing: -.025em;
  text-wrap: balance;
}
.setup-rail p {
  max-width: 580px;
  margin-top: 9px;
  color: var(--sub);
  font-size: 13px;
  line-height: 1.5;
}
.setup-ledger-card {
  display: none;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--r3);
  background: var(--surface);
}
.setup-ledger-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 42px;
  padding: 0 12px;
  border-bottom: 1px solid var(--line);
  color: var(--sub);
  font-size: 12px;
  font-weight: 700;
}
.setup-ledger-row:last-child { border-bottom: 0; }
.setup-ledger-row strong {
  color: var(--debit);
  font-family: var(--mono);
  font-size: 12px;
  font-weight: 600;
}
.setup-ledger-row.credit strong { color: var(--credit); }
.setup-ledger-row.muted {
  background: var(--surface-2);
}
.setup-ledger-row.muted strong { color: var(--ink); }
.setup-panel-title {
  margin-bottom: 14px;
  padding-bottom: 9px;
  border-bottom: 1px solid var(--line);
  color: var(--ink);
  font-size: 13px;
  font-weight: 700;
}
.setup-progress {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 7px;
}
.setup-progress-step {
  position: relative;
  min-width: 0;
  min-height: 54px;
  padding: 9px;
  border: 1px solid var(--line);
  border-radius: var(--r2);
  background: var(--surface);
  color: var(--sub);
  text-align: left;
  cursor: pointer;
  transition: background-color .16s ease, border-color .16s ease, color .16s ease;
}
.setup-progress-step.active {
  border-color: var(--brand);
  background: var(--brand-soft);
  color: var(--brand);
}
.setup-progress-step:hover { border-color: var(--line-strong); color: var(--ink); }
.setup-progress-step span {
  display: block;
  overflow: hidden;
  font-size: 12px;
  font-weight: 700;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.setup-progress-step small {
  display: none;
  margin-top: 3px;
  color: var(--sub);
  font-size: 11px;
}
.setup-main {
  display: flex;
  min-height: 0;
  flex-direction: column;
  overflow-y: auto;
  padding: 18px 16px 0;
  -webkit-overflow-scrolling: touch;
}
.setup-step { display: none; }
.setup-step.active {
  display: block;
  width: 100%;
  max-width: 900px;
  margin: 0 auto;
  padding-bottom: 12px;
}
.setup-step-head { margin-bottom: 16px; }
.setup-step-head span {
  color: var(--brand);
  font-family: var(--mono);
  font-size: 12px;
  font-weight: 600;
}
.setup-step-head h2 {
  margin-top: 5px;
  color: var(--ink);
  font-size: 28px;
  font-weight: 700;
  line-height: 1.12;
  letter-spacing: -.02em;
}
.setup-step-head p {
  max-width: 620px;
  margin-top: 8px;
  color: var(--sub);
  font-size: 14px;
  line-height: 1.55;
}
.setup-panel,
.setup-week-preview {
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: var(--r3);
  background: var(--surface);
  box-shadow: 0 1px 2px oklch(25% .035 255 / .06);
}
.setup-note {
  padding: 11px 12px;
  border: 1px solid var(--line);
  border-radius: var(--r2);
  background: var(--surface-2);
  color: var(--sub);
  font-size: 13px;
  line-height: 1.55;
}
.setup-week-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 12px;
}
.setup-week-preview {
  display: grid;
  grid-auto-columns: minmax(148px, 1fr);
  grid-auto-flow: column;
  gap: 9px;
  overflow-x: auto;
  scrollbar-width: none;
}
.setup-week-preview::-webkit-scrollbar { display: none; }
.setup-week-day {
  min-width: 148px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--r2);
  background: var(--surface);
}
.setup-week-day.today { border-color: var(--brand); }
.setup-week-day-head {
  padding: 9px 10px;
  border-bottom: 1px solid var(--line);
  color: var(--sub);
  font-size: 12px;
  font-weight: 700;
}
.setup-week-block,
.setup-week-add {
  width: calc(100% - 16px);
  min-height: 48px;
  margin: 8px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: var(--r);
  background: var(--surface-2);
  color: var(--text);
  text-align: left;
}
.setup-week-block strong {
  display: block;
  color: var(--ink);
  font-size: 12px;
}
.setup-week-block span {
  display: block;
  margin-top: 4px;
  color: var(--sub);
  font-family: var(--mono);
  font-size: 11px;
}
.setup-week-block.sleep { border-color: var(--line2); }
.setup-week-block.work {
  border-color: var(--brand-ring);
  background: var(--brand-soft);
}
.setup-week-add {
  border-style: dashed;
  color: var(--sub);
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
}
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}
.setup-cat-rows {
  display: grid;
  gap: 8px;
  margin-bottom: 10px;
}
.setup-cat-row {
  display: grid;
  grid-template-columns: 1fr 1fr 44px;
  grid-template-areas:
    "name name name"
    "mins days remove";
  gap: 8px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: var(--r2);
  background: var(--surface-2);
}
.setup-cat-row .fg { margin-bottom: 0; }
.setup-cat-name { grid-area: name; }
.setup-cat-mins { grid-area: mins; }
.setup-cat-days { grid-area: days; }
.setup-cat-remove {
  grid-area: remove;
  align-self: stretch;
  min-width: 44px;
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: var(--r2);
  background: var(--surface);
  color: var(--sub);
  font-size: 15px;
  cursor: pointer;
  transition: background-color .16s ease, border-color .16s ease, color .16s ease;
}
.setup-cat-remove:hover { border-color: var(--debit); color: var(--debit); background: var(--debit-dim); }
.setup-cat-add {
  min-height: 44px;
  width: 100%;
  margin-bottom: 12px;
}
.setup-pref-panel {
  display: grid;
  grid-template-columns: 1fr;
  gap: 2px;
  margin-top: 10px;
}
.setup-actions {
  position: sticky;
  bottom: 0;
  z-index: 5;
  display: grid;
  grid-template-columns: minmax(0, .75fr) minmax(0, .95fr) minmax(0, 1.1fr);
  gap: 8px;
  width: 100%;
  max-width: 900px;
  margin: auto auto 0;
  padding: 12px 0 max(14px, calc(var(--safe-b) + 12px));
  background: linear-gradient(180deg, transparent, color-mix(in oklch, var(--bg-2) 96%, transparent) 28%, var(--bg-2) 100%);
}
.setup-actions .btn {
  min-width: 0;
  min-height: 44px;
  padding-inline: 10px;
}

.setup-mode-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 7px;
  margin-bottom: 10px;
}
.setup-mode-card {
  min-height: 60px;
  padding: 10px 11px;
  border: 1px solid var(--line);
  border-radius: var(--r2);
  background: var(--surface);
  color: var(--text);
  text-align: left;
  cursor: pointer;
}
.setup-mode-card.on {
  border-color: var(--brand);
  background: var(--brand-soft);
}
.setup-mode-card strong {
  display: block;
  color: var(--ink);
  font-size: 13px;
  font-weight: 700;
}
.setup-mode-card span {
  display: block;
  margin-top: 4px;
  color: var(--sub);
  font-size: 12px;
  line-height: 1.35;
}


@media (min-width: 760px) {
  .setup-mode-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .setup-progress-step small { display: block; }
  .setup-pref-panel { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
  .setup-cat-row {
    grid-template-columns: 1fr 110px 110px 44px;
    grid-template-areas: "name mins days remove";
  }
  .setup-cat-add { width: auto; }
}

@media (min-width: 980px) {
  .setup-shell {
    grid-template-columns: 320px minmax(0, 1fr);
    grid-template-rows: 1fr;
  }
  .setup-rail {
    align-content: start;
    border-right: 1px solid var(--line);
    border-bottom: 0;
    padding: 24px 18px;
  }
  .setup-rail h1 { font-size: 34px; }
  .setup-ledger-card { display: block; }
  .setup-progress { grid-template-columns: 1fr; }
  .setup-main { padding: 34px; }
  .setup-actions {
    display: flex;
    justify-content: flex-end;
    margin: 16px auto 0;
    padding: 14px 0 0;
  }
  .setup-week-layout { grid-template-columns: 280px minmax(0, 1fr); align-items: start; }
  .setup-week-preview {
    grid-template-columns: repeat(7, minmax(0, 1fr));
    grid-auto-flow: row;
    grid-auto-columns: initial;
    overflow: visible;
  }
  .setup-week-day { min-width: 0; }
}
