/* ── Variables ──────────────────────────────────────────────────────────── */
:root {
  --bg:           #f8fafc;
  --surface:      #ffffff;
  --border:       #e2e8f0;
  --border-light: #f1f5f9;
  --text:         #0f172a;
  --text-muted:   #64748b;
  --text-light:   #94a3b8;
  --accent:       #2563eb;
  --accent-hover: #1d4ed8;
  --accent-bg:    #eff6ff;
  --accent-border:#bfdbfe;
  --font: 'Inter', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --radius:    12px;
  --radius-sm:  8px;
  --shadow-xs: 0 1px 2px rgba(0,0,0,.05);
  --shadow-sm: 0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.04);
  --shadow:    0 4px 6px -1px rgba(0,0,0,.07), 0 2px 4px -2px rgba(0,0,0,.05);
  --shadow-md: 0 10px 15px -3px rgba(0,0,0,.08), 0 4px 6px -4px rgba(0,0,0,.05);
  --shadow-lg: 0 20px 40px rgba(0,0,0,.1), 0 8px 16px rgba(0,0,0,.06);
  --container: 1200px;
  --nav-h:     62px;
}

/* ── Dark theme ──────────────────────────────────────────────────────────── */
[data-theme="dark"] {
  --bg:           #0f172a;
  --surface:      #1e293b;
  --border:       #334155;
  --border-light: #1e293b;
  --text:         #f1f5f9;
  --text-muted:   #94a3b8;
  --text-light:   #475569;
  --accent:       #3b82f6;
  --accent-hover: #60a5fa;
  --accent-bg:    rgba(59,130,246,.12);
  --accent-border:#1d4ed8;
  --shadow-xs: 0 1px 2px rgba(0,0,0,.3);
  --shadow-sm: 0 1px 3px rgba(0,0,0,.4), 0 1px 2px rgba(0,0,0,.3);
  --shadow:    0 4px 6px -1px rgba(0,0,0,.4), 0 2px 4px -2px rgba(0,0,0,.3);
  --shadow-md: 0 10px 15px -3px rgba(0,0,0,.5), 0 4px 6px -4px rgba(0,0,0,.4);
  --shadow-lg: 0 20px 40px rgba(0,0,0,.6), 0 8px 16px rgba(0,0,0,.4);
}

/* Bootstrap's own CSS variables — override so its components inherit dark colours */
[data-theme="dark"] body,
[data-theme="dark"] {
  --bs-body-bg:             #0f172a;
  --bs-body-color:          #f1f5f9;
  --bs-secondary-color:     #94a3b8;   /* text-muted */
  --bs-tertiary-color:      #64748b;
  --bs-border-color:        #334155;
  --bs-border-color-translucent: rgba(255,255,255,.1);
  --bs-card-bg:             #1e293b;
  --bs-card-cap-bg:         #162032;
  --bs-card-border-color:   #334155;
  --bs-modal-bg:            #1e293b;
  --bs-modal-header-bg:     #162032;
  --bs-modal-footer-bg:     #162032;
  --bs-dropdown-bg:         #1e293b;
  --bs-dropdown-border-color: #334155;
  --bs-dropdown-link-color: #f1f5f9;
  --bs-dropdown-link-hover-bg: rgba(59,130,246,.12);
  --bs-table-bg:            transparent;
  --bs-table-striped-bg:    rgba(255,255,255,.03);
  --bs-table-hover-bg:      rgba(59,130,246,.08);
  --bs-table-color:         #f1f5f9;
  --bs-table-border-color:  #334155;
  --bs-input-bg:            #162032;
  --bs-form-control-bg:     #162032;
  --bs-progress-bg:         #334155;
  --bs-nav-pills-link-active-bg: #2563eb;
  --bs-emphasis-color:      #f1f5f9;
  color-scheme: dark;
}

/* Header uses a hardcoded rgba — override it */
[data-theme="dark"] .site-header {
  background: rgba(15,23,42,.92);
}

/* Auth page gradient */
[data-theme="dark"] .auth-page {
  background: linear-gradient(160deg, #0f172a 0%, #1e293b 100%);
}

/* Card header hardcoded background */
[data-theme="dark"] .card-header {
  background: #162032 !important;
}

/* Table header hardcoded background */
[data-theme="dark"] .table-light th {
  background: #162032 !important;
  color: var(--text-muted);
}
[data-theme="dark"] .table-hover tbody tr:hover {
  background: var(--accent-bg) !important;
  color: var(--text);
}
[data-theme="dark"] .table { color: var(--text); }
[data-theme="dark"] .table td, [data-theme="dark"] .table th {
  border-color: var(--border) !important;
}

/* Bootstrap form controls */
[data-theme="dark"] .form-control,
[data-theme="dark"] .form-select {
  background-color: #162032 !important;
  color: var(--text) !important;
  border-color: var(--border) !important;
}
[data-theme="dark"] .form-control::placeholder { color: var(--text-light); }
[data-theme="dark"] .form-control:focus,
[data-theme="dark"] .form-select:focus {
  background-color: #162032 !important;
}

/* Modal */
[data-theme="dark"] .modal-content {
  background: var(--surface) !important;
  color: var(--text);
}
[data-theme="dark"] .modal-header,
[data-theme="dark"] .modal-footer { background: #162032 !important; }

/* Dropdown */
[data-theme="dark"] .dropdown-menu {
  background: var(--surface) !important;
  border-color: var(--border) !important;
}
[data-theme="dark"] .dropdown-item { color: var(--text); }
[data-theme="dark"] .dropdown-item:hover { background: var(--accent-bg) !important; }

/* Alerts — tint the bg darker */
[data-theme="dark"] .alert-success  { background: #052e16; border-color: #166534; color: #bbf7d0; }
[data-theme="dark"] .alert-danger   { background: #450a0a; border-color: #991b1b; color: #fecaca; }
[data-theme="dark"] .alert-warning  { background: #422006; border-color: #92400e; color: #fde68a; }
[data-theme="dark"] .alert-info     { background: #0c1a2e; border-color: #1e40af; color: #bfdbfe; }

/* Warning tip box */
[data-theme="dark"] .warn-box { background: #2d1f07; border-color: #d97706; }

/* Outline-secondary button */
[data-theme="dark"] .btn-outline-secondary {
  color: var(--text-muted) !important;
  border-color: var(--border) !important;
  background: transparent !important;
}
[data-theme="dark"] .btn-outline-secondary:hover:not(:disabled) {
  background: var(--surface) !important;
  color: var(--text) !important;
  border-color: #475569 !important;
}
[data-theme="dark"] .btn-outline-secondary.active {
  background: var(--accent-bg) !important;
  color: var(--accent) !important;
  border-color: var(--accent-border) !important;
}

/* Outline-danger */
[data-theme="dark"] .btn-outline-danger {
  color: #f87171 !important;
  border-color: #7f1d1d !important;
}
[data-theme="dark"] .btn-outline-danger:hover:not(:disabled) {
  background: #450a0a !important;
  border-color: #ef4444 !important;
}

/* Progress background */
[data-theme="dark"] .progress { background: var(--border) !important; }

/* btn-close uses a hardcoded dark SVG filter */
[data-theme="dark"] .btn-close { filter: invert(1) grayscale(1); }

/* Range input thumb */
[data-theme="dark"] .form-range::-webkit-slider-runnable-track { background: var(--border); }
[data-theme="dark"] .form-range::-moz-range-track { background: var(--border); }

/* Horizontal rules / border-top dividers */
[data-theme="dark"] hr { border-color: var(--border); }

/* Nav links: hover is transparent so no box shows against the header */
[data-theme="dark"] .main-nav .nav-link:hover { background: transparent; }

/* Nav mobile dropdown only */
@media (max-width: 768px) {
  [data-theme="dark"] .main-nav { background: var(--surface); border-bottom-color: var(--border); }
}

/* Theme toggle switch */
.theme-toggle {
  display: flex;
  align-items: center;
  gap: .75rem;
}
.theme-toggle__label {
  font-size: .875rem;
  font-weight: 500;
  color: var(--text);
  cursor: pointer;
  user-select: none;
}
.theme-toggle__switch {
  position: relative;
  width: 42px;
  height: 24px;
  flex-shrink: 0;
}
.theme-toggle__switch input {
  opacity: 0;
  width: 0;
  height: 0;
  position: absolute;
}
.theme-toggle__track {
  position: absolute;
  inset: 0;
  background: var(--border);
  border-radius: 99px;
  cursor: pointer;
  transition: background .2s;
}
.theme-toggle__track::after {
  content: '';
  position: absolute;
  top: 3px;
  left: 3px;
  width: 18px;
  height: 18px;
  background: #fff;
  border-radius: 50%;
  transition: transform .2s;
  box-shadow: 0 1px 3px rgba(0,0,0,.3);
}
.theme-toggle__switch input:checked + .theme-toggle__track {
  background: var(--accent);
}
.theme-toggle__switch input:checked + .theme-toggle__track::after {
  transform: translateX(18px);
}

/* ── Reset / Base ────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  margin: 0;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ── Layout ──────────────────────────────────────────────────────────────── */
.site-container {
  max-width: var(--container);
  margin: 0 auto;
  padding: 0 1.5rem;
}

.site-main {
  padding: 2rem 0 3.5rem;
}

/* ── Header ──────────────────────────────────────────────────────────────── */
.site-header {
  background: rgba(255,255,255,.92);
  border-bottom: 1px solid var(--border);
  height: var(--nav-h);
  position: sticky;
  top: 0;
  z-index: 200;
  box-shadow: var(--shadow-xs);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

.header-inner {
  display: flex;
  align-items: center;
  height: var(--nav-h);
  gap: 1.5rem;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-weight: 700;
  font-size: 0.9375rem;
  color: var(--text);
  text-decoration: none;
  letter-spacing: -0.025em;
  white-space: nowrap;
  flex-shrink: 0;
  transition: color .15s;
}
.brand:hover { color: var(--accent); text-decoration: none; }

.brand-icon {
  color: var(--accent);
  flex-shrink: 0;
  transition: color .15s;
}
.brand:hover .brand-icon { color: var(--accent-hover); }

/* ── Main nav ────────────────────────────────────────────────────────────── */
.main-nav {
  display: flex;
  align-items: center;
  gap: 2px;
}

.main-nav .nav-link {
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-muted);
  padding: 0.375rem 0.75rem;
  border-radius: var(--radius-sm);
  text-decoration: none;
  transition: color .15s, background .15s;
  white-space: nowrap;
  line-height: 1.4;
}
.main-nav .nav-link:hover  { color: var(--text); background: var(--bg); }
.main-nav .nav-link.active { color: var(--accent); background: var(--accent-bg); }
.nav-mobile-only { display: none; }

/* ── Header actions ──────────────────────────────────────────────────────── */
.header-actions {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-shrink: 0;
}

.btn-kofi {
  background: #FF5E5B;
  color: #fff !important;
  border: none;
  font-weight: 600;
  font-size: 0.8125rem;
  padding: 0.3125rem 0.75rem;
  border-radius: var(--radius-sm);
  text-decoration: none !important;
  transition: opacity .15s;
  white-space: nowrap;
  display: inline-block;
  line-height: 1.5;
}
.btn-kofi:hover { opacity: 0.88; }

/* Mobile hamburger */
.nav-toggle {
  display: none;
  flex-direction: column;
  justify-content: center;
  gap: 4px;
  background: none;
  border: 1px solid var(--border);
  cursor: pointer;
  padding: 6px 7px;
  border-radius: var(--radius-sm);
  margin-left: auto;
  transition: background .15s;
}
.nav-toggle:hover { background: var(--bg); }
.nav-toggle span {
  display: block;
  width: 18px;
  height: 2px;
  background: var(--text-muted);
  border-radius: 2px;
}

/* ── Bootstrap overrides ─────────────────────────────────────────────────── */

/* Cards */
.card {
  border-radius: var(--radius) !important;
  border-color: var(--border) !important;
  box-shadow: var(--shadow-sm) !important;
}
.card-header {
  background: #fafbfd !important;
  border-bottom-color: var(--border) !important;
  border-radius: var(--radius) var(--radius) 0 0 !important;
}

/* Buttons */
.btn {
  font-family: var(--font) !important;
  font-weight: 500;
  border-radius: var(--radius-sm) !important;
  transition: all .15s !important;
  font-size: 0.875rem !important;
  letter-spacing: -0.01em;
}
.btn-primary {
  background: var(--accent) !important;
  border-color: var(--accent) !important;
}
.btn-primary:hover:not(:disabled) {
  background: var(--accent-hover) !important;
  border-color: var(--accent-hover) !important;
  box-shadow: 0 2px 8px rgba(37,99,235,.3) !important;
}
.btn-primary:active:not(:disabled) {
  transform: translateY(1px) !important;
}
.btn-primary:disabled { opacity: .45; }

.btn-outline-secondary {
  color: var(--text-muted) !important;
  border-color: var(--border) !important;
  background: var(--surface) !important;
}
.btn-outline-secondary:hover:not(:disabled) {
  background: var(--bg) !important;
  color: var(--text) !important;
  border-color: #cbd5e1 !important;
}
.btn-outline-secondary.active {
  background: var(--accent-bg) !important;
  color: var(--accent) !important;
  border-color: var(--accent-border) !important;
}

.btn-outline-primary {
  color: var(--accent) !important;
  border-color: var(--accent-border) !important;
}
.btn-outline-primary:hover:not(:disabled) {
  background: var(--accent-bg) !important;
  border-color: var(--accent) !important;
}

.btn-link {
  color: var(--text-muted) !important;
  font-size: 0.8125rem !important;
  text-decoration: none !important;
}
.btn-link:hover { color: var(--accent) !important; }

/* Warning button */
.btn-warning {
  background: #f59e0b !important;
  border-color: #f59e0b !important;
  color: #fff !important;
}
.btn-warning:hover:not(:disabled) {
  background: #d97706 !important;
  border-color: #d97706 !important;
}

/* Secondary button */
.btn-secondary {
  background: #64748b !important;
  border-color: #64748b !important;
  color: #fff !important;
}
.btn-secondary:hover:not(:disabled) {
  background: #475569 !important;
  border-color: #475569 !important;
}

/* Danger */
.btn-outline-danger {
  color: #dc2626 !important;
  border-color: #fca5a5 !important;
}
.btn-outline-danger:hover:not(:disabled) {
  background: #fef2f2 !important;
  border-color: #dc2626 !important;
}

.btn-success {
  background: #16a34a !important;
  border-color: #16a34a !important;
}
.btn-success:hover:not(:disabled) {
  background: #15803d !important;
  border-color: #15803d !important;
}

/* Form controls */
.form-control, .form-select {
  font-family: var(--font);
  border-color: var(--border) !important;
  border-radius: var(--radius-sm) !important;
  color: var(--text);
  font-size: 0.9375rem;
  transition: border-color .15s, box-shadow .15s;
  background-color: var(--surface) !important;
  padding: 0.5rem 0.75rem;
}
.form-control:focus, .form-select:focus {
  border-color: var(--accent) !important;
  box-shadow: 0 0 0 3px rgba(37,99,235,.12) !important;
}
.form-control::placeholder { color: var(--text-light); }
.form-label {
  font-weight: 500;
  font-size: 0.875rem;
  color: var(--text);
  margin-bottom: 0.375rem;
}
.form-text { color: var(--text-muted); font-size: 0.8125rem; }

/* Nav pills */
.nav-pills .nav-link {
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-muted);
  border-radius: var(--radius-sm) !important;
  padding: 0.375rem 0.875rem;
  transition: all .15s;
}
.nav-pills .nav-link.active {
  background: var(--accent) !important;
  color: #fff !important;
}
.nav-pills .nav-link:hover:not(.active) {
  background: var(--bg);
  color: var(--text);
}

/* Nav tabs */
.nav-tabs { border-bottom-color: var(--border) !important; }
.nav-tabs .nav-link {
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-muted);
  border-color: transparent !important;
  border-radius: var(--radius-sm) var(--radius-sm) 0 0 !important;
  padding: 0.5rem 1rem;
}
.nav-tabs .nav-link.active {
  color: var(--accent) !important;
  border-bottom-color: var(--accent) !important;
  background: transparent !important;
}
.nav-tabs .nav-link:hover:not(.active) { color: var(--text); background: var(--bg); }

/* Progress */
.progress {
  border-radius: 99px !important;
  background: var(--border) !important;
}
.progress-bar {
  background: var(--accent) !important;
  border-radius: 99px !important;
}

/* Dropdowns */
.dropdown-menu {
  border-color: var(--border) !important;
  border-radius: var(--radius) !important;
  box-shadow: var(--shadow-md) !important;
  font-size: 0.875rem;
}

/* Badges */
.badge { font-weight: 500; border-radius: 5px !important; }

/* Alerts */
.alert { border-radius: var(--radius-sm) !important; font-size: 0.875rem; }

/* Tables */
.table { font-size: 0.875rem; }
.table-light th {
  background: #fafbfd !important;
  color: var(--text-muted);
  font-size: 0.8125rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .04em;
}
.table-hover tbody tr:hover { background: var(--accent-bg) !important; }
.table th, .table td { border-color: var(--border-light) !important; }

/* Modals */
.modal-content {
  border-radius: var(--radius) !important;
  border-color: var(--border) !important;
  box-shadow: var(--shadow-lg) !important;
}
.modal-header { border-bottom-color: var(--border) !important; }
.modal-footer { border-top-color: var(--border) !important; }

/* ── Home page ────────────────────────────────────────────────────────────── */
.home-hero {
  text-align: center;
  padding: 4.5rem 1rem 2.75rem;
  max-width: 600px;
  margin: 0 auto;
}

.home-eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: .07em;
  text-transform: uppercase;
  color: var(--accent);
  background: var(--accent-bg);
  border: 1px solid var(--accent-border);
  border-radius: 99px;
  padding: 0.25rem 0.75rem;
  margin-bottom: 1.5rem;
}

.home-title {
  font-size: 2.5rem;
  font-weight: 700;
  letter-spacing: -0.035em;
  line-height: 1.1;
  color: var(--text);
  margin: 0 0 1.125rem;
}

.home-sub {
  font-size: 1rem;
  color: var(--text-muted);
  line-height: 1.7;
  margin: 0 0 2.25rem;
  max-width: 480px;
  margin-left: auto;
  margin-right: auto;
}

.home-hero .btn {
  padding: 0.5625rem 1.25rem !important;
  font-size: 0.9375rem !important;
}

.home-divider {
  border: none;
  border-top: 1px solid var(--border);
  margin: 0 0 2.75rem;
}

.home-tools {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(270px, 1fr));
  gap: 1.25rem;
  max-width: 960px;
  margin: 0 auto 4rem;
}

.tool-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: 1.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.625rem;
  transition: box-shadow .2s, border-color .2s, transform .18s;
  text-decoration: none;
  color: inherit;
}
.tool-card:hover {
  box-shadow: var(--shadow-md);
  border-color: #cbd5e1;
  transform: translateY(-2px);
}

.tool-card__icon {
  width: 42px;
  height: 42px;
  background: var(--accent-bg);
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--accent);
  margin-bottom: 0.25rem;
  flex-shrink: 0;
}

.tool-card__title {
  font-size: 0.9375rem;
  font-weight: 600;
  color: var(--text);
  margin: 0;
  letter-spacing: -0.01em;
}

.tool-card__desc {
  font-size: 0.875rem;
  color: var(--text-muted);
  line-height: 1.65;
  margin: 0;
  flex-grow: 1;
}

.tool-card__link {
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--accent);
  text-decoration: none;
  margin-top: 0.5rem;
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  transition: gap .15s;
}
.tool-card:hover .tool-card__link { gap: 0.4rem; }

/* ── Page-level tab bar ───────────────────────────────────────────────────── */
.page-tabs {
  display: flex;
  align-items: center;
  border-bottom: 1px solid var(--border);
  margin-bottom: 1.5rem;
}

.page-tab {
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  padding: 0.5rem 1.125rem;
  margin-bottom: -1px;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-muted);
  cursor: pointer;
  transition: color .15s, border-color .15s;
  font-family: var(--font);
  outline: none;
}
.page-tab:hover  { color: var(--text); }
.page-tab.active { color: var(--accent); border-bottom-color: var(--accent); }

/* ── Reader layout (2-col on desktop) ───────────────────────────────────── */
.reader-layout {
  display: grid;
  grid-template-columns: 310px 1fr;
  gap: 1.25rem;
  align-items: start;
}

.reader-sidebar {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  position: sticky;
  top: calc(var(--nav-h) + 1rem);
}

/* ── Preview box ─────────────────────────────────────────────────────────── */
#preview-box {
  width: 112px;
  height: 112px;
  background: var(--bg);
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  overflow: hidden;
  transition: border-color .15s, background .15s;
  flex-shrink: 0;
}
#preview-box:hover {
  border-color: var(--accent);
  background: var(--accent-bg);
}
#preview-text {
  font-size: 0.75rem;
  color: var(--text-muted);
  text-align: center;
  line-height: 1.4;
  pointer-events: none;
  user-select: none;
}
#preview-img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

/* ── Result cards ─────────────────────────────────────────────────────────── */
.result-card {
  background: var(--surface);
  cursor: pointer;
  transition: background .12s, box-shadow .12s, border-color .12s;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
}
.result-card:hover {
  background: var(--accent-bg);
  border-color: var(--accent-border);
  box-shadow: var(--shadow);
}

.result-thumb {
  width: 64px;
  height: 64px;
  object-fit: contain;
  background: var(--bg);
  border-radius: 4px;
  flex-shrink: 0;
}

/* ── Cropper wrapper ─────────────────────────────────────────────────────── */
.cropper-container-wrapper {
  max-height: 500px;
  overflow: hidden;
  background: #1a1a1a;
  border-radius: var(--radius-sm);
}
.cropper-container-wrapper img { max-width: 100%; display: block; }

/* ── Drop zone ───────────────────────────────────────────────────────────── */
#drop-zone {
  border-color: var(--border) !important;
  background: var(--bg);
  transition: background .15s, border-color .15s;
  border-radius: var(--radius) !important;
}
#drop-zone:hover {
  background: var(--accent-bg);
  border-color: var(--accent) !important;
}

/* ── Tutorial ────────────────────────────────────────────────────────────── */
.tutorial-page {
  max-width: 1040px;
  margin: 0 auto;
}

.tutorial-hero {
  max-width: 760px;
  padding: 2.5rem 0 2rem;
}
.tutorial-eyebrow,
.tutorial-kicker {
  display: block;
  color: var(--accent);
  font-size: .7rem;
  font-weight: 700;
  letter-spacing: .09em;
  text-transform: uppercase;
}
.tutorial-hero h1 {
  max-width: 720px;
  margin: .5rem 0 .85rem;
  color: var(--text);
  font-size: clamp(2rem, 4vw, 3.25rem);
  font-weight: 700;
  letter-spacing: -.045em;
  line-height: 1.08;
}
.tutorial-hero p {
  max-width: 690px;
  margin: 0;
  color: var(--text-muted);
  font-size: 1.02rem;
  line-height: 1.7;
}

.tutorial-nav {
  position: sticky;
  top: calc(var(--nav-h) + .75rem);
  z-index: 20;
  display: flex;
  gap: .35rem;
  padding: .45rem;
  overflow-x: auto;
  background: var(--surface);
  background: color-mix(in srgb, var(--surface) 94%, transparent);
  border: 1px solid var(--border);
  border-radius: 999px;
  box-shadow: var(--shadow-sm);
  backdrop-filter: blur(10px);
  scrollbar-width: none;
}
.tutorial-nav::-webkit-scrollbar { display: none; }
.tutorial-nav a {
  flex: 0 0 auto;
  padding: .45rem .8rem;
  color: var(--text-muted);
  border-radius: 999px;
  font-size: .78rem;
  font-weight: 600;
  text-decoration: none;
  transition: color .15s, background .15s;
}
.tutorial-nav a:hover {
  color: var(--accent);
  background: var(--accent-bg);
}

.tutorial-section {
  padding: 4.75rem 0 0;
  scroll-margin-top: calc(var(--nav-h) + 5rem);
}
.tutorial-section-heading {
  max-width: 680px;
  margin-bottom: 1.5rem;
}
.tutorial-section-heading--action {
  max-width: none;
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 1.5rem;
}
.tutorial-section-heading h2,
.tutorial-history-card h2,
.tutorial-footer-cta h2 {
  margin: .35rem 0 .45rem;
  color: var(--text);
  font-size: 1.55rem;
  font-weight: 700;
  letter-spacing: -.025em;
}
.tutorial-section-heading p,
.tutorial-history-card p {
  margin: 0;
  color: var(--text-muted);
  line-height: 1.65;
}

.tutorial-path-grid,
.tutorial-check-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1rem;
}
.tutorial-path-card {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  min-height: 100%;
  padding: 1.6rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-xs);
}
.tutorial-path-card--primary {
  border-color: var(--accent-border);
  background: linear-gradient(145deg, var(--surface), var(--accent-bg));
}
.tutorial-path-icon,
.tutorial-history-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  margin-bottom: 1rem;
  color: var(--accent);
  background: var(--accent-bg);
  border: 1px solid var(--accent-border);
  border-radius: 11px;
}
.tutorial-path-label,
.tutorial-check-label {
  color: var(--accent);
  font-size: .69rem;
  font-weight: 700;
  letter-spacing: .065em;
  text-transform: uppercase;
}
.tutorial-path-card h3,
.tutorial-check-card h3,
.tutorial-step h3 {
  margin: .35rem 0 .5rem;
  color: var(--text);
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: -.01em;
}
.tutorial-path-card > p {
  min-height: 5.2rem;
  margin-bottom: 1rem;
  color: var(--text-muted);
  font-size: .875rem;
  line-height: 1.65;
}
.tutorial-mini-steps {
  width: 100%;
  margin: 0 0 1.35rem;
  padding: 0;
  list-style: none;
  counter-reset: mini-step;
}
.tutorial-mini-steps li {
  position: relative;
  padding: .45rem 0 .45rem 2rem;
  color: var(--text-muted);
  border-top: 1px solid var(--border-light);
  font-size: .8rem;
  counter-increment: mini-step;
}
.tutorial-mini-steps li::before {
  content: counter(mini-step);
  position: absolute;
  left: .15rem;
  top: .42rem;
  width: 1.15rem;
  height: 1.15rem;
  color: var(--accent);
  background: var(--accent-bg);
  border-radius: 50%;
  font-size: .66rem;
  font-weight: 700;
  line-height: 1.15rem;
  text-align: center;
}
.tutorial-path-card .btn { margin-top: auto; }

.tutorial-safety-note {
  display: flex;
  align-items: flex-start;
  gap: .8rem;
  margin-top: 1rem;
  padding: 1rem 1.1rem;
  color: #92400e;
  background: #fffbeb;
  border: 1px solid #fde68a;
  border-radius: var(--radius-sm);
  font-size: .82rem;
  line-height: 1.55;
}
.tutorial-safety-note svg { flex: 0 0 auto; margin-top: .05rem; }

.tutorial-check-card {
  display: grid;
  grid-template-columns: 138px minmax(0, 1fr);
  align-items: center;
  gap: 1.25rem;
  padding: 1.25rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.tutorial-check-visual {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 132px;
  color: #475569;
  background: var(--bg);
  border-radius: var(--radius-sm);
}
.tutorial-check-visual--mask { background: #eef2f7; }
.tutorial-checklist {
  margin: .7rem 0 0;
  padding: 0;
  list-style: none;
}
.tutorial-checklist li {
  position: relative;
  margin-top: .4rem;
  padding-left: 1.25rem;
  color: var(--text-muted);
  font-size: .8rem;
  line-height: 1.45;
}
.tutorial-checklist li::before {
  content: "✓";
  position: absolute;
  left: 0;
  color: #16a34a;
  font-weight: 700;
}

.tutorial-steps {
  position: relative;
  display: grid;
  gap: .75rem;
}
.tutorial-step {
  display: grid;
  grid-template-columns: 2.35rem minmax(0, 1fr);
  gap: 1rem;
  padding: 1.15rem 1.25rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}
.tutorial-step-number {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.1rem;
  height: 2.1rem;
  color: #fff;
  background: var(--accent);
  border-radius: 50%;
  font-size: .78rem;
  font-weight: 700;
}
.tutorial-step h3 { margin-top: .1rem; }
.tutorial-step p {
  max-width: 790px;
  margin: 0;
  color: var(--text-muted);
  font-size: .86rem;
  line-height: 1.65;
}

.tutorial-history-card {
  display: flex;
  align-items: center;
  gap: 1.25rem;
  padding: 1.5rem;
  background: var(--accent-bg);
  border: 1px solid var(--accent-border);
  border-radius: var(--radius);
}
.tutorial-history-icon {
  flex: 0 0 auto;
  margin: 0;
  background: var(--surface);
}
.tutorial-history-card h2 {
  margin-top: 0;
  font-size: 1.05rem;
}
.tutorial-history-card p { font-size: .84rem; }

.tutorial-faq {
  overflow: hidden;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.tutorial-faq details + details { border-top: 1px solid var(--border); }
.tutorial-faq summary {
  position: relative;
  padding: 1rem 3rem 1rem 1.2rem;
  color: var(--text);
  cursor: pointer;
  font-size: .88rem;
  font-weight: 600;
  list-style: none;
}
.tutorial-faq summary::-webkit-details-marker { display: none; }
.tutorial-faq summary::after {
  content: "+";
  position: absolute;
  top: .75rem;
  right: 1.2rem;
  color: var(--accent);
  font-size: 1.25rem;
  font-weight: 400;
}
.tutorial-faq details[open] summary::after { content: "−"; }
.tutorial-faq details[open] summary { color: var(--accent); }
.tutorial-faq p {
  max-width: 800px;
  margin: -.25rem 3rem 1rem 1.2rem;
  color: var(--text-muted);
  font-size: .82rem;
  line-height: 1.65;
}

.tutorial-footer-cta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 2rem;
  margin-top: 4.75rem;
  padding: 2rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}
.tutorial-footer-cta h2 { margin-bottom: 0; }

[data-theme="dark"] .tutorial-safety-note {
  color: #fde68a;
  background: #2d1f07;
  border-color: #78350f;
}
[data-theme="dark"] .tutorial-check-visual { color: #94a3b8; }
[data-theme="dark"] .tutorial-check-visual--mask { background: #cbd5e1; }

/* ── Auth pages ──────────────────────────────────────────────────────────── */
.auth-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(160deg, #eef2ff 0%, #f8fafc 45%, #f8fafc 100%);
  padding: 2rem 1rem;
}
.auth-card {
  width: 100%;
  max-width: 400px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  padding: 2.25rem 2.25rem 2rem;
}
.auth-logo {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-weight: 700;
  font-size: 0.9375rem;
  color: var(--text);
  text-decoration: none;
  letter-spacing: -0.025em;
  margin-bottom: 2rem;
  transition: color .15s;
}
.auth-logo:hover { color: var(--accent); text-decoration: none; }
.auth-logo svg { color: var(--accent); flex-shrink: 0; }

.auth-divider {
  border: none;
  border-top: 1px solid var(--border-light);
  margin: 1.5rem 0;
}

/* ── Account page ────────────────────────────────────────────────────────── */
.account-page { max-width: 900px; margin: 0 auto; }

.account-hero {
  display: flex;
  align-items: center;
  gap: 1.25rem;
  margin-bottom: 2rem;
}

.account-avatar {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  font-size: 1.5rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  letter-spacing: -.02em;
}

.account-name {
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: -.025em;
  margin: 0 0 .25rem;
}

.account-meta { display: flex; align-items: center; flex-wrap: wrap; gap: .25rem; }

.account-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(135px, 1fr));
  gap: 1rem;
  margin-bottom: 2rem;
}

.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem 1rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: .375rem;
  box-shadow: var(--shadow-xs);
}

.stat-value {
  font-size: 1.75rem;
  font-weight: 700;
  color: var(--accent);
  letter-spacing: -.03em;
  line-height: 1;
}
.stat-value--sm { font-size: 1.125rem; }

.stat-label {
  font-size: 0.75rem;
  color: var(--text-muted);
  line-height: 1.35;
}

.account-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.25rem;
}

.account-section {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  box-shadow: var(--shadow-xs);
}

.section-title {
  font-size: 0.9375rem;
  font-weight: 600;
  letter-spacing: -.02em;
  margin: 0 0 .25rem;
}

.quota-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(145px, 1fr));
  gap: .75rem;
}
.quota-grid > div {
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  background: var(--bg);
  padding: .875rem;
}
.quota-label {
  display: block;
  color: var(--text-muted);
  font-size: .75rem;
  margin-bottom: .25rem;
}
.quota-grid strong {
  color: var(--text);
  font-size: .9375rem;
}

/* Pricing page */
.pricing-page { max-width: 980px; margin: 0 auto; }
.pricing-header {
  max-width: 560px;
  margin-bottom: 1.5rem;
}
.pricing-title {
  font-size: 1.75rem;
  font-weight: 700;
  letter-spacing: -.03em;
  margin: 0 0 .5rem;
}
.pricing-sub {
  color: var(--text-muted);
  line-height: 1.65;
  margin: 0;
}
.pricing-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1rem;
  margin-bottom: 1rem;
}
.pricing-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: 1.5rem;
}
.pricing-card--featured {
  border-color: var(--accent-border);
  box-shadow: var(--shadow);
}
.pricing-card__head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.25rem;
}
.pricing-card h2 {
  font-size: 1rem;
  font-weight: 700;
  margin: 0 .5rem .25rem 0;
}
.pricing-price {
  color: var(--accent);
  font-size: 1.25rem;
  font-weight: 700;
}
.pricing-badge {
  color: var(--accent);
  background: var(--accent-bg);
  border: 1px solid var(--accent-border);
  border-radius: 6px;
  font-size: .75rem;
  font-weight: 600;
  padding: .2rem .45rem;
}
.pricing-metrics {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: .75rem;
  margin-bottom: 1rem;
}
.pricing-metrics div {
  background: var(--bg);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  padding: .75rem;
}
.pricing-metrics span,
.pricing-note {
  color: var(--text-muted);
  font-size: .75rem;
}
.pricing-metrics strong {
  display: block;
  color: var(--text);
  font-size: .9375rem;
  margin-top: .25rem;
}
.pricing-note {
  line-height: 1.55;
  margin-bottom: 1rem;
}
.pricing-policy {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
}
.pricing-policy h2 {
  font-size: .9375rem;
  font-weight: 700;
  margin: 0 0 1rem;
}
.policy-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: .75rem;
}
.policy-grid strong,
.policy-grid span {
  display: block;
  font-size: .8125rem;
}
.policy-grid strong { color: var(--text); margin-bottom: .25rem; }
.policy-grid span { color: var(--text-muted); line-height: 1.55; }

@media (max-width: 640px) {
  .account-stats { grid-template-columns: repeat(2, 1fr); }
  .account-grid  { grid-template-columns: 1fr; }
  .pricing-grid,
  .policy-grid { grid-template-columns: 1fr; }
}

/* ── Responsive ──────────────────────────────────────────────────────────── */
@media (max-width: 900px) {
  .reader-layout {
    grid-template-columns: 1fr;
  }
  .reader-sidebar {
    position: static;
  }
}

@media (max-width: 768px) {
  .site-container { padding: 0 1rem; }
  .site-main { padding: 1.5rem 0 2.5rem; }

  .main-nav {
    display: none;
    position: absolute;
    top: var(--nav-h);
    left: 0;
    right: 0;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    flex-direction: column;
    align-items: stretch;
    padding: 0.5rem 1rem;
    box-shadow: var(--shadow);
    gap: 2px;
    z-index: 190;
  }
  .main-nav.open { display: flex; }
  .main-nav .nav-link { padding: 0.625rem 0.75rem; }
  .main-nav .nav-mobile-only { display: block; }

  .nav-toggle { display: flex; }
  .btn-kofi  { display: none; }
  .header-actions > a { display: none; }
  .header-actions { gap: 0.375rem; }
  .header-inner { gap: 0.75rem; }

  #preview-box { width: 96px; height: 96px; }

  .home-title { font-size: 1.875rem; }
  .home-hero { padding: 3rem 1rem 2.5rem; }

  .tutorial-hero { padding: 1.5rem 0 1.4rem; }
  .tutorial-nav {
    top: calc(var(--nav-h) + .4rem);
    margin: 0 -.25rem;
    border-radius: var(--radius-sm);
  }
  .tutorial-section { padding-top: 3.75rem; }
  .tutorial-path-grid,
  .tutorial-check-grid { grid-template-columns: 1fr; }
  .tutorial-path-card > p { min-height: 0; }
  .tutorial-section-heading--action,
  .tutorial-footer-cta {
    align-items: flex-start;
    flex-direction: column;
  }
  .tutorial-footer-cta { margin-top: 3.75rem; }
}

@media (max-width: 480px) {
  .auth-card { padding: 1.75rem 1.5rem 1.5rem; }
  .site-main { padding: 1.25rem 0 2rem; }
  .home-tools { grid-template-columns: 1fr; }

  .tutorial-hero h1 { font-size: 2rem; }
  .tutorial-path-card { padding: 1.25rem; }
  .tutorial-check-card {
    grid-template-columns: 1fr;
    gap: 1rem;
  }
  .tutorial-check-visual { min-height: 112px; }
  .tutorial-step {
    grid-template-columns: 1.9rem minmax(0, 1fr);
    gap: .8rem;
    padding: 1rem;
  }
  .tutorial-step-number { width: 1.8rem; height: 1.8rem; }
  .tutorial-history-card { align-items: flex-start; }
  .tutorial-footer-cta { padding: 1.4rem; }
}
