/* =========================================================
   RESET + BASE
========================================================= */
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; }
body {
  font-family: var(--font-body);
  font-size: 14.5px;
  line-height: 1.5;
  color: var(--c-text);
  background: var(--c-bg);
  min-height: 100vh;
  min-height: 100dvh;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  letter-spacing: -0.005em;
}
h1, h2, h3, h4 {
  font-family: var(--font-display);
  margin: 0;
  letter-spacing: -0.025em;
  color: var(--c-text);
  font-weight: 600;
  line-height: 1.25;
}
p { margin: 0; }
ul { list-style: none; margin: 0; padding: 0; }
button, input, select, textarea { font: inherit; color: inherit; }
button {
  border: 0;
  background: none;
  cursor: pointer;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
  /* Prevent 300 ms tap delay + accidental double-tap zoom on mobile. */
  touch-action: manipulation;
  user-select: none;
}
input[type="checkbox"] { touch-action: manipulation; }
:focus-visible {
  outline: 2px solid var(--c-primary);
  outline-offset: 2px;
  border-radius: 4px;
}

/* =========================================================
   BUTTONS
========================================================= */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 7px 13px;
  min-height: 34px;
  border-radius: var(--r-md);
  font-family: var(--font-body);
  font-weight: 500;
  font-size: 13px;
  letter-spacing: -0.005em;
  white-space: nowrap;
  border: 1px solid var(--c-border-strong);
  background: var(--c-bg-elev);
  color: var(--c-text);
  transition: background var(--dur-fast), border-color var(--dur-fast), transform var(--dur-fast);
}
.btn:hover:not([disabled]) { background: var(--c-bg-soft); border-color: var(--c-text-muted); }
.btn:active:not([disabled]) { transform: translateY(0.5px); }
.btn[disabled] { opacity: 0.4; cursor: not-allowed; }
.btn-primary {
  background: var(--c-text);
  color: var(--c-bg-elev);
  border-color: var(--c-text);
}
.btn-primary:hover:not([disabled]) { background: #2A2832; border-color: #2A2832; }
.btn-accent {
  background: var(--c-primary);
  color: white;
  border-color: var(--c-primary);
}
.btn-accent:hover:not([disabled]) { background: var(--c-primary-dark); border-color: var(--c-primary-dark); }
.btn-ghost {
  background: transparent;
  border-color: transparent;
  color: var(--c-text-muted);
}
.btn-ghost:hover:not([disabled]) { background: var(--c-bg-soft); color: var(--c-text); border-color: var(--c-border); }
.btn-sm { padding: 4px 10px; min-height: 28px; font-size: 12px; }
.btn svg { width: 14px; height: 14px; flex-shrink: 0; }

/* =========================================================
   APP SHELL
========================================================= */
.app {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  min-height: 100dvh;
}

/* ---------- Toolbar ---------- */
.toolbar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px clamp(12px, 3vw, 22px);
  background: var(--c-bg-elev);
  border-bottom: 1px solid var(--c-border);
  padding-top: max(12px, env(safe-area-inset-top));
  flex-shrink: 0;
}
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  flex: 1;
}
.brand__icon {
  flex-shrink: 0;
  display: inline-grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: var(--r-md);
  background: var(--c-bg);
  border: 1px solid var(--c-border);
  color: var(--c-primary);
}
.brand__icon svg { width: 18px; height: 18px; }
.brand__text { min-width: 0; }
.brand__text h1 {
  font-size: clamp(14px, 2.6vw, 16px);
  font-weight: 600;
  line-height: 1.2;
  letter-spacing: -0.02em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.brand__text p {
  font-size: clamp(11px, 2vw, 12px);
  color: var(--c-text-soft);
  margin-top: 1px;
  font-weight: 400;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
@media (max-width: 520px) { .brand__text p { display: none; } }

.toolbar__actions { display: flex; gap: 6px; flex-wrap: wrap; }
.toolbar__student-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px 6px 8px;
  min-height: 34px;
  border-radius: var(--r-md);
  background: var(--c-bg);
  border: 1px solid var(--c-border-strong);
  color: var(--c-text);
  font-weight: 500;
  font-size: 13px;
  letter-spacing: -0.005em;
  transition: background var(--dur-fast), border-color var(--dur-fast);
}
.toolbar__student-btn:hover { background: var(--c-bg-elev); border-color: var(--c-text-muted); }
.toolbar__student-btn__avatar {
  display: inline-grid;
  place-items: center;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--c-primary-soft);
  color: var(--c-primary);
}
.toolbar__student-btn__avatar svg { width: 12px; height: 12px; }
.toolbar__student-btn__ratio {
  font-variant-numeric: tabular-nums;
  color: var(--c-text-muted);
}
@media (max-width: 520px) {
  .toolbar__student-btn span.label { display: none; }
}

/* ---------- Banner ---------- */
.banner {
  margin: 0;
  padding: 12px clamp(12px, 3vw, 22px);
  background: var(--c-primary-soft);
  border-bottom: 1px solid #D9D6EF;
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}
.banner[hidden] { display: none !important; }
.banner__text {
  flex: 1;
  min-width: 220px;
  font-size: 13.5px;
  color: var(--c-primary-dark);
  line-height: 1.5;
}
.banner__text strong { font-weight: 600; }

/* =========================================================
   MAIN LAYOUT — sidebar + graph
========================================================= */
.main {
  flex: 1;
  display: grid;
  grid-template-columns: 300px minmax(0, 1fr);
  min-height: 0;
}

.sidebar {
  background: var(--c-bg-elev);
  border-right: 1px solid var(--c-border);
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
}
.sidebar__head {
  padding: 14px 16px 10px;
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}
.sidebar__head h2 {
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--c-text-muted);
  font-weight: 600;
  flex: 1;
}
.sidebar__count {
  font-size: 11px;
  font-weight: 500;
  color: var(--c-text-soft);
  background: var(--c-bg-soft);
  padding: 2px 8px;
  border-radius: var(--r-pill);
  font-variant-numeric: tabular-nums;
}
.sidebar__add {
  display: flex;
  gap: 6px;
  padding: 0 12px 10px;
  flex-shrink: 0;
}
.sidebar__add input {
  flex: 1;
  min-width: 0;
  padding: 8px 12px;
  border: 1px solid var(--c-border);
  border-radius: var(--r-sm);
  background: var(--c-bg);
  color: var(--c-text);
  font-size: 13px;
}
.sidebar__add input::placeholder { color: var(--c-text-soft); }
.sidebar__add input:focus {
  outline: none;
  border-color: var(--c-primary);
  box-shadow: 0 0 0 3px rgba(60, 55, 179, 0.14);
}
.sidebar__list {
  flex: 1;
  overflow-y: auto;
  padding: 4px 8px 12px;
}

/* ---------- Item row ---------- */
.item {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 6px 6px 4px;
  border-radius: var(--r-sm);
  position: relative;
  transition: background var(--dur-fast);
}
.item + .item { margin-top: 2px; }
.item:hover { background: var(--c-bg-soft); }
.item__chip {
  width: 22px;
  height: 22px;
  border: 0;
  border-radius: 50%;
  flex-shrink: 0;
  background: var(--c-locked);
  cursor: pointer;
  position: relative;
  transition: background var(--dur-fast), transform var(--dur-fast);
}
.item__chip::after {
  content: '';
  position: absolute;
  inset: -4px;
  border-radius: 50%;
  border: 2px solid transparent;
  transition: border-color var(--dur-fast);
}
.item__chip:hover::after { border-color: var(--c-border-strong); }
.item[data-state="known"] .item__chip { background: var(--c-known); }
.item[data-state="fringe"] .item__chip { background: var(--c-fringe); }
.item[data-state="review"] .item__chip { background: var(--c-known); }
.item[data-state="review"] .item__chip::after { border-color: var(--c-review); }
.item__label {
  flex: 1;
  min-width: 0;
  padding: 5px 6px;
  border: 1px solid transparent;
  border-radius: var(--r-xs);
  background: transparent;
  font-size: 13.5px;
  color: var(--c-text);
  font-weight: 400;
}
.item[data-state="known"] .item__label,
.item[data-state="review"] .item__label { font-weight: 500; }
.item__label:hover {
  background: var(--c-bg-elev);
  border-color: var(--c-border);
}
.item__label:focus {
  outline: none;
  background: var(--c-bg-elev);
  border-color: var(--c-primary);
  box-shadow: 0 0 0 3px rgba(60, 55, 179, 0.14);
}
.item__prereq {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 3px 8px;
  font-size: 11px;
  font-weight: 500;
  border-radius: var(--r-sm);
  background: transparent;
  border: 1px solid transparent;
  color: var(--c-text-soft);
  letter-spacing: -0.005em;
  flex-shrink: 0;
  transition: background var(--dur-fast), border-color var(--dur-fast), color var(--dur-fast);
}
.item:hover .item__prereq,
.item__prereq--has {
  background: var(--c-bg-elev);
  border-color: var(--c-border);
  color: var(--c-text-muted);
}
.item__prereq--has {
  background: var(--c-primary-soft);
  border-color: #D3CFEF;
  color: var(--c-primary);
}
.item__prereq:hover:not(.item__prereq--has) { border-color: var(--c-text-muted); color: var(--c-text); }
.item__del {
  display: none;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: var(--r-xs);
  color: var(--c-text-soft);
  flex-shrink: 0;
  background: transparent;
  transition: background var(--dur-fast), color var(--dur-fast);
}
.item:hover .item__del,
.item:focus-within .item__del { display: inline-grid; }
.item__del:hover { background: var(--c-danger-soft); color: var(--c-danger); }
.item__del svg { width: 13px; height: 13px; }
/* Touch devices have no hover — always expose the delete button. */
@media (hover: none) {
  .item__del { display: inline-grid; }
  .item__chip { width: 26px; height: 26px; }
  .item__chip::after { inset: -8px; }
}

/* ---------- Sidebar empty state ---------- */
.sidebar__empty {
  padding: 24px 18px;
  text-align: center;
  color: var(--c-text-soft);
  font-size: 13px;
  line-height: 1.55;
}
.sidebar__empty strong {
  display: block;
  font-weight: 500;
  color: var(--c-text-muted);
  margin-bottom: 4px;
  letter-spacing: -0.01em;
}

/* ---------- Sidebar legend at bottom ---------- */
.sidebar__legend {
  border-top: 1px solid var(--c-border-subtle);
  padding: 12px 16px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px 12px;
  font-size: 11.5px;
  color: var(--c-text-muted);
  flex-shrink: 0;
}
.legend-dot {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.legend-dot::before {
  content: '';
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}
.legend-dot--known::before { background: var(--c-known); }
.legend-dot--fringe::before { background: var(--c-fringe); }
.legend-dot--review::before { background: var(--c-known); outline: 2px solid var(--c-review); outline-offset: -1px; }
.legend-dot--locked::before { background: var(--c-locked); }

/* =========================================================
   GRAPH
========================================================= */
.graph {
  position: relative;
  background:
    radial-gradient(circle at 15% 0%, rgba(60, 55, 179, 0.035), transparent 50%),
    var(--c-bg);
  min-height: 0;
  min-width: 0;
  overflow: hidden;
}
#cy {
  position: absolute;
  inset: 0;
}
.graph__empty {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  pointer-events: none;
  text-align: center;
}
.graph__empty[hidden] { display: none !important; }
.graph__empty-inner { max-width: 340px; color: var(--c-text-muted); }
.graph__empty-title {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 16px;
  color: var(--c-text);
  margin-bottom: 6px;
  letter-spacing: -0.02em;
}
.graph__empty-title em {
  font-family: var(--font-accent);
  font-style: italic;
  font-weight: 400;
  color: var(--c-primary);
}
.graph__empty-body {
  font-size: 13.5px;
  line-height: 1.55;
  margin-bottom: 14px;
}
.graph__empty-cta {
  display: inline-flex;
  pointer-events: auto;
}
.graph__fallback {
  position: absolute;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: var(--c-bg);
  text-align: center;
}
.graph__fallback[data-visible="true"] { display: flex; }

.graph__loading {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 24px;
  color: var(--c-text-muted);
  font-size: 13px;
  pointer-events: none;
  background: rgba(251, 250, 247, 0.92);
}
.graph__loading[hidden] { display: none !important; }
.graph__loading-spinner {
  width: 16px;
  height: 16px;
  border: 2px solid var(--c-border-strong);
  border-top-color: var(--c-primary);
  border-radius: 50%;
  animation: spin 800ms linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.graph__fallback-inner { max-width: 360px; color: var(--c-text-muted); font-size: 13px; line-height: 1.55; }
.graph__fallback-title {
  font-family: var(--font-display);
  font-weight: 600;
  color: var(--c-text);
  font-size: 15px;
  margin-bottom: 6px;
  letter-spacing: -0.02em;
}

/* Help hint floating in top-right of graph */
.graph__hint {
  position: absolute;
  top: 14px;
  right: 14px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 12px;
  font-size: 11.5px;
  color: var(--c-text-muted);
  background: var(--c-bg-elev);
  border: 1px solid var(--c-border);
  border-radius: var(--r-pill);
  box-shadow: var(--sh-xs);
  pointer-events: none;
}
.graph__hint[hidden] { display: none; }
.graph__hint svg { width: 13px; height: 13px; color: var(--c-text-soft); }

/* Zoom controls */
.graph__controls {
  position: absolute;
  bottom: 14px;
  right: 14px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  z-index: 2;
}
.graph__controls button {
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  background: var(--c-bg-elev);
  border: 1px solid var(--c-border);
  border-radius: var(--r-md);
  color: var(--c-text-muted);
  box-shadow: var(--sh-xs);
  transition: background var(--dur-fast), color var(--dur-fast);
}
.graph__controls button:hover { background: var(--c-bg-soft); color: var(--c-text); }
.graph__controls svg { width: 16px; height: 16px; }

/* =========================================================
   STUDENT DRAWER
========================================================= */
.drawer-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(20, 19, 26, 0.35);
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--dur) var(--ease-out);
  z-index: 50;
}
.drawer-backdrop[data-open="true"] {
  opacity: 1;
  pointer-events: auto;
}

.drawer {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: min(420px, 100%);
  background: var(--c-bg-elev);
  border-left: 1px solid var(--c-border);
  box-shadow: var(--sh-lg);
  display: flex;
  flex-direction: column;
  transform: translateX(100%);
  transition: transform var(--dur-slow) var(--ease-out);
  z-index: 60;
  overflow: hidden;
}
.drawer[data-open="true"] { transform: translateX(0); }
.drawer__head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--c-border);
  padding-top: max(14px, env(safe-area-inset-top));
  flex-shrink: 0;
}
.drawer__avatar {
  display: inline-grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--c-primary-soft);
  color: var(--c-primary);
  flex-shrink: 0;
}
.drawer__avatar svg { width: 17px; height: 17px; }
.drawer__titles { flex: 1; min-width: 0; }
.drawer__titles h2 {
  font-size: 15px;
  font-weight: 600;
  letter-spacing: -0.02em;
}
.drawer__titles p {
  font-size: 12px;
  color: var(--c-text-soft);
  margin-top: 1px;
}
.drawer__close {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border-radius: var(--r-md);
  background: transparent;
  color: var(--c-text-muted);
  transition: background var(--dur-fast);
  flex-shrink: 0;
}
.drawer__close:hover { background: var(--c-bg-soft); color: var(--c-text); }
.drawer__close svg { width: 16px; height: 16px; }

.drawer__body {
  flex: 1;
  overflow-y: auto;
  padding: 18px;
  padding-bottom: calc(18px + env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  gap: 18px;
}

/* Counter cards */
.counter-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
}
.counter {
  padding: 10px 8px;
  border-radius: var(--r-md);
  background: var(--c-bg);
  border: 1px solid var(--c-border-subtle);
  text-align: center;
}
.counter[data-kind="known"]  { background: var(--c-known-soft); border-color: #BFDCC5; }
.counter[data-kind="fringe"] { background: var(--c-fringe-soft); border-color: #E5D29A; }
.counter[data-kind="review"] { background: var(--c-review-soft); border-color: #D3CFEF; }
.counter__num {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 22px;
  line-height: 1;
  color: var(--c-text);
  letter-spacing: -0.03em;
  font-variant-numeric: tabular-nums;
}
.counter[data-kind="known"]  .counter__num { color: var(--c-known-dark); }
.counter[data-kind="fringe"] .counter__num { color: var(--c-fringe-dark); }
.counter[data-kind="review"] .counter__num { color: var(--c-review-dark); }
.counter__label {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--c-text-muted);
  font-weight: 600;
  margin-top: 4px;
  line-height: 1.2;
}

/* Radar */
.radar {
  padding: 8px;
  background: var(--c-bg);
  border: 1px solid var(--c-border-subtle);
  border-radius: var(--r-md);
  display: flex;
  justify-content: center;
}
.radar__svg {
  display: block;
  width: 100%;
  max-width: 340px;
  height: auto;
}
.radar__empty {
  padding: 28px 16px;
  text-align: center;
  color: var(--c-text-soft);
  font-size: 12.5px;
  font-style: italic;
  line-height: 1.55;
}

/* Sections */
.section__title {
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--c-text-muted);
  font-weight: 600;
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.section__title::before {
  content: '';
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--c-text-soft);
}
.section--fringe .section__title::before { background: var(--c-fringe); }
.section--review .section__title::before { background: var(--c-review); }
.section--known  .section__title::before { background: var(--c-known); }

.pill-list { display: flex; flex-direction: column; gap: 5px; }
.pill {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  background: var(--c-bg);
  border: 1px solid var(--c-border-subtle);
  border-radius: var(--r-sm);
  font-size: 13px;
  color: var(--c-text);
  text-align: left;
  width: 100%;
  transition: background var(--dur-fast), border-color var(--dur-fast), transform var(--dur-fast);
}
.pill--interactive { cursor: pointer; }
.pill--interactive:hover {
  background: var(--c-bg-elev);
  border-color: var(--c-text-muted);
}
.pill--interactive:active { transform: translateY(0.5px); }
.pill__label { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.pill__hint {
  font-size: 11px;
  color: var(--c-text-soft);
  opacity: 0;
  transition: opacity var(--dur-fast);
  flex-shrink: 0;
}
.pill--interactive:hover .pill__hint { opacity: 1; }
.pill__tag {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--c-review);
  background: var(--c-review-soft);
  padding: 2px 7px;
  border-radius: var(--r-pill);
  flex-shrink: 0;
  font-weight: 600;
}
.pill-list__empty {
  padding: 10px 12px;
  font-size: 12.5px;
  color: var(--c-text-soft);
  font-style: italic;
  text-align: center;
  border: 1px dashed var(--c-border);
  border-radius: var(--r-sm);
  background: transparent;
}

/* Drawer actions */
.drawer__actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  padding-top: 10px;
  border-top: 1px solid var(--c-border-subtle);
}
.drawer__actions .btn { width: 100%; }

/* =========================================================
   DIALOG
========================================================= */
dialog {
  border: 0;
  padding: 0;
  border-radius: var(--r-xl);
  background: var(--c-bg-elev);
  color: var(--c-text);
  max-width: 460px;
  width: calc(100% - 32px);
  box-shadow: var(--sh-lg);
}
dialog::backdrop { background: rgba(20, 19, 26, 0.42); }
.dialog-head {
  padding: 18px 20px 12px;
  border-bottom: 1px solid var(--c-border-subtle);
}
.dialog-head h3 {
  font-size: 16px;
  font-weight: 600;
  letter-spacing: -0.02em;
  margin-bottom: 2px;
}
.dialog-head p {
  font-size: 12.5px;
  color: var(--c-text-muted);
}
.dialog-body {
  max-height: 50vh;
  overflow-y: auto;
  padding: 12px 16px;
}
.dialog-checklist { display: flex; flex-direction: column; gap: 2px; }
.dialog-checklist label {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 8px 10px;
  border-radius: var(--r-sm);
  cursor: pointer;
  font-size: 13.5px;
  color: var(--c-text);
}
.dialog-checklist label:hover { background: var(--c-bg-soft); }
.dialog-checklist input {
  margin-top: 2px;
  accent-color: var(--c-primary);
  flex-shrink: 0;
}
.dialog-foot {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 12px 16px;
  border-top: 1px solid var(--c-border-subtle);
}
.dialog-empty {
  padding: 16px;
  text-align: center;
  color: var(--c-text-soft);
  font-size: 13px;
  font-style: italic;
}

/* =========================================================
   TOAST
========================================================= */
.toast {
  position: fixed;
  bottom: calc(22px + env(safe-area-inset-bottom));
  left: 50%;
  transform: translateX(-50%) translateY(12px);
  background: var(--c-text);
  color: white;
  padding: 9px 16px;
  border-radius: var(--r-pill);
  font-size: 12.5px;
  font-weight: 500;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--dur) var(--ease-out), transform var(--dur) var(--ease-out);
  z-index: 200;
  max-width: calc(100vw - 40px);
  box-shadow: var(--sh-lg);
  letter-spacing: -0.005em;
}
.toast[data-visible="true"] { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast--error { background: var(--c-danger); }

/* =========================================================
   RESPONSIVE
   Breakpoints:
   • ≥ 900px  — desktop two-column (sidebar + graph)
   • 900px–601px — tablet / landscape stacked (graph 55 % / sidebar 45 %)
   • ≤ 600px  — phone stacked, tighter toolbar
========================================================= */

/* Tablet and under: stack vertically, graph on top. */
@media (max-width: 900px) {
  /* Prevent iOS Safari zoom-on-focus when input font-size < 16px. */
  .sidebar__add input,
  .item__label,
  .dialog-checklist input + span { font-size: 16px; }

  .main {
    grid-template-columns: 1fr;
    grid-template-rows: minmax(260px, 1fr) minmax(200px, 0.9fr);
  }
  .sidebar {
    border-right: 0;
    border-bottom: 0;
    border-top: 1px solid var(--c-border);
    order: 2;
    min-height: 0;
  }
  .graph {
    order: 1;
    min-height: 0;
    border-bottom: 1px solid var(--c-border);
  }
  .sidebar__legend {
    grid-template-columns: repeat(4, auto);
    justify-content: start;
    gap: 10px 14px;
  }
  .drawer { width: 100%; max-width: 100%; border-left: 0; }

  /* Allow scroll regions to scroll without propagating to the page. */
  .sidebar__list, .drawer__body, .dialog-body { overscroll-behavior: contain; }
}

/* Phone portrait and smaller: compact toolbar, 2-col legend. */
@media (max-width: 600px) {
  .toolbar { padding: 10px 14px; gap: 8px; }
  .toolbar__actions { gap: 4px; }
  .toolbar__actions .btn__text { display: none; }
  .toolbar__actions .btn {
    padding: 7px 9px;
    width: 36px;
    justify-content: center;
  }
  .toolbar__actions .btn svg { width: 16px; height: 16px; }
  .toolbar__student-btn {
    padding: 6px 10px 6px 6px;
    gap: 6px;
  }
  .toolbar__student-btn .label { display: none; }
  .sidebar__legend {
    grid-template-columns: repeat(2, 1fr);
    font-size: 11px;
    padding: 10px 14px;
  }
  .graph__controls { bottom: 10px; right: 10px; }
  .graph__controls button { width: 34px; height: 34px; }
  .graph__hint {
    top: 10px;
    right: 10px;
    font-size: 11px;
    padding: 6px 10px;
    max-width: calc(100% - 20px);
  }
  .banner { padding: 10px 14px; }
  .banner__text { font-size: 13px; min-width: 180px; }
}

/* Very narrow (<= 360px): kill non-essentials. */
@media (max-width: 360px) {
  .graph__hint { display: none; }
  .brand__text h1 { font-size: 14px; }
  .toolbar__student-btn__ratio { font-size: 12px; }
}

/* Short viewport (landscape phones with low height): keep sidebar compact. */
@media (max-height: 520px) and (max-width: 900px) {
  .main {
    grid-template-rows: minmax(200px, 1fr) minmax(160px, 0.6fr);
  }
  .sidebar__legend { display: none; }
}
