/* ==========================================================================
   Jeewians Modern Design System & Component Library
   ========================================================================== */

:root {
  /* Brand Palette (Deep Violet / Indigo) */
  --p: #6366f1;
  --p-hover: #4f46e5;
  --p-dark: #4338ca;
  --p-light: #eef2ff;
  --p-subtle: #f5f3ff;
  --p-ring: rgba(99, 102, 241, 0.25);

  /* Secondary Accents */
  --accent-cyan: #06b6d4;
  --accent-pink: #ec4899;
  --accent-amber: #f59e0b;

  /* Subject Colors */
  --phy: #2563eb;
  --phy-bg: #eff6ff;
  --chem: #059669;
  --chem-bg: #ecfdf5;
  --math: #d97706;
  --math-bg: #fffbeb;

  /* Semantic Feedback */
  --ok: #10b981;
  --ok-bg: #ecfdf5;
  --ok-border: #a7f3d0;
  --warn: #f59e0b;
  --warn-bg: #fffbeb;
  --warn-border: #fde68a;
  --bad: #ef4444;
  --bad-bg: #fef2f2;
  --bad-border: #fecaca;
  --info: #3b82f6;
  --info-bg: #eff6ff;

  /* Typography & Surfaces */
  --ink: #0f172a;
  --ink-soft: #334155;
  --mut: #64748b;
  --mut-light: #94a3b8;
  --bd: #e2e8f0;
  --bd-dark: #cbd5e1;
  --bg: #f8fafc;
  --surface: #ffffff;
  --surface-alt: #f1f5f9;

  /* Shadows & Radius */
  --radius-sm: 8px;
  --radius: 12px;
  --radius-lg: 16px;
  --radius-full: 9999px;

  --sh-xs: 0 1px 2px 0 rgb(0 0 0 / 0.05);
  --sh-sm: 0 1px 3px 0 rgb(0 0 0 / 0.1), 0 1px 2px -1px rgb(0 0 0 / 0.1);
  --sh: 0 4px 6px -1px rgb(0 0 0 / 0.08), 0 2px 4px -2px rgb(0 0 0 / 0.06);
  --sh-md: 0 10px 15px -3px rgb(0 0 0 / 0.08), 0 4px 6px -4px rgb(0 0 0 / 0.04);
  --sh-lg: 0 20px 25px -5px rgb(0 0 0 / 0.08), 0 8px 10px -6px rgb(0 0 0 / 0.04);

  --font-sans: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

*, *::before, *::after {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
  color-scheme: light;
}

body {
  margin: 0;
  font-family: var(--font-sans);
  font-size: 15px;
  line-height: 1.6;
  color: var(--ink);
  background-color: var(--bg);
  padding-bottom: 80px;
  -webkit-font-smoothing: antialiased;
}

a {
  color: var(--p);
  text-decoration: none;
  transition: color 0.15s ease, opacity 0.15s ease;
}
a:hover {
  color: var(--p-hover);
}

/* ==========================================================================
   Header & Navigation (Consolidated)
   ========================================================================== */

.notif-bell {
  position: relative;
  font-size: 1.15rem;
  padding: 6px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #cbd5e1 !important;
}
.notif-bell sup {
  position: absolute;
  top: 2px;
  right: 0px;
  background: var(--bad);
  color: #fff;
  font-size: 0.65rem;
  font-weight: 700;
  padding: 1px 5px;
  border-radius: 99px;
  line-height: 1.2;
}

.profile-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: rgba(255, 255, 255, 0.1);
  padding: 4px 12px;
  border-radius: var(--radius-full);
  color: #fff !important;
  font-weight: 600;
  font-size: 0.88rem;
  border: 1px solid rgba(255, 255, 255, 0.12);
  transition: background 0.15s ease;
}
.profile-pill:hover {
  background: rgba(255, 255, 255, 0.18);
}

/* ==========================================================================
   Main Container & Layouts
   ========================================================================== */

main {
  max-width: 1120px;
  margin: 0 auto;
  padding: 24px 20px;
}

.grid {
  display: grid;
  gap: 16px;
}
.g2 {
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
}
.g3 {
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
}
.g4 {
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
}

.row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: center;
}
.row > * {
  width: auto;
}
.row .grow {
  flex: 1;
  min-width: 140px;
}

/* ==========================================================================
   Cards & Surfaces
   ========================================================================== */

.card {
  background: var(--surface);
  border: 1px solid var(--bd);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 16px;
  box-shadow: var(--sh-sm);
  transition: transform 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease;
}
a.card {
  display: block;
  color: inherit;
}
a.card:hover {
  transform: translateY(-2px);
  box-shadow: var(--sh-md);
  border-color: #cbd5e1;
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}

/* ==========================================================================
   Typography
   ========================================================================== */

h1, h2, h3, h4 {
  color: var(--ink);
  font-weight: 700;
  line-height: 1.25;
}
h1 {
  font-size: 1.75rem;
  margin: 0 0 16px;
  letter-spacing: -0.02em;
}
h2 {
  font-size: 1.25rem;
  margin: 0 0 12px;
  letter-spacing: -0.01em;
}
h3 {
  font-size: 1.05rem;
  margin: 0 0 8px;
}

.mut {
  color: var(--mut);
  font-size: 0.9rem;
}
.stat {
  font-size: 1.85rem;
  font-weight: 800;
  color: var(--ink);
  line-height: 1.1;
  letter-spacing: -0.02em;
  margin: 6px 0;
}
.stat.primary {
  color: var(--p);
}

/* ==========================================================================
   Buttons & Interactive Elements
   ========================================================================== */

.btn, button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: var(--p);
  color: #fff;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  padding: 9px 18px;
  font-family: inherit;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  min-height: 40px;
  box-shadow: var(--sh-xs);
  transition: all 0.15s cubic-bezier(0.4, 0, 0.2, 1);
  text-decoration: none;
  user-select: none;
}
.btn:hover, button:hover {
  background: var(--p-hover);
  color: #fff;
  transform: translateY(-1px);
  box-shadow: var(--sh);
}
.btn:active, button:active {
  transform: translateY(0);
}

.btn.alt, button.alt {
  background: var(--surface);
  color: var(--ink-soft);
  border: 1px solid var(--bd);
  box-shadow: var(--sh-xs);
}
.btn.alt:hover, button.alt:hover {
  background: var(--surface-alt);
  border-color: var(--bd-dark);
  color: var(--ink);
}

.btn.sm, button.sm {
  padding: 6px 12px;
  min-height: 32px;
  font-size: 0.85rem;
  border-radius: 6px;
}

.btn.lg {
  padding: 13px 26px;
  font-size: 1.05rem;
  border-radius: var(--radius);
}

.btn.danger {
  background: var(--bad);
  color: #fff;
}
.btn.danger:hover {
  background: #dc2626;
}

.btn.outline-primary {
  background: transparent;
  color: var(--p);
  border: 1.5px solid var(--p);
}
.btn.outline-primary:hover {
  background: var(--p-light);
  color: var(--p-hover);
}

/* ==========================================================================
   Form Controls
   ========================================================================== */

input, select, textarea {
  font-family: inherit;
  font-size: 0.95rem;
  padding: 10px 14px;
  border: 1px solid var(--bd);
  border-radius: var(--radius-sm);
  width: 100%;
  background: var(--surface);
  color: var(--ink);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--p);
  box-shadow: 0 0 0 3px var(--p-ring);
}
input[type=checkbox], input[type=radio] {
  width: 18px;
  height: 18px;
  accent-color: var(--p);
  cursor: pointer;
}
label {
  display: block;
  margin: 10px 0 5px;
  font-weight: 600;
  font-size: 0.92rem;
  color: var(--ink-soft);
}
form.inline {
  display: inline;
}
form.inline button {
  width: auto;
}

/* ==========================================================================
   Badges, Pills, Progress
   ========================================================================== */

.pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: var(--p-light);
  color: var(--p-dark);
  border-radius: var(--radius-full);
  padding: 3px 10px;
  font-size: 0.8rem;
  font-weight: 600;
  margin-right: 6px;
  line-height: 1.3;
}
.pill.ok {
  background: var(--ok-bg);
  color: #065f46;
  border: 1px solid var(--ok-border);
}
.pill.bad {
  background: var(--bad-bg);
  color: #991b1b;
  border: 1px solid var(--bad-border);
}
.pill.warn {
  background: var(--warn-bg);
  color: #92400e;
  border: 1px solid var(--warn-border);
}
.pill.phy {
  background: var(--phy-bg);
  color: var(--phy);
}
.pill.chem {
  background: var(--chem-bg);
  color: var(--chem);
}
.pill.math {
  background: var(--math-bg);
  color: var(--math);
}

.bar {
  height: 10px;
  background: var(--bd);
  border-radius: var(--radius-full);
  overflow: hidden;
  margin: 8px 0;
}
.bar i {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, var(--p), #818cf8);
  border-radius: var(--radius-full);
  transition: width 0.4s ease;
}
.bar.phy i { background: linear-gradient(90deg, #2563eb, #60a5fa); }
.bar.chem i { background: linear-gradient(90deg, #059669, #34d399); }
.bar.math i { background: linear-gradient(90deg, #d97706, #fbbf24); }

.msgs .m {
  padding: 12px 18px;
  border-radius: var(--radius-sm);
  margin-bottom: 12px;
  background: var(--info-bg);
  color: #1e40af;
  border: 1px solid #bfdbfe;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 8px;
}
.m.error {
  background: var(--bad-bg);
  color: #991b1b;
  border-color: var(--bad-border);
}
.m.success {
  background: var(--ok-bg);
  color: #065f46;
  border-color: var(--ok-border);
}

.errorlist {
  color: var(--bad);
  list-style: none;
  padding: 0;
  margin: 6px 0;
  font-size: 0.88rem;
  font-weight: 500;
}

/* ==========================================================================
   Tables & Options
   ========================================================================== */

table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  margin: 12px 0;
}
td, th {
  padding: 12px 16px;
  border-bottom: 1px solid var(--bd);
  text-align: left;
}
th {
  background: var(--surface-alt);
  font-weight: 700;
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--mut);
}
tr:last-child td {
  border-bottom: none;
}

.opt {
  display: flex;
  gap: 12px;
  align-items: center;
  padding: 14px 16px;
  border: 1.5px solid var(--bd);
  border-radius: var(--radius);
  margin: 8px 0;
  background: var(--surface);
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s ease;
}
.opt:hover {
  border-color: #cbd5e1;
  background: #fdfdfd;
}
.opt.selected {
  border-color: var(--p);
  background: var(--p-light);
}
.opt.right {
  border-color: var(--ok);
  background: var(--ok-bg);
}
.opt.wrong {
  border-color: var(--bad);
  background: var(--bad-bg);
}
.qimg {
  max-width: 100%;
  height: auto;
  border-radius: var(--radius-sm);
  margin: 10px 0;
}

/* ==========================================================================
   Hero & Showcase Sections
   ========================================================================== */

.hero {
  background: linear-gradient(135deg, #090d16 0%, #1e1145 50%, #2e1065 100%);
  color: #fff;
  border-radius: 20px;
  padding: 48px 36px;
  margin-bottom: 32px;
  position: relative;
  overflow: hidden;
  box-shadow: 0 10px 30px -10px rgba(99, 102, 241, 0.3);
}
.hero::after {
  content: "";
  position: absolute;
  top: -50%;
  right: -20%;
  width: 500px;
  height: 500px;
  background: radial-gradient(circle, rgba(139, 92, 246, 0.25) 0%, transparent 70%);
  pointer-events: none;
}
.hero h1 {
  font-size: 2.6rem;
  color: #fff;
  margin: 0 0 14px;
  font-weight: 900;
  letter-spacing: -0.03em;
  line-height: 1.15;
}
.hero p {
  color: #e2e8f0;
  font-size: 1.15rem;
  max-width: 640px;
  margin: 0 0 24px;
  line-height: 1.5;
}
.hero-tag {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: rgba(255, 255, 255, 0.12);
  color: #e0e7ff;
  font-size: 0.85rem;
  font-weight: 600;
  padding: 4px 14px;
  border-radius: var(--radius-full);
  margin-bottom: 16px;
  backdrop-filter: blur(8px);
  border: 1px solid rgba(255, 255, 255, 0.15);
}

/* Feature grid item */
.feature-box {
  background: var(--surface);
  border: 1px solid var(--bd);
  border-radius: var(--radius);
  padding: 24px;
  transition: all 0.2s ease;
  box-shadow: var(--sh-sm);
}
.feature-box:hover {
  transform: translateY(-3px);
  box-shadow: var(--sh-md);
  border-color: #cbd5e1;
}
.feature-icon {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  background: var(--p-light);
  color: var(--p);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.35rem;
  margin-bottom: 14px;
}

/* ==========================================================================
   Bottom Navigation (Floating PWA Mobile Dock)
   ========================================================================== */

nav.bottom {
  position: fixed;
  bottom: 12px;
  left: 14px;
  right: 14px;
  max-width: 480px;
  margin: 0 auto;
  background: rgba(255, 255, 255, 0.88);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid rgba(255, 255, 255, 0.3);
  border-radius: 99px;
  display: flex;
  align-items: center;
  justify-content: space-around;
  padding: 6px 12px;
  z-index: 99;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.15), 0 2px 6px rgba(0, 0, 0, 0.08);
  transition: all 0.3s ease;
}

nav.bottom a {
  flex: 1;
  text-align: center;
  padding: 6px 4px;
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--mut);
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  border-radius: 99px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  text-decoration: none;
}

nav.bottom a b {
  font-size: 1.25rem;
  line-height: 1;
}

nav.bottom a:active,
nav.bottom a.on,
nav.bottom a:hover {
  color: var(--p);
  transform: scale(0.95);
}

@media (min-width: 860px) {
  header.top nav {
    display: flex;
  }
  nav.bottom {
    display: none;
  }
  body {
    padding-bottom: 0;
  }
}

/* Custom badges & cosmetic items */
.frame-gold {
  outline: 3px solid #f59e0b;
  border-radius: 99px;
  box-shadow: 0 0 10px rgba(245, 158, 11, 0.4);
}
.done {
  text-decoration: line-through;
  color: var(--mut);
}

/* Footer */
footer.site-footer {
  border-top: 1px solid var(--bd);
  margin-top: 48px;
  padding: 32px 0 20px;
  color: var(--mut);
  font-size: 0.9rem;
}

/* ==========================================================================
   Comprehensive Responsive Architecture & Mobile Polish
   ========================================================================== */

/* Universal Overflow & Media Protection */
html, body {
  overflow-x: hidden;
  max-width: 100vw;
  width: 100%;
}

img, svg, video, canvas {
  max-width: 100%;
  height: auto;
}

/* Safe Area Insets for iOS & Modern Edge Devices */
body {
  padding-bottom: calc(76px + env(safe-area-inset-bottom, 0px));
}

nav.bottom {
  bottom: calc(12px + env(safe-area-inset-bottom, 0px));
}

/* KaTeX Math Equations Horizontal Scroll Guard */
.katex-display {
  overflow-x: auto !important;
  overflow-y: hidden !important;
  max-width: 100% !important;
  padding: 8px 0 !important;
  -webkit-overflow-scrolling: touch !important;
  margin: 1em 0 !important;
}

.katex {
  max-width: 100% !important;
  white-space: normal;
}

/* Responsive Table Wrapper */
.table-responsive {
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  margin-bottom: 16px;
  border-radius: var(--radius-sm);
}

table {
  max-width: 100%;
}


/* Mobile Navigation Slide-Over Drawer */
.mobile-nav-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.65);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  z-index: 999;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
}
.mobile-nav-backdrop.open {
  opacity: 1;
  pointer-events: auto;
}

.mobile-drawer {
  position: fixed;
  top: 0;
  left: 0;
  width: 290px;
  max-width: 85vw;
  height: 100%;
  background: var(--surface);
  color: var(--ink);
  z-index: 1000;
  display: flex;
  flex-direction: column;
  box-shadow: 4px 0 25px rgba(0, 0, 0, 0.3);
  transform: translateX(-100%);
  transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  overflow-y: auto;
  border-right: 1px solid var(--bd);
}
.mobile-drawer.open {
  transform: translateX(0);
}

.mobile-drawer-header {
  padding: 18px 20px;
  border-bottom: 1px solid var(--bd);
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--surface-alt);
}

.mobile-drawer-links {
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.mobile-nav-link {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  color: var(--ink);
  font-weight: 600;
  font-size: 0.92rem;
  text-decoration: none;
  transition: all 0.15s ease;
}
.mobile-nav-link:hover, .mobile-nav-link.active {
  background: var(--p-light);
  color: var(--p);
}
.mobile-nav-more {
  margin-top: 4px;
  border-top: 1px solid var(--bd);
}
.mobile-nav-more summary {
  padding: 12px 14px;
  color: var(--mut);
  font-size: 0.88rem;
  font-weight: 700;
  cursor: pointer;
  list-style: none;
}
.mobile-nav-more summary::-webkit-details-marker { display: none; }
.mobile-nav-more summary::after { content: "+"; float: right; color: var(--mut-light); }
.mobile-nav-more[open] summary::after { content: "−"; }
.mobile-nav-more .mobile-nav-link { margin-left: 8px; }
a.mobile-nav-link.drawer-dock-duplicate { display: none; }

/* Tablet & Mobile Breakpoints */
@media (max-width: 860px) {
  header.top {
    padding: 10px 14px;
    gap: 10px;
  }
  header.top .brand {
    font-size: 1.15rem;
  }
  .user-nav {
    gap: 8px;
  }
}

@media (max-width: 768px) {
  /* Prevent iOS Safari Automatic Zoom on Form Focus */
  input[type="text"],
  input[type="number"],
  input[type="email"],
  input[type="password"],
  input[type="search"],
  select,
  textarea {
    font-size: 16px !important;
  }

  /* Responsive Grids */
  .grid.g2 {
    grid-template-columns: 1fr;
  }
  .grid.g3 {
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 260px), 1fr));
  }
  .grid.g4 {
    grid-template-columns: repeat(2, 1fr);
  }

  /* Floating elements clearance */
  .floating-action-mobile {
    bottom: calc(76px + env(safe-area-inset-bottom, 0px)) !important;
  }
}

@media (max-width: 640px) {
  main {
    padding: 16px 12px;
  }
  .card {
    padding: 16px 14px;
    border-radius: 12px;
    margin-bottom: 12px;
  }
  h1 {
    font-size: 1.45rem;
    line-height: 1.25;
    margin-bottom: 12px;
  }
  h2 {
    font-size: 1.18rem;
    margin-bottom: 10px;
  }
  h3 {
    font-size: 1rem;
  }
  .hero {
    padding: 28px 18px;
    border-radius: 16px;
    margin-bottom: 20px;
  }
  .hero h1 {
    font-size: 1.7rem;
    line-height: 1.2;
  }
  .hero p {
    font-size: 0.95rem;
    margin-bottom: 18px;
  }
  .stat {
    font-size: 1.45rem;
  }
  .btn.lg {
    padding: 10px 18px;
    font-size: 0.95rem;
    width: 100%;
    justify-content: center;
  }
  .grid.g4 {
    grid-template-columns: 1fr;
    gap: 12px;
  }
  .profile-pill .name-text {
    display: none;
  }
  .user-nav .btn.alt {
    display: none;
  }
}
@media (min-width: 861px) and (max-width: 1179px) {
  a.mobile-nav-link.drawer-dock-duplicate { display: flex; }
}

@media (max-width: 400px) {
  main {
    padding: 12px 8px;
  }
  .card {
    padding: 14px 10px;
  }
  .btn {
    padding: 8px 14px;
    font-size: 0.88rem;
  }
}

/* ==========================================================================
   Refined responsive theme
   ========================================================================== */
:root {
  --p: #5b5bd6;
  --p-hover: #4949bd;
  --p-dark: #39399e;
  --p-light: #eeeeff;
  --p-subtle: #f6f6ff;
  --ink: #172033;
  --ink-soft: #39445a;
  --mut: #68748a;
  --mut-light: #929caf;
  --bd: #e5e8ef;
  --bd-dark: #d4d9e4;
  --bg: #f5f7fb;
  --surface: #fff;
  --surface-alt: #f7f8fc;
  --radius: 14px;
  --radius-lg: 20px;
  --font-sans: "DM Sans", system-ui, sans-serif;
  --font-display: "Plus Jakarta Sans", "DM Sans", system-ui, sans-serif;

  /* Compatibility names used by older page templates. */
  --primary: var(--p);
  --pri: var(--p);
  --primary-bg: var(--p-light);
  --accent: var(--accent-cyan);
  --text: var(--ink);
  --text-sec: var(--mut);
  --fg: var(--ink);
  --panel: var(--surface);
  --card: var(--surface);
  --bg-card: var(--surface);
  --bg-mut: var(--surface-alt);
  --border: var(--bd);
  --danger: var(--bad);
  --success: var(--ok);
  --shadow-xs: var(--sh-xs);
  --shadow-sm: var(--sh-sm);
  --shadow-md: var(--sh-md);
  --shadow-lg: var(--sh-lg);
}

body {
  background: var(--bg);
  font-size: 15px;
  line-height: 1.65;
}

header.top {
  min-height: 64px;
  padding: 0 clamp(16px, 3vw, 36px);
  background: rgba(255, 255, 255, 0.98);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  color: var(--ink);
  border-bottom: 1px solid var(--bd);
  box-shadow: 0 2px 12px rgba(15, 23, 42, 0.05);
  display: flex;
  align-items: center;
  position: sticky;
  top: 0;
  z-index: 100;
}

header.top .brand {
  order: 0;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 1.25rem;
  font-weight: 900;
  letter-spacing: 0.025em;
  color: var(--ink);
  text-decoration: none;
  flex: 0 0 auto;
}
header.top .brand span {
  background: linear-gradient(135deg, #7c3aed, #4f46e5);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

/* Mobile Hamburger Button (Default hidden on desktop) */
.hamburger-btn {
  display: none;
  align-items: center;
  justify-content: center;
  background: var(--p-light);
  border: 1px solid #d9d9fb;
  border-radius: 8px;
  color: var(--p-dark) !important;
  width: 38px;
  height: 38px;
  cursor: pointer;
  padding: 0;
  transition: all 0.15s ease;
  flex: 0 0 auto;
}
.hamburger-btn:hover {
  background: #e3e4ff;
  color: var(--p-dark) !important;
}

/* Desktop Navigation */
header.top nav {
  order: 1;
  display: flex;
  align-items: center;
  gap: 4px;
  margin-left: 20px;
  flex-wrap: nowrap;
}

/* Nav Dropdown Container */
.nav-item-dropdown {
  position: relative;
  display: inline-block;
}

/* Nav Buttons & Dropdown Triggers */
.top-nav-btn,
header.top nav > a {
  display: inline-flex !important;
  align-items: center !important;
  gap: 6px !important;
  padding: 8px 14px !important;
  border-radius: 8px !important;
  font-size: 0.9rem !important;
  font-weight: 600 !important;
  color: var(--ink-soft) !important;
  background: transparent !important;
  border: none !important;
  cursor: pointer !important;
  user-select: none !important;
  white-space: nowrap !important;
  text-decoration: none !important;
  line-height: 1 !important;
  height: 38px !important;
  box-sizing: border-box !important;
  transition: all 0.15s ease !important;
}

.top-nav-btn:hover,
header.top nav > a:hover,
.nav-item-dropdown.open .top-nav-btn {
  color: var(--p-dark) !important;
  background: var(--p-light) !important;
}

.nav-item-dropdown .chevron-icon {
  width: 12px;
  height: 12px;
  transition: transform 0.2s ease;
  color: var(--mut);
  flex-shrink: 0;
}
.nav-item-dropdown.open .chevron-icon {
  transform: rotate(180deg);
  color: var(--p-dark);
}

/* Dropdown Menu Container (Animated & Exclusively Toggled) */
.top-nav-menu {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  min-width: 250px;
  padding: 8px;
  border: 1px solid rgba(226, 232, 240, 0.9);
  border-radius: 14px;
  background: #ffffff;
  box-shadow: 0 16px 36px -4px rgba(15, 23, 42, 0.12), 0 6px 12px -2px rgba(15, 23, 42, 0.05);
  display: flex;
  flex-direction: column;
  gap: 3px;
  z-index: 120;
  opacity: 0;
  visibility: hidden;
  transform: translateY(-6px);
  pointer-events: none;
  transition: opacity 0.18s cubic-bezier(0.16, 1, 0.3, 1), transform 0.18s cubic-bezier(0.16, 1, 0.3, 1), visibility 0.18s;
}

.nav-item-dropdown.open > .top-nav-menu {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
  pointer-events: auto;
}

header.top .top-nav-menu a {
  display: flex !important;
  align-items: center !important;
  gap: 10px !important;
  padding: 8px 12px !important;
  border-radius: 8px !important;
  color: var(--ink) !important;
  font-size: 0.88rem !important;
  font-weight: 500 !important;
  white-space: nowrap !important;
  height: auto !important;
  text-decoration: none !important;
  transition: all 0.15s ease !important;
}
header.top .top-nav-menu a:hover {
  color: var(--p-dark) !important;
  background: var(--p-light) !important;
  transform: translateX(2px);
}
.top-nav-menu a .nav-icon {
  font-size: 1.15rem;
  line-height: 1;
  width: 22px;
  height: 22px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

header.top .sp {
  order: 2;
  flex: 1;
}

header.top .user-nav {
  order: 3;
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 10px;
}

.profile-pill {
  padding: 5px 12px;
  background: var(--surface-alt);
  border: 1px solid var(--bd);
  border-radius: 99px;
  color: var(--ink) !important;
  transition: all 0.15s ease;
}
.profile-pill:hover {
  background: #eff1f8;
}
.notif-bell {
  color: var(--mut) !important;
}
.notif-bell:hover {
  color: var(--ink) !important;
}

main { max-width: 1240px; padding: clamp(20px, 3vw, 36px) clamp(16px, 3vw, 32px); }
.grid { gap: 18px; }
.card, .feature-box {
  border-radius: var(--radius);
  border-color: var(--bd);
  box-shadow: 0 2px 8px rgba(25, 35, 60, .035), 0 1px 2px rgba(25, 35, 60, .025);
}
.card { padding: 22px; }
.grid > .card, .grid > a.card, .grid > .feature-box { margin-bottom: 0; }
a.card:hover, .feature-box:hover { transform: translateY(-3px); box-shadow: 0 14px 34px rgba(25, 35, 60, .09); }
h1, h2, h3, h4 { letter-spacing: -.025em; }
h1 { font-size: clamp(1.65rem, 3vw, 2.15rem); }
.btn, button { border-radius: 10px; font-weight: 700; line-height: 1.35; }
.btn:focus-visible, button:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible {
  outline: 3px solid var(--p-ring);
  outline-offset: 2px;
}

.hero {
  padding: clamp(32px, 6vw, 68px) clamp(24px, 5vw, 56px);
  border-radius: 24px;
  background: radial-gradient(ellipse at 84% 20%, rgba(129,140,248,.3), transparent 38%), linear-gradient(125deg, #101827 0%, #211c49 58%, #373079 100%);
  box-shadow: 0 24px 60px rgba(37, 34, 95, .18);
}
.hero h1 { max-width: 850px; font-size: clamp(2.1rem, 5vw, 3.5rem); line-height: 1.08; }
.hero p { max-width: 660px; color: #d7deed; }
.hero-tag { letter-spacing: .015em; }
.feature-box { padding: 26px; }
.feature-icon { border-radius: 14px; }
footer.site-footer { padding: 28px 0 32px; }
.site-footer-inner { width: calc(100% - clamp(32px, 6vw, 64px)); max-width: 1176px; margin: 0 auto; display: flex; justify-content: space-between; flex-wrap: wrap; gap: 12px 24px; align-items: center; }
.site-footer-inner b { color: var(--ink); }

nav.bottom {
  border-color: rgba(226,232,240,.8);
  background: rgba(255,255,255,.94);
  box-shadow: 0 12px 36px rgba(20, 30, 55, .16);
  padding: 7px 10px;
}

@media (min-width: 860px) {
  header.top nav { display: flex !important; }
  header.top .hamburger-btn { display: none !important; }
  body { padding-bottom: 0; }
}
@media (max-width: 859px) {
  header.top { min-height: 60px; }
  header.top nav { display: none !important; }
  header.top .hamburger-btn { display: inline-flex !important; }
  .user-nav { gap: 7px; }
  .user-nav form.inline { display: none; }
}
@media (max-width: 640px) {
  main { padding: 18px 14px 28px; }
  .card { padding: 18px 16px; }
  .hero { padding: 32px 22px; border-radius: 18px; }
  .hero h1 { font-size: clamp(1.9rem, 9vw, 2.5rem); }
  .hero .row { align-items: stretch; }
  .hero .row > .btn { flex: 1 1 100%; }
  .grid.g4 { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .grid.g4 > .card { padding: 15px 12px; }
  .stat { font-size: 1.55rem; }
  .mobile-drawer { padding-bottom: env(safe-area-inset-bottom, 0px); }
  .site-footer-inner { align-items: flex-start; }
}
@media (max-width: 380px) {
  header.top { gap: 8px; padding-inline: 10px; }
  header.top .brand { font-size: 1.02rem; }
  .grid.g4 { grid-template-columns: 1fr 1fr; }
  nav.bottom { left: 8px; right: 8px; bottom: calc(8px + env(safe-area-inset-bottom, 0px)); }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; transition-duration: .01ms !important; }
}

/* Shared page rhythm for every screen */
main > h1:first-child,
main > .card-header:first-child { margin-top: 0; }
main > h1:first-child { margin-bottom: 20px; }
main > .card-header:first-child { margin-bottom: 22px; }
.card-header { gap: 16px; align-items: flex-start; }
.card-header > :first-child { min-width: 0; }
.card-header h1, .card-header h2 { margin-top: 0; }
.card-header .btn { flex: 0 0 auto; }
.row { min-width: 0; }
.row > * { min-width: 0; }
.row .grow { min-width: 0; overflow-wrap: anywhere; }
.grid { align-items: stretch; }
.grid > * { min-width: 0; }
.card p:last-child { margin-bottom: 0; }
.feature-box { height: 100%; }

label { line-height: 1.45; }
input, select, textarea { min-width: 0; }
textarea { min-height: 112px; resize: vertical; }
input[type="checkbox"], input[type="radio"] { width: 18px; min-width: 18px; flex: 0 0 18px; }
fieldset { min-width: 0; margin: 0 0 16px; padding: 16px; border: 1px solid var(--bd); border-radius: var(--radius); }
legend { padding: 0 6px; color: var(--ink-soft); font-weight: 700; }
table { table-layout: auto; }
td, th { vertical-align: top; overflow-wrap: anywhere; }
th { color: var(--ink-soft); }
.table-responsive { border: 1px solid var(--bd); background: var(--surface); }
.table-responsive table { margin: 0; }
.table-responsive th { position: sticky; top: 0; z-index: 1; }
pre, code { max-width: 100%; overflow-x: auto; }
hr { border: 0; border-top: 1px solid var(--bd); margin: 20px 0; }
.msgs { margin-bottom: 18px; }
.msgs .m { border-radius: 12px; box-shadow: var(--sh-xs); }
.site-footer { color: var(--mut); }
.site-footer-inner > div { min-width: 0; }
.site-footer-inner .row { justify-content: flex-end; }

@media (max-width: 640px) {
  .site-footer-inner { width: calc(100% - 28px); }
  main > .card-header:first-child { align-items: stretch; flex-direction: column; }
  .card-header { flex-wrap: wrap; }
  .card-header .btn { align-self: flex-start; }
  .table-responsive { margin-left: -2px; margin-right: -2px; }
  td, th { padding: 10px 12px; }
  .site-footer-inner { flex-direction: column; }
  .site-footer-inner .row { justify-content: flex-start; }
}

/* Final responsive shell rules: desktop header >= 860px, mobile header < 860px */
@media (min-width: 860px) {
  header.top .hamburger-btn { display: none !important; }
  header.top nav { display: flex !important; }
}
@media (max-width: 859px) {
  header.top nav { display: none !important; }
  header.top .hamburger-btn { display: inline-flex !important; }
}

main h1:not(.hero h1) { font-size: clamp(1.6rem, 3vw, 2.15rem) !important; }
main h2 { font-size: clamp(1.15rem, 2vw, 1.4rem) !important; }
main h3 { font-size: 1.05rem !important; }
main h1, main h2, main h3, main h4 { font-family: var(--font-display); }
main h1, main h2, main h3 { text-wrap: pretty; }
main > .card-header { margin-bottom: 22px; }
main > div[style*="max-width"]:not(.card) {
  width: 100%;
  margin-right: auto;
  margin-left: auto;
  padding-right: 0 !important;
  padding-left: 0 !important;
}
.card, .feature-box { border-radius: var(--radius) !important; }
.card, .feature-box, .card-header, .row, .grid > * { min-width: 0; }
.card-header { flex-wrap: wrap; }
.row { row-gap: 10px; }
button, .btn { white-space: normal; }
input, select, textarea { max-width: 100%; }
label { color: var(--ink-soft); }
input, select, textarea { border-color: var(--bd); }
input::placeholder, textarea::placeholder { color: var(--mut-light); opacity: 1; }
table tr:hover td { background: color-mix(in srgb, var(--p-light) 34%, transparent); }
.hidden { display: none !important; }
.question-toolbar > div,
.result-toolbar > div { flex-wrap: wrap; }

@media (max-width: 640px) {
  main { padding-inline: 14px; }
  .card-header { align-items: stretch; }
  .card-header > .row { width: 100%; }
  .card-header > .row .btn { flex: 1 1 auto; }
  .question-toolbar > a:first-child { width: 100%; }
  .question-toolbar > div { width: 100%; }
  .result-toolbar > a:first-child { width: 100%; }
  .result-toolbar > div { width: 100%; }
}
