*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  font-family: var(--font-sans);
  background: var(--bg); color: var(--fg);
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
  line-height: 1.5;
}

/* ── Auth ── */
#auth-screen {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  min-height: 100vh; padding: 2rem; gap: 1rem;
}
#auth-screen h1 { font-family: var(--font-serif); font-size: 1.75rem; font-weight: 700; color: var(--primary); }
#auth-screen .parent-tag {
  font-size: 0.75rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.08em;
  color: var(--copper-deep); background: var(--copper-soft);
  padding: 0.2rem 0.6rem; border-radius: 99px;
  margin-top: -0.5rem;
}
#auth-screen input {
  font-size: 16px; padding: 0.75rem; width: 100%; max-width: 300px;
  border: 1px solid var(--border); border-radius: var(--r-sm);
  background: var(--card-bg); color: var(--fg);
}
#auth-screen button {
  font-size: 1rem; padding: 0.75rem 2rem; border: none; border-radius: var(--r-sm);
  background: var(--primary); color: #fff; cursor: pointer;
  min-height: 44px; font-weight: 500;
}

/* ── Dashboard shell ── */
#dashboard {
  display: none; max-width: 600px; margin: 0 auto;
  padding: 0 0 3rem;
}

/* Header */
.sconce-header {
  display: flex; align-items: center; gap: 10px;
  padding: 14px 18px 10px;
}
.sconce-header .logo-circle {
  width: 32px; height: 32px; border-radius: 50%;
  background: var(--bg-sunk); display: flex; align-items: center; justify-content: center;
  overflow: hidden; flex-shrink: 0;
}
.sconce-header .logo-circle img { width: 26px; height: 26px; display: block; }
.sconce-header .student-name {
  font-size: 16px; font-weight: 500; color: var(--fg); flex: 1;
}
.sconce-header .coach-chip {
  font-size: 13px; color: var(--muted); white-space: nowrap;
  max-width: 55%; overflow: hidden; text-overflow: ellipsis;
}
/* TODO: hidden until settings menu is wired — taps were a no-op, which is worse than no button. Restore display when handler exists. */
.sconce-header .settings-btn {
  display: none;
  background: transparent; border: none; color: var(--muted); cursor: pointer;
  font-size: 20px; line-height: 1; padding: 6px 10px;
  min-width: 44px; min-height: 44px;
}

/* Week strip */
.week-strip {
  display: grid; grid-template-columns: repeat(7, 1fr);
  gap: 2px; padding: 4px 12px 10px;
}
.week-day {
  display: flex; flex-direction: column; align-items: center;
  padding: 6px 4px 8px;
  border-radius: var(--r-sm);
  background: transparent; border: none; cursor: pointer;
  color: var(--fg); font-family: inherit;
  min-height: 56px;
}
.week-day.selected { background: var(--bg-sunk); }
.week-day.today .wd-num, .week-day.today .wd-label { color: var(--accent); }
.week-day .wd-label {
  font-size: 10px; font-weight: 600; letter-spacing: 0.05em;
  text-transform: uppercase; color: var(--muted);
}
.week-day .wd-num {
  font-size: 16px; font-weight: 600; font-variant-numeric: tabular-nums;
  margin-top: 2px;
}
.week-day .wd-dot {
  width: 5px; height: 5px; border-radius: 50%; margin-top: 4px;
  background: transparent;
}
.week-day .wd-dot.has-unresolved { background: var(--copper); }
.week-day .wd-dot.has-overdue { background: var(--red-dot); }

/* API failure banner */
.api-failure-banner {
  display: none;
  background: var(--red-bg); color: var(--fg);
  padding: 10px 14px; border-radius: var(--r-md);
  margin: 0 14px 12px; font-size: 13.5px; line-height: 1.4;
  border: 1px solid var(--red-dot);
}
.api-failure-banner.visible { display: block; }
.api-failure-banner strong { color: var(--red-deep); }

/* Day hero */
.day-hero {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 18px 6px; gap: 12px;
}
.day-hero h1 {
  font-family: var(--font-serif); font-size: 24px; font-weight: 700;
  color: var(--primary); letter-spacing: -0.2px;
}
.needs-plan-pill {
  background: var(--copper-soft); color: var(--copper-deep);
  font-size: 11.5px; font-weight: 600;
  padding: 3px 8px; border-radius: 99px;
  white-space: nowrap;
}

/* Schedule card */
.schedule-card {
  background: var(--card-bg); border: 1px solid var(--border);
  border-radius: var(--r-lg); box-shadow: var(--shadow-card);
  margin: 10px 14px 0; padding: 12px 14px;
}
.schedule-empty {
  text-align: center; padding: 22px 0 18px;
  color: var(--muted); font-size: 14px;
}
.schedule-row {
  display: flex; align-items: baseline; gap: 10px;
  padding: 8px 0; border-bottom: 1px solid var(--border-soft);
  font-size: 14px;
}
.schedule-row:last-child { border-bottom: none; }
.schedule-row .time {
  flex-shrink: 0; width: 64px;
  font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums;
}
.schedule-row .label { flex: 1; color: var(--fg); }
.schedule-row .location { color: var(--muted); margin-left: 4px; font-size: 12.5px; }
.schedule-row.school .label { color: var(--muted); }

/* Transit rows */
.transit-row {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 10px 12px; margin: 6px 0;
  border-radius: var(--r-sm);
  font-size: 14px;
  background: transparent;
  border-left: 3px solid transparent;
}
.transit-row.unresolved {
  background: var(--copper-soft);
  border-left-color: var(--copper);
}
.transit-row.unknown-location {
  background: var(--copper-soft);
  border-left-color: var(--copper-deep);
}
.transit-row.kid-asked {
  background: var(--copper-soft);
  border-left-color: var(--copper);
}
.transit-row .tr-eyebrow {
  font-size: 10.5px; font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.5px; color: var(--copper-deep);
  display: inline-flex; align-items: center; gap: 5px; margin-bottom: 4px;
}
.transit-row .tr-eyebrow::before {
  content: ""; width: 6px; height: 6px; border-radius: 99px;
  background: var(--copper);
  animation: sconce-breathe 2.4s ease-in-out infinite;
}
.transit-row .tr-dest-unknown {
  border-bottom: 1px dashed var(--copper); padding-bottom: 1px;
  color: var(--copper-deep); font-weight: 600;
}
.transit-row .tr-time {
  flex-shrink: 0; width: 54px;
  font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums;
  padding-top: 1px;
}
.transit-row .tr-body { flex: 1; min-width: 0; }
.transit-row .tr-route {
  color: var(--fg); font-weight: 500;
  overflow: hidden; text-overflow: ellipsis;
}
.transit-row .tr-meta {
  display: flex; align-items: center; gap: 6px; flex-wrap: wrap;
  font-size: 12px; color: var(--muted); margin-top: 2px;
}
.transit-row .tr-tag {
  display: inline-block;
  font-size: 11px; font-weight: 600;
  padding: 2px 7px; border-radius: 99px;
}
.transit-row.unresolved .tr-tag {
  background: var(--copper); color: #fff;
}
.transit-row.unknown-location .tr-tag {
  background: var(--copper-deep); color: #fff;
  display: inline-flex; align-items: center; gap: 4px;
}
.transit-row.kid-asked .tr-tag {
  background: var(--copper-deep); color: #fff;
}
.transit-row.resolved .tr-tag {
  background: var(--accent-soft); color: var(--accent);
}

/* Deadline rows */
.deadline-row {
  display: flex; align-items: baseline; gap: 10px;
  padding: 8px 0; border-bottom: 1px solid var(--border-soft);
  font-size: 14px;
}
.deadline-row:last-child { border-bottom: none; }
.deadline-row .dl-tag {
  flex-shrink: 0; width: 64px; text-align: left;
  font-size: 11px; font-weight: 600; text-transform: uppercase;
  color: var(--muted); letter-spacing: 0.04em;
}
.deadline-row.overdue .dl-tag { color: var(--red-deep); }
.deadline-row.upcoming .dl-tag { color: var(--yellow-deep); }
.deadline-row .dl-label { flex: 1; color: var(--fg); }

/* At-a-glance pillar section */
.section-label {
  font-size: 11.5px; font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.5px;
  color: var(--muted);
  padding: 20px 18px 6px;
}
.pillar-stack { padding: 0 14px; display: flex; flex-direction: column; gap: 8px; }
.pillar-card {
  background: var(--card-bg); border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: 12px 14px;
  position: relative;
  overflow: hidden;
}
.pillar-card::before {
  content: ""; position: absolute; top: 0; bottom: 0; left: 0;
  width: 3px; background: var(--border);
}
.pillar-card.level-green::before { background: var(--green-dot); }
.pillar-card.level-yellow::before { background: var(--yellow-dot); }
.pillar-card.level-red::before { background: var(--red-dot); }

.pillar-card .pc-label {
  font-size: 11px; font-weight: 600; text-transform: uppercase;
  letter-spacing: 0.04em; color: var(--muted);
  margin-bottom: 3px;
}
.pillar-card .pc-summary {
  font-size: 14.5px; color: var(--fg); line-height: 1.4;
}
.pillar-card .pc-extra {
  font-size: 13px; color: var(--muted); margin-top: 6px;
}
.pillar-card .pc-actions {
  list-style: none; margin-top: 8px; padding: 0;
}
.pillar-card .pc-actions li {
  padding: 4px 0; font-size: 13px; color: var(--fg);
  border-top: 1px solid var(--border-soft);
}
.pillar-card .pc-actions li:first-child { border-top: none; }

/* Academics expand */
.expand-toggle {
  display: inline-flex; align-items: center; gap: 6px; margin-top: 8px;
  font-size: 12.5px; color: var(--accent); cursor: pointer;
  border: none; background: none; padding: 6px 0; font-family: inherit;
  min-height: 44px;
}
.expand-toggle:hover { text-decoration: underline; }
.expand-toggle .ex-chevron {
  display: inline-block; transition: transform 0.15s ease;
}
.expand-toggle.open .ex-chevron { transform: rotate(90deg); }
.expand-content { display: none; margin-top: 8px; }
.expand-content.open { display: block; }
.show-older-label {
  display: none; margin-top: 6px; font-size: 12px; color: var(--muted); cursor: pointer;
}
.show-older-label input { margin-right: 4px; }
.class-group { margin-bottom: 12px; padding-top: 6px; border-top: 1px solid var(--border-soft); }
.class-group:first-child { padding-top: 0; border-top: none; }
.class-group:last-child { margin-bottom: 0; }
.class-group h3 { font-size: 13px; font-weight: 600; margin-bottom: 4px; color: var(--primary); }
.assignment-row { padding: 4px 0; border-bottom: 1px solid var(--border-soft); }
.assignment-row:last-child { border-bottom: none; }
.assignment-row .title { font-size: 13px; line-height: 1.3; overflow-wrap: anywhere; }
.assignment-row .meta {
  display: flex; align-items: center; gap: 5px;
  font-size: 11.5px; color: var(--muted); margin-top: 2px;
}
.assignment-row .dot { width: 7px; height: 7px; border-radius: 50%; flex: 0 0 auto; }
.assignment-row .dot.done { background: var(--green-dot); }
.assignment-row .dot.overdue { background: var(--red-dot); }
.assignment-row .dot.not-done { background: var(--muted); opacity: 0.4; }
.assignment-row .dot.no-date { background: transparent; }
.assignment-row .meta.overdue { color: var(--red-deep); font-weight: 500; }
.assignment-row .meta.no-date { font-style: italic; }

/* Notes */
.notes-section { padding: 24px 18px 0; }
.notes-section h2 {
  font-size: 11.5px; font-weight: 600; text-transform: uppercase;
  letter-spacing: 0.5px; color: var(--muted); margin-bottom: 8px;
}
.note-row {
  display: flex; align-items: center; gap: 4px;
  padding: 6px 0; border-bottom: 1px solid var(--border-soft);
  font-size: 14px;
}
.note-row:last-child { border-bottom: none; }
.note-text { flex: 1; color: var(--fg); }
.note-recurrence { font-size: 11.5px; color: var(--muted); margin-left: 4px; }
.note-btn {
  border: none; background: none; cursor: pointer; font-size: 15px;
  padding: 10px; border-radius: var(--r-xs);
  min-width: 44px; min-height: 44px;
  display: inline-flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.note-btn.done { color: var(--green-deep); }
.note-btn.done:hover { background: var(--green-bg); }
.note-btn.del { color: var(--red-deep); }
.note-btn.del:hover { background: var(--red-bg); }
.note-add-form {
  display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px;
}
.note-add-form input[type="text"] {
  flex: 1; min-width: 150px; font-size: 16px; padding: 10px 12px;
  border: 1px solid var(--border); border-radius: var(--r-sm);
  background: var(--card-bg); color: var(--fg); font-family: inherit;
  min-height: 44px;
}
.note-add-form select {
  font-size: 16px; padding: 8px 10px; border: 1px solid var(--border);
  border-radius: var(--r-sm); background: var(--card-bg); color: var(--fg); font-family: inherit;
  min-height: 44px;
}
.note-add-form button {
  font-size: 14px; padding: 8px 16px; border: none; border-radius: var(--r-sm);
  background: var(--primary); color: #fff; cursor: pointer; font-family: inherit;
  font-weight: 500; min-height: 44px;
}
.note-add-form button:disabled { opacity: 0.5; cursor: default; }
.note-error {
  display: none;
  color: var(--red-deep); font-size: 13px; line-height: 1.35;
  margin-top: 6px; padding: 6px 10px;
  background: var(--red-bg); border-radius: var(--r-xs);
}
.note-error.visible { display: block; }

/* Devices */
.devices-section { padding: 24px 18px 0; }
.devices-section h2 {
  font-size: 11.5px; font-weight: 600; text-transform: uppercase;
  letter-spacing: 0.5px; color: var(--muted); margin-bottom: 8px;
}
.devices-explain { font-size: 13px; color: var(--muted); margin-bottom: 10px; line-height: 1.4; }
.device-row {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 0; border-bottom: 1px solid var(--border-soft);
  font-size: 14px;
}
.device-row:last-child { border-bottom: none; }
.device-info { flex: 1; min-width: 0; }
.device-label-line { color: var(--fg); font-weight: 500; }
.device-meta-line { font-size: 12px; color: var(--muted); margin-top: 2px; }
.device-role-tag {
  display: inline-block; font-size: 10.5px; padding: 1px 6px;
  border-radius: var(--r-xs); background: var(--border-soft); color: var(--muted);
  margin-left: 6px; vertical-align: middle; text-transform: uppercase; letter-spacing: 0.4px;
}
.device-revoke-btn {
  border: 1px solid var(--border); background: var(--card-bg);
  color: var(--red-deep); cursor: pointer; font-family: inherit;
  font-size: 13px; padding: 8px 12px; border-radius: var(--r-sm);
  min-height: 44px; flex-shrink: 0;
}
.device-revoke-btn:hover { background: var(--red-bg); }
.devices-revoke-all {
  margin-top: 12px;
  width: 100%; padding: 10px; border: 1px solid var(--border);
  background: var(--card-bg); color: var(--red-deep);
  font-family: inherit; font-size: 14px; font-weight: 500;
  border-radius: var(--r-sm); cursor: pointer; min-height: 44px;
}
.devices-revoke-all:hover { background: var(--red-bg); }
.devices-empty { font-size: 13px; color: var(--muted); padding: 6px 0; font-style: italic; }

/* Footer */
.footer {
  margin: 22px 18px 0; text-align: center;
  font-size: 12px; color: var(--muted);
}
.ai-footer {
  margin: 8px 18px 0; text-align: center;
  font-size: 11.5px; color: var(--muted);
  line-height: 1.4;
}

/* Section-level error fallback */
.section-error {
  color: var(--red-deep); font-size: 13px; padding: 8px 0;
}

/* ── Transit row tap affordance ── */
.transit-row {
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  min-height: 44px;
}
.transit-row:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
.transit-row .tr-assignment {
  font-size: 12.5px; color: var(--muted); margin-top: 2px;
}

/* ── Transit sheet (bottom sheet) ── */
#transit-sheet-root {
  position: fixed; inset: 0; z-index: 50;
  display: none;
}
#transit-sheet-root.open { display: block; }
.ts-backdrop {
  position: absolute; inset: 0;
  background: rgba(30, 50, 82, 0.4);
  -webkit-backdrop-filter: blur(2px);
  backdrop-filter: blur(2px);
}
.ts-sheet {
  position: absolute; left: 0; right: 0; bottom: 0;
  background: var(--bg);
  border-top-left-radius: 20px; border-top-right-radius: 20px;
  padding: 10px 18px calc(28px + env(safe-area-inset-bottom));
  box-shadow: var(--shadow-sheet);
  max-height: 85%; overflow-y: auto;
  transform: translateY(100%);
  transition: transform 220ms ease-out;
}
#transit-sheet-root.open .ts-sheet { transform: translateY(0); }
.ts-handle {
  width: 38px; height: 4px; background: var(--border);
  border-radius: 99px; margin: 0 auto 14px;
}
.ts-asked-eyebrow {
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--copper-deep); color: #fff;
  font-size: 10.5px; font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.5px; padding: 4px 10px;
  border-radius: 99px; margin-bottom: 10px;
}
.ts-asked-eyebrow::before {
  content: ""; width: 6px; height: 6px; border-radius: 99px;
  background: #fff;
  animation: sconce-breathe 2.4s ease-in-out infinite;
}
.ts-kicker {
  font-size: 11.5px; font-weight: 600; text-transform: uppercase;
  letter-spacing: 0.5px; color: var(--copper-deep); margin-bottom: 6px;
}
.ts-route {
  font-family: var(--font-serif); font-size: 20px; font-weight: 700;
  color: var(--primary); line-height: 1.25;
}
.ts-meta {
  font-size: 13.5px; color: var(--muted); margin-top: 4px;
}
.ts-modes {
  display: grid; grid-template-columns: 1fr 1fr; gap: 8px;
  margin: 16px 0 10px;
}
.ts-mode {
  display: flex; align-items: center; gap: 10px;
  min-height: 56px; padding: 10px 12px;
  background: var(--card-bg); color: var(--fg);
  border: 1.5px solid var(--border);
  border-radius: var(--r-md);
  font-family: inherit; font-size: 14.5px; font-weight: 500;
  text-align: left; cursor: pointer;
}
.ts-mode.active {
  background: var(--primary); color: #fff;
  border-color: var(--primary);
}
.ts-mode .ts-mode-dot {
  width: 10px; height: 10px; border-radius: 50%;
  background: var(--accent); flex-shrink: 0;
}
.ts-mode.active .ts-mode-dot { background: #fff; }
.ts-disclosure {
  display: flex; align-items: center; gap: 6px;
  padding: 10px 0; background: none; border: none;
  color: var(--accent); font-size: 14px; font-weight: 500;
  cursor: pointer; font-family: inherit;
  min-height: 44px;
}
.ts-details {
  display: none; flex-direction: column; gap: 12px;
  margin: 8px 0 14px;
}
.ts-details.open { display: flex; }
.ts-details label {
  display: block; font-size: 12px; font-weight: 600;
  color: var(--muted); text-transform: uppercase;
  letter-spacing: 0.4px; margin-bottom: 6px;
}
.ts-details input[type="text"] {
  width: 100%; padding: 10px 12px; font-size: 16px;
  border: 1px solid var(--border); border-radius: var(--r-sm);
  background: var(--card-bg); color: var(--fg);
  font-family: inherit;
  min-height: 44px;
}
.ts-save {
  width: 100%; min-height: 48px;
  background: var(--primary); color: #fff;
  border: none; border-radius: var(--r-md);
  font-family: inherit; font-size: 15px; font-weight: 600;
  cursor: pointer; margin-top: 4px;
}
.ts-save:disabled { background: var(--border); cursor: default; }
.ts-clear {
  width: 100%; min-height: 44px; background: transparent;
  color: var(--red-deep); border: none; margin-top: 6px;
  font-family: inherit; font-size: 13.5px; cursor: pointer;
}
.ts-error {
  display: none;
  color: var(--red-deep); font-size: 13px; line-height: 1.35;
  margin-top: 8px; padding: 6px 10px;
  background: var(--red-bg, #fce8e6); border-radius: var(--r-xs);
}
.ts-error.visible { display: block; }

/* ── Toast ── */
#toast {
  position: fixed;
  left: 50%; transform: translateX(-50%) translateY(120%);
  bottom: calc(24px + env(safe-area-inset-bottom));
  background: var(--primary); color: #fff;
  padding: 10px 18px; border-radius: 99px;
  font-size: 14px; font-weight: 500;
  box-shadow: var(--shadow-card);
  opacity: 0; pointer-events: none;
  transition: transform 220ms ease-out, opacity 220ms ease-out;
  z-index: 60;
}
#toast.visible {
  opacity: 1; transform: translateX(-50%) translateY(0);
}

/* ── Extracted inline style="" attributes ──
   CSP is style-src 'self': inline style attributes are blocked, so the
   declarations that used to live on elements (and in JS innerHTML
   templates) moved here. Initial-hidden elements use the `hidden`
   attribute; the [hidden] rule needs !important because source order only
   breaks specificity TIES — an ID display rule beats the attribute
   selector regardless of order. !important here mirrors the UA-stylesheet
   pattern (HTML spec §15.3.1). */
.auth-logo { margin-bottom: 0.25rem; }
.auth-note { color: var(--muted); }
.cal-mini-item { font-size: 12px; color: var(--muted); padding: 2px 0; }
.cal-mini-label { font-weight: 500; font-size: 13px; margin-bottom: 2px; color: var(--fg); }
.cal-error-pad { padding: 14px 0; }
.notes-empty { color: var(--muted); font-size: 13px; padding: 4px 0; }
[hidden] { display: none !important; }
