/* Plan45 — Material Design 3 skin (m3.material.io baseline scheme).
   Implemented as plain CSS tokens: no framework, no build step, works offline.
   Light + dark follow the M3 baseline palettes; components follow M3 specs
   (nav bar with active pill, FAB, filled/tonal buttons, chips, 28px dialogs). */

:root {
  /* M3 baseline — light */
  --primary: #6750a4;
  --on-primary: #ffffff;
  --primary-container: #eaddff;
  --on-primary-container: #21005d;
  --secondary-container: #e8def8;
  --on-secondary-container: #1d192b;
  --surface: #fef7ff;
  --surface-container-lowest: #ffffff;
  --surface-container-low: #f7f2fa;
  --surface-container: #f3edf7;
  --surface-container-high: #ece6f0;
  --on-surface: #1d1b20;
  --on-surface-variant: #49454f;
  --outline: #79747e;
  --outline-variant: #cac4d0;
  /* provenance (custom semantic tones, M3-tonal style) */
  --school-container: #d3e8d0;  --on-school: #0f5223;
  --student-container: #f5e1b9; --on-student: #6b4f00;
  --ib-container: #eaddff;      --on-ib: #4f378b;
  --none-container: #e6e0e9;    --on-none: #49454f;
  --elev-1: 0 1px 2px rgba(0,0,0,.3), 0 1px 3px 1px rgba(0,0,0,.15);
  --elev-3: 0 4px 8px 3px rgba(0,0,0,.15), 0 1px 3px rgba(0,0,0,.3);
}

@media (prefers-color-scheme: dark) {
  :root {
    --primary: #d0bcff;
    --on-primary: #381e72;
    --primary-container: #4f378b;
    --on-primary-container: #eaddff;
    --secondary-container: #4a4458;
    --on-secondary-container: #e8def8;
    --surface: #141218;
    --surface-container-lowest: #0f0d13;
    --surface-container-low: #1d1b20;
    --surface-container: #211f26;
    --surface-container-high: #2b2930;
    --on-surface: #e6e0e9;
    --on-surface-variant: #cac4d0;
    --outline: #938f99;
    --outline-variant: #49454f;
    --school-container: #1e4620;  --on-school: #a5d6a7;
    --student-container: #4e3d00; --on-student: #e8c66a;
    --ib-container: #4f378b;      --on-ib: #eaddff;
    --none-container: #36343b;    --on-none: #cac4d0;
  }
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body {
  margin: 0; padding: 0;
  background: var(--surface); color: var(--on-surface);
  font: 400 16px/1.5 Roboto, "Google Sans Text", -apple-system, "Segoe UI", sans-serif;
}
#app { max-width: 600px; margin: 0 auto; padding: 0 16px 120px; }

/* ---------- top app bar ---------- */
header.brand {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 2px 8px;
}
.wordmark {
  font-size: 1.375rem; font-weight: 500; letter-spacing: 0;
  font-family: "Google Sans", Roboto, inherit;
}
.wordmark b { color: var(--primary); font-weight: 700; }
.tagline { font-size: 0.8rem; color: var(--on-surface-variant); }
.icon-btn {
  border: none; background: transparent; color: var(--on-surface-variant);
  width: 48px; height: 48px; border-radius: 50%; display: grid; place-items: center;
  cursor: pointer;
}
.icon-btn:active { background: var(--surface-container-high); }
.icon-btn svg { width: 24px; height: 24px; stroke: currentColor; fill: none;
  stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

/* ---------- M3 type scale ---------- */
h1 { font-size: 1.75rem; font-weight: 400; margin: 0.4em 0; }       /* headline-m */
h2 { font-size: 1.375rem; font-weight: 500; margin: 1em 0 0.5em; }  /* title-l */
h3 {
  font-size: 0.875rem; font-weight: 500; margin: 1.6em 0 0.5em;     /* title-s */
  color: var(--on-surface-variant); letter-spacing: 0.01em;
}
p { margin: 0.5em 0; }
.muted { color: var(--on-surface-variant); }

/* ---------- navigation bar (M3 spec: 80px, pill active indicator) ---------- */
nav {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 10;
  display: flex; justify-content: space-around; align-items: center;
  height: calc(80px + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
  background: var(--surface-container);
}
nav button {
  border: none; background: transparent; color: var(--on-surface-variant);
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  font: 500 0.75rem/1 Roboto, inherit; cursor: pointer; padding: 0; width: 96px;
}
nav button .ind {
  display: grid; place-items: center;
  width: 64px; height: 32px; border-radius: 16px;
  transition: background 0.15s ease;
}
nav button svg { width: 24px; height: 24px; stroke: currentColor; fill: none;
  stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
nav button.on { color: var(--on-surface); }
nav button.on .ind { background: var(--secondary-container); color: var(--on-secondary-container); }

/* ---------- FAB (M3: 56px, 16px radius, primary-container) ---------- */
.fab {
  position: fixed; right: 20px; bottom: calc(96px + env(safe-area-inset-bottom));
  width: 56px; height: 56px; border-radius: 16px; border: none;
  background: var(--primary-container); color: var(--on-primary-container);
  box-shadow: var(--elev-3); display: grid; place-items: center; cursor: pointer;
  z-index: 11; transition: transform 0.1s ease;
}
.fab:active { transform: scale(0.94); }
.fab svg { width: 24px; height: 24px; stroke: currentColor; fill: none;
  stroke-width: 2.2; stroke-linecap: round; }

/* ---------- cards & list items ---------- */
.card {
  background: var(--surface-container-low); border: none;
  border-radius: 12px; padding: 20px; margin: 12px 0;
}
.item {
  display: flex; justify-content: space-between; gap: 12px;
  background: var(--surface-container-low);
  border-radius: 12px; padding: 14px 16px; margin: 8px 0;
  position: relative; overflow: hidden;
}
.item::after { /* M3 state layer on press */
  content: ""; position: absolute; inset: 0; background: currentColor;
  opacity: 0; transition: opacity 0.12s ease; pointer-events: none;
}
.item:active::after { opacity: 0.06; }
.item.undated { background: var(--surface-container); }
.item.question {
  background: var(--surface);
  outline: 1px dashed var(--outline-variant); outline-offset: -1px;
}
.item-main { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.item .title { font-weight: 500; font-size: 1rem; }
.item.question .title { font-weight: 400; font-size: 0.95rem; }
.item .detail { font-size: 0.85rem; color: var(--on-surface-variant); }
.item .meta { font-size: 0.8rem; color: var(--on-surface-variant);
  display: flex; gap: 6px; align-items: center; flex-wrap: wrap; margin-top: 2px; }
.item-actions { display: flex; flex-direction: column; gap: 6px;
  align-items: flex-end; flex-shrink: 0; justify-content: center; }

/* ---------- provenance chips (M3 assist-chip style) ---------- */
.badge {
  display: inline-flex; align-items: center; height: 24px; padding: 0 10px;
  border-radius: 8px; font-size: 0.72rem; font-weight: 500;
}
.badge.school { background: var(--school-container); color: var(--on-school); }
.badge.student { background: var(--student-container); color: var(--on-student); }
.badge.ib { background: var(--ib-container); color: var(--on-ib); }
.badge.none { background: var(--none-container); color: var(--on-none); }

/* ---------- forms (M3 outlined fields) ---------- */
label { display: block; margin: 14px 0 4px; font-weight: 500; font-size: 0.875rem;
  color: var(--on-surface-variant); }
input, select, textarea {
  width: 100%; padding: 14px 14px; margin-top: 4px;
  border: 1px solid var(--outline); border-radius: 4px;
  font: inherit; background: transparent; color: var(--on-surface);
}
input:focus, select:focus, textarea:focus {
  outline: none; border: 2px solid var(--primary); padding: 13px;
}

/* ---------- buttons (M3 filled / text) ---------- */
button { font: 500 0.875rem/1 Roboto, inherit; cursor: pointer;
  letter-spacing: 0.01em; }
button.primary {
  display: block; width: 100%; margin-top: 16px; height: 48px;
  background: var(--primary); color: var(--on-primary); border: none;
  border-radius: 24px; font-size: 0.95rem;
}
button.primary:active { box-shadow: var(--elev-1); opacity: 0.92; }
button.ghost {
  display: block; width: 100%; margin-top: 8px; height: 44px;
  background: transparent; border: none; border-radius: 22px;
  color: var(--primary);
}
button.ghost:active { background: var(--surface-container-high); }
button.small {
  width: auto; display: inline-flex; align-items: center; height: 34px;
  margin: 0; padding: 0 14px; border-radius: 17px;
  border: 1px solid var(--outline); background: transparent;
  color: var(--primary); font-size: 0.8rem;
}
button.small:active { background: var(--surface-container-high); }
button.small.ghost { border: none; color: var(--on-surface-variant); width: auto;
  display: inline-flex; margin: 0; height: 34px; }

/* ---------- empty state ---------- */
.empty {
  text-align: center; padding: 30px 20px; margin: 12px 0;
  border-radius: 12px; background: var(--surface-container-low);
  color: var(--on-surface-variant); font-size: 0.95rem;
}
.empty .forty5 {
  display: block; font-size: 2.2rem; font-weight: 700; color: var(--primary);
  margin-bottom: 6px; font-family: "Google Sans", Roboto, inherit;
}

/* ---------- dialogs (M3: 28px radius, surface-container-high) ---------- */
dialog {
  border: none; border-radius: 28px; padding: 0;
  max-width: 92vw; width: 440px;
  background: var(--surface-container-high); color: var(--on-surface);
}
dialog::backdrop { background: rgba(0, 0, 0, 0.4); }
dialog .card { margin: 0; background: transparent; padding: 24px; }
dialog h3 { margin-top: 0; color: var(--on-surface); font-size: 1.1rem; }

footer { margin-top: 28px; }
.hidden { display: none; }

/* ---------- print: the paper version ---------- */
@media print {
  nav, footer, .fab, .item-actions, button, .icon-btn { display: none !important; }
  body { background: #fff; color: #000; font-size: 12px; }
  #app { max-width: none; padding: 0; }
  .card, .item, .empty { border: 1px solid #ccc; border-radius: 6px;
    background: #fff; break-inside: avoid; }
  .item.question { border-style: dashed; }
  .badge { border: 1px solid #999; background: #fff; color: #000; }
  header.brand::after { content: "plan45.app"; font-size: 0.8rem; color: #666; }
}
