/* =====================================================================
   docs · design system
   One set of tokens, one radius scale, one shadow scale, one focus style.
   ===================================================================== */

:root {
  --bg: #f7f6f3;
  --surface: #ffffff;
  --surface-2: #f1efea;
  --surface-3: #e9e6df;
  --text: #1d1c1a;
  --text-2: #4a4843;
  --muted: #74706a;
  --border: #e4e1da;
  --border-strong: #cfcac0;
  --accent: #0f6e5a;
  --accent-hover: #0b5a49;
  --accent-soft: #e3f1ec;
  --accent-text: #0b5a49;
  --on-accent: #ffffff;
  --danger: #b42318;
  --danger-soft: #fdecea;
  --warn: #9a6a00;
  --warn-soft: #fff4d6;
  --info: #3b5bc4;
  --info-soft: #e8edfb;
  --pdf: #b4441f;
  --pdf-soft: #fbeae3;

  --radius-xs: 6px;
  --radius-sm: 8px;
  --radius: 12px;
  --radius-lg: 16px;
  --shadow-sm: 0 1px 2px rgba(28, 25, 20, .05);
  --shadow: 0 1px 2px rgba(28, 25, 20, .04), 0 4px 14px rgba(28, 25, 20, .05);
  --shadow-lg: 0 12px 40px rgba(20, 18, 10, .18);
  --ring: 0 0 0 3px color-mix(in srgb, var(--accent) 28%, transparent);
  --ease: cubic-bezier(.2, .7, .3, 1);

  --font-ui: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-read: "Source Serif 4", Georgia, "Times New Roman", serif;
  --font-mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace;

  --topbar-h: 58px;
  --gutter: 20px;
  --logo-main: #0f6e5a; --logo-deep: #0a5646; --logo-light: #3db89a;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #121311; --surface: #1a1c19; --surface-2: #222521; --surface-3: #2b2e2a;
    --text: #ecebe6; --text-2: #c7c5be; --muted: #95928a; --border: #2c2f2b; --border-strong: #40443e;
    --accent: #3fbf9b; --accent-hover: #5fd3b1; --accent-soft: #15302a; --accent-text: #6fdcbc; --on-accent: #06231b;
    --danger: #f2766b; --danger-soft: #3a1d1a; --warn: #e8b84a; --warn-soft: #36301b; --info: #8ea6f2; --info-soft: #1f2741;
    --pdf: #f08c64; --pdf-soft: #3a231a;
  --logo-main: #3fbf9b; --logo-deep: #2e9f80; --logo-light: #9be6cf;
    --shadow-sm: 0 1px 2px rgba(0,0,0,.3); --shadow: 0 1px 2px rgba(0,0,0,.3), 0 4px 14px rgba(0,0,0,.25);
    --shadow-lg: 0 12px 40px rgba(0,0,0,.6); color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #121311; --surface: #1a1c19; --surface-2: #222521; --surface-3: #2b2e2a;
  --text: #ecebe6; --text-2: #c7c5be; --muted: #95928a; --border: #2c2f2b; --border-strong: #40443e;
  --accent: #3fbf9b; --accent-hover: #5fd3b1; --accent-soft: #15302a; --accent-text: #6fdcbc; --on-accent: #06231b;
  --danger: #f2766b; --danger-soft: #3a1d1a; --warn: #e8b84a; --warn-soft: #36301b; --info: #8ea6f2; --info-soft: #1f2741;
  --pdf: #f08c64; --pdf-soft: #3a231a;
  --logo-main: #3fbf9b; --logo-deep: #2e9f80; --logo-light: #9be6cf;
  --shadow-sm: 0 1px 2px rgba(0,0,0,.3); --shadow: 0 1px 2px rgba(0,0,0,.3), 0 4px 14px rgba(0,0,0,.25);
  --shadow-lg: 0 12px 40px rgba(0,0,0,.6); color-scheme: dark;
}

/* ---------------------------------------------------------------- base */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-padding-top: calc(var(--topbar-h) + 20px); }
body { margin: 0; min-height: 100vh; display: flex; flex-direction: column; background: var(--bg); color: var(--text);
  font: 15px/1.55 var(--font-ui); -webkit-font-smoothing: antialiased; overflow-x: hidden; }
main { flex: 1; width: 100%; }
a { color: var(--accent-text); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 3px; }
img { max-width: 100%; height: auto; }
code, kbd, pre { font-family: var(--font-mono); }
hr { border: 0; border-top: 1px solid var(--border); margin: 24px 0; }
h1, h2, h3, h4 { line-height: 1.25; margin: 0 0 .5em; letter-spacing: -.01em; }
p { margin: 0 0 1em; }
[hidden] { display: none !important; }
:focus { outline: none; }
:focus-visible { outline: none; box-shadow: var(--ring); border-radius: var(--radius-xs); }
::selection { background: color-mix(in srgb, var(--accent) 25%, transparent); }
.icon { flex: none; vertical-align: -.18em; }
.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; }

.container { width: 100%; max-width: 1120px; margin: 0 auto; padding: 32px var(--gutter) 64px; }
.container-wide { max-width: 1280px; }
.narrow { max-width: 680px; }
.center { text-align: center; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.right { text-align: right; }
.spacer { flex: 1; }
.pad { padding: 16px 20px; margin: 0; }
.row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.row-between { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; flex-wrap: wrap; }
.stack { display: grid; gap: 14px; }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 20px; }
.grid-2.gap-lg { gap: 20px; }
.field-wide { grid-column: 1 / -1; }

/* ---------------------------------------------------------------- page header */
.page-head { margin-bottom: 24px; }
.page-head h1 { font-size: 28px; margin: 4px 0 6px; }
.page-head p { margin: 0; }
.page-head.row-between { align-items: flex-end; }
.eyebrow { display: inline-flex; align-items: center; gap: 6px; margin: 0; font-size: 12px; font-weight: 700;
  letter-spacing: .1em; text-transform: uppercase; color: var(--accent-text); }
.back { display: inline-flex; align-items: center; gap: 6px; font-size: 14px; color: var(--muted); font-weight: 500; }
.back:hover { color: var(--text); text-decoration: none; }
.section-title { font-size: 15px; font-weight: 700; margin: 0 0 12px; }

/* ---------------------------------------------------------------- top bar */
.topbar { position: sticky; top: 0; z-index: 40; height: var(--topbar-h);
  background: color-mix(in srgb, var(--bg) 86%, transparent); backdrop-filter: saturate(1.4) blur(10px);
  border-bottom: 1px solid var(--border); }
.topbar-inner { max-width: 1280px; height: 100%; margin: 0 auto; padding: 0 var(--gutter); display: flex; align-items: center; gap: 14px; }
.brand { display: flex; align-items: center; gap: 10px; color: var(--text); font-weight: 700; font-size: 16px; letter-spacing: -.02em; flex: none; }
.brand:hover { text-decoration: none; }
.brand-mark { display: grid; place-items: center; width: 32px; height: 32px; border-radius: 9px; background: var(--accent); color: var(--on-accent); }
/* logo: symbol + divider + wordmark; the SVG keeps its own aspect ratio (viewBox 490x345) */
.brand-logo { display: block; height: 28px; width: auto; aspect-ratio: 490 / 345; flex: none; }
.brand-divider { width: 1.5px; height: 22px; border-radius: 1px; background: var(--logo-main); opacity: .9; flex: none; }
.brand-word { color: var(--logo-main); font-size: 21px; font-weight: 700; letter-spacing: -.035em; line-height: 1; padding-bottom: 2px; }
.search-trigger { display: flex; align-items: center; gap: 8px; flex: 0 1 280px; min-width: 0; height: 36px; padding: 0 10px;
  border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface); color: var(--muted);
  font: inherit; font-size: 14px; cursor: pointer; text-align: left; transition: border-color .15s var(--ease); }
.search-trigger:hover { border-color: var(--border-strong); }
.search-trigger span { flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
kbd { font-size: 11px; padding: 2px 6px; border: 1px solid var(--border); border-bottom-width: 2px; border-radius: 5px;
  background: var(--surface-2); color: var(--muted); font-family: var(--font-ui); }
.nav { display: flex; gap: 2px; min-width: 0; }
.nav a { display: inline-flex; align-items: center; gap: 6px; height: 34px; padding: 0 10px; border-radius: var(--radius-sm);
  color: var(--text-2); font-weight: 500; font-size: 14px; white-space: nowrap; transition: background .15s var(--ease), color .15s var(--ease); }
.nav a:hover { background: var(--surface-2); color: var(--text); text-decoration: none; }
.nav a.active { color: var(--text); background: var(--surface-2); }
.topbar-actions { margin-left: auto; display: flex; align-items: center; gap: 4px; flex: none; }
.nav-toggle { display: none; }
.nav { overflow: hidden; flex: 1 1 auto; }
.nav a { flex: none; }
.nav-more { position: relative; flex: none; }
.nav-more summary { display: inline-flex; align-items: center; gap: 4px; height: 34px; padding: 0 10px; border-radius: var(--radius-sm); color: var(--text-2); font-size: 14px; font-weight: 500; cursor: pointer; list-style: none; }
.nav-more summary::-webkit-details-marker { display: none; }
.nav-more summary:hover, .nav-more[open] summary { background: var(--surface-2); color: var(--text); }
.nav-more.has-active summary { color: var(--text); background: var(--surface-2); }
.nav-more-menu { position: fixed; z-index: 70; min-width: 180px; padding: 6px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow-lg); display: flex; flex-direction: column; }
.nav-more-menu a { width: 100%; }

.icon-btn { position: relative; display: inline-grid; place-items: center; width: 36px; height: 36px; padding: 0;
  border: 0; border-radius: var(--radius-sm); background: transparent; color: var(--text-2); cursor: pointer;
  transition: background .15s var(--ease), color .15s var(--ease); }
.icon-btn:hover { background: var(--surface-2); color: var(--text); text-decoration: none; }
.icon-btn:disabled { opacity: .45; cursor: not-allowed; }
.i-moon { display: none; }
:root[data-theme="dark"] .i-sun { display: none; }
:root[data-theme="dark"] .i-moon { display: inline; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .i-sun { display: none; }
  :root:not([data-theme="light"]) .i-moon { display: inline; }
}
.count-badge { position: absolute; top: 3px; right: 2px; min-width: 17px; height: 17px; padding: 0 5px; border-radius: 999px;
  background: var(--danger); color: #fff; font-size: 10.5px; font-weight: 700; line-height: 17px; text-align: center;
  box-shadow: 0 0 0 2px var(--bg); }

/* avatar + user menu */
.avatar { display: inline-grid; place-items: center; width: 34px; height: 34px; border-radius: 50%; flex: none;
  background: var(--accent-soft); color: var(--accent-text); font-weight: 700; font-size: 12.5px; user-select: none; }
.avatar-xs { width: 22px; height: 22px; font-size: 9.5px; }
.avatar-sm { width: 30px; height: 30px; font-size: 11px; }
.avatar-lg { width: 44px; height: 44px; font-size: 15px; }
.avatar-xl { width: 84px; height: 84px; font-size: 30px; }
.avatar { overflow: hidden; }
.avatar img { display: block; width: 100%; height: 100%; object-fit: cover; }
.avatar-card { display: flex; align-items: center; gap: 18px; padding: 18px 20px; margin-bottom: 16px; }
.avatar-card h3 { margin: 0 0 2px; font-size: 15px; }
.avatar-card p { margin: 0 0 10px; font-size: 13px; }
.avatar-card-body { min-width: 0; }
.avatar-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.avatar-actions label.btn { cursor: pointer; }
.avatar-actions label.btn:focus-within { outline: 2px solid var(--accent); outline-offset: 2px; }
.drawer-install { display: flex; align-items: center; gap: 12px; width: 100%; padding: 10px 12px; border: 0; border-radius: var(--radius-sm); background: var(--accent-soft); color: var(--accent-text); font: inherit; font-weight: 600; cursor: pointer; margin-top: 8px; text-align: left; }
.ios-install { width: min(400px, calc(100vw - 32px)); }
.ios-install-body { padding: 22px 22px 6px; }
.ios-install-body h3 { margin: 0 0 10px; }
.ios-install-body ol { margin: 0 0 12px; padding-left: 20px; display: grid; gap: 8px; }
.ios-key { display: inline-flex; align-items: center; gap: 4px; padding: 1px 7px; border-radius: 6px; background: var(--surface-2); font-weight: 600; }
.push-ask { width: min(400px, calc(100vw - 24px)); }
.push-ask-body { padding: 26px 24px 4px; text-align: center; }
.push-ask-ico { display: inline-grid; place-items: center; width: 52px; height: 52px; border-radius: 50%; background: var(--accent-soft); color: var(--accent-text); margin-bottom: 12px; }
.push-ask-body h3 { margin: 0 0 8px; font-size: 18px; }
.push-ask-body p { margin: 0; color: var(--text-2); font-size: 14px; }
@media (max-width: 640px) {
  /* bottom sheet on phones */
  dialog.push-ask { margin: auto 0 0; width: 100vw; max-width: 100vw; border-radius: 18px 18px 0 0; padding-bottom: env(safe-area-inset-bottom); }
}
.push-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; margin-top: 4px; }
.push-state { display: inline-flex; align-items: center; gap: 6px; font-size: 13.5px; font-weight: 600; }
.push-state::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--muted); }
.push-state.on::before { background: var(--accent); }
.cropper { width: min(420px, calc(100vw - 24px)); }
.cropper-head { padding: 20px 22px 12px; }
.cropper-head h3 { margin: 0 0 4px; }
.cropper-head p { margin: 0; font-size: 13px; }
.crop-stage { position: relative; width: min(320px, calc(100vw - 72px)); aspect-ratio: 1; margin: 0 auto; overflow: hidden; border-radius: var(--radius); background: #111; touch-action: none; cursor: grab; user-select: none; }
.crop-stage.dragging { cursor: grabbing; }
.crop-stage img { position: absolute; left: 50%; top: 50%; max-width: none; transform-origin: 0 0; will-change: transform; pointer-events: none; }
.crop-ring { position: absolute; inset: 0; border-radius: 50%; box-shadow: 0 0 0 999px rgba(0, 0, 0, .55); outline: 2px solid rgba(255, 255, 255, .85); outline-offset: -2px; pointer-events: none; }
.crop-msg { position: absolute; inset: auto 12px 12px; margin: 0; padding: 8px 10px; border-radius: var(--radius-sm); background: rgba(0,0,0,.7); color: #fff; font-size: 12.5px; text-align: center; }
.crop-tools { display: flex; align-items: center; gap: 6px; padding: 12px 22px 0; }
.crop-tools input[type=range] { flex: 1; accent-color: var(--accent); }
@media (max-width: 640px) { .avatar-card { flex-direction: column; text-align: center; } .avatar-actions { justify-content: center; } }
.menu { position: relative; }
.menu > summary { list-style: none; cursor: pointer; border-radius: 50%; }
.menu > summary::-webkit-details-marker { display: none; }
.menu-pop { position: absolute; right: 0; top: calc(100% + 8px); width: 240px; padding: 6px; z-index: 60;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-lg);
  animation: pop .14s var(--ease); }
.menu-head { padding: 8px 10px 10px; margin-bottom: 4px; border-bottom: 1px solid var(--border); display: grid; }
.menu-head span { color: var(--muted); font-size: 12px; }
.menu-item { display: flex; align-items: center; gap: 10px; width: 100%; padding: 8px 10px; border: 0; border-radius: var(--radius-xs);
  background: none; color: var(--text); font: inherit; font-size: 14px; text-align: left; cursor: pointer; }
.menu-item .icon { color: var(--muted); }
.menu-item:hover { background: var(--surface-2); text-decoration: none; }
.menu-sep { height: 1px; background: var(--border); margin: 4px 0; }

/* mobile drawer */
.drawer { position: fixed; inset: 0; z-index: 90; display: none; }
.drawer.open { display: block; }
.drawer-backdrop { position: absolute; inset: 0; background: rgba(15, 14, 10, .45); animation: fade .15s ease; }
.drawer-panel { position: absolute; top: 0; left: 0; bottom: 0; width: min(300px, 86vw); padding: 14px; overflow-y: auto;
  background: var(--surface); border-right: 1px solid var(--border); box-shadow: var(--shadow-lg); animation: slide-in .18s var(--ease); }
.drawer-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.drawer-nav { display: grid; gap: 2px; }
.drawer-nav a { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: var(--radius-sm);
  color: var(--text); font-weight: 500; }
.drawer-nav a .icon { color: var(--muted); }
.drawer-nav a:hover, .drawer-nav a.active { background: var(--surface-2); text-decoration: none; }
@keyframes slide-in { from { transform: translateX(-16px); opacity: 0; } }
@keyframes fade { from { opacity: 0; } }
@keyframes pop { from { opacity: 0; transform: translateY(-4px) scale(.98); } }

/* ---------------------------------------------------------------- buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 7px; height: 38px; padding: 0 16px;
  border: 1px solid var(--border-strong); border-radius: var(--radius-sm); background: var(--surface); color: var(--text);
  font: inherit; font-weight: 600; font-size: 14px; line-height: 1; white-space: nowrap; cursor: pointer; text-decoration: none;
  transition: background .15s var(--ease), border-color .15s var(--ease), color .15s var(--ease), box-shadow .15s var(--ease); }
.btn:hover { background: var(--surface-2); text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn:disabled, .btn[aria-disabled="true"] { opacity: .55; cursor: not-allowed; transform: none; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn-ghost { background: transparent; border-color: transparent; color: var(--text-2); }
.btn-ghost:hover { background: var(--surface-2); color: var(--text); }
.btn-outline { background: transparent; }
.btn-danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn-danger:hover { background: color-mix(in srgb, var(--danger) 88%, black); }
.btn-danger-ghost { background: transparent; border-color: transparent; color: var(--danger); }
.btn-danger-ghost:hover { background: var(--danger-soft); }
.btn-sm { height: 32px; padding: 0 12px; font-size: 13px; gap: 6px; }
.btn-xs { height: 28px; padding: 0 9px; font-size: 12.5px; gap: 5px; border-radius: var(--radius-xs); }
.btn-icon { width: 32px; padding: 0; }
.btn-block { width: 100%; }
.btn.is-on { color: var(--warn); border-color: color-mix(in srgb, var(--warn) 40%, var(--border)); }
.btn.is-on .icon-star { fill: currentColor; }
.btn.is-loading { position: relative; color: transparent !important; pointer-events: none; }
.btn.is-loading::after { content: ""; position: absolute; width: 16px; height: 16px; border-radius: 50%;
  border: 2px solid currentColor; border-color: var(--on-accent) transparent var(--on-accent) transparent; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.danger-text { color: var(--danger); }

/* ---------------------------------------------------------------- forms */
.field { margin-bottom: 16px; }
.field > label, .label { display: block; margin-bottom: 6px; font-weight: 600; font-size: 13px; color: var(--text-2); }
.field .optional { color: var(--muted); font-weight: 400; }
input:not([type=checkbox]):not([type=radio]):not([type=file]):not([type=range]), select, textarea {
  width: 100%; min-height: 40px; padding: 9px 12px; border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  background: var(--surface); color: var(--text); font: inherit; font-size: 14px;
  transition: border-color .15s var(--ease), box-shadow .15s var(--ease); }
textarea { min-height: 96px; resize: vertical; line-height: 1.5; }
input::placeholder, textarea::placeholder { color: color-mix(in srgb, var(--muted) 80%, transparent); }
input:hover, select:hover, textarea:hover { border-color: color-mix(in srgb, var(--border-strong) 70%, var(--text)); }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: var(--ring); }
input:disabled, select:disabled, textarea:disabled { background: var(--surface-2); color: var(--muted); cursor: not-allowed; }
select { appearance: none; padding-right: 34px; cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2374706a' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 10px center; }
.input-lg { font-size: 18px !important; font-weight: 600; min-height: 48px !important; }
.hint { display: block; margin-top: 6px; color: var(--muted); font-size: 12.5px; }
.field-error { display: flex; align-items: center; gap: 6px; margin-top: 6px; color: var(--danger); font-size: 12.5px; font-weight: 500; }
.has-error input, .has-error textarea, .has-error select { border-color: var(--danger); }
.has-error input:focus, .has-error textarea:focus { box-shadow: 0 0 0 3px color-mix(in srgb, var(--danger) 25%, transparent); }
.counter { float: right; font-weight: 400; color: var(--muted); font-variant-numeric: tabular-nums; }
.form-card { padding: 24px; }
.form-actions { display: flex; justify-content: flex-end; align-items: center; gap: 10px; margin-top: 8px; flex-wrap: wrap; }
.form-section { padding-top: 18px; margin-top: 18px; border-top: 1px solid var(--border); }
.form-section h3 { font-size: 15px; margin-bottom: 4px; }
.form-section > p { color: var(--muted); font-size: 13px; }

/* checkbox */
.check { display: flex; align-items: flex-start; gap: 10px; margin: 0 0 14px; font-size: 14px; cursor: pointer; line-height: 1.4; }
.check input { appearance: none; flex: none; width: 18px; height: 18px; margin: 1px 0 0; border: 1.5px solid var(--border-strong);
  border-radius: 5px; background: var(--surface); cursor: pointer; display: grid; place-items: center;
  transition: background .15s var(--ease), border-color .15s var(--ease); }
.check input::after { content: ""; width: 10px; height: 6px; border: 2px solid var(--on-accent); border-top: 0; border-right: 0;
  transform: rotate(-45deg) translate(1px, -1px) scale(0); transition: transform .12s var(--ease); }
.check input:checked { background: var(--accent); border-color: var(--accent); }
.check input:checked::after { transform: rotate(-45deg) translate(1px, -1px) scale(1); }
.check input:focus-visible { box-shadow: var(--ring); }
.check input:disabled { opacity: .5; cursor: not-allowed; }

/* switch / toggle */
.switch-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 14px 0; border-top: 1px solid var(--border); cursor: pointer; }
.switch-row:first-of-type { border-top: 0; }
.switch-text { display: grid; gap: 2px; min-width: 0; }
.switch-text strong { font-size: 14px; font-weight: 600; }
.switch-text span { color: var(--muted); font-size: 13px; }
.switch { position: relative; flex: none; width: 40px; height: 22px; }
.switch input { position: absolute; inset: 0; opacity: 0; margin: 0; cursor: pointer; z-index: 1; }
.switch-track { position: absolute; inset: 0; border-radius: 999px; background: var(--surface-3); border: 1px solid var(--border-strong);
  transition: background .18s var(--ease), border-color .18s var(--ease); }
.switch-track::after { content: ""; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 50%;
  background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.25); transition: transform .18s var(--ease); }
.switch input:checked + .switch-track { background: var(--accent); border-color: var(--accent); }
.switch input:checked + .switch-track::after { transform: translateX(18px); }
.switch input:focus-visible + .switch-track { box-shadow: var(--ring); }
.switch input:disabled + .switch-track { opacity: .5; }

/* honeypot: present for bots, invisible and unreachable for people */
.hp { position: absolute !important; left: -9999px !important; width: 1px; height: 1px; overflow: hidden; }

/* ---------------------------------------------------------------- cards, panels, badges */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-sm); }
.panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px 18px; }
.panel-quiet { background: transparent; }
.panel-title { display: flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 700; text-transform: uppercase;
  letter-spacing: .08em; color: var(--muted); margin: 0 0 12px; }
.panel-link { display: inline-flex; align-items: center; gap: 4px; margin-top: 12px; font-size: 13px; font-weight: 600; }

.badge { display: inline-flex; align-items: center; gap: 4px; height: 22px; padding: 0 8px; border-radius: 999px;
  font-size: 11.5px; font-weight: 600; white-space: nowrap; background: var(--surface-2); color: var(--text-2); }
.badge .icon { width: 12px; height: 12px; }
.badge-pdf { background: var(--pdf-soft); color: var(--pdf); }
.badge-md { background: var(--info-soft); color: var(--info); }
.badge-ed, .badge-ok { background: var(--accent-soft); color: var(--accent-text); }
.badge-pin, .badge-warn { background: var(--warn-soft); color: var(--warn); }
.badge-share { background: var(--info-soft); color: var(--info); }
.badge-danger { background: var(--danger-soft); color: var(--danger); }
.role-admin { background: var(--accent-soft); color: var(--accent-text); }
.role-editor { background: var(--info-soft); color: var(--info); }
.role-contributor { background: var(--warn-soft); color: var(--warn); }
.role-reader { background: var(--surface-2); color: var(--text-2); }
.status { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; font-weight: 600; }
.status::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.status.ok { color: var(--accent-text); }
.status.off { color: var(--muted); }

.tags { display: flex; flex-wrap: wrap; gap: 6px; }
.tag { display: inline-flex; align-items: center; gap: 5px; height: 26px; padding: 0 10px; border: 1px solid transparent; border-radius: 999px;
  background: var(--surface-2); color: var(--text-2); font-size: 13px; font-weight: 500; transition: border-color .15s, color .15s; }
.tag:hover { text-decoration: none; border-color: var(--border-strong); color: var(--text); }
.tag.active { background: var(--accent); color: var(--on-accent); }
.tag .count { color: var(--muted); font-size: 11px; font-weight: 600; }
.tag.active .count { color: inherit; opacity: .8; }
.tag-btn { cursor: pointer; font: inherit; font-size: 12px; height: 24px; }
.tag-suggest { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 8px; }

.empty { display: grid; justify-items: center; gap: 6px; padding: 48px 20px; text-align: center; color: var(--text-2); }
.empty h3 { margin: 4px 0 0; font-size: 17px; }
.empty p { margin: 0; }
.empty-icon { display: grid; place-items: center; width: 52px; height: 52px; border-radius: 14px; background: var(--surface-2); color: var(--muted); margin-bottom: 6px; }
.empty.card { padding: 40px 20px; }

/* ---------------------------------------------------------------- flashes */
.flashes { position: fixed; top: calc(var(--topbar-h) + 12px); left: 50%; transform: translateX(-50%); z-index: 80;
  width: min(560px, calc(100vw - 2 * var(--gutter))); display: grid; gap: 8px; }
.flash { display: flex; align-items: flex-start; gap: 10px; padding: 12px 12px 12px 14px; border-radius: var(--radius); font-size: 14px;
  background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow-lg); animation: pop .2s var(--ease); }
.flash > .icon { margin-top: 1px; }
.flash-text { flex: 1; }
.flash-success { border-left: 3px solid var(--accent); }
.flash-success > .icon { color: var(--accent-text); }
.flash-error { border-left: 3px solid var(--danger); }
.flash-error > .icon { color: var(--danger); }
.flash .icon-btn { width: 26px; height: 26px; margin: -3px -2px 0 0; }

/* ---------------------------------------------------------------- tabs */
.tabs { display: inline-flex; gap: 3px; padding: 3px; background: var(--surface-2); border-radius: var(--radius-sm); margin-bottom: 16px; max-width: 100%; overflow-x: auto; }
.tab { display: inline-flex; align-items: center; gap: 6px; height: 32px; padding: 0 14px; border: 0; border-radius: 6px;
  background: transparent; color: var(--muted); font: inherit; font-weight: 600; font-size: 13.5px; white-space: nowrap; cursor: pointer; }
.tab:hover { color: var(--text); text-decoration: none; }
.tab.active { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm); }
.tab .count { font-size: 11.5px; color: var(--muted); font-weight: 600; }
.subnav { display: flex; gap: 4px; margin-top: 12px; border-bottom: 1px solid var(--border); overflow-x: auto; overflow-y: hidden; scrollbar-width: none; }
.subnav a { padding: 9px 12px; color: var(--muted); font-weight: 600; font-size: 14px; border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; }
.subnav a:hover { color: var(--text); text-decoration: none; }
.subnav a.active { color: var(--text); border-bottom-color: var(--accent); }

/* ---------------------------------------------------------------- tables & lists */
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th { text-align: left; font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted);
  font-weight: 600; padding: 11px 16px; border-bottom: 1px solid var(--border); white-space: nowrap; }
.table td { padding: 12px 16px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table tbody tr:hover td { background: color-mix(in srgb, var(--surface-2) 50%, transparent); }
.list-card { overflow: hidden; }
.list-card > h3 { display: flex; align-items: center; justify-content: space-between; font-size: 14px; margin: 0; padding: 14px 18px; border-bottom: 1px solid var(--border); }
.list-row { display: flex; justify-content: space-between; align-items: center; gap: 14px; padding: 12px 18px; border-bottom: 1px solid var(--border); color: var(--text); min-width: 0; }
.list-row:last-child { border-bottom: 0; }
a.list-row:hover, .list-row.active { background: var(--surface-2); text-decoration: none; }
.list-row > span:first-child { min-width: 0; }
.list-row > span:last-child { flex: none; }
.byline { display: inline-flex; align-items: center; gap: 8px; color: var(--text-2); font-weight: 500; min-width: 0; }
.byline:hover { text-decoration: none; color: var(--text); }
.who { display: grid; min-width: 0; line-height: 1.3; }
.who strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.who span { color: var(--muted); font-size: 12.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------------------------------------------------------------- feed */
.hero { display: flex; justify-content: space-between; align-items: flex-end; gap: 24px; margin-bottom: 28px; flex-wrap: wrap; }
.hero h1 { font-family: var(--font-read); font-size: 38px; font-weight: 700; margin: 6px 0 6px; letter-spacing: -.02em; }
.hero-sub { margin: 0; color: var(--muted); }
.upload-cta { display: flex; align-items: center; gap: 12px; padding: 12px 16px; border: 1.5px dashed var(--border-strong);
  border-radius: var(--radius); background: var(--surface); color: var(--text); transition: border-color .15s var(--ease); }
.upload-cta:hover { border-color: var(--accent); text-decoration: none; }
.upload-cta > .icon { color: var(--accent); }
.upload-cta span { display: grid; font-size: 14px; }
.upload-cta small { color: var(--muted); }
.filter-head { margin-bottom: 24px; }
.filter-head h1 { font-family: var(--font-read); font-size: 32px; margin: 6px 0 2px; }

.feed-layout { display: grid; grid-template-columns: minmax(0, 1fr) 280px; gap: 32px; align-items: start; }
.feed { display: grid; gap: 14px; min-width: 0; }
.feed-tabs { display: flex; gap: 3px; padding: 3px; background: var(--surface-2); border-radius: var(--radius-sm); justify-self: start; }
.feed-tab { display: inline-flex; align-items: center; gap: 7px; height: 32px; padding: 0 14px; border-radius: 6px; font-weight: 600; font-size: 13.5px; color: var(--muted); }
.feed-tab:hover { text-decoration: none; color: var(--text); }
.feed-tab.active { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm); }
.toolbar { display: flex; gap: 8px; }
.toolbar-search { flex: 1; min-width: 0; }
.toolbar select { width: auto; flex: none; }

.doc-card { position: relative; padding: 18px 20px; transition: border-color .15s var(--ease), box-shadow .15s var(--ease); }
.doc-card:hover { border-color: var(--border-strong); box-shadow: var(--shadow); }
.doc-card.is-pinned { border-left: 3px solid var(--warn); }
.doc-card-meta { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; margin-bottom: 8px; font-size: 13px; color: var(--muted); }
.doc-card-meta time { margin-left: 2px; }
.doc-card-title { font-family: var(--font-read); font-size: 21px; font-weight: 600; margin: 0 0 6px; overflow-wrap: anywhere; }
.doc-card-title a { color: var(--text); }
.doc-card-title a::after { content: ""; position: absolute; inset: 0; }
.doc-card-summary { margin: 0 0 12px; color: var(--text-2); display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.doc-card .tags, .doc-card .byline { position: relative; z-index: 1; }
.doc-card-foot { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-top: 12px; font-size: 13px; color: var(--muted); }
.doc-card-foot .stat { display: inline-flex; align-items: center; gap: 4px; }
.dot { color: var(--border-strong); }

.sidebar { position: sticky; top: calc(var(--topbar-h) + 18px); display: grid; gap: 14px; }
.pagination { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-top: 8px; font-size: 14px; }
.rm-mini { display: grid; gap: 1px; padding: 8px 0; border-bottom: 1px solid var(--border); color: var(--text); font-size: 13.5px; min-width: 0; }
.rm-mini:last-of-type { border-bottom: 0; }
.rm-mini:hover { text-decoration: none; color: var(--accent-text); }
.rm-mini span { display: flex; align-items: center; gap: 6px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rm-mini span .icon { color: var(--muted); }

/* ---------------------------------------------------------------- document */
.reading-progress { position: fixed; top: 0; left: 0; z-index: 60; height: 3px; width: 0; background: var(--accent); transition: width .1s linear; }
.doc-layout { display: grid; grid-template-columns: minmax(0, 760px) 240px; gap: 56px; justify-content: center; }
.doc-layout.no-toc { grid-template-columns: minmax(0, 760px); }
.doc { min-width: 0; }
.doc-header { margin-bottom: 32px; padding-bottom: 24px; border-bottom: 1px solid var(--border); }
.doc-title { font-family: var(--font-read); font-size: 40px; font-weight: 700; letter-spacing: -.02em; margin: 8px 0 12px; overflow-wrap: anywhere; }
.doc-lede { font-family: var(--font-read); font-size: 19px; color: var(--text-2); margin: 0 0 18px; }
.doc-byline { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; font-size: 14px; }
.doc-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-top: 18px; }
.share-line { display: flex; align-items: center; gap: 6px; margin: 12px 0 0; flex-wrap: wrap; }

.prose { font-family: var(--font-read); font-size: 18.5px; line-height: 1.72; color: var(--text); overflow-wrap: break-word; }
.prose > :first-child { margin-top: 0; }
.prose h1, .prose h2, .prose h3, .prose h4 { position: relative; font-family: var(--font-ui); font-weight: 700; margin: 1.8em 0 .6em; }
.prose h1 { font-size: 1.6em; }
.prose h2 { font-size: 1.35em; padding-bottom: .3em; border-bottom: 1px solid var(--border); }
.prose h3 { font-size: 1.12em; }
.prose h4 { font-size: 1em; }
.prose .header-anchor { position: absolute; left: -1.1em; padding-right: .3em; color: var(--border-strong); opacity: 0; font-weight: 400; text-decoration: none; }
.prose :is(h1, h2, h3, h4):hover .header-anchor { opacity: 1; }
.prose p, .prose ul, .prose ol, .prose blockquote, .prose table, .prose pre { margin: 0 0 1.15em; }
.prose a { text-decoration: underline; text-decoration-color: color-mix(in srgb, var(--accent) 40%, transparent); text-underline-offset: 3px; }
.prose ul, .prose ol { padding-left: 1.5em; }
.prose li { margin: .25em 0; }
.prose li > p { margin: 0; }
.prose .contains-task-list { list-style: none; padding-left: .3em; }
.prose .task-list-item-checkbox { margin-right: .5em; accent-color: var(--accent); }
.prose blockquote { padding: .7em 1.1em; border-left: 3px solid var(--accent); border-radius: 0 var(--radius-sm) var(--radius-sm) 0; background: var(--surface-2); color: var(--text-2); }
.prose blockquote > :last-child { margin-bottom: 0; }
.prose code { font-size: .84em; padding: .15em .4em; border: 1px solid var(--border); border-radius: 5px; background: var(--surface-2); }
.prose pre { position: relative; padding: 16px 18px; border-radius: 10px; background: #0d1117; color: #e6edf3; overflow-x: auto; font-size: 14px; line-height: 1.6; }
.prose pre code { padding: 0; border: 0; background: none; font-size: inherit; color: inherit; }
.chat-search { position: relative; margin-bottom: 14px; }
.chat-search input { padding-left: 38px !important; }
.search-hit .who > span { white-space: normal; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.search-hit mark { background: var(--warn-soft); color: inherit; padding: 0 2px; border-radius: 3px; }
.hit-who { font-weight: 600; color: var(--text-2); }
/* chat reactions */
.msg-reactions { display: flex; flex-wrap: wrap; gap: 4px; margin: 3px 4px 0; }
.msg-reactions:empty { display: none; }
.msg.mine .msg-reactions { justify-content: flex-end; }
.react-chip { display: inline-flex; align-items: center; gap: 4px; height: 24px; padding: 0 8px; border: 1px solid var(--border); border-radius: 999px; background: var(--surface); color: var(--text-2); font: inherit; font-size: 12px; font-weight: 600; cursor: pointer; }
.react-chip:hover { border-color: var(--border-strong); }
.react-chip.mine { border-color: var(--accent); background: var(--accent-soft); color: var(--accent-text); }
.react-picker { position: absolute; z-index: 30; display: flex; gap: 2px; padding: 5px; border: 1px solid var(--border); border-radius: 999px; background: var(--surface); box-shadow: var(--shadow-lg); animation: pop .14s var(--ease); }
.react-picker button { display: grid; place-items: center; width: 38px; height: 38px; border: 0; border-radius: 50%; background: transparent; color: var(--text-2); cursor: pointer; transition: transform .12s var(--ease), background .12s; }
.react-picker button:hover, .react-picker button:focus-visible { background: var(--surface-2); color: var(--accent-text); transform: scale(1.15); }
@media (min-width: 641px) { .chat-wrap { position: relative; } }  /* on phones it is position: fixed already */
/* comment threads */
.comment-thread { margin-bottom: 4px; }
.comment-body { min-width: 0; flex: 1; }
.comment-replies { margin-left: 44px; padding-left: 14px; border-left: 2px solid var(--border); }
.comment.is-reply .avatar { width: 26px; height: 26px; font-size: 10px; }
.reply-box { margin-top: 2px; }
.reply-box summary { display: inline-flex; align-items: center; gap: 5px; font-size: 13px; color: var(--muted); cursor: pointer; list-style: none; padding: 2px 0; }
.reply-box summary::-webkit-details-marker { display: none; }
.reply-box summary:hover, .reply-box[open] summary { color: var(--accent-text); }
.reply-form { margin-top: 8px; }
.reply-context { margin: 6px 0 8px; padding: 6px 10px; border-left: 3px solid var(--border-strong); background: var(--surface-2); border-radius: 6px; font-size: 13px; color: var(--text-2); }
.comment:target { animation: flash-msg 1.6s var(--ease); border-radius: var(--radius-sm); }
@media (max-width: 640px) { .comment-replies { margin-left: 14px; } }
/* two-step verification */
.otp-input { font-family: var(--font-mono); font-size: 20px !important; letter-spacing: .18em; text-align: center; }
.tfa-steps { margin: 0; padding-left: 20px; display: grid; gap: 18px; }
.tfa-qr { display: grid; place-items: center; margin: 14px auto 8px; }
.tfa-qr img { display: block; max-width: 100%; height: auto; border-radius: 8px; image-rendering: pixelated; }
.tfa-secret { font-size: 12.5px; word-break: break-all; }
.tfa-confirm { display: flex; gap: 8px; margin-top: 10px; max-width: 320px; }
.tfa-confirm input { flex: 1; min-width: 0; }
.tfa-on { display: inline-flex; align-items: center; gap: 6px; color: var(--accent-text); font-weight: 600; }
.tfa-row p { margin: 0; }
.tfa-help { margin: 14px 0 6px; font-size: 13.5px; }
.tfa-help summary { cursor: pointer; color: var(--accent-text); }
.recovery-codes { list-style: none; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; padding: 14px; margin: 12px 0; background: var(--surface-2); border-radius: var(--radius-sm); }
.recovery-codes code { font-size: 15px; letter-spacing: .04em; }
.notice-box { display: flex; align-items: center; gap: 10px; margin-bottom: 16px; padding: 12px 14px; border: 1px solid var(--warn); border-radius: var(--radius-sm); background: var(--warn-soft); font-size: 14px; }
/* chat: groups, replies, seen */
.msg-row { display: flex; align-items: center; gap: 4px; max-width: 100%; }
.msg.mine .msg-row { flex-direction: row-reverse; }
.msg { transition: transform .15s var(--ease); }
.msg-reply { flex: none; display: grid; place-items: center; width: 30px; height: 30px; border: 0; border-radius: 50%; background: transparent; color: var(--muted); cursor: pointer; opacity: 0; transition: opacity .15s; }
.msg:hover .msg-reply, .msg-reply:focus-visible { opacity: 1; }
.msg-reply:hover { background: var(--surface-2); color: var(--text); }
@media (hover: none) { .msg-reply { display: none; } }
.msg.swipe-ready .bubble { box-shadow: 0 0 0 2px var(--accent); }
.msg-author { margin: 6px 0 2px 10px; font-size: 12px; font-weight: 600; color: var(--accent-text); }
.msg-quote { display: flex; flex-direction: column; gap: 1px; width: 100%; margin: 0 0 4px; padding: 6px 10px; border: 0; border-left: 3px solid var(--accent); border-radius: 8px; background: color-mix(in srgb, var(--text) 6%, transparent); color: inherit; font: inherit; font-size: 13px; text-align: left; cursor: pointer; white-space: normal; }
.msg.mine .msg-quote { border-left-color: currentColor; background: color-mix(in srgb, #fff 18%, transparent); }
.msg-quote strong { font-size: 12px; }
.msg-quote span { opacity: .85; overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.msg-quote.is-gone { display: flex; flex-direction: row; align-items: center; gap: 6px; cursor: default; opacity: .7; font-style: italic; }
.bubble.has-media .msg-quote { margin: 0 0 4px; }
.msg-seen { display: inline-flex; align-items: center; gap: 4px; margin: 2px 6px 0; font-size: 11px; color: var(--accent-text); }
.msg.same .msg-time + .msg-seen, .msg-seen { align-self: flex-end; }
@keyframes flash-msg { 0%, 100% { background: transparent; } 30% { background: var(--accent-soft); } }
.msg.flash-msg { animation: flash-msg 1.4s var(--ease); border-radius: 12px; }
.chat-reply-bar { flex-basis: 100%; display: flex; align-items: center; gap: 10px; padding: 6px 8px 6px 12px; border-left: 3px solid var(--accent); border-radius: var(--radius-sm); background: var(--surface-2); font-size: 13px; min-width: 0; color: var(--accent-text); }
.chat-reply-bar .who { flex: 1; min-width: 0; display: flex; flex-direction: column; color: var(--text); }
.chat-reply-bar .who span { color: var(--text-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.avatar-group { background: var(--accent-soft); color: var(--accent-text); border-radius: 30%; }
.chat-settings { margin-left: auto; }
.chat-kind { display: inline-flex; align-items: center; gap: 3px; margin-left: 6px; font-size: 11.5px; font-weight: 500; color: var(--muted); }
.member-picker { position: relative; }
.member-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.member-chips:not(:empty) { margin-bottom: 8px; }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 3px 4px 3px 4px; border-radius: 999px; background: var(--accent-soft); color: var(--accent-text); font-size: 13px; font-weight: 600; }
.chip button { display: grid; place-items: center; width: 20px; height: 20px; border: 0; border-radius: 50%; background: transparent; color: inherit; cursor: pointer; font-size: 16px; line-height: 1; }
.chip button:hover { background: color-mix(in srgb, var(--accent) 20%, transparent); }
.member-list { list-style: none; margin: 0 0 14px; padding: 0; }
.member-list li { display: flex; align-items: center; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.member-list li:last-child { border-bottom: 0; }
.member-list .byline { flex: 1; min-width: 180px; }
.member-actions { display: flex; align-items: center; gap: 4px; }
.member-actions form { margin: 0; }
.member-add { display: flex; gap: 8px; align-items: flex-start; flex-wrap: wrap; }
.member-add .member-picker { flex: 1; min-width: 220px; }
.section-title { margin: 0 0 10px; font-size: 15px; }
/* reactions, ranking, collections */
.react-btn .react-count:empty { display: none; }
.react-count { font-variant-numeric: tabular-nums; font-weight: 600; }
.react-util.is-on { background: var(--warn-soft); border-color: var(--warn); color: var(--text); }
.react-util.is-on svg { color: var(--warn); }
.react-like.is-on { background: var(--danger-soft); border-color: var(--danger); color: var(--text); }
.react-like.is-on svg { color: var(--danger); fill: var(--danger); }
.react-btn.pop svg { animation: react-pop .3s var(--ease); }
@keyframes react-pop { 50% { transform: scale(1.35); } }
.rank-row { gap: 14px; }
.rank-pos { flex: none; display: grid; place-items: center; width: 30px; height: 30px; border-radius: 50%; background: var(--surface-2); font-weight: 700; font-size: 13px; color: var(--text-2); }
.rank-pos.top { background: var(--accent-soft); color: var(--accent-text); }
.rank-votes { margin-left: auto; display: inline-flex; align-items: center; gap: 5px; font-weight: 600; color: var(--text-2); flex: none; }
.collection-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 14px; }
.collection-card { display: flex; flex-direction: column; gap: 6px; padding: 18px; color: var(--text); }
.collection-card:hover { text-decoration: none; border-color: var(--accent); }
.collection-card p { margin: 0; color: var(--text-2); font-size: 14px; }
.collection-ico { display: grid; place-items: center; width: 38px; height: 38px; border-radius: 10px; background: var(--accent-soft); color: var(--accent-text); margin-bottom: 4px; }
.syllabus { list-style: none; padding: 0; margin: 0; }
.syllabus-num { flex: none; display: grid; place-items: center; width: 28px; height: 28px; border-radius: 50%; background: var(--accent-soft); color: var(--accent-text); font-weight: 700; font-size: 13px; }
.syllabus .list-row { gap: 12px; }
.syllabus-edit { list-style: none; padding: 0; margin: 0 0 14px; }
.syllabus-edit li { display: flex; align-items: center; gap: 8px; padding: 8px 0; border-bottom: 1px solid var(--border); }
.syllabus-edit .grow { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text); }
.syllabus-edit form { margin: 0; }
.doc-picker { position: relative; }
.danger-zone { margin-top: 12px; text-align: right; }
.back-link { display: inline-flex; align-items: center; gap: 4px; margin-bottom: 6px; }
.row-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.collection-banner { display: flex; align-items: center; gap: 8px; margin: 0 0 18px; padding: 9px 12px; border-radius: var(--radius-sm); background: var(--accent-soft); color: var(--accent-text); font-size: 14px; }
.collection-banner:hover { text-decoration: none; filter: brightness(.98); }
.collection-nav { margin: 28px 0 0; padding: 14px 16px; }
.collection-nav-head { display: flex; align-items: center; gap: 8px; font-weight: 600; }
.collection-nav-head .muted { margin-left: auto; font-weight: 500; font-size: 13px; }
.collection-progress { height: 4px; margin: 10px 0 12px; border-radius: 2px; background: var(--surface-2); overflow: hidden; }
.collection-progress i { display: block; height: 100%; background: var(--accent); }
.collection-nav-links { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.collection-nav-links a { display: flex; flex-direction: column; gap: 2px; color: var(--text); min-width: 0; }
.collection-nav-links a:hover { text-decoration: none; color: var(--accent-text); }
.collection-nav-links small { display: inline-flex; align-items: center; gap: 4px; color: var(--muted); }
.collection-nav-links span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; }
.collection-nav-links .right { text-align: right; align-items: flex-end; align-self: center; }
@media print { .collection-nav, .collection-banner { display: none !important; } }
.activity-filters { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin-bottom: 14px; }
.activity-filters select { width: auto; min-width: 180px; }
.activity-row { display: flex; align-items: flex-start; gap: 12px; padding: 12px 16px; border-bottom: 1px solid var(--border); }
.activity-row:last-child { border-bottom: 0; }
.activity-row p { margin: 0; overflow-wrap: anywhere; }
.activity-main { flex: 1; min-width: 0; }
.activity-row time { flex: none; white-space: nowrap; }
.activity-ico { flex: none; display: grid; place-items: center; width: 30px; height: 30px; border-radius: 50%; background: var(--surface-2); color: var(--text-2); }
.activity-ico.act-comment { background: var(--info-soft); color: var(--info); }
.activity-ico.act-user { background: var(--accent-soft); color: var(--accent-text); }
.activity-ico.is-danger { background: var(--danger-soft); color: var(--danger); }
.activity-target { font-weight: 600; }
.prose pre.code-block { padding-top: 36px; }
.code-lang { position: absolute; top: 0; left: 0; padding: 5px 12px; border-bottom-right-radius: 8px; background: rgba(255,255,255,.07);
  color: #9aa7b4; font: 600 11px/1.4 var(--font-ui); letter-spacing: .04em; text-transform: uppercase; user-select: none; }
.prose code.language-console .gp { color: #7ee2b8; user-select: none; }
.toc-left { margin: 10px 0 0; font-size: 12px; color: var(--muted); }
.reader-fab { position: fixed; right: max(16px, env(safe-area-inset-right)); bottom: max(18px, env(safe-area-inset-bottom)); z-index: 40; display: flex; flex-direction: column; gap: 10px; }
.fab { display: grid; place-items: center; width: 46px; height: 46px; border-radius: 50%; border: 1px solid var(--border); background: var(--surface); color: var(--text); box-shadow: var(--shadow); cursor: pointer; transition: transform .15s var(--ease); }
.fab:hover { transform: translateY(-2px); }
.fab-toc { display: none; }
.toc-sheet { width: min(420px, calc(100vw - 24px)); max-height: 70vh; }
.toc-sheet-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 14px 6px 20px; }
.toc-sheet-head h4 { margin: 0; font-size: 12px; text-transform: uppercase; letter-spacing: .1em; color: var(--muted); }
.toc-sheet ul { list-style: none; margin: 0; padding: 0 10px 16px; overflow-y: auto; }
.toc-sheet a { display: block; padding: 9px 10px; border-radius: var(--radius-sm); color: var(--text); }
.toc-sheet a:hover { background: var(--surface-2); text-decoration: none; }
.toc-sheet .toc-l3 a { padding-left: 24px; color: var(--text-2); font-size: 14px; }
@media (max-width: 1080px) { .fab-toc { display: grid; } }
@media print { .reader-fab { display: none !important; } }
.copy-btn { position: absolute; top: 8px; right: 8px; display: inline-flex; align-items: center; gap: 5px; height: 26px; padding: 0 9px;
  border: 1px solid #30363d; border-radius: 6px; background: #161b22; color: #c9d1d9; font: 600 11.5px var(--font-ui); cursor: pointer; opacity: 0; transition: opacity .15s; }
.prose pre:hover .copy-btn, .copy-btn:focus-visible { opacity: 1; }
@media (hover: none) { .copy-btn { opacity: 1; } }
.prose table { display: block; width: max-content; max-width: 100%; overflow-x: auto; border-collapse: collapse; font-family: var(--font-ui); font-size: 14.5px; }
.prose th, .prose td { padding: 8px 12px; border: 1px solid var(--border); text-align: left; vertical-align: top; }
.prose th { background: var(--surface-2); font-weight: 600; }
.prose img { border-radius: var(--radius-sm); }
.prose hr { margin: 2em 0; }
.prose .footnotes { font-size: .85em; color: var(--text-2); }

.toc { position: relative; }
.toc-inner { position: sticky; top: calc(var(--topbar-h) + 26px); max-height: calc(100vh - 110px); overflow-y: auto; padding-left: 14px; border-left: 1px solid var(--border); font-size: 13.5px; }
.toc h4 { font-size: 11px; text-transform: uppercase; letter-spacing: .1em; color: var(--muted); margin-bottom: 10px; }
.toc ul { list-style: none; padding: 0; margin: 0; }
.toc li a { display: block; padding: 4px 0; color: var(--muted); line-height: 1.4; }
.toc li a:hover { color: var(--text); text-decoration: none; }
.toc li a.active { color: var(--accent-text); font-weight: 600; }
.toc .toc-l3 { padding-left: 12px; font-size: 13px; }
.toc-top { display: inline-flex; align-items: center; gap: 5px; margin-top: 14px; font-size: 12px; color: var(--muted); }

.doc-nav { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-top: 44px; }
.doc-nav-item { display: grid; gap: 2px; padding: 14px 18px; color: var(--text); min-width: 0; }
.doc-nav-item small { display: inline-flex; align-items: center; gap: 4px; color: var(--muted); }
.doc-nav-item span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.doc-nav-item:hover { text-decoration: none; border-color: var(--accent); }
.doc-nav-item.right { grid-column: 2; text-align: right; justify-items: end; }
.related { margin-top: 36px; }
.related h3 { font-size: 12px; text-transform: uppercase; letter-spacing: .1em; color: var(--muted); }
.related-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.related-item { display: grid; gap: 4px; padding: 14px 16px; color: var(--text); }
.related-item:hover { text-decoration: none; border-color: var(--accent); }
.related-date { font-size: 12px; color: var(--muted); }

/* comments */
.comments { margin-top: 44px; padding-top: 26px; border-top: 1px solid var(--border); }
.comments-title { display: flex; align-items: center; gap: 8px; font-size: 18px; margin-bottom: 18px; }
.comment { display: grid; grid-template-columns: 30px minmax(0, 1fr); gap: 12px; margin-bottom: 18px; }
.comment .avatar:hover { text-decoration: none; }
.comment-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-size: 14px; }
.comment-head strong { color: var(--text); }
.comment-text { margin: 4px 0 0; white-space: pre-wrap; overflow-wrap: anywhere; line-height: 1.55; }
.comment.is-pending { opacity: .78; }
.comment-form { display: grid; gap: 8px; margin-top: 8px; }
.comment-foot { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
.notice { display: flex; align-items: flex-start; gap: 8px; color: var(--muted); font-size: 13px; }
.notice .icon { margin-top: 2px; }
.mention { padding: 0 .2em; border-radius: 4px; background: var(--accent-soft); color: var(--accent-text); font-weight: 600; text-decoration: none; }
.mention:hover { text-decoration: underline; }

/* ---------------------------------------------------------------- @mention dropdown */
.mention-host { position: relative; }
.mention-menu { position: absolute; z-index: 75; left: 0; bottom: calc(100% + 6px); width: min(300px, 100%); max-height: 260px; overflow-y: auto;
  padding: 4px; margin: 0; list-style: none; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-lg); }
.mention-menu.below { bottom: auto; top: calc(100% + 6px); }
.mention-menu li { display: flex; align-items: center; gap: 10px; padding: 7px 9px; border-radius: var(--radius-xs); cursor: pointer; }
.mention-menu li.sel, .mention-menu li:hover { background: var(--accent-soft); }
.mention-menu .who strong { font-size: 13.5px; font-weight: 600; }
.mention-menu .empty-row { color: var(--muted); font-size: 13px; cursor: default; }
.mention-menu .empty-row:hover { background: none; }

/* ---------------------------------------------------------------- editor & upload */
.dropzone { position: relative; display: grid; justify-items: center; gap: 6px; padding: 40px 20px; margin-bottom: 18px; text-align: center;
  border: 2px dashed var(--border-strong); border-radius: var(--radius); color: var(--text); cursor: pointer; transition: border-color .15s, background .15s; }
.dropzone > .icon { color: var(--accent); margin-bottom: 4px; }
.dropzone:hover, .dropzone.drag { border-color: var(--accent); background: var(--accent-soft); }
.dropzone input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.file-list { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px; padding: 0; margin: 12px 0 0; list-style: none; }
.file-list li { display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border-radius: 6px; background: var(--surface-2); font-size: 13px; }
.tip { display: flex; align-items: flex-start; gap: 8px; padding: 10px 14px; margin-bottom: 20px; border-radius: var(--radius-sm); background: var(--surface-2); color: var(--text-2); font-size: 13px; }
.tip .icon { margin-top: 2px; color: var(--warn); }
.editor-form > .card { padding: 22px 24px 8px; margin-bottom: 16px; }
.editor { overflow: hidden; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }
.editor-bar { display: flex; justify-content: space-between; align-items: center; gap: 8px; flex-wrap: wrap; padding: 6px 8px; border-bottom: 1px solid var(--border); background: var(--surface-2); }
.editor-tools, .editor-modes { display: flex; align-items: center; gap: 2px; flex-wrap: wrap; }
.editor-bar button { display: inline-grid; place-items: center; min-width: 32px; height: 30px; padding: 0 8px; border: 0; border-radius: 6px;
  background: transparent; color: var(--text-2); font: inherit; font-size: 13px; cursor: pointer; }
.editor-bar button:hover { background: var(--surface); color: var(--text); }
.editor-img-btn { display: inline-grid; place-items: center; min-width: 32px; height: 30px; padding: 0 8px; border-radius: 6px; color: var(--text-2); cursor: pointer; }
.editor-img-btn:hover { background: var(--surface); color: var(--text); }
.editor-img-btn:focus-within { outline: 2px solid var(--accent); }
.editor-panes textarea.drag-over { outline: 2px dashed var(--accent) !important; outline-offset: -6px; }
.prose img { max-width: 100%; height: auto; border-radius: 8px; border: 1px solid var(--border); }
.editor-modes button.active { background: var(--surface); color: var(--text); font-weight: 600; box-shadow: var(--shadow-sm); }
.editor-modes .muted { margin-right: 8px; }
.editor-panes { display: grid; grid-template-columns: 1fr 1fr; min-height: 540px; }
.editor-panes textarea { min-height: 540px; padding: 18px 20px !important; border: 0 !important; border-radius: 0 !important; box-shadow: none !important;
  resize: vertical; background: var(--surface); font: 14px/1.65 var(--font-mono) !important; tab-size: 2; }
.editor-preview { max-height: 75vh; overflow-y: auto; padding: 18px 26px; border-left: 1px solid var(--border); font-size: 16.5px; }
.view-edit { grid-template-columns: 1fr; } .view-edit .editor-preview { display: none; }
.view-preview { grid-template-columns: 1fr; } .view-preview textarea { display: none; } .view-preview .editor-preview { max-height: none; border-left: 0; }
.sticky-actions { position: sticky; bottom: 0; z-index: 5; padding: 14px 0; background: color-mix(in srgb, var(--bg) 92%, transparent); backdrop-filter: blur(8px); }
.note-input { max-width: 340px; margin-right: auto; }
.vis-locked { display: flex; align-items: center; gap: 8px; margin: 0; padding: 9px 12px; border-radius: var(--radius-sm); background: var(--surface-2); color: var(--text-2); font-size: 13px; }
.danger-zone { padding: 20px 24px; margin-top: 28px; }
.danger-zone h3 { font-size: 15px; }
.danger-row { display: flex; flex-wrap: wrap; gap: 10px; }
.inline-form { display: inline-flex; align-items: center; gap: 8px; margin: 0; }
.inline-form input { max-width: 260px; }

.diff { max-height: 60vh; margin-top: 16px; padding: 14px; overflow: auto; border-radius: var(--radius-sm); background: var(--surface-2); font-size: 13px; line-height: 1.5; }
.diff span { display: block; white-space: pre-wrap; }
.diff .add { background: color-mix(in srgb, #2da44e 18%, transparent); }
.diff .del { background: color-mix(in srgb, #cf222e 16%, transparent); }
.diff .hunk { color: var(--info); }

/* ---------------------------------------------------------------- profile & social */
.profile-head { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: 24px; padding: 26px; margin-bottom: 28px; }
.profile-info h1 { font-family: var(--font-read); font-size: 30px; margin: 0 0 4px; overflow-wrap: anywhere; }
.profile-info > p { margin: 0 0 10px; }
.profile-meta { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; color: var(--muted); font-size: 14px; }
.profile-bio { max-width: 60ch; color: var(--text-2); }
.profile-social { display: flex; gap: 14px; font-size: 14px; color: var(--muted); }
.profile-social strong { color: var(--text); }
.profile-cta { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-top: 4px; }
.profile-stats { display: flex; gap: 26px; }
.profile-stats div { display: grid; justify-items: center; }
.profile-stats strong { font-size: 24px; letter-spacing: -.02em; }
.profile-stats span { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .06em; }
.follow-btn { min-width: 118px; }
.profile-cta .follow-btn { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.profile-cta .follow-btn:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.profile-cta.is-following .follow-btn { background: var(--surface); border-color: var(--border-strong); color: var(--text); }
.profile-cta.is-following .follow-btn:hover { background: var(--danger-soft); border-color: var(--danger); color: var(--danger); }
.profile-cta:not(.is-following) .mute-form { display: none; }
.follow-label-hover { display: none; }
.profile-cta.is-following .follow-btn:hover .follow-label { display: none; }
.profile-cta.is-following .follow-btn:hover .follow-label-hover { display: inline; }
.follow-actions { display: flex; gap: 4px; flex: none; }

/* notifications */
.notif-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; margin-bottom: 12px; }
.notif-toolbar .tabs { margin: 0; }
.notif-list { overflow: hidden; }
.notif { position: relative; display: grid; grid-template-columns: 36px minmax(0, 1fr) auto; align-items: center; gap: 12px;
  padding: 12px 14px 12px 16px; border-bottom: 1px solid var(--border); transition: background .15s var(--ease); }
.notif:last-child { border-bottom: 0; }
.notif:hover { background: color-mix(in srgb, var(--surface-2) 60%, transparent); }
.notif.unread { background: color-mix(in srgb, var(--accent-soft) 55%, var(--surface)); }
.notif.unread::before { content: ""; position: absolute; left: 0; top: 10px; bottom: 10px; width: 3px; border-radius: 0 3px 3px 0; background: var(--accent); }
.notif-ico { display: grid; place-items: center; width: 36px; height: 36px; border-radius: 10px; background: var(--surface-2); color: var(--text-2); }
.notif-ico.k-new_doc { background: var(--info-soft); color: var(--info); }
.notif-ico.k-follow { background: var(--accent-soft); color: var(--accent-text); }
.notif-ico.k-comment, .notif-ico.k-comment_approved { background: var(--warn-soft); color: var(--warn); }
.notif-ico.k-chat, .notif-ico.k-mention { background: var(--accent-soft); color: var(--accent-text); }
.notif-body { display: grid; gap: 2px; min-width: 0; color: var(--text); }
.notif-body:hover { text-decoration: none; }
.notif-text { font-size: 14px; line-height: 1.4; overflow-wrap: anywhere; }
.notif.unread .notif-text { font-weight: 600; }
.notif-time { font-size: 12px; color: var(--muted); }
.notif-actions { display: flex; align-items: center; gap: 2px; }
.notif-actions .icon-btn { width: 32px; height: 32px; color: var(--muted); }
.notif-actions .icon-btn:hover { color: var(--text); }

/* chat */
.chat-list .list-row { padding: 12px 16px; }
.chat-preview { display: block; max-width: 46ch; color: var(--muted); font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-meta { display: grid; justify-items: end; gap: 4px; flex: none; font-size: 12px; color: var(--muted); }
.chat-meta .count-badge { position: static; box-shadow: none; }
.chat-wrap { display: flex; flex-direction: column; max-width: 780px; height: calc(100dvh - var(--topbar-h) - 64px); min-height: 420px; margin: 0 auto; overflow: hidden; }
.chat-header { display: flex; align-items: center; gap: 10px; padding: 10px 14px; border-bottom: 1px solid var(--border); }
.chat-status { font-size: 12.5px; color: var(--muted); min-height: 1.2em; }
.chat-messages { flex: 1; display: flex; flex-direction: column; gap: 2px; padding: 16px 14px; overflow-y: auto; overscroll-behavior: contain; background: var(--bg); }
.chat-day { align-self: center; margin: 12px 0 8px; padding: 2px 10px; border-radius: 999px; background: var(--surface-2); color: var(--muted); font-size: 11.5px; font-weight: 600; }
.msg { display: flex; flex-direction: column; align-items: flex-start; max-width: min(78%, 560px); margin-top: 6px; }
.msg.mine { align-self: flex-end; align-items: flex-end; }
.msg + .msg.same { margin-top: 2px; }
.bubble { display: inline-block; width: fit-content; max-width: 100%; padding: 7px 12px 8px; border-radius: 16px; line-height: 1.45;
  background: var(--surface); border: 1px solid var(--border); color: var(--text); white-space: pre-wrap; overflow-wrap: anywhere; word-break: break-word; font-size: 14.5px; }
.msg.theirs .bubble { border-bottom-left-radius: 5px; }
.msg.mine .bubble { background: var(--accent); border-color: var(--accent); color: var(--on-accent); border-bottom-right-radius: 5px; }
.msg.same.theirs .bubble { border-top-left-radius: 5px; }
.msg.same.mine .bubble { border-top-right-radius: 5px; }
.msg.mine .bubble .mention { background: color-mix(in srgb, #fff 22%, transparent); color: inherit; }
.msg-time { margin: 2px 6px 0; font-size: 11px; color: var(--muted); }
.msg.same .msg-time { display: none; }
.msg.pending .bubble { opacity: .6; }
.typing { display: inline-flex; align-items: center; gap: 4px; align-self: flex-start; margin-top: 8px; padding: 10px 13px; border-radius: 16px; border-bottom-left-radius: 5px; background: var(--surface); border: 1px solid var(--border); }
.typing span { width: 6px; height: 6px; border-radius: 50%; background: var(--muted); animation: blink 1.2s infinite ease-in-out; }
.typing span:nth-child(2) { animation-delay: .15s; }
.typing span:nth-child(3) { animation-delay: .3s; }
@keyframes blink { 0%, 80%, 100% { opacity: .25; transform: translateY(0); } 40% { opacity: 1; transform: translateY(-3px); } }
.chat-empty { margin: auto; text-align: center; color: var(--muted); font-size: 14px; }
.chat-form { display: flex; align-items: flex-end; gap: 8px; padding: 10px 12px; border-top: 1px solid var(--border); background: var(--surface); }
.chat-form .mention-host { flex: 1; min-width: 0; }
.chat-form textarea { min-height: 40px; max-height: 140px; padding: 9px 12px; resize: none; border-radius: 20px; line-height: 1.4; }
.chat-form .btn { flex: none; width: 40px; height: 40px; padding: 0; border-radius: 50%; }
.chat-form { flex-wrap: wrap; }
.chat-attach { flex: none; width: 40px; height: 40px; border-radius: 50%; }
.chat-attach:focus-within { outline: 2px solid var(--accent); outline-offset: 2px; }
.chat-attach-preview { flex-basis: 100%; display: flex; align-items: center; gap: 10px; padding: 6px 8px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface-2); font-size: 13px; min-width: 0; }
.chat-attach-preview img, .chat-attach-preview video { width: 52px; height: 52px; object-fit: cover; border-radius: 8px; background: var(--border); flex: none; }
.chat-attach-preview .att-ph { display: grid; place-items: center; width: 52px; height: 52px; border-radius: 8px; background: var(--border); color: var(--text-2); flex: none; }
.chat-attach-preview .att-info { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.chat-attach-preview .att-info strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-attach-preview .att-info span { color: var(--muted); font-size: 12px; }
.att-progress { height: 4px; margin-top: 5px; border-radius: 2px; background: var(--border); overflow: hidden; }
.att-progress i { display: block; height: 100%; width: 0; background: var(--accent); transition: width .15s linear; }
.bubble.has-media { width: min(100%, 348px); padding: 4px; overflow: hidden; }
.bubble.has-media .msg-text { padding: 5px 8px 4px; }
.media { display: block; max-width: 100%; border-radius: 12px; overflow: hidden; background: color-mix(in srgb, var(--text) 8%, transparent); }
.media img, video.media { display: block; max-width: 100%; height: auto; max-height: 420px; object-fit: contain; }
.media img { width: auto; }
video.media { width: 100%; }
.media-note { display: flex; align-items: center; gap: 8px; padding: 10px 12px; font-size: 13.5px; white-space: normal; }
.media-note.is-error { color: inherit; opacity: .85; }
.spinner { width: 16px; height: 16px; border-radius: 50%; border: 2px solid currentColor; border-right-color: transparent; animation: spin .8s linear infinite; flex: none; }
.chat-wrap.drag-over .chat-messages { outline: 2px dashed var(--accent); outline-offset: -8px; }
.lightbox { padding: 0; border: 0; background: transparent; max-width: 100vw; max-height: 100vh; width: 100vw; height: 100vh; }
.lightbox::backdrop { background: rgba(0, 0, 0, .88); }
.lightbox img { position: absolute; inset: 0; margin: auto; max-width: 96vw; max-height: 92vh; object-fit: contain; }
.lightbox .icon-btn { position: absolute; top: 12px; right: 12px; color: #fff; background: rgba(255,255,255,.12); }
@media (prefers-reduced-motion: reduce) { .spinner { animation-duration: 2.4s; } }

/* ---------------------------------------------------------------- absences */
.ab-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px; margin-bottom: 24px; }
.ab-card { --lvl: var(--accent); padding: 16px; }
.ab-warn { --lvl: var(--warn); }
.ab-danger { --lvl: #d4561c; }
.ab-over { --lvl: var(--danger); border-color: color-mix(in srgb, var(--danger) 35%, var(--border)); }
.ab-top { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; }
.ab-used { display: grid; place-items: center; flex: none; width: 42px; height: 42px; border-radius: 11px; font-size: 19px; font-weight: 700;
  color: var(--lvl); background: color-mix(in srgb, var(--lvl) 13%, transparent); font-variant-numeric: tabular-nums; }
.ab-name { font-weight: 600; line-height: 1.3; overflow-wrap: anywhere; }
.ab-bar { height: 6px; overflow: hidden; border-radius: 99px; background: var(--surface-2); }
.ab-bar span { display: block; height: 100%; border-radius: 99px; background: var(--lvl); }
.ab-foot { display: flex; justify-content: space-between; gap: 8px; margin-top: 9px; font-size: 13px; color: var(--muted); }
.ab-foot strong { color: var(--lvl); font-weight: 600; }
.ab-layout { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 24px; align-items: start; }
.ab-layout h3 { font-size: 16px; }
.ab-inputs { display: grid; grid-template-columns: 1fr 1fr; gap: 0 16px; margin-bottom: 14px; }
.ab-input { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 7px 0; border-bottom: 1px solid var(--border); font-size: 14px; }
.ab-input > span:first-child { min-width: 0; overflow-wrap: anywhere; }
.stepper { display: inline-flex; flex: none; align-items: center; overflow: hidden; border: 1px solid var(--border-strong); border-radius: var(--radius-sm); }
.stepper button { display: grid; place-items: center; width: 30px; height: 32px; border: 0; background: var(--surface-2); color: var(--text); cursor: pointer; }
.stepper button:hover { background: var(--surface-3); }
.stepper input { width: 40px !important; min-height: 32px !important; height: 32px; padding: 0 !important; border: 0 !important; border-radius: 0 !important;
  box-shadow: none !important; text-align: center; -moz-appearance: textfield; font-variant-numeric: tabular-nums; }
.stepper input::-webkit-inner-spin-button { -webkit-appearance: none; }
.ab-day { padding: 12px 16px; margin-bottom: 10px; }
.ab-day-head { display: flex; justify-content: space-between; gap: 10px; margin-bottom: 4px; }
.ab-row { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 7px 0; border-top: 1px solid var(--border); font-size: 14px; }
.ab-row > span:first-child { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; min-width: 0; }
.ab-actions { display: flex; gap: 2px; flex: none; }
.ab-week { display: flex; justify-content: space-around; padding: 14px 16px; margin-bottom: 12px; }
.ab-wd { display: grid; justify-items: center; gap: 4px; font-size: 12px; color: var(--muted); }
.ab-wd-bar { display: flex; align-items: flex-end; width: 22px; height: 60px; overflow: hidden; border-radius: 6px; background: var(--surface-2); }
.ab-wd-bar span { display: block; width: 100%; border-radius: 6px; background: var(--accent); }
.ab-wd b { color: var(--text); font-size: 13px; }
.num-input { width: 84px !important; }
.csv-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 14px; }
.csv-help { margin-top: 12px; }
.csv-help summary { cursor: pointer; font-size: 13px; color: var(--muted); }
.csv-help ul { margin: 10px 0 0; padding-left: 18px; }

/* ---------------------------------------------------------------- redmine */
.setup-card { padding: 16px 20px; margin-bottom: 20px; border-left: 3px solid var(--warn); }
.rm-day { margin-bottom: 22px; }
.rm-day-title { margin: 0 0 8px; font-size: 12px; text-transform: uppercase; letter-spacing: .1em; color: var(--muted); }
.rm-list { overflow: hidden; }
.rm-item { display: grid; grid-template-columns: 32px minmax(0, 1fr); gap: 12px; padding: 13px 16px; border-bottom: 1px solid var(--border); }
.rm-item:last-child { border-bottom: 0; }
.rm-icon { display: grid; place-items: center; width: 32px; height: 32px; border-radius: 9px; background: var(--surface-2); color: var(--text-2); }
.rm-meta { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 3px; font-size: 13px; color: var(--text-2); }
.rm-title { color: var(--text); font-weight: 600; overflow-wrap: anywhere; }
.rm-details summary { margin-top: 4px; font-size: 12px; color: var(--muted); cursor: pointer; }
.rm-content { margin-top: 8px; padding: 10px 14px; border-radius: var(--radius-sm); background: var(--surface-2); font-family: var(--font-ui); font-size: 14px; line-height: 1.6; }
.rm-issue { display: grid; gap: 3px; padding: 10px 0; border-bottom: 1px solid var(--border); color: var(--text); font-size: 14px; }
.rm-issue:last-of-type { border-bottom: 0; }
.rm-issue:hover { text-decoration: none; color: var(--accent-text); }
.rm-issue-top { display: flex; justify-content: space-between; gap: 8px; font-size: 12px; }
.rm-keys-toggle { cursor: pointer; margin-bottom: 0; }
details[open] > .rm-keys-toggle { margin-bottom: 12px; }

/* ---------------------------------------------------------------- admin */
.stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin-bottom: 20px; }
.stat-card { display: grid; gap: 2px; padding: 16px 18px; }
.stat-label { display: flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .07em; color: var(--muted); }
.stat-value { font-size: 28px; font-weight: 700; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.stat-sub { font-size: 13px; color: var(--muted); }
.mail-card { padding: 16px 20px; margin-bottom: 20px; }
.mail-card h3 { font-size: 15px; margin-bottom: 4px; }
.mail-card p { margin: 0; }
.user-cell { display: flex; align-items: center; gap: 10px; min-width: 0; }
.roles-help { padding: 14px 18px; margin-top: 14px; font-size: 13px; color: var(--text-2); }
.roles-help dl { display: grid; grid-template-columns: max-content 1fr; gap: 6px 14px; margin: 8px 0 0; }
.roles-help dt { font-weight: 600; }
.roles-help dd { margin: 0; color: var(--muted); }
.comment-review { padding: 16px 18px; margin-bottom: 12px; }
.comment-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.tag-cloud { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; padding: 26px; }

/* ---------------------------------------------------------------- auth */
.auth-wrap { display: grid; place-items: center; padding: 32px 0; }
.auth-card { width: 100%; max-width: 420px; padding: 30px; }
.auth-card h1 { font-size: 24px; margin: 14px 0 4px; }
.auth-card > .muted { margin: 0 0 22px; }
.auth-brand { display: grid; place-items: center; width: 46px; height: 46px; border-radius: 12px; background: var(--accent); color: var(--on-accent); }
.auth-alt { margin: 18px 0 0; text-align: center; font-size: 14px; color: var(--muted); }
.welcome { display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, 420px); gap: 48px; align-items: center; min-height: calc(100vh - var(--topbar-h) - 180px); }
.welcome-copy h1 { font-family: var(--font-read); font-size: 44px; line-height: 1.1; letter-spacing: -.02em; margin: 10px 0 14px; }
.welcome-copy > p { max-width: 52ch; font-size: 17px; color: var(--text-2); }
.welcome-points { display: grid; gap: 12px; padding: 0; margin: 22px 0 0; list-style: none; }
.welcome-points li { display: flex; align-items: flex-start; gap: 12px; color: var(--text-2); }
.welcome-points .icon-wrap { display: grid; place-items: center; flex: none; width: 34px; height: 34px; border-radius: 9px; background: var(--accent-soft); color: var(--accent-text); }
.welcome-points strong { display: block; color: var(--text); }
.welcome .auth-card { justify-self: end; }

/* ---------------------------------------------------------------- help & contact */
.help-hero { padding: 16px 0 8px; text-align: center; }
.help-hero h1 { font-family: var(--font-read); font-size: 36px; margin: 8px 0 10px; }
.help-lede { max-width: 56ch; margin: 0 auto; }
.help-cards { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin: 28px auto 40px; max-width: 900px; }
.help-card { display: grid; justify-items: center; gap: 4px; padding: 18px 14px; text-align: center; color: var(--text); transition: border-color .15s, transform .15s; }
.help-card:hover { text-decoration: none; border-color: var(--accent); transform: translateY(-2px); }
.help-card .icon-wrap { display: grid; place-items: center; width: 40px; height: 40px; border-radius: 11px; background: var(--accent-soft); color: var(--accent-text); margin-bottom: 4px; }
.help-section { max-width: 760px; margin: 0 auto 34px; }
.help-section > h2 { font-family: var(--font-read); font-size: 24px; padding-bottom: 8px; margin-bottom: 14px; border-bottom: 1px solid var(--border); }
.faq-item { margin-bottom: 8px; overflow: hidden; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface); }
.faq-item summary { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 13px 16px; font-weight: 600; list-style: none; cursor: pointer; }
.faq-item summary::-webkit-details-marker { display: none; }
.faq-item summary .icon { color: var(--muted); transition: transform .18s var(--ease); }
.faq-item[open] summary .icon { transform: rotate(180deg); }
.faq-item[open] summary { border-bottom: 1px solid var(--border); }
.faq-a { padding: 13px 16px; color: var(--text-2); line-height: 1.6; }
.faq-a code { padding: .1em .4em; border-radius: 5px; background: var(--surface-2); font-size: .88em; }
.contact-card { max-width: 760px; margin: 0 auto; padding: 26px; }
.contact-card h2 { font-size: 22px; margin-bottom: 4px; }
.contact-card > p { color: var(--muted); }
.sent-card { display: grid; justify-items: center; gap: 8px; padding: 34px 26px; text-align: center; }
.sent-card .icon-wrap { display: grid; place-items: center; width: 52px; height: 52px; border-radius: 50%; background: var(--accent-soft); color: var(--accent-text); }

/* ---------------------------------------------------------------- modal (confirm) */
.modal { padding: 0; border: 0; border-radius: var(--radius-lg); background: var(--surface); color: var(--text); box-shadow: var(--shadow-lg); width: min(440px, calc(100vw - 32px)); }
.modal::backdrop { background: rgba(15, 14, 10, .45); }
.modal[open] { animation: pop .16s var(--ease); }
.modal-body { display: grid; grid-template-columns: 40px minmax(0, 1fr); gap: 14px; padding: 22px 22px 8px; }
.modal-ico { display: grid; place-items: center; width: 40px; height: 40px; border-radius: 50%; background: var(--danger-soft); color: var(--danger); }
.modal h3 { font-size: 16px; margin: 2px 0 6px; }
.modal p { margin: 0; color: var(--text-2); font-size: 14px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; padding: 16px 22px 20px; }

/* ---------------------------------------------------------------- search modal */
.search-modal { position: fixed; inset: 0; z-index: 100; display: flex; justify-content: center; align-items: flex-start; padding: 12vh 16px 16px; background: rgba(15, 14, 10, .45); backdrop-filter: blur(3px); }
.search-box { width: 100%; max-width: 620px; overflow: hidden; border: 1px solid var(--border); border-radius: 14px; background: var(--surface); box-shadow: var(--shadow-lg); animation: pop .15s var(--ease); }
.search-input { display: flex; align-items: center; gap: 10px; padding: 12px 16px; border-bottom: 1px solid var(--border); color: var(--muted); }
.search-input input { min-height: 32px !important; padding: 0 !important; border: 0 !important; box-shadow: none !important; background: transparent !important; font-size: 17px !important; }
.search-results { max-height: 52vh; overflow-y: auto; padding: 6px; margin: 0; list-style: none; }
.search-results:empty { display: none; }
.search-results a { display: block; padding: 10px 12px; border-radius: var(--radius-sm); color: var(--text); }
.search-results a:hover, .search-results a.sel { background: var(--accent-soft); text-decoration: none; }
.search-results strong { display: block; }
.search-results small { display: block; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.search-results .none { padding: 18px; color: var(--muted); text-align: center; }
.search-foot { display: flex; justify-content: space-between; gap: 10px; padding: 10px 16px; border-top: 1px solid var(--border); font-size: 12px; color: var(--muted); }

/* ---------------------------------------------------------------- footer */
.footer { border-top: 1px solid var(--border); }
.footer-inner { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; padding-top: 22px; padding-bottom: 22px; font-size: 13px; color: var(--muted); }
.footer nav { display: flex; gap: 16px; flex-wrap: wrap; }
.footer a { color: var(--muted); }
.footer a:hover { color: var(--text); }

/* =====================================================================
   responsive
   ===================================================================== */
@media (max-width: 1240px) {
  .search-trigger { flex-basis: 190px; }
  .search-trigger kbd { display: none; }
}
@media (max-width: 1080px) {
  .doc-layout { grid-template-columns: minmax(0, 760px); }
  .toc { display: none; }
  .nav a .nav-label-long { display: none; }
}

/* tablet: navigation moves to the drawer, sidebars go under the content */
@media (max-width: 920px) {
  .nav { display: none; }
  .nav-toggle { display: inline-grid; }
  .feed-layout { grid-template-columns: 1fr; }
  .sidebar { position: static; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .help-cards { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .welcome { grid-template-columns: 1fr; gap: 28px; min-height: 0; }
  .welcome .auth-card { justify-self: stretch; max-width: none; }
  .welcome-copy h1 { font-size: 36px; }
  .search-trigger { flex: 1 1 auto; }
  .ab-layout { grid-template-columns: 1fr; }
}

/* phone */
@media (max-width: 640px) {
  :root { --gutter: 16px; --topbar-h: 54px; }
  body { font-size: 15px; }
  .container { padding-top: 20px; padding-bottom: 48px; }
  .topbar-inner { gap: 8px; }
  .brand .brand-divider, .brand .brand-word { display: none; }
  .drawer .brand .brand-divider, .drawer .brand .brand-word { display: block; }
  .search-trigger { flex: 0 0 auto; width: 36px; padding: 0; justify-content: center; border-color: transparent; background: transparent; }
  .search-trigger span, .search-trigger kbd { display: none; }
  .topbar-actions { gap: 0; }
  .gh-link, .btn-new-label { display: none; }
  .topbar-actions .btn-new { width: 36px; padding: 0; }
  .page-head h1 { font-size: 24px; }
  .hero h1, .filter-head h1 { font-size: 28px; }
  .doc-title { font-size: 29px; }
  .prose { font-size: 17px; }
  .prose .header-anchor { display: none; }
  .grid-2, .related-grid, .doc-nav { grid-template-columns: 1fr; }
  .doc-nav-item.right { grid-column: auto; text-align: left; justify-items: start; }
  .doc-actions .btn-label { display: none; }
  .doc-actions .btn { padding: 0 10px; }
  .toolbar { flex-wrap: wrap; }
  .toolbar-search { flex-basis: 100%; }
  .toolbar select { flex: 1; min-width: 0; width: auto; }
  .form-card, .contact-card { padding: 18px; }
  .editor-form > .card { padding: 18px 16px 4px; }
  .editor-panes { grid-template-columns: 1fr; min-height: 380px; }
  .editor-panes textarea { min-height: 380px; }
  .editor-panes.view-split .editor-preview { display: none; }
  .note-input { max-width: none; flex-basis: 100%; }
  .profile-head { grid-template-columns: auto minmax(0, 1fr); gap: 16px; padding: 18px; }
  .profile-stats { grid-column: 1 / -1; justify-content: space-around; gap: 12px; flex-wrap: wrap; }
  .profile-stats span { font-size: 11px; letter-spacing: .03em; }
  .avatar-xl { width: 60px; height: 60px; font-size: 21px; }
  .profile-info h1 { font-size: 24px; }
  .stats { grid-template-columns: 1fr 1fr; gap: 10px; }
  .stat-value { font-size: 23px; }
  .help-hero h1 { font-size: 28px; }
  .welcome-copy h1 { font-size: 30px; }
  .ab-grid { grid-template-columns: 1fr 1fr; gap: 10px; }
  .ab-card { padding: 13px; }
  .ab-inputs { grid-template-columns: 1fr; }
  .notif { grid-template-columns: 34px minmax(0, 1fr); padding: 12px 12px 10px 14px; row-gap: 6px; }
  .notif-ico { width: 34px; height: 34px; }
  .notif-actions { grid-column: 2; justify-content: flex-start; margin-left: -6px; }
  .notif-toolbar { align-items: stretch; }
  .notif-toolbar .row { justify-content: flex-end; }
  /* the chat is pinned to the visible area; app.js keeps top/height in sync with the on-screen keyboard */
  .chat-wrap { position: fixed; z-index: 30; left: 0; right: 0; top: var(--topbar-h); height: calc(100dvh - var(--topbar-h));
    min-height: 0; max-width: none; margin: 0; border-radius: 0; border-left: 0; border-right: 0; border-bottom: 0; }
  .page-chat main { min-height: calc(100dvh - var(--topbar-h)); }
  /* 16px stops iOS Safari from zooming into a field on focus (and staying zoomed) */
  input:not([type=checkbox]):not([type=radio]), select, textarea { font-size: 16px !important; }
  .msg { max-width: 86%; }
  .chat-preview { max-width: 60vw; }
  .table .hide-sm { display: none; }
  .table th, .table td { padding: 10px 12px; }
  .list-row { padding: 12px 14px; }
  .sticky-actions { flex-wrap: wrap; }
  .pagination .btn-label { display: none; }
  .modal-actions { flex-direction: column-reverse; }
  .modal-actions .btn { width: 100%; }
}

@media (max-width: 380px) {
  .ab-grid { grid-template-columns: 1fr; }
  .stats { grid-template-columns: 1fr; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}

@media print {
  .topbar, .footer, .doc-actions, .toc, .doc-nav, .related, .comments, .flashes, .reading-progress, .copy-btn { display: none !important; }
  body { background: #fff; color: #000; }
  .doc-layout { display: block; }
  .prose { font-size: 12pt; }
  .prose pre { white-space: pre-wrap; border: 1px solid #ccc; }
}

/* ---------------------------------------------------------------- misc pages */
.error-page { padding: 64px 20px; }
.error-code { font-family: var(--font-read); font-size: 72px; font-weight: 700; line-height: 1; color: var(--accent); }
.csv-import { padding-top: 14px; border-top: 1px solid var(--border); }
.row-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.row-actions .tabs { margin: 0; }
.rm-body { min-width: 0; }
.rm-issue-foot { color: var(--muted); }
.rm-setup { max-width: 480px; }
.follow-label, .lbl-on, .lbl-off { display: inline-flex; align-items: center; gap: 6px; }
.profile-cta .lbl-on, .profile-cta.is-following .lbl-off { display: none; }
.profile-cta.is-following .lbl-on { display: inline-flex; }
.row-between > * { min-width: 0; }
.page-head.row-between > div { flex: 1 1 260px; }
@media (max-width: 640px) { .page-chat .footer { display: none; } .page-chat { overflow: hidden; overscroll-behavior: none; } }
@media (max-width: 640px) { .form-actions .notice { flex-basis: 100%; } .form-actions .btn-primary { width: 100%; } }
.btn-link { padding: 0; border: 0; background: none; color: var(--accent-text); font: inherit; font-weight: 600; text-decoration: underline; cursor: pointer; }
input.is-locked, input[readonly] { background: var(--surface-2); color: var(--text-2); cursor: default; }
input[readonly]:focus { border-color: var(--border-strong); box-shadow: none; }

/* people picker (new chat, find people) */
.user-picker { position: relative; margin-bottom: 16px; }
.user-picker input { padding-left: 38px !important; }
.user-picker-icon { position: absolute; left: 12px; top: 12px; color: var(--muted); pointer-events: none; display: inline-flex; }
.user-picker .mention-menu { width: 100%; }
.search-group { padding: 8px 12px 4px; font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); list-style: none; }
.search-results .person { display: flex; align-items: center; gap: 10px; }
.profile-social a { color: var(--muted); }
.profile-social a:hover { color: var(--text); text-decoration: none; }
.person-row { display: flex; align-items: center; gap: 10px; padding: 7px 0; border-bottom: 1px solid var(--border); color: var(--text); min-width: 0; }
.person-row:last-of-type { border-bottom: 0; }
.person-row:hover { text-decoration: none; color: var(--accent-text); }

/* ---------------------------------------------------------------- admin: visitor log */
.visit-filters input[type=search] { width: auto; flex: 1 1 200px; min-width: 0; max-width: 320px; }
.check.check-inline { display: inline-flex; align-items: center; margin: 0; gap: 8px; font-size: 14px; color: var(--text-2); cursor: pointer; }
.visit-cc { display: inline-block; padding: 0 4px; border-radius: 4px; background: var(--surface-3); font-size: 11px; font-weight: 700; letter-spacing: .03em; color: var(--text-2); }
.visit-tops { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 12px; margin-bottom: 18px; }
.visit-tops .list-row { padding: 8px 16px; font-size: 13.5px; }
.visit-top-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.visit-count { margin: 0 0 8px; }
.visit-row { border-bottom: 1px solid var(--border); }
.visit-row:last-child { border-bottom: 0; }
.visit-row > summary { display: flex; align-items: flex-start; gap: 12px; padding: 11px 16px; cursor: pointer; list-style: none; }
.visit-row > summary::-webkit-details-marker { display: none; }
.visit-row > summary:hover, .visit-row[open] > summary { background: var(--surface-2); }
.visit-row time { flex: none; white-space: nowrap; margin-top: 2px; }
.visit-main { flex: 1; min-width: 0; display: grid; gap: 2px; }
.visit-line { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; min-width: 0; }
.visit-path { font-family: var(--font-mono); font-size: 12.5px; color: var(--text-2); overflow-wrap: anywhere; min-width: 0; }
.visit-path em { font-style: normal; font-weight: 700; color: var(--info); }
.visit-meta { overflow-wrap: anywhere; }
.visit-row.is-bot .activity-ico { background: var(--surface-3); color: var(--muted); }
.visit-row.is-probe .activity-ico { background: var(--warn-soft); color: var(--warn); }
.visit-dev-mobile, .visit-dev-tablet { background: var(--info-soft); color: var(--info); }
.visit-dev-desktop { background: var(--accent-soft); color: var(--accent-text); }
.visit-details { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 6px 16px; margin: 0;
  padding: 4px 16px 14px 58px; font-size: 13.5px; background: var(--surface-2); }
.visit-details dt { color: var(--muted); font-weight: 600; }
.visit-details dd { margin: 0; overflow-wrap: anywhere; }
.visit-ua { font-size: 12px; white-space: normal; word-break: break-all; }
@media (max-width: 640px) {
  .visit-tops { grid-template-columns: 1fr; }
  .visit-row > summary { padding: 11px 12px; gap: 10px; }
  .visit-details { grid-template-columns: 1fr; gap: 2px; padding: 6px 12px 14px; }
  .visit-details dd { margin-bottom: 6px; }
  .visit-filters input[type=search] { max-width: none; }
}

/* ---------------------------------------------------------------- caja de herramientas */
:root { --violet: #6941c6; --violet-soft: #f0ebfb; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) { --violet: #b9a2f5; --violet-soft: #2a2340; } }
:root[data-theme="dark"] { --violet: #b9a2f5; --violet-soft: #2a2340; }

.cat-redes { background: var(--info-soft); color: var(--info); }
.cat-linux { background: var(--accent-soft); color: var(--accent-text); }
.cat-web { background: var(--pdf-soft); color: var(--pdf); }
.cat-auto { background: var(--warn-soft); color: var(--warn); }
.cat-seguridad { background: var(--danger-soft); color: var(--danger); }
.cat-devops { background: var(--violet-soft); color: var(--violet); }

.tools-head p { max-width: 680px; }
.tools-toolbar { display: grid; gap: 12px; margin-bottom: 26px; }
.tools-search { position: relative; display: block; max-width: 520px; }
.tools-search > .icon { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); color: var(--muted); pointer-events: none; }
.tools-search input { width: 100%; height: 44px; padding-left: 40px !important; border-radius: 999px !important; }
.tools-cats { display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; padding-bottom: 2px; }
.tools-cat { display: inline-flex; align-items: center; gap: 6px; height: 32px; padding: 0 12px; border: 1px solid var(--border);
  border-radius: 999px; background: var(--surface); color: var(--text-2); font-size: 13.5px; font-weight: 600; white-space: nowrap; }
.tools-cat:hover { text-decoration: none; border-color: var(--border-strong); color: var(--text); }
.tools-cat.active { background: var(--text); border-color: var(--text); color: var(--bg); }
.tools-cat .count { font-size: 11.5px; opacity: .7; font-variant-numeric: tabular-nums; }

.tools-group { margin-bottom: 30px; }
.tools-group-title { display: flex; align-items: center; gap: 10px; font-size: 16px; margin: 0 0 12px; }
.tool-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 12px; }
.tool-card { display: flex; flex-direction: column; gap: 6px; padding: 18px; color: var(--text);
  transition: border-color .15s var(--ease), box-shadow .15s var(--ease), transform .15s var(--ease); }
.tool-card:hover { text-decoration: none; border-color: color-mix(in srgb, var(--accent) 55%, var(--border)); box-shadow: var(--shadow); transform: translateY(-1px); }
.tool-card strong { font-size: 15px; }
.tool-card p { margin: 0; color: var(--text-2); font-size: 13.5px; line-height: 1.5; flex: 1; }
.tool-card-foot { display: flex; align-items: center; justify-content: space-between; margin-top: 8px; color: var(--muted); font-size: 12.5px; font-weight: 600; }
.tool-card:hover .tool-card-foot { color: var(--accent-text); }
.tool-ico { display: grid; place-items: center; flex: none; width: 40px; height: 40px; border-radius: 11px; margin-bottom: 4px; }
.tool-ico-sm { width: 28px; height: 28px; border-radius: 8px; margin: 0; }
.tool-ico-lg { width: 52px; height: 52px; border-radius: 14px; margin: 0; }
.tool-grid-compact { grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); }
.tool-grid-compact .tool-card { flex-direction: row; align-items: center; gap: 10px; padding: 12px 14px; }
.tool-grid-compact .tool-card strong { font-size: 14px; }

.crumbs { display: flex; align-items: center; flex-wrap: wrap; gap: 6px; margin-bottom: 14px; font-size: 13px; color: var(--muted); }
.crumbs a { display: inline-flex; align-items: center; gap: 6px; color: var(--text-2); font-weight: 600; }
.tool-head { display: flex; align-items: center; gap: 16px; margin-bottom: 10px; }
.tool-head h1 { font-size: 26px; margin: 0 0 2px; }
.tool-head p { margin: 0; }
.tool-privacy { display: inline-flex; align-items: center; gap: 7px; margin: 4px 0 22px; padding: 6px 11px; border-radius: 999px;
  background: var(--accent-soft); color: var(--accent-text); font-size: 12.5px; font-weight: 600; }
.tool-privacy .icon { flex: none; }

.tool-layout { display: grid; grid-template-columns: minmax(0, 5fr) minmax(0, 6fr); gap: 18px; align-items: start; }
.tool-layout-even { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
.tool-panel { padding: 20px; min-width: 0; }
.tool-panel > h2, .tool-panel > h3 { display: flex; align-items: center; gap: 8px; font-size: 13px; margin: 0 0 14px; text-transform: uppercase; letter-spacing: .07em; color: var(--muted); }
.tool-panel .field:last-child { margin-bottom: 0; }
.tool-result { background: var(--surface-2); border-color: transparent; box-shadow: none; }
.tool-section { margin-top: 18px; }
.tool-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 0 12px; }
.tool-inline { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.tool-inline > input, .tool-inline > select { flex: 1; min-width: 0; }
.tool-examples { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin: 10px 0 0; font-size: 12.5px; color: var(--muted); }
.tool-examples button { height: 26px; padding: 0 9px; border: 1px dashed var(--border-strong); border-radius: 999px; background: transparent;
  color: var(--text-2); font: 500 12.5px var(--font-mono); cursor: pointer; }
.tool-examples button:hover { border-style: solid; border-color: var(--accent); color: var(--accent-text); }
.tool .check { margin-bottom: 10px; }
.tool input[aria-invalid="true"], .tool select[aria-invalid="true"], .tool textarea[aria-invalid="true"] { border-color: var(--danger); }
.tool input[aria-invalid="true"]:focus, .tool textarea[aria-invalid="true"]:focus { box-shadow: 0 0 0 3px color-mix(in srgb, var(--danger) 22%, transparent); }
.tool textarea.mono, .tool input.mono { font-family: var(--font-mono); font-size: 13.5px; }
.tool-big-input { font: 600 17px var(--font-mono) !important; min-height: 48px !important; }

.seg { display: inline-flex; flex-wrap: wrap; gap: 3px; padding: 3px; background: var(--surface-2); border-radius: var(--radius-sm); max-width: 100%; }
.seg label { position: relative; }
.seg input { position: absolute; opacity: 0; pointer-events: none; }
.seg span { display: inline-flex; align-items: center; gap: 6px; height: 30px; padding: 0 12px; border-radius: 6px; font-size: 13px; font-weight: 600; color: var(--text-2); cursor: pointer; white-space: nowrap; }
.seg input:checked + span { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm); }
.seg input:focus-visible + span { box-shadow: var(--ring); }
.tool-result .seg { background: var(--surface-3); }

.kv { display: grid; gap: 0; margin: 0; }
.kv-row { display: grid; grid-template-columns: minmax(120px, 38%) minmax(0, 1fr); gap: 12px; align-items: center; padding: 7px 0; border-bottom: 1px solid var(--border); }
.kv-row:last-child { border-bottom: 0; }
.kv dt { color: var(--muted); font-size: 13px; font-weight: 600; }
.kv dd { display: flex; align-items: center; gap: 6px; margin: 0; min-width: 0; flex-wrap: wrap; }
.kv dd .mono { font-family: var(--font-mono); font-size: 13.5px; overflow-wrap: anywhere; min-width: 0; }
.kv-hint { color: var(--muted); font-size: 12px; }
.kv-copy { display: inline-grid; place-items: center; width: 26px; height: 26px; margin-left: auto; border: 0; border-radius: 6px; background: transparent; color: var(--muted); cursor: pointer; flex: none; }
.kv-copy:hover, .kv-copy.is-done { background: var(--surface); color: var(--accent-text); }

.out { display: grid; gap: 0; min-width: 0; }
.out + .out { margin-top: 16px; }
.out-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap; margin-bottom: 8px; }
.out-head h3 { margin: 0; font-size: 13px; text-transform: uppercase; letter-spacing: .07em; color: var(--muted); }
.out-actions { display: flex; gap: 6px; }
.out pre { margin: 0; padding: 14px 16px; border-radius: 10px; background: #0d1117; color: #e6edf3; font-size: 13px; line-height: 1.6;
  overflow: auto; max-height: 560px; white-space: pre; tab-size: 4; }
.out pre.wrap { white-space: pre-wrap; word-break: break-all; }
.out-explain { margin: 10px 0 0; font-size: 14px; color: var(--text-2); }
.btn.is-done { color: var(--accent-text); border-color: color-mix(in srgb, var(--accent) 45%, var(--border)); }

.tool-msg { display: flex; align-items: flex-start; gap: 8px; margin: 0 0 12px; padding: 9px 12px; border-radius: var(--radius-sm); font-size: 13.5px; line-height: 1.45; }
.tool-msg .icon { flex: none; margin-top: 2px; }
.tool-msg-ok { background: var(--accent-soft); color: var(--accent-text); }
.tool-msg-warn { background: var(--warn-soft); color: var(--warn); }
.tool-msg-error { background: var(--danger-soft); color: var(--danger); }
.tool-msg-info { background: var(--info-soft); color: var(--info); }
.tool-msg:last-child { margin-bottom: 0; }
.tool-msgs:empty { display: none; }
.tool-msgs { margin-bottom: 12px; }

.tool-table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface); }
.tool-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.tool-table th, .tool-table td { padding: 7px 10px; text-align: left; border-bottom: 1px solid var(--border); white-space: nowrap; }
.tool-table th { position: sticky; top: 0; background: var(--surface-2); font-size: 12px; color: var(--muted); font-weight: 600; }
.tool-table .mono { font-family: var(--font-mono); font-size: 12.5px; }
.tool-table tr:last-child td { border-bottom: 0; }
.tool-table tr.is-current td { background: var(--accent-soft); color: var(--accent-text); font-weight: 600; }
.tool-table-tall { max-height: 440px; overflow: auto; }

.bin { font-family: var(--font-mono); font-size: 12.5px; overflow-wrap: anywhere; line-height: 1.7; }
.bin .n { color: var(--info); font-weight: 600; }
.bin .h { color: var(--muted); }

.bars { display: grid; gap: 10px; }
.bar-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 3px 10px; font-size: 13px; }
.bar-row .mono { font-family: var(--font-mono); overflow-wrap: anywhere; }
.bar { grid-column: 1 / -1; height: 7px; border-radius: 4px; background: var(--surface-3); overflow: hidden; }
.bar i { display: block; height: 100%; border-radius: 4px; background: var(--accent); }
.bar.warn i { background: var(--warn); }
.bar.danger i { background: var(--danger); }

.meter { display: grid; grid-template-columns: repeat(5, 1fr); gap: 4px; margin: 4px 0 8px; }
.meter i { height: 6px; border-radius: 3px; background: var(--surface-3); }
.meter[data-score="0"] i:nth-child(-n+1) { background: var(--danger); }
.meter[data-score="1"] i:nth-child(-n+2) { background: var(--danger); }
.meter[data-score="2"] i:nth-child(-n+3) { background: var(--warn); }
.meter[data-score="3"] i:nth-child(-n+4) { background: var(--accent); }
.meter[data-score="4"] i { background: var(--accent); }
.meter-label { display: flex; justify-content: space-between; gap: 10px; font-size: 13px; font-weight: 600; }

.pw-out { display: flex; align-items: center; gap: 8px; padding: 12px 12px 12px 16px; border-radius: 10px; background: var(--surface); border: 1px solid var(--border); }
.pw-out code { flex: 1; min-width: 0; font-size: 17px; font-weight: 500; overflow-wrap: anywhere; letter-spacing: .02em; }
.pw-list { display: grid; gap: 2px; margin: 10px 0 0; padding: 0; list-style: none; }
.pw-list li { display: flex; align-items: center; gap: 6px; padding: 3px 3px 3px 10px; border-radius: 6px; font: 13px var(--font-mono); }
.pw-list li:hover { background: var(--surface); }
.pw-list li span { flex: 1; overflow-wrap: anywhere; }
.tool input[type=range] { width: 100%; accent-color: var(--accent); }

.chips { display: flex; flex-wrap: wrap; gap: 5px; }
.chips label { position: relative; }
.chips input { position: absolute; opacity: 0; pointer-events: none; }
.chips span { display: inline-grid; place-items: center; min-width: 36px; height: 28px; padding: 0 8px; border: 1px solid var(--border); border-radius: 7px;
  font-size: 12.5px; font-weight: 600; color: var(--text-2); background: var(--surface); cursor: pointer; font-variant-numeric: tabular-nums; }
.chips input:checked + span { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.chips input:focus-visible + span { box-shadow: var(--ring); }

.cron-fields { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 6px; margin: 12px 0 0; text-align: center; }
.cron-fields div { padding: 8px 4px; border-radius: 8px; background: var(--surface); border: 1px solid var(--border); min-width: 0; }
.cron-fields code { display: block; font-size: 14px; font-weight: 600; overflow-wrap: anywhere; }
.cron-fields span { display: block; font-size: 11px; color: var(--muted); }
.cron-human { font-size: 19px; font-weight: 600; line-height: 1.35; margin: 0 0 4px; }
.cron-gen-field { padding: 14px 0; border-bottom: 1px solid var(--border); }
.cron-gen-field:first-of-type { padding-top: 0; }
.cron-gen-field:last-of-type { border-bottom: 0; }
.cron-gen-field .seg { margin-bottom: 8px; }
.runs { margin: 0; padding: 0; list-style: none; display: grid; gap: 4px; font-size: 13.5px; }
.runs li { display: flex; justify-content: space-between; gap: 10px; padding: 6px 10px; border-radius: 6px; background: var(--surface); }
.runs li span:last-child { color: var(--muted); }

.perm-grid { display: grid; grid-template-columns: auto repeat(3, minmax(0, 1fr)); gap: 6px; align-items: center; }
.perm-grid > span { font-size: 12px; font-weight: 600; color: var(--muted); text-align: center; }
.perm-grid > .perm-who { text-align: left; font-size: 13px; color: var(--text-2); padding-right: 6px; }
.perm-grid label { position: relative; display: grid; place-items: center; height: 34px; border-radius: 8px; border: 1px solid var(--border); background: var(--surface); cursor: pointer; font: 600 13px var(--font-mono); color: var(--muted); }
.perm-grid label:has(input:checked) { background: var(--accent-soft); border-color: color-mix(in srgb, var(--accent) 45%, var(--border)); color: var(--accent-text); }
.perm-grid label:has(input:focus-visible) { box-shadow: var(--ring); }
.perm-grid input { position: absolute; opacity: 0; pointer-events: none; }
.perm-big { display: flex; flex-wrap: wrap; align-items: baseline; gap: 6px 18px; margin-bottom: 12px; }
.perm-big code { font-size: 30px; font-weight: 600; letter-spacing: .04em; }
.perm-big .octal { color: var(--accent-text); }

.hash-list { display: grid; gap: 8px; }
.hash-row { padding: 10px 12px; border-radius: 10px; background: var(--surface); border: 1px solid var(--border); }
.hash-row.is-ok { border-color: color-mix(in srgb, var(--accent) 55%, var(--border)); }
.hash-row.is-bad { border-color: color-mix(in srgb, var(--danger) 45%, var(--border)); }
.hash-head { display: flex; align-items: center; gap: 8px; margin-bottom: 4px; font-size: 13px; }
.tool .hash-value { display: block; padding: 0; background: none; font-size: 12.5px; line-height: 1.5; white-space: normal; word-break: break-all; color: var(--text); }
.tool .json-caret { margin: 0 0 12px; padding: 8px 10px; border-radius: 8px; background: var(--surface); color: var(--danger); font-size: 12.5px; overflow-x: auto; white-space: pre; }
.consent-card h1 { font-size: 21px; }
.consent-logos { display: flex; align-items: center; gap: 10px; }
.consent-link { color: var(--muted); display: inline-grid; }
.consent-app { display: grid; place-items: center; flex: none; width: 46px; height: 46px; border-radius: 12px; background: #d97757; color: #fff; font: 700 20px var(--font-read); }
.consent-scopes { list-style: none; margin: 0 0 14px; padding: 0; display: grid; gap: 10px; }
.consent-scopes > li { display: flex; gap: 10px; align-items: flex-start; padding: 12px; border: 1px solid var(--border); border-radius: var(--radius-sm); }
.consent-scopes > li > .icon { flex: none; margin-top: 3px; color: var(--accent-text); }
.consent-scopes .check { margin: 0; }
.consent-note { display: flex; gap: 6px; align-items: flex-start; }
.consent-note .icon { flex: none; margin-top: 2px; }
.consent-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 18px; }
.connected-apps { margin-top: 18px; }
.connected-apps h3 { margin: 0 0 2px; font-size: 15px; }
.app-row { display: flex; align-items: center; gap: 12px; padding: 12px 0; border-top: 1px solid var(--border); margin-top: 12px; }
.app-row .consent-app { width: 36px; height: 36px; font-size: 16px; border-radius: 9px; }
.app-main { display: grid; flex: 1; min-width: 0; }
.app-empty { margin: 12px 0 0; }
.connect-hero { text-align: center; display: grid; justify-items: center; gap: 4px; margin-bottom: 30px; }
.connect-hero h1 { font-size: 28px; margin: 14px 0 4px; }
.connect-hero > p { max-width: 560px; margin: 0 0 12px; }
.connect-url { display: flex; align-items: center; gap: 8px; max-width: 100%; padding: 6px 6px 6px 14px; border: 1px solid var(--border-strong); border-radius: 999px; background: var(--surface); }
.connect-url code { font-size: 14px; overflow-wrap: anywhere; }
.connect-section { margin-bottom: 30px; }
.connect-section h2 { font-size: 19px; margin-bottom: 12px; }
.connect-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 10px; margin-bottom: 14px; }
.connect-card { display: grid; gap: 4px; padding: 16px; }
.connect-card .icon { color: var(--accent-text); }
.connect-card p { margin: 0; font-size: 13.5px; color: var(--text-2); }
.connect-prompts, .connect-list { margin: 0; padding-left: 20px; display: grid; gap: 6px; font-size: 14.5px; }
.connect-prompts li { font-style: italic; color: var(--text-2); }
.connect-steps { margin: 0; padding-left: 22px; display: grid; gap: 12px; }
.connect-steps ul { margin: 6px 0; }
.connect-pre { margin: 0 0 10px; padding: 12px 14px; border-radius: 10px; background: #0d1117; color: #e6edf3; overflow-x: auto; font-size: 13.5px; }
.connect-page code:not(pre code) { font-size: .9em; padding: 1px 5px; border-radius: 5px; background: var(--surface-2); overflow-wrap: anywhere; }
.connect-url code { background: none !important; padding: 0 !important; }
.connect-kv dd code { font-size: 12.5px; }
.tool-about { margin-top: 32px; max-width: 760px; color: var(--text-2); font-size: 14.5px; }
.tool-about h2, .tool-related h2 { font-size: 17px; color: var(--text); margin-bottom: 10px; }
.tool-about p, .tool-about ul { margin: 0 0 10px; }
.tool-about li { margin-bottom: 4px; }
.tool-about code, .tool :not(pre) > code { font-size: .9em; padding: 1px 5px; border-radius: 5px; background: var(--surface-2); }
.tool-result :not(pre) > code { background: var(--surface-3); }
.tool .cron-fields code, .tool .perm-big code, .tool .pw-out code { padding: 0; background: none; }
.tool-related { margin-top: 30px; }

@media (min-width: 901px) { .tool-sticky { position: sticky; top: calc(var(--topbar-h) + 16px); max-height: calc(100vh - var(--topbar-h) - 32px); overflow: auto; } }
@media (max-width: 900px) {
  .tool-layout, .tool-layout-even { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 640px) {
  .tool-head { align-items: flex-start; gap: 12px; }
  .tool-head h1 { font-size: 22px; }
  .tool-ico-lg { width: 44px; height: 44px; }
  .tool-panel { padding: 16px; }
  .tool-grid { grid-template-columns: 1fr; }
  .kv-row { grid-template-columns: 1fr; gap: 2px; }
  .cron-fields { grid-template-columns: repeat(5, minmax(56px, 1fr)); overflow-x: auto; }
  .perm-big code { font-size: 24px; }
  .out pre { font-size: 12.5px; padding: 12px; }
}
