/* ==========================================================================
   Unpack Chat — legal & support site
   Tokens mirror UnpackChat/Theme.swift so the web surface and the app agree.
   ========================================================================== */

:root {
  color-scheme: light dark;

  /* Brand — Color.indigo500 / indigo600 (fill stays constant in both modes) */
  --accent-fill: #6366F1;
  --accent-fill-hover: #4F46E5;
  --on-accent: #FFFFFF;

  /* Brand — text / tint roles */
  --accent: #4F46E5;
  --accent-hover: #4338CA;
  --accent-soft: #EEF2FF;
  --accent-ring: rgba(99, 102, 241, 0.35);

  /* Surfaces — bgGray50 / bgWhite / borderGray200 */
  --bg: #F9FAFB;
  --bg-tint: #FFFFFF;
  --surface: #FFFFFF;
  --surface-muted: #F3F4F6;
  --border: #E5E7EB;
  --border-strong: #D1D5DB;

  /* Text — textPrimary / textSecondary / textTertiary */
  --text: #111827;
  --text-secondary: #6B7280;
  --text-tertiary: #9CA3AF;

  /* Semantic */
  --success: #10B981;
  --warning: #F59E0B;

  --shadow-sm: 0 1px 2px rgba(17, 24, 39, 0.06);
  --shadow-md: 0 10px 30px -12px rgba(17, 24, 39, 0.18),
               0 2px 6px -2px rgba(17, 24, 39, 0.05);
  --shadow-brand: 0 18px 40px -18px rgba(79, 70, 229, 0.45);

  --radius-sm: 10px;
  --radius-md: 16px;
  --radius-lg: 24px;
  --radius-pill: 999px;

  --wrap: 1080px;
  --measure: 68ch;

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

@media (prefers-color-scheme: dark) {
  :root {
    --accent: #A5B4FC;
    --accent-hover: #C7D2FE;
    --accent-soft: #1E1B4B;
    --accent-ring: rgba(165, 180, 252, 0.4);

    --bg: #111827;
    --bg-tint: #0D1421;
    --surface: #1F2937;
    --surface-muted: #18202F;
    --border: #374151;
    --border-strong: #4B5563;

    --text: #F3F4F6;
    --text-secondary: #9CA3AF;
    --text-tertiary: #8A92A0;

    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
    --shadow-md: 0 12px 32px -14px rgba(0, 0, 0, 0.7),
                 0 2px 6px -2px rgba(0, 0, 0, 0.4);
    --shadow-brand: 0 18px 40px -18px rgba(0, 0, 0, 0.8);
  }
}

/* ---------- Reset ---------- */

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

html {
  scroll-behavior: smooth;
  scroll-padding-top: 96px;
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

img,
svg {
  display: block;
  max-width: 100%;
}

a {
  color: var(--accent);
  text-decoration: none;
  text-underline-offset: 3px;
}

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

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

::selection {
  background: var(--accent-soft);
  color: var(--accent);
}

/* ---------- Layout ---------- */

.container {
  width: 100%;
  max-width: var(--wrap);
  margin-inline: auto;
  padding-inline: 24px;
}

.narrow {
  max-width: 760px;
  margin-inline: auto;
}

/* ---------- Header ---------- */

.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: saturate(180%) blur(16px);
  -webkit-backdrop-filter: saturate(180%) blur(16px);
  border-bottom: 1px solid var(--border);
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  min-height: 68px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--text);
  font-weight: 650;
  font-size: 16px;
  letter-spacing: -0.01em;
  text-decoration: none;
}

.brand:hover {
  color: var(--text);
  text-decoration: none;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: 9px;
  background: linear-gradient(140deg, var(--accent-fill), var(--accent-fill-hover));
  color: var(--on-accent);
  box-shadow: 0 4px 12px -4px rgba(99, 102, 241, 0.7);
}

.nav {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 4px;
  border-radius: var(--radius-pill);
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
}

.nav a {
  padding: 7px 14px;
  border-radius: var(--radius-pill);
  color: var(--text-secondary);
  font-size: 14px;
  font-weight: 500;
  white-space: nowrap;
  transition: color 0.15s ease, background 0.15s ease;
}

.nav a:hover {
  color: var(--text);
  background: var(--surface-muted);
  text-decoration: none;
}

.nav a[aria-current="page"] {
  color: var(--accent);
  background: var(--accent-soft);
}

/* ---------- Hero (support home) ---------- */

.hero {
  position: relative;
  padding: 88px 0 40px;
  overflow: hidden;
}

.hero::before {
  content: "";
  position: absolute;
  inset: -180px 0 auto 50%;
  width: min(900px, 120vw);
  height: 620px;
  transform: translateX(-50%);
  background:
    radial-gradient(closest-side, rgba(99, 102, 241, 0.18), transparent 72%),
    radial-gradient(closest-side at 70% 60%, rgba(79, 70, 229, 0.14), transparent 70%);
  filter: blur(8px);
  pointer-events: none;
}

.hero > * {
  position: relative;
}

.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 7px 14px 7px 12px;
  border-radius: var(--radius-pill);
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 500;
}

.eyebrow .dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--success);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--success) 18%, transparent);
}

h1 {
  margin: 24px 0 0;
  font-size: clamp(2.15rem, 5vw, 3.25rem);
  line-height: 1.1;
  letter-spacing: -0.035em;
  font-weight: 700;
  max-width: 20ch;
}

.grad {
  background: linear-gradient(115deg, var(--accent-fill) 10%, #8B5CF6 90%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.lead {
  margin: 22px 0 0;
  max-width: 58ch;
  font-size: clamp(1.02rem, 1.6vw, 1.15rem);
  line-height: 1.72;
  color: var(--text-secondary);
}

.hero-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
  margin-top: 32px;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 22px;
  border-radius: var(--radius-pill);
  border: 1px solid transparent;
  font-size: 15px;
  font-weight: 600;
  letter-spacing: -0.005em;
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.2s ease, background 0.2s ease,
    color 0.2s ease, border-color 0.2s ease;
}

.btn:hover {
  text-decoration: none;
  transform: translateY(-1px);
}

.btn-primary {
  background: linear-gradient(140deg, var(--accent-fill), var(--accent-fill-hover));
  color: var(--on-accent);
  box-shadow: var(--shadow-brand);
}

.btn-primary:hover {
  color: var(--on-accent);
  box-shadow: 0 22px 48px -18px rgba(79, 70, 229, 0.6);
}

.btn-ghost {
  background: var(--surface);
  border-color: var(--border);
  color: var(--text);
  box-shadow: var(--shadow-sm);
}

.btn-ghost:hover {
  color: var(--text);
  border-color: var(--border-strong);
}

.hero-note {
  margin: 18px 0 0;
  font-size: 13.5px;
  color: var(--text-tertiary);
}

/* ---------- Feature cards ---------- */

.section {
  padding-block: 56px;
}

.section-head {
  max-width: 46ch;
  margin-bottom: 28px;
}

.section-head h2 {
  margin: 0;
  font-size: clamp(1.4rem, 2.4vw, 1.75rem);
  letter-spacing: -0.02em;
  line-height: 1.25;
}

.section-head p {
  margin: 10px 0 0;
  color: var(--text-secondary);
  font-size: 15.5px;
}

.features {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 16px;
}

.feature {
  padding: 24px;
  border-radius: var(--radius-md);
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
}

.feature:hover {
  transform: translateY(-2px);
  border-color: color-mix(in srgb, var(--accent) 30%, var(--border));
  box-shadow: var(--shadow-md);
}

.feature-icon {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  margin-bottom: 16px;
  border-radius: 12px;
  background: var(--accent-soft);
  color: var(--accent);
}

.feature h3 {
  margin: 0 0 6px;
  font-size: 16px;
  letter-spacing: -0.01em;
}

.feature p {
  margin: 0;
  font-size: 14.5px;
  line-height: 1.65;
  color: var(--text-secondary);
}

/* ---------- FAQ ---------- */

.faq {
  display: grid;
  gap: 10px;
  max-width: var(--measure);
}

details.faq-item {
  border-radius: var(--radius-md);
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

details.faq-item[open] {
  border-color: color-mix(in srgb, var(--accent) 32%, var(--border));
  box-shadow: var(--shadow-md);
}

details.faq-item summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 18px 20px;
  cursor: pointer;
  list-style: none;
  font-size: 15.5px;
  font-weight: 600;
  letter-spacing: -0.005em;
  border-radius: var(--radius-md);
}

details.faq-item summary::-webkit-details-marker {
  display: none;
}

details.faq-item summary:hover {
  color: var(--accent);
}

.faq-chevron {
  flex: none;
  color: var(--text-tertiary);
  transition: transform 0.2s ease, color 0.2s ease;
}

details[open] .faq-chevron {
  transform: rotate(180deg);
  color: var(--accent);
}

.faq-body {
  padding: 0 20px 20px;
  margin: 0;
  color: var(--text-secondary);
  font-size: 14.8px;
  line-height: 1.7;
}

/* ---------- Support card ---------- */

.card {
  padding: 28px;
  border-radius: var(--radius-lg);
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-md);
}

.contact-card {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 22px;
  background:
    linear-gradient(140deg, var(--accent-soft), transparent 62%),
    var(--surface);
  border-color: color-mix(in srgb, var(--accent) 24%, var(--border));
}

.contact-card h2 {
  margin: 0 0 6px;
  font-size: 19px;
  letter-spacing: -0.01em;
}

.contact-card p {
  margin: 0;
  font-size: 14.8px;
  color: var(--text-secondary);
  max-width: 44ch;
}

.mail-link {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  font-size: 15px;
  font-weight: 600;
  word-break: break-all;
}

/* ---------- Legal pages ---------- */

.page-head {
  padding-block: 64px 36px;
  border-bottom: 1px solid var(--border);
}

.page-head h1 {
  max-width: none;
  font-size: clamp(2rem, 4vw, 2.75rem);
}

.page-head .meta {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin: 18px 0 0;
  padding: 6px 14px;
  border-radius: var(--radius-pill);
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text-tertiary);
  font-size: 13px;
  font-variant-numeric: tabular-nums;
}

.layout {
  display: grid;
  grid-template-columns: 232px minmax(0, 1fr);
  gap: 56px;
  padding-block: 48px 80px;
}

.toc {
  position: sticky;
  top: 100px;
  align-self: start;
  max-height: calc(100vh - 140px);
  overflow-y: auto;
  padding-right: 8px;
}

.toc-title {
  margin: 0 0 12px;
  font-size: 11.5px;
  font-weight: 700;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--text-tertiary);
}

.toc ol {
  margin: 0;
  padding: 0 0 0 12px;
  list-style: none;
  border-left: 1px solid var(--border);
}

.toc li {
  margin: 0;
}

.toc a {
  display: block;
  padding: 5px 0 5px 12px;
  margin-left: -13px;
  border-left: 2px solid transparent;
  color: var(--text-secondary);
  font-size: 13.5px;
  line-height: 1.45;
  transition: color 0.15s ease, border-color 0.15s ease;
}

.toc a:hover {
  color: var(--accent);
  border-left-color: var(--accent);
  text-decoration: none;
}

article {
  max-width: var(--measure);
}

article > h2 {
  margin: 44px 0 12px;
  font-size: 19px;
  line-height: 1.35;
  letter-spacing: -0.015em;
  scroll-margin-top: 96px;
}

article > h2:first-of-type {
  margin-top: 0;
}

article p {
  margin: 0 0 16px;
  color: var(--text-secondary);
  font-size: 15.5px;
  line-height: 1.75;
}

article ul {
  margin: 0 0 16px;
  padding-left: 20px;
  color: var(--text-secondary);
  font-size: 15.5px;
}

article li {
  margin-bottom: 8px;
}

article li::marker {
  color: var(--text-tertiary);
}

.anchor {
  margin-left: 8px;
  color: var(--text-tertiary);
  font-weight: 400;
  opacity: 0;
  transition: opacity 0.15s ease, color 0.15s ease;
}

h2:hover .anchor,
.anchor:focus-visible {
  opacity: 1;
}

.anchor:hover {
  color: var(--accent);
  text-decoration: none;
}

/* ---------- Footer ---------- */

.site-footer {
  margin-top: 24px;
  border-top: 1px solid var(--border);
  padding: 40px 0 56px;
}

.footer-inner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
}

.footer-links {
  display: flex;
  flex-wrap: wrap;
  gap: 20px;
  font-size: 14px;
}

.footer-links a {
  color: var(--text-secondary);
}

.footer-links a:hover {
  color: var(--accent);
}

.copyright {
  margin: 0;
  color: var(--text-tertiary);
  font-size: 13px;
}

/* ---------- Motion / print ---------- */

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}

@media (max-width: 860px) {
  .layout {
    grid-template-columns: 1fr;
    gap: 32px;
    padding-block: 32px 64px;
  }

  .toc {
    position: static;
    max-height: none;
    padding: 18px 20px;
    border-radius: var(--radius-md);
    background: var(--surface-muted);
    border: 1px solid var(--border);
  }

  .toc ol {
    columns: 2;
    column-gap: 20px;
  }

  .hero {
    padding-top: 56px;
  }
}

@media (max-width: 620px) {
  .header-inner {
    min-height: 60px;
    flex-wrap: wrap;
    gap: 12px;
    padding-block: 12px;
  }

  .nav {
    width: 100%;
    justify-content: space-between;
  }

  .nav a {
    flex: 1;
    text-align: center;
    padding-inline: 8px;
    font-size: 13px;
  }

  .toc ol {
    columns: 1;
  }

  .contact-card,
  .card {
    padding: 22px;
  }

  .section {
    padding-block: 40px;
  }
}

@media print {
  .site-header,
  .toc,
  .site-footer,
  .hero::before {
    display: none;
  }

  .layout {
    display: block;
    padding: 0;
  }

  body {
    background: #FFFFFF;
    color: #000000;
    font-size: 11pt;
  }

  article p,
  article li {
    color: #000000;
  }
}