/* Shared site styles: tokens, top bar, language toggle, footer and legal documents.
   The homepage adds home.css on top of this file. */

:root {
  color-scheme: light dark;
  --bg: #ffffff;
  --surface: #f5f5f7;
  --fg: #1d1d1f;
  --muted: #6e6e73;
  --hairline: rgba(0, 0, 0, 0.1);
  --accent: #0f766e;
  --button-bg: #0f766e;
  --button-fg: #ffffff;
  --focus: #0d9488;
  --glow: rgba(20, 184, 166, 0.16);
  --topbar-bg: rgba(255, 255, 255, 0.78);
  --toggle-bg: rgba(0, 0, 0, 0.05);
  --toggle-hover-bg: rgba(0, 0, 0, 0.06);
  --toggle-active-bg: #1d1d1f;
  --toggle-active-fg: #ffffff;

  --font: -apple-system, BlinkMacSystemFont, "SF Pro Display", "SF Pro Text", "Helvetica Neue", Inter, "Segoe UI", Roboto, Arial, sans-serif;
  --gutter: clamp(1.25rem, 5vw, 2.5rem);
  --content: 1080px;
  --measure: 68ch;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #000000;
    --surface: #161617;
    --fg: #f5f5f7;
    --muted: #a1a1a6;
    --hairline: rgba(255, 255, 255, 0.14);
    --accent: #2dd4bf;
    --button-bg: #2dd4bf;
    --button-fg: #042f2e;
    --focus: #5eead4;
    --glow: rgba(45, 212, 191, 0.14);
    --topbar-bg: rgba(0, 0, 0, 0.72);
    --toggle-bg: rgba(255, 255, 255, 0.08);
    --toggle-hover-bg: rgba(255, 255, 255, 0.1);
    --toggle-active-bg: #f5f5f7;
    --toggle-active-fg: #000000;
  }
}

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

[hidden] { display: none !important; }

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  margin: 0;
  overflow-x: hidden;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--font);
  font-size: 1.0625rem;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

:lang(ja) { font-family: -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Hiragino Kaku Gothic ProN", "Noto Sans JP", "Yu Gothic", Meiryo, sans-serif; }
:lang(zh) { font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Noto Sans SC", "Microsoft YaHei", sans-serif; }

img { max-width: 100%; }

a { color: var(--accent); }

:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 3px;
  border-radius: 6px;
}

/* Top bar */
.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  background: var(--topbar-bg);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  backdrop-filter: saturate(180%) blur(20px);
  border-bottom: 0.5px solid var(--hairline);
}

.topbar-inner {
  max-width: var(--content);
  margin: 0 auto;
  padding: 0.625rem var(--gutter);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  color: var(--fg);
  text-decoration: none;
  font-weight: 600;
  font-size: 1.0625rem;
  letter-spacing: -0.01em;
  flex: none;
}

.brand img {
  width: 28px;
  height: 28px;
  border-radius: 22.5%;
}

.lang-toggle {
  display: flex;
  gap: 2px;
  padding: 2px;
  border-radius: 999px;
  background: var(--toggle-bg);
  min-width: 0;
}

.lang-toggle button {
  appearance: none;
  border: 0;
  margin: 0;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 0.8125rem;
  font-weight: 500;
  line-height: 1;
  padding: 0.5rem 0.55rem;
  min-height: 32px;
  border-radius: 999px;
  cursor: pointer;
  white-space: nowrap;
}

.lang-toggle button[aria-pressed="false"]:hover {
  color: var(--fg);
  background: var(--toggle-hover-bg);
}

/* Selected language: solid inverted pill, identical on every page and width. */
.lang-toggle button[aria-pressed="true"] {
  background: var(--toggle-active-bg);
  color: var(--toggle-active-fg);
  font-weight: 600;
  cursor: default;
}

.lang-long {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  white-space: nowrap;
}

@media (max-width: 420px) {
  .brand span { display: none; }
}

@media (min-width: 900px) {
  .lang-long {
    position: static;
    width: auto;
    height: auto;
    overflow: visible;
    clip: auto;
    clip-path: none;
  }
  .lang-short { display: none; }
  .lang-toggle button { padding: 0.5rem 0.8rem; }
}

/* Footer */
.site-footer {
  background: var(--surface);
  color: var(--muted);
  font-size: 0.8125rem;
  line-height: 1.5;
  border-top: 0.5px solid var(--hairline);
}

.footer-inner {
  max-width: var(--content);
  margin: 0 auto;
  padding: 1.75rem var(--gutter) 2.25rem;
  display: grid;
  gap: 0.5rem;
}

.footer-inner p { margin: 0; }

.footer-links {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem 1.25rem;
  margin-bottom: 0.25rem;
}

.site-footer a { color: var(--fg); text-decoration: none; }
.site-footer a:hover { text-decoration: underline; }

/* Legal documents (privacy, terms, support) */
.brand--back { gap: 0.375rem; }

.brand-back {
  width: 20px;
  height: 20px;
  margin-left: -0.375rem;
  fill: none;
  stroke: var(--accent);
  stroke-width: 2.2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.doc {
  font-size: 1.0625rem;
  line-height: 1.7;
  overflow-wrap: break-word;
}

.doc-hero {
  background:
    radial-gradient(60% 120% at 85% 0%, var(--glow), transparent 70%),
    var(--surface);
  border-bottom: 0.5px solid var(--hairline);
}

.doc-hero-inner {
  max-width: var(--content);
  margin: 0 auto;
  padding: clamp(2.5rem, 7vw, 4.5rem) var(--gutter) clamp(2rem, 5vw, 3rem);
}

.doc-title {
  margin: 0;
  font-size: clamp(2rem, 5.5vw, 3rem);
  line-height: 1.1;
  font-weight: 700;
  letter-spacing: -0.028em;
  text-wrap: balance;
}

.doc-title-main { display: inline; }

.doc-title-app {
  color: var(--muted);
  font-weight: 500;
}

.doc .updated {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  margin: 1.25rem 0 0;
  padding: 0.375rem 0.875rem;
  border-radius: 999px;
  background: var(--bg);
  border: 0.5px solid var(--hairline);
  color: var(--muted);
  font-size: 0.875rem;
  line-height: 1.4;
}

.doc .updated::before {
  content: "";
  width: 0.5rem;
  height: 0.5rem;
  border-radius: 50%;
  background: var(--accent);
  flex: none;
}

.doc-layout {
  max-width: var(--content);
  margin: 0 auto;
  padding: clamp(1.75rem, 5vw, 3rem) var(--gutter) clamp(4rem, 10vw, 6.5rem);
}

.doc-body { max-width: var(--measure); }

.doc-body > :first-child { margin-top: 0; }

.doc h2 {
  margin: 2.5rem 0 0.875rem;
  padding-top: 1.75rem;
  border-top: 0.5px solid var(--hairline);
  font-size: clamp(1.25rem, 2.6vw, 1.5rem);
  line-height: 1.3;
  font-weight: 650;
  letter-spacing: -0.015em;
  scroll-margin-top: 4.5rem;
}

.doc-layout--single .doc-body h2 { margin-top: 2.5rem; }

.doc p { margin: 0 0 1rem; }

.doc-body ul {
  list-style: none;
  margin: 0 0 1.25rem;
  padding: 0;
  display: grid;
  gap: 0.625rem;
}

.doc-body li {
  position: relative;
  padding-left: 1.5rem;
}

.doc-body li::before {
  content: "";
  position: absolute;
  left: 0.3rem;
  top: 0.72em;
  width: 0.375rem;
  height: 0.375rem;
  border-radius: 50%;
  background: var(--accent);
}

.doc strong { font-weight: 600; }

.doc a { text-underline-offset: 0.15em; }

.doc .crosslink {
  margin: 3.5rem 0 0;
  padding-top: 1.75rem;
  border-top: 0.5px solid var(--hairline);
  font-size: 0.9375rem;
  font-weight: 600;
}

.doc .crosslink a { text-decoration: none; }
.doc .crosslink a:hover { text-decoration: underline; }

/* Table of contents: collapsible card on small screens, sticky sidebar from 1100px. */
.toc {
  margin: 0 0 2.5rem;
  border-radius: 1rem;
  background: var(--surface);
  border: 0.5px solid var(--hairline);
  font-size: 0.9375rem;
  line-height: 1.4;
}

.toc summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.875rem 1.125rem;
  font-weight: 600;
  cursor: pointer;
  list-style: none;
  border-radius: 1rem;
}

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

.toc summary::after {
  content: "";
  width: 0.5rem;
  height: 0.5rem;
  border-right: 2px solid var(--muted);
  border-bottom: 2px solid var(--muted);
  transform: translateY(-25%) rotate(45deg);
  transition: transform 0.2s ease;
  flex: none;
}

.toc[open] summary::after { transform: translateY(25%) rotate(-135deg); }

.toc ol {
  list-style: none;
  margin: 0;
  padding: 0 0.5rem 0.75rem;
  display: grid;
  gap: 2px;
}

.toc a {
  display: block;
  padding: 0.5rem 0.625rem;
  border-radius: 0.625rem;
  color: var(--muted);
  text-decoration: none;
}

.toc a:hover { color: var(--fg); background: var(--toggle-hover-bg); }

.toc a[aria-current="true"] {
  color: var(--fg);
  font-weight: 600;
  background: var(--toggle-hover-bg);
}

@media (min-width: 1100px) {
  .doc-layout:not(.doc-layout--single) {
    display: grid;
    grid-template-columns: 15.5rem minmax(0, 1fr);
    gap: 4.5rem;
    align-items: start;
  }
  .toc {
    position: sticky;
    top: 5rem;
    max-height: calc(100vh - 6rem);
    overflow-y: auto;
    margin: 0;
    background: none;
    border: 0;
    border-radius: 0;
  }
  .toc summary {
    padding: 0 0.625rem 0.75rem;
    color: var(--muted);
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    pointer-events: none;
    cursor: default;
  }
  .toc summary::after { display: none; }
  .toc ol {
    padding: 0;
    border-left: 0.5px solid var(--hairline);
  }
  .toc a {
    border-radius: 0 0.5rem 0.5rem 0;
    margin-left: -0.5px;
    border-left: 2px solid transparent;
    padding: 0.4rem 0.75rem;
  }
  .toc a[aria-current="true"] {
    background: none;
    border-left-color: var(--accent);
  }
  .doc-body > :first-child { margin-top: 0; }
}

:lang(ja) .doc,
:lang(zh) .doc { line-height: 1.85; }

:lang(ja) .doc-title,
:lang(zh) .doc-title,
:lang(ja) .doc h2,
:lang(zh) .doc h2,
:lang(ja) .toc summary,
:lang(zh) .toc summary { letter-spacing: 0; }
