/* =====================================================================
   KOMIKO — design system
   ---------------------------------------------------------------------
   Dark-first, because that is how people actually read comics at night,
   with a full light theme for daytime and for anyone who prefers it.

   The palette is Filipino without being a flag pastiche: the gold of the
   eight-rayed sun carries every call to action, a deep midnight blue
   holds the page, and a single warm red marks anything urgent.
   ===================================================================== */

/* ------------------------------------------------------------------ */
/* 1. Tokens                                                          */
/* ------------------------------------------------------------------ */

:root {
  /* Brand */
  --gold:        #FFB800;
  --gold-light:  #FFD766;
  --gold-deep:   #FF8A1E;
  --gold-ink:    #0B1020;
  --red:         #FF4D5E;
  --teal:        #2DD4BF;
  --violet:      #8B7CFF;

  /* Dark surfaces (default theme) */
  --bg:          #070A16;
  --surface:     #0F1428;
  --surface-2:   #161D38;
  --surface-3:   #1E2748;
  --line:        #232C50;
  --line-soft:   #1A2140;

  /* Text */
  --text:        #F4F6FF;
  --text-2:      #C3C9E0;
  --text-3:      #8892B8;
  --text-4:      #5C6690;

  /* State */
  --success:     #2DD4BF;
  --warning:     #FFB800;
  --danger:      #FF4D5E;
  --info:        #6BA8FF;

  /* Typography */
  --font-display: 'Bricolage Grotesque', 'Outfit', system-ui, -apple-system,
                  'Segoe UI', Roboto, sans-serif;
  --font-body:    'Inter', system-ui, -apple-system, 'Segoe UI', Roboto,
                  'Helvetica Neue', sans-serif;
  --font-mono:    'JetBrains Mono', ui-monospace, 'SF Mono', Consolas, monospace;

  /* Scale */
  --step--2: 0.75rem;
  --step--1: 0.8125rem;
  --step-0:  0.9375rem;
  --step-1:  1.0625rem;
  --step-2:  1.375rem;
  --step-3:  1.75rem;
  --step-4:  2.25rem;
  --step-5:  clamp(2.25rem, 1.4rem + 3.6vw, 3.75rem);

  /* Radii */
  --r-sm: 8px;
  --r-md: 12px;
  --r-lg: 18px;
  --r-xl: 26px;
  --r-full: 999px;

  /* Shadows */
  --shadow-sm: 0 1px 2px rgb(0 0 0 / .3);
  --shadow-md: 0 8px 24px -8px rgb(0 0 0 / .5);
  --shadow-lg: 0 24px 56px -16px rgb(0 0 0 / .6);
  --glow-gold: 0 8px 32px -8px rgb(255 184 0 / .45);

  /* Layout */
  --wrap: 1240px;
  --wrap-narrow: 760px;
  --header-h: 66px;

  --ease: cubic-bezier(.22, 1, .36, 1);

  color-scheme: dark;
}

[data-theme='light'] {
  --bg:        #F7F8FC;
  --surface:   #FFFFFF;
  --surface-2: #F0F2F9;
  --surface-3: #E5E9F4;
  --line:      #DCE1EF;
  --line-soft: #E9EDF7;

  --text:   #0B1020;
  --text-2: #39415F;
  --text-3: #646E91;
  --text-4: #8A93B3;

  --gold-deep: #E07800;
  --shadow-md: 0 8px 24px -10px rgb(11 16 32 / .18);
  --shadow-lg: 0 24px 56px -20px rgb(11 16 32 / .22);
  --glow-gold: 0 8px 28px -10px rgb(255 184 0 / .5);

  color-scheme: light;
}

/* ------------------------------------------------------------------ */
/* 2. Reset                                                           */
/* ------------------------------------------------------------------ */

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

* { margin: 0; }

/* The hidden attribute must always win. Without this, any class that sets a
   display value (.pill, .btn, .row) silently un-hides the element. */
[hidden] { display: none !important; }

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
  scrollbar-color: var(--surface-3) transparent;
}

body {
  font-family: var(--font-body);
  font-size: var(--step-0);
  line-height: 1.65;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
}

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

input, button, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: 0; padding: 0; }

a { color: var(--gold); text-decoration: none; transition: color .15s var(--ease); }
a:hover { color: var(--gold-light); }

h1, h2, h3, h4 {
  font-family: var(--font-display);
  font-weight: 800;
  line-height: 1.12;
  letter-spacing: -0.025em;
  text-wrap: balance;
}

h1 { font-size: var(--step-5); }
h2 { font-size: var(--step-4); }
h3 { font-size: var(--step-2); }
h4 { font-size: var(--step-1); }

p { text-wrap: pretty; }

:focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: 3px;
  border-radius: 4px;
}

::selection { background: rgb(255 184 0 / .3); color: var(--text); }

::-webkit-scrollbar { width: 11px; height: 11px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: var(--surface-3);
  border-radius: var(--r-full);
  border: 3px solid var(--bg);
}
::-webkit-scrollbar-thumb:hover { background: var(--text-4); }

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

/* ------------------------------------------------------------------ */
/* 3. Layout                                                          */
/* ------------------------------------------------------------------ */

.wrap {
  width: 100%;
  max-width: var(--wrap);
  margin-inline: auto;
  padding-inline: clamp(1rem, 3vw, 2rem);
}

.wrap-narrow { max-width: var(--wrap-narrow); }

main { flex: 1; }

.section { padding-block: clamp(2.5rem, 5vw, 4.5rem); }
.section-tight { padding-block: clamp(1.75rem, 3vw, 2.75rem); }

.stack > * + * { margin-top: var(--gap, 1rem); }
.row { display: flex; align-items: center; gap: var(--gap, .75rem); }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: 1rem; }
.row-wrap { flex-wrap: wrap; }
.spacer { flex: 1; }

.grid { display: grid; gap: var(--gap, 1.25rem); }
.grid-cards {
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: clamp(.85rem, 2vw, 1.4rem);
}
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); }
.grid-3 { grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); }

/* Content-plus-sidebar and cover-plus-details layouts are declared inline
   per page. Below tablet width they all stack into a single column; the
   selector matches the minmax(0, ...) two-track pattern those pages share. */
@media (max-width: 860px) {
  .grid[style*="minmax(0,1fr) minmax(0,"],
  .grid[style*="minmax(0,200px) minmax(0,1fr)"] {
    grid-template-columns: 1fr !important;
  }
  .grid[style*="minmax(0,200px) minmax(0,1fr)"] > :first-child {
    max-width: 200px;
  }
}

.hide-sm { display: revert; }
@media (max-width: 760px) { .hide-sm { display: none !important; } }
.show-sm { display: none; }
@media (max-width: 760px) { .show-sm { display: revert; } }

/* ------------------------------------------------------------------ */
/* 4. Header                                                          */
/* ------------------------------------------------------------------ */

.site-header {
  position: sticky;
  top: 0;
  z-index: 60;
  height: var(--header-h);
  display: flex;
  align-items: center;
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: blur(18px) saturate(160%);
  border-bottom: 1px solid var(--line-soft);
}

.site-header .wrap { display: flex; align-items: center; gap: 1.25rem; }

.brand { display: flex; align-items: center; gap: .6rem; flex-shrink: 0; }
.brand svg, .brand img { width: 34px; height: 34px; }
.brand-text {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 1.3rem;
  letter-spacing: -0.04em;
  color: var(--text);
}

.nav-main { display: flex; align-items: center; gap: .25rem; }

.nav-link {
  padding: .5rem .8rem;
  border-radius: var(--r-full);
  color: var(--text-2);
  font-weight: 600;
  font-size: var(--step--1);
  transition: background .15s var(--ease), color .15s var(--ease);
  white-space: nowrap;
}
.nav-link:hover { background: var(--surface-2); color: var(--text); }
.nav-link[aria-current='page'] { color: var(--gold); background: rgb(255 184 0 / .1); }

.search-box {
  position: relative;
  flex: 1;
  max-width: 340px;
  margin-inline: auto;
}
.search-box input {
  width: 100%;
  padding: .55rem 1rem .55rem 2.4rem;
  border-radius: var(--r-full);
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--text);
  font-size: var(--step--1);
  transition: border-color .15s var(--ease), background .15s var(--ease);
}
.search-box input::placeholder { color: var(--text-4); }
.search-box input:focus {
  outline: none;
  border-color: var(--gold);
  background: var(--surface-2);
}
.search-box svg {
  position: absolute;
  left: .85rem; top: 50%;
  transform: translateY(-50%);
  width: 16px; height: 16px;
  color: var(--text-4);
  pointer-events: none;
}

.icon-btn {
  position: relative;
  display: grid;
  place-items: center;
  width: 38px; height: 38px;
  border-radius: var(--r-full);
  color: var(--text-2);
  transition: background .15s var(--ease), color .15s var(--ease);
}
.icon-btn:hover { background: var(--surface-2); color: var(--text); }
.icon-btn svg { width: 19px; height: 19px; }

.badge-dot {
  position: absolute;
  top: 6px; right: 6px;
  min-width: 16px; height: 16px;
  padding: 0 4px;
  border-radius: var(--r-full);
  background: var(--red);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  display: grid;
  place-items: center;
  border: 2px solid var(--bg);
}

.avatar {
  width: 34px; height: 34px;
  border-radius: var(--r-full);
  object-fit: cover;
  background: var(--surface-3);
  border: 1px solid var(--line);
}
.avatar-fallback {
  display: grid;
  place-items: center;
  font-weight: 800;
  font-size: .85rem;
  color: var(--gold-ink);
  background: linear-gradient(135deg, var(--gold-light), var(--gold-deep));
  border: 0;
}

/* Dropdown menus */
.menu { position: relative; }
.menu-panel {
  position: absolute;
  right: 0; top: calc(100% + .6rem);
  min-width: 226px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-lg);
  padding: .4rem;
  z-index: 70;
  animation: menu-in .16s var(--ease);
}
@keyframes menu-in {
  from { opacity: 0; transform: translateY(-6px) scale(.98); }
}
.menu-item {
  display: flex; align-items: center; gap: .65rem;
  width: 100%;
  padding: .58rem .7rem;
  border-radius: var(--r-md);
  color: var(--text-2);
  font-size: var(--step--1);
  font-weight: 500;
  text-align: left;
  transition: background .12s var(--ease), color .12s var(--ease);
}
.menu-item:hover { background: var(--surface-2); color: var(--text); }
.menu-item svg { width: 16px; height: 16px; opacity: .75; flex-shrink: 0; }
.menu-item.is-danger { color: var(--red); }
.menu-sep { height: 1px; background: var(--line-soft); margin: .35rem .5rem; }
.menu-label {
  padding: .5rem .7rem .3rem;
  font-size: var(--step--2);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .07em;
  color: var(--text-4);
}

/* ------------------------------------------------------------------ */
/* 5. Buttons                                                         */
/* ------------------------------------------------------------------ */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .5rem;
  padding: .68rem 1.3rem;
  border-radius: var(--r-full);
  font-family: var(--font-body);
  font-weight: 700;
  font-size: var(--step--1);
  letter-spacing: -0.01em;
  white-space: nowrap;
  border: 1px solid transparent;
  transition: transform .12s var(--ease), background .15s var(--ease),
              border-color .15s var(--ease), box-shadow .15s var(--ease),
              color .15s var(--ease);
}
.btn:active { transform: translateY(1px); }
.btn svg { width: 17px; height: 17px; flex-shrink: 0; }
.btn:disabled, .btn[aria-disabled='true'] {
  opacity: .5; pointer-events: none;
}

.btn-primary {
  background: linear-gradient(135deg, var(--gold-light), var(--gold));
  color: var(--gold-ink);
  box-shadow: var(--glow-gold);
}
.btn-primary:hover {
  background: linear-gradient(135deg, #FFE08A, var(--gold-light));
  color: var(--gold-ink);
}

.btn-ghost {
  background: var(--surface-2);
  color: var(--text);
  border-color: var(--line);
}
.btn-ghost:hover { background: var(--surface-3); color: var(--text); }

.btn-outline {
  border-color: var(--line);
  color: var(--text-2);
}
.btn-outline:hover { border-color: var(--gold); color: var(--gold); }

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

.btn-quiet { color: var(--text-3); padding-inline: .7rem; }
.btn-quiet:hover { color: var(--text); background: var(--surface-2); }

.btn-lg { padding: .9rem 1.8rem; font-size: var(--step-0); }
.btn-sm { padding: .42rem .85rem; font-size: var(--step--2); }
.btn-block { width: 100%; }

/* ------------------------------------------------------------------ */
/* 6. Cards and surfaces                                              */
/* ------------------------------------------------------------------ */

.card {
  background: var(--surface);
  border: 1px solid var(--line-soft);
  border-radius: var(--r-lg);
  padding: clamp(1.1rem, 2.4vw, 1.6rem);
}
.card-flush { padding: 0; overflow: hidden; }
.card-hover { transition: border-color .18s var(--ease), transform .18s var(--ease); }
.card-hover:hover { border-color: var(--line); transform: translateY(-2px); }

.panel {
  background: var(--surface);
  border: 1px solid var(--line-soft);
  border-radius: var(--r-lg);
  overflow: hidden;
}
.panel-head {
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--line-soft);
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
}
.panel-head h3 { font-size: var(--step-1); }
.panel-body { padding: 1.25rem; }

.section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.25rem;
}
.section-head h2 { font-size: var(--step-3); }
.section-head a { font-size: var(--step--1); font-weight: 700; }

/* ------------------------------------------------------------------ */
/* 7. Comic cards                                                     */
/* ------------------------------------------------------------------ */

.comic-card { display: block; color: inherit; }
.comic-card:hover { color: inherit; }

.comic-cover {
  position: relative;
  aspect-ratio: 3 / 4;
  border-radius: var(--r-md);
  overflow: hidden;
  background: var(--surface-2);
  box-shadow: var(--shadow-md);
  transition: transform .25s var(--ease), box-shadow .25s var(--ease);
}
.comic-cover img {
  width: 100%; height: 100%;
  object-fit: cover;
  transition: transform .45s var(--ease);
}
.comic-card:hover .comic-cover { transform: translateY(-4px); box-shadow: var(--shadow-lg); }
.comic-card:hover .comic-cover img { transform: scale(1.05); }

.comic-cover::after {
  content: '';
  position: absolute; inset: 0;
  background: linear-gradient(to top, rgb(7 10 22 / .85) 0%, transparent 45%);
  opacity: 0;
  transition: opacity .25s var(--ease);
}
.comic-card:hover .comic-cover::after { opacity: 1; }

.comic-title {
  margin-top: .6rem;
  font-weight: 700;
  font-size: var(--step--1);
  line-height: 1.35;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  color: var(--text);
}
.comic-meta {
  font-size: var(--step--2);
  color: var(--text-4);
  margin-top: .15rem;
  display: flex; align-items: center; gap: .4rem;
}

.cover-placeholder {
  width: 100%; height: 100%;
  display: grid; place-items: center;
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 1.6rem;
  color: rgb(255 255 255 / .28);
  background: linear-gradient(145deg, var(--surface-2), var(--surface-3));
  text-align: center;
  padding: 1rem;
}

/* Corner flags on a cover */
.cover-tag {
  position: absolute;
  top: .5rem; left: .5rem;
  padding: .18rem .5rem;
  border-radius: var(--r-sm);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: .05em;
  text-transform: uppercase;
  backdrop-filter: blur(8px);
  z-index: 2;
}
.cover-tag-gold { background: rgb(255 184 0 / .92); color: var(--gold-ink); }
.cover-tag-dark { background: rgb(7 10 22 / .78); color: #fff; }
.cover-tag-red  { background: rgb(255 77 94 / .92); color: #fff; }

.cover-chapters {
  position: absolute;
  bottom: .5rem; right: .5rem;
  padding: .18rem .5rem;
  border-radius: var(--r-sm);
  background: rgb(7 10 22 / .8);
  backdrop-filter: blur(8px);
  font-size: 10px;
  font-weight: 700;
  color: #fff;
  z-index: 2;
}

.progress-strip {
  position: absolute;
  bottom: 0; left: 0; right: 0;
  height: 3px;
  background: rgb(7 10 22 / .6);
  z-index: 2;
}
.progress-strip span {
  display: block; height: 100%;
  background: var(--gold);
}

/* ------------------------------------------------------------------ */
/* 8. Hero                                                            */
/* ------------------------------------------------------------------ */

.hero {
  position: relative;
  min-height: clamp(380px, 52vw, 560px);
  display: flex;
  align-items: flex-end;
  border-radius: var(--r-xl);
  overflow: hidden;
  isolation: isolate;
  background: var(--surface);
}
.hero-bg {
  position: absolute; inset: 0;
  z-index: -2;
}
.hero-bg img { width: 100%; height: 100%; object-fit: cover; }
.hero::before {
  content: '';
  position: absolute; inset: 0;
  z-index: -1;
  background:
    linear-gradient(to top,   rgb(7 10 22 / .96) 8%, rgb(7 10 22 / .35) 62%, transparent),
    linear-gradient(to right, rgb(7 10 22 / .92) 0%, rgb(7 10 22 / .1) 68%);
}
.hero-body {
  padding: clamp(1.5rem, 4vw, 3rem);
  max-width: 620px;
}
.hero-body h1 {
  font-size: clamp(2rem, 1.1rem + 4vw, 3.4rem);
  margin-bottom: .7rem;
  color: #fff;
}
.hero-body p {
  color: #D6DBEE;
  font-size: var(--step-1);
  margin-bottom: 1.3rem;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* Landing hero, no artwork behind it */
.hero-plain {
  position: relative;
  padding-block: clamp(3rem, 7vw, 6rem);
  text-align: center;
  isolation: isolate;
}
.hero-plain::before {
  content: '';
  position: absolute;
  z-index: -1;
  top: -30%; left: 50%;
  translate: -50% 0;
  width: min(900px, 120%);
  aspect-ratio: 1;
  background: radial-gradient(circle, rgb(255 184 0 / .16), transparent 62%);
  pointer-events: none;
}

/* ------------------------------------------------------------------ */
/* 9. Rails                                                           */
/* ------------------------------------------------------------------ */

.rail {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: minmax(148px, 1fr);
  gap: clamp(.8rem, 1.8vw, 1.25rem);
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  padding-bottom: .6rem;
  scrollbar-width: thin;
}
.rail > * { scroll-snap-align: start; }
@media (min-width: 760px) {
  .rail { grid-auto-columns: minmax(172px, 1fr); }
}

/* ------------------------------------------------------------------ */
/* 10. Chips, pills, badges                                           */
/* ------------------------------------------------------------------ */

.chip {
  display: inline-flex;
  align-items: center;
  gap: .35rem;
  padding: .32rem .75rem;
  border-radius: var(--r-full);
  background: var(--surface-2);
  border: 1px solid var(--line-soft);
  color: var(--text-2);
  font-size: var(--step--2);
  font-weight: 600;
  transition: all .15s var(--ease);
}
a.chip:hover { border-color: var(--gold); color: var(--gold); }
.chip[aria-pressed='true'], .chip.is-on {
  background: rgb(255 184 0 / .14);
  border-color: var(--gold);
  color: var(--gold);
}

.pill {
  display: inline-flex;
  align-items: center;
  gap: .3rem;
  padding: .2rem .6rem;
  border-radius: var(--r-full);
  font-size: var(--step--2);
  font-weight: 700;
  letter-spacing: .01em;
}
.pill-gold    { background: rgb(255 184 0 / .15); color: var(--gold); }
.pill-teal    { background: rgb(45 212 191 / .15); color: var(--teal); }
.pill-red     { background: rgb(255 77 94 / .15); color: var(--red); }
.pill-violet  { background: rgb(139 124 255 / .16); color: var(--violet); }
.pill-muted   { background: var(--surface-2); color: var(--text-3); }

.rating {
  display: inline-flex;
  align-items: center;
  gap: .25rem;
  color: var(--gold);
  font-weight: 700;
  font-size: var(--step--2);
}
.rating svg { width: 13px; height: 13px; }

/* ------------------------------------------------------------------ */
/* 11. Forms                                                          */
/* ------------------------------------------------------------------ */

.field { margin-bottom: 1.1rem; }

.label {
  display: block;
  margin-bottom: .4rem;
  font-size: var(--step--1);
  font-weight: 700;
  color: var(--text-2);
}

.input, .select, .textarea {
  width: 100%;
  padding: .7rem .95rem;
  border-radius: var(--r-md);
  border: 1px solid var(--line);
  background: var(--surface-2);
  color: var(--text);
  font-size: var(--step-0);
  transition: border-color .15s var(--ease), box-shadow .15s var(--ease);
}
.input::placeholder, .textarea::placeholder { color: var(--text-4); }
.input:focus, .select:focus, .textarea:focus {
  outline: none;
  border-color: var(--gold);
  box-shadow: 0 0 0 3px rgb(255 184 0 / .16);
}
.input[aria-invalid='true'] { border-color: var(--red); }
.textarea { min-height: 120px; 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='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='%238892B8' d='M1 1.5 6 6.5l5-5'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right .9rem center;
  padding-right: 2.4rem;
}

.hint { font-size: var(--step--2); color: var(--text-4); margin-top: .35rem; }
.error-text { font-size: var(--step--2); color: var(--red); margin-top: .35rem; }

.check {
  display: flex;
  align-items: flex-start;
  gap: .65rem;
  cursor: pointer;
  font-size: var(--step--1);
  color: var(--text-2);
  line-height: 1.55;
}
.check input {
  appearance: none;
  flex-shrink: 0;
  width: 19px; height: 19px;
  margin-top: 1px;
  border-radius: 6px;
  border: 1.5px solid var(--line);
  background: var(--surface-2);
  transition: all .15s var(--ease);
  cursor: pointer;
}
.check input:checked {
  background: var(--gold) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='none' stroke='%230B1020' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round' d='m2.5 6.2 2.3 2.3 4.7-4.9'/%3E%3C/svg%3E") center / 12px no-repeat;
  border-color: var(--gold);
}

.switch {
  position: relative;
  width: 44px; height: 25px;
  flex-shrink: 0;
  border-radius: var(--r-full);
  background: var(--surface-3);
  border: 1px solid var(--line);
  appearance: none;
  cursor: pointer;
  transition: background .2s var(--ease);
}
.switch::after {
  content: '';
  position: absolute;
  top: 2px; left: 2px;
  width: 19px; height: 19px;
  border-radius: var(--r-full);
  background: var(--text-3);
  transition: transform .2s var(--ease), background .2s var(--ease);
}
.switch:checked { background: var(--gold); border-color: var(--gold); }
.switch:checked::after { transform: translateX(19px); background: var(--gold-ink); }

fieldset { border: 0; padding: 0; }

/* ------------------------------------------------------------------ */
/* 12. Tables                                                         */
/* ------------------------------------------------------------------ */

.table-wrap { overflow-x: auto; border-radius: var(--r-lg); }

.table { width: 100%; border-collapse: collapse; font-size: var(--step--1); }
.table th {
  text-align: left;
  padding: .7rem 1rem;
  font-size: var(--step--2);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--text-4);
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}
.table td {
  padding: .8rem 1rem;
  border-bottom: 1px solid var(--line-soft);
  color: var(--text-2);
  vertical-align: middle;
}
.table tr:last-child td { border-bottom: 0; }
.table tbody tr { transition: background .12s var(--ease); }
.table tbody tr:hover { background: var(--surface-2); }
.table .num { text-align: right; font-variant-numeric: tabular-nums; }
.table .strong { color: var(--text); font-weight: 700; }

/* ------------------------------------------------------------------ */
/* 13. Stats                                                          */
/* ------------------------------------------------------------------ */

.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 1rem;
}
.stat {
  background: var(--surface);
  border: 1px solid var(--line-soft);
  border-radius: var(--r-lg);
  padding: 1.1rem 1.25rem;
}
.stat-label {
  font-size: var(--step--2);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--text-4);
  margin-bottom: .3rem;
}
.stat-value {
  font-family: var(--font-display);
  font-size: var(--step-3);
  font-weight: 800;
  letter-spacing: -0.03em;
  color: var(--text);
  font-variant-numeric: tabular-nums;
  line-height: 1.1;
}
.stat-value.is-gold { color: var(--gold); }
.stat-delta { font-size: var(--step--2); font-weight: 700; margin-top: .3rem; }
.stat-delta.up   { color: var(--teal); }
.stat-delta.down { color: var(--red); }
.stat-delta.flat { color: var(--text-4); }

/* ------------------------------------------------------------------ */
/* 14. Alerts and flashes                                             */
/* ------------------------------------------------------------------ */

.alert {
  display: flex;
  align-items: flex-start;
  gap: .75rem;
  padding: .9rem 1.1rem;
  border-radius: var(--r-md);
  font-size: var(--step--1);
  border: 1px solid;
  line-height: 1.55;
}
.alert svg { width: 18px; height: 18px; flex-shrink: 0; margin-top: 1px; }
.alert-success { background: rgb(45 212 191 / .1); border-color: rgb(45 212 191 / .3); color: #7FEEDF; }
.alert-error   { background: rgb(255 77 94 / .1);  border-color: rgb(255 77 94 / .3);  color: #FF9AA5; }
.alert-warning { background: rgb(255 184 0 / .1);  border-color: rgb(255 184 0 / .3);  color: var(--gold-light); }
.alert-info    { background: rgb(107 168 255 / .1);border-color: rgb(107 168 255 / .3);color: #A8C9FF; }

[data-theme='light'] .alert-success { color: #0A7A6B; }
[data-theme='light'] .alert-error   { color: #C8203A; }
[data-theme='light'] .alert-warning { color: #9A6E00; }
[data-theme='light'] .alert-info    { color: #1D5FBF; }

.toast-stack {
  position: fixed;
  bottom: 1.5rem; right: 1.5rem;
  z-index: 200;
  display: flex;
  flex-direction: column;
  gap: .6rem;
  max-width: min(380px, calc(100vw - 3rem));
}
.toast {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-lg);
  padding: .85rem 1.1rem;
  font-size: var(--step--1);
  animation: toast-in .28s var(--ease);
}
@keyframes toast-in {
  from { opacity: 0; transform: translateX(20px); }
}
.toast.is-leaving { animation: toast-out .22s var(--ease) forwards; }
@keyframes toast-out {
  to { opacity: 0; transform: translateX(20px); }
}

/* ------------------------------------------------------------------ */
/* 15. Empty states                                                   */
/* ------------------------------------------------------------------ */

.empty {
  text-align: center;
  padding: clamp(2.5rem, 6vw, 4.5rem) 1.5rem;
  color: var(--text-3);
}
.empty svg { width: 52px; height: 52px; margin: 0 auto 1rem; opacity: .35; }
.empty h3 { color: var(--text); margin-bottom: .5rem; font-size: var(--step-2); }
.empty p { max-width: 44ch; margin: 0 auto 1.35rem; }

/* ------------------------------------------------------------------ */
/* 16. Tabs                                                           */
/* ------------------------------------------------------------------ */

.tabs {
  display: flex;
  gap: .25rem;
  border-bottom: 1px solid var(--line);
  margin-bottom: 1.5rem;
  overflow-x: auto;
}
.tab {
  padding: .7rem 1rem;
  color: var(--text-3);
  font-weight: 700;
  font-size: var(--step--1);
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  white-space: nowrap;
  transition: color .15s var(--ease), border-color .15s var(--ease);
}
.tab:hover { color: var(--text); }
.tab[aria-selected='true'] { color: var(--gold); border-bottom-color: var(--gold); }

/* ------------------------------------------------------------------ */
/* 17. Footer                                                         */
/* ------------------------------------------------------------------ */

.site-footer {
  margin-top: auto;
  border-top: 1px solid var(--line-soft);
  background: var(--surface);
  padding-block: clamp(2.5rem, 5vw, 3.5rem) 2rem;
}
/* Explicit tracks. auto-fit cannot be combined with a flexible 1.6fr track,
   and a browser silently drops the whole declaration when it is. */
.footer-grid {
  display: grid;
  grid-template-columns: 1.6fr 1fr 1fr 1fr 1fr;
  gap: 2.5rem 2rem;
  margin-bottom: 2.5rem;
}
@media (max-width: 980px) {
  .footer-grid { grid-template-columns: 1fr 1fr 1fr; }
  .footer-grid > :first-child { grid-column: 1 / -1; }
}
@media (max-width: 560px) {
  .footer-grid { grid-template-columns: 1fr 1fr; }
}
.footer-col h4 {
  font-family: var(--font-body);
  font-size: var(--step--2);
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--text-4);
  margin-bottom: .85rem;
}
.footer-col ul { list-style: none; padding: 0; display: grid; gap: .55rem; }
.footer-col a { color: var(--text-3); font-size: var(--step--1); }
.footer-col a:hover { color: var(--gold); }
.footer-bottom {
  border-top: 1px solid var(--line-soft);
  padding-top: 1.5rem;
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 1rem;
  font-size: var(--step--2);
  color: var(--text-4);
}

/* ------------------------------------------------------------------ */
/* 18. Utilities                                                      */
/* ------------------------------------------------------------------ */

.muted   { color: var(--text-3); }
.dim     { color: var(--text-4); }
.gold    { color: var(--gold); }
.danger  { color: var(--red); }
.success { color: var(--teal); }

.text-sm  { font-size: var(--step--1); }
.text-xs  { font-size: var(--step--2); }
.text-lg  { font-size: var(--step-1); }
.bold     { font-weight: 700; }
.center   { text-align: center; }
.right    { text-align: right; }
.nums     { font-variant-numeric: tabular-nums; }
.mono     { font-family: var(--font-mono); font-size: .92em; }

.mt-0 { margin-top: 0; }
.mt-1 { margin-top: .5rem; }
.mt-2 { margin-top: 1rem; }
.mt-3 { margin-top: 1.5rem; }
.mt-4 { margin-top: 2.25rem; }
.mb-1 { margin-bottom: .5rem; }
.mb-2 { margin-bottom: 1rem; }
.mb-3 { margin-bottom: 1.5rem; }
.mb-4 { margin-bottom: 2.25rem; }

.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.clamp-2 {
  display: -webkit-box; -webkit-line-clamp: 2;
  -webkit-box-orient: vertical; overflow: hidden;
}
.clamp-3 {
  display: -webkit-box; -webkit-line-clamp: 3;
  -webkit-box-orient: vertical; overflow: hidden;
}

.sr-only {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

.divider { height: 1px; background: var(--line-soft); margin-block: 1.5rem; }

.skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  z-index: 300;
  padding: .75rem 1.25rem;
  background: var(--gold);
  color: var(--gold-ink);
  font-weight: 700;
  border-radius: 0 0 var(--r-md) 0;
}
.skip-link:focus { left: 0; }

/* ------------------------------------------------------------------ */
/* 19. Prose (legal documents, help pages)                            */
/* ------------------------------------------------------------------ */

.prose { max-width: 72ch; color: var(--text-2); line-height: 1.78; }
.prose h2 {
  font-size: var(--step-2);
  color: var(--text);
  margin-top: 2.5rem;
  margin-bottom: .85rem;
  scroll-margin-top: calc(var(--header-h) + 1rem);
}
.prose h3 {
  font-size: var(--step-1);
  color: var(--text);
  margin-top: 1.85rem;
  margin-bottom: .6rem;
}
.prose h2:first-child, .prose h3:first-child { margin-top: 0; }
.prose p { margin-bottom: 1.05rem; }
.prose ul, .prose ol { margin: 0 0 1.15rem 1.3rem; display: grid; gap: .5rem; }
.prose li { padding-left: .2rem; }
.prose li::marker { color: var(--gold); }
.prose strong { color: var(--text); font-weight: 700; }
.prose a { text-decoration: underline; text-underline-offset: 2px; }
.prose blockquote {
  border-left: 3px solid var(--gold);
  padding: .3rem 0 .3rem 1.15rem;
  margin: 1.35rem 0;
  color: var(--text-3);
  font-style: italic;
}
.prose table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 1.35rem;
  font-size: var(--step--1);
}
.prose th, .prose td {
  padding: .6rem .85rem;
  border: 1px solid var(--line-soft);
  text-align: left;
}
.prose th { background: var(--surface-2); color: var(--text); font-weight: 700; }
.prose hr { border: 0; border-top: 1px solid var(--line-soft); margin: 2.25rem 0; }
.prose code {
  font-family: var(--font-mono);
  font-size: .88em;
  background: var(--surface-2);
  padding: .12em .4em;
  border-radius: 5px;
  color: var(--gold-light);
}

/* ------------------------------------------------------------------ */
/* 20. Pagination                                                     */
/* ------------------------------------------------------------------ */

.pagination {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: .35rem;
  margin-top: 2.5rem;
  flex-wrap: wrap;
}
.pagination a, .pagination span {
  min-width: 38px;
  height: 38px;
  padding-inline: .6rem;
  display: grid;
  place-items: center;
  border-radius: var(--r-md);
  font-size: var(--step--1);
  font-weight: 700;
  color: var(--text-3);
  border: 1px solid var(--line-soft);
  transition: all .15s var(--ease);
}
.pagination a:hover { border-color: var(--gold); color: var(--gold); }
.pagination .is-current {
  background: var(--gold);
  border-color: var(--gold);
  color: var(--gold-ink);
}
.pagination .is-gap { border: 0; color: var(--text-4); }

/* ------------------------------------------------------------------ */
/* 21. Mobile bottom navigation                                       */
/* ------------------------------------------------------------------ */

.bottom-nav { display: none; }

@media (max-width: 760px) {
  .bottom-nav {
    position: fixed;
    bottom: 0; left: 0; right: 0;
    z-index: 80;
    display: grid;
    grid-auto-flow: column;
    grid-auto-columns: 1fr;
    background: color-mix(in srgb, var(--bg) 92%, transparent);
    backdrop-filter: blur(18px);
    border-top: 1px solid var(--line-soft);
    padding-bottom: env(safe-area-inset-bottom);
  }
  .bottom-nav a {
    display: grid;
    place-items: center;
    gap: .15rem;
    padding: .55rem 0 .5rem;
    color: var(--text-4);
    font-size: 10px;
    font-weight: 700;
  }
  .bottom-nav a svg { width: 21px; height: 21px; }
  .bottom-nav a[aria-current='page'] { color: var(--gold); }

  body { padding-bottom: 62px; }
  .site-footer { margin-bottom: 62px; }
}
