:root {
  --legal-header-height: 64px;
}

html[data-theme="light"] {
  color-scheme: light;
  --bg: #f5f7fb;
  --surface: #ffffff;
  --surface-soft: #f8fafc;
  --soft: #f8fafc;
  --text: #172033;
  --muted: #5d687a;
  --border: #dfe5ee;
  --brand: #2856d8;
  --brand-soft: #edf2ff;
  --shadow: 0 16px 42px rgba(24, 39, 75, 0.08);
}

html[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0f172a;
  --surface: #151f34;
  --surface-soft: #1a263d;
  --soft: #1a263d;
  --text: #eef3fb;
  --muted: #b1bdd0;
  --border: #2d3a52;
  --brand: #91adff;
  --brand-soft: #1d2d59;
  --shadow: none;
}

body {
  min-width: 0;
}

.app-webview .legal-site-header {
  display: none;
}

.app-webview .page {
  margin-top: 0;
}

.legal-site-header {
  position: relative;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}

.legal-site-header-inner {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 44px;
  align-items: center;
  width: min(920px, calc(100% - 28px));
  min-height: 0;
  margin: 0 auto;
  padding: 8px 0 10px;
  gap: 0 16px;
}

.legal-brand {
  display: inline-flex;
  flex: 0 0 auto;
  align-items: center;
  min-height: 44px;
  gap: 9px;
  color: var(--text);
  font-weight: 750;
  text-decoration: none;
}

.legal-brand img {
  width: 30px;
  height: 30px;
  border-radius: 7px;
}

.legal-nav {
  display: flex;
  grid-column: 1 / -1;
  align-items: center;
  justify-content: flex-start;
  flex-wrap: nowrap;
  width: 100%;
  min-width: 0;
  margin-top: 2px;
  gap: 6px;
}

.legal-nav a {
  display: inline-flex;
  align-items: center;
  min-height: 40px;
  padding: 0 10px;
  border-radius: 6px;
  color: var(--muted);
  font-size: 14px;
  font-weight: 650;
  text-decoration: none;
  white-space: nowrap;
}

.legal-nav a:hover,
.legal-nav a:focus-visible,
.legal-nav a[aria-current="page"] {
  background: var(--brand-soft);
  color: var(--brand);
}

.legal-nav a:focus-visible,
.legal-brand:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 2px;
}

.legal-theme-toggle {
  display: inline-grid;
  flex: 0 0 44px;
  place-items: center;
  width: 44px;
  height: 44px;
  grid-column: 2;
  grid-row: 1;
  margin-left: 0;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 50%;
  background: var(--surface-soft, var(--soft));
  color: var(--text);
  cursor: pointer;
  touch-action: manipulation;
}

.legal-theme-toggle:hover {
  border-color: var(--brand);
  color: var(--brand);
}

.legal-theme-toggle:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 2px;
}

.legal-theme-glyph {
  width: 17px;
  height: 17px;
  border: 2px solid currentColor;
  border-radius: 50%;
  background: linear-gradient(90deg, currentColor 50%, transparent 50%);
}

.page {
  width: min(780px, calc(100% - 28px));
  margin: 20px auto 48px;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
}

.hero,
.toc,
.content {
  margin: 0;
  border: 0;
  border-radius: 0;
  box-shadow: none;
}

.hero {
  padding: 30px 32px 26px;
  border-bottom: 1px solid var(--border);
}

h1 {
  font-size: clamp(28px, 5vw, 38px);
  letter-spacing: 0;
}

.summary {
  max-width: 68ch;
}

.operator {
  gap: 0;
  border: 1px solid var(--border);
  border-radius: 6px;
  overflow: hidden;
}

.operator div {
  border: 0;
  border-radius: 0;
}

.operator div + div {
  border-left: 1px solid var(--border);
}

.toc {
  padding: 22px 32px;
  border-bottom: 1px solid var(--border);
}

.content {
  padding: 8px 32px 34px;
}

section {
  scroll-margin-top: 16px;
}

footer {
  padding: 24px 32px 30px;
  border-top: 1px solid var(--border);
  text-align: left;
}

@media (max-width: 680px) {
  :root {
    --legal-header-height: 0px;
  }

  body {
    background: var(--surface);
    font-size: 16px;
    line-height: 1.72;
  }

  .legal-site-header-inner {
    width: 100%;
    min-height: 0;
    padding: max(6px, env(safe-area-inset-top)) 16px 4px;
  }

  .legal-brand {
    min-height: 44px;
  }

  .legal-nav {
    margin-top: 2px;
    gap: 2px;
  }

  .legal-theme-toggle {
    grid-column: 2;
    grid-row: 1;
    margin-left: 0;
  }

  .legal-nav a {
    min-height: 40px;
    padding: 0 6px;
    font-size: 13px;
  }

  .page {
    width: 100%;
    margin: 0;
    border: 0;
    border-radius: 0;
  }

  .hero {
    padding: 24px 20px 22px;
  }

  h1 {
    font-size: 30px;
    line-height: 1.22;
  }

  .summary {
    margin-top: 16px;
    font-size: 16px;
  }

  .operator {
    grid-template-columns: 1fr;
  }

  .operator div + div {
    border-top: 1px solid var(--border);
    border-left: 0;
  }

  .toc {
    padding: 20px;
  }

  .toc ol {
    columns: 1;
  }

  .toc a {
    display: inline-flex;
    align-items: center;
    min-height: 36px;
  }

  .content {
    padding: 4px 20px 28px;
  }

  section {
    padding-top: 24px;
  }

  h2 {
    font-size: 21px;
  }

  h3 {
    margin-top: 22px;
    font-size: 17px;
  }

  .notice,
  .contact {
    border-radius: 6px;
  }

  footer {
    padding: 22px 20px calc(28px + env(safe-area-inset-bottom));
  }
}

@media print {
  .legal-site-header {
    display: none;
  }

  .page {
    border: 0;
  }
}
