@font-face {
  font-family: Inter;
  src: url("/shared/fonts/Inter.woff2") format("woff2");
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
}

/* Shared appearance for the existing account themes. */
:root {
  --panel-padding-block: 14px;
  --panel-gap: 12px;
  --empty-state-padding-block: 24px;
  --font-ui: Inter, "Noto Sans", "Noto Sans SC", "Noto Sans CJK SC", "Noto Sans CJK", sans-serif;
  --accent-soft: color-mix(in srgb, var(--accent-primary) 13%, transparent);
  --accent-soft-06: color-mix(in srgb, var(--accent-primary) 6%, transparent);
  --danger-soft: color-mix(in srgb, var(--danger) 13%, transparent);
  --focus-ring-on-dark: 0 0 0 3px color-mix(in srgb, var(--accent-primary) 58%, transparent);
  --focus-ring-on-light: var(--focus-ring-on-dark);
  --header-shadow: 0 1px 1px var(--surface-line);
  --surface-highlight: inset 0 1px 0 var(--edge-light);
  --card-shadow: var(--surface-highlight), 0 1px 2px var(--shadow-color), 0 8px 24px var(--shadow-color);
  --pop-shadow: var(--surface-highlight), 0 4px 10px var(--shadow-color), 0 14px 36px var(--shadow-color);
  --card-fill: var(--bg-card);
  --action-fill: #005fc7;
  --action-hover: #0054b6;
  --action-fg: #fff;
  --action-shadow: inset 0 1px 0 rgb(255 255 255 / 24%), 0 2px 4px rgb(0 75 170 / 18%);
  --progress-track: color-mix(in srgb, var(--text-main) 13%, var(--bg-card));
  --nav-active-bg: var(--accent-soft);
  --surface-selected: color-mix(in srgb, var(--bg-card) 85%, var(--accent-primary));
  --ix-fg: var(--accent-primary);
  --ix-bg: var(--accent-soft);
  --accent-on-surface: var(--accent-primary);

  --bg: var(--bg-body);
  --panel: var(--bg-card);
  --text: var(--text-main);
  --muted: var(--text-muted);
  --accent: var(--accent-primary);
  --header-h: 52px;
  --footer-compact-pad-y: 0.45rem;
  --font-brand: 18px;
  --font-page-title: clamp(1.4rem, 3.2vw, 1.9rem);
  --font-lang: 13px;
  --font-btn: 13px;
  --font-btn-compact: 12px;
  --font-footer: 12px;
  --font-footer-link: 12px;
  --radius: 12px;
  --radius-compact: 8px;
  --card-radius: 20px;
  --pill-radius: 999px;
  --control-h-dense: 1.75rem;
  --control-h-compact: 2rem;
  --control-h: 2.25rem;
  --control-h-menu: 2.5rem;
  --control-h-touch: 2.75rem;

  font-family: var(--font-ui);
  font-optical-sizing: auto;
}

:root {
  --bg-body: #f2f2f7;
  --bg-card: #fff;
  --bg-hover: #e9e9f0;
  --text-main: #1c1c1e;
  --text-muted: #565660;
  --text-placeholder: #6b6b76;
  --accent-primary: #005fc7;
  --danger: #b92724;
  --ok: #196e39;
  --surface-line: rgb(60 60 67 / 16%);
  --edge-light: rgb(255 255 255 / 80%);
  --shadow-color: rgb(27 35 63 / 9%);
  --header-bg: rgb(252 252 255 / 88%);
  --menu-bg: #fff;
  --input-bg: #f6f6fa;
  --progress-fill: #0062c9;
  --modal-backdrop: rgb(29 31 42 / 36%);
  color-scheme: light;
}

html[data-theme="black"] {
  --bg-body: #000;
  --bg-card: #1c1c1e;
  --bg-hover: #2c2c2e;
  --text-main: #f5f5f7;
  --text-muted: #b4b4bc;
  --text-placeholder: #9696a2;
  --accent-primary: #72b6ff;
  --danger: #ff7773;
  --ok: #61da81;
  --surface-line: rgb(235 235 245 / 15%);
  --edge-light: rgb(235 235 245 / 11%);
  --shadow-color: rgb(0 0 0 / 45%);
  --header-bg: rgb(24 24 26 / 88%);
  --menu-bg: #202022;
  --input-bg: #171719;
  --progress-fill: #4d9eff;
  --modal-backdrop: rgb(0 0 0 / 66%);
  color-scheme: dark;
}

* { box-sizing: border-box; }
/* Card padding owns the space before and after its visible content. */
:is(.card, .social-panel, .curated-card) > :nth-child(1 of :not([hidden])) {
  margin-block-start: 0;
}
:is(.card, .social-panel, .curated-card) > :nth-last-child(1 of :not([hidden])) {
  margin-block-end: 0;
}
/* Inset controls and code blocks use the same radius. */
pre,
:where(pre),
kbd,
samp,
.xk-code,
article pre,
.flash-shell pre {
  border-radius: var(--radius);
}
html {
  height: 100%;
  margin: 0;
  background: var(--bg-body);
  color: var(--text-main);
}
body {
  margin: 0;
  display: flex;
  flex-direction: column;
  height: 100%;
  min-height: 100vh;
  min-height: 100dvh;
  overflow: hidden;
  font-size: 16px;
  line-height: 1.5;
  color: var(--text-main);
  background-color: var(--bg-body);
}
.docs-shell,
.static-shell,
#app,
main.hero {
  flex: 1 1 auto;
  min-height: 0;
  width: 100%;
  max-width: none; /* keep page scrollbar on the viewport edge across themes */
  overflow: auto;
  -webkit-overflow-scrolling: touch;
  background: transparent;
}
[hidden] { display: none !important; }
:is(.table-scroll, .console-table-scroll) tbody tr:has(> td:last-child .btn) > td {
  vertical-align: middle;
}
html:not([data-donate-ui]) [data-donate-entry] { display: none !important; }
.visually-hidden {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
}
.muted { color: var(--text-muted); }

/* —— Legacy top / topbar (pre-site-header pages) —— */
.top, .topbar {
  flex: 0 0 auto;
  position: relative;
  z-index: 2;
  display: flex; align-items: center; justify-content: space-between;
  min-height: var(--header-h);
  height: var(--header-h);
  padding: 0 32px;
  background: var(--header-bg);
  color: var(--text-main);
  border-bottom: 1px solid var(--surface-line);
  box-shadow: var(--header-shadow);
  gap: 16px;
}
.top nav, .topbar-right {
  display: flex; align-items: center; gap: 16px; flex-wrap: wrap;
}
.brand {
  color: var(--text-main); text-decoration: none; font-weight: 700;
  font-size: var(--font-brand); letter-spacing: -0.02em; line-height: 1.2;
  outline: none; box-shadow: none;
}
.brand:hover { opacity: 0.95; }
.brand:focus-visible { box-shadow: var(--focus-ring-on-dark); }
.brand .accent {
  color: var(--accent-primary);
  text-shadow: none;
  font-weight: 700;
  opacity: 1;
}
.top-link, .top nav > a:not(.brand) {
  color: var(--text-muted); text-decoration: none;
  font-size: 14px; padding: 6px 14px;
  outline: none; box-shadow: none; transition: all 0.3s;
}
/* Header chrome (.top / top-link): same language as .xk-site-header — not page --ix-*. */
.top-link:hover, .top nav > a:not(.brand):hover {
  color: var(--accent-primary);
  text-shadow: none;
}
.top-link:focus-visible, .top nav > a:not(.brand):focus-visible {
  color: var(--accent-primary); box-shadow: var(--focus-ring-on-dark);
}
.top nav > a:not(.brand) {
  border-radius: var(--radius);
}
.top nav > a:not(.brand)[aria-current] {
  color: var(--accent-primary);
  text-shadow: none;
  background: var(--nav-active-bg);
  font-weight: 650;
  box-shadow: var(--surface-highlight);
}

/* Shared stroke icons (lang switch, details, selects). One weight / gap everywhere. */
:root {
  --chevron-gap: 0.45rem;
  --chevron-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='none' stroke='%23000' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round' d='M1.5 2.2 L6 6.2 L10.5 2.2'/%3E%3C/svg%3E");
  /* Select arrow = same stroke chevron; color matches muted text per theme. */
  --select-chevron: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='none' stroke='%23B6BFCD' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round' d='M1.5 2.2 L6 6.2 L10.5 2.2'/%3E%3C/svg%3E");
}
html[data-theme="light"] {
  --select-chevron: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='none' stroke='%23565660' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round' d='M1.5 2.2 L6 6.2 L10.5 2.2'/%3E%3C/svg%3E");
}
.xk-icon {
  width: 1.1em;
  height: 1.1em;
  flex: none;
  display: inline-block;
  vertical-align: -0.15em;
}
a.back-community,
.follow-button,
.inbox-all,
.author-pop-footer a {
  display: inline-flex;
  align-items: center;
  gap: var(--chevron-gap);
}
.lang-switch { position: relative; }
.lang-switch-btn {
  appearance: none; -webkit-appearance: none;
  display: inline-flex; align-items: center; gap: var(--chevron-gap);
  background-color: transparent;
  background-image: none;
  color: var(--text-muted);
  border: 0;
  border-radius: var(--radius); padding: 0.4rem 0.6rem;
  font: inherit; font-size: var(--font-lang); max-width: 11rem; line-height: 1.3;
  box-shadow: none; outline: none; cursor: pointer; transition: color 0.3s, text-shadow 0.3s;
}
.lang-switch-btn::after {
  content: "";
  flex: 0 0 auto;
  width: 12px;
  height: 8px;
  background-color: currentColor;
  -webkit-mask: var(--chevron-mask) center / contain no-repeat;
  mask: var(--chevron-mask) center / contain no-repeat;
  pointer-events: none;
}
.lang-switch-btn:hover {
  color: var(--accent-primary);
  text-shadow: none;
  background: transparent;
}
.lang-switch-btn:focus-visible {
  color: var(--accent-primary);
  box-shadow: var(--focus-ring-on-dark);
}
.lang-switch-label {
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 8.5rem;
}
/*
 * Canonical dropdown shell — lang menu is the reference.
 * Position via XkPop: prefer below, align end, gap 6, pad 8 (all themes).
 * Body menus clamp between header and footer; XkPop sets max-height per open.
 */
.lang-switch-menu,
.xk-select-menu,
.xk-pop,
.social-user-menu,
.user-dropdown,
#header-inbox,
.board-pop,
.author-pop {
  position: fixed;
  z-index: 1400;
  box-sizing: border-box;
  min-width: 11rem;
  max-width: min(18rem, calc(100vw - 1rem));
  /* Height/overflow set by XkPop: expand fully when it fits; scroll only if needed. */
  max-height: none;
  overflow: visible;
  background: var(--menu-bg);
  color: var(--text-main);
  border: 1px solid var(--surface-line);
  border-radius: var(--card-radius);
  padding: 6px;
  box-shadow: var(--pop-shadow);
  font: 400 14px/1.5 -apple-system, BlinkMacSystemFont, var(--font-ui);
}
/* Wider panels that still share the same chrome */
#header-inbox,
.board-pop,
.author-pop {
  min-width: min(280px, calc(100vw - 24px));
  max-width: min(420px, calc(100vw - 24px));
}
.lang-option,
.xk-menu-item,
.social-user-menu > a,
.social-user-menu > button,
.user-dropdown button {
  display: flex;
  align-items: center;
  gap: var(--chevron-gap);
  width: 100%;
  min-height: var(--control-h-menu);
  box-sizing: border-box;
  text-align: start;
  background: transparent;
  border: 0;
  border-radius: var(--radius);
  color: var(--text-main);
  padding: 0.55rem 0.7rem;
  font: inherit;
  font-size: 14px;
  cursor: pointer;
  outline: none;
  box-shadow: none;
  text-decoration: none;
}
/* Lang rows: label start, check end (reference screenshot) */
.lang-option,
.xk-menu-item {
  justify-content: space-between;
}
/* Account/console rows: icon + label packed at start */
.social-user-menu > a,
.social-user-menu > button,
.user-dropdown button {
  justify-content: flex-start;
}
.lang-option:hover,
.lang-option[aria-selected="true"],
.xk-menu-item:hover,
.xk-menu-item[aria-selected="true"],
.social-user-menu > a:hover,
.social-user-menu > button:hover,
.user-dropdown button:hover,
.lang-option:focus-visible,
.xk-menu-item:focus-visible,
.social-user-menu > a:focus-visible,
.social-user-menu > button:focus-visible,
.user-dropdown button:focus-visible {
  background: var(--ix-bg);
  color: var(--ix-fg);
  text-shadow: none;
  box-shadow: none;
}
.lang-check,
.xk-menu-check {
  display: inline-flex;
  align-items: center;
  color: var(--accent-primary);
  flex: none;
}
.lang-check .xk-icon,
.xk-menu-check .xk-icon {
  width: 14px;
  height: 14px;
}

/* Details/summary: same stroke chevron as lang switch (not native solid ▶) */
summary {
  list-style: none;
  display: inline-flex;
  align-items: center;
  gap: var(--chevron-gap);
  cursor: pointer;
  color: inherit;
}
summary::-webkit-details-marker,
summary::marker {
  display: none;
  content: "";
}
summary::after {
  content: "";
  flex: 0 0 auto;
  width: 12px;
  height: 8px;
  background-color: currentColor;
  -webkit-mask: var(--chevron-mask) center / contain no-repeat;
  mask: var(--chevron-mask) center / contain no-repeat;
  transition: transform 0.15s ease;
}
details[open] > summary::after {
  transform: rotate(180deg);
}

/* Shared action and form controls. */
.btn, button.btn,
input:not([type="checkbox"]):not([type="radio"]):not([type="range"]):not([type="file"]):not([type="hidden"]),
select,
textarea {
  border: 1px solid var(--surface-line);
  border-radius: var(--radius);
  outline: none;
  box-shadow: none;
  box-sizing: border-box;
}
/* Single-line controls share --control-h; textarea stays multi-line. */
.btn, button.btn,
input:not([type="checkbox"]):not([type="radio"]):not([type="range"]):not([type="hidden"]),
select {
  height: var(--control-h);
  min-height: var(--control-h);
  max-height: var(--control-h);
}
.btn, button.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--chevron-gap);
  min-width: 5.5rem; padding: 0 16px;
  text-decoration: none; font-weight: 600; font-size: var(--font-btn); line-height: 1.2;
  font-family: inherit; cursor: pointer;
  background: var(--bg-card);
  color: var(--accent-primary);
  transition: background-color 0.18s ease, color 0.18s ease, box-shadow 0.18s ease;
}
.btn:hover, button.btn:hover {
  background: var(--ix-bg);
  color: var(--ix-fg);
  border-color: var(--surface-line);
  box-shadow: none;
  text-shadow: none;
  transform: none;
}
.btn:focus-visible, button.btn:focus-visible {
  outline: 2px solid var(--accent-primary);
  outline-offset: 2px;
}
.btn.ghost, button.btn.ghost {
  background: transparent;
  color: var(--accent-primary);
  border-color: var(--surface-line);
}
.btn.ghost:hover, button.btn.ghost:hover {
  background: var(--ix-bg);
  color: var(--ix-fg);
  border-color: var(--surface-line);
  box-shadow: none;
  text-shadow: none;
  transform: none;
}
.btn.primary, button.btn.primary {
  background: var(--action-fill);
  color: var(--action-fg);
  border-color: transparent;
  box-shadow: var(--action-shadow);
}
.btn.primary:hover:not(:disabled), button.btn.primary:hover:not(:disabled) {
  background: var(--action-hover);
  color: var(--action-fg);
  border-color: transparent;
  box-shadow: var(--action-shadow);
}
.btn:active:not(:disabled):not([aria-disabled="true"]),
.xk-select-btn:active:not(:disabled) {
  filter: brightness(.9);
}

button[data-tooltip] { position: relative; overflow: visible; }
button[data-tooltip]::after {
  content: attr(data-tooltip);
  display: none;
  position: absolute;
  z-index: 2;
  inset-inline-end: 0;
  bottom: calc(100% + 6px);
  width: max-content;
  max-width: 11rem;
  padding: 6px 9px;
  background: var(--menu-bg);
  color: var(--text-main);
  border: 1px solid var(--surface-line);
  border-radius: var(--radius);
  box-shadow: var(--pop-shadow);
  font: 500 .8125rem/1.4 var(--font-ui);
  white-space: normal;
  overflow-wrap: anywhere;
  pointer-events: none;
}
button[data-tooltip]:is(:hover,:focus-visible)::after { display: block; }

.btn.primary:disabled, button.btn.primary:disabled {
  background: var(--bg-hover);
  color: var(--text-muted);
  border-color: var(--surface-line);
  box-shadow: none;
  opacity: 0.75;
}

.btn.danger, button.btn.danger {
  color: var(--danger);
  border-color: var(--surface-line);
  background: transparent;
}
.btn.danger:hover, button.btn.danger:hover {
  color: var(--danger);
  background: var(--danger-soft);
  border-color: var(--surface-line);
  box-shadow: none;
  text-shadow: none;
  transform: none;
}
button:disabled, .btn:disabled {
  opacity: 0.45; cursor: not-allowed; transform: none; box-shadow: none;
}

/* —— Footer (one split layout site-wide: meta left, links right) —— */
.site-footer {
  flex: 0 0 auto;
  position: relative;
  z-index: 2;
  background: transparent;
  color: var(--text-muted);
  font-size: var(--font-footer);
  line-height: 1.35;
  padding: var(--footer-compact-pad-y) 32px;
  text-align: left;
  border-top: 1px solid var(--surface-line);
  background-color: var(--header-bg);
}
.footer-main,
.footer-main--split {
  display: flex;
  flex-direction: row;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.65rem 0.85rem;
  width: 100%;
}
.footer-main > :first-child { margin-top: 0; }
.footer-main > :last-child { margin-bottom: 0; }
.footer-main p,
.footer-main .footer-meta { margin: 0; }
.footer-meta {
  display: flex; gap: 0.65rem 0.85rem; align-items: center; flex-wrap: wrap;
}
.footer-links, .footer-nav, .footer-legal {
  display: flex; gap: 0.85rem; align-items: center; justify-content: flex-end; flex-wrap: wrap;
  margin: 0;
  font-size: var(--font-footer-link);
}
.footer-links a, .footer-nav a, .footer-legal a, #site-icp a, #site-police a, .site-footer a {
  color: var(--text-muted); text-decoration: none;
  outline: none; box-shadow: none;
}
/* Footer: own quiet hover — not page --ix-* pills. */
.footer-links a:hover, .footer-nav a:hover, .footer-legal a:hover, #site-icp a:hover, #site-police a:hover, .site-footer a:hover {
  color: var(--accent-primary);
  text-shadow: none;
  background: transparent;
}
.footer-links a:focus-visible, .footer-nav a:focus-visible, .footer-legal a:focus-visible,
#site-icp a:focus-visible, #site-police a:focus-visible, .site-footer a:focus-visible {
  color: var(--accent-primary); box-shadow: var(--focus-ring-on-dark);
}
#site-police a {
  display: inline-flex; align-items: center; gap: 0.28em;
}
.beian-police-icon {
  width: 16px; height: 17px;
  object-fit: contain;
  flex: 0 0 auto;
  vertical-align: -0.15em;
}
/* Keep class for existing markup; layout is already the unified split. */
.site-footer--compact {
  padding-block: var(--footer-compact-pad-y);
  line-height: 1.35;
}
/* —— Forms (chrome + height shared with .btn above) —— */
label { display: grid; gap: 6px; font-size: 0.9rem; color: var(--text-muted); flex: 1; min-width: 160px; }
input:not([type="checkbox"]):not([type="radio"]):not([type="range"]):not([type="file"]):not([type="hidden"]),
select,
textarea {
  background: var(--input-bg);
  color: var(--text-main);
  font: inherit;
  font-size: var(--font-btn);
  line-height: 1.2;
  transition: background 0.2s, color 0.2s;
}
input:not([type="checkbox"]):not([type="radio"]):not([type="range"]):not([type="file"]):not([type="hidden"]),
select {
  padding: 0 16px;
}
textarea {
  height: auto;
  min-height: 6rem;
  max-height: none;
  padding: 12px 16px;
  line-height: 1.5;
}
select {
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  /* Keep chevron clear of the right edge (match left padding rhythm). */
  padding-right: 2.75rem;
  background-color: var(--input-bg);
  background-image: var(--select-chevron);
  background-repeat: no-repeat;
  background-position: right 1rem center;
  background-size: 12px 8px;
  cursor: pointer;
}
/* Custom select — same trigger chrome as native select; popup is .xk-select-menu */
.xk-select {
  position: relative;
  display: block;
  width: 100%;
  min-width: 0;
}
.xk-select-native {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
  opacity: 0 !important;
  pointer-events: none !important;
}
.xk-select-btn {
  display: inline-flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--chevron-gap);
  width: 100%;
  box-sizing: border-box;
  height: var(--control-h);
  min-height: var(--control-h);
  max-height: var(--control-h);
  margin: 0;
  padding: 0 2.75rem 0 16px;
  border: 1px solid var(--surface-line);
  border-radius: var(--radius);
  background: var(--input-bg);
  color: var(--text-main);
  font: inherit;
  font-size: var(--font-btn);
  line-height: 1.2;
  text-align: left;
  cursor: pointer;
  outline: none;
  box-shadow: none;
  appearance: none;
  -webkit-appearance: none;
}
.xk-select-btn:hover,
.xk-select-btn:focus-visible {
  color: var(--ix-fg);
  background: var(--ix-bg);
  border-color: var(--surface-line);
  box-shadow: none;
  text-shadow: none;
}
/* Open menu: keep resting input chrome — selection highlight belongs in the list. */
.xk-select-btn[aria-expanded="true"] {
  color: var(--text-main);
  background: var(--input-bg);
  border-color: var(--surface-line);
  box-shadow: none;
  text-shadow: none;
}
.xk-select.is-disabled .xk-select-btn,
.xk-select-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  color: var(--text-main);
  background: var(--input-bg);
}
.xk-select-label {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.xk-select-chevron {
  position: absolute;
  right: 1rem;
  top: 50%;
  width: 12px;
  height: 8px;
  transform: translateY(-50%);
  background-color: currentColor;
  -webkit-mask: var(--chevron-mask) center / contain no-repeat;
  mask: var(--chevron-mask) center / contain no-repeat;
  pointer-events: none;
}
.xk-select-btn { position: relative; }
/* Header / footer keep their own compact controls */
.xk-site-header .btn, .xk-site-header button.btn,
.xk-site-header input, .xk-site-header select,
.site-footer .btn, .site-footer button.btn,
.top .btn, .topbar .btn {
  height: auto;
  min-height: 0;
  max-height: none;
}
input::placeholder,
textarea::placeholder {
  color: var(--text-placeholder);
  font-size: max(.75rem, calc(1em - .125rem));
  font-weight: 400;
  opacity: 1;
}
input:not([type="checkbox"]):not([type="radio"]):not([type="range"]):not([type="file"]):focus,
select:focus, textarea:focus {
  border-color: var(--accent-primary);
}
.xk-select-btn:focus-visible {
  outline: 2px solid var(--accent-primary);
  outline-offset: 2px;
}
option { background: var(--bg-card); color: var(--text-main); }

/* Checkbox / radio — theme tokens (native OS chrome ignores --surface-line / accent). */
input[type="checkbox"],
input[type="radio"] {
  appearance: none;
  -webkit-appearance: none;
  box-sizing: border-box;
  width: 1.125rem;
  height: 1.125rem;
  margin: 0;
  padding: 0;
  flex: 0 0 auto;
  vertical-align: middle;
  cursor: pointer;
  border: 1.5px solid color-mix(in srgb, var(--text-muted) 75%, var(--surface-line));
  background-color: color-mix(in srgb, var(--input-bg) 70%, transparent);
  background-position: center;
  background-repeat: no-repeat;
  background-size: 78% 78%;
  accent-color: var(--accent-primary);
  color: var(--accent-primary);
  box-shadow: none;
  outline: none;
  transition: background-color 0.15s, border-color 0.15s;
}
input[type="checkbox"] {
  border-radius: 5px;
}
input[type="radio"] {
  border-radius: 50%;
}
input[type="checkbox"]:checked {
  background-color: #0069d9;
  border-color: transparent;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath fill='none' stroke='%23fff' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round' d='M3.5 8.5l3 3 6-6'/%3E%3C/svg%3E");
}
input[type="radio"]:checked {
  border-color: var(--accent-primary);
  padding: 0.25rem;
  background-color: var(--accent-primary);
  background-clip: content-box;
}
input[type="checkbox"]:hover:not(:checked),
input[type="radio"]:hover:not(:checked) {
  border-color: color-mix(in srgb, var(--accent-primary) 55%, var(--surface-line));
}
input[type="checkbox"]:focus-visible,
input[type="radio"]:focus-visible {
  border-color: var(--surface-line);
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent-primary) 40%, transparent);
}
input[type="checkbox"]:disabled,
input[type="radio"]:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

/* File / progress / range / autofill / search — same theme tokens as text fields. */
input[type="file"] {
  display: block;
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  border: 1px solid var(--surface-line);
  border-radius: var(--radius);
  background: var(--input-bg);
  color: var(--text-main);
  font: inherit;
  font-size: var(--font-btn);
  line-height: 1.2;
  cursor: pointer;
  outline: none;
  box-shadow: none;
}
input[type="file"]::file-selector-button {
  height: 100%;
  margin: 0 12px 0 0;
  padding: 0 16px;
  border: 0;
  border-right: 1px solid var(--surface-line);
  border-radius: var(--radius) 0 0 var(--radius);
  background: transparent;
  color: var(--accent-primary);
  font: inherit;
  font-size: var(--font-btn);
  font-weight: 500;
  cursor: pointer;
}
input[type="file"]::file-selector-button:hover {
  background: var(--ix-bg);
  color: var(--ix-fg);
}
/* Overlay pickers keep the native control invisible (avatar / comment image). */
.upload-avatar input[type="file"],
.comment-image-label input[type="file"] {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  min-height: 0;
  max-height: none;
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 0;
  opacity: 0;
  background: transparent;
  cursor: pointer;
  font-size: 0;
}
.upload-avatar input[type="file"]::file-selector-button,
.comment-image-label input[type="file"]::file-selector-button {
  display: none;
}

progress {
  appearance: none;
  -webkit-appearance: none;
  display: block;
  width: 100%;
  height: 8px;
  border: 0;
  border-radius: var(--pill-radius);
  overflow: hidden;
  background: var(--progress-track);
  box-shadow: inset 0 1px 2px var(--shadow-color);
  accent-color: var(--accent-primary);
  vertical-align: middle;
}
progress::-webkit-progress-bar {
  background: transparent;
  border-radius: var(--pill-radius);
}
progress::-webkit-progress-value {
  background: var(--progress-fill);
  border-radius: var(--pill-radius);
}
progress::-moz-progress-bar {
  background: var(--progress-fill);
  border-radius: var(--pill-radius);
}
progress[hidden] { display: none !important; }

input[type="range"] {
  width: 100%;
  height: 1.25rem;
  margin: 0;
  accent-color: var(--accent-primary);
  background: transparent;
  cursor: pointer;
}

input:-webkit-autofill,
input:-webkit-autofill:hover,
input:-webkit-autofill:focus,
textarea:-webkit-autofill,
textarea:-webkit-autofill:hover,
textarea:-webkit-autofill:focus,
select:-webkit-autofill,
select:-webkit-autofill:hover,
select:-webkit-autofill:focus {
  -webkit-text-fill-color: var(--text-main);
  caret-color: var(--text-main);
  box-shadow: 0 0 0 1000px var(--input-bg) inset;
  transition: background-color 99999s ease-out;
}

input[type="search"] {
  -webkit-appearance: none;
  appearance: none;
}
input[type="search"]::-webkit-search-decoration {
  -webkit-appearance: none;
}
input[type="search"]::-webkit-search-cancel-button {
  cursor: pointer;
  filter: invert(0.55);
}
html[data-theme="light"] input[type="search"]::-webkit-search-cancel-button {
  filter: none;
}

.xk-page-bg {
  position: relative;
  isolation: isolate;
  background-color: var(--bg-body);
}
/* Shared dialog surface and actions. */
html:has(dialog.xk-modal-card[open]) { overflow: hidden; }
dialog.xk-modal-card {
  position: fixed;
  inset: 0;
  margin: auto;
  width: min(26rem, calc(100% - 32px));
  max-height: calc(100dvh - 32px);
  overflow: auto;
  padding: 24px;
  color: var(--text-main);
  background: var(--bg-card);
  border: 1px solid var(--surface-line);
  border-radius: var(--card-radius);
  box-shadow: var(--pop-shadow);
  font: 400 14px/1.5 -apple-system, BlinkMacSystemFont, var(--font-ui);
  overflow-wrap: anywhere;
}
dialog.xk-modal-wide { width: min(42rem, calc(100% - 32px)); }
dialog.xk-modal-card::backdrop { background: var(--modal-backdrop); }
:is(.xk-modal-card, .xk-pop) .xk-modal-title {
  margin: 0;
  color: var(--text-main);
  font-family: var(--font-ui);
  font-size: 16px;
  font-weight: 600;
  line-height: 1.3;
}
:is(.xk-modal-card, .xk-pop) .xk-modal-body {
  margin: 8px 0 0;
  color: var(--text-muted);
  font-size: 14px;
  line-height: 1.5;
  white-space: pre-line;
}
:is(.xk-modal-card, .xk-pop) .xk-modal-actions {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: minmax(80px, 1fr);
  gap: 8px;
  width: fit-content;
  max-width: 100%;
  margin-block-start: 16px;
  margin-inline-start: auto;
}
:is(.xk-modal-card, .xk-pop) .xk-modal-actions > .btn {
  min-width: 80px;
  min-height: var(--control-h-compact);
  height: auto;
  max-height: none;
  padding: 4px 12px;
  border: 0;
  border-radius: var(--radius-compact);
  box-shadow: none;
  overflow-wrap: anywhere;
  white-space: normal;
  font: 600 var(--font-btn)/1.25 var(--font-ui);
}
.xk-modal-card .xk-modal-actions > .ghost { background: var(--input-bg); color: var(--text-main); }
.xk-modal-card .xk-modal-actions > .ghost:hover:not(:disabled) { background: var(--bg-hover); }
.xk-modal-card .xk-modal-actions > .danger { background: var(--danger-soft); color: var(--danger); }
.xk-modal-card .xk-modal-actions > .danger:hover:not(:disabled) {
  background: color-mix(in srgb, var(--danger) 20%, var(--bg-card));
}
:is(.xk-modal-card, .xk-pop) .xk-modal-actions > .primary:not(:disabled):hover { box-shadow: none; }
.xk-modal-card .xk-modal-field { margin: 12px 0 0; }
.xk-modal-card .xk-modal-label { display: block; margin-bottom: 4px; color: var(--text-muted); }
.xk-modal-card .xk-modal-input {
  display: block;
  width: 100%;
  min-height: var(--control-h-touch);
  padding: 8px 10px;
  border: 1px solid var(--surface-line);
  border-radius: 10px;
  background: var(--input-bg);
  color: var(--text-main);
  font: inherit;
}
.xk-modal-card input.xk-modal-input { margin-block-start: 12px; max-height: none; }
.xk-modal-card .xk-modal-field input.xk-modal-input { margin-block-start: 0; }
.xk-modal-card textarea.xk-modal-input { resize: vertical; }
.xk-modal-card .xk-modal-input:focus-visible {
  outline: 2px solid var(--accent-primary);
  outline-offset: 2px;
}
@media (max-width: 280px) {
  :is(.xk-modal-card, .xk-pop) .xk-modal-actions { grid-auto-flow: row; width: 100%; }
}

@media (max-width: 560px) {
  .top, .topbar { padding: 0 16px; }
  .brand { font-size: 18px; }
  .site-footer { padding-inline: 16px; }
  .btn { padding-inline: 14px; }
}

@media (prefers-reduced-motion: reduce) {
  .btn, .top-link, .lang-switch-btn, summary::after {
    transition: none;
  }
}

@media (forced-colors: active) {
  input[type="checkbox"], input[type="radio"], progress {
    appearance: auto;
  }
}

.repository-fields {
  border: 0;
  margin: 12px 0;
  padding: 0;
  min-width: 0;
  display: grid;
  gap: 8px;
}
.repository-fields input[type="url"] {
  display: block;
  width: 100%;
  margin-top: 4px;
}
.repository-fields .repository-switch {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: var(--control-h-touch);
}
.repository-switch input[role="switch"] {
  appearance: none;
  flex: none;
  position: relative;
  margin: 0;
  width: 42px;
  height: 25px;
  padding: 0;
  border: 1px solid var(--surface-line);
  border-radius: 999px;
  background: var(--progress-track);
  cursor: pointer;
}
.repository-switch input[role="switch"]::after {
  content: "";
  position: absolute;
  inset: 2px auto 2px 2px;
  aspect-ratio: 1;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 3px rgb(0 0 0 / 24%);
}
.repository-switch input[role="switch"]:checked {
  background: var(--accent-primary);
}
.repository-switch input[role="switch"]:checked::after {
  left: auto;
  right: 2px;
}

/* Shared password controls for login, account and service forms. */
.password-field { display: grid; gap: 6px; flex: 1 1 180px; min-width: 0; }
.password-field label { min-width: 0; }
.password-control { position: relative; }
.password-control > input {
  width: 100%;
  padding-inline-end: calc(var(--control-h) + .5rem);
}
.password-control > input::-ms-reveal { display: none; }
.password-control > .password-toggle {
  position: absolute;
  inset-block: 1px;
  inset-inline-end: 1px;
  width: var(--control-h);
  display: grid;
  place-items: center;
  padding: 0;
  border: 0;
  border-radius: var(--radius);
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
}
.password-control > .password-toggle:hover { background: var(--ix-bg); color: var(--ix-fg); }
.password-control > .password-toggle:focus-visible { outline: 2px solid var(--accent-primary); outline-offset: -3px; }
.password-control > .password-toggle svg {
  width: 1.125rem;
  height: 1.125rem;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.75;
  stroke-linecap: round;
  stroke-linejoin: round;
}
/* The artwork shows the current visibility; the label describes the next action. */
.password-control > input[type="password"] + .password-toggle .password-icon-show,
.password-control > input[type="text"] + .password-toggle .password-icon-hide { display: none; }
