:root {
  --ink: #042040;
  --ink-soft: #3b4a60;
  --muted: #6b7a90;
  --line: #e4e8ef;
  --bg: #ffffff;
  --bg-soft: #f6f8fb;
  --brand: #6366f1;
  --brand-dark: #4f52d9;
  --brand-soft: #eef0fe;
  --navy: #042040;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(4, 32, 64, 0.06), 0 8px 24px -12px rgba(4, 32, 64, 0.18);
  --font: "Work Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body {
  margin: 0;
  font-family: var(--font);
  color: var(--ink);
  background: var(--bg);
  line-height: 1.6;
  font-size: 16px;
}
a { color: var(--brand); text-decoration: none; }
a:hover { color: var(--brand-dark); text-decoration: underline; }
img { max-width: 100%; height: auto; }
h1, h2, h3, h4 { line-height: 1.25; font-weight: 600; margin: 0 0 0.5em; color: var(--navy); }
h1 { font-size: 2rem; letter-spacing: -0.01em; }
h2 { font-size: 1.4rem; margin-top: 2em; }
h3 { font-size: 1.12rem; margin-top: 1.6em; }
p, ul, ol { margin: 0 0 1.1em; }
li { margin-bottom: 0.35em; }
code { font-family: var(--mono); font-size: 0.9em; background: var(--bg-soft); padding: 0.1em 0.35em; border-radius: 4px; border: 1px solid var(--line); }
pre { background: #0f1b2d; color: #e6edf7; padding: 1rem 1.2rem; border-radius: var(--radius); overflow: auto; font-size: 0.88rem; line-height: 1.5; }
pre code { background: none; border: 0; padding: 0; color: inherit; font-size: inherit; }
table { border-collapse: collapse; width: 100%; margin: 1.2em 0; font-size: 0.95rem; display: block; overflow-x: auto; }
th, td { text-align: left; padding: 0.55em 0.75em; border-bottom: 1px solid var(--line); vertical-align: top; }
th { background: var(--bg-soft); font-weight: 600; white-space: nowrap; }
hr { border: 0; border-top: 1px solid var(--line); margin: 2em 0; }
kbd { font-family: var(--font); font-size: 0.85em; border: 1px solid #c9d1de; border-bottom-width: 2px; border-radius: 5px; padding: 0.05em 0.45em; background: #fff; }

.skip { position: absolute; left: -999px; top: 0; background: var(--navy); color: #fff; padding: 0.5rem 1rem; z-index: 100; }
.skip:focus { left: 0; }

.wrap { max-width: 1180px; margin: 0 auto; padding: 0 16px; }
.btn {
  display: inline-block;
  background: var(--brand);
  color: #fff !important;
  padding: 0.55rem 1rem;
  border-radius: 8px;
  font-weight: 600;
  text-decoration: none !important;
  border: 0;
  cursor: pointer;
  font-size: 0.95rem;
}
.btn:hover { background: var(--brand-dark); }

/* header */
.site-header { background: var(--navy); color: #fff; position: sticky; top: 0; z-index: 50; }
.site-header .wrap { display: flex; align-items: center; gap: 1rem; min-height: 64px; flex-wrap: wrap; padding-top: 8px; padding-bottom: 8px; }
.brand { display: flex; align-items: center; gap: 0.6rem; color: #fff; font-weight: 600; font-size: 1.05rem; white-space: nowrap; }
.brand:hover { color: #fff; text-decoration: none; }
.brand em { font-style: normal; color: #a5b4fc; font-weight: 500; }
.brand img { border-radius: 50%; }
.search { position: relative; flex: 1; min-width: 200px; max-width: 460px; margin: 0 auto; }
.search input, .hero-search input {
  width: 100%;
  font: inherit;
  padding: 0.6rem 0.9rem 0.6rem 2.3rem;
  border-radius: 8px;
  border: 1px solid rgba(255,255,255,0.15);
  background: rgba(255,255,255,0.1) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='18' height='18' fill='none' stroke='%23c7d2fe' stroke-width='2' stroke-linecap='round'%3E%3Ccircle cx='8' cy='8' r='6'/%3E%3Cpath d='M12.5 12.5 17 17'/%3E%3C/svg%3E") no-repeat 0.75rem center;
  color: #fff;
}
.search input::placeholder { color: #c7d2fe; }
.search input:focus { outline: 2px solid var(--brand); background-color: rgba(255,255,255,0.16); }
.top-links { display: flex; gap: 1rem; align-items: center; margin-left: auto; }
.top-links a { color: #e0e7ff; font-size: 0.95rem; white-space: nowrap; }
.search-results {
  position: absolute; top: calc(100% + 6px); left: 0; right: 0;
  background: #fff; color: var(--ink); border-radius: var(--radius); box-shadow: var(--shadow);
  border: 1px solid var(--line); max-height: 60vh; overflow: auto; z-index: 60; text-align: left;
}
.search-results a { display: block; padding: 0.65rem 0.9rem; border-bottom: 1px solid var(--line); color: var(--ink); }
.search-results a:last-child { border-bottom: 0; }
.search-results a:hover, .search-results a.selected { background: var(--brand-soft); text-decoration: none; }
.search-results a strong { display: block; font-weight: 600; }
.search-results a span { display: block; font-size: 0.85rem; color: var(--muted); }
.search-results .empty { padding: 0.8rem 0.9rem; color: var(--muted); font-size: 0.92rem; }
.search-results mark { background: #fef08a; padding: 0 1px; border-radius: 2px; }

/* layout */
.page { display: grid; grid-template-columns: 260px minmax(0, 1fr); gap: 2.5rem; padding-top: 2rem; padding-bottom: 3rem; }
.sidebar { position: sticky; top: 80px; align-self: start; max-height: calc(100vh - 100px); overflow: auto; font-size: 0.95rem; }
.sidebar nav > a, .sidebar summary { display: block; padding: 0.45rem 0.6rem; border-radius: 6px; color: var(--ink); font-weight: 600; }
.sidebar summary { cursor: pointer; list-style: none; position: relative; }
.sidebar summary::-webkit-details-marker { display: none; }
.sidebar summary::after { content: "›"; position: absolute; right: 0.6rem; top: 0.35rem; color: var(--muted); transition: transform 0.15s; }
.sidebar details[open] summary::after { transform: rotate(90deg); }
.sidebar summary a { color: inherit; }
.sidebar ul { list-style: none; margin: 0 0 0.4rem; padding: 0 0 0 0.6rem; border-left: 2px solid var(--line); margin-left: 0.75rem; }
.sidebar li a { display: block; padding: 0.3rem 0.6rem; color: var(--ink-soft); border-radius: 6px; }
.sidebar li a:hover { background: var(--bg-soft); text-decoration: none; color: var(--ink); }
.sidebar li.active a, .sidebar nav > a.active { background: var(--brand-soft); color: var(--brand-dark); }
.main { min-width: 0; }

/* breadcrumbs */
.crumbs { font-size: 0.88rem; color: var(--muted); margin-bottom: 1rem; }
.crumbs a { color: var(--muted); }
.crumbs .sep { margin: 0 0.5rem; }
.crumbs span:last-child { color: var(--ink-soft); }

/* home */
.hero { background: linear-gradient(135deg, #f1f3ff 0%, #f6f8fb 100%); border: 1px solid var(--line); border-radius: 16px; padding: 2.5rem 2rem; text-align: center; margin-bottom: 2.5rem; }
.hero h1 { font-size: 2.2rem; }
.hero p { color: var(--ink-soft); max-width: 600px; margin: 0 auto 1.4rem; }
.hero-search { position: relative; max-width: 640px; margin: 0 auto; display: flex; gap: 0.5rem; }
.hero-search input { background-color: #fff; border: 1px solid #cfd6e3; color: var(--ink); background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='18' height='18' fill='none' stroke='%236b7a90' stroke-width='2' stroke-linecap='round'%3E%3Ccircle cx='8' cy='8' r='6'/%3E%3Cpath d='M12.5 12.5 17 17'/%3E%3C/svg%3E"); padding-top: 0.8rem; padding-bottom: 0.8rem; font-size: 1.05rem; }
.hero-search input::placeholder { color: var(--muted); }
.hero-search button { font: inherit; font-weight: 600; background: var(--brand); color: #fff; border: 0; border-radius: 8px; padding: 0 1.3rem; cursor: pointer; }
.hero-search .search-results { top: calc(100% + 6px); }
.page-header { margin-bottom: 1.5rem; }
.page-header p { color: var(--ink-soft); font-size: 1.05rem; }
.popular h2, .topics h2 { font-size: 1.25rem; margin-top: 0; }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 1rem; margin-bottom: 2.5rem; }
.card { display: block; background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 1.1rem 1.2rem; color: var(--ink); transition: box-shadow 0.15s, transform 0.15s, border-color 0.15s; }
.card:hover { text-decoration: none; box-shadow: var(--shadow); border-color: #c7cdfb; transform: translateY(-1px); }
.card h3 { margin: 0 0 0.35rem; font-size: 1.05rem; color: var(--brand-dark); }
.card p { margin: 0; color: var(--ink-soft); font-size: 0.93rem; line-height: 1.5; }
.topics { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 1.5rem 2.5rem; margin-bottom: 2.5rem; }
.topic h2 { margin-top: 0; font-size: 1.2rem; }
.topic > p { color: var(--ink-soft); font-size: 0.95rem; }
.topic ul { list-style: none; padding: 0; margin: 0; }
.topic li { padding: 0.25rem 0; border-bottom: 1px dashed var(--line); }
.topic li.more a { font-weight: 600; }
.support-cta { background: var(--navy); color: #fff; border-radius: 16px; padding: 2rem; text-align: center; }
.support-cta h2 { color: #fff; margin-top: 0; }
.support-cta p { color: #dbe3f0; max-width: 620px; margin: 0 auto 1.2rem; }
.support-cta a:not(.btn) { color: #a5b4fc; }

/* article */
.article header { margin-bottom: 1.5rem; }
.article .meta { color: var(--muted); font-size: 0.9rem; margin: 0; }
.toc { background: var(--bg-soft); border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem 1.2rem; margin-bottom: 1.8rem; font-size: 0.93rem; }
.toc strong { display: block; margin-bottom: 0.4rem; font-size: 0.8rem; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); }
.toc ol { margin: 0; padding-left: 1.2rem; }
.toc li { margin: 0.15rem 0; }
.content { font-size: 1.02rem; max-width: 760px; }
.content h2 { padding-top: 0.5rem; border-top: 1px solid var(--line); margin-top: 2.2em; padding-top: 1.4em; }
.content h2 .anchor, .content h3 .anchor { float: left; margin-left: -1.2em; opacity: 0; color: var(--muted); font-weight: 400; }
.content h2:hover .anchor, .content h3:hover .anchor { opacity: 1; }
.content ol li, .content ul li { margin-bottom: 0.5em; }
.content > .content-intro, .content > p:first-child { font-size: 1.08rem; color: var(--ink-soft); }
.shot { margin: 1.4em 0; }
.shot img { border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); display: block; }
.shot figcaption { font-size: 0.85rem; color: var(--muted); margin-top: 0.5rem; }
.callout { border-left: 4px solid var(--brand); background: var(--brand-soft); padding: 0.9rem 1.1rem; border-radius: 0 var(--radius) var(--radius) 0; margin: 1.4em 0; }
.callout p { margin: 0; }
.callout p + p { margin-top: 0.6em; }
.callout strong { margin-right: 0.3em; }
.callout-tip { border-color: #10b981; background: #ecfdf5; }
.callout-warning, .callout-important { border-color: #f59e0b; background: #fffbeb; }
.video { position: relative; padding-top: 56.25%; margin: 1.4em 0; border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); }
.video iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }
.article-footer { margin-top: 3rem; }
.pager { display: flex; justify-content: space-between; gap: 1rem; margin-bottom: 2rem; }
.pager a { flex: 1; border: 1px solid var(--line); border-radius: var(--radius); padding: 0.8rem 1rem; color: var(--ink); font-weight: 600; max-width: 48%; }
.pager a:hover { text-decoration: none; border-color: #c7cdfb; background: var(--bg-soft); }
.pager a small { display: block; font-weight: 400; color: var(--muted); font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.05em; }
.pager .next { text-align: right; margin-left: auto; }
.support { background: var(--bg-soft); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.2rem 1.4rem; }
.support h2 { margin: 0 0 0.4rem; font-size: 1.1rem; }
.support p { margin: 0; color: var(--ink-soft); font-size: 0.95rem; }

/* footer */
.site-footer { border-top: 1px solid var(--line); background: var(--bg-soft); padding: 1.5rem 0; font-size: 0.9rem; color: var(--muted); }
.site-footer p { margin: 0.2rem 0; }

@media (max-width: 900px) {
  .page { grid-template-columns: 1fr; gap: 1.5rem; padding-top: 1.2rem; }
  .sidebar { position: static; max-height: none; order: 2; border-top: 1px solid var(--line); padding-top: 1rem; }
  .hero { padding: 1.8rem 1.2rem; }
  .hero h1 { font-size: 1.7rem; }
  .hero-search { flex-direction: column; }
  .hero-search button { padding: 0.75rem; }
  .top-links a:not(.btn) { display: none; }
  .search { order: 3; flex-basis: 100%; max-width: none; }
  .pager { flex-direction: column; }
  .pager a { max-width: none; }
  .pager .next { text-align: left; }
  .content h2 .anchor, .content h3 .anchor { display: none; }
}
