:root {
  --bg: #0b0d12;
  --bg-glow: #12161f;
  --surface: #161a22;
  --surface2: #1f2430;
  --surface3: #2a3140;
  --border: #3a4252;
  --border-soft: rgba(255, 255, 255, 0.06);
  --text: #f4f6fb;
  --muted: #9aa3b5;
  --accent: #6b9bff;
  --accent-2: #8ab0ff;
  --accent-press: #5486e8;
  --accent-glow: rgba(107, 155, 255, 0.28);
  --amber: #e8b04a;
  --amber-bg: rgba(232, 176, 74, 0.16);
  --danger-label: #d4b03a; /* not red; warn via label+shape */
  --ok-label: #8ab0ff; /* blue, not green */
  --radius: 18px;
  --radius-sm: 14px;
  --radius-lg: 22px;
  --shadow-card: 0 8px 24px rgba(0, 0, 0, 0.35), 0 1px 0 var(--border-soft) inset;
  --shadow-soft: 0 4px 14px rgba(0, 0, 0, 0.28);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
  --tab-h: 64px;
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", system-ui, sans-serif;
}

*, *::before, *::after { box-sizing: border-box; }
html, body {
  margin: 0;
  padding: 0;
  background:
    radial-gradient(1200px 600px at 50% -120px, rgba(107, 155, 255, 0.08), transparent 60%),
    linear-gradient(180deg, var(--bg-glow), var(--bg) 40%);
  background-attachment: fixed;
  color: var(--text);
  min-height: 100%;
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
}
body {
  padding-top: var(--safe-t);
  padding-bottom: calc(var(--tab-h) + var(--safe-b));
}
button, input, textarea {
  font: inherit;
  color: inherit;
}
button {
  border: none;
  background: none;
  cursor: pointer;
  touch-action: manipulation;
}
.app-header {
  position: sticky;
  top: 0;
  z-index: 10;
  background: rgba(11, 13, 18, 0.78);
  backdrop-filter: blur(18px) saturate(1.2);
  -webkit-backdrop-filter: blur(18px) saturate(1.2);
  padding: 12px 16px 10px;
  border-bottom: 1px solid var(--border-soft);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.18);
}
.app-header h1 {
  margin: 0;
  font-size: 1.28rem;
  font-weight: 700;
  letter-spacing: -0.025em;
  background: linear-gradient(180deg, #fff, #d7deec);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.app-header .sub {
  margin: 3px 0 0;
  font-size: 0.75rem;
  color: var(--muted);
}
.view { display: none; padding: 14px 16px 28px; }
.view.active { display: block; }

.card {
  background: linear-gradient(165deg, rgba(36, 42, 56, 0.95), var(--surface) 55%);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 15px;
  margin-bottom: 12px;
  box-shadow: var(--shadow-card);
}
.card.expired {
  border-color: rgba(232, 176, 74, 0.55);
  background: linear-gradient(180deg, var(--amber-bg), var(--surface));
  box-shadow: var(--shadow-card), 0 0 0 1px rgba(232, 176, 74, 0.12);
}
.card .meta {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
  flex-wrap: wrap;
}
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--surface2);
  color: var(--muted);
  border: 1px solid var(--border);
}
.badge.running {
  color: var(--accent-2);
  border-color: rgba(107, 155, 255, 0.55);
  background: rgba(107, 155, 255, 0.12);
  box-shadow: 0 0 0 3px rgba(107, 155, 255, 0.08);
}
.badge.expired {
  color: var(--amber);
  border-color: rgba(232, 176, 74, 0.55);
  background: var(--amber-bg);
}
.countdown {
  font-variant-numeric: tabular-nums;
  font-size: 1.7rem;
  font-weight: 700;
  letter-spacing: -0.03em;
}
.countdown.expired { color: var(--amber); }
.note-text {
  white-space: pre-wrap;
  word-break: break-word;
  line-height: 1.45;
  font-size: 1.05rem;
}
.row-actions {
  display: flex;
  gap: 8px;
  margin-top: 12px;
  flex-wrap: wrap;
}
.btn {
  flex: 1;
  min-height: 46px;
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  font-weight: 600;
  border: 1px solid var(--border);
  background: linear-gradient(180deg, var(--surface3), var(--surface2));
  box-shadow: var(--shadow-soft);
}
.btn.primary {
  background: linear-gradient(180deg, var(--accent-2), var(--accent));
  border-color: transparent;
  color: #fff;
  box-shadow: 0 8px 20px var(--accent-glow), 0 1px 0 rgba(255,255,255,0.18) inset;
}
.btn.primary:active { background: var(--accent-press); }
.btn.ghost {
  background: transparent;
  box-shadow: none;
}
.btn.warn {
  border-style: dashed;
  border-color: var(--amber);
  color: var(--amber);
  background: rgba(232, 176, 74, 0.06);
}
.btn.complete {
  border-color: rgba(138, 176, 255, 0.55);
  color: var(--ok-label);
  background: rgba(107, 155, 255, 0.08);
}
.btn.cancel {
  border-color: var(--muted);
  color: var(--muted);
}
.btn.block { width: 100%; flex: none; margin-top: 8px; }
.fab-row { margin: 10px 0 18px; }
.empty {
  text-align: center;
  color: var(--muted);
  padding: 40px 14px;
  font-size: 0.95rem;
  line-height: 1.5;
  background: rgba(255,255,255,0.02);
  border: 1px dashed var(--border);
  border-radius: var(--radius);
}

.tabs {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  height: calc(var(--tab-h) + var(--safe-b));
  padding-bottom: var(--safe-b);
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  background: rgba(18, 22, 31, 0.72);
  border-top: 1px solid var(--border-soft);
  backdrop-filter: blur(22px) saturate(1.35);
  -webkit-backdrop-filter: blur(22px) saturate(1.35);
  box-shadow: 0 -10px 30px rgba(0, 0, 0, 0.35);
  z-index: 20;
}
.tab {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  color: var(--muted);
  font-size: 0.68rem;
  font-weight: 600;
  min-height: var(--tab-h);
  border-radius: 14px;
  margin: 4px 3px;
  transition: background 0.15s ease, color 0.15s ease;
}
.tab .ico { font-size: 1.22rem; line-height: 1; }
.tab.active {
  color: var(--accent-2);
  background: rgba(107, 155, 255, 0.12);
  box-shadow: 0 0 0 1px rgba(107, 155, 255, 0.18) inset;
}
.tab .dot {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--amber);
  display: none;
  box-shadow: 0 0 8px rgba(232, 176, 74, 0.7);
}
.tab.has-expired .dot { display: inline-block; }

.sheet-backdrop {
  position: fixed; inset: 0;
  background: rgba(4, 6, 10, 0.62);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  z-index: 30;
  display: none;
}
.sheet-backdrop.open { display: block; }
.sheet {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  z-index: 31;
  background: linear-gradient(180deg, #1c212c, var(--surface));
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  border: 1px solid var(--border);
  border-bottom: none;
  padding: 18px 16px calc(18px + var(--safe-b));
  transform: translateY(110%);
  transition: transform 0.22s ease;
  max-height: 90vh;
  overflow: auto;
  box-shadow: 0 -16px 40px rgba(0, 0, 0, 0.45);
}
.sheet.open { transform: translateY(0); }
.sheet h2 {
  margin: 0 0 14px;
  font-size: 1.12rem;
  letter-spacing: -0.02em;
}
.field { margin-bottom: 14px; }
.field label {
  display: block;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--muted);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.field input, .field textarea {
  width: 100%;
  background: rgba(11, 13, 18, 0.85);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 13px 14px;
  min-height: 48px;
  outline: none;
  box-shadow: 0 1px 0 var(--border-soft) inset;
}
.field input:focus, .field textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}
.field textarea { min-height: 110px; resize: vertical; }
.hint { font-size: 0.75rem; color: var(--muted); margin-top: 4px; }
.list-item {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  width: 100%;
  text-align: left;
  padding: 14px 10px;
  margin: 0 -4px;
  border-radius: var(--radius-sm);
  border-bottom: 1px solid var(--border-soft);
}
.list-item:last-child { border-bottom: none; }
.list-item:active {
  background: rgba(107, 155, 255, 0.08);
}
.list-item .chev { color: var(--muted); margin-left: auto; padding-top: 2px; }
.student-name { font-weight: 600; font-size: 1.05rem; }
.student-count { color: var(--muted); font-size: 0.8rem; }
.note-card time {
  display: block;
  font-size: 0.7rem;
  color: var(--muted);
  margin-bottom: 6px;
}
.back {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  color: var(--accent-2);
  font-weight: 600;
  margin-bottom: 10px;
  min-height: 44px;
  padding: 0 4px 0 0;
}
.sr-only {
  position: absolute; width: 1px; height: 1px;
  padding: 0; margin: -1px; overflow: hidden;
  clip: rect(0,0,0,0); border: 0;
}

/* v1.2 — note cards (AI brief) + detail sheet */
.note-card-btn {
  display: block;
  width: 100%;
  text-align: left;
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease;
}
.note-card-btn:active {
  border-color: rgba(107, 155, 255, 0.55);
  background: linear-gradient(165deg, rgba(50, 60, 80, 0.95), var(--surface) 55%);
}
.note-brief {
  margin-top: 6px;
  font-size: 1.02rem;
  font-weight: 600;
  line-height: 1.4;
  letter-spacing: -0.01em;
  word-break: break-word;
  white-space: pre-wrap;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  background: rgba(107, 155, 255, 0.1);
  border: 1px solid rgba(107, 155, 255, 0.22);
}
.note-brief.brief-preview {
  background: rgba(255, 193, 99, 0.08);
  border-color: rgba(255, 193, 99, 0.28);
}
.brief-tag {
  display: inline-block;
  margin-right: 8px;
  padding: 1px 7px;
  border-radius: 999px;
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  color: #0b0d12;
  background: var(--amber);
  vertical-align: 2px;
}
.brief-tag-ai {
  background: var(--accent-2);
  color: #0b0d12;
}
.note-open-hint {
  margin-top: 8px;
  font-size: 0.72rem;
  color: var(--muted);
  font-weight: 600;
}
.detail-when {
  margin: -6px 0 12px;
  font-size: 0.75rem;
  color: var(--muted);
}
.detail-brief {
  margin-bottom: 12px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  background: rgba(107, 155, 255, 0.1);
  border: 1px solid rgba(107, 155, 255, 0.22);
  word-break: break-word;
}
.detail-brief[data-source="preview"] {
  background: rgba(255, 193, 99, 0.08);
  border-color: rgba(255, 193, 99, 0.28);
}
.detail-brief-label {
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  color: var(--accent-2);
  margin-bottom: 6px;
}
.detail-brief[data-source="preview"] .detail-brief-label {
  color: var(--amber);
  text-transform: none;
  letter-spacing: 0;
  font-weight: 600;
}
.detail-brief-text {
  font-size: 0.95rem;
  font-weight: 600;
  line-height: 1.4;
  white-space: pre-wrap;
}
.detail-body {
  margin-bottom: 16px;
  padding: 12px;
  background: rgba(11, 13, 18, 0.55);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  max-height: 50vh;
  overflow: auto;
}
.export-preview {
  margin-top: 14px;
  padding: 10px 12px;
  font-size: 0.72rem;
  line-height: 1.35;
  color: var(--muted);
  background: rgba(11, 13, 18, 0.55);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  max-height: 28vh;
  overflow: auto;
  white-space: pre-wrap;
  word-break: break-word;
}
.header-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}
.header-titles { min-width: 0; flex: 1; }
.header-need-briefs,
.header-more {
  font-size: 0.75rem;
  padding: 8px 10px;
  min-height: 40px;
  white-space: nowrap;
}
.header-more {
  font-size: 1.1rem;
  line-height: 1;
  padding: 8px 12px;
  min-width: 40px;
}
.header-overflow {
  position: relative;
  flex-shrink: 0;
}
.header-menu {
  position: absolute;
  right: 0;
  top: calc(100% + 6px);
  min-width: 168px;
  padding: 6px;
  border-radius: 12px;
  background: #161a24;
  border: 1px solid var(--border);
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.45);
  z-index: 40;
}
.header-menu-item {
  display: block;
  width: 100%;
  text-align: left;
  padding: 10px 12px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--text);
  font: inherit;
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
}
.header-menu-item:hover,
.header-menu-item:focus-visible {
  background: rgba(255, 255, 255, 0.06);
  outline: none;
}

.export-sep {
  border: none;
  border-top: 1px solid var(--border);
  margin: 16px 0 12px;
}
.export-sub {
  margin: 0 0 6px;
  font-size: 0.95rem;
  font-weight: 650;
  color: var(--text);
}
.import-paste {
  min-height: 96px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.78rem;
  line-height: 1.35;
}
.export-sub + .hint code,
.hint code {
  font-size: 0.78em;
  color: var(--accent-2);
}


/* —— Personal list title / subhead (sync-v1i) —— */
.note-card-personal .note-list-title {
  margin-top: 4px;
  font-size: 1.05rem;
  font-weight: 700;
  line-height: 1.3;
  letter-spacing: -0.015em;
  color: var(--text);
  word-break: break-word;
}
.note-card-personal .note-list-subhead {
  margin-top: 3px;
  font-size: 0.82rem;
  font-weight: 500;
  line-height: 1.35;
  color: var(--muted);
  word-break: break-word;
}
.detail-list-header {
  margin: 0 0 12px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
}
.detail-list-title {
  font-size: 1.08rem;
  font-weight: 700;
  line-height: 1.3;
  letter-spacing: -0.015em;
}
.detail-list-subhead {
  margin-top: 3px;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--muted);
  line-height: 1.35;
}

/* —— Private Caddie sync —— */
.note-brief.brief-caddie {
  color: var(--text);
}
.brief-tag-caddie {
  background: #2a3a55;
  color: #c9daf8;
  border: 1px solid #4a6a9a;
}
.detail-brief[data-source="caddie"] {
  border-color: #4a6a9a;
  background: rgba(42, 58, 85, 0.35);
}
.detail-brief[data-source="caddie"] .detail-brief-label {
  color: #c9daf8;
}
.sync-panel {
  margin: 14px 0 8px;
  padding: 12px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.08);
}
.sync-status {
  margin: 0 0 8px;
  font-size: 0.85rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: var(--muted, #9aa3b5);
}
.sync-status[data-kind="sent"] {
  color: #f0c674; /* amber — not red/green only */
}
.sync-status[data-kind="ready"] {
  color: #8ec7ff; /* blue — colorblind-safe vs amber */
}
.sync-hint {
  margin: 8px 0 0;
  font-size: 0.75rem;
}
.sync-chip {
  display: inline-block;
  margin-top: 6px;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.02em;
}
.sync-chip.sent {
  background: rgba(240, 198, 116, 0.15);
  color: #f0c674;
  border: 1px solid rgba(240, 198, 116, 0.35);
}
.sync-chip.ready {
  background: transparent;
  border: none;
  color: #7eb0ff;
  font-size: 0.85rem;
  font-weight: 700;
  padding: 0 2px;
  min-width: 0;
  letter-spacing: 0;
}

.header-actions { display: flex; gap: 6px; align-items: center; flex-shrink: 0; }
.header-refresh { font-size: 0.75rem; padding: 8px 10px; min-height: 40px; white-space: nowrap; }


/* (removed Students landing bulk Send chrome — Send need-briefs lives in global header) */
.sheet-back {
  margin: -4px 0 8px;
}

/* Header primary actions — press / Sending / ✓ success (Send need-briefs + Refresh briefs) */
.header-need-briefs,
.header-refresh.header-action-feedback {
  transition: background 0.12s ease, border-color 0.12s ease, color 0.12s ease, transform 0.08s ease;
  border: 1px solid var(--border);
  background: var(--surface2);
  color: var(--text);
  font-weight: 700;
}
.header-need-briefs:not(:disabled):active,
.header-need-briefs.is-pressed,
.header-refresh.header-action-feedback:not(:disabled):active,
.header-refresh.header-action-feedback.is-pressed {
  transform: scale(0.96);
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
.header-need-briefs.is-busy,
.header-refresh.header-action-feedback.is-busy {
  background: rgba(91, 141, 239, 0.28);
  border-color: var(--accent);
  color: var(--accent);
}
.header-need-briefs.is-success,
.header-refresh.header-action-feedback.is-success {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  box-shadow: 0 0 0 3px rgba(91, 141, 239, 0.35);
}
.header-need-briefs:disabled:not(.is-busy):not(.is-success) {
  opacity: 0.45;
}

/* Personal header folders */
.header-folder .student-name { font-weight: 650; }
.header-unfiled .student-name { color: var(--muted); font-weight: 600; }
.header-unfiled .student-count { opacity: 0.9; }

/* Note detail actions — compact 2-col grid (all sections) */
.detail-sync-hint { margin: 6px 0 4px; font-size: 0.7rem; line-height: 1.3; }
.detail-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  margin-top: 6px;
  padding-top: 6px;
  border-top: 1px solid var(--border-soft);
}
.detail-actions .btn.detail-action {
  width: 100%;
  margin: 0;
  min-height: 34px;
  padding: 6px 8px;
  font-size: 0.8rem;
  font-weight: 600;
  line-height: 1.2;
  border-radius: var(--radius-sm);
}
.detail-actions .detail-action-done {
  min-height: 34px;
  font-size: 0.82rem;
}

/* Director-training chrome stripped — keep header-sub slot but invisible */
.app-header .sub[hidden],
#header-sub:empty { display: none !important; }
.note-open-hint { display: none; }

