/* ── iOS Design System ─────────────────────────────── */
:root {
  --bg:           #F2F2F7;
  --bg-card:      #FFFFFF;
  --bg-card2:     #F2F2F7;
  --label:        #000000;
  --label2:       rgba(60,60,67,0.6);
  --label3:       rgba(60,60,67,0.3);
  --separator:    rgba(60,60,67,0.18);
  --blue:         #007AFF;
  --green:        #34C759;
  --red:          #FF3B30;
  --orange:       #FF9500;
  --gray:         #8E8E93;
  --nav-bg:       rgba(242,242,247,0.82);
  --radius:       12px;
  --radius-sm:    8px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg:           #000000;
    --bg-card:      #1C1C1E;
    --bg-card2:     #2C2C2E;
    --label:        #FFFFFF;
    --label2:       rgba(235,235,245,0.6);
    --label3:       rgba(235,235,245,0.18);
    --separator:    rgba(84,84,88,0.55);
    --nav-bg:       rgba(28,28,30,0.82);
  }
}

/* ── Reset ─────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text",
               "Helvetica Neue", sans-serif;
  background: var(--bg);
  color: var(--label);
  min-height: 100vh;
  padding-bottom: env(safe-area-inset-bottom, 24px);
}
a { color: var(--blue); text-decoration: none; }

/* ── Nav bar ───────────────────────────────────────── */
.nav {
  position: sticky; top: 0; z-index: 100;
  background: var(--nav-bg);
  backdrop-filter: saturate(180%) blur(20px);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  border-bottom: 0.5px solid var(--separator);
  padding: 12px 20px;
  padding-top: calc(12px + env(safe-area-inset-top, 0px));
  display: flex; align-items: center; gap: 12px;
}
.nav-back {
  color: var(--blue);
  font-size: 17px;
  display: flex; align-items: center; gap: 4px;
  -webkit-tap-highlight-color: transparent;
}
.nav-back:active { opacity: 0.5; }
.nav-title {
  font-size: 17px;
  font-weight: 600;
  letter-spacing: -0.4px;
}
.nav-large-title {
  font-size: 34px;
  font-weight: 700;
  letter-spacing: -0.5px;
  padding: 8px 20px 4px;
  color: var(--label);
}

/* ── Page wrapper ──────────────────────────────────── */
.page { padding: 0 0 40px; }

/* ── Section ───────────────────────────────────────── */
.section { margin: 24px 0 0; }
.section-header {
  font-size: 13px;
  font-weight: 400;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--label2);
  padding: 0 20px 6px;
}
.section-footer {
  font-size: 13px;
  color: var(--label2);
  padding: 6px 20px 0;
  line-height: 1.4;
}

/* ── Card / grouped list ───────────────────────────── */
.card {
  background: var(--bg-card);
  margin: 0 16px;
  border-radius: var(--radius);
  overflow: hidden;
  animation: fadeSlideUp 0.38s cubic-bezier(0.34,1.3,0.64,1) both;
}
.card + .card { margin-top: 10px; }
@keyframes fadeSlideUp {
  from { opacity: 0; transform: translateY(16px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ── Cell ──────────────────────────────────────────── */
.cell {
  display: flex;
  align-items: center;
  padding: 12px 16px;
  min-height: 50px;
  gap: 12px;
  position: relative;
  -webkit-tap-highlight-color: transparent;
}
.cell + .cell::before {
  content: '';
  position: absolute;
  top: 0; left: 16px; right: 0;
  height: 0.5px;
  background: var(--separator);
}
.cell-link { cursor: pointer; }
.cell-link:active { background: var(--bg-card2); }
.cell-icon {
  width: 32px; height: 32px;
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  font-size: 17px;
  flex-shrink: 0;
}
.cell-content { flex: 1; min-width: 0; }
.cell-title {
  font-size: 17px;
  font-weight: 400;
  letter-spacing: -0.2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.cell-subtitle {
  font-size: 13px;
  color: var(--label2);
  margin-top: 1px;
}
.cell-right {
  display: flex; align-items: center; gap: 6px;
  flex-shrink: 0;
}
.cell-value {
  font-size: 17px;
  color: var(--label2);
}
.chevron {
  color: var(--label3);
  font-size: 14px;
  font-weight: 600;
}

/* ── Status dot ────────────────────────────────────── */
.status-dot {
  width: 10px; height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}
.dot-on  { background: var(--green);
           box-shadow: 0 0 6px rgba(52,199,89,0.5); }
.dot-off { background: var(--red);
           box-shadow: 0 0 6px rgba(255,59,48,0.4); }
.dot-ex  { background: var(--gray); }

/* ── Badge ─────────────────────────────────────────── */
.badge {
  font-size: 12px;
  font-weight: 500;
  padding: 2px 8px;
  border-radius: 20px;
  background: var(--blue);
  color: #fff;
}
.badge-gray { background: var(--bg-card2); color: var(--label2); }
.badge-warn { background: var(--orange); color: #fff; }

/* ── iOS Toggle ────────────────────────────────────── */
.toggle-wrap { display: flex; align-items: center; }
.ios-toggle { position: relative; display: inline-block; width: 51px; height: 31px; }
.ios-toggle input { opacity: 0; width: 0; height: 0; position: absolute; }
.toggle-track {
  position: absolute; inset: 0;
  background: var(--label3);
  border-radius: 15.5px;
  transition: background 0.25s ease;
  cursor: pointer;
}
.ios-toggle input:checked + .toggle-track { background: var(--green); }
.toggle-track::after {
  content: '';
  position: absolute;
  width: 27px; height: 27px;
  background: #fff;
  border-radius: 50%;
  top: 2px; left: 2px;
  box-shadow: 0 2px 6px rgba(0,0,0,0.25);
  transition: transform 0.28s cubic-bezier(0.34,1.56,0.64,1);
}
.ios-toggle input:checked + .toggle-track::after { transform: translateX(20px); }

/* ── Button ────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  font-family: inherit;
  font-size: 17px;
  font-weight: 400;
  padding: 12px 20px;
  border-radius: var(--radius);
  border: none;
  cursor: pointer;
  transition: opacity 0.15s, transform 0.15s;
  -webkit-tap-highlight-color: transparent;
  letter-spacing: -0.2px;
}
.btn:active { opacity: 0.75; transform: scale(0.97); }
.btn-blue   { background: var(--blue);  color: #fff; }
.btn-red    { background: var(--red);   color: #fff; }
.btn-green  { background: var(--green); color: #fff; }
.btn-ghost  { background: var(--bg-card2); color: var(--blue); }
.btn-full   { width: 100%; }
.btn-sm     { font-size: 15px; padding: 8px 16px; }

/* ── Form inputs ───────────────────────────────────── */
.input {
  width: 100%;
  background: transparent;
  border: none;
  font-family: inherit;
  font-size: 17px;
  color: var(--label);
  outline: none;
  padding: 0;
  letter-spacing: -0.2px;
}
.input::placeholder { color: var(--label3); }
.input-row {
  display: flex; align-items: center; gap: 8px;
  padding: 12px 16px;
}
.input-label {
  font-size: 17px;
  color: var(--label);
  flex-shrink: 0;
  min-width: 80px;
}

/* ── Day pills ─────────────────────────────────────── */
.day-grid {
  display: flex; flex-wrap: wrap; gap: 8px;
  padding: 12px 16px;
}
.day-pill {
  width: 38px; height: 38px;
  border-radius: 50%;
  background: var(--bg-card2);
  border: none;
  font-family: inherit;
  font-size: 14px;
  font-weight: 500;
  color: var(--label2);
  cursor: pointer;
  transition: background 0.2s, color 0.2s, transform 0.15s;
  -webkit-tap-highlight-color: transparent;
}
.day-pill.selected {
  background: var(--blue);
  color: #fff;
}
.day-pill:active { transform: scale(0.9); }

/* ── Override banner ───────────────────────────────── */
.override-banner {
  margin: 0 16px;
  padding: 14px 16px;
  background: rgba(255,149,0,0.12);
  border-radius: var(--radius);
  border: 1px solid rgba(255,149,0,0.3);
  display: flex; align-items: center; gap: 10px;
  animation: fadeSlideUp 0.3s ease both;
}
.override-banner-text { flex: 1; font-size: 15px; color: var(--orange); font-weight: 500; }

/* ── Schedule row ──────────────────────────────────── */
.schedule-row {
  display: flex; align-items: center;
  padding: 12px 16px; gap: 12px;
  position: relative;
}
.schedule-row + .schedule-row::before {
  content: ''; position: absolute;
  top: 0; left: 16px; right: 0;
  height: 0.5px; background: var(--separator);
}
.schedule-info { flex: 1; }
.schedule-days { font-size: 15px; font-weight: 500; letter-spacing: -0.2px; }
.schedule-time { font-size: 13px; color: var(--label2); margin-top: 2px; }

/* ── Action buttons row ────────────────────────────── */
.btn-row {
  display: flex; gap: 10px;
  padding: 0 16px;
  margin-top: 12px;
}
.btn-row .btn { flex: 1; }

/* ── Empty state ───────────────────────────────────── */
.empty {
  text-align: center;
  padding: 32px 20px;
  color: var(--label2);
  font-size: 15px;
}
.empty-icon { font-size: 36px; margin-bottom: 8px; }

/* ── Stagger animation for lists ───────────────────── */
.card:nth-child(1) { animation-delay: 0.04s; }
.card:nth-child(2) { animation-delay: 0.08s; }
.card:nth-child(3) { animation-delay: 0.12s; }
.card:nth-child(4) { animation-delay: 0.16s; }
.card:nth-child(5) { animation-delay: 0.20s; }
.card:nth-child(6) { animation-delay: 0.24s; }

/* ── Exempt / Manage move button ───────────────────── */
.cell-link-grow {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--label);
}
.cell-link-grow:active { background: var(--bg-card2); }
.cell-move-form { flex-shrink: 0; }
.btn-move {
  font-family: inherit;
  font-size: 16px;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 1.5px solid var(--separator);
  background: transparent;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
  transition: opacity 0.15s, transform 0.15s;
}
.btn-move:active { opacity: 0.5; transform: scale(0.88); }
.btn-move-manage {
  border-color: rgba(0,122,255,0.35);
}
