/* Himel Agent — colors from App/Theme.swift. Ink for text, bluish greys for
   everything quiet, and Himel blue only for the sand, links and focus. */
:root {
  color-scheme: light dark;
  --base: #ffffff;
  --text: #0f1115;
  --secondary: #575c63;
  --tertiary: #6b7078;
  --border: rgba(0, 0, 0, 0.1);
  --accent: #4268fd;
  --link: #3456de;
  --inline-code: #eff1f4;
  --todo-bg: #fdf1dc;
  --todo-fg: #8a4206;
  --shadow: rgba(15, 17, 21, 0.12);
  --hairline: 1px;
  --gutter: 20px;
  --header: 64px;
  --font: system-ui, -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Hiragino Kaku Gothic ProN", "Noto Sans JP", "Yu Gothic UI", "Yu Gothic", Meiryo, sans-serif;
  --mono: ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas, monospace;
}

@media (prefers-color-scheme: dark) {
  :root {
    --base: #151517;
    --text: #f9fafb;
    --secondary: #cfd3d6;
    --tertiary: #adb2b8;
    --border: rgba(255, 255, 255, 0.12);
    --accent: #5b7cff;
    --link: #a2b5ff;
    --inline-code: #2e2f33;
    --todo-bg: #3a2a10;
    --todo-fg: #fbbf24;
    --shadow: rgba(0, 0, 0, 0.5);
  }
}

/* The app's 0.5 pt hairlines on high-density screens. */
@media (min-resolution: 2dppx) {
  :root { --hairline: 0.5px; }
}

@media (min-width: 900px) {
  :root { --gutter: 40px; }
}

/* Each language gets its own system fonts and rhythm. */
:root:lang(zh-Hans) { --font: system-ui, -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans SC", sans-serif; }
:root:lang(zh-Hant) { --font: system-ui, -apple-system, BlinkMacSystemFont, "PingFang TC", "Microsoft JhengHei", "Noto Sans TC", sans-serif; }
:root:lang(ko) { --font: system-ui, -apple-system, BlinkMacSystemFont, "Apple SD Gothic Neo", "Malgun Gothic", "Noto Sans KR", sans-serif; }
:root:lang(en), :root:lang(es) { --font: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif; }

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

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

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--base);
  color: var(--text);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.85;
  line-break: strict;
  overflow-wrap: break-word;
  -webkit-font-smoothing: antialiased;
}

main { flex: 1; }

/* The shape sand.js forms Himel from; `hidden` alone does not hide SVG. */
svg[hidden] { display: none; }

h1, h2, h3, h4 {
  margin: 0;
  font-weight: 700;
  font-feature-settings: "palt";
  letter-spacing: 0.02em;
  word-break: auto-phrase;
}

p, li, dd { text-wrap: pretty; }

body:lang(en), body:lang(es) { line-height: 1.6; }
:lang(en) :is(h1, h2), :lang(es) :is(h1, h2) { letter-spacing: -0.015em; }
:lang(ko) { word-break: keep-all; }

a { color: var(--link); text-underline-offset: 0.22em; text-decoration-thickness: 1px; }
a:hover { text-decoration-thickness: 2px; }
a[href^="mailto:"] { overflow-wrap: anywhere; }

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

::selection { background: color-mix(in srgb, var(--accent) 24%, transparent); }

code {
  font-family: var(--mono);
  font-size: 0.875em;
  padding: 0.1em 0.4em;
  border-radius: 6px;
  background: var(--inline-code);
}

.wrap {
  width: 100%;
  max-width: 1200px;
  margin: 0 auto;
  padding-left: max(var(--gutter), env(safe-area-inset-left));
  padding-right: max(var(--gutter), env(safe-area-inset-right));
}

.skip {
  position: absolute;
  left: 12px;
  top: -60px;
  z-index: 10;
  padding: 8px 14px;
  background: var(--text);
  color: var(--base);
}
.skip:focus { top: 12px; }

/* Header */
.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: var(--header);
  position: relative;
  z-index: 2;
}
.brand { display: block; color: var(--text); }
.wordmark { display: block; height: 40px; width: auto; fill: currentColor; }
.site-header nav { display: flex; align-items: center; gap: 22px; font-size: 14px; }
.site-header nav > a {
  color: var(--text);
  text-decoration: none;
}
.site-header nav > a:hover,
.site-header nav > a[aria-current="page"] { text-decoration: underline; }
@media (max-width: 380px) {
  .wordmark { height: 34px; }
  .site-header nav { gap: 16px; }
}

/* The language menu: a plain list under the current language's name. */
.languages { position: relative; }
.languages summary {
  display: flex;
  align-items: center;
  gap: 7px;
  color: var(--text);
  cursor: pointer;
  list-style: none;
  user-select: none;
}
.languages summary::-webkit-details-marker { display: none; }
.languages summary::after {
  content: "";
  width: 5px;
  height: 5px;
  margin-top: -3px;
  border-right: 1.5px solid currentColor;
  border-bottom: 1.5px solid currentColor;
  transform: rotate(45deg);
}
.languages[open] summary::after { margin-top: 3px; transform: rotate(-135deg); }
.languages ul {
  position: absolute;
  top: calc(100% + 12px);
  right: -12px;
  z-index: 5;
  min-width: 168px;
  margin: 0;
  padding: 6px;
  list-style: none;
  background: var(--base);
  border: var(--hairline) solid var(--border);
  border-radius: 14px;
  box-shadow: 0 12px 32px var(--shadow);
}
.languages li a {
  display: block;
  padding: 7px 12px;
  border-radius: 9px;
  color: var(--text);
  font-size: 15px;
  line-height: 1.5;
  text-decoration: none;
}
.languages li a:hover { background: var(--inline-code); }
.languages li a[aria-current] { color: var(--tertiary); }

/* The first view: copy above the ground, Himel asleep in the sand. */
.hero {
  position: relative;
  min-height: clamp(560px, calc(100svh - var(--header)), 1000px);
}
.sand {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}
.hero-copy {
  position: relative;
  z-index: 1;
  padding-top: clamp(28px, 8vh, 96px);
}
.hero h1 {
  font-size: clamp(40px, 7.2vw, 96px);
  font-weight: 800;
  line-height: 1.14;
}
.hero-copy p {
  max-width: 27em;
  margin: 28px 0 0;
  color: var(--secondary);
  font-size: clamp(16px, 1.3vw, 18px);
}
.hero-copy .links { margin-top: 16px; }
.hero-copy .links a + a { margin-left: 1.6em; }

/* Chapters: heading on the left, text on the right. */
.chapter {
  display: grid;
  gap: 20px;
  padding-top: 56px;
  padding-bottom: 56px;
  background: linear-gradient(var(--border), var(--border)) top center / calc(100% - 2 * var(--gutter)) var(--hairline) no-repeat;
}
.chapter h2 {
  font-size: clamp(26px, 2.8vw, 36px);
  line-height: 1.36;
}
.chapter-body { max-width: 34em; }
.chapter-body > * { margin: 0; }
.chapter-body > * + * { margin-top: 1em; }
.chapter-body p,
.chapter-body li,
.chapter-body dd { color: var(--secondary); }
.chapter-body ul,
.chapter-body ol { padding-left: 1.3em; }
.chapter-body li + li { margin-top: 6px; }
.chapter-body li::marker { color: var(--tertiary); }
.aside { font-size: 14px; }
.chapter-body .aside { color: var(--tertiary); }

@media (min-width: 900px) {
  .chapter {
    grid-template-columns: minmax(0, 5fr) minmax(0, 7fr);
    column-gap: 64px;
    padding-top: 96px;
    padding-bottom: 96px;
  }
}

.ways { margin: 0; }
.ways div + div { margin-top: 28px; }
.ways dt { font-size: 18px; font-weight: 700; font-feature-settings: "palt"; letter-spacing: 0.02em; }
.ways dd { margin: 4px 0 0; }

.mail { font-size: clamp(20px, 2.2vw, 26px); font-weight: 600; line-height: 1.5; }
.chapter-body .mail { color: var(--text); }

.faq { margin: 0; }
.faq dt { font-weight: 700; }
.faq dd { margin: 4px 0 0; }
.faq dd + dt { margin-top: 28px; }

/* Support and legal pages */
.page-head { padding-top: clamp(32px, 8vh, 96px); padding-bottom: 48px; }
.page-head h1 {
  font-size: clamp(30px, 8.4vw, 64px);
  font-weight: 800;
  line-height: 1.18;
}
.page-head p { max-width: 34em; margin: 20px 0 0; color: var(--secondary); }

.doc .prose { max-width: 720px; }
.prose > * { margin: 16px 0 0; }
.prose > :first-child { margin-top: 0; }
.prose h2 { margin-top: 48px; font-size: 21px; line-height: 1.5; scroll-margin-top: 24px; }
.prose h3 { margin-top: 32px; font-size: 18px; }
.prose h4, .prose h5, .prose h6 { font-size: 16px; }
.prose ul, .prose ol { padding-left: 1.4em; }
.prose li + li { margin-top: 6px; }
.prose li::marker { color: var(--tertiary); }
.prose blockquote { margin-left: 0; padding-left: 14px; border-left: 2px solid var(--border); color: var(--secondary); }
.prose blockquote p { margin: 0; }
.prose hr { border: 0; border-top: var(--hairline) solid var(--border); margin: 40px 0; }
.prose pre { overflow-x: auto; padding: 14px 16px; border-radius: 12px; background: var(--inline-code); font-size: 13px; }
.prose pre code { padding: 0; background: none; }
.prose .table { overflow-x: auto; }
.prose table { border-collapse: collapse; min-width: 100%; font-size: 15px; }
.prose th, .prose td { padding: 8px 12px; border-bottom: var(--hairline) solid var(--border); text-align: left; vertical-align: top; }
.prose th { font-weight: 600; }

.toc {
  margin-top: 32px;
  padding: 18px 0;
  border-top: var(--hairline) solid var(--border);
  border-bottom: var(--hairline) solid var(--border);
}
.toc-title { margin: 0 0 6px; color: var(--tertiary); font-size: 13px; }
.toc ol { list-style: none; margin: 0; padding: 0; columns: 2 15em; column-gap: 32px; }
.toc li { break-inside: avoid; margin: 0; padding: 2px 0; font-size: 15px; }
.toc a { color: var(--text); text-decoration: none; }
.toc a:hover { color: var(--link); text-decoration: underline; }

mark.todo { padding: 0.05em 0.3em; border-radius: 4px; background: var(--todo-bg); color: var(--todo-fg); }

.doc-foot {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 24px;
  max-width: 720px;
  margin-top: 56px;
  padding-top: 20px;
  border-top: var(--hairline) solid var(--border);
  font-size: 15px;
}

/* Footer */
.site-footer {
  margin-top: 40px;
  padding-top: 28px;
  padding-bottom: calc(40px + env(safe-area-inset-bottom));
  background: linear-gradient(var(--border), var(--border)) top center / calc(100% - 2 * var(--gutter)) var(--hairline) no-repeat;
  color: var(--tertiary);
  font-size: 13px;
  line-height: 1.7;
}
.site-footer p { margin: 12px 0 0; }
.site-footer a { color: inherit; }
.footer-row {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px 24px;
}
.footer-row p { margin: 0; }
.site-footer nav { display: flex; flex-wrap: wrap; gap: 4px 20px; font-size: 14px; }
.site-footer nav a { color: var(--text); text-decoration: none; }
.site-footer nav a:hover { text-decoration: underline; }
.site-footer nav a[aria-current="page"] { color: var(--tertiary); }
.facts { display: flex; flex-wrap: wrap; gap: 0 16px; }
