/* ==========================================================================
   StudySkewl design system — dark glassmorphism
   Tokens: --accent / --accent-2 are "R G B" triplets set per user preference.
   Use these classes everywhere; combine with Tailwind utilities for layout.
   ========================================================================== */

:root {
  --bg: #07080f;
  --bg-2: #0b0d19;
  --surface: rgba(255, 255, 255, 0.035);
  --surface-2: rgba(255, 255, 255, 0.06);
  --surface-3: rgba(255, 255, 255, 0.09);
  --border: rgba(255, 255, 255, 0.075);
  --border-strong: rgba(255, 255, 255, 0.14);
  --text: #e7e9f5;
  --muted: #94a3b8;
  --radius: 16px;
  --sidebar-w: 256px;
  --sidebar-w-collapsed: 76px;
  --topbar-h: 64px;
  --ease: cubic-bezier(.2, .8, .2, 1);
}

* { -webkit-tap-highlight-color: transparent; }
html { background: var(--bg); color-scheme: dark; }
body.app-body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
  font-feature-settings: "cv02", "cv03", "cv04", "cv11";
}
::selection { background: rgb(var(--accent) / .35); color: #fff; }
a { color: inherit; text-decoration: none; }
[x-cloak], .hidden-important { display: none !important; }

/* ---------- Aurora background ---------- */
.aurora { position: fixed; inset: 0; z-index: 0; pointer-events: none; overflow: hidden; }
.aurora::after {
  content: ""; position: absolute; inset: 0;
  background-image: radial-gradient(rgba(255,255,255,.035) 1px, transparent 1px);
  background-size: 22px 22px;
  mask-image: radial-gradient(ellipse at 50% 0%, #000 20%, transparent 75%);
}
.aurora span { position: absolute; border-radius: 9999px; filter: blur(110px); opacity: .22; animation: auroraFloat 22s ease-in-out infinite; }
.aurora span:nth-child(1) { width: 620px; height: 620px; background: rgb(var(--accent)); top: -220px; left: 12%; }
.aurora span:nth-child(2) { width: 520px; height: 520px; background: rgb(var(--accent-2)); top: 8%; right: -160px; animation-delay: -7s; opacity: .14; }
.aurora span:nth-child(3) { width: 460px; height: 460px; background: #ec4899; bottom: -260px; left: 38%; animation-delay: -14s; opacity: .08; }

/* ---------- Shell ---------- */
.app-shell { position: relative; z-index: 1; display: flex; min-height: 100vh; }
.app-main { flex: 1; min-width: 0; margin-left: var(--sidebar-w); transition: margin-left .3s var(--ease); display: flex; flex-direction: column; }
.app-content { flex: 1; padding: 28px 36px 64px; max-width: 1480px; width: 100%; margin: 0 auto; }
.bare-main { position: relative; z-index: 1; min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px; }

/* ---------- Sidebar ---------- */
.sidebar {
  position: fixed; inset: 0 auto 0 0; width: var(--sidebar-w); z-index: 40;
  display: flex; flex-direction: column; gap: 6px; padding: 18px 14px;
  background: linear-gradient(180deg, rgba(12,14,28,.82), rgba(8,9,18,.9));
  backdrop-filter: blur(22px) saturate(150%); -webkit-backdrop-filter: blur(22px) saturate(150%);
  border-right: 1px solid var(--border);
  transition: width .3s var(--ease);
}
.sidebar-brand { display: flex; align-items: center; gap: 10px; padding: 4px 8px 14px; }
.brand-mark { display: grid; place-items: center; width: 36px; height: 36px; border-radius: 12px; background: rgba(255,255,255,.04); box-shadow: 0 0 24px -4px rgb(var(--accent) / .6); flex-shrink: 0; }
.brand-text { font-family: "Space Grotesk", Inter, sans-serif; font-weight: 700; font-size: 1.25rem; letter-spacing: -.02em; color: #fff; white-space: nowrap; }
.sidebar-ask {
  display: flex; align-items: center; gap: 10px; width: 100%; padding: 8px 10px; margin-bottom: 6px;
  border-radius: 14px; border: 1px solid rgb(var(--accent) / .28);
  background: linear-gradient(135deg, rgb(var(--accent) / .16), rgb(var(--accent-2) / .08));
  color: #fff; font-weight: 500; font-size: .9rem; cursor: pointer; transition: all .2s var(--ease);
}
.sidebar-ask:hover { box-shadow: 0 0 0 1px rgb(var(--accent) / .45), 0 10px 30px -10px rgb(var(--accent) / .6); transform: translateY(-1px); }
.sidebar-nav { flex: 1; overflow-y: auto; overflow-x: hidden; margin: 0 -4px; padding: 0 4px; scrollbar-width: none; }
.sidebar-nav::-webkit-scrollbar { display: none; }
.sidebar-section { font-size: .68rem; font-weight: 600; letter-spacing: .1em; text-transform: uppercase; color: #5b6488; padding: 16px 12px 6px; white-space: nowrap; }
.sidebar-link {
  position: relative; display: flex; align-items: center; gap: 12px; padding: 9px 12px; margin: 2px 0;
  border-radius: 12px; color: #aab3cf; font-size: .9rem; font-weight: 500; white-space: nowrap;
  transition: background .18s, color .18s;
}
.sidebar-link:hover { background: rgba(255,255,255,.05); color: #fff; }
.sidebar-link.active { color: #fff; background: linear-gradient(90deg, rgb(var(--accent) / .22), rgb(var(--accent) / .04)); box-shadow: inset 0 0 0 1px rgb(var(--accent) / .22); }
.sidebar-link.active::before { content: ""; position: absolute; left: -14px; top: 8px; bottom: 8px; width: 3px; border-radius: 0 4px 4px 0; background: linear-gradient(rgb(var(--accent)), rgb(var(--accent-2))); box-shadow: 0 0 12px rgb(var(--accent)); }
.sidebar-link.active svg { color: rgb(var(--accent)); filter: drop-shadow(0 0 6px rgb(var(--accent) / .6)); }
.sidebar-footer { display: flex; align-items: center; gap: 6px; padding-top: 10px; border-top: 1px solid var(--border); }
.sidebar-user { flex: 1; min-width: 0; display: flex; align-items: center; gap: 10px; padding: 6px; border-radius: 12px; transition: background .18s; }
.sidebar-user:hover { background: rgba(255,255,255,.05); }

body.sidebar-collapsed .sidebar { width: var(--sidebar-w-collapsed); }
body.sidebar-collapsed .app-main { margin-left: var(--sidebar-w-collapsed); }
body.sidebar-collapsed .sidebar-label,
body.sidebar-collapsed .brand-text,
body.sidebar-collapsed .sidebar-section { display: none; }
body.sidebar-collapsed .sidebar-link, body.sidebar-collapsed .sidebar-ask { justify-content: center; padding-left: 0; padding-right: 0; }
body.sidebar-collapsed .sidebar-footer { flex-direction: column; }
body.sidebar-collapsed .sidebar-collapse svg { transform: rotate(180deg); }

/* ---------- Topbar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 30; height: var(--topbar-h);
  display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 0 36px;
  background: rgba(7, 8, 15, .62); backdrop-filter: blur(18px) saturate(140%); -webkit-backdrop-filter: blur(18px) saturate(140%);
  border-bottom: 1px solid var(--border);
}
.topbar-search {
  display: flex; align-items: center; gap: 10px; width: min(520px, 100%); height: 40px; padding: 0 8px 0 14px;
  border-radius: 12px; background: rgba(255,255,255,.04); border: 1px solid var(--border); font-size: .875rem; cursor: text;
  transition: all .2s var(--ease);
}
.topbar-search:hover { border-color: var(--border-strong); background: rgba(255,255,255,.06); }
.notif-dot { position: absolute; top: 4px; right: 3px; min-width: 16px; height: 16px; padding: 0 4px; border-radius: 99px; font-size: 10px; font-weight: 700; line-height: 16px; text-align: center; color: #fff; background: linear-gradient(135deg, #f43f5e, #ec4899); box-shadow: 0 0 10px rgba(244,63,94,.6); }

.impersonation-bar { display: flex; align-items: center; gap: 10px; padding: 8px 36px; font-size: .85rem; color: #fde68a; background: linear-gradient(90deg, rgba(245,158,11,.18), rgba(245,158,11,.06)); border-bottom: 1px solid rgba(245,158,11,.25); }
.announcement { display: flex; align-items: center; gap: 12px; margin: 16px 36px 0; padding: 10px 14px; border-radius: 14px; font-size: .875rem; border: 1px solid; backdrop-filter: blur(12px); animation: fadeUp .4s var(--ease) both; }
.announcement-info { color: #bae6fd; background: rgba(14,165,233,.1); border-color: rgba(14,165,233,.25); }
.announcement-success { color: #bbf7d0; background: rgba(34,197,94,.1); border-color: rgba(34,197,94,.25); }
.announcement-warning { color: #fde68a; background: rgba(245,158,11,.1); border-color: rgba(245,158,11,.28); }
.announcement-danger { color: #fecdd3; background: rgba(244,63,94,.1); border-color: rgba(244,63,94,.28); }

/* ---------- Page header ---------- */
.page-header { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 28px; }
.page-header-icon { display: grid; place-items: center; width: 52px; height: 52px; border-radius: 16px; color: #fff; flex-shrink: 0; background: linear-gradient(135deg, rgb(var(--accent) / .9), rgb(var(--accent-2) / .75)); box-shadow: 0 10px 30px -10px rgb(var(--accent) / .8), inset 0 1px 0 rgba(255,255,255,.25); }
.page-title { font-family: "Space Grotesk", Inter, sans-serif; font-size: 1.9rem; font-weight: 700; letter-spacing: -.025em; color: #fff; line-height: 1.15; }
.page-subtitle { color: var(--muted); margin-top: 4px; font-size: .95rem; }
.section-title { font-family: "Space Grotesk", Inter, sans-serif; font-size: 1.1rem; font-weight: 600; color: #fff; letter-spacing: -.01em; }

/* ---------- Glass surfaces ---------- */
.glass { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); backdrop-filter: blur(16px) saturate(140%); -webkit-backdrop-filter: blur(16px) saturate(140%); }
.glass-strong { background: rgba(16, 18, 38, .78); border: 1px solid var(--border-strong); border-radius: var(--radius); backdrop-filter: blur(24px) saturate(160%); -webkit-backdrop-filter: blur(24px) saturate(160%); }
.card {
  position: relative; padding: 20px; border-radius: var(--radius);
  background: linear-gradient(180deg, rgba(255,255,255,.045), rgba(255,255,255,.02));
  border: 1px solid var(--border);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.04), 0 10px 30px -18px rgba(0,0,0,.6);
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
}
.card-hover { transition: transform .25s var(--ease), border-color .25s, box-shadow .25s; cursor: pointer; }
.card-hover:hover { transform: translateY(-3px); border-color: rgb(var(--accent) / .35); box-shadow: inset 0 1px 0 rgba(255,255,255,.06), 0 18px 40px -18px rgb(var(--accent) / .45); }
.card-flush { padding: 0; overflow: hidden; }
.gradient-border { position: relative; border: none; }
.gradient-border::before { content: ""; position: absolute; inset: 0; padding: 1px; border-radius: inherit; background: linear-gradient(135deg, rgb(var(--accent) / .7), rgba(255,255,255,.06) 40%, rgb(var(--accent-2) / .6)); -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0); -webkit-mask-composite: xor; mask-composite: exclude; pointer-events: none; }
.divider { height: 1px; background: var(--border); border: 0; margin: 16px 0; }

.gradient-text { background: linear-gradient(120deg, rgb(var(--accent)) 10%, rgb(var(--accent-2)) 90%); -webkit-background-clip: text; background-clip: text; color: transparent; }
.text-muted { color: var(--muted); }

/* ---------- Stat cards ---------- */
.stat-card { display: flex; align-items: center; gap: 14px; }
.stat-icon { display: grid; place-items: center; width: 44px; height: 44px; border-radius: 13px; color: var(--c); background: color-mix(in srgb, var(--c) 16%, transparent); box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--c) 30%, transparent); flex-shrink: 0; }
.stat-value { font-family: "Space Grotesk", Inter, sans-serif; font-size: 1.6rem; font-weight: 700; color: #fff; line-height: 1.1; }
.stat-label { font-size: .8rem; color: var(--muted); }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: 40px; padding: 0 16px;
  border-radius: 12px; font-size: .875rem; font-weight: 600; white-space: nowrap; cursor: pointer; user-select: none;
  border: 1px solid transparent; transition: all .18s var(--ease); position: relative;
}
.btn:disabled, .btn[aria-disabled="true"] { opacity: .5; cursor: not-allowed; transform: none !important; }
.btn:focus-visible, .btn-icon:focus-visible { outline: 2px solid rgb(var(--accent)); outline-offset: 2px; }
.btn-primary { color: #fff; background: linear-gradient(135deg, rgb(var(--accent)), color-mix(in srgb, rgb(var(--accent)) 55%, rgb(var(--accent-2)))); box-shadow: 0 8px 24px -10px rgb(var(--accent) / .9), inset 0 1px 0 rgba(255,255,255,.22); }
.btn-primary:hover:not(:disabled) { transform: translateY(-1px); box-shadow: 0 12px 30px -10px rgb(var(--accent)), inset 0 1px 0 rgba(255,255,255,.3); filter: brightness(1.08); }
.btn-primary:active:not(:disabled) { transform: translateY(0); }
.btn-secondary { color: #e2e8f0; background: rgba(255,255,255,.06); border-color: var(--border-strong); }
.btn-secondary:hover:not(:disabled) { background: rgba(255,255,255,.1); color: #fff; }
.btn-ghost { color: #cbd5e1; background: transparent; }
.btn-ghost:hover:not(:disabled) { background: rgba(255,255,255,.06); color: #fff; }
.btn-danger { color: #fecdd3; background: rgba(244,63,94,.14); border-color: rgba(244,63,94,.35); }
.btn-danger:hover:not(:disabled) { background: rgba(244,63,94,.24); color: #fff; }
.btn-success { color: #bbf7d0; background: rgba(34,197,94,.14); border-color: rgba(34,197,94,.35); }
.btn-success:hover:not(:disabled) { background: rgba(34,197,94,.24); color: #fff; }
.btn-ai { color: #fff; background: linear-gradient(120deg, #7c3aed, #db2777 50%, #06b6d4); background-size: 200% 100%; box-shadow: 0 8px 28px -10px rgba(168,85,247,.9), inset 0 1px 0 rgba(255,255,255,.25); animation: aiGradient 6s ease infinite; }
.btn-ai:hover:not(:disabled) { transform: translateY(-1px); filter: brightness(1.1); }
.btn-sm { height: 32px; padding: 0 12px; font-size: .8rem; border-radius: 10px; gap: 6px; }
.btn-lg { height: 48px; padding: 0 22px; font-size: .95rem; border-radius: 14px; }
.btn-block { width: 100%; }
.btn-icon { display: inline-grid; place-items: center; width: 38px; height: 38px; border-radius: 11px; color: #aab3cf; background: transparent; border: 0; cursor: pointer; transition: all .18s; }
.btn-icon:hover { background: rgba(255,255,255,.07); color: #fff; }
.btn.is-loading { color: transparent !important; pointer-events: none; }
.btn.is-loading::after { content: ""; position: absolute; width: 16px; height: 16px; border-radius: 50%; border: 2px solid rgba(255,255,255,.35); border-top-color: #fff; animation: spin .7s linear infinite; }

/* ---------- Forms ---------- */
.label { display: block; font-size: .8rem; font-weight: 600; color: #cbd5e1; margin-bottom: 6px; }
.hint { font-size: .75rem; color: #64748b; margin-top: 5px; }
.input, .select, .textarea {
  width: 100%; height: 42px; padding: 0 14px; border-radius: 12px; font-size: .9rem; color: #f1f5f9;
  background: rgba(255,255,255,.04); border: 1px solid var(--border-strong); outline: none;
  transition: border-color .18s, box-shadow .18s, background .18s;
}
.textarea { height: auto; min-height: 100px; padding: 12px 14px; resize: vertical; line-height: 1.55; }
.select { padding-right: 36px; appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='none' stroke='%2394a3b8' stroke-width='2' viewBox='0 0 24 24'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 12px center; }
.select option, .select optgroup { background: #10122a; color: #e2e8f0; }
.input::placeholder, .textarea::placeholder { color: #5b6488; }
.input:hover, .select:hover, .textarea:hover { border-color: rgba(255,255,255,.2); }
.input:focus, .select:focus, .textarea:focus { border-color: rgb(var(--accent) / .7); background: rgba(255,255,255,.06); box-shadow: 0 0 0 4px rgb(var(--accent) / .15); }
.input-group { position: relative; }
.input-group > svg, .input-group > i { position: absolute; left: 13px; top: 50%; transform: translateY(-50%); color: #64748b; pointer-events: none; width: 16px; height: 16px; }
.input-group > .input { padding-left: 40px; }
.checkbox { width: 18px; height: 18px; border-radius: 6px; background-color: rgba(255,255,255,.05); border: 1px solid var(--border-strong); color: rgb(var(--accent)); cursor: pointer; }
.checkbox:focus { box-shadow: 0 0 0 3px rgb(var(--accent) / .25); outline: none; }
.toggle { position: relative; display: inline-block; width: 42px; height: 24px; flex-shrink: 0; }
.toggle input { opacity: 0; width: 0; height: 0; }
.toggle span { position: absolute; inset: 0; border-radius: 99px; cursor: pointer; background: rgba(255,255,255,.1); border: 1px solid var(--border-strong); transition: .25s var(--ease); }
.toggle span::before { content: ""; position: absolute; width: 18px; height: 18px; left: 2px; top: 2px; border-radius: 50%; background: #cbd5e1; transition: .25s var(--ease); }
.toggle input:checked + span { background: rgb(var(--accent)); border-color: rgb(var(--accent)); box-shadow: 0 0 14px rgb(var(--accent) / .5); }
.toggle input:checked + span::before { transform: translateX(18px); background: #fff; }
.segmented { display: inline-flex; padding: 4px; gap: 4px; border-radius: 12px; background: rgba(255,255,255,.04); border: 1px solid var(--border); }
.segmented button, .segmented label { padding: 6px 12px; border-radius: 9px; font-size: .8rem; font-weight: 600; color: #94a3b8; cursor: pointer; transition: all .18s; }
.segmented button.active, .segmented input:checked + label, .segmented label.active { background: rgba(255,255,255,.1); color: #fff; box-shadow: 0 2px 10px -4px rgba(0,0,0,.6); }
.segmented input { display: none; }
.range { width: 100%; accent-color: rgb(var(--accent)); }

/* ---------- Badges & chips ---------- */
.badge { display: inline-flex; align-items: center; gap: 5px; height: 22px; padding: 0 8px; border-radius: 99px; font-size: .7rem; font-weight: 600; color: #cbd5e1; background: rgba(255,255,255,.07); border: 1px solid var(--border); white-space: nowrap; }
.badge-accent { color: #fff; background: rgb(var(--accent) / .2); border-color: rgb(var(--accent) / .4); }
.badge-success { color: #86efac; background: rgba(34,197,94,.12); border-color: rgba(34,197,94,.3); }
.badge-warning { color: #fcd34d; background: rgba(245,158,11,.12); border-color: rgba(245,158,11,.3); }
.badge-danger { color: #fda4af; background: rgba(244,63,94,.12); border-color: rgba(244,63,94,.3); }
.badge-info { color: #7dd3fc; background: rgba(14,165,233,.12); border-color: rgba(14,165,233,.3); }
.course-badge { display: inline-flex; align-items: center; gap: 5px; height: 22px; padding: 0 9px; border-radius: 99px; font-size: .7rem; font-weight: 600; white-space: nowrap; color: color-mix(in srgb, var(--c) 70%, #fff); background: color-mix(in srgb, var(--c) 15%, transparent); border: 1px solid color-mix(in srgb, var(--c) 35%, transparent); }
.chip { display: inline-flex; align-items: center; gap: 6px; height: 32px; padding: 0 12px; border-radius: 99px; font-size: .8rem; font-weight: 500; color: #cbd5e1; background: rgba(255,255,255,.04); border: 1px solid var(--border-strong); cursor: pointer; transition: all .18s; }
.chip:hover { color: #fff; border-color: rgba(255,255,255,.25); }
.chip.active, .chip[aria-pressed="true"] { color: #fff; background: rgb(var(--accent) / .2); border-color: rgb(var(--accent) / .55); box-shadow: 0 0 16px -6px rgb(var(--accent)); }
.kbd { display: inline-flex; align-items: center; height: 20px; padding: 0 6px; border-radius: 6px; font-family: "JetBrains Mono", monospace; font-size: .66rem; color: #94a3b8; background: rgba(255,255,255,.06); border: 1px solid var(--border-strong); border-bottom-width: 2px; white-space: nowrap; }

/* ---------- Avatars ---------- */
.avatar { display: inline-grid; place-items: center; border-radius: 50%; color: #fff; font-weight: 700; flex-shrink: 0; box-shadow: 0 0 0 2px rgba(255,255,255,.08); overflow: hidden; }
.avatar-xs { width: 22px; height: 22px; font-size: .55rem; }
.avatar-sm { width: 32px; height: 32px; font-size: .72rem; }
.avatar-md { width: 40px; height: 40px; font-size: .85rem; }
.avatar-lg { width: 64px; height: 64px; font-size: 1.25rem; }
.avatar-xl { width: 104px; height: 104px; font-size: 2rem; }
.avatar-stack { display: flex; }
.avatar-stack > * { margin-left: -8px; box-shadow: 0 0 0 2px var(--bg); }
.avatar-stack > *:first-child { margin-left: 0; }

/* ---------- Giancarlo orb ---------- */
.giancarlo-orb { display: inline-grid; place-items: center; border-radius: 50%; color: #fff; flex-shrink: 0; background: radial-gradient(circle at 30% 25%, #fff 0, rgba(255,255,255,0) 22%), conic-gradient(from 200deg, #8b5cf6, #ec4899, #22d3ee, #8b5cf6); box-shadow: 0 0 18px -2px rgba(168,85,247,.75), inset 0 0 8px rgba(255,255,255,.35); animation: orbSpin 8s linear infinite; }
.giancarlo-orb > * { animation: orbSpin 8s linear infinite reverse; }

/* ---------- Tabs ---------- */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); overflow-x: auto; scrollbar-width: none; }
.tab { position: relative; display: inline-flex; align-items: center; gap: 8px; padding: 10px 14px; font-size: .875rem; font-weight: 600; color: #8b93b3; cursor: pointer; white-space: nowrap; transition: color .18s; background: none; border: 0; }
.tab:hover { color: #fff; }
.tab.active { color: #fff; }
.tab.active::after { content: ""; position: absolute; left: 10px; right: 10px; bottom: -1px; height: 2px; border-radius: 2px; background: linear-gradient(90deg, rgb(var(--accent)), rgb(var(--accent-2))); box-shadow: 0 0 10px rgb(var(--accent)); }

/* ---------- Dropdowns & menus ---------- */
.dropdown { position: absolute; top: calc(100% + 8px); z-index: 60; min-width: 200px; border-radius: 16px; background: rgba(14, 16, 34, .92); border: 1px solid var(--border-strong); box-shadow: 0 24px 60px -12px rgba(0,0,0,.8); backdrop-filter: blur(24px); -webkit-backdrop-filter: blur(24px); opacity: 0; transform: translateY(-6px) scale(.98); pointer-events: none; transition: opacity .16s, transform .16s var(--ease); }
.dropdown-right { right: 0; }
.dropdown-left { left: 0; }
[data-dropdown].open > .dropdown, .dropdown.open { opacity: 1; transform: none; pointer-events: auto; }
/* .card uses backdrop-filter, which traps an absolutely-positioned dropdown in
   the card's stacking context. Lift any card whose menu is open so it paints
   above sibling cards and later sections (e.g. tables below a grid). */
.card:has([data-dropdown].open) { position: relative; z-index: 90; }
/* .page-header uses animate-fade-up (a transform animation), which traps the
   header's dropdown in its stacking context below backdrop-filtered .card
   sections. Lift the header while its menu is open. */
.page-header:has([data-dropdown].open) { position: relative; z-index: 90; }
.menu-item { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 10px; font-size: .875rem; color: #cbd5e1; cursor: pointer; background: none; border: 0; text-align: left; transition: background .15s, color .15s; }
.menu-item:hover, .menu-item.active { background: rgba(255,255,255,.07); color: #fff; }
.menu-item svg { width: 16px; height: 16px; opacity: .8; }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; border-radius: var(--radius); border: 1px solid var(--border); background: var(--surface); }
.table-ss { width: 100%; border-collapse: collapse; font-size: .875rem; }
.table-ss th { text-align: left; padding: 12px 16px; font-size: .72rem; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; color: #7d86a8; background: rgba(255,255,255,.025); border-bottom: 1px solid var(--border); white-space: nowrap; }
.table-ss td { padding: 12px 16px; border-bottom: 1px solid rgba(255,255,255,.045); color: #d4d9ea; vertical-align: middle; }
.table-ss tbody tr { transition: background .15s; }
.table-ss tbody tr:hover { background: rgba(255,255,255,.03); }
.table-ss tbody tr:last-child td { border-bottom: 0; }

/* ---------- Progress ---------- */
.progress { height: 8px; border-radius: 99px; background: rgba(255,255,255,.07); overflow: hidden; }
.progress > span { display: block; height: 100%; border-radius: inherit; background: linear-gradient(90deg, rgb(var(--accent)), rgb(var(--accent-2))); box-shadow: 0 0 12px rgb(var(--accent) / .6); transition: width .5s var(--ease); }
.ring { --p: 0; --size: 64px; width: var(--size); height: var(--size); border-radius: 50%; display: grid; place-items: center; background: conic-gradient(rgb(var(--accent)) calc(var(--p) * 1%), rgba(255,255,255,.08) 0); }
.ring::before { content: ""; grid-area: 1/1; width: calc(var(--size) - 12px); height: calc(var(--size) - 12px); border-radius: 50%; background: var(--bg-2); }
.ring > * { grid-area: 1/1; position: relative; }

/* ---------- Skeleton & loaders ---------- */
.skeleton { border-radius: 10px; background: linear-gradient(90deg, rgba(255,255,255,.04) 25%, rgba(255,255,255,.09) 37%, rgba(255,255,255,.04) 63%); background-size: 400% 100%; animation: shimmer 1.4s ease infinite; }
.spinner { width: 20px; height: 20px; border-radius: 50%; border: 2px solid rgba(255,255,255,.15); border-top-color: rgb(var(--accent)); animation: spin .7s linear infinite; display: inline-block; }
.typing-dots { display: inline-flex; gap: 4px; align-items: center; }
.typing-dots span { width: 6px; height: 6px; border-radius: 50%; background: rgb(var(--accent)); animation: typing 1.2s infinite ease-in-out; }
.typing-dots span:nth-child(2) { animation-delay: .15s; }
.typing-dots span:nth-child(3) { animation-delay: .3s; }
.ai-loader { display: flex; flex-direction: column; align-items: center; gap: 16px; padding: 48px 24px; text-align: center; }
.ai-loader .giancarlo-orb { width: 64px; height: 64px; animation: orbSpin 2.4s linear infinite, pulseGlow 2s ease-in-out infinite; }
.ai-loader-steps { font-size: .875rem; color: #94a3b8; min-height: 1.5em; }

/* ---------- Empty state ---------- */
.empty-state { text-align: center; padding: 56px 24px; border-radius: var(--radius); border: 1px dashed var(--border-strong); background: rgba(255,255,255,.015); }
.empty-state-icon { display: grid; place-items: center; width: 68px; height: 68px; margin: 0 auto 16px; border-radius: 20px; color: rgb(var(--accent)); background: rgb(var(--accent) / .1); box-shadow: inset 0 0 0 1px rgb(var(--accent) / .25), 0 0 40px -10px rgb(var(--accent) / .5); }

/* ---------- Modals ---------- */
.modal-backdrop { position: fixed; inset: 0; z-index: 100; display: flex; align-items: center; justify-content: center; padding: 24px; background: rgba(3, 4, 10, .66); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); animation: fadeIn .18s ease both; }
.modal-backdrop.closing { animation: fadeOut .16s ease both; }
.modal { width: 100%; max-width: 520px; max-height: calc(100vh - 48px); display: flex; flex-direction: column; border-radius: 20px; background: linear-gradient(180deg, rgba(20,22,44,.96), rgba(12,14,30,.97)); border: 1px solid var(--border-strong); box-shadow: 0 40px 100px -20px rgba(0,0,0,.9), 0 0 0 1px rgba(255,255,255,.03) inset; animation: modalIn .24s var(--ease) both; }
.modal-sm { max-width: 400px; } .modal-lg { max-width: 760px; } .modal-xl { max-width: 1040px; }
.modal-header { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 18px 22px; border-bottom: 1px solid var(--border); }
.modal-title { font-family: "Space Grotesk", Inter, sans-serif; font-size: 1.1rem; font-weight: 600; color: #fff; }
.modal-body { padding: 22px; overflow-y: auto; }
.modal-footer { display: flex; justify-content: flex-end; gap: 8px; padding: 14px 22px; border-top: 1px solid var(--border); }

/* ---------- Toasts ---------- */
.toast-root { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%); z-index: 200; display: flex; flex-direction: column; align-items: center; gap: 8px; pointer-events: none; }
.toast { pointer-events: auto; display: flex; align-items: center; gap: 10px; min-width: 260px; max-width: 480px; padding: 11px 16px; border-radius: 14px; font-size: .875rem; color: #f1f5f9; background: rgba(18,20,40,.94); border: 1px solid var(--border-strong); box-shadow: 0 20px 50px -12px rgba(0,0,0,.8); backdrop-filter: blur(20px); animation: toastIn .3s var(--ease) both; }
.toast.leaving { animation: toastOut .25s ease both; }
.toast-success svg { color: #4ade80; } .toast-error svg { color: #fb7185; } .toast-info svg { color: rgb(var(--accent)); } .toast-warning svg { color: #fbbf24; }

/* ---------- Command palette ---------- */
.palette { max-width: 640px; align-self: flex-start; margin-top: 12vh; overflow: hidden; }
.palette-input { width: 100%; height: 58px; padding: 0 20px 0 52px; font-size: 1.05rem; color: #fff; background: transparent; border: 0; outline: none; }
.palette-results { max-height: 420px; overflow-y: auto; padding: 8px; border-top: 1px solid var(--border); }
.palette-group { padding: 10px 12px 4px; font-size: .68rem; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: #5b6488; }
.palette-item { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 12px; color: #cbd5e1; cursor: pointer; }
.palette-item .pi-icon { display: grid; place-items: center; width: 32px; height: 32px; border-radius: 10px; background: rgba(255,255,255,.05); color: #aab3cf; flex-shrink: 0; }
.palette-item.selected { background: rgb(var(--accent) / .16); color: #fff; box-shadow: inset 0 0 0 1px rgb(var(--accent) / .3); }
.palette-item.selected .pi-icon { background: rgb(var(--accent) / .3); color: #fff; }

/* ---------- Giancarlo floating bubble ---------- */
.gc-fab { position: fixed; right: 24px; bottom: 24px; z-index: 90; width: 60px; height: 60px; border-radius: 50%; border: 0; cursor: pointer; display: grid; place-items: center; transition: transform .25s var(--ease); }
.gc-fab .giancarlo-orb { width: 60px; height: 60px; box-shadow: 0 12px 40px -6px rgba(168,85,247,.85), inset 0 0 12px rgba(255,255,255,.4); }
.gc-fab:hover { transform: scale(1.07) translateY(-2px); }
.gc-fab.hidden-fab { transform: scale(0); pointer-events: none; }
.gc-panel { position: fixed; right: 24px; bottom: 24px; z-index: 95; width: 420px; height: min(640px, calc(100vh - 48px)); display: flex; flex-direction: column; border-radius: 22px; overflow: hidden; background: linear-gradient(180deg, rgba(20,22,46,.94), rgba(10,12,26,.96)); border: 1px solid var(--border-strong); box-shadow: 0 40px 100px -20px rgba(0,0,0,.9), 0 0 60px -20px rgb(var(--accent) / .5); backdrop-filter: blur(28px); -webkit-backdrop-filter: blur(28px); transform-origin: bottom right; animation: panelIn .3s var(--ease) both; }
.gc-panel.closing { animation: panelOut .2s ease both; }
.gc-panel.expanded { width: min(760px, calc(100vw - 48px)); height: calc(100vh - 48px); }

/* ---------- Chat messages (bubble + full chat) ---------- */
.msg { display: flex; gap: 10px; animation: fadeUp .3s var(--ease) both; }
.msg-user { justify-content: flex-end; }
.msg-user .msg-body { max-width: 85%; padding: 10px 14px; border-radius: 16px 16px 4px 16px; color: #fff; background: linear-gradient(135deg, rgb(var(--accent) / .85), color-mix(in srgb, rgb(var(--accent)) 60%, rgb(var(--accent-2)))); box-shadow: 0 6px 20px -10px rgb(var(--accent)); white-space: pre-wrap; word-wrap: break-word; }
.msg-ai .msg-body { flex: 1; min-width: 0; }
.thinking-block { margin-bottom: 8px; border-radius: 12px; border: 1px solid var(--border); background: rgba(255,255,255,.02); font-size: .8rem; }
.thinking-block summary { cursor: pointer; padding: 7px 12px; color: #8b93b3; list-style: none; display: flex; align-items: center; gap: 8px; user-select: none; }
.thinking-block summary::-webkit-details-marker { display: none; }
.thinking-block .thinking-text { padding: 0 12px 10px; color: #7d86a8; white-space: pre-wrap; max-height: 240px; overflow-y: auto; font-style: italic; }

/* ---------- Rich content (Markdown / notes) ---------- */
.prose-ss { color: #d6dbeb; font-size: .95rem; line-height: 1.72; word-wrap: break-word; }
.prose-ss > *:first-child { margin-top: 0; }
.prose-ss > *:last-child { margin-bottom: 0; }
.prose-ss h1, .prose-ss h2, .prose-ss h3, .prose-ss h4 { font-family: "Space Grotesk", Inter, sans-serif; color: #fff; letter-spacing: -.015em; line-height: 1.3; }
.prose-ss h1 { font-size: 1.75rem; font-weight: 700; margin: 1.6em 0 .6em; }
.prose-ss h2 { font-size: 1.35rem; font-weight: 700; margin: 1.6em 0 .55em; padding-bottom: .35em; border-bottom: 1px solid var(--border); }
.prose-ss h3 { font-size: 1.12rem; font-weight: 600; margin: 1.35em 0 .45em; color: color-mix(in srgb, rgb(var(--accent)) 35%, #fff); }
.prose-ss h4 { font-size: 1rem; font-weight: 600; margin: 1.2em 0 .4em; }
.prose-ss p { margin: .7em 0; }
.prose-ss a { color: rgb(var(--accent-2)); text-decoration: underline; text-underline-offset: 3px; text-decoration-color: rgb(var(--accent-2) / .4); }
.prose-ss strong { color: #fff; font-weight: 650; }
.prose-ss em { color: #e2e8f0; }
.prose-ss ul, .prose-ss ol { margin: .7em 0; padding-left: 1.5em; }
.prose-ss ul { list-style: disc; }
.prose-ss ol { list-style: decimal; }
.prose-ss li { margin: .3em 0; }
.prose-ss li::marker { color: rgb(var(--accent)); }
.prose-ss ul[data-type="taskList"] { list-style: none; padding-left: .2em; }
.prose-ss ul[data-type="taskList"] li { display: flex; gap: .6em; align-items: flex-start; }
.prose-ss blockquote { margin: 1em 0; padding: .6em 1em; border-left: 3px solid rgb(var(--accent)); background: rgb(var(--accent) / .07); border-radius: 0 12px 12px 0; color: #cbd5e1; }
.prose-ss code:not(pre code) { font-family: "JetBrains Mono", monospace; font-size: .85em; padding: .15em .4em; border-radius: 6px; color: #f0abfc; background: rgba(255,255,255,.07); border: 1px solid var(--border); }
.prose-ss pre { position: relative; margin: 1em 0; padding: 14px 16px; border-radius: 14px; background: #0a0c18 !important; border: 1px solid var(--border); overflow-x: auto; font-size: .84rem; line-height: 1.6; }
.prose-ss pre code { font-family: "JetBrains Mono", monospace; background: transparent !important; padding: 0 !important; }
.prose-ss .code-copy { position: absolute; top: 8px; right: 8px; opacity: 0; transition: opacity .15s; }
.prose-ss pre:hover .code-copy { opacity: 1; }
.prose-ss table { width: 100%; margin: 1em 0; border-collapse: collapse; font-size: .9em; display: block; overflow-x: auto; }
.prose-ss th { text-align: left; padding: 8px 12px; color: #fff; font-weight: 600; background: rgba(255,255,255,.05); border: 1px solid var(--border-strong); }
.prose-ss td { padding: 8px 12px; border: 1px solid var(--border); }
.prose-ss hr { border: 0; height: 1px; margin: 2em 0; background: linear-gradient(90deg, transparent, var(--border-strong), transparent); }
.prose-ss img { border-radius: 12px; max-width: 100%; }
.prose-ss mark { background: rgba(250, 204, 21, .25); color: #fef9c3; padding: 0 .15em; border-radius: 4px; }
.prose-ss .katex-display { margin: 1em 0; padding: 12px; overflow-x: auto; overflow-y: hidden; border-radius: 12px; background: rgba(255,255,255,.02); }
.prose-ss .katex { font-size: 1.06em; }
.prose-ss .mermaid { margin: 1em 0; padding: 16px; border-radius: 14px; background: rgba(255,255,255,.03); border: 1px solid var(--border); text-align: center; overflow-x: auto; }
.prose-ss .callout { margin: 1em 0; padding: 12px 16px; border-radius: 14px; border: 1px solid rgb(var(--accent) / .3); background: rgb(var(--accent) / .08); }
.prose-sm { font-size: .875rem; line-height: 1.65; }
.prose-sm h1 { font-size: 1.3rem; } .prose-sm h2 { font-size: 1.12rem; } .prose-sm h3 { font-size: 1rem; }
.streaming-caret::after { content: ""; display: inline-block; width: 8px; height: 1.1em; margin-left: 2px; vertical-align: text-bottom; border-radius: 2px; background: rgb(var(--accent)); animation: blink 1s steps(2) infinite; }

/* ---------- Scrollbars ---------- */
.scrollbar-thin, .app-content, .modal-body, .gc-panel * { scrollbar-width: thin; scrollbar-color: rgba(255,255,255,.14) transparent; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(255,255,255,.1); border-radius: 99px; border: 3px solid transparent; background-clip: content-box; }
::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,.2); background-clip: content-box; }

/* ---------- Animations ---------- */
@keyframes fadeUp { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes fadeOut { to { opacity: 0; } }
@keyframes modalIn { from { opacity: 0; transform: translateY(12px) scale(.97); } to { opacity: 1; transform: none; } }
@keyframes panelIn { from { opacity: 0; transform: translateY(16px) scale(.94); } to { opacity: 1; transform: none; } }
@keyframes panelOut { to { opacity: 0; transform: translateY(12px) scale(.95); } }
@keyframes toastIn { from { opacity: 0; transform: translateY(14px) scale(.96); } to { opacity: 1; transform: none; } }
@keyframes toastOut { to { opacity: 0; transform: translateY(8px) scale(.96); } }
@keyframes shimmer { 0% { background-position: 100% 50%; } 100% { background-position: 0 50%; } }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes orbSpin { to { transform: rotate(360deg); } }
@keyframes pulseGlow { 0%, 100% { box-shadow: 0 0 24px -2px rgba(168,85,247,.6); } 50% { box-shadow: 0 0 50px 4px rgba(34,211,238,.55); } }
@keyframes typing { 0%, 60%, 100% { transform: translateY(0); opacity: .4; } 30% { transform: translateY(-5px); opacity: 1; } }
@keyframes blink { to { visibility: hidden; } }
@keyframes aiGradient { 0%, 100% { background-position: 0 50%; } 50% { background-position: 100% 50%; } }
@keyframes auroraFloat { 0%, 100% { transform: translate(0, 0) scale(1); } 33% { transform: translate(40px, 30px) scale(1.08); } 66% { transform: translate(-30px, 20px) scale(.95); } }
@keyframes float { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-8px); } }
.animate-fade-up { animation: fadeUp .45s var(--ease) both; }
.stagger > * { animation: fadeUp .45s var(--ease) both; }
.stagger > *:nth-child(1) { animation-delay: .02s; } .stagger > *:nth-child(2) { animation-delay: .06s; } .stagger > *:nth-child(3) { animation-delay: .1s; }
.stagger > *:nth-child(4) { animation-delay: .14s; } .stagger > *:nth-child(5) { animation-delay: .18s; } .stagger > *:nth-child(6) { animation-delay: .22s; }
.stagger > *:nth-child(7) { animation-delay: .26s; } .stagger > *:nth-child(8) { animation-delay: .3s; } .stagger > *:nth-child(n+9) { animation-delay: .34s; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}

/* ---------- Responsive (desktop-focused, graceful on small screens) ---------- */
@media (max-width: 1024px) {
  .app-content { padding: 22px 20px 56px; }
  .topbar { padding: 0 20px; }
  body:not(.sidebar-collapsed) .sidebar { width: var(--sidebar-w-collapsed); }
  body:not(.sidebar-collapsed) .app-main { margin-left: var(--sidebar-w-collapsed); }
  .sidebar-label, .brand-text, .sidebar-section { display: none; }
  .sidebar-link, .sidebar-ask { justify-content: center; padding-left: 0; padding-right: 0; }
  .sidebar-footer { flex-direction: column; }
  .gc-panel { width: calc(100vw - 32px); right: 16px; bottom: 16px; }
}

/* ---------- Print ---------- */
@media print {
  .sidebar, .topbar, .aurora, .gc-fab, .gc-panel, .announcement, .impersonation-bar, .no-print, .toast-root { display: none !important; }
  html, body.app-body { background: #fff !important; color: #111 !important; }
  .app-main { margin: 0 !important; }
  .app-content { padding: 0 !important; max-width: none !important; }
  .card, .glass { background: none !important; border: 0 !important; box-shadow: none !important; backdrop-filter: none !important; padding: 0 !important; }
  .prose-ss, .prose-ss p, .prose-ss li, .prose-ss td { color: #111 !important; }
  .prose-ss h1, .prose-ss h2, .prose-ss h3, .prose-ss h4, .prose-ss strong { color: #000 !important; }
  .prose-ss h2 { border-color: #ddd !important; }
  .prose-ss pre { background: #f6f8fa !important; border-color: #ddd !important; }
  .prose-ss code:not(pre code) { color: #9d174d !important; background: #f3f4f6 !important; }
  .prose-ss blockquote { background: #f5f3ff !important; color: #333 !important; }
  .prose-ss th { background: #f3f4f6 !important; color: #000 !important; border-color: #ccc !important; }
  .prose-ss td { border-color: #ddd !important; }
  .print-only { display: block !important; }
  a { color: #111 !important; }
}
.print-only { display: none; }

/* ========================================================================== 
   StudySkewl global refinement pass
   --------------------------------------------------------------------------
   This layer intentionally lives in the shared stylesheet. It normalizes the
   visual language used by every page without changing the markup contracts,
   state classes, or JavaScript selectors used by the module styles.
   ========================================================================== */

/* ---------- Refined design tokens ---------- */
:root {
  --bg: #080a12;
  --bg-2: #0d1020;
  --bg-3: #12162a;
  --surface: rgba(255, 255, 255, .045);
  --surface-2: rgba(255, 255, 255, .065);
  --surface-3: rgba(255, 255, 255, .095);
  --surface-solid: #101429;
  --surface-elevated: #151a32;
  --border: rgba(148, 163, 184, .17);
  --border-soft: rgba(148, 163, 184, .115);
  --border-strong: rgba(203, 213, 225, .25);
  --border-focus: rgb(var(--accent) / .72);
  --text: #eef2ff;
  --text-strong: #ffffff;
  --text-soft: #d8def0;
  --muted: #9aa6c1;
  --muted-strong: #bac4d9;
  --muted-dim: #71809e;
  --danger: #fb7185;
  --success: #4ade80;
  --warning: #fbbf24;
  --info: #38bdf8;
  --radius-xs: 8px;
  --radius-sm: 10px;
  --radius-md: 14px;
  --radius: 16px;
  --radius-lg: 20px;
  --radius-xl: 26px;
  --sidebar-w: 264px;
  --sidebar-w-collapsed: 78px;
  --topbar-h: 68px;
  --content-max: 1520px;
  --content-gutter: clamp(20px, 3vw, 48px);
  --control-h: 42px;
  --control-h-sm: 34px;
  --control-h-lg: 50px;
  --focus-ring: 0 0 0 3px rgb(var(--accent) / .22);
  --shadow-xs: 0 2px 8px rgba(0, 0, 0, .16);
  --shadow-sm: 0 8px 24px -16px rgba(0, 0, 0, .8);
  --shadow-md: 0 20px 46px -24px rgba(0, 0, 0, .85);
  --shadow-lg: 0 36px 90px -36px rgba(0, 0, 0, .9);
  --ease: cubic-bezier(.22, .75, .2, 1);
}

/* ---------- Predictable global geometry ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { min-width: 320px; overflow-x: hidden; background: var(--bg); }
body.app-body {
  min-width: 320px;
  overflow-x: hidden;
  overflow-x: clip; /* clip, not hidden: hidden makes body a 2nd scroll container (double scrollbar) */
  background:
    radial-gradient(1000px 560px at 60% -12%, rgb(var(--accent) / .07), transparent 68%),
    linear-gradient(180deg, #080a12 0%, #090b16 45%, #080a12 100%);
  color: var(--text);
}
body.app-body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background: linear-gradient(90deg, rgba(255,255,255,.012) 1px, transparent 1px), linear-gradient(rgba(255,255,255,.012) 1px, transparent 1px);
  background-size: 72px 72px;
  mask-image: linear-gradient(to bottom, rgba(0,0,0,.65), transparent 70%);
}

body.app-body :where(h1, h2, h3, h4, h5, h6, p, ul, ol, dl) { margin-block-start: 0; }
body.app-body :where(button, input, select, textarea) { font: inherit; }
body.app-body :where(button, [role="button"], a, input, select, textarea, summary) { -webkit-tap-highlight-color: transparent; }
body.app-body :where(img, svg, video, iframe) { max-width: 100%; }
body.app-body :where(button, select) { text-transform: none; }
body.app-body :where(button) { color: inherit; }
body.app-body :where(button, a, input, select, textarea, summary):focus { outline: none; }
body.app-body :where(a, button, [role="button"], input, select, textarea, summary):focus-visible {
  outline: 2px solid rgb(var(--accent));
  outline-offset: 3px;
}
body.app-body :where(a, button, [role="button"]) { transition: color .18s var(--ease), background-color .18s var(--ease), border-color .18s var(--ease), box-shadow .18s var(--ease), transform .18s var(--ease); }
body.app-body :where(table) { max-width: 100%; }
body.app-body :where(pre, code, kbd) { font-variant-ligatures: none; }

/* Keep browser autofill from introducing a bright input stripe. */
body.app-body :where(input, textarea, select):-webkit-autofill,
body.app-body :where(input, textarea, select):-webkit-autofill:hover,
body.app-body :where(input, textarea, select):-webkit-autofill:focus {
  -webkit-text-fill-color: var(--text);
  -webkit-box-shadow: 0 0 0 1000px #11162a inset;
  transition: background-color 9999s ease-out 0s;
}

/* ---------- Shell and page rhythm ---------- */
.app-shell {
  min-height: 100svh;
  isolation: isolate;
  align-items: stretch;
}
.app-main {
  min-height: 100svh;
  margin-left: var(--sidebar-w);
  background: linear-gradient(180deg, rgba(8,10,18,.05), rgba(8,10,18,.32));
}
.app-content {
  width: min(100%, var(--content-max));
  min-height: calc(100svh - var(--topbar-h));
  padding: 34px var(--content-gutter) 72px;
  margin-inline: auto;
}
.app-content > :where(.page-header, .dash-hero) { margin-bottom: 30px; }
.app-content > :where(.section-title) { margin-top: 30px; margin-bottom: 14px; }
.app-content > :where(.section-title):first-child { margin-top: 0; }
.app-content :where(.grid, .flex) { min-width: 0; }
.app-content :where(.grid > *, .flex > *) { min-width: 0; }
.bare-main {
  min-height: 100svh;
  padding: clamp(16px, 4vw, 48px);
  background:
    radial-gradient(700px 460px at 12% 8%, rgb(var(--accent) / .12), transparent 66%),
    radial-gradient(650px 500px at 92% 86%, rgb(var(--accent-2) / .08), transparent 66%);
}
.bare-main > * { width: 100%; }

/* ---------- Sidebar alignment ---------- */
.sidebar {
  width: var(--sidebar-w);
  padding: 20px 14px 16px;
  gap: 8px;
  background:
    linear-gradient(180deg, rgba(17, 21, 42, .92), rgba(9, 11, 22, .96)),
    radial-gradient(420px 600px at 0 0, rgb(var(--accent) / .1), transparent 70%);
  border-right-color: rgba(148, 163, 184, .16);
  box-shadow: 18px 0 50px -42px rgba(0,0,0,.95);
}
.sidebar-brand {
  min-height: 42px;
  gap: 11px;
  padding: 2px 9px 16px;
}
.brand-mark {
  width: 38px;
  height: 38px;
  border: 1px solid rgba(255,255,255,.12);
  border-radius: 13px;
  background: linear-gradient(145deg, rgba(255,255,255,.1), rgba(255,255,255,.025));
  box-shadow: 0 10px 24px -12px rgb(var(--accent) / .85), inset 0 1px 0 rgba(255,255,255,.16);
}
.brand-mark img { width: 24px; height: 24px; }
.brand-text { font-size: 1.22rem; letter-spacing: -.035em; }
.sidebar-ask {
  min-height: 44px;
  margin-bottom: 8px;
  padding: 7px 10px;
  border-color: rgb(var(--accent) / .3);
  border-radius: 13px;
  background: linear-gradient(135deg, rgb(var(--accent) / .19), rgb(var(--accent-2) / .07));
  box-shadow: inset 0 1px 0 rgba(255,255,255,.08), 0 10px 22px -18px rgb(var(--accent) / .8);
}
.sidebar-ask:hover { transform: translateY(-1px); border-color: rgb(var(--accent) / .52); }
.sidebar-nav { margin-inline: -2px; padding-inline: 2px; }
.sidebar-section {
  padding: 17px 12px 7px;
  color: #7886a8;
  font-size: .64rem;
  font-weight: 700;
  letter-spacing: .14em;
}
.sidebar-link {
  min-height: 42px;
  gap: 12px;
  padding: 9px 12px;
  margin: 2px 0;
  border: 1px solid transparent;
  border-radius: 12px;
  color: #aeb9d2;
  line-height: 1.2;
}
.sidebar-link:hover {
  background: rgba(255,255,255,.055);
  border-color: rgba(255,255,255,.06);
  color: #fff;
}
.sidebar-link.active {
  background: linear-gradient(90deg, rgb(var(--accent) / .2), rgb(var(--accent-2) / .06));
  border-color: rgb(var(--accent) / .24);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.045);
}
.sidebar-link.active::before { left: -3px; top: 8px; bottom: 8px; width: 3px; }
.sidebar-footer {
  gap: 8px;
  padding-top: 12px;
  border-top-color: rgba(148, 163, 184, .15);
}
.sidebar-user { min-height: 42px; padding: 6px 7px; }
.sidebar-user:hover { background: rgba(255,255,255,.055); }
.sidebar-collapse { flex: 0 0 auto; }
body.sidebar-collapsed .sidebar { width: var(--sidebar-w-collapsed); }
body.sidebar-collapsed .app-main { margin-left: var(--sidebar-w-collapsed); }
body.sidebar-collapsed .sidebar { padding-inline: 10px; }
body.sidebar-collapsed .sidebar-brand { justify-content: center; padding-inline: 0; }
body.sidebar-collapsed .sidebar-ask { margin-inline: 1px; }
body.sidebar-collapsed .sidebar-link.active::before { left: -10px; }

/* ---------- Topbar and global announcements ---------- */
.topbar {
  height: var(--topbar-h);
  padding-inline: var(--content-gutter);
  gap: 22px;
  background: rgba(8, 10, 18, .78);
  border-bottom-color: rgba(148, 163, 184, .14);
  box-shadow: 0 12px 30px -28px rgba(0,0,0,.9);
}
.topbar-search {
  min-width: 0;
  width: min(560px, 100%);
  height: 42px;
  padding-inline: 14px 9px;
  border-color: rgba(148, 163, 184, .18);
  border-radius: 12px;
  background: rgba(255,255,255,.045);
  color: var(--muted-strong);
}
.topbar-search:hover,
.topbar-search:focus-visible {
  border-color: rgb(var(--accent) / .46);
  background: rgba(255,255,255,.065);
  box-shadow: 0 0 0 3px rgb(var(--accent) / .1);
}
.topbar > :last-child { flex: 0 0 auto; }
.notif-dot { top: 2px; right: 1px; border: 2px solid #0b0e1a; }
.impersonation-bar {
  min-height: 42px;
  padding: 8px var(--content-gutter);
  background: linear-gradient(90deg, rgba(245,158,11,.17), rgba(245,158,11,.035));
  border-bottom-color: rgba(245,158,11,.24);
}
.announcement {
  min-height: 46px;
  margin: 18px var(--content-gutter) 0;
  padding: 10px 13px;
  border-radius: 13px;
  box-shadow: 0 10px 24px -22px rgba(0,0,0,.8);
}
.announcement strong { color: currentColor; font-weight: 700; }

/* ---------- Page headings and common alignment primitives ---------- */
.page-header {
  align-items: center;
  gap: 20px;
  min-width: 0;
  margin-bottom: 30px;
}
.page-header > :first-child { min-width: 0; }
.page-header > :last-child { flex: 0 0 auto; }
.page-header-icon {
  width: 48px;
  height: 48px;
  border-radius: 14px;
  box-shadow: 0 14px 28px -18px rgb(var(--accent) / .95), inset 0 1px 0 rgba(255,255,255,.24);
}
.page-title { font-size: clamp(1.55rem, 2.2vw, 2rem); letter-spacing: -.035em; }
.page-subtitle { max-width: 70ch; color: var(--muted); line-height: 1.55; }
.section-title { font-size: 1.02rem; letter-spacing: -.012em; }
.font-display { letter-spacing: -.02em; }
.text-muted { color: var(--muted); }
.truncate { min-width: 0; }
.divider { margin: 18px 0; background: rgba(148, 163, 184, .14); }

/* ---------- Surfaces and cards ---------- */
.glass,
.glass-strong,
.card {
  border-color: var(--border);
  box-shadow: var(--shadow-sm), inset 0 1px 0 rgba(255,255,255,.045);
}
.glass { background: linear-gradient(145deg, rgba(255,255,255,.055), rgba(255,255,255,.025)); }
.glass-strong { background: linear-gradient(145deg, rgba(22, 27, 53, .88), rgba(13, 16, 33, .9)); }
.card {
  padding: 22px;
  border-radius: var(--radius);
  background: linear-gradient(145deg, rgba(255,255,255,.06), rgba(255,255,255,.026));
}
.card:hover { border-color: rgba(203, 213, 225, .22); }
.card.card-flush { padding: 0; }
.card-hover:hover {
  border-color: rgb(var(--accent) / .42);
  box-shadow: 0 22px 46px -26px rgb(var(--accent) / .5), inset 0 1px 0 rgba(255,255,255,.07);
}
.gradient-border::before { opacity: .8; }
.empty-state {
  min-height: 210px;
  display: grid;
  place-items: center;
  align-content: center;
  padding: 44px 24px;
  border-color: rgba(148, 163, 184, .2);
  background: rgba(255,255,255,.018);
}
.empty-state > * { max-width: 48rem; }
.empty-state-icon { width: 62px; height: 62px; margin-bottom: 14px; border-radius: 18px; }
.stat-card { min-width: 0; gap: 13px; }
.stat-icon { width: 42px; height: 42px; border-radius: 12px; }
.stat-value { font-size: 1.5rem; font-variant-numeric: tabular-nums; }
.stat-label { line-height: 1.35; }

/* ---------- Buttons and icon buttons ---------- */
.btn {
  min-width: 0;
  height: var(--control-h);
  padding-inline: 15px;
  border-radius: 11px;
  border-color: transparent;
  letter-spacing: -.005em;
  box-shadow: 0 1px 0 rgba(255,255,255,.05) inset;
}
.btn > svg, .btn > i, .btn-icon > svg, .btn-icon > i { flex: 0 0 auto; }
.btn:hover:not(:disabled):not([aria-disabled="true"]) { transform: translateY(-1px); }
.btn-primary { box-shadow: 0 10px 22px -14px rgb(var(--accent) / .95), inset 0 1px 0 rgba(255,255,255,.24); }
.btn-secondary { background: rgba(255,255,255,.065); border-color: rgba(203, 213, 225, .22); }
.btn-secondary:hover:not(:disabled) { border-color: rgba(203, 213, 225, .38); background: rgba(255,255,255,.1); }
.btn-ghost { border-color: transparent; }
.btn-danger, .btn-success { box-shadow: inset 0 1px 0 rgba(255,255,255,.06); }
.btn-sm { height: var(--control-h-sm); padding-inline: 11px; border-radius: 9px; }
.btn-lg { height: var(--control-h-lg); padding-inline: 20px; border-radius: 13px; }
.btn-icon,
.btn-sm-icon {
  display: inline-grid;
  place-items: center;
  flex: 0 0 auto;
  width: 38px;
  height: 38px;
  padding: 0;
  border: 1px solid transparent;
  border-radius: 10px;
  color: #aab6d0;
  background: transparent;
}
.btn-sm-icon { width: 32px; height: 32px; border-radius: 8px; }
.btn-icon:hover, .btn-sm-icon:hover { color: #fff; background: rgba(255,255,255,.08); border-color: rgba(255,255,255,.08); }
.btn-icon:focus-visible, .btn-sm-icon:focus-visible { outline: 2px solid rgb(var(--accent)); outline-offset: 2px; }
.btn:disabled, .btn-icon:disabled, .btn-sm-icon:disabled { opacity: .48; }
.btn-block { min-width: 0; }

/* ---------- Forms: one shared control language ---------- */
.label {
  margin-bottom: 7px;
  color: #d4dbeb;
  font-size: .78rem;
  letter-spacing: .005em;
}
.hint { color: var(--muted-dim); line-height: 1.45; }
.input, .select, .textarea {
  display: block;
  width: 100%;
  max-width: 100%;
  border: 1px solid rgba(148, 163, 184, .24);
  border-radius: 11px;
  background: rgba(255,255,255,.045);
  color: var(--text);
  line-height: 1.3;
  box-shadow: inset 0 1px 0 rgba(255,255,255,.025);
}
.input, .select { height: var(--control-h); padding-inline: 13px; }
.textarea { min-height: 112px; padding: 12px 13px; }
.input:hover, .select:hover, .textarea:hover { border-color: rgba(203, 213, 225, .36); background: rgba(255,255,255,.06); }
.input:focus, .select:focus, .textarea:focus {
  border-color: var(--border-focus);
  background: rgba(255,255,255,.065);
  box-shadow: var(--focus-ring), inset 0 1px 0 rgba(255,255,255,.035);
}
.input[aria-invalid="true"], .select[aria-invalid="true"], .textarea[aria-invalid="true"] {
  border-color: rgb(251 113 133 / .68);
  box-shadow: 0 0 0 3px rgb(251 113 133 / .14);
}
.input::placeholder, .textarea::placeholder { color: #71809d; opacity: 1; }
.select { padding-right: 40px; cursor: pointer; }
.select:disabled, .input:disabled, .textarea:disabled { cursor: not-allowed; opacity: .56; }
.select option, .select optgroup { background: #12172c; color: #eef2ff; }
.input-group { min-width: 0; }
.input-group > svg, .input-group > i { left: 13px; color: #7785a4; }
.input-group > .input { padding-left: 40px; }
.input-group:focus-within > svg, .input-group:focus-within > i { color: rgb(var(--accent)); }
.checkbox {
  width: 18px;
  height: 18px;
  margin: 0;
  accent-color: rgb(var(--accent));
  border-color: rgba(203, 213, 225, .3);
  vertical-align: middle;
}
.checkbox:focus-visible { outline: 2px solid rgb(var(--accent)); outline-offset: 2px; box-shadow: none; }
.toggle { width: 44px; height: 26px; }
.toggle span { border-color: rgba(203,213,225,.25); background: rgba(255,255,255,.1); }
.toggle span::before { width: 20px; height: 20px; }
.toggle input:focus-visible + span { outline: 2px solid rgb(var(--accent)); outline-offset: 3px; }
.toggle input:checked + span::before { transform: translateX(18px); }
.segmented {
  gap: 3px;
  padding: 3px;
  border-color: rgba(148,163,184,.17);
  border-radius: 11px;
  background: rgba(255,255,255,.045);
}
.segmented button, .segmented label { min-height: 30px; display: inline-flex; align-items: center; justify-content: center; padding-inline: 11px; border-radius: 8px; }
.segmented button:hover, .segmented label:hover { color: #fff; background: rgba(255,255,255,.05); }
.segmented button.active, .segmented input:checked + label, .segmented label.active { background: rgb(var(--accent) / .18); color: #fff; box-shadow: inset 0 0 0 1px rgb(var(--accent) / .3); }
.range { height: 6px; cursor: pointer; }

/* ---------- Badges, chips, avatars, tabs ---------- */
.badge, .course-badge {
  min-width: 0;
  border-color: rgba(148,163,184,.2);
  line-height: 1;
}
.badge { height: 23px; padding-inline: 8px; }
.chip { border-color: rgba(148,163,184,.23); background: rgba(255,255,255,.045); }
.chip:hover { border-color: rgba(203,213,225,.4); background: rgba(255,255,255,.075); }
.chip:focus-visible { outline: 2px solid rgb(var(--accent)); outline-offset: 2px; }
.kbd { border-color: rgba(148,163,184,.22); background: rgba(255,255,255,.07); color: #a9b4cb; }
.avatar { box-shadow: 0 0 0 2px rgba(255,255,255,.1), 0 8px 18px -14px rgba(0,0,0,.8); }
.tabs { gap: 5px; border-bottom-color: rgba(148,163,184,.16); }
.tab { min-height: 42px; padding: 10px 13px; border-radius: 9px 9px 0 0; }
.tab:hover { background: rgba(255,255,255,.04); }
.tab:focus-visible { outline-offset: -2px; }
.tab.active::after { left: 9px; right: 9px; height: 3px; }

/* ---------- Dropdowns and menus ---------- */
[data-dropdown] { position: relative; }
.dropdown,
.dropdown-menu {
  position: absolute;
  top: calc(100% + 9px);
  left: 0;
  z-index: 60;
  width: max-content;
  min-width: 216px;
  max-width: min(360px, calc(100vw - 24px));
  padding: 6px;
  overflow: hidden;
  border: 1px solid rgba(203, 213, 225, .24);
  border-radius: 14px;
  background: rgba(17, 21, 42, .96);
  box-shadow: 0 24px 56px -22px rgba(0,0,0,.92), 0 0 0 1px rgba(255,255,255,.025) inset;
  backdrop-filter: blur(24px) saturate(145%);
  -webkit-backdrop-filter: blur(24px) saturate(145%);
  opacity: 0;
  transform: translateY(-5px) scale(.985);
  transform-origin: top right;
  pointer-events: none;
  visibility: hidden;
  transition: opacity .16s var(--ease), transform .16s var(--ease), visibility .16s;
}
.dropdown-right, [data-dropdown] > .dropdown-menu.dropdown-right { right: 0; left: auto; }
.dropdown-left { right: auto; left: 0; }
[data-dropdown].open > .dropdown,
[data-dropdown].open > .dropdown-menu,
.dropdown.open,
.dropdown-menu.open {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
  visibility: visible;
}
/* Some existing templates use .dropdown on the trigger wrapper as well as on
   the panel. Treat that variant as a clean positioning wrapper. */
.dropdown[data-dropdown] {
  top: auto;
  left: auto;
  right: auto;
  z-index: auto;
  width: auto;
  min-width: 0;
  max-width: none;
  padding: 0;
  overflow: visible;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
  opacity: 1;
  transform: none;
  pointer-events: auto;
  visibility: visible;
}
.dropdown[data-dropdown] > .dropdown-menu { top: calc(100% + 9px); }
.menu-item {
  width: 100%;
  min-height: 36px;
  padding: 8px 10px;
  border: 1px solid transparent;
  border-radius: 9px;
  color: #c8d1e4;
  line-height: 1.25;
}
.menu-item:hover, .menu-item.active, .menu-item:focus-visible {
  color: #fff;
  background: rgba(255,255,255,.075);
  border-color: rgba(255,255,255,.06);
}
.menu-item:focus-visible { outline: 2px solid rgb(var(--accent)); outline-offset: -2px; }
.menu-item svg { flex: 0 0 auto; color: #9aa8c4; }
.menu-item:hover svg, .menu-item.active svg { color: rgb(var(--accent)); }
.dropdown > .divider, .dropdown-menu > .divider { margin: 5px 2px; }
.dropdown :where(.border-b, .border-t), .dropdown-menu :where(.border-b, .border-t) { border-color: rgba(148,163,184,.13) !important; }

/* ---------- Tables and data density ---------- */
.table-wrap {
  overflow: auto;
  border-color: rgba(148,163,184,.17);
  background: rgba(255,255,255,.028);
  box-shadow: var(--shadow-xs);
}
.table-ss {
  min-width: 640px;
  table-layout: auto;
  border-collapse: separate;
  border-spacing: 0;
}
.table-ss th {
  height: 42px;
  padding: 10px 15px;
  color: #8f9dbb;
  background: rgba(255,255,255,.045);
  border-bottom-color: rgba(148,163,184,.16);
  vertical-align: middle;
}
.table-ss td {
  min-height: 50px;
  padding: 13px 15px;
  color: #d8deed;
  border-bottom-color: rgba(148,163,184,.09);
  vertical-align: middle;
}
.table-ss tbody tr:hover { background: rgba(var(--accent) / .055); }
.table-ss tbody tr:focus-within { background: rgb(var(--accent) / .075); }
.table-ss tbody tr:last-child td:first-child { border-bottom-left-radius: var(--radius); }
.table-ss tbody tr:last-child td:last-child { border-bottom-right-radius: var(--radius); }
.table-ss :where(th, td).text-right { text-align: right; }
.table-ss :where(th, td).text-center { text-align: center; }

/* ---------- Progress, loading, and feedback ---------- */
.progress, .progress-mini, .mastery-bar {
  min-width: 0;
  background: rgba(255,255,255,.085);
  box-shadow: inset 0 1px 2px rgba(0,0,0,.2);
}
.progress { height: 8px; }
.progress > span { box-shadow: 0 0 13px rgb(var(--accent) / .45); }
.ring { flex: 0 0 auto; }
.skeleton { background-color: rgba(255,255,255,.045); }
.spinner { flex: 0 0 auto; }
.ai-loader { min-height: 240px; justify-content: center; }
.toast-root { width: min(100% - 32px, 520px); bottom: 22px; }
.toast {
  width: 100%;
  min-width: 0;
  padding: 12px 15px;
  border-color: rgba(203,213,225,.25);
  box-shadow: var(--shadow-lg);
}

/* ---------- Modals and command palette ---------- */
.modal-backdrop {
  padding: clamp(12px, 3vw, 32px);
  background: rgba(3, 5, 12, .78);
  overscroll-behavior: contain;
}
.modal {
  max-width: 560px;
  max-height: min(760px, calc(100svh - 32px));
  border-radius: var(--radius-lg);
  border-color: rgba(203,213,225,.25);
  background: linear-gradient(155deg, rgba(24,29,57,.98), rgba(12,15,31,.985));
  box-shadow: var(--shadow-lg), 0 0 0 1px rgba(255,255,255,.03) inset;
}
.modal-sm { max-width: 420px; }
.modal-lg { max-width: 800px; }
.modal-xl { max-width: 1120px; }
.modal-header { min-height: 62px; padding: 16px 22px; border-bottom-color: rgba(148,163,184,.15); }
.modal-title { letter-spacing: -.02em; }
.modal-body { min-height: 0; padding: 22px; overscroll-behavior: contain; }
.modal-footer { min-height: 64px; padding: 14px 22px; border-top-color: rgba(148,163,184,.15); }
.palette {
  width: min(680px, 100%);
  max-width: 680px;
  margin-top: 10vh;
  overflow: hidden;
}
.palette-input { height: 60px; }
.palette-results { border-top-color: rgba(148,163,184,.15); }
.palette-item { min-height: 50px; }
.palette-item:hover { background: rgba(255,255,255,.055); }

/* ---------- Common content layouts ---------- */
.page-header :where(.flex, .grid),
.dash-hero :where(.flex, .grid),
.admin-pagination,
.profile-header-card,
.welcome-banner,
.breadcrumb { min-width: 0; }
.dash-hero { align-items: stretch; gap: 22px; }
.dash-greeting { font-size: clamp(1.6rem, 2.4vw, 2.05rem); }
.briefing-card { min-width: min(100%, 320px); }
.onboard-step { min-height: 52px; }
.continue-card { min-height: 104px; }
.exam-card { min-width: 152px; }
.heat-grid { scrollbar-width: thin; padding-bottom: 4px; }
.heat-cell { flex: 0 0 auto; }

/* ---------- Link and rich text consistency ---------- */
.prose-ss { color: #d9dfed; line-height: 1.75; }
.prose-ss :where(h1, h2, h3, h4) { scroll-margin-top: 96px; }
.prose-ss a { color: color-mix(in srgb, rgb(var(--accent-2)) 88%, white); }
.prose-ss a:hover { color: #fff; }
.prose-ss blockquote, .prose-ss .callout { box-shadow: inset 0 1px 0 rgba(255,255,255,.04); }
.prose-ss :where(table) { display: block; max-width: 100%; overflow-x: auto; }
.prose-ss :where(th, td) { min-width: 120px; }

/* ---------- Scroll behavior ---------- */
:where(.sidebar-nav, .app-content, .modal-body, .gc-panel, .palette-results, .table-wrap) {
  overscroll-behavior: contain;
  scrollbar-gutter: stable;
}
::selection { background: rgb(var(--accent) / .34); color: #fff; }
::-webkit-scrollbar { width: 11px; height: 11px; }
::-webkit-scrollbar-thumb { background: rgba(148,163,184,.18); border-width: 3px; }
::-webkit-scrollbar-thumb:hover { background: rgba(203,213,225,.3); background-clip: content-box; }

/* ---------- Responsive alignment ---------- */
@media (max-width: 1280px) {
  :root { --content-gutter: clamp(20px, 2.6vw, 32px); }
  .app-content { padding-top: 28px; }
  .page-header { margin-bottom: 26px; }
}

@media (max-width: 1024px) {
  :root { --content-gutter: 22px; }
  .app-content { padding-bottom: 60px; }
  body:not(.sidebar-collapsed) .sidebar { width: var(--sidebar-w-collapsed); padding-inline: 10px; }
  body:not(.sidebar-collapsed) .app-main { margin-left: var(--sidebar-w-collapsed); }
  body:not(.sidebar-collapsed) .sidebar-brand { justify-content: center; padding-inline: 0; }
  body:not(.sidebar-collapsed) .sidebar-link,
  body:not(.sidebar-collapsed) .sidebar-ask { justify-content: center; padding-inline: 0; }
  body:not(.sidebar-collapsed) .sidebar-footer { flex-direction: column; }
  .sidebar-link.active::before { left: -10px; }
  .topbar { gap: 14px; }
  .topbar-search { flex: 1 1 auto; }
  .page-header { align-items: flex-start; }
  .page-header > :last-child { margin-left: auto; }
}

@media (max-width: 720px) {
  :root { --content-gutter: 16px; --topbar-h: 62px; }
  .app-content { padding: 22px 16px 48px; }
  .topbar { height: var(--topbar-h); padding-inline: 16px; }
  .topbar-search { height: 40px; }
  .topbar-search > .kbd { display: none; }
  .page-header { gap: 13px; margin-bottom: 22px; }
  .page-header-icon { width: 42px; height: 42px; border-radius: 12px; }
  .page-header > :last-child { width: 100%; margin-left: 0; }
  .page-header > :last-child:where(.btn, .btn-group) { width: auto; }
  .announcement { margin-inline: 16px; }
  .card { padding: 18px; }
  .modal-backdrop { align-items: flex-end; padding: 10px; }
  .modal { max-height: calc(100svh - 20px); border-radius: 20px; }
  .modal-header, .modal-body, .modal-footer { padding-inline: 17px; }
  .modal-footer { flex-wrap: wrap; }
  .modal-footer > .btn { flex: 1 1 auto; }
  .dropdown, .dropdown-menu { max-width: calc(100vw - 20px); }
  .toast-root { bottom: 14px; }
  .toast { max-width: 100%; }
}

@media (max-width: 520px) {
  .topbar > :last-child > button:not([data-dropdown-toggle]) { display: none; }
  .topbar > :last-child { margin-left: auto; }
  .page-title { font-size: 1.45rem; }
  .page-subtitle { font-size: .86rem; }
  .page-header > :last-child { display: flex; flex-wrap: wrap; gap: 8px; }
  .page-header > :last-child .btn { flex: 1 1 auto; }
  .table-ss { min-width: 560px; }
  .table-ss th, .table-ss td { padding-inline: 12px; }
  .input, .select { font-size: .875rem; }
  .profile-stats { width: 100%; margin-left: 0; justify-content: space-between; }
  .modal-footer > .btn { width: 100%; }
}

/* ---------- Cross-page composition bridge ---------- */
/* These selectors are deliberately scoped below the shared app shell. They
   improve page-level alignment while leaving each module's behavior and
   state-specific styling intact. */
body.app-body .login-shell {
  width: min(1120px, 100%);
  min-height: 640px;
  border-color: rgba(203,213,225,.22);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-lg);
}
body.app-body .login-brand,
body.app-body .login-form-side {
  min-width: 0;
  padding: clamp(30px, 5vw, 58px);
}
body.app-body .login-form-side { background: rgba(10,13,26,.72); }
body.app-body .login-card { max-width: 410px; padding: 0; }
body.app-body .login-feature { border-color: rgba(203,213,225,.13); background: rgba(255,255,255,.035); }
body.app-body .login-alert { margin-bottom: 20px; border-color: rgb(251 113 133 / .32); }
body.app-body .invite-shell { width: min(520px, 100%); }
body.app-body .invite-card { padding: clamp(22px, 5vw, 38px); }

body.app-body .files-layout {
  grid-template-columns: minmax(208px, 240px) minmax(0, 1fr);
  gap: clamp(18px, 2.4vw, 28px);
}
body.app-body .files-rail {
  top: calc(var(--topbar-h) + 18px);
  padding: 16px;
  border-color: rgba(148,163,184,.16);
  background: linear-gradient(160deg, rgba(255,255,255,.05), rgba(255,255,255,.024));
  box-shadow: var(--shadow-sm);
}
body.app-body .files-rail-link { min-height: 38px; padding: 8px 10px; }
body.app-body .files-main { width: 100%; }
body.app-body .files-grid { grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 16px; }
body.app-body .file-card { min-width: 0; min-height: 164px; }
body.app-body .file-card.card { padding: 17px; }
body.app-body .fc-name { overflow-wrap: anywhere; }
body.app-body .fc-actions { z-index: 2; }
body.app-body .viewer-layout {
  grid-template-columns: minmax(0, 1.35fr) minmax(300px, 1fr);
  gap: 20px;
  min-height: 520px;
}
body.app-body .viewer-left iframe,
body.app-body .viewer-text-reader,
body.app-body .viewer-right { border-color: rgba(148,163,184,.17); box-shadow: var(--shadow-sm); }
body.app-body .viewer-text-reader,
body.app-body .viewer-right-body { padding: clamp(16px, 2vw, 22px); }

body.app-body .admin-nav {
  align-items: center;
  gap: 5px;
  padding: 5px;
  border-color: rgba(148,163,184,.16);
  background: rgba(255,255,255,.035);
}
body.app-body .admin-nav-tab { min-height: 36px; padding-inline: 12px; border: 1px solid transparent; }
body.app-body .admin-nav-tab.active { border-color: rgb(var(--accent) / .28); }
body.app-body .admin-pagination { padding: 16px 2px 2px; }
body.app-body .admin-pagination .pg-btns { align-items: center; }
body.app-body .stat-grid { gap: 16px; }
body.app-body .role-card,
body.app-body .cred-card { border-color: rgba(148,163,184,.17); background: rgba(255,255,255,.035); }
body.app-body .perm-matrix-wrap,
body.app-body .table-wrap-sticky { border: 1px solid rgba(148,163,184,.16); box-shadow: var(--shadow-xs); }
body.app-body .perm-matrix thead th,
body.app-body .perm-matrix tbody th,
body.app-body .table-wrap-sticky .table-ss thead th { background: #11162b; }

body.app-body .profile-header-card {
  min-width: 0;
  padding: clamp(20px, 3vw, 30px);
  border-color: rgba(203,213,225,.19);
}
body.app-body .profile-header-card > .flex-1,
body.app-body .profile-header-card .min-w-0 { min-width: 0; }
body.app-body .profile-stats { flex-wrap: wrap; align-items: center; }
body.app-body .profile-stat { min-width: 72px; }
body.app-body .welcome-banner {
  min-width: 0;
  padding: clamp(18px, 3vw, 24px) clamp(18px, 3.4vw, 28px);
  border-color: rgb(var(--accent) / .27);
}
body.app-body .course-grid { gap: 16px; }
body.app-body .course-card { min-width: 0; min-height: 218px; }
body.app-body .course-card-fields { align-items: start; }
body.app-body .pref-row,
body.app-body .session-row { min-width: 0; padding-block: 16px; }
body.app-body .pref-row > :first-child,
body.app-body .session-row > :first-child { min-width: 0; }
body.app-body .search-hero { width: min(100%, 720px); }
body.app-body .search-result-row { min-width: 0; }
body.app-body .search-result-row > :not(.search-result-icon) { min-width: 0; }

body.app-body .editor-layout,
body.app-body .generate-layout,
body.app-body .note-view-layout {
  min-width: 0;
  gap: clamp(16px, 2vw, 24px);
}
body.app-body .editor-main,
body.app-body .editor-panel,
body.app-body .editor-surface,
body.app-body .note-view-main,
body.app-body .note-view-toc { min-width: 0; }
body.app-body .editor-toolbar {
  min-height: 48px;
  align-items: center;
  gap: 4px;
  padding: 6px 8px;
  border-color: rgba(148,163,184,.17);
  background: rgba(255,255,255,.045);
}
body.app-body .editor-toolbar :where(.tb-btn, .bm-btn) { min-width: 32px; min-height: 32px; border-radius: 8px; }
body.app-body .editor-surface { border-color: rgba(148,163,184,.18); background: rgba(255,255,255,.026); }
body.app-body .note-title-input { min-width: 0; }
body.app-body .note-view-toc { position: sticky; top: calc(var(--topbar-h) + 18px); align-self: start; }
body.app-body .ai-panel { border-color: rgba(148,163,184,.18); box-shadow: var(--shadow-sm); }
body.app-body .ai-panel-head,
body.app-body .ai-panel-foot { border-color: rgba(148,163,184,.14); }
body.app-body .slash-menu,
body.app-body .bubble-menu { border-color: rgba(203,213,225,.23); box-shadow: var(--shadow-md); }

body.app-body .quiz-take {
  grid-template-columns: minmax(220px, 260px) minmax(0, 1fr);
  gap: clamp(16px, 2vw, 24px);
}
body.app-body .quiz-nav { min-width: 0; }
body.app-body .quiz-nav-grid { gap: 7px; }
body.app-body .question-card { min-width: 0; padding: clamp(18px, 3vw, 28px); }
body.app-body .option-card,
body.app-body .tf-btn { min-width: 0; }
body.app-body .option-card { min-height: 58px; }
body.app-body .breakdown-bar-row { grid-template-columns: minmax(92px, 150px) minmax(0, 1fr) 46px; }
body.app-body .study-root { width: min(100%, 800px); }
body.app-body .study-toolbar { min-width: 0; flex-wrap: wrap; }
body.app-body .study-rating-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; }
body.app-body .study-rating-btn { min-width: 0; }
body.app-body .deck-card,
body.app-body .quiz-card { min-width: 0; min-height: 188px; }
body.app-body .deck-card-actions,
body.app-body .quiz-card-footer { flex-wrap: wrap; }

body.app-body .gc-page,
body.app-body .gc-layout {
  min-width: 0;
  min-height: 0;
}
body.app-body .gc-layout { gap: 0; }
body.app-body .gc-rail { border-color: rgba(148,163,184,.16); background: rgba(255,255,255,.025); }
body.app-body .gc-main { min-width: 0; }
body.app-body .gc-topbar {
  min-height: 60px;
  padding-inline: clamp(14px, 2vw, 22px);
  border-color: rgba(148,163,184,.15);
}
body.app-body .gc-topbar-actions { min-width: 0; flex-wrap: wrap; justify-content: flex-end; }
body.app-body .gc-select { min-width: 132px; max-width: 210px; }
body.app-body .gc-messages,
body.app-body .gc-messages-inner { min-width: 0; }
body.app-body .gc-composer { border-color: rgba(148,163,184,.18); background: rgba(255,255,255,.035); }
body.app-body .gc-input-shell { min-width: 0; }
body.app-body .gc-input-shell textarea { min-width: 0; }
body.app-body .gc-suggestions { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 8px; }
body.app-body .gc-suggestion { min-width: 0; }
body.app-body .gc-fab { right: clamp(16px, 2.5vw, 28px); bottom: clamp(16px, 2.5vw, 28px); }
body.app-body .gc-panel { right: clamp(12px, 2.5vw, 28px); bottom: clamp(12px, 2.5vw, 28px); }

body.app-body .cal-view,
body.app-body .cal-month,
body.app-body .cal-week { min-width: 0; }
body.app-body .cal-view { border-color: rgba(148,163,184,.17); box-shadow: var(--shadow-sm); }
body.app-body .cal-week-head,
body.app-body .cal-weekdays { background: rgba(255,255,255,.035); }
body.app-body .cal-day,
body.app-body .cal-week-col { min-width: 0; border-color: rgba(148,163,184,.11); }
body.app-body .cal-day-num { font-variant-numeric: tabular-nums; }
body.app-body .agenda-day { border-color: rgba(148,163,184,.14); }
body.app-body .task-row { min-width: 0; }
body.app-body .task-main { min-width: 0; }
body.app-body .task-actions { opacity: .72; }
body.app-body .task-row:hover .task-actions,
body.app-body .task-row:focus-within .task-actions { opacity: 1; }
body.app-body .task-board { align-items: stretch; }
body.app-body .task-board-col { min-width: 0; }
body.app-body .focus-picker { width: min(100%, 480px); }
body.app-body .focus-card { gap: 8px; }

@media (max-width: 900px) {
  body.app-body .files-layout,
  body.app-body .quiz-take { grid-template-columns: 1fr; }
  body.app-body .files-rail,
  body.app-body .note-view-toc { position: static; }
  body.app-body .login-shell { min-height: 0; }
  body.app-body .gc-layout { grid-template-columns: 1fr; }
  body.app-body .gc-rail { max-height: 240px; }
}

@media (max-width: 640px) {
  body.app-body .files-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 11px; }
  body.app-body .file-card { min-height: 148px; }
  body.app-body .file-card.card { padding: 14px; }
  body.app-body .profile-header-card { align-items: flex-start; }
  body.app-body .course-grid { grid-template-columns: 1fr; }
  body.app-body .editor-toolbar { overflow-x: auto; flex-wrap: nowrap; scrollbar-width: none; }
  body.app-body .editor-toolbar::-webkit-scrollbar { display: none; }
  body.app-body .study-rating-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  body.app-body .breakdown-bar-row { grid-template-columns: minmax(80px, 1fr) minmax(80px, 1.7fr) 40px; gap: 7px; }
  body.app-body .gc-topbar-actions .select { max-width: 145px; }
  body.app-body .gc-panel { width: calc(100vw - 24px); height: calc(100svh - 24px); }
  body.app-body .focus-ring-wrap { width: min(70vw, 260px); height: min(70vw, 260px); }
}

/* ---------- Accessibility and motion preferences ---------- */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto !important; }
  *, *::before, *::after {
    animation-duration: .001ms !important;
    animation-iteration-count: 1 !important;
    scroll-behavior: auto !important;
    transition-duration: .001ms !important;
  }
  .card-hover:hover, .btn:hover:not(:disabled), .gc-fab:hover { transform: none !important; }
}

@media (forced-colors: active) {
  .btn, .input, .select, .textarea, .card, .glass, .dropdown, .dropdown-menu { border: 1px solid CanvasText; }
  .sidebar-link.active, .tab.active, .chip.active { outline: 2px solid Highlight; }
  .progress > span, .ring { forced-color-adjust: none; }
}

/* ---------- Print-safe global overrides ---------- */
@media print {
  body.app-body { background: #fff !important; }
  body.app-body::before, .aurora { display: none !important; }
  .app-content { width: 100% !important; min-height: auto !important; padding: 0 !important; }
  .app-main { min-height: auto !important; background: none !important; }
  .card, .glass, .glass-strong, .table-wrap { box-shadow: none !important; }
  .table-wrap { overflow: visible !important; }
  .table-ss { min-width: 0 !important; }
  .btn, .badge, .chip { color: #111 !important; border-color: #aaa !important; background: #fff !important; box-shadow: none !important; }
}

/* ========================================================================== 
   Product shell reset — restrained SaaS workspace
   ========================================================================== */
:root {
  --bg: #0b1020;
  --bg-2: #10172a;
  --surface: #121a2d;
  --surface-2: #17213a;
  --surface-3: #202d4a;
  --border: #26334d;
  --border-strong: #3a4967;
  --text: #f4f7fc;
  --muted: #9ca9bf;
  --muted-strong: #c4cede;
  --muted-dim: #71809a;
  --sidebar-w: 232px;
  --sidebar-w-collapsed: 72px;
  --topbar-h: 64px;
  --content-max: 1360px;
  --content-gutter: clamp(20px, 2.75vw, 40px);
  --radius: 12px;
  --radius-lg: 16px;
  --radius-xl: 20px;
  --shadow-xs: 0 1px 2px rgb(4 8 20 / .16);
  --shadow-sm: 0 8px 20px rgb(4 8 20 / .14);
  --shadow-md: 0 16px 38px rgb(4 8 20 / .18);
}

/* Keep decoration for entry screens only; the authenticated workspace stays calm. */
body.app-body:not(.bare-body) .aurora,
body.app-body:not(.bare-body)::before { display: none; }
body.app-body {
  background: #0b1020;
  background-image: none;
}

.app-shell { background: #0b1020; }
.app-main {
  background: #0f1525;
  border-left: 0;
}
.app-content {
  width: min(100%, var(--content-max));
  padding: 32px var(--content-gutter) 72px;
}
.app-content > :where(.page-header, .dash-hero) { margin-bottom: 24px; }
.app-content > :where(.section-title) { margin-top: 28px; margin-bottom: 12px; }

/* Sidebar: compact application navigation rather than a decorative panel. */
.sidebar {
  padding: 16px 12px 14px;
  gap: 6px;
  background: #0d1323;
  border-right: 1px solid #24314a;
  box-shadow: none;
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
}
.sidebar-brand {
  min-height: 44px;
  padding: 4px 8px 14px;
  gap: 10px;
}
.brand-mark {
  width: 32px;
  height: 32px;
  border: 1px solid #34425d;
  border-radius: 9px;
  background: #18233a;
  box-shadow: none;
}
.brand-mark img { width: 20px; height: 20px; }
.brand-text { font-size: 1.1rem; letter-spacing: -.03em; }
.sidebar-ask {
  min-height: 40px;
  margin: 0 0 6px;
  padding: 7px 9px;
  border: 1px solid #344363;
  border-radius: 10px;
  background: #18223a;
  box-shadow: none;
  font-size: .84rem;
}
.sidebar-ask:hover {
  border-color: rgb(var(--accent) / .65);
  background: #1c2945;
  box-shadow: none;
  transform: none;
}
.sidebar-ask .giancarlo-orb {
  width: 25px !important;
  height: 25px !important;
  box-shadow: none;
}
.sidebar-section {
  padding: 17px 10px 6px;
  color: #6e7d99;
  font-size: .61rem;
  font-weight: 700;
  letter-spacing: .13em;
}
.sidebar-link {
  min-height: 38px;
  gap: 10px;
  padding: 8px 10px;
  margin: 1px 0;
  border: 1px solid transparent;
  border-radius: 9px;
  color: #aab6cb;
  font-size: .86rem;
}
.sidebar-link:hover {
  border-color: transparent;
  background: #161f33;
  color: #f5f7fb;
}
.sidebar-link.active {
  border-color: rgb(var(--accent) / .34);
  background: rgb(var(--accent) / .13);
  box-shadow: none;
}
.sidebar-link.active::before {
  left: -13px;
  top: 9px;
  bottom: 9px;
  width: 2px;
  box-shadow: none;
}
.sidebar-link.active svg { filter: none; }
.sidebar-footer { padding-top: 12px; border-top-color: #24314a; }
.sidebar-user { min-height: 40px; padding: 5px 6px; }
.sidebar-user:hover { background: #161f33; }

/* Topbar uses quiet utility controls and aligns to the page rhythm. */
.topbar {
  display: block;
  height: var(--topbar-h);
  padding: 0;
  background: #0d1323;
  border-bottom: 1px solid #24314a;
  box-shadow: none;
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
}
.topbar-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: min(100%, var(--content-max));
  height: 100%;
  margin-inline: auto;
  padding-inline: var(--content-gutter);
  gap: 18px;
}
.topbar-search {
  width: min(460px, 100%);
  height: 40px;
  border-color: #2d3a54;
  border-radius: 9px;
  background: #131c2e;
  color: #aab6cb;
  box-shadow: none;
}
.topbar-search:hover,
.topbar-search:focus-visible {
  border-color: #4b5c7d;
  background: #172238;
  box-shadow: 0 0 0 3px rgb(var(--accent) / .12);
}
.topbar-actions { flex: 0 0 auto; }
.sidebar-mobile-toggle { display: none; }
.topbar .btn-icon { width: 34px; height: 34px; border-radius: 8px; }
.notif-dot { border-color: #0d1323; box-shadow: none; }

/* Shared surfaces, data, and controls. */
.glass,
.glass-strong,
.card {
  border: 1px solid #293650;
  border-radius: var(--radius);
  background: #121a2b;
  box-shadow: var(--shadow-xs);
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
}
.glass-strong { background: #151e32; }
.card { padding: 20px; }
.card:hover { border-color: #33425f; }
.card-hover:hover {
  border-color: rgb(var(--accent) / .55);
  box-shadow: var(--shadow-sm);
  transform: translateY(-1px);
}
.empty-state {
  min-height: 180px;
  border: 1px dashed #33405a;
  border-radius: var(--radius);
  background: #101827;
}
.empty-state-icon {
  width: 50px;
  height: 50px;
  margin-bottom: 12px;
  border-radius: 12px;
  box-shadow: none;
}
.page-header { align-items: center; gap: 16px; margin-bottom: 24px; }
.page-header-icon {
  width: 44px;
  height: 44px;
  border-radius: 11px;
  background: rgb(var(--accent));
  box-shadow: none;
}
.page-title { font-size: clamp(1.55rem, 2vw, 1.9rem); }
.page-subtitle { color: #96a4bc; }
.section-title { color: #e9eef8; font-size: .95rem; }
.gradient-text {
  color: rgb(var(--accent));
  background: none;
  -webkit-text-fill-color: currentColor;
}

.btn {
  height: 40px;
  border-radius: 9px;
  font-size: .84rem;
  font-weight: 650;
  box-shadow: none;
}
.btn-primary,
.btn-ai {
  background: rgb(var(--accent));
  box-shadow: none;
  animation: none;
}
.btn-primary:hover:not(:disabled),
.btn-ai:hover:not(:disabled) {
  background: color-mix(in srgb, rgb(var(--accent)) 86%, white);
  box-shadow: none;
  filter: none;
}
.btn-secondary { border-color: #3a4964; background: #172033; }
.btn-secondary:hover:not(:disabled) { border-color: #4a5a77; background: #1c2940; }
.btn-ghost:hover:not(:disabled) { background: #1a2438; }
.btn-icon { border-radius: 8px; color: #aab6cb; }
.btn-icon:hover { background: #1b263b; color: #fff; }
.btn-sm { height: 32px; border-radius: 8px; }

/* Form selectors deliberately use input.input specificity to defeat browser/form-plugin defaults. */
input.input,
select.select,
textarea.textarea,
.input,
.select,
.textarea {
  color: #f5f7fb;
  border-color: #3a4761;
  border-radius: 9px;
  background-color: #151e30;
  box-shadow: none;
}
input.input,
select.select,
.input,
.select { min-height: 42px; }
textarea.textarea,
.textarea { min-height: 112px; }
input.input:hover,
select.select:hover,
textarea.textarea:hover,
.input:hover,
.select:hover,
.textarea:hover { border-color: #50607e; background-color: #182338; }
input.input:focus,
select.select:focus,
textarea.textarea:focus,
.input:focus,
.select:focus,
.textarea:focus {
  border-color: rgb(var(--accent));
  background-color: #18233a;
  box-shadow: 0 0 0 3px rgb(var(--accent) / .15);
}
input.input:-webkit-autofill,
input.input:-webkit-autofill:hover,
input.input:-webkit-autofill:focus {
  -webkit-text-fill-color: #f5f7fb !important;
  -webkit-box-shadow: 0 0 0 1000px #151e30 inset !important;
  caret-color: #f5f7fb;
}
.input::placeholder,
.textarea::placeholder { color: #7787a3; opacity: 1; }
.select option,
.select optgroup { background: #151e30; color: #f5f7fb; }
.label { color: #c9d3e3; font-size: .78rem; }
.hint { color: #7f8da5; }

.dropdown,
.dropdown-menu {
  border-color: #394863;
  border-radius: 10px;
  background: #151e30;
  box-shadow: 0 18px 38px rgb(4 8 20 / .25);
}
.menu-item { border-radius: 7px; color: #c6d0df; }
.menu-item:hover,
.menu-item.active,
.menu-item:focus-visible { background: #202c44; }

.table-wrap { border-color: #293650; background: #121a2b; }
.table-ss th { background: #151e30; border-bottom-color: #293650; }
.table-ss td { border-bottom-color: #243049; }
.table-ss tbody tr:hover { background: #172137; }
.progress { background: #263249; }
.progress > span { box-shadow: none; background: rgb(var(--accent)); }

@media (max-width: 1024px) {
  :root { --content-gutter: 24px; }
  .sidebar { padding-inline: 10px; }
  body:not(.sidebar-collapsed) .sidebar { width: var(--sidebar-w-collapsed); }
  .sidebar-link.active::before { left: -10px; }
}

@media (max-width: 900px) {
  .app-main,
  body.sidebar-collapsed .app-main { margin-left: 0; }
  .sidebar,
  body.sidebar-collapsed .sidebar {
    width: min(290px, calc(100vw - 46px));
    padding: 16px 12px;
    transform: translateX(-100%);
    transition: transform .22s ease;
    box-shadow: 18px 0 38px rgb(4 8 20 / .32);
  }
  body.sidebar-open .sidebar { transform: translateX(0); }
  body.sidebar-open .sidebar-label,
  body.sidebar-open .brand-text,
  body.sidebar-open .sidebar-section { display: initial; }
  body.sidebar-open .sidebar-link,
  body.sidebar-open .sidebar-ask { justify-content: flex-start; padding-inline: 10px; }
  body.sidebar-open .sidebar-footer { flex-direction: row; }
  .sidebar-scrim {
    position: fixed;
    inset: 0;
    z-index: 35;
    background: rgb(4 8 20 / .52);
    opacity: 0;
    pointer-events: none;
    transition: opacity .22s ease;
  }
  body.sidebar-open .sidebar-scrim { opacity: 1; pointer-events: auto; }
  .sidebar-mobile-toggle { display: inline-grid; }
  .topbar-inner { padding-inline: 16px; gap: 10px; }
  .topbar-search { flex: 1 1 auto; width: auto; }
}

@media (max-width: 720px) {
  :root { --content-gutter: 16px; --topbar-h: 60px; }
  .app-content { padding-top: 22px; padding-bottom: 48px; }
  .topbar-inner { padding-inline: 14px; gap: 8px; }
  .topbar-search { width: min(100%, 360px); }
  .sidebar-link { border-radius: 8px; }
  .card { padding: 16px; }
}

/* Final control pass: compact product menus and a single-purpose AI entry. */
.dropdown,
.dropdown-menu {
  padding: 5px;
  border-color: #34425c;
  border-radius: 11px;
  background: #131c2e;
  box-shadow: 0 20px 46px rgb(2 6 18 / .42), 0 1px 0 rgb(255 255 255 / .05) inset;
}
.menu-item {
  min-height: 34px;
  padding: 7px 9px;
  border-radius: 7px;
  font-size: .79rem;
  font-weight: 560;
}
.menu-item:hover,
.menu-item.active,
.menu-item:focus-visible { border-color: transparent; background: #24314a; }

.sidebar-ask {
  display: grid;
  grid-template-columns: 26px minmax(0,1fr) auto;
  align-items: center;
  gap: 8px;
  min-height: 42px;
  margin-bottom: 7px;
  padding: 7px 8px;
  border-color: #354568;
  border-radius: 10px;
  background: #18233a;
  box-shadow: inset 0 1px 0 rgb(255 255 255 / .04);
}
.sidebar-ask:hover { border-color: rgb(var(--accent) / .58); background: #1c2943; box-shadow: 0 7px 18px -15px rgb(var(--accent) / .9); transform: none; }
.sidebar-ask-orb { display: grid; place-items: center; width: 26px; height: 26px; }
.sidebar-ask .giancarlo-orb { width: 26px; height: 26px; box-shadow: 0 5px 13px -7px rgb(var(--accent) / .9); }
.sidebar-ask-label { min-width: 0; overflow: hidden; color: #edf2fb; font-size: .79rem; font-weight: 650; line-height: 1; text-overflow: ellipsis; white-space: nowrap; }
.sidebar-ask-shortcut { height: 19px; padding: 0 5px; border-color: #3d4a63; color: #9caac4; font-size: .6rem; line-height: 18px; white-space: nowrap; }
body.sidebar-collapsed .sidebar-ask { grid-template-columns: 26px; justify-content: center; padding-inline: 0; }

@media (max-width: 900px) {
  body.sidebar-open .sidebar-ask { display: grid; grid-template-columns: 26px minmax(0,1fr) auto; padding-inline: 8px; }
}

/* Note title control: prevent browser defaults from rendering a bright white
   rectangle when the editor stylesheet or autofill styles are active. */
body.app-body #note-title.note-title-input {
  box-sizing: border-box;
  display: block;
  width: 100%;
  min-height: 44px;
  padding: 10px 13px;
  border: 1px solid #34425d;
  border-radius: 10px;
  outline: 0;
  color: #f4f7fc;
  background: #151e31 !important;
  caret-color: rgb(var(--accent));
  font-family: "Space Grotesk", Inter, sans-serif;
  font-size: 1.05rem;
  font-weight: 650;
  line-height: 1.3;
  letter-spacing: -.015em;
  box-shadow: 0 1px 0 rgb(255 255 255 / .04) inset;
}
body.app-body #note-title.note-title-input:hover { border-color: #4b5c7c; background: #18243a !important; }
body.app-body #note-title.note-title-input:focus { border-color: rgb(var(--accent) / .78); background: #18243a !important; box-shadow: 0 0 0 3px rgb(var(--accent) / .13), 0 1px 0 rgb(255 255 255 / .04) inset; }
body.app-body #note-title.note-title-input::placeholder { color: #8190ab; opacity: 1; }
body.app-body #note-title.note-title-input:-webkit-autofill,
body.app-body #note-title.note-title-input:-webkit-autofill:hover,
body.app-body #note-title.note-title-input:-webkit-autofill:focus {
  -webkit-text-fill-color: #f4f7fc !important;
  -webkit-box-shadow: 0 0 0 1000px #151e31 inset !important;
}

@media (max-width: 720px) {
  body.app-body #note-title.note-title-input { min-height: 42px; font-size: .98rem; }
}

/* Floating Giancarlo bubble: keep the header controls inside the panel and
   reserve a real, non-shrinking row for the composer. */
.gc-panel {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  min-height: 0;
}
.gc-panel > :first-child {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  min-height: 60px;
  padding: 9px 12px;
}
.gc-panel > :first-child > .flex-1 { min-width: 0; }
.gc-panel > [data-msgs] { min-height: 0; overflow-x: hidden; overflow-y: auto; }
.gc-panel > :last-child {
  min-height: 0;
  padding: 10px 12px 12px;
  border-top-color: rgb(148 163 184 / .1);
}
.gc-panel > :last-child > div {
  min-height: 48px;
  padding: 5px 6px 5px 10px;
  border-color: #34425d;
  border-radius: 13px;
  background: #151e31;
  box-shadow: 0 12px 28px -20px rgb(0 0 0 / .95), 0 1px 0 rgb(255 255 255 / .05) inset;
}
.gc-panel > :last-child > div:focus-within { border-color: rgb(var(--accent) / .72); box-shadow: 0 0 0 3px rgb(var(--accent) / .12), 0 12px 28px -20px rgb(0 0 0 / .95); }
.gc-panel textarea {
  box-sizing: border-box;
  min-width: 0;
  min-height: 36px;
  height: 36px;
  max-height: 96px;
  padding: 8px 2px;
  overflow-x: hidden;
  overflow-y: auto;
  line-height: 20px;
  resize: none;
}
.gc-panel [data-act="send"] { flex: 0 0 36px; width: 36px; height: 36px; }

.gc-bubble-mode { position: relative; flex: 0 0 auto; min-width: 0; }
.gc-bubble-mode-trigger {
  display: inline-flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  width: 112px;
  height: 34px;
  padding: 0 9px;
  border: 1px solid #3b4b69;
  border-radius: 9px;
  color: #e5ebf7;
  background: #17223a;
  cursor: pointer;
  font: inherit;
  font-size: .73rem;
  font-weight: 650;
  text-align: left;
}
.gc-bubble-mode-trigger:hover,
.gc-bubble-mode.open .gc-bubble-mode-trigger { border-color: rgb(var(--accent) / .72); background: #1c2a46; }
.gc-bubble-mode-trigger > span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.gc-bubble-mode-trigger svg { flex: 0 0 auto; color: #8c9bb5; transition: transform .16s var(--ease); }
.gc-bubble-mode.open .gc-bubble-mode-trigger svg { transform: rotate(180deg); }
.gc-bubble-mode-menu { top: calc(100% + 6px); min-width: 168px; padding: 5px; border-color: #3b4b69; border-radius: 10px; background: #131d31; }
.gc-bubble-menu-label { padding: 6px 8px 5px; color: #7f8eaa; font-size: .58rem; font-weight: 750; letter-spacing: .1em; text-transform: uppercase; }
.gc-bubble-mode-option { display: block; width: 100%; min-height: 31px; padding: 7px 9px; border: 0; border-radius: 7px; color: #ced8e9; background: transparent; cursor: pointer; font: inherit; font-size: .74rem; font-weight: 560; line-height: 1.2; text-align: left; }
.gc-bubble-mode-option:hover,
.gc-bubble-mode-option:focus-visible { outline: 0; color: #fff; background: #24334e; }
.gc-bubble-mode-option.selected { color: #fff; background: rgb(var(--accent) / .2); box-shadow: inset 2px 0 0 rgb(var(--accent)); }

@media (max-width: 520px) {
  .gc-panel > :first-child { gap: 6px; padding-inline: 10px; }
  .gc-bubble-mode-trigger { width: 98px; }
  .gc-panel > :first-child > .btn-icon { width: 30px; height: 30px; }
  .gc-panel > :last-child { padding-inline: 8px; }
}
