:root {
  --canvas: #faf7f4;
  --surface: #ffffff;
  --surface-raised: #fcfaf8;
  --surface-soft: #f5f1ed;
  --text: #171820;
  --text-muted: #646874;
  --border: #e2e5ea;
  --border-strong: #c8cdd5;
  --accent: #c43e0b;
  --accent-soft: #fff0e8;
  --accent-contrast: #ffffff;
  --link: #a93208;
  --focus: #c43e0b;
  --success: #107c10;
  --warning: #986f0b;
  --danger: #c50f1f;
  --code: #f7f8fa;
  --sidebar: 320px;
  --header: 64px;
  --footer: 44px;
  --control-bg: #ffffff;
  --control-bg-hover: #f2f2f2;
  --control-bg-active: #fff0e8;
  --control-text: #1b1b1f;
  --control-border: #c8cdd5;
  --popover-bg: #ffffff;
  --popover-border: #d9dde4;
  --radius-control: 10px;
  --radius-panel: 14px;
  --radius-document: 20px;
  --radius-pill: 999px;
  --shadow-control: 0 2px 10px rgba(24, 28, 38, .05);
  --shadow-icon: 0 3px 12px rgba(24, 28, 38, .08);
  --shadow-soft: 0 8px 28px rgba(24, 28, 38, .06);
  --popover-shadow: 0 18px 48px rgba(24, 28, 38, .14);
  --option-selected-bg: #fff0e8;
  --option-selected-text: #1b1b1f;
  color-scheme: light;
  font-family: "Segoe UI", SegoeUI, system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
}

[data-theme="light"] {
  --canvas: #faf7f4;
  --surface: #ffffff;
  --surface-raised: #fcfaf8;
  --surface-soft: #f5f1ed;
  --text: #171820;
  --text-muted: #646874;
  --border: #e2e5ea;
  --border-strong: #c8cdd5;
  --accent: #c43e0b;
  --accent-soft: #fff0e8;
  --accent-contrast: #ffffff;
  --link: #a93208;
  --focus: #c43e0b;
  --code: #f7f8fa;
  color-scheme: light;
}

[data-theme="dark"] {
  --canvas: #111218;
  --surface: #191b22;
  --surface-raised: #20232c;
  --surface-soft: #252832;
  --text: #f4f5f7;
  --text-muted: #b9bdc8;
  --border: #30343f;
  --border-strong: #515765;
  --accent: #ff7a3b;
  --accent-soft: #422316;
  --accent-contrast: #171717;
  --link: #ff9a68;
  --focus: #ff7a3b;
  --code: #12141a;
  --control-bg: #191b22;
  --control-bg-hover: #252832;
  --control-bg-active: #422316;
  --control-text: #f5f5f5;
  --control-border: #515765;
  --popover-bg: #191b22;
  --popover-border: #3b404d;
  --shadow-control: 0 2px 12px rgba(0, 0, 0, .18);
  --shadow-icon: 0 3px 14px rgba(0, 0, 0, .22);
  --shadow-soft: 0 10px 30px rgba(0, 0, 0, .2);
  --popover-shadow: 0 20px 54px rgba(0, 0, 0, .42);
  --option-selected-bg: #422316;
  --option-selected-text: #f5f5f5;
  color-scheme: dark;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { scroll-behavior: smooth; background: var(--canvas); }
body { margin: 0; min-width: 320px; background: var(--canvas); color: var(--text); }
body.auth-only { height: 100svh; overflow: hidden; }
button, input, select { font: inherit; }
button, a, select { -webkit-tap-highlight-color: transparent; }
button:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }
.skip-link { position: fixed; left: 16px; top: -100px; z-index: 100; padding: 10px 14px; background: var(--text); color: var(--surface); text-decoration: none; }
.skip-link:focus { top: 10px; }

.app-shell { min-height: 100vh; }
.global-header { position: fixed; inset: 0 0 auto var(--sidebar); z-index: 30; height: var(--header); display: flex; align-items: center; padding: 0 28px; background: color-mix(in srgb, var(--surface) 94%, transparent); border-bottom: 1px solid var(--border); backdrop-filter: blur(14px); }
.global-actions { display: flex; align-items: center; gap: 8px; margin-left: auto; }
.mobile-menu { min-height: 40px; padding: 0 15px; color: var(--text); background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-pill); cursor: pointer; }
.mobile-menu:hover { background: var(--surface-raised); border-color: var(--border); }
.mobile-menu { display: none; }
.theme-toggle { display: grid; place-items: center; width: 44px; height: 44px; padding: 0; color: var(--text); background: transparent; border: 1px solid transparent; border-radius: 50%; cursor: pointer; }
.theme-toggle:hover { background: var(--surface-raised); border-color: var(--border); }
.theme-icon { width: 24px; height: 24px; background: currentColor; -webkit-mask: url('/assets/dark-theme-24-regular.svg') center/24px 24px no-repeat; mask: url('/assets/dark-theme-24-regular.svg') center/24px 24px no-repeat; }
.user-button { display: flex; align-items: center; gap: 9px; min-height: 44px; max-width: 280px; padding: 4px 12px 4px 4px; color: var(--text); background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-pill); box-shadow: var(--shadow-control); cursor: pointer; }
.user-button:hover { background: var(--surface-raised); border-color: var(--border); }
.user-button > strong { overflow: hidden; max-width: 150px; text-overflow: ellipsis; white-space: nowrap; font-size: 14px; }
.user-avatar { position: relative; flex: 0 0 auto; width: 34px; height: 34px; overflow: hidden; border-radius: 50%; background: var(--accent); color: var(--accent-contrast); }
.user-avatar > img, .user-avatar > span { position: absolute; inset: 0; width: 100%; height: 100%; }
.user-avatar > img { display: block; object-fit: cover; }
.user-avatar > span { display: grid; place-items: center; font-size: 11px; font-weight: 700; }
.user-chevron { flex: 0 0 auto; color: var(--text-muted); font-size: 16px; line-height: 1; transform: translateY(-1px); }
.user-button[aria-expanded="true"] .user-chevron { transform: rotate(180deg) translateY(1px); }
.account-menu { position: absolute; top: calc(100% + 8px); right: 24px; z-index: 35; width: 220px; padding: 8px; background: var(--popover-bg); border: 1px solid var(--popover-border); border-radius: var(--radius-panel); box-shadow: var(--popover-shadow); animation: menu-in .18s ease both; }
.account-menu button { width: 100%; min-height: 44px; padding: 0 14px; color: var(--text); background: transparent; border: 0; border-radius: var(--radius-control); cursor: pointer; text-align: left; }
.account-menu button:hover, .account-menu button:focus-visible { background: var(--surface-raised); }

.sidebar { position: fixed; inset: 0 auto 0 0; z-index: 40; width: var(--sidebar); display: flex; flex-direction: column; padding: 22px 18px 18px 22px; background: var(--surface); border-right: 1px solid var(--border); }
.sidebar-close { display: none; position: absolute; top: 18px; right: 14px; width: 44px; height: 44px; padding: 0; color: var(--text); background: transparent; border: 1px solid transparent; border-radius: 50%; cursor: pointer; }
.sidebar-close:hover { background: var(--surface-soft); border-color: var(--border); }
.sidebar-close span { display: block; width: 24px; height: 24px; margin: auto; background: currentColor; -webkit-mask: url('/assets/dismiss-24-regular.svg') center/24px 24px no-repeat; mask: url('/assets/dismiss-24-regular.svg') center/24px 24px no-repeat; }
.sidebar-brand { display: flex; align-items: center; gap: 12px; min-height: 48px; margin: 0 0 26px; color: var(--text); text-decoration: none; }
.sidebar-brand img { flex: 0 0 auto; border: 1px solid var(--border); border-radius: 12px; box-shadow: var(--shadow-icon); }
.sidebar-brand span { display: grid; gap: 2px; }
.sidebar-brand strong { font-size: 18px; letter-spacing: -.02em; }
.sidebar-brand small { color: var(--text-muted); font-size: 11px; font-weight: 650; letter-spacing: .08em; text-transform: uppercase; }
.search-trigger { display: flex; align-items: center; justify-content: space-between; gap: 12px; width: 100%; min-height: 46px; margin: 0 0 22px; padding: 0 14px; color: var(--text-muted); background: var(--surface-raised); border: 1px solid var(--border); border-radius: 12px; box-shadow: var(--shadow-control); cursor: pointer; text-align: left; }
.search-trigger:hover { color: var(--text); border-color: var(--text); }
kbd { padding: 2px 6px; color: var(--text-muted); background: var(--surface); border: 1px solid var(--border); border-radius: 6px; font-size: 10px; }
.doc-nav { overflow-y: auto; padding: 0 6px 30px 0; scrollbar-color: var(--border-strong) transparent; scrollbar-width: thin; }
.nav-group { margin: 0 0 23px; }
.nav-group > span { display: block; padding: 0 12px 8px; color: var(--text-muted); font-size: 12px; font-weight: 650; }
.nav-link { display: block; min-height: 40px; margin: 2px 0; padding: 10px 12px; color: var(--text); border-left: 3px solid transparent; border-radius: var(--radius-control); text-decoration: none; font-size: 14px; line-height: 1.35; }
.nav-link:hover { background: var(--surface-soft); text-decoration: underline; text-underline-offset: 3px; }
.nav-link[aria-current="page"] { background: var(--accent-soft); border-left-color: var(--accent); font-weight: 650; }

.content { min-height: 100vh; margin-left: var(--sidebar); padding: calc(var(--header) + 32px) clamp(28px, 4vw, 68px) calc(var(--footer) + 48px); }
.content-main { width: min(940px, calc(100% - 220px)); padding: clamp(28px, 4vw, 48px); background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-document); box-shadow: var(--shadow-soft); }
.breadcrumb { display: flex; align-items: center; gap: 9px; margin-bottom: 36px; color: var(--text-muted); font-size: 14px; }
.breadcrumb a { color: var(--link); text-decoration: none; }
.breadcrumb a:hover { text-decoration: underline; }
.breadcrumb strong { min-width: 0; overflow: hidden; color: var(--text-muted); font-weight: 400; text-overflow: ellipsis; white-space: nowrap; }
.document-header { margin: 0 0 40px; animation: appear .24s ease both; }
.document-header .eyebrow { margin: 0 0 9px; color: var(--accent); font-size: 12px; font-weight: 650; letter-spacing: .03em; text-transform: uppercase; }
.document h1 { max-width: 760px; margin: 0; font-size: clamp(36px, 4vw, 48px); line-height: 1.12; letter-spacing: -.025em; text-wrap: balance; }
.document-header > p { max-width: 720px; margin: 20px 0 0; color: var(--text-muted); font-size: 18px; line-height: 1.6; }
.document h2 { margin: 50px 0 15px; font-size: clamp(27px, 3vw, 34px); line-height: 1.2; letter-spacing: -.018em; scroll-margin-top: 90px; }
.document h3 { margin: 34px 0 11px; font-size: 21px; line-height: 1.3; scroll-margin-top: 90px; }
.document p, .document li { color: var(--text); font-size: 16px; line-height: 1.7; }
.document strong { color: var(--text); }
.document a { color: var(--link); text-underline-offset: 3px; }
.document ul, .document ol { margin: 16px 0 26px; padding-left: 25px; }
.document li { padding-left: 3px; margin: 7px 0; }
.document blockquote { margin: 26px 0; padding: 16px 20px; background: var(--accent-soft); border-left: 4px solid var(--accent); border-radius: 0 12px 12px 0; }
.document blockquote p { margin: 0; }
.document pre { overflow-x: auto; margin: 24px 0; padding: 18px; background: var(--code); color: var(--text); border: 1px solid var(--border); border-radius: 12px; font: 14px/1.65 "Cascadia Code", Consolas, monospace; }
.document code:not(pre code) { padding: 2px 6px; background: var(--surface-raised); color: var(--text); border: 1px solid var(--border); border-radius: 6px; font: 13px/1.4 "Cascadia Code", Consolas, monospace; }
.table-wrap { overflow-x: auto; margin: 24px 0 34px; border: 1px solid var(--border); border-radius: 12px; }
.document table { width: 100%; border-collapse: collapse; font-size: 14px; }
.document th, .document td { padding: 13px 14px; border-bottom: 1px solid var(--border); text-align: left; vertical-align: top; }
.document th { background: var(--surface-raised); font-weight: 650; }
.document td { line-height: 1.55; }
.check-item { list-style: none; margin-left: -24px !important; }
.check-item::before { content: ""; display: inline-block; width: 14px; height: 14px; margin: 0 10px -2px 0; border: 1px solid var(--border-strong); }
.theme-gallery { display: grid; grid-template-columns: repeat(2, 1fr); gap: 16px; margin: 30px 0 42px; }
.theme-figure { margin: 0; }
.theme-figure img { display: block; width: 100%; aspect-ratio: 16/10; object-fit: cover; border: 1px solid var(--border); border-radius: 6px; transition: transform .16s ease, box-shadow .16s ease; }
.theme-figure img:hover { transform: translateY(-2px); box-shadow: 0 3px 10px color-mix(in srgb, var(--text) 15%, transparent); }
.theme-figure figcaption { display: flex; justify-content: space-between; gap: 8px; padding: 9px 1px; color: var(--text-muted); font-size: 12px; }
.theme-figure strong { color: var(--text); }
.on-this-page { position: fixed; top: calc(var(--header) + 32px); right: max(18px, 2vw); width: 190px; padding: 18px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-panel); box-shadow: var(--shadow-soft); }
.on-this-page > span { display: block; margin-bottom: 12px; font-size: 13px; font-weight: 650; }
.on-this-page a { display: block; padding: 5px 0; color: var(--text-muted); text-decoration: none; font-size: 12px; line-height: 1.4; }
.on-this-page a:hover { color: var(--link); text-decoration: underline; }

.eyebrow { color: var(--accent); font-size: 13px; font-weight: 650; letter-spacing: .06em; }
.auth-only .app-shell { height: 100svh; min-height: 0; overflow: hidden; }
.auth-only .content { display: grid; height: 100%; min-height: 0; margin: 0; overflow: hidden; padding: clamp(28px, 7vw, 96px); place-items: center; }
.auth-content { width: min(720px, 100%); animation: appear .28s ease both; }
.auth-brand { display: flex; align-items: center; gap: 14px; margin-bottom: clamp(56px, 9vh, 96px); }
.auth-brand img { border: 1px solid var(--border); border-radius: 14px; box-shadow: var(--shadow-soft); }
.auth-brand span { display: grid; gap: 2px; }
.auth-brand strong { font-size: 20px; letter-spacing: -.02em; }
.auth-brand small { color: var(--text-muted); font-size: 11px; font-weight: 650; letter-spacing: .09em; text-transform: uppercase; }
.auth-content .eyebrow { margin: 0 0 16px; }
.auth-content h1 { max-width: 700px; margin: 0; font-size: clamp(42px, 7vw, 76px); line-height: 1.02; letter-spacing: -.045em; text-wrap: balance; }
.auth-lead { max-width: 620px; margin: 24px 0 28px; color: var(--text-muted); font-size: clamp(17px, 2vw, 20px); line-height: 1.65; }
.primary-button { display: inline-flex; align-items: center; justify-content: center; min-width: 132px; min-height: 46px; margin-top: 12px; padding: 0 22px; background: var(--accent); color: var(--accent-contrast); border: 1px solid var(--accent); border-radius: var(--radius-control); text-decoration: none; font-size: 15px; font-weight: 650; transition: background-color .16s ease, transform .16s ease, box-shadow .16s ease; }
.document .primary-button { color: var(--accent-contrast); }
.primary-button:hover { background: color-mix(in srgb, var(--accent) 86%, black); box-shadow: 0 8px 20px color-mix(in srgb, var(--accent) 22%, transparent); transform: translateY(-1px); }
.auth-status { display: block; margin-top: 14px; color: var(--text-muted); font-size: 13px; line-height: 1.45; }

.search-dialog { width: min(720px, calc(100vw - 32px)); max-height: min(700px, calc(100vh - 40px)); padding: 0; color: var(--text); background: var(--surface); border: 1px solid var(--popover-border); border-radius: 16px; box-shadow: var(--popover-shadow); }
.search-dialog::backdrop { background: color-mix(in srgb, #000 45%, transparent); }
.search-box { display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 12px; padding: 15px; border-bottom: 1px solid var(--border); }
.search-box label { display: block; }
.search-box input { width: 100%; min-height: 44px; padding: 8px 12px; color: var(--text); background: var(--surface); border: 1px solid var(--border-strong); border-radius: 10px; font-size: 16px; }
.search-box button { min-height: 36px; padding: 0 12px; color: var(--text); background: var(--surface-raised); border: 1px solid var(--border); border-radius: 9px; cursor: pointer; }
.search-results { overflow-y: auto; max-height: 540px; padding: 8px; }
.search-result { display: block; padding: 14px; color: var(--text-muted); border-bottom: 1px solid var(--border); text-decoration: none; }
.search-result:hover { background: var(--surface-raised); }
.search-result strong { display: block; margin-bottom: 5px; color: var(--text); font-size: 15px; }
.search-result small { font-size: 13px; line-height: 1.5; }
.empty-search { padding: 42px 20px; color: var(--text-muted); text-align: center; }
.confirm-dialog { width: min(430px, calc(100vw - 32px)); padding: 0; color: var(--text); background: var(--surface); border: 1px solid var(--popover-border); border-radius: 16px; box-shadow: var(--popover-shadow); }
.confirm-dialog::backdrop { background: color-mix(in srgb, #000 45%, transparent); }
.confirm-dialog form { padding: 26px; }
.confirm-dialog h2 { margin: 0 0 12px; font-size: 24px; }
.confirm-dialog p { margin: 0 0 24px; color: var(--text-muted); line-height: 1.5; }
.confirm-dialog form > div { display: flex; justify-content: flex-end; gap: 10px; }
.confirm-dialog button { min-height: 40px; padding: 0 16px; color: var(--text); background: var(--surface-raised); border: 1px solid var(--border-strong); border-radius: 9px; cursor: pointer; }
.confirm-dialog .danger-button { background: var(--danger); color: #fff; border-color: var(--danger); }
.footerbar { position: fixed; inset: auto 0 0 var(--sidebar); z-index: 45; min-height: var(--footer); display: flex; align-items: center; justify-content: flex-end; gap: 18px; padding: 0 28px; color: var(--text-muted); background: color-mix(in srgb, var(--surface) 96%, transparent); border-top: 1px solid var(--border); font-size: 12px; backdrop-filter: blur(12px); }
.footerbar a { color: var(--link); font-weight: 650; text-decoration: none; }
.footerbar a:hover { text-decoration: underline; text-underline-offset: 3px; }
.release-dialog { width: min(720px, calc(100vw - 32px)); max-height: min(760px, calc(100vh - 40px)); padding: 0; color: var(--text); background: var(--surface); border: 1px solid var(--border-strong); border-radius: 14px; box-shadow: var(--popover-shadow); }
.release-dialog::backdrop { background: color-mix(in srgb, #000 45%, transparent); }
.release-dialog-header { position: sticky; top: 0; display: flex; align-items: center; justify-content: space-between; gap: 20px; padding: 20px 24px; background: var(--surface); border-bottom: 1px solid var(--border); }
.release-dialog-header h2 { margin: 0; font-size: 24px; }
.release-dialog-header button { min-height: 40px; padding: 0 14px; color: var(--control-text); background: var(--control-bg); border: 1px solid var(--control-border); border-radius: 8px; cursor: pointer; }
.release-dialog-content { padding: 0 24px 28px; }
.release-dialog-content section { padding: 26px 0; border-bottom: 1px solid var(--border); }
.release-dialog-content section:last-child { border-bottom: 0; }
.release-dialog-content h3 { margin: 8px 0 14px; font-size: 20px; }
.release-dialog-content li { margin: 7px 0; line-height: 1.5; }
.update-dialog { width: min(560px, calc(100vw - 32px)); padding: 0; color: var(--text); background: var(--surface); border: 1px solid var(--border-strong); border-radius: 14px; box-shadow: var(--popover-shadow); }
.update-dialog::backdrop { background: color-mix(in srgb, #000 52%, transparent); }
.update-dialog-content { padding: 28px; }
.update-dialog-content h2 { margin: 8px 0 18px; font-size: 28px; }
.update-dialog-content li { margin: 8px 0; line-height: 1.5; }
.update-dialog-content > p:not(.eyebrow) { color: var(--text-muted); }

@keyframes appear { from { opacity: 0; transform: translateY(6px); } }
@keyframes menu-in { from { opacity: 0; transform: translateY(-6px) scale(.98); } }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; } }

@media (max-width: 1120px) {
  .content-main { width: 100%; }
  .on-this-page { display: none; }
  .theme-gallery { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 860px) {
  .mobile-menu { display: block; margin-right: 10px; }
  .global-header { left: 0; }
  .sidebar-close { display: grid; place-items: center; }
  .sidebar { transform: translateX(-102%); transition: transform .2s ease; box-shadow: 16px 0 35px color-mix(in srgb, #000 24%, transparent); }
  body.menu-open .sidebar { transform: translateX(0); }
  .content { margin-left: 0; padding: calc(var(--header) + 24px) 20px 70px; }
  .footerbar { left: 0; }
  .auth-content { width: 100%; }
}

@media (max-width: 560px) {
  :root { --header: 56px; }
  .global-header { padding: 0 10px; }
  .user-button { min-height: 42px; padding-right: 2px; }
  .user-button > strong, .user-chevron { display: none; }
  .account-menu { right: 10px; }
  .footerbar { gap: 12px; padding: 0 12px; }
  .content { padding-left: 12px; padding-right: 12px; }
  .content-main { padding: 24px 20px 36px; border-radius: 16px; }
  .breadcrumb { margin-bottom: 30px; font-size: 13px; }
  .document h1 { font-size: clamp(34px, 11vw, 44px); }
  .document-header > p { font-size: 17px; }
  .document h2 { margin-top: 42px; }
  .theme-gallery { grid-template-columns: 1fr; }
  .auth-only .content { padding: 28px 22px; }
  .auth-brand { margin-bottom: 56px; }
}

@media (max-height: 720px) {
  .auth-only .content { padding-top: 20px; padding-bottom: 20px; }
  .auth-brand { margin-bottom: 24px; }
  .auth-content .eyebrow { margin-bottom: 8px; }
  .auth-content h1 { font-size: clamp(34px, 7vh, 52px); }
  .auth-lead { margin: 16px 0 12px; font-size: 16px; line-height: 1.45; }
  .primary-button { margin-top: 4px; }
  .auth-status { margin-top: 8px; }
}
