/* CampusDesk — design tokens + components. Tailwind handles layout utilities. */
:root {
  --bg: #fafaf9; --surface: #ffffff; --surface-2: #f5f5f4; --border: #e7e5e4;
  --text: #1c1917; --muted: #78716c; --accent: #4f46e5; --accent-soft: #eef2ff; --on-accent: #ffffff;
  --danger: #dc2626; --success: #16a34a; --warn: #b45309;
  --shadow: 0 1px 2px rgba(28,25,23,.04), 0 2px 8px rgba(28,25,23,.04);
  --radius: 12px;
}
.dark {
  --bg: #0c0a09; --surface: #161311; --surface-2: #1c1917; --border: #292524;
  --text: #f5f5f4; --muted: #a8a29e; --accent: #818cf8; --accent-soft: rgba(129,140,248,.14); --on-accent: #0c0a09;
  --danger: #f87171; --success: #4ade80; --warn: #fbbf24;
  --shadow: 0 1px 2px rgba(0,0,0,.4);
}
html { color-scheme: light; }
html.dark { color-scheme: dark; }
body { font-family: Inter, ui-sans-serif, system-ui, sans-serif; font-feature-settings: "cv11", "ss01"; }

.bg-app { background: var(--bg); } .bg-surface { background: var(--surface); } .bg-surface-2 { background: var(--surface-2); }
.text-app { color: var(--text); } .text-muted { color: var(--muted); } .text-accent { color: var(--accent); }
.border-app { border-color: var(--border); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 6px; }

/* Brand */
.brand-mark { display: inline-flex; align-items: center; justify-content: center; width: 28px; height: 28px; border-radius: 8px; background: var(--accent); color: var(--on-accent); }

/* Sidebar */
.sidebar { position: fixed; inset: 0 auto 0 0; z-index: 40; width: 16rem; display: flex; flex-direction: column;
  background: var(--surface); border-right: 1px solid var(--border); transform: translateX(-100%); transition: transform .2s ease; }
.sidebar.open { transform: none; box-shadow: 0 0 40px rgba(0,0,0,.25); }
@media (min-width: 1024px) { .sidebar { transform: none; box-shadow: none; } }
.nav-group { padding: 0 .625rem .375rem; font-size: .75rem; font-weight: 500; color: var(--muted); }
.nav-link { display: flex; align-items: center; gap: .625rem; padding: .4rem .625rem; border-radius: 8px; font-size: .875rem; color: var(--muted); transition: background .12s, color .12s; }
.nav-link:hover { background: var(--surface-2); color: var(--text); }
.nav-link.active { background: var(--accent-soft); color: var(--accent); font-weight: 500; }
.nav-link.disabled { opacity: .55; cursor: not-allowed; }
.nav-link.disabled:hover { background: transparent; color: var(--muted); }
.soon { margin-left: auto; font-style: normal; font-size: .6875rem; padding: 1px 6px; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--border); }
.avatar { display: inline-flex; align-items: center; justify-content: center; width: 32px; height: 32px; border-radius: 999px; flex-shrink: 0;
  background: var(--accent-soft); color: var(--accent); font-size: .75rem; font-weight: 600; }
.avatar-btn { border: 1px solid var(--border); cursor: pointer; }

/* Topbar */
.topbar { position: sticky; top: 0; z-index: 20; height: 3.5rem; display: flex; align-items: center; gap: .75rem; padding: 0 1rem;
  background: color-mix(in srgb, var(--bg) 85%, transparent); backdrop-filter: blur(10px); border-bottom: 1px solid var(--border); }
@media (min-width: 1024px) { .topbar { padding: 0 2rem; } }
.icon-btn { display: inline-flex; padding: .4rem; border-radius: 8px; color: var(--muted); }
.icon-btn:hover { background: var(--surface-2); color: var(--text); }
.search-btn { display: inline-flex; align-items: center; gap: .5rem; height: 2rem; padding: 0 .625rem; border-radius: 8px; font-size: .8125rem;
  color: var(--muted); background: var(--surface); border: 1px solid var(--border); }
.search-btn:not(:disabled):hover { color: var(--text); }
.search-btn:disabled { opacity: .6; cursor: not-allowed; }
.kbd { font-family: "JetBrains Mono", monospace; font-size: .6875rem; padding: 1px 5px; border-radius: 4px; border: 1px solid var(--border); background: var(--surface-2); }
.segmented { display: inline-flex; padding: 2px; border-radius: 9px; background: var(--surface-2); border: 1px solid var(--border); }
.seg { display: inline-flex; padding: .3rem .4rem; border-radius: 7px; color: var(--muted); }
.seg.active { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }
.dropdown { position: absolute; right: 0; top: calc(100% + 8px); z-index: 50; min-width: 15rem; background: var(--surface);
  border: 1px solid var(--border); border-radius: 10px; box-shadow: 0 8px 30px rgba(0,0,0,.14); overflow: hidden; }
.menu-item { display: flex; width: 100%; align-items: center; gap: .5rem; padding: .5rem .75rem; border-radius: 7px; font-size: .875rem; text-align: left; }
.menu-item:hover { background: var(--surface-2); }

/* Mobile bottom nav */
.bottom-nav { position: fixed; inset: auto 0 0 0; z-index: 30; display: grid; grid-template-columns: repeat(5, 1fr);
  padding-bottom: env(safe-area-inset-bottom); background: var(--surface); border-top: 1px solid var(--border); }
.bn-item { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: .5rem 0; font-size: .6875rem; color: var(--muted); }
.bn-item.active { color: var(--accent); }
.bn-item.disabled { opacity: .45; }

/* Cards */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
.card-head { display: flex; align-items: center; justify-content: space-between; padding: .875rem 1rem; border-bottom: 1px solid var(--border); }
.card-head h2 { font-size: .875rem; font-weight: 600; }
.stat { padding: .875rem 1rem; }
.card-link { transition: border-color .12s; } .card-link:hover { border-color: var(--accent); }
.row { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: .75rem 1rem; }
.hover-row:hover { background: var(--surface-2); }
.file-ico { display: inline-flex; padding: .45rem; border-radius: 8px; background: var(--surface-2); color: var(--muted); }
.empty { display: flex; flex-direction: column; align-items: center; text-align: center; padding: 2.25rem 1rem; }
.empty.compact { padding: 1.5rem 1rem; }

/* Buttons */
.btn { display: inline-flex; align-items: center; gap: .5rem; height: 2.25rem; padding: 0 .875rem; border-radius: 9px; font-size: .875rem; font-weight: 500;
  border: 1px solid transparent; transition: background .12s, opacity .12s; cursor: pointer; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary { background: var(--accent); color: var(--on-accent); }
.btn-primary:not(:disabled):hover { opacity: .9; }
.btn-ghost { background: var(--surface); border-color: var(--border); color: var(--text); }
.btn-ghost:not(:disabled):hover { background: var(--surface-2); }
.btn-danger { background: var(--danger); color: #fff; }

/* Forms */
.label { display: block; margin-bottom: .375rem; font-size: .8125rem; font-weight: 500; }
.input { width: 100%; height: 2.5rem; padding: 0 .75rem; border-radius: 9px; font-size: .875rem; color: var(--text);
  background: var(--surface); border: 1px solid var(--border); transition: border-color .12s, box-shadow .12s; }
.input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.input-error { border-color: var(--danger); }
.field-error { margin-top: .375rem; font-size: .75rem; color: var(--danger); }
.checkbox { width: 1rem; height: 1rem; accent-color: var(--accent); }
.alert { padding: .625rem .875rem; border-radius: 9px; font-size: .8125rem; margin-bottom: 1rem; border: 1px solid; }
.alert-error { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 40%, transparent); background: color-mix(in srgb, var(--danger) 8%, transparent); }
.alert-success { color: var(--success); border-color: color-mix(in srgb, var(--success) 40%, transparent); background: color-mix(in srgb, var(--success) 8%, transparent); }

/* Chips */
.chip { display: inline-flex; padding: 2px 8px; border-radius: 999px; font-size: .6875rem; font-weight: 500; border: 1px solid var(--border); background: var(--surface-2); color: var(--muted); }
.chip-danger { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 35%, transparent); background: color-mix(in srgb, var(--danger) 8%, transparent); }
.chip-warn { color: var(--warn); border-color: color-mix(in srgb, var(--warn) 35%, transparent); background: color-mix(in srgb, var(--warn) 8%, transparent); }
.chip-info { color: var(--accent); background: var(--accent-soft); border-color: transparent; }
.chip-p-high { color: var(--danger); } .chip-p-medium { color: var(--warn); } .chip-p-low { color: var(--muted); }
.chip-box { display: flex; flex-wrap: wrap; gap: .375rem; padding: .375rem; min-height: 2.75rem; border-radius: 9px; background: var(--surface); border: 1px solid var(--border); cursor: text; }
.chip-box:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.chip-tag { display: inline-flex; align-items: center; gap: .25rem; padding: .25rem .25rem .25rem .625rem; border-radius: 7px; font-size: .8125rem; background: var(--accent-soft); color: var(--accent); }
.chip-tag button { padding: 0 .375rem; font-size: 1rem; line-height: 1; opacity: .7; } .chip-tag button:hover { opacity: 1; }
.chip-input { flex: 1; min-width: 10rem; padding: 0 .375rem; font-size: .875rem; background: transparent; color: var(--text); outline: none !important; box-shadow: none !important; }

/* Toasts + modal */
.toast-root { position: fixed; z-index: 100; right: 1rem; bottom: 5.5rem; display: flex; flex-direction: column; gap: .5rem; pointer-events: none; }
@media (min-width: 1024px) { .toast-root { bottom: 1.5rem; right: 1.5rem; } }
.toast { pointer-events: auto; display: flex; align-items: center; gap: .625rem; max-width: 22rem; padding: .625rem .875rem; border-radius: 10px; font-size: .875rem;
  background: var(--text); color: var(--bg); box-shadow: 0 8px 30px rgba(0,0,0,.25); animation: toast-in .18s ease-out; }
.toast.out { opacity: 0; transform: translateY(6px); transition: .18s; }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } }
.modal-backdrop { position: fixed; inset: 0; z-index: 90; display: flex; align-items: center; justify-content: center; padding: 1rem; background: rgba(0,0,0,.45); }
.modal { width: 100%; max-width: 24rem; padding: 1.25rem; border-radius: 14px; background: var(--surface); border: 1px solid var(--border); box-shadow: 0 20px 60px rgba(0,0,0,.3); animation: toast-in .16s ease-out; }

/* Skeleton loader (used by later phases) */
.skeleton { border-radius: 8px; background: linear-gradient(90deg, var(--surface-2) 25%, var(--border) 37%, var(--surface-2) 63%); background-size: 400% 100%; animation: shimmer 1.4s ease infinite; }
@keyframes shimmer { 0% { background-position: 100% 50%; } 100% { background-position: 0 50%; } }

/* Auth side panel */
.code-peek { padding: 1rem 1.125rem; border-radius: 12px; background: var(--surface); border: 1px solid var(--border); font-family: "JetBrains Mono", monospace; font-size: .75rem; line-height: 1.7; white-space: pre-wrap; }
.code-peek .c { color: var(--muted); } .code-peek .k { color: var(--accent); }

@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }

/* ---- Phase 2 additions ---- */
.modal { max-height: 90vh; overflow-y: auto; }
.modal-lg { max-width: 34rem; }
.dropdown-sm { min-width: 11rem; }
.subject-ico { display: inline-flex; align-items: center; justify-content: center; width: 40px; height: 40px; border-radius: 10px; flex-shrink: 0; }
.tabs { display: flex; gap: .25rem; margin-bottom: 1.5rem; overflow-x: auto; border-bottom: 1px solid var(--border); }
.tab { display: inline-flex; align-items: center; gap: .5rem; padding: .625rem .875rem; margin-bottom: -1px; font-size: .875rem; white-space: nowrap;
  color: var(--muted); border-bottom: 2px solid transparent; }
.tab:hover { color: var(--text); }
.tab.active { color: var(--text); font-weight: 500; border-bottom-color: var(--accent); }
.tab-count { font-size: .6875rem; padding: 0 6px; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--border); }
.icon-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(2.5rem, 1fr)); gap: .375rem; }
.icon-opt { display: flex; align-items: center; justify-content: center; height: 2.5rem; border-radius: 9px; border: 1px solid var(--border); color: var(--muted); }
.icon-opt:hover { background: var(--surface-2); }
.icon-opt[aria-pressed="true"] { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); }
.swatch { width: 1.75rem; height: 1.75rem; border-radius: 999px; border: 2px solid transparent; box-shadow: inset 0 0 0 2px var(--surface); }
.swatch[aria-pressed="true"] { border-color: var(--text); }
