/* ============================================================
   SimplTasks Legal Center — Enterprise Documentation Style
   Inspired by Stripe Docs, Vercel, Linear, and Notion
   Pure CSS, zero dependencies, self-hosted Inter
   Features: refined typography, sophisticated color palette,
             subtle depth, professional spacing, dark mode,
             responsive 4-breakpoint, print-optimized
   ============================================================ */

/* ── Self-Hosted Inter Variable ─────────────────────────
   Served from this origin (css/fonts/). Deliberately NOT a
   third-party CDN: a privacy page must not leak visitor IPs
   to Google Fonts or jsDelivr, and doing so would falsify
   "zero external requests" in README.md.
   Inter © The Inter Project Authors — SIL OFL 1.1
   (full text: css/fonts/LICENSE-Inter.txt)
   ────────────────────────────────────────────────────── */
@font-face {
  font-family: "Inter";
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url("fonts/inter-latin-wght-normal.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+2074, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

/* ── CSS Variables ────────────────────────────────────── */
:root {
  /* Core neutrals */
  --color-bg: #fafafa;
  --color-surface: #ffffff;
  --color-sidebar-bg: #f5f5f7;
  --color-border: #e5e5e7;
  --color-border-subtle: #f0f0f2;
  
  /* Text hierarchy */
  --color-text-primary: #1d1d1f;
  --color-text-secondary: #6e6e73;
  --color-text-tertiary: #86868b;
  --color-text-inverse: #ffffff;
  
  /* Brand accent — refined blue */
  --color-accent: #0071e3;
  --color-accent-hover: #0077ed;
  --color-accent-subtle: #e8f4fd;
  --color-accent-text: #ffffff;
  --color-accent-glow: rgba(0, 113, 227, 0.16);
  
  /* Semantic colors */
  --color-success: #34c759;
  --color-success-bg: #edfcf2;
  --color-warning: #ff9500;
  --color-warning-bg: #fff8e6;
  --color-error: #ff3b30;
  --color-error-bg: #ffe5e5;
  --color-info: #007aff;
  --color-info-bg: #e8f4fd;
  
  /* Header & footer */
  --color-header-bg: rgba(255, 255, 255, 0.8);
  --color-header-border: rgba(0, 0, 0, 0.08);
  --color-footer-bg: #f5f5f7;
  --color-footer-text: #6e6e73;
  
  /* Tables */
  --color-table-header: #f5f5f7;
  --color-table-stripe: #fafafa;
  --color-table-border: #e5e5e7;
  
  /* Code */
  --color-code-bg: #f5f5f7;
  --color-code-text: #1d1d1f;
  
  /* Shadows — subtle depth */
  --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.04);
  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.06);
  --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.08);
  --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.12);
  
  /* Radii */
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --radius-xl: 20px;
  
  /* Typography */
  --font-sans: "Inter", -apple-system, BlinkMacSystemFont, "SF Pro Display", "SF Pro Text", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-mono: "SF Mono", "Fira Code", "Fira Mono", "Roboto Mono", Menlo, Courier, monospace;
  
  /* Layout */
  --sidebar-width: 280px;
  --header-height: 64px;
  --content-max-width: 820px;
  
  /* Transitions */
  --transition-fast: 150ms cubic-bezier(0.4, 0, 0.2, 1);
  --transition-base: 250ms cubic-bezier(0.4, 0, 0.2, 1);
  --transition-smooth: 400ms cubic-bezier(0.22, 0.61, 0.36, 1);
}

/* ─ Dark Mode ────────────────────────────────────────── */
@media (prefers-color-scheme: dark) {
  :root {
    --color-bg: #000000;
    --color-surface: #1c1c1e;
    --color-sidebar-bg: #111111;
    --color-border: #2c2c2e;
    --color-border-subtle: #1c1c1e;
    
    --color-text-primary: #f5f5f7;
    --color-text-secondary: #a1a1a6;
    --color-text-tertiary: #6e6e73;
    
    --color-accent: #0a84ff;
    --color-accent-hover: #409cff;
    --color-accent-subtle: #0d2137;
    --color-accent-glow: rgba(10, 132, 255, 0.22);
    
    --color-success: #30d158;
    --color-success-bg: #0d2818;
    --color-warning: #ff9f0a;
    --color-warning-bg: #2a1f0a;
    --color-error: #ff453a;
    --color-error-bg: #2a0f0e;
    --color-info: #0a84ff;
    --color-info-bg: #0d2137;
    
    --color-header-bg: rgba(0, 0, 0, 0.8);
    --color-header-border: rgba(255, 255, 255, 0.08);
    --color-footer-bg: #111111;
    --color-footer-text: #6e6e73;
    
    --color-table-header: #1c1c1e;
    --color-table-stripe: #111111;
    --color-table-border: #2c2c2e;
    
    --color-code-bg: #1c1c1e;
    --color-code-text: #f5f5f7;
    
    --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.2);
    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.5);
  }
}

/* ── Reset & Base ──────────────────────────────────────── */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  scroll-behavior: smooth;
  scroll-padding-top: calc(var(--header-height) + 24px);
  -webkit-text-size-adjust: 100%;
  font-feature-settings: "kern" 1, "liga" 1;
}

body {
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.6;
  color: var(--color-text-primary);
  background: var(--color-bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
  letter-spacing: -0.011em;
}

/* ── Header ────────────────────────────────────────────── */
.site-header {
  background: var(--color-header-bg);
  backdrop-filter: saturate(180%) blur(20px);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  border-bottom: 1px solid var(--color-header-border);
  position: sticky;
  top: 0;
  z-index: 100;
  height: var(--header-height);
  display: flex;
  align-items: center;
}

.header-inner {
  max-width: 1440px;
  width: 100%;
  margin: 0 auto;
  padding: 0 32px;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
}

.header-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
  color: var(--color-text-primary);
  font-weight: 600;
  font-size: 1.05rem;
  letter-spacing: -0.02em;
  transition: opacity var(--transition-fast);
}

.header-brand:hover {
  opacity: 0.7;
}

.header-brand img {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  flex-shrink: 0;
}

.header-nav {
  display: flex;
  align-items: center;
  gap: 4px;
  list-style: none;
}

.header-nav a {
  color: var(--color-text-secondary);
  text-decoration: none;
  padding: 8px 16px;
  border-radius: var(--radius-md);
  font-size: 0.875rem;
  font-weight: 500;
  transition: all var(--transition-fast);
  white-space: nowrap;
  letter-spacing: -0.01em;
}

.header-nav a:hover {
  color: var(--color-text-primary);
  background: var(--color-border-subtle);
}

.header-nav a.active {
  color: var(--color-accent);
  background: var(--color-accent-subtle);
  font-weight: 600;
}

/* ── Hamburger ─────────────────────────────────────────── */
.mobile-nav-toggle {
  display: none;
  background: none;
  border: none;
  cursor: pointer;
  padding: 8px;
  border-radius: var(--radius-md);
  flex-direction: column;
  gap: 5px;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  z-index: 102;
  transition: background var(--transition-fast);
}

.mobile-nav-toggle:hover {
  background: var(--color-border-subtle);
}

.hamburger-line {
  display: block;
  width: 20px;
  height: 2px;
  background: var(--color-text-primary);
  border-radius: 2px;
  transition: all var(--transition-base);
  transform-origin: center;
}

.mobile-nav-toggle.open .hamburger-line:nth-child(1) {
  transform: translateY(7px) rotate(45deg);
}

.mobile-nav-toggle.open .hamburger-line:nth-child(2) {
  opacity: 0;
}

.mobile-nav-toggle.open .hamburger-line:nth-child(3) {
  transform: translateY(-7px) rotate(-45deg);
}

/* ── Main Layout ───────────────────────────────────────── */
.app-layout {
  display: flex;
  flex: 1;
  min-height: 0;
  width: 100%;
  max-width: 1440px;
  margin: 0 auto;
}

/* ── Sidebar ───────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-width);
  flex-shrink: 0;
  background: var(--color-sidebar-bg);
  color: var(--color-text-secondary);
  padding: 32px 24px 48px;
  overflow-y: auto;
  position: sticky;
  top: var(--header-height);
  height: calc(100vh - var(--header-height));
  border-right: 1px solid var(--color-border);
}

.sidebar-title {
  font-size: 0.6875rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--color-text-tertiary);
  margin-bottom: 20px;
  padding-left: 8px;
}

.toc-list {
  list-style: none;
  padding: 0;
}

.toc-list li {
  margin: 0;
}

.toc-list a {
  display: block;
  padding: 8px 12px;
  color: var(--color-text-secondary);
  text-decoration: none;
  font-size: 0.875rem;
  border-radius: var(--radius-md);
  transition: all var(--transition-fast);
  line-height: 1.5;
  margin-bottom: 2px;
  letter-spacing: -0.01em;
  border-left: 2px solid transparent;
}

.toc-list a:hover {
  color: var(--color-text-primary);
  background: var(--color-border-subtle);
}

.toc-list a.toc-active {
  color: var(--color-accent);
  background: var(--color-accent-subtle);
  font-weight: 600;
  border-left-color: var(--color-accent);
}

.toc-dropdown-toggle {
  display: none;
  width: 100%;
  padding: 12px 16px;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  font-family: var(--font-sans);
  font-size: 0.875rem;
  color: var(--color-text-primary);
  cursor: pointer;
  text-align: left;
  font-weight: 500;
  transition: all var(--transition-fast);
}

.toc-dropdown-toggle:hover {
  border-color: var(--color-text-tertiary);
}

.toc-dropdown-toggle:focus {
  outline: 2px solid var(--color-accent);
  outline-offset: 2px;
}

/* ── Main Content ──────────────────────────────────────── */
.main-content {
  flex: 1;
  min-width: 0;
  padding: 48px 64px 96px;
  max-width: var(--content-max-width);
}

.content-card {
  /* pure content, no card styling */
}

/* ── Page Title Area ───────────────────────────────────── */
.page-title-area {
  margin-bottom: 48px;
  padding-bottom: 32px;
  border-bottom: 1px solid var(--color-border);
}

.page-title-area h1 {
  font-size: 2.5rem;
  font-weight: 700;
  color: var(--color-text-primary);
  letter-spacing: -0.035em;
  line-height: 1.15;
  margin-bottom: 12px;
}

.page-subtitle {
  font-size: 1.125rem;
  color: var(--color-text-secondary);
  line-height: 1.5;
  max-width: 640px;
  letter-spacing: -0.01em;
}

.page-meta {
  font-size: 0.8125rem;
  color: var(--color-text-tertiary);
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 16px;
  font-weight: 500;
}

.page-meta svg {
  width: 16px;
  height: 16px;
  opacity: 0.5;
}

/* ── Section Headings ──────────────────────────────────── */
.section-heading {
  display: flex;
  align-items: baseline;
  gap: 16px;
  margin-top: 56px;
  margin-bottom: 20px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--color-border-subtle);
}

.section-heading:first-of-type {
  margin-top: 8px;
}

.section-heading h2 {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--color-text-primary);
  letter-spacing: -0.025em;
  line-height: 1.3;
  margin: 0;
  padding: 0;
  border: none;
  flex: 1;
}

/* ── Typography ────────────────────────────────────────── */
.content-card p {
  margin-bottom: 20px;
  color: var(--color-text-secondary);
  line-height: 1.7;
  letter-spacing: -0.01em;
}

.content-card ul, .content-card ol {
  margin-bottom: 24px;
  padding-left: 24px;
  color: var(--color-text-secondary);
}

.content-card li {
  margin-bottom: 10px;
  line-height: 1.6;
}

.content-card li:last-child {
  margin-bottom: 0;
}

.content-card strong {
  font-weight: 600;
  color: var(--color-text-primary);
}

.content-card a {
  color: var(--color-accent);
  text-decoration: none;
  transition: color var(--transition-fast);
  border-bottom: 1px solid transparent;
  font-weight: 500;
}

.content-card a:hover {
  color: var(--color-accent-hover);
  border-bottom-color: var(--color-accent);
}

.content-card h3 {
  font-size: 1.125rem;
  font-weight: 600;
  color: var(--color-text-primary);
  margin-top: 36px;
  margin-bottom: 12px;
  letter-spacing: -0.02em;
}

/* ── Tables ────────────────────────────────────────────── */
.content-card table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  margin: 24px 0 32px;
  font-size: 0.875rem;
  border-radius: var(--radius-md);
  border: 1px solid var(--color-table-border);
  display: block;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  background: var(--color-surface);
}

.content-card table::-webkit-scrollbar {
  height: 6px;
}

.content-card table::-webkit-scrollbar-thumb {
  background: var(--color-border);
  border-radius: 3px;
}

.content-card thead {
  background: var(--color-table-header);
}

.content-card th {
  text-align: left;
  padding: 12px 16px;
  font-weight: 600;
  color: var(--color-text-primary);
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  border-bottom: 1px solid var(--color-table-border);
  white-space: nowrap;
}

.content-card td {
  padding: 14px 16px;
  color: var(--color-text-secondary);
  border-bottom: 1px solid var(--color-border-subtle);
  vertical-align: top;
}

.content-card tbody tr {
  transition: background var(--transition-fast);
}

.content-card tbody tr:nth-child(even) {
  background: var(--color-table-stripe);
}

.content-card tbody tr:hover {
  background: var(--color-accent-subtle);
}

.content-card tbody tr:last-child td {
  border-bottom: none;
}

/* ── Info / Warning / Success Boxes ───────────────────── */
.info-box, .warning-box, .success-box {
  border-radius: var(--radius-md);
  padding: 16px 20px;
  margin: 24px 0;
  font-size: 0.9375rem;
  border: 1px solid;
  line-height: 1.6;
  letter-spacing: -0.01em;
}

.info-box {
  background: var(--color-info-bg);
  border-color: var(--color-info);
  border-left: 3px solid var(--color-info);
}

.info-box strong {
  color: var(--color-info);
}

.warning-box {
  background: var(--color-warning-bg);
  border-color: var(--color-warning);
  border-left: 3px solid var(--color-warning);
}

.warning-box strong {
  color: var(--color-warning);
}

.success-box {
  background: var(--color-success-bg);
  border-color: var(--color-success);
  border-left: 3px solid var(--color-success);
}

.success-box strong {
  color: var(--color-success);
}

/* ── Badge ─────────────────────────────────────────────── */
.badge {
  display: inline-block;
  padding: 3px 10px;
  font-size: 0.6875rem;
  font-weight: 600;
  border-radius: 99px;
  background: var(--color-accent-subtle);
  color: var(--color-accent);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  vertical-align: middle;
  margin-left: 8px;
}

/* ── Step List ─────────────────────────────────────────── */
.step-list {
  counter-reset: step;
  list-style: none;
  padding-left: 0;
}

.step-list li {
  counter-increment: step;
  position: relative;
  padding: 20px 20px 20px 64px;
  margin-bottom: 12px;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  transition: all var(--transition-fast);
  box-shadow: var(--shadow-xs);
}

.step-list li:hover {
  border-color: var(--color-text-tertiary);
  box-shadow: var(--shadow-sm);
}

.step-list li::before {
  content: counter(step);
  position: absolute;
  left: 16px;
  top: 18px;
  width: 36px;
  height: 36px;
  background: var(--color-accent);
  color: var(--color-accent-text);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.875rem;
  box-shadow: var(--shadow-xs);
}

/* ── Accordion FAQ ─────────────────────────────────────── */
.accordion-item {
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  margin-bottom: 10px;
  background: var(--color-surface);
  overflow: hidden;
  transition: all var(--transition-fast);
}

.accordion-item:hover {
  border-color: var(--color-text-tertiary);
}

.accordion-trigger {
  width: 100%;
  text-align: left;
  background: none;
  border: none;
  padding: 18px 48px 18px 20px;
  font-family: var(--font-sans);
  font-size: 0.9375rem;
  font-weight: 600;
  color: var(--color-text-primary);
  cursor: pointer;
  position: relative;
  line-height: 1.4;
  letter-spacing: -0.01em;
  transition: background var(--transition-fast);
}

.accordion-trigger:hover {
  background: var(--color-border-subtle);
}

.accordion-trigger::after {
  content: '+';
  position: absolute;
  right: 20px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 1.25rem;
  font-weight: 300;
  color: var(--color-text-tertiary);
  transition: transform var(--transition-base);
}

.accordion-item.open .accordion-trigger::after {
  transform: translateY(-50%) rotate(45deg);
}

.accordion-content {
  max-height: 0;
  overflow: hidden;
  transition: max-height var(--transition-smooth), padding var(--transition-base);
}

.accordion-item.open .accordion-content {
  max-height: 800px;
  padding: 0 20px 20px;
}

/* ── Deletion Timeline ─────────────────────────────────── */
.deletion-timeline {
  display: flex;
  flex-wrap: wrap;
  gap: 0;
  margin: 32px 0 40px;
  position: relative;
}

.deletion-timeline::before {
  content: '';
  position: absolute;
  top: 24px;
  left: 40px;
  right: 40px;
  height: 2px;
  background: var(--color-border);
  z-index: 0;
}

.timeline-step {
  flex: 1;
  min-width: 110px;
  text-align: center;
  position: relative;
  z-index: 1;
  padding: 0 12px;
}

.timeline-dot {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: var(--color-surface);
  border: 2px solid var(--color-accent);
  margin: 0 auto 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.875rem;
  color: var(--color-accent);
  box-shadow: var(--shadow-xs);
  transition: all var(--transition-fast);
}

.timeline-step:hover .timeline-dot {
  transform: scale(1.1);
  box-shadow: var(--shadow-sm);
}

.timeline-step:last-child .timeline-dot {
  background: var(--color-success);
  border-color: var(--color-success);
  color: var(--color-text-inverse);
}

.timeline-label {
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--color-text-primary);
  margin-bottom: 4px;
  letter-spacing: -0.01em;
}

.timeline-sublabel {
  font-size: 0.75rem;
  color: var(--color-text-tertiary);
  line-height: 1.4;
}

/* ── Data Flow Diagram ─────────────────────────────────── */
.data-flow {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  margin: 32px 0 40px;
  padding: 32px 24px;
  background: var(--color-accent-subtle);
  border-radius: var(--radius-lg);
  border: 1px solid var(--color-border);
}

.flow-node {
  position: relative;
  background: var(--color-surface);
  border: 1px solid var(--color-accent);
  border-radius: var(--radius-md);
  padding: 12px 20px;
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--color-text-primary);
  text-align: center;
  white-space: nowrap;
  transition: transform var(--transition-fast), box-shadow var(--transition-fast), border-color var(--transition-fast);
  box-shadow: var(--shadow-xs);
}

/* Breathing ring lives on a pseudo-element, so it never collides with
   the hover lift/shadow on the node itself. */
.flow-node::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  pointer-events: none;
  box-shadow: 0 0 0 0 var(--color-accent-glow);
  animation: node-breathe 3.2s ease-in-out infinite;
}

.flow-node:hover {
  border-color: var(--color-accent-hover);
  box-shadow: var(--shadow-sm);
  transform: translateY(-2px);
}

.flow-node.user {
  background: var(--color-accent);
  color: var(--color-text-inverse);
  border-color: var(--color-accent);
}

/* Connector: dashed rail + arrowhead, both drawn in CSS. The rail is a
   repeating gradient whose background-position is animated, so the dashes
   travel without any SVG or JavaScript. Vertical, because the content column
   is capped at 692px by --content-max-width and the chain needs 1035px to
   sit on one line — a horizontal rail would always wrap and strand a head. */
.flow-arrow {
  position: relative;
  display: block;
  width: 20px;
  height: 40px;
  flex-shrink: 0;
  color: var(--color-accent);
  opacity: 0.6;
}

.flow-arrow::before {
  content: "";
  position: absolute;
  top: 0;
  bottom: 8px;
  left: 50%;
  width: 2px;
  margin-left: -1px;
  background-image: repeating-linear-gradient(to bottom, currentColor 0 6px, transparent 6px 12px);
  background-size: 2px 12px;
  animation: flow-dash 1.6s linear infinite;
}

.flow-arrow::after {
  content: "";
  position: absolute;
  bottom: 1px;
  left: 50%;
  width: 6px;
  height: 6px;
  border-top: 2px solid currentColor;
  border-right: 2px solid currentColor;
  transform: translateX(-50%) rotate(135deg);
}

@keyframes node-breathe {
  0%, 100% { box-shadow: 0 0 0 0 var(--color-accent-glow); }
  50%      { box-shadow: 0 0 0 5px var(--color-accent-glow); }
}

@keyframes flow-dash {
  from { background-position: 0 0; }
  to   { background-position: 0 12px; }
}

@media (prefers-reduced-motion: reduce) {
  .flow-node::after,
  .flow-arrow::before {
    animation: none;
  }
}

.flow-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
  align-items: center;
  /* Let the processor row shrink so its chips wrap inside the card on
     narrow screens instead of overflowing it. */
  min-width: 0;
}

/* ── Scroll-Reveal Animation ───────────────────────────── */
.reveal {
  opacity: 0;
  transform: translateY(20px);
  transition: opacity var(--transition-smooth), transform var(--transition-smooth);
}

.reveal.revealed {
  opacity: 1;
  transform: translateY(0);
}

/* ── Back to Top ──────────────────────────────────────── */
.back-to-top {
  position: fixed;
  bottom: 32px;
  right: 32px;
  width: 44px;
  height: 44px;
  background: var(--color-surface);
  color: var(--color-text-primary);
  border: 1px solid var(--color-border);
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow-md);
  opacity: 0;
  transform: translateY(16px);
  pointer-events: none;
  transition: all var(--transition-base);
  z-index: 50;
}

.back-to-top.visible {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}

.back-to-top:hover {
  border-color: var(--color-accent);
  color: var(--color-accent);
  box-shadow: var(--shadow-lg);
  transform: translateY(-2px);
}

/* ── Footer ────────────────────────────────────────────── */
.site-footer {
  background: var(--color-footer-bg);
  border-top: 1px solid var(--color-border);
  padding: 32px 0;
  margin-top: auto;
}

.footer-inner {
  max-width: 1440px;
  margin: 0 auto;
  padding: 0 32px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 16px;
  font-size: 0.8125rem;
  color: var(--color-footer-text);
  letter-spacing: -0.01em;
}

.footer-inner a {
  color: var(--color-text-secondary);
  text-decoration: none;
  transition: color var(--transition-fast);
  font-weight: 500;
}

.footer-inner a:hover {
  color: var(--color-text-primary);
}

.footer-links {
  display: flex;
  gap: 24px;
  list-style: none;
}

/* ============================================================ */
/*  RESPONSIVE BREAKPOINTS                                       */
/* ============================================================ */

/* ── ≤1024px (Tablet) ─────────────────────────────────── */
@media (max-width: 1024px) {
  .app-layout {
    flex-direction: column;
  }
  
  .sidebar {
    width: 100%;
    position: static;
    height: auto;
    padding: 20px 24px;
    border-right: none;
    border-bottom: 1px solid var(--color-border);
  }
  
  .toc-list {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
  }
  
  .toc-list li {
    flex-shrink: 0;
  }
  
  .toc-list a {
    padding: 6px 12px;
    font-size: 0.8125rem;
    background: var(--color-surface);
    border-radius: var(--radius-md);
    border-left: none;
  }
  
  .toc-list a.toc-active {
    background: var(--color-accent-subtle);
    color: var(--color-accent);
  }
  
  .sidebar-title {
    display: none;
  }
  
  .main-content {
    padding: 40px 32px 80px;
    max-width: none;
  }
  
  .section-heading h2 {
    font-size: 1.375rem;
  }
  
  .page-title-area h1 {
    font-size: 2rem;
  }
}

/* ── ≤768px (Large Phone) ─────────────────────────────── */
@media (max-width: 768px) {
  :root {
    --header-height: 56px;
  }
  
  .header-inner {
    padding: 0 20px;
  }
  
  .header-brand {
    font-size: 0.9375rem;
  }
  
  .header-brand img {
    width: 28px;
    height: 28px;
  }
  
  .mobile-nav-toggle {
    display: flex;
  }
  
  .header-nav {
    position: fixed;
    top: var(--header-height);
    left: 0;
    right: 0;
    flex-direction: column;
    background: var(--color-header-bg);
    backdrop-filter: saturate(180%) blur(20px);
    -webkit-backdrop-filter: saturate(180%) blur(20px);
    padding: 12px 20px;
    gap: 4px;
    border-bottom: 1px solid var(--color-header-border);
    box-shadow: var(--shadow-lg);
    transform: translateY(-110%);
    opacity: 0;
    pointer-events: none;
    transition: transform var(--transition-base), opacity var(--transition-base);
    z-index: 99;
  }
  
  .header-nav.open {
    transform: translateY(0);
    opacity: 1;
    pointer-events: auto;
  }
  
  .header-nav a {
    display: block;
    padding: 12px 16px;
    font-size: 0.9375rem;
    border-radius: var(--radius-md);
    width: 100%;
  }
  
  .main-content {
    padding: 32px 20px 64px;
  }
  
  .page-title-area h1 {
    font-size: 1.75rem;
  }
  
  .page-subtitle {
    font-size: 1rem;
  }
  
  .section-heading {
    gap: 12px;
    margin-top: 40px;
  }
  
  .section-heading h2 {
    font-size: 1.25rem;
  }
  
  .toc-dropdown-toggle {
    display: block;
  }
  
  .toc-list {
    display: none;
    flex-direction: column;
    gap: 0;
    border: 1px solid var(--color-border);
    border-top: none;
    border-radius: 0 0 var(--radius-md) var(--radius-md);
    margin-top: -1px;
    max-height: 40vh;
    overflow-y: auto;
  }
  
  .toc-list.open {
    display: flex;
  }
  
  .toc-list a {
    border: none;
    border-bottom: 1px solid var(--color-border-subtle);
    border-radius: 0;
    padding: 12px 16px;
    margin: 0;
    font-size: 0.875rem;
  }
  
  .toc-list a:last-child {
    border-bottom: none;
  }
  
  .step-list li {
    padding: 16px 16px 16px 52px;
  }
  
  .step-list li::before {
    left: 12px;
    top: 14px;
    width: 32px;
    height: 32px;
    font-size: 0.8125rem;
  }
  
  .content-card th, .content-card td {
    padding: 10px 12px;
    font-size: 0.8125rem;
  }
  
  .deletion-timeline::before {
    left: 12px;
    right: 12px;
    top: 18px;
  }
  
  .timeline-dot {
    width: 36px;
    height: 36px;
    font-size: 0.75rem;
  }
  
  .data-flow {
    gap: 8px;
    padding: 20px 16px;
  }
  
  .flow-node {
    font-size: 0.8125rem;
    padding: 10px 14px;
  }
  
  .back-to-top {
    bottom: 24px;
    right: 24px;
    width: 40px;
    height: 40px;
  }
}

/* ── ≤480px (Small Phone) ─────────────────────────────── */
@media (max-width: 480px) {
  :root {
    --header-height: 52px;
  }
  
  .header-inner {
    padding: 0 16px;
  }
  
  .header-brand {
    font-size: 0.875rem;
    gap: 8px;
  }
  
  .header-brand img {
    width: 24px;
    height: 24px;
  }
  
  .main-content {
    padding: 24px 16px 56px;
  }
  
  .page-title-area h1 {
    font-size: 1.5rem;
  }
  
  .page-subtitle {
    font-size: 0.9375rem;
  }
  
  .section-heading {
    gap: 8px;
    margin-top: 32px;
  }
  
  .section-heading h2 {
    font-size: 1.125rem;
  }
  
  .content-card p, .content-card li {
    font-size: 0.9375rem;
    line-height: 1.6;
  }
  
  .content-card ul, .content-card ol {
    padding-left: 20px;
  }
  
  .step-list li {
    padding: 14px 14px 14px 48px;
    margin-bottom: 10px;
  }
  
  .step-list li::before {
    left: 10px;
    top: 12px;
    width: 28px;
    height: 28px;
    font-size: 0.75rem;
  }
  
  .content-card th, .content-card td {
    padding: 8px 10px;
    font-size: 0.75rem;
  }
  
  .content-card th {
    font-size: 0.6875rem;
  }
  
  .accordion-trigger {
    font-size: 0.875rem;
    padding: 14px 40px 14px 16px;
  }
  
  .deletion-timeline {
    flex-direction: column;
    gap: 0;
  }
  
  .deletion-timeline::before {
    display: none;
  }
  
  .timeline-step {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px 0;
    text-align: left;
    border-bottom: 1px solid var(--color-border-subtle);
  }
  
  .timeline-step:last-child {
    border-bottom: none;
  }
  
  .timeline-dot {
    width: 32px;
    height: 32px;
    font-size: 0.75rem;
    margin: 0;
    flex-shrink: 0;
  }
  
  .timeline-label {
    font-size: 0.8125rem;
    flex: 1;
  }
  
  .timeline-sublabel {
    display: none;
  }
  
  .footer-inner {
    font-size: 0.75rem;
    gap: 8px;
    flex-direction: column;
    text-align: center;
  }
  
  .footer-links {
    gap: 16px;
    flex-wrap: wrap;
    justify-content: center;
  }
}

/* ── ≤380px (Tiny Phone) ─────────────────────────────── */
@media (max-width: 380px) {
  .main-content {
    padding: 20px 12px 48px;
  }
  
  .page-title-area h1 {
    font-size: 1.375rem;
  }
  
  .section-heading h2 {
    font-size: 1rem;
  }
  
  .content-card p, .content-card li {
    font-size: 0.875rem;
  }
  
  .step-list li {
    padding: 12px 12px 12px 44px;
  }
  
  .step-list li::before {
    left: 8px;
    top: 10px;
    width: 24px;
    height: 24px;
    font-size: 0.6875rem;
  }
  
  .content-card th, .content-card td {
    padding: 6px 8px;
    font-size: 0.6875rem;
  }
}

/* ── Print ─────────────────────────────────────────────── */
@media print {
  .site-header, .sidebar, .site-footer, .back-to-top,
  .mobile-nav-toggle, .toc-dropdown-toggle {
    display: none !important;
  }
  
  .app-layout {
    display: block;
  }
  
  .main-content {
    max-width: none;
    padding: 0;
  }
  
  body {
    font-size: 11pt;
    line-height: 1.6;
    color: #000;
    background: #fff;
  }
  
  .content-card a {
    color: #000;
    border-bottom: 1px solid #000;
  }
  
  .content-card table {
    box-shadow: none;
    display: table;
    overflow-x: visible;
  }
  
  .content-card th, .content-card td {
    border: 1px solid #ccc;
  }
  
  .reveal {
    opacity: 1 !important;
    transform: none !important;
  }
  
  .section-heading {
    break-after: avoid;
  }
  
  .content-card table, .info-box, .warning-box, .success-box {
    break-inside: avoid;
  }
}
