/* ==========================================================================
   StudySpace — shared components
   Header · nav · buttons · badges · cards · forms · overlays · footer
   ========================================================================== */

/* =============================== SHELL ================================= */
/* Desktop: a fixed left rail plus a sticky top bar. Phones: the rail becomes
   an off-canvas drawer and the tab bar at the foot does the navigating. */

/* The chrome host is a bare wrapper: `display: contents` lets the top bar be
   a child of <body> so its `position: sticky` is measured against the page,
   not against this zero-height div. */
#site-header { display: contents; }
.site-header { position: relative; z-index: var(--z-header); }

.sidebar {
  position: fixed;
  top: 0; bottom: 0; left: 0;
  z-index: calc(var(--z-header) + 2);
  width: var(--sidebar-w);
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
  padding: var(--sp-5) var(--sp-4) var(--sp-4);
  background: var(--surface-sunken);
  border-right: 1px solid var(--border);
  overflow-y: auto;
  transform: translateX(-100%);
  transition: transform var(--dur) var(--ease);
}
.sidebar.is-open { transform: none; }

.sidebar .brand { margin: 0 var(--sp-2) var(--sp-6); }



.side-nav { display: grid; gap: 2px; }
.side-link {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 44px;
  padding: 0 12px;
  border-radius: var(--r-md);
  color: var(--text-muted);
  font-size: var(--text-sm);
  font-weight: 600;
  transition: background var(--dur-fast) var(--ease), color var(--dur-fast) var(--ease);
}
.side-link svg { width: 20px; height: 20px; flex: 0 0 auto; }
.side-link:hover { background: var(--surface-raised); color: var(--text-strong); }
.side-link[aria-current="page"] {
  background: var(--violet-600);
  color: var(--text-invert);
  box-shadow: 0 6px 16px rgba(91, 91, 246, 0.28);
}
.side-link[aria-current="page"] svg { color: var(--text-invert); }

.side-foot {
  margin-top: auto;
  padding: var(--sp-4) var(--sp-2) 0;
  border-top: 1px solid var(--border);
  display: grid;
  gap: 10px;
}
.side-foot-note { font-size: var(--text-xs); color: var(--text-subtle); margin: 0; }
.side-foot-link {
  font-size: var(--text-xs);
  font-weight: 700;
  color: var(--violet-400);
  text-align: center;
}
.side-foot-link:hover { text-decoration: underline; text-underline-offset: 3px; }
.side-user {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px;
  border-radius: var(--r-md);
  color: var(--text);
}
.side-user:hover { background: var(--surface-raised); }
.side-user-text { display: grid; min-width: 0; }
.side-user-text strong { font-size: var(--text-sm); color: var(--text-strong); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.side-user-text small { font-size: var(--text-xs); color: var(--text-subtle); }

.sidebar-scrim {
  position: fixed;
  inset: 0;
  z-index: calc(var(--z-header) + 1);
  background: rgba(4, 4, 10, 0.66);
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
}

/* Brand */
.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  flex: 0 0 auto;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.125rem;
  letter-spacing: -0.01em;
  color: var(--text-strong);
}
.brand-mark {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  background: var(--grad-brand);
  box-shadow: var(--shadow-brand);
  display: grid;
  place-items: center;
  flex: 0 0 auto;
}
.brand-mark svg { width: 17px; height: 17px; color: var(--text-invert); }
.brand-text small {
  display: block;
  font-family: var(--font-sans);
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.16em;
  color: var(--text-subtle);
  text-transform: uppercase;
  margin-top: 1px;
}

/* Top bar */
.topbar {
  position: sticky;
  top: 0;
  z-index: var(--z-sticky);
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  height: var(--topbar-h);
  padding: 0 clamp(var(--sp-4), 2.2vw, var(--sp-7));
  background: rgba(11, 11, 22, 0.88);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  border-bottom: 1px solid var(--border);
}
.topbar-menu { display: grid; margin-left: -6px; }

.topbar-brand {
  display: none;
  align-items: center;
  gap: 8px;
  font-weight: 700;
  font-size: var(--text-md);
  color: var(--text-strong);
}
.topbar-brand .brand-mark { width: 28px; height: 28px; border-radius: 8px; }
.topbar-brand .brand-mark svg { width: 14px; height: 14px; }

.topbar-search {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 1 1 auto;
  max-width: 520px;
  height: 42px;
  padding: 0 8px 0 14px;
  border-radius: var(--r-pill);
  background: var(--surface-soft);
  border: 1px solid var(--border);
  transition: border-color var(--dur-fast) var(--ease), background var(--dur-fast) var(--ease);
}
.topbar-search:focus-within {
  border-color: var(--violet-600);
  background: var(--surface);
  box-shadow: 0 0 0 3px rgba(91, 91, 246, 0.18);
}
.topbar-search svg { width: 17px; height: 17px; color: var(--text-subtle); flex: 0 0 auto; }
.topbar-search input {
  flex: 1 1 auto;
  min-width: 0;
  border: 0;
  background: none;
  color: var(--text-strong);
  font-size: var(--text-sm);
  outline: none;
}
.topbar-search input::placeholder { color: var(--text-subtle); }
.topbar-search kbd {
  font-family: var(--font-sans);
  font-size: 10px;
  font-weight: 700;
  padding: 3px 7px;
  border-radius: 6px;
  background: var(--surface-raised);
  color: var(--text-subtle);
  border: 1px solid var(--border);
}

.topbar-actions { display: flex; align-items: center; gap: var(--sp-2); margin-left: auto; flex: 0 0 auto; }
.topbar-actions [data-search-toggle] { display: none; }

.icon-btn {
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  border-radius: var(--r-pill);
  color: var(--text-muted);
  transition: background var(--dur-fast) var(--ease), color var(--dur-fast) var(--ease);
}
.icon-btn:hover { background: var(--surface-raised); color: var(--text-strong); }
.icon-btn svg { width: 20px; height: 20px; }
.icon-btn.has-dot { position: relative; }
.icon-btn.has-dot::after {
  content: "";
  position: absolute;
  top: 9px; right: 10px;
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--live);
  box-shadow: 0 0 0 2px var(--canvas);
}

.user-chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 3px;
  border-radius: var(--r-pill);
  background: var(--surface-raised);
  border: 1px solid var(--border);
  color: var(--text-strong);
  max-width: 190px;
}
.user-chip:hover { border-color: var(--border-strong); }
.user-chip .avatar { width: 30px; height: 30px; font-size: 11px; }

/* Nav-toggle / mobile drawer affordances are only meaningful below 1024px. */
/* ============================== BUTTONS ================================ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 44px;
  padding: 0 var(--sp-5);
  border-radius: var(--r-sm);
  font-family: var(--font-sans);
  font-size: var(--text-sm);
  font-weight: 600;
  letter-spacing: 0;
  white-space: nowrap;
  cursor: pointer;
  border: 1px solid transparent;
  transition: transform var(--dur-fast) var(--ease),
    box-shadow var(--dur-fast) var(--ease),
    background var(--dur-fast) var(--ease),
    border-color var(--dur-fast) var(--ease),
    color var(--dur-fast) var(--ease);
}
.btn:active { transform: translateY(1px); }
.btn svg { width: 17px; height: 17px; flex: 0 0 auto; }
.btn[disabled], .btn[aria-disabled="true"] { opacity: 0.55; cursor: not-allowed; }

.btn-primary {
  background: var(--ink-900);
  color: var(--text-invert);
}
.btn-primary:hover { background: var(--ink-700); }

.btn-accent {
  background: var(--amber-600);
  color: var(--amber-ink);
}
.btn-accent:hover { background: var(--amber-500); }

.btn-ghost {
  background: transparent;
  color: var(--text);
  border-color: var(--border-strong);
}
.btn-ghost:hover { background: var(--slate-100); border-color: var(--slate-300); }

/* Ghost button that sits on the dark header. */
.btn-ghost-invert { background: transparent; color: var(--text-invert); border-color: var(--border-inverse); }
.btn-ghost-invert:hover {
  background: rgba(251, 249, 244, 0.08);
  border-color: rgba(251, 249, 244, 0.28);
  color: var(--text-invert);
}

.btn-danger { background: var(--danger-solid); color: var(--text-invert); }
.btn-danger:hover { background: var(--danger-solid-hover); }

.btn-sm { min-height: 34px; padding: 0 var(--sp-4); font-size: var(--text-xs); border-radius: var(--r-sm); }
.btn-sm svg { width: 15px; height: 15px; }
.btn-lg { min-height: 50px; padding: 0 var(--sp-7); font-size: var(--text-md); border-radius: var(--r-lg); }

/* A long label must wrap inside its button rather than spill out of it: the
   hero action on a phone ("Redeem access code") was clipping its own text. */
@media (max-width: 560px) {
  .btn { white-space: normal; text-align: center; line-height: 1.2; }
  .btn-lg { padding-inline: var(--sp-4); font-size: var(--text-sm); }
}
.btn-block { width: 100%; }

.link {
  color: var(--violet-600);
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  gap: 5px;
}
.link:hover { text-decoration: underline; text-underline-offset: 3px; }
.link svg { width: 15px; height: 15px; }

/* ============================== BADGES ================================= */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 2px 7px;
  border-radius: var(--r-xs);
  font-size: var(--text-2xs);
  font-weight: 600;
  letter-spacing: 0.01em;
  line-height: 1.6;
  white-space: nowrap;
}
.badge svg { width: 12px; height: 12px; }
.badge-live { background: var(--danger-100); color: var(--danger-600); }
.badge-live::before {
  content: "";
  width: 5px; height: 5px;
  border-radius: 50%;
  background: currentColor;
  animation: blink 1.6s ease-in-out infinite;
}
@keyframes blink { 0%, 100% { opacity: 1; } 50% { opacity: 0.25; } }
.badge-new { background: var(--success-100); color: var(--success-600); }
.badge-hot { background: var(--amber-100); color: var(--amber-800); }
.badge-free { background: var(--success-100); color: var(--success-600); }
.badge-paid { background: var(--violet-100); color: var(--violet-700); }
.badge-neutral { background: var(--slate-100); color: var(--slate-600); }
.badge-dark { background: rgba(255, 255, 255, 0.12); color: var(--text-invert); }
.badge-outline { border: 1px solid var(--border-strong); color: var(--text-muted); }

/* ============================== CHIPS ================================== */
.chip {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 36px;
  padding: 7px 14px;
  border-radius: var(--r-xs);
  border: 1px solid var(--border);
  background: var(--paper);
  color: var(--text-muted);
  font-size: var(--text-sm);
  font-weight: 500;
  white-space: nowrap;
  transition: all var(--dur-fast) var(--ease);
}
.chip:hover { border-color: var(--slate-300); color: var(--text-strong); }
.chip[aria-pressed="true"], .chip.is-active {
  background: var(--ink-900);
  border-color: var(--ink-900);
  color: var(--text-invert);
}
.chip svg { width: 15px; height: 15px; }

/* ============================== CARDS ================================== */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  box-shadow: none;
}
.card-pad { padding: var(--sp-6); }

/* Avatar */
.avatar {
  width: 36px; height: 36px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: var(--text-xs);
  font-weight: 600;
  color: var(--violet-800);
  background: var(--violet-100);
  flex: 0 0 auto;
  letter-spacing: 0.02em;
  overflow: hidden;
}
.avatar-lg { width: 52px; height: 52px; font-size: var(--text-base); }
.avatar-violet, .avatar { background: var(--violet-100); color: var(--violet-800); }
.avatar-amber { background: var(--amber-100); color: var(--amber-800); }
.avatar-teal { background: var(--success-100); color: var(--success-600); }
.avatar-rose { background: var(--danger-100); color: var(--danger-600); }
.avatar-ink { background: var(--ink-900); color: var(--text-invert); }

/* Rating */
.rating {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: var(--text-xs);
  font-weight: 700;
  color: var(--text-strong);
}
.rating svg { width: 13px; height: 13px; color: var(--amber-500); }
.rating small { color: var(--text-subtle); font-weight: 500; }

/* ============================== FORMS ================================== */
.field { display: grid; gap: 6px; }
.field > label,
.label {
  font-size: var(--text-xs);
  font-weight: 700;
  color: var(--text-strong);
  letter-spacing: 0.01em;
}
.input, .select, .textarea {
  width: 100%;
  min-height: 46px;
  padding: 11px 14px;
  border: 1.5px solid var(--border-input);
  border-radius: var(--r-md);
  background: var(--paper);
  color: var(--text-strong);
  font-size: var(--text-base);
  outline: none;
  transition: border-color var(--dur-fast) var(--ease), box-shadow var(--dur-fast) var(--ease);
}
.input::placeholder, .textarea::placeholder { color: var(--text-subtle); }
.input:hover, .select:hover { border-color: var(--slate-400); }
.input:focus, .select:focus, .textarea:focus {
  border-color: var(--violet-500);
  box-shadow: 0 0 0 3px rgba(86, 84, 148, 0.16);
}
.textarea { min-height: 110px; resize: vertical; line-height: 1.6; }
.select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%236f685c' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
  padding-right: 40px;
}
.field-hint { font-size: var(--text-xs); color: var(--text-subtle); }
.field-error { font-size: var(--text-xs); color: var(--danger-600); font-weight: 600; }

.input-group { position: relative; display: flex; align-items: center; }
.input-group svg {
  position: absolute;
  left: 14px;
  width: 17px; height: 17px;
  color: var(--text-subtle);
  pointer-events: none;
}
.input-group .input { padding-left: 42px; }
.input-group .input-action {
  position: absolute;
  right: 6px;
  width: 36px; height: 36px;
  display: grid; place-items: center;
  border-radius: var(--r-sm);
  color: var(--text-subtle);
}
.input-group .input-action:hover { background: var(--slate-100); color: var(--text); }
.input-group .input-action svg { position: static; }

/* Checkbox / radio */
.check {
  display: inline-flex;
  align-items: flex-start;
  gap: 10px;
  cursor: pointer;
  font-size: var(--text-sm);
  color: var(--text-muted);
  min-height: 24px;
}
.check input {
  appearance: none;
  width: 20px; height: 20px;
  margin: 1px 0 0;
  border: 2px solid var(--border-input);
  border-radius: 6px;
  background: var(--paper);
  flex: 0 0 auto;
  cursor: pointer;
  display: grid;
  place-content: center;
  transition: all var(--dur-fast) var(--ease);
}
.check input[type="radio"] { border-radius: 50%; }
.check input::after {
  content: "";
  width: 10px; height: 10px;
  transform: scale(0);
  transition: transform var(--dur-fast) var(--ease);
  box-shadow: inset 1em 1em #fff;
  clip-path: polygon(14% 44%, 0 65%, 50% 100%, 100% 16%, 80% 0%, 43% 62%);
}
.check input[type="radio"]::after { border-radius: 50%; clip-path: none; clip-path: circle(50%); }
.check input:checked { background: var(--violet-600); border-color: var(--violet-600); }
.check input:checked::after { transform: scale(1); }
.check input:focus-visible { outline: 3px solid var(--violet-500); outline-offset: 2px; }

/* Switch */
/* ============================== OVERLAYS =============================== */
.modal {
  position: fixed;
  inset: 0;
  z-index: var(--z-overlay);
  display: grid;
  place-items: center;
  padding: var(--sp-4);
  background: rgba(7, 10, 21, 0.62);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  opacity: 0;
  visibility: hidden;
  transition: opacity var(--dur) var(--ease), visibility var(--dur) var(--ease);
}
.modal.is-open { opacity: 1; visibility: visible; }
.modal-panel {
  width: 100%;
  max-width: 460px;
  max-height: 90vh;
  overflow-y: auto;
  background: var(--paper);
  border-radius: var(--r-2xl);
  box-shadow: var(--shadow-xl);
  padding: var(--sp-7);
  transform: translateY(14px) scale(0.98);
  transition: transform var(--dur) var(--ease-out);
}
.modal.is-open .modal-panel { transform: translateY(0) scale(1); }
.modal-head { display: flex; align-items: flex-start; justify-content: space-between; gap: var(--sp-4); margin-bottom: var(--sp-5); }
.modal-title { font-size: var(--text-xl); }
.modal-body { color: var(--text-muted); font-size: var(--text-base); }
.modal-foot { display: flex; gap: var(--sp-3); justify-content: flex-end; margin-top: var(--sp-6); flex-wrap: wrap; }

/* Toast */
.toast-stack {
  position: fixed;
  right: var(--sp-5);
  bottom: var(--sp-5);
  z-index: var(--z-toast);
  display: grid;
  gap: 10px;
  width: min(360px, calc(100vw - 2 * var(--sp-4)));
}
.toast {
  display: flex;
  align-items: flex-start;
  gap: 11px;
  padding: 13px 15px;
  border-radius: var(--r-md);
  background: var(--ink-900);
  color: var(--text-invert);
  box-shadow: var(--shadow-lg);
  font-size: var(--text-sm);
  animation: toast-in var(--dur) var(--ease-out);
}
.toast svg { width: 18px; height: 18px; flex: 0 0 auto; margin-top: 1px; }
.toast-success svg { color: var(--toast-success); }
.toast-error svg { color: var(--toast-error); }
.toast-info svg { color: var(--violet-400); }
@keyframes toast-in {
  from { opacity: 0; transform: translateY(12px) scale(0.97); }
  to { opacity: 1; transform: none; }
}

/* ============================== STATES ================================= */
.skeleton {
  position: relative;
  overflow: hidden;
  background: var(--slate-100);
  border-radius: var(--r-sm);
}
.skeleton::after {
  content: "";
  position: absolute;
  inset: 0;
  transform: translateX(-100%);
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.65), transparent);
  animation: shimmer 1.4s infinite;
}
@keyframes shimmer { 100% { transform: translateX(100%); } }
.skeleton-text { height: 12px; margin-bottom: 8px; }
.skeleton-title { height: 18px; width: 70%; margin-bottom: 12px; }

.empty-state {
  display: grid;
  place-items: center;
  gap: var(--sp-3);
  padding: var(--sp-9) var(--sp-5);
  text-align: center;
  border: 1.5px dashed var(--border-strong);
  border-radius: var(--r-xl);
  background: var(--paper);
}
.empty-state svg { width: 44px; height: 44px; color: var(--slate-300); }
.empty-state h3 { font-size: var(--text-lg); }
.empty-state p { color: var(--text-muted); font-size: var(--text-sm); max-width: 42ch; }

.alert {
  display: flex;
  gap: 11px;
  padding: 13px 15px;
  border-radius: var(--r-md);
  font-size: var(--text-sm);
  border: 1px solid transparent;
}
.alert svg { width: 18px; height: 18px; flex: 0 0 auto; margin-top: 1px; }
.alert-info { background: var(--info-100); color: var(--info-800); border-color: var(--info-200); }
.alert-warn { background: var(--amber-100); color: var(--amber-800); border-color: var(--amber-200); }

/* Progress */
.progress {
  height: 7px;
  border-radius: var(--r-pill);
  background: var(--slate-200);
  overflow: hidden;
}
.progress > span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: var(--grad-brand);
  transition: width var(--dur-slow) var(--ease);
}

/* Tooltip (title attribute fallback + CSS) */
[data-tip] { position: relative; }
[data-tip]:hover::after {
  content: attr(data-tip);
  position: absolute;
  bottom: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%);
  background: var(--ink-900);
  color: var(--text-invert);
  font-size: var(--text-2xs);
  font-weight: 600;
  padding: 5px 9px;
  border-radius: var(--r-xs);
  white-space: nowrap;
  pointer-events: none;
  z-index: 10;
}

/* ============================== MOBILE TABBAR ========================== */
.tabbar {
  display: none;
  position: fixed;
  bottom: 0; left: 0; right: 0;
  z-index: var(--z-header);
  height: var(--tabbar-h);
  padding-bottom: env(safe-area-inset-bottom);
  background: rgba(12, 12, 22, 0.94);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  border-top: 1px solid var(--border);
}
.tabbar ul { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); height: 100%; }
.tabbar a {
  display: grid;
  place-items: center;
  align-content: center;
  gap: 4px;
  font-size: 10px;
  font-weight: 700;
  color: var(--text-subtle);
  position: relative;
}
.tabbar a svg { width: 22px; height: 22px; }
.tabbar a[aria-current="page"] { color: var(--violet-400); }
.tabbar a[aria-current="page"]::before {
  content: "";
  position: absolute;
  top: 4px; left: 50%;
  transform: translateX(-50%);
  width: 22px; height: 3px;
  border-radius: var(--r-pill);
  background: var(--violet-500);
}

/* ============================== FOOTER ================================= */
.site-footer {
  background: var(--surface-sunken);
  border-top: 1px solid var(--border);
  color: var(--text-invert-muted);
  padding-top: var(--sp-9);
  margin-top: var(--sp-10);
}
.footer-grid {
  display: grid;
  grid-template-columns: 1.6fr repeat(4, 1fr);
  gap: var(--sp-7);
  padding-bottom: var(--sp-9);
}
.footer-brand .brand { margin-bottom: var(--sp-4); }
.footer-brand p { font-size: var(--text-sm); line-height: 1.75; max-width: 30ch; }
.footer-col h4 {
  color: var(--text-invert);
  font-size: var(--text-2xs);
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  margin-bottom: var(--sp-4);
  font-family: var(--font-sans);
}
.footer-col li { margin-bottom: 11px; }
.footer-col a { font-size: var(--text-sm); transition: color var(--dur-fast) var(--ease); }
.footer-col a:hover { color: var(--text-invert); }
.footer-bottom {
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  padding-block: var(--sp-5);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-4);
  flex-wrap: wrap;
  font-size: var(--text-xs);
}

.footer-contact { margin-top: 18px; }
.footer-contact a {
  font-size: var(--text-sm);
  color: rgba(255, 255, 255, 0.72);
  text-decoration: underline;
  text-underline-offset: 3px;
  text-decoration-color: rgba(255, 255, 255, 0.28);
}
.footer-contact a:hover { color: var(--text-invert); text-decoration-color: currentColor; }

/* Preview notice (shown only when running on demo fixtures) */
.preview-flag {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: var(--r-pill);
  background: rgba(245, 158, 11, 0.14);
  border: 1px solid rgba(245, 158, 11, 0.3);
  color: var(--amber-400);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

/* ============================== RESPONSIVE ============================= */
@media (min-width: 1024px) {
  body.has-shell { padding-left: var(--sidebar-w); }
  body.has-shell .skip-link { left: calc(var(--sidebar-w) + 16px); }
  body.exam-shell { padding-left: 0; }
  .sidebar { transform: none; }
  .sidebar-scrim { display: none; }
  .topbar-menu { display: none; }
  .site-footer { margin-left: 0; }
}
@media (max-width: 1200px) {
  .footer-grid { grid-template-columns: 1.4fr repeat(2, 1fr); }
}
@media (max-width: 900px) {
  .footer-grid { grid-template-columns: repeat(2, 1fr); }
  .footer-brand { grid-column: 1 / -1; }
}
@media (max-width: 1023px) {
  .topbar-brand { display: inline-flex; }
}

/* A drawer you can only close by tapping 70px of scrim is a trap on a phone. */
.side-close {
  display: none;
  position: absolute;
  top: calc(var(--sp-3) + env(safe-area-inset-top));
  right: var(--sp-3);
  width: 40px;
  height: 40px;
  place-items: center;
  z-index: 1;
}

@media (max-width: 760px) {
  .topbar { height: 60px; }
  .topbar-search { display: none; }
  .topbar-actions [data-search-toggle] { display: grid; }
  .topbar-cta { display: none; }

  /* Search becomes a second row under the top bar. */
  body.is-search-open .topbar { flex-wrap: wrap; height: auto; padding-block: 8px; row-gap: 8px; }
  body.is-search-open .topbar-search {
    display: flex;
    order: 10;
    flex: 1 0 100%;
    max-width: none;
    height: 40px;
  }
  body.is-search-open .topbar-search kbd { display: none; }
  .sidebar {
    width: min(84vw, 320px);
    padding-bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom) + var(--sp-4));
  }
  .side-close { display: grid; }

  .tabbar { display: block; }
  .site-footer { margin-bottom: 0; padding-top: var(--sp-8); }
  .footer-grid { gap: var(--sp-6); padding-bottom: var(--sp-6); }
  .toast-stack { bottom: calc(var(--tabbar-h) + var(--sp-3)); }
  .modal-panel { padding: var(--sp-5); border-radius: var(--r-xl); }
}

/* ------------------------------------------------------------------ */
/* Offline shell (offline.html)                                        */
/* ------------------------------------------------------------------ */

.offline-shell {
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 24px;
  background: var(--canvas);
}

.offline-card {
  width: min(440px, 100%);
  background: var(--surface-raised);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  padding: clamp(28px, 5vw, 44px);
  text-align: center;
  display: grid;
  gap: 14px;
  justify-items: center;
}

.offline-card h1 {
  font-size: var(--text-xl);
  letter-spacing: -0.02em;
}

.offline-card p {
  margin: 0;
  color: var(--text-muted);
  font-size: var(--text-sm);
  line-height: 1.65;
}

.offline-icon {
  width: 56px;
  height: 56px;
  border-radius: var(--r-sm);
  display: grid;
  place-items: center;
  background: var(--amber-100);
  color: var(--amber-600);
}

.offline-icon svg {
  width: 28px;
  height: 28px;
}

.offline-note {
  font-size: var(--text-xs) !important;
  color: var(--text-subtle) !important;
  border-top: 1px dashed var(--border);
  padding-top: 12px;
  width: 100%;
}

/* ------------------------------------------------------------------ */
/* Activity panel (top-bar bell)                                       */
/* ------------------------------------------------------------------ */

.notify-panel {
  position: absolute;
  top: calc(100% + 8px);
  right: var(--sp-4);
  width: min(360px, calc(100vw - 24px));
  max-height: min(70vh, 520px);
  overflow-y: auto;
  padding: var(--sp-3);
  border-radius: var(--r-lg);
  border: 1px solid var(--border);
  background: var(--surface-raised);
  box-shadow: var(--shadow-lg, 0 18px 40px rgba(0, 0, 0, 0.45));
  z-index: 70;
}

.notify-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-3);
  padding: 2px 6px var(--sp-2);
}

.notify-head strong { font-size: var(--text-sm); }

.notify-item {
  display: flex;
  gap: 10px;
  padding: 10px;
  border-radius: var(--r-md);
  color: inherit;
  text-decoration: none;
}

.notify-item:hover, .notify-item:focus-visible { background: var(--surface); }

.notify-item.is-unread { background: var(--surface); }

.notify-icon {
  display: inline-grid;
  place-items: center;
  width: 30px;
  height: 30px;
  flex: none;
  border-radius: 50%;
  background: var(--surface-sunken);
  color: var(--violet-600);
}

.notify-icon svg { width: 16px; height: 16px; }

.notify-body { display: grid; gap: 2px; min-width: 0; }
.notify-body strong { font-size: var(--text-sm); font-weight: 600; }
.notify-body small { font-size: var(--text-xs); color: var(--text-subtle); line-height: 1.5; }

.notify-item.is-unread .notify-body strong::after {
  content: "";
  display: inline-block;
  width: 6px;
  height: 6px;
  margin-left: 6px;
  border-radius: 50%;
  background: var(--live);
  vertical-align: middle;
}

.notify-empty { padding: var(--sp-4) var(--sp-3); text-align: center; }

@media (max-width: 560px) {
  .notify-panel { right: 8px; left: 8px; width: auto; }
}
