/* ═══════════════════════════════════════════════════════════
   URLMap Design System — v3.0 (CMS Edition)
   Built with OKLCH colors, 4pt spacing, Plus Jakarta Sans
   ═══════════════════════════════════════════════════════════ */

/* ── Design Tokens ── */
:root {
  /* Color: Softer warm neutral palette */
  --hue: 45;
  --primary: oklch(68% 0.12 45);           /* warm gold-amber */
  --primary-hover: oklch(60% 0.14 45);
  --primary-subtle: oklch(24% 0.03 45);
  --primary-ghost: oklch(20% 0.02 45);

  /* Surfaces — warm-tinted dark grays */
  --bg: oklch(14% 0.008 45);
  --surface-1: oklch(18% 0.008 45);
  --surface-2: oklch(22% 0.008 45);
  --surface-3: oklch(26% 0.008 45);

  /* Text */
  --text: oklch(92% 0.008 45);
  --text-secondary: oklch(70% 0.008 45);
  --text-muted: oklch(53% 0.008 45);

  /* Borders */
  --border: oklch(26% 0.008 45);
  --border-hover: oklch(36% 0.008 45);
  --border-focus: var(--primary);

  /* Semantic */
  --success: oklch(68% 0.15 155);
  --success-bg: oklch(22% 0.04 155);
  --warning: oklch(75% 0.13 80);
  --warning-bg: oklch(22% 0.03 80);
  --danger: oklch(62% 0.18 25);
  --danger-bg: oklch(22% 0.04 25);
  --info: oklch(68% 0.10 250);
  --info-bg: oklch(22% 0.03 250);

  /* Spacing (4pt base) */
  --sp-1: 4px;  --sp-2: 8px;  --sp-3: 12px;
  --sp-4: 16px; --sp-5: 20px; --sp-6: 24px;
  --sp-8: 32px; --sp-10: 40px; --sp-12: 48px;
  --sp-16: 64px;

  /* Radius */
  --radius-sm: 8px;
  --radius: 12px;
  --radius-lg: 16px;
  --radius-xl: 24px;
  --radius-full: 999px;

  /* Typography */
  --font-display: 'Plus Jakarta Sans', system-ui, -apple-system, sans-serif;
  --font-body: system-ui, -apple-system, 'Segoe UI', sans-serif;
  --font-mono: 'JetBrains Mono', 'Fira Code', monospace;

  --text-xs: 0.75rem;
  --text-sm: 0.8125rem;
  --text-base: 0.9375rem;
  --text-md: 1rem;
  --text-lg: 1.125rem;
  --text-xl: 1.375rem;
  --text-2xl: 1.75rem;
  --text-3xl: 2.25rem;

  /* Motion */
  --ease-out: cubic-bezier(0.25, 1, 0.5, 1);
  --ease-in: cubic-bezier(0.7, 0, 0.84, 0);
  --ease-inout: cubic-bezier(0.65, 0, 0.35, 1);
  --duration-instant: 100ms;
  --duration-fast: 200ms;
  --duration-normal: 300ms;
  --duration-slow: 500ms;

  /* Z-index scale */
  --z-dropdown: 100;
  --z-sticky: 200;
  --z-modal-bg: 800;
  --z-modal: 900;
  --z-toast: 1000;

  /* Layout */
  --sidebar-w: 220px;
  --content-max: 1400px;
}

/* ── Reset ── */
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }

body {
  font-family: var(--font-body);
  font-size: var(--text-base);
  line-height: 1.6;
  color: var(--text);
  background: var(--bg);
  min-height: 100vh;
  display: flex;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ── Typography ── */
h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-display);
  font-weight: 650;
  line-height: 1.25;
  color: var(--text);
  letter-spacing: -0.01em;
}
h1 { font-size: var(--text-2xl); }
h2 { font-size: var(--text-xl); }
h3 { font-size: var(--text-lg); }

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

p { max-width: 68ch; }

.tabular { font-variant-numeric: tabular-nums; }

/* ── Focus Ring ── */
:focus { outline: none; }
:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

/* ══════════════════════════════════════════
   LAYOUT
   ══════════════════════════════════════════ */

/* ── Sidebar ── */
.sidebar {
  width: var(--sidebar-w);
  background: var(--surface-1);
  border-right: 1px solid var(--border);
  padding: var(--sp-6) var(--sp-4);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: var(--z-sticky);
  transition: transform var(--duration-normal) var(--ease-out);
}

.sidebar-brand {
  font-family: var(--font-display);
  font-size: var(--text-lg);
  font-weight: 700;
  color: var(--primary);
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  margin-bottom: var(--sp-8);
  text-decoration: none;
}
.sidebar-brand:hover { text-decoration: none; }
.sidebar-brand .brand-icon { font-size: 1.6em; }
.brand-tagline {
  font-size: var(--text-xs);
  color: var(--text-muted);
  font-weight: 400;
  letter-spacing: 0.04em;
  margin-top: -2px;
}

/* Nav links */
.nav-link {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: var(--sp-3) var(--sp-4);
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-size: var(--text-sm);
  font-weight: 500;
  text-decoration: none;
  margin-bottom: var(--sp-1);
  transition: background var(--duration-fast) var(--ease-out),
              color var(--duration-fast) var(--ease-out);
}
.nav-link:hover {
  background: var(--surface-2);
  color: var(--text);
  text-decoration: none;
}
.nav-link.active {
  background: var(--primary-subtle);
  color: var(--primary);
}
.nav-link svg {
  width: 18px; height: 18px;
  flex-shrink: 0;
  opacity: 0.7;
}
.nav-link.active svg { opacity: 1; }

.sidebar-footer {
  margin-top: auto;
  padding-top: var(--sp-4);
  border-top: 1px solid var(--border);
}

/* ── Main Content ── */
.main-content {
  flex: 1;
  margin-left: var(--sidebar-w);
  padding: var(--sp-8);
  min-height: 100vh;
  max-width: calc(var(--content-max) + var(--sidebar-w));
}

/* ── Mobile toggle ── */
.mobile-toggle {
  display: none;
  position: fixed;
  top: var(--sp-4);
  left: var(--sp-4);
  z-index: calc(var(--z-sticky) + 1);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: var(--sp-2) var(--sp-3);
  color: var(--text);
  cursor: pointer;
  font-size: var(--text-lg);
  line-height: 1;
}

.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: oklch(0% 0 0 / 0.5);
  z-index: calc(var(--z-sticky) - 1);
}

/* ══════════════════════════════════════════
   COMPONENTS
   ══════════════════════════════════════════ */

/* ── Buttons ── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--sp-2);
  padding: var(--sp-3) var(--sp-5);
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  font-family: var(--font-body);
  font-size: var(--text-sm);
  font-weight: 550;
  cursor: pointer;
  text-decoration: none;
  line-height: 1.4;
  transition: all var(--duration-fast) var(--ease-out);
  white-space: nowrap;
}
.btn:hover { text-decoration: none; }
.btn:active { transform: scale(0.97); }
.btn:disabled, .btn[disabled] {
  opacity: 0.4;
  pointer-events: none;
}

.btn-primary {
  background: var(--primary);
  color: oklch(15% 0.02 45);
  border-color: var(--primary);
}
.btn-primary:hover {
  background: var(--primary-hover);
  border-color: var(--primary-hover);
}

.btn-secondary {
  background: transparent;
  color: var(--text-secondary);
  border-color: var(--border);
}
.btn-secondary:hover {
  background: var(--surface-2);
  color: var(--text);
  border-color: var(--border-hover);
}

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

.btn-danger {
  background: var(--danger);
  color: white;
  border-color: var(--danger);
}
.btn-danger:hover { background: oklch(55% 0.22 25); }

.btn-sm {
  padding: var(--sp-2) var(--sp-3);
  font-size: var(--text-xs);
}
.btn-icon {
  padding: var(--sp-2);
  min-width: 34px;
  min-height: 34px;
}

/* ── Inputs ── */
.input, .textarea, .select {
  width: 100%;
  padding: var(--sp-3) var(--sp-4);
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-family: var(--font-body);
  font-size: var(--text-sm);
  line-height: 1.5;
  transition: border-color var(--duration-fast) var(--ease-out),
              box-shadow var(--duration-fast) var(--ease-out);
}
.input:focus, .textarea:focus, .select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px oklch(68% 0.12 45 / 0.12);
}
.input::placeholder, .textarea::placeholder {
  color: var(--text-muted);
}
.textarea { resize: vertical; min-height: 100px; }
.select { appearance: none; cursor: pointer; }

.form-label {
  display: block;
  font-size: var(--text-xs);
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: var(--sp-2);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.form-group {
  display: flex;
  flex-direction: column;
}

/* ── Cards ── */
.card {
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: var(--sp-6);
  transition: transform var(--duration-fast) var(--ease-out),
              box-shadow var(--duration-fast) var(--ease-out),
              border-color var(--duration-fast) var(--ease-out);
}

.card-hover:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 24px oklch(0% 0 0 / 0.15);
  border-color: var(--border-hover);
}

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: var(--sp-5);
}

.card-title {
  font-family: var(--font-display);
  font-size: var(--text-md);
  font-weight: 650;
}

/* ── URL Input Hero ── */
.url-hero {
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--sp-10) var(--sp-8);
  margin-bottom: var(--sp-8);
  text-align: center;
}
.url-hero-heading {
  font-family: var(--font-display);
  font-size: var(--text-2xl);
  font-weight: 700;
  margin-bottom: var(--sp-2);
}
.url-hero-sub {
  color: var(--text-muted);
  font-size: var(--text-sm);
  margin-bottom: var(--sp-6);
  margin-left: auto;
  margin-right: auto;
}
.url-input-row {
  display: flex;
  gap: var(--sp-3);
  max-width: 640px;
  margin: 0 auto;
}
.url-input-row .input {
  flex: 1;
  font-size: var(--text-md);
  padding: var(--sp-4) var(--sp-5);
  background: var(--surface-2);
  border-color: var(--border-hover);
}
.url-input-row .input:focus {
  border-color: var(--primary);
  background: var(--bg);
}
.url-input-row .btn {
  padding: var(--sp-4) var(--sp-6);
  font-size: var(--text-sm);
  font-weight: 650;
}

.batch-toggle {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: var(--text-sm);
  font-family: var(--font-body);
  padding: var(--sp-2);
  transition: color var(--duration-fast) var(--ease-out);
}
.batch-toggle:hover { color: var(--text); }

.batch-section {
  display: none;
  margin-top: var(--sp-5);
  padding-top: var(--sp-5);
  border-top: 1px solid var(--border);
  max-width: 640px;
  margin-left: auto;
  margin-right: auto;
  text-align: left;
}
.batch-section.open { display: block; }

.batch-results {
  margin-top: var(--sp-3);
  padding: var(--sp-3) var(--sp-4);
  background: var(--success-bg);
  border: 1px solid oklch(40% 0.08 155);
  border-radius: var(--radius-sm);
  font-size: var(--text-sm);
  color: var(--success);
}

/* ── Mini Stats Bar ── */
.mini-stats {
  display: flex;
  gap: var(--sp-6);
  padding: var(--sp-3) 0;
  margin-bottom: var(--sp-6);
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}
.mini-stat {
  display: flex;
  gap: var(--sp-2);
  align-items: baseline;
  font-size: var(--text-sm);
  color: var(--text-muted);
}
.mini-stat strong {
  font-family: var(--font-display);
  font-size: var(--text-md);
  font-weight: 700;
  color: var(--primary);
  font-variant-numeric: tabular-nums;
}

/* Old stats grid (kept for fallback) */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: var(--sp-4);
  margin-bottom: var(--sp-8);
}
.stat-card {
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: var(--sp-5);
  text-align: center;
}
.stat-value {
  font-family: var(--font-display);
  font-size: var(--text-2xl);
  font-weight: 700;
  color: var(--primary);
  font-variant-numeric: tabular-nums;
}
.stat-label {
  font-size: var(--text-xs);
  color: var(--text-muted);
  margin-top: var(--sp-1);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* ── Record List ── */
.record-list {
  display: flex;
  flex-direction: column;
  gap: var(--sp-3);
}

.record-card {
  display: flex;
  gap: var(--sp-4);
  align-items: flex-start;
  padding: var(--sp-5);
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  transition: transform var(--duration-fast) var(--ease-out),
              border-color var(--duration-fast) var(--ease-out),
              box-shadow var(--duration-fast) var(--ease-out);
}
.record-card:hover {
  border-color: var(--border-hover);
  transform: translateY(-1px);
  box-shadow: 0 4px 16px oklch(0% 0 0 / 0.1);
}

.record-card .favicon {
  width: 40px; height: 40px;
  border-radius: var(--radius-sm);
  background: var(--surface-3);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-size: var(--text-md);
  overflow: hidden;
}
.record-card .favicon img {
  width: 24px; height: 24px;
  object-fit: contain;
}

.record-info {
  flex: 1;
  min-width: 0;
  text-decoration: none;
  color: inherit;
}
.record-info:hover { text-decoration: none; }

.record-title {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: var(--text-base);
  margin-bottom: var(--sp-1);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--text);
}

.record-summary {
  font-size: var(--text-sm);
  color: var(--text-secondary);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  line-height: 1.6;
  margin-bottom: var(--sp-2);
}

.record-meta {
  display: flex;
  gap: var(--sp-3);
  margin-top: var(--sp-2);
  font-size: var(--text-xs);
  color: var(--text-muted);
  flex-wrap: wrap;
  align-items: center;
}

/* Source type icons */
.source-icon {
  display: inline-flex;
  align-items: center;
  font-size: var(--text-sm);
  line-height: 1;
}

/* ── Tags ── */
.tag {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-1);
  padding: 2px var(--sp-3);
  background: var(--primary-subtle);
  color: var(--primary);
  border-radius: var(--radius-full);
  font-size: var(--text-xs);
  font-weight: 550;
  line-height: 1.6;
  text-decoration: none;
  border: 1px solid transparent;
  transition: background var(--duration-fast) var(--ease-out);
}
.tag:hover {
  background: oklch(30% 0.05 45);
  text-decoration: none;
}
.tag.active {
  background: var(--primary);
  color: oklch(15% 0.02 45);
}
.tag-remove {
  cursor: pointer;
  opacity: 0.5;
  font-size: var(--text-sm);
  line-height: 1;
  transition: opacity var(--duration-instant);
}
.tag-remove:hover { opacity: 1; }

/* ── Status Badges ── */
.status {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-1);
  padding: 2px var(--sp-3);
  border-radius: var(--radius-full);
  font-size: var(--text-xs);
  font-weight: 600;
  line-height: 1.6;
}
.status-pending,
.status-extracting,
.status-analyzing { background: var(--info-bg); color: var(--info); }
.status-done     { background: var(--success-bg); color: var(--success); }
.status-failed   { background: var(--danger-bg); color: var(--danger); }

/* ── Star Button ── */
.star-btn {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 1.2rem;
  padding: var(--sp-2);
  line-height: 1;
  transition: transform var(--duration-instant) var(--ease-out);
  flex-shrink: 0;
}
.star-btn:hover { transform: scale(1.2); }
.star-btn:active { transform: scale(0.9); }

/* ── Alerts ── */
.alert {
  padding: var(--sp-3) var(--sp-4);
  border-radius: var(--radius-sm);
  margin-bottom: var(--sp-4);
  font-size: var(--text-sm);
  border: 1px solid;
}
.alert-success { background: var(--success-bg); color: var(--success); border-color: oklch(40% 0.08 155); }
.alert-error   { background: var(--danger-bg); color: var(--danger); border-color: oklch(40% 0.08 25); }
.alert-info    { background: var(--info-bg); color: var(--info); border-color: oklch(40% 0.06 250); }

/* ── Pagination ── */
.pagination {
  display: flex;
  gap: var(--sp-2);
  justify-content: center;
  margin-top: var(--sp-8);
}
.pagination a, .pagination span {
  padding: var(--sp-2) var(--sp-3);
  border-radius: var(--radius-sm);
  font-size: var(--text-sm);
  text-decoration: none;
  font-variant-numeric: tabular-nums;
}
.pagination a {
  color: var(--text-muted);
  background: var(--surface-1);
  border: 1px solid var(--border);
  transition: all var(--duration-fast) var(--ease-out);
}
.pagination a:hover {
  border-color: var(--primary);
  color: var(--primary);
}
.pagination span.current {
  background: var(--primary);
  color: oklch(15% 0.02 45);
}

/* ══════════════════════════════════════════
   DETAIL PAGE
   ══════════════════════════════════════════ */

.detail-header {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  margin-bottom: var(--sp-4);
  flex-wrap: wrap;
}
.detail-header h1 {
  flex: 1;
  font-size: var(--text-xl);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}
.detail-header .actions {
  display: flex;
  gap: var(--sp-2);
  flex-shrink: 0;
}

/* Tags under title */
.detail-tags {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-2);
  margin-bottom: var(--sp-6);
  align-items: center;
}
.detail-tags .tag-input-inline {
  display: inline-flex;
}
.detail-tags .tag-input-inline input {
  width: 120px;
  padding: 2px var(--sp-3);
  font-size: var(--text-xs);
  border-radius: var(--radius-full);
  background: var(--surface-2);
  border: 1px dashed var(--border);
}

/* Summary-first layout */
.detail-content {
  display: flex;
  flex-direction: column;
  gap: var(--sp-5);
  max-width: 900px;
}

.summary-card {
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: var(--sp-6);
}
.summary-card h3 {
  font-size: var(--text-sm);
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.03em;
  margin-bottom: var(--sp-3);
  font-weight: 600;
}
.summary-card p {
  font-size: var(--text-base);
  line-height: 1.8;
  color: var(--text);
}

/* Key Points with numbered accent */
.key-points-list {
  counter-reset: kp;
  list-style: none;
}
.key-points-list li {
  counter-increment: kp;
  padding: var(--sp-3) var(--sp-4);
  margin-bottom: var(--sp-2);
  background: var(--surface-2);
  border-radius: var(--radius-sm);
  border-left: 3px solid var(--primary);
  font-size: var(--text-sm);
  line-height: 1.7;
  display: flex;
  gap: var(--sp-3);
  align-items: baseline;
}
.key-points-list li::before {
  content: counter(kp);
  font-family: var(--font-display);
  font-weight: 700;
  font-size: var(--text-xs);
  color: var(--primary);
  min-width: 1.5em;
  text-align: center;
}

/* Collapsible section */
.collapsible {
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
.collapsible-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: var(--sp-4) var(--sp-5);
  cursor: pointer;
  user-select: none;
  transition: background var(--duration-fast);
}
.collapsible-header:hover { background: var(--surface-2); }
.collapsible-header h3 {
  font-size: var(--text-sm);
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.03em;
  font-weight: 600;
  margin: 0;
}
.collapsible-arrow {
  font-size: var(--text-sm);
  color: var(--text-muted);
  transition: transform var(--duration-fast) var(--ease-out);
}
.collapsible.open .collapsible-arrow { transform: rotate(180deg); }
.collapsible-body {
  max-height: 0;
  overflow: hidden;
  transition: max-height var(--duration-normal) var(--ease-out);
}
.collapsible.open .collapsible-body {
  max-height: 2000px;
}
.collapsible-inner {
  padding: 0 var(--sp-5) var(--sp-5);
}

/* Notes section */
.notes-section {
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: var(--sp-5);
}
.notes-section h3 {
  font-size: var(--text-sm);
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.03em;
  font-weight: 600;
  margin-bottom: var(--sp-3);
}
.notes-textarea {
  width: 100%;
  min-height: 120px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  padding: var(--sp-4);
  font-size: var(--text-sm);
  resize: vertical;
  font-family: var(--font-body);
  line-height: 1.7;
  transition: border-color var(--duration-fast) var(--ease-out);
}
.notes-textarea:focus {
  outline: none;
  border-color: var(--primary);
}
.notes-save-hint {
  font-size: var(--text-xs);
  color: var(--text-muted);
  margin-top: var(--sp-2);
}

/* Metadata (simplified) */
.meta-simple {
  display: flex;
  gap: var(--sp-5);
  flex-wrap: wrap;
  font-size: var(--text-xs);
  color: var(--text-muted);
  padding: var(--sp-3) 0;
}
.meta-simple span {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-1);
}

/* Mindmap (in collapsible) */
.mindmap-area {
  background: white;
  border-radius: var(--radius-sm);
  overflow: hidden;
}
.mindmap-toolbar {
  background: var(--surface-2);
  padding: var(--sp-3) var(--sp-4);
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: var(--sp-2);
}
#mindmap-svg {
  width: 100%;
  min-height: 500px;
}

/* Step progress */
.step-progress {
  display: flex;
  gap: 0;
  margin: var(--sp-8) auto;
  max-width: 480px;
}
.step-progress-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  position: relative;
}
.step-progress-item::before {
  content: '';
  position: absolute;
  top: 14px;
  left: 50%;
  width: 100%;
  height: 2px;
  background: var(--border);
}
.step-progress-item:last-child::before { display: none; }
.step-progress-item.active::before { background: var(--primary); }
.step-progress-item.done::before { background: var(--success); }
.step-dot {
  width: 28px; height: 28px;
  border-radius: 50%;
  background: var(--surface-3);
  border: 2px solid var(--border);
  display: flex; align-items: center; justify-content: center;
  font-size: var(--text-xs);
  z-index: 1;
  transition: all var(--duration-fast);
}
.step-progress-item.active .step-dot {
  border-color: var(--primary);
  background: var(--primary-subtle);
  color: var(--primary);
}
.step-progress-item.done .step-dot {
  border-color: var(--success);
  background: var(--success-bg);
  color: var(--success);
}
.step-label {
  font-size: var(--text-xs);
  color: var(--text-muted);
  margin-top: var(--sp-2);
  text-align: center;
}
.step-progress-item.active .step-label { color: var(--primary); font-weight: 600; }
.step-progress-item.done .step-label { color: var(--success); }

/* Old detail-grid (kept for backward compat) */
.detail-grid {
  display: grid;
  grid-template-columns: 1fr 360px;
  gap: var(--sp-6);
  min-height: calc(100vh - 10rem);
}
.info-panel { display: flex; flex-direction: column; gap: var(--sp-4); }
.info-card {
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: var(--sp-5);
}
.info-card h3 {
  font-family: var(--font-display);
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: var(--sp-3);
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}
.info-card p { font-size: var(--text-sm); line-height: 1.7; }
.key-points { list-style: none; }
.key-points li {
  padding: var(--sp-2) 0;
  border-bottom: 1px solid var(--border);
  font-size: var(--text-sm);
  line-height: 1.6;
}
.key-points li:last-child { border-bottom: none; }
.entity-group { margin-bottom: var(--sp-3); }
.entity-label {
  font-size: var(--text-xs);
  color: var(--text-muted);
  margin-bottom: var(--sp-2);
  font-weight: 550;
}
.meta-row {
  display: flex;
  justify-content: space-between;
  padding: var(--sp-2) 0;
  font-size: var(--text-sm);
  border-bottom: 1px solid var(--border);
}
.meta-row:last-child { border-bottom: none; }
.meta-row span:first-child { color: var(--text-muted); }
.meta-row span:last-child { font-variant-numeric: tabular-nums; }

/* View tabs */
.view-tabs {
  display: flex;
  gap: 0;
  margin-top: var(--sp-6);
  border-bottom: 2px solid var(--border);
}
.view-tab {
  padding: var(--sp-3) var(--sp-5);
  cursor: pointer;
  font-size: var(--text-sm);
  font-weight: 550;
  color: var(--text-muted);
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  transition: all var(--duration-fast) var(--ease-out);
}
.view-tab:hover { color: var(--text); }
.view-tab.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
}
.tab-content { display: none; }
.tab-content.active { display: block; }

/* Reader mode */
.reader-content {
  max-width: 720px;
  margin: var(--sp-4) auto;
  line-height: 1.9;
  font-size: var(--text-md);
  white-space: pre-wrap;
  word-wrap: break-word;
  padding: var(--sp-6);
}

/* ── Loading & Error ── */
.loading-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: var(--sp-16);
  gap: var(--sp-4);
}
.error-state {
  text-align: center;
  padding: var(--sp-12);
}
.error-state .error-icon {
  font-size: 3rem;
  margin-bottom: var(--sp-4);
}

@keyframes spin { to { transform: rotate(360deg); } }
.spinner {
  width: 36px; height: 36px;
  border: 3px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

@keyframes pulse { 0%,100%{opacity:1} 50%{opacity:.4} }
.animate-pulse { animation: pulse 2s var(--ease-inout) infinite; }

/* ══════════════════════════════════════════
   TOAST NOTIFICATIONS
   ══════════════════════════════════════════ */
.toast-container {
  position: fixed;
  top: var(--sp-5);
  right: var(--sp-5);
  z-index: var(--z-toast);
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
  pointer-events: none;
}
.toast {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: var(--sp-3) var(--sp-5);
  border-radius: var(--radius-sm);
  font-size: var(--text-sm);
  font-weight: 500;
  pointer-events: auto;
  opacity: 0;
  transform: translateX(20px);
  transition: all var(--duration-normal) var(--ease-out);
  box-shadow: 0 4px 16px oklch(0% 0 0 / 0.2);
}
.toast-visible {
  opacity: 1;
  transform: translateX(0);
}
.toast-hiding {
  opacity: 0;
  transform: translateX(20px);
}
.toast-success { background: var(--success-bg); color: var(--success); border: 1px solid oklch(40% 0.08 155); }
.toast-error { background: var(--danger-bg); color: var(--danger); border: 1px solid oklch(40% 0.08 25); }
.toast-info { background: var(--info-bg); color: var(--info); border: 1px solid oklch(40% 0.06 250); }
.toast-warning { background: var(--warning-bg); color: var(--warning); border: 1px solid oklch(40% 0.06 80); }
.toast-icon { font-size: var(--text-md); }

/* ══════════════════════════════════════════
   MODALS (enhanced)
   ══════════════════════════════════════════ */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: oklch(0% 0 0 / 0.55);
  z-index: var(--z-modal-bg);
  display: flex;
  align-items: center;
  justify-content: center;
  animation: fade-in var(--duration-fast) var(--ease-out);
}
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }
.modal-box {
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--sp-6);
  width: 90%;
  max-width: 440px;
  animation: modal-in var(--duration-normal) var(--ease-out);
}
@keyframes modal-in { from { opacity: 0; transform: scale(0.95) translateY(8px); } to { opacity: 1; transform: scale(1) translateY(0); } }
.modal-box h3 {
  margin-bottom: var(--sp-4);
  font-size: var(--text-md);
}
.modal-actions {
  display: flex;
  gap: var(--sp-2);
  justify-content: flex-end;
  margin-top: var(--sp-5);
}
.modal-hint {
  font-size: var(--text-xs);
  color: var(--text-muted);
  margin-top: var(--sp-2);
}

/* Context menu */
.ctx-menu {
  position: fixed;
  z-index: var(--z-toast);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: var(--sp-1) 0;
  min-width: 150px;
  list-style: none;
  box-shadow: 0 8px 24px oklch(0% 0 0 / 0.3);
}
.ctx-menu li {
  padding: var(--sp-2) var(--sp-4);
  cursor: pointer;
  font-size: var(--text-sm);
  color: var(--text);
  transition: background var(--duration-instant);
}
.ctx-menu li:hover { background: var(--surface-3); }
.ctx-menu li.danger { color: var(--danger); }

/* ── Tag autocomplete ── */
.tag-input-wrap { position: relative; margin-top: var(--sp-3); }
.tag-suggestions {
  position: absolute;
  top: 100%;
  left: 0; right: 0;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 0 0 var(--radius-sm) var(--radius-sm);
  max-height: 180px;
  overflow-y: auto;
  z-index: var(--z-dropdown);
  display: none;
}
.tag-suggestions div {
  padding: var(--sp-2) var(--sp-3);
  cursor: pointer;
  font-size: var(--text-sm);
  transition: background var(--duration-instant);
}
.tag-suggestions div:hover { background: var(--surface-3); }

/* ── Batch action bar ── */
.batch-bar {
  display: none;
  position: fixed;
  bottom: var(--sp-6);
  left: 50%;
  transform: translateX(-50%);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--sp-3) var(--sp-6);
  box-shadow: 0 8px 32px oklch(0% 0 0 / 0.4);
  z-index: var(--z-dropdown);
  align-items: center;
  gap: var(--sp-3);
}
.batch-bar.visible { display: flex; }

/* ── Search bar (promoted) ── */
.search-hero {
  margin-bottom: var(--sp-5);
}
.search-hero .input {
  font-size: var(--text-md);
  padding: var(--sp-4) var(--sp-5);
  background: var(--surface-2);
  border-color: var(--border);
}
.search-hero .input:focus {
  border-color: var(--primary);
  background: var(--surface-1);
}

/* ── Filter bar ── */
.filter-bar {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-3);
  align-items: flex-end;
}
.filter-bar .form-group {
  flex: 1;
  min-width: 140px;
}

.filter-toggle {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  font-size: var(--text-sm);
  color: var(--text-muted);
  cursor: pointer;
  background: none;
  border: none;
  font-family: var(--font-body);
  padding: var(--sp-2) 0;
  transition: color var(--duration-fast);
}
.filter-toggle:hover { color: var(--text); }

.tag-filters {
  display: flex;
  gap: var(--sp-2);
  margin-top: var(--sp-3);
  flex-wrap: wrap;
}

/* ══════════════════════════════════════════
   PAGE-SPECIFIC
   ══════════════════════════════════════════ */

/* Settings page */
.settings-section  {
  margin-bottom: var(--sp-6);
}
.settings-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: var(--sp-4);
}

/* Collections/Tags management */
.mgmt-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: var(--sp-4);
}
.mgmt-card {
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: var(--sp-5);
  transition: transform var(--duration-fast) var(--ease-out),
              border-color var(--duration-fast) var(--ease-out),
              box-shadow var(--duration-fast) var(--ease-out);
}
.mgmt-card:hover {
  border-color: var(--border-hover);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px oklch(0% 0 0 / 0.08);
}

/* Login */
.login-container {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--sp-6);
  background: var(--bg);
}
.login-box {
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  padding: var(--sp-12) var(--sp-10);
  width: 100%;
  max-width: 420px;
  box-shadow: 0 16px 48px oklch(0% 0 0 / 0.2);
}
.login-brand {
  text-align: center;
  margin-bottom: var(--sp-10);
}
.login-brand .brand-emoji {
  font-size: 3rem;
  margin-bottom: var(--sp-3);
  display: block;
}
.login-brand h1 {
  font-size: var(--text-xl);
  color: var(--primary);
  margin-bottom: var(--sp-1);
}
.login-brand .login-tagline {
  color: var(--text-muted);
  font-size: var(--text-sm);
}

/* Duplicate page */
.duplicate-card {
  max-width: 560px;
  margin: var(--sp-16) auto;
  text-align: center;
}
.duplicate-card .actions {
  display: flex;
  gap: var(--sp-3);
  justify-content: center;
  margin-top: var(--sp-6);
}

/* ── Checkbox ── */
.record-cb {
  accent-color: var(--primary);
  width: 16px;
  height: 16px;
  cursor: pointer;
  flex-shrink: 0;
  margin-top: var(--sp-2);
}

/* ── Page header ── */
.page-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: var(--sp-6);
}

/* ── Empty state ── */
.empty-state {
  text-align: center;
  padding: var(--sp-16);
  color: var(--text-muted);
}
.empty-state p { margin: 0 auto; }
.empty-state .icon {
  font-size: 3rem;
  margin-bottom: var(--sp-4);
}
.empty-state .cta {
  margin-top: var(--sp-5);
}

/* ── Skeleton loading ── */
@keyframes shimmer {
  0% { background-position: -200% 0; }
  100% { background-position: 200% 0; }
}
.skeleton {
  background: linear-gradient(90deg, var(--surface-2) 25%, var(--surface-3) 50%, var(--surface-2) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  border-radius: var(--radius-sm);
}
.skeleton-line { height: 14px; margin-bottom: var(--sp-2); }
.skeleton-line.w-75 { width: 75%; }
.skeleton-line.w-50 { width: 50%; }
.skeleton-line.w-full { width: 100%; }
.skeleton-circle { border-radius: 50%; }

/* ══════════════════════════════════════════
   ANIMATIONS
   ══════════════════════════════════════════ */

@keyframes fade-in-up {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: translateY(0); }
}
.animate-in {
  animation: fade-in-up var(--duration-slow) var(--ease-out) both;
}
.stagger-1 { animation-delay: 60ms; }
.stagger-2 { animation-delay: 120ms; }
.stagger-3 { animation-delay: 180ms; }
.stagger-4 { animation-delay: 240ms; }

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

/* ══════════════════════════════════════════
   RESPONSIVE
   ══════════════════════════════════════════ */

@media (max-width: 1024px) {
  .detail-grid { grid-template-columns: 1fr; }
}

@media (max-width: 768px) {
  .mobile-toggle { display: block; }

  .sidebar {
    transform: translateX(-100%);
  }
  .sidebar.open {
    transform: translateX(0);
    box-shadow: 8px 0 24px oklch(0% 0 0 / 0.3);
  }
  .sidebar-overlay.open { display: block; }

  .main-content {
    margin-left: 0;
    padding: var(--sp-5);
    padding-top: calc(var(--sp-5) + 48px);
  }

  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .mini-stats { gap: var(--sp-4); }

  .url-input-row { flex-direction: column; }
  .url-hero { padding: var(--sp-6); }

  .filter-bar { flex-direction: column; }
  .filter-bar .form-group { min-width: 100%; }

  .detail-header h1 { font-size: var(--text-lg); }
  .page-header { flex-direction: column; gap: var(--sp-3); align-items: stretch; }

  /* Larger tap targets on mobile */
  .record-card { padding: var(--sp-5) var(--sp-4); }
  .star-btn { font-size: 1.4rem; padding: var(--sp-3); }
  .record-cb { width: 20px; height: 20px; }

  .batch-bar {
    left: var(--sp-3);
    right: var(--sp-3);
    transform: none;
    justify-content: center;
    flex-wrap: wrap;
  }

  .toast-container {
    top: auto;
    bottom: var(--sp-5);
    left: var(--sp-3);
    right: var(--sp-3);
  }
}

@media (max-width: 480px) {
  .stats-grid { grid-template-columns: 1fr; }
  .detail-header .actions { flex-wrap: wrap; }
}
