/* Archaeo Design Vault — Developed by Archaeo Agency LLC
   Themes are CSS variables only; every component reads tokens, never raw colours. */

@font-face { font-family: "Manrope"; font-weight: 500; font-style: normal; font-display: swap; src: url("../fonts/manrope-latin-500-normal.woff2") format("woff2"); }
@font-face { font-family: "Manrope"; font-weight: 600; font-style: normal; font-display: swap; src: url("../fonts/manrope-latin-600-normal.woff2") format("woff2"); }
@font-face { font-family: "Manrope"; font-weight: 700; font-style: normal; font-display: swap; src: url("../fonts/manrope-latin-700-normal.woff2") format("woff2"); }
@font-face { font-family: "Manrope"; font-weight: 800; font-style: normal; font-display: swap; src: url("../fonts/manrope-latin-800-normal.woff2") format("woff2"); }
@font-face { font-family: "Poppins"; font-weight: 400; font-style: normal; font-display: swap; src: url("../fonts/poppins-latin-400-normal.woff2") format("woff2"); }
@font-face { font-family: "Poppins"; font-weight: 500; font-style: normal; font-display: swap; src: url("../fonts/poppins-latin-500-normal.woff2") format("woff2"); }
@font-face { font-family: "Poppins"; font-weight: 600; font-style: normal; font-display: swap; src: url("../fonts/poppins-latin-600-normal.woff2") format("woff2"); }

/* ---------------------------------------------------------------- themes */
:root, [data-theme="light"], [data-theme="system"] {
  color-scheme: light;
  --bg: #f4f6f8; --surface: #ffffff; --surface-2: #eef1f4; --surface-3: #e2e7ec;
  --border: #d3dae1; --border-strong: #aab5c0; --field-border: #76828e;
  --text: #111a23; --text-muted: #4b5866;
  --primary: #1d3557; --primary-hover: #142844; --on-primary: #ffffff;
  --accent: #8f5c06; --link: #1857a4; --focus: #2563c9;
  --danger: #b42318; --on-danger: #ffffff; --success: #19703a; --warning: #8a5300;
  --info-bg: #e6eefa; --info-text: #123a6b; --warn-bg: #fcf0da; --warn-text: #5f3b00;
  --ok-bg: #e3f3e8; --ok-text: #12552a; --err-bg: #fce7e5; --err-text: #8a1a10;
  --chip-bg: #eaeef2; --chip-text: #283441;
  --overlay: rgba(10, 15, 22, .55); --viewer-bg: rgba(8, 11, 15, .95);
  --shadow: 0 1px 2px rgba(16,24,40,.06), 0 4px 14px rgba(16,24,40,.07);
  --chart-1: #1d3557; --chart-2: #b9790f; --chart-3: #1f8a7e; --chart-4: #6c4fa0; --chart-5: #c23d50; --chart-6: #3f6e9e;
  --heat-0: #eef1f4; --heat-0-text: #4b5866; --heat-1: #d8e4f2; --heat-1-text: #15324f;
  --heat-2: #a9c3e3; --heat-2-text: #10273f; --heat-3: #3f6ea8; --heat-3-text: #ffffff; --heat-4: #1d3557; --heat-4-text: #ffffff;
}
[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0d1218; --surface: #141b23; --surface-2: #1b242e; --surface-3: #243039;
  --border: #2a3642; --border-strong: #41505f; --field-border: #738394;
  --text: #e8eef4; --text-muted: #a0aebb;
  --primary: #f0c26c; --primary-hover: #f6d391; --on-primary: #1b1405;
  --accent: #f0c26c; --link: #8cc2ff; --focus: #8cc2ff;
  --danger: #ff8f85; --on-danger: #200605; --success: #74d6a0; --warning: #f5c56f;
  --info-bg: #142739; --info-text: #b2d6ff; --warn-bg: #33270e; --warn-text: #f7d995;
  --ok-bg: #10301e; --ok-text: #a3e8bd; --err-bg: #3b1613; --err-text: #ffbab2;
  --chip-bg: #222d38; --chip-text: #d5dee7;
  --overlay: rgba(0, 0, 0, .65); --viewer-bg: rgba(0, 0, 0, .95);
  --shadow: 0 1px 2px rgba(0,0,0,.4), 0 6px 18px rgba(0,0,0,.35);
  --chart-1: #f0c26c; --chart-2: #7fb8ff; --chart-3: #5fd0c0; --chart-4: #c3a3ff; --chart-5: #ff8f9c; --chart-6: #9ad27a;
  --heat-0: #1b242e; --heat-0-text: #a0aebb; --heat-1: #2a3a2c; --heat-1-text: #d7f0d9; --heat-2: #3d5a37; --heat-2-text: #e6f6e3;
  --heat-3: #6a8f3f; --heat-3-text: #0d1406; --heat-4: #a7cf62; --heat-4-text: #0e1505;
}
[data-theme="oled"] {
  color-scheme: dark;
  --bg: #000000; --surface: #000000; --surface-2: #0e0e0e; --surface-3: #1a1a1a;
  --border: #262626; --border-strong: #3d3d3d; --field-border: #767676;
  --text: #f5f5f5; --text-muted: #a9a9a9;
  --primary: #f0c26c; --primary-hover: #f6d391; --on-primary: #000000;
  --accent: #f0c26c; --link: #93c6ff; --focus: #93c6ff;
  --danger: #ff8f85; --on-danger: #000000; --success: #74d6a0; --warning: #f5c56f;
  --info-bg: #0b1828; --info-text: #b2d6ff; --warn-bg: #221905; --warn-text: #f7d995;
  --ok-bg: #08200f; --ok-text: #a3e8bd; --err-bg: #2a0c09; --err-text: #ffbab2;
  --chip-bg: #161616; --chip-text: #e2e2e2;
  --overlay: rgba(0, 0, 0, .75); --viewer-bg: #000000;
  --shadow: none;
  --chart-1: #f0c26c; --chart-2: #7fb8ff; --chart-3: #5fd0c0; --chart-4: #c3a3ff; --chart-5: #ff8f9c; --chart-6: #9ad27a;
  --heat-0: #0e0e0e; --heat-0-text: #a9a9a9; --heat-1: #1f2c18; --heat-1-text: #d7f0d9; --heat-2: #34502a; --heat-2-text: #e6f6e3;
  --heat-3: #6a8f3f; --heat-3-text: #000000; --heat-4: #a7cf62; --heat-4-text: #000000;
}
[data-theme="slate"] {
  color-scheme: dark;
  --bg: #1f252d; --surface: #283039; --surface-2: #303a45; --surface-3: #3a4552;
  --border: #46525f; --border-strong: #5b6876; --field-border: #8e9caa;
  --text: #eef2f6; --text-muted: #bcc6d0;
  --primary: #a7cbff; --primary-hover: #c2dbff; --on-primary: #0c1a2c;
  --accent: #f3c977; --link: #b3d4ff; --focus: #f3c977;
  --danger: #ffaaa1; --on-danger: #2a0a07; --success: #93e2b5; --warning: #f7d08a;
  --info-bg: #2c425c; --info-text: #d6e8ff; --warn-bg: #4b3e22; --warn-text: #ffe6b0;
  --ok-bg: #24463a; --ok-text: #c8f3d8; --err-bg: #522d2d; --err-text: #ffd1cb;
  --chip-bg: #36414d; --chip-text: #e6ecf2;
  --overlay: rgba(10, 14, 18, .65); --viewer-bg: rgba(14, 18, 22, .96);
  --shadow: 0 1px 2px rgba(0,0,0,.3), 0 6px 18px rgba(0,0,0,.25);
  --chart-1: #a7cbff; --chart-2: #f3c977; --chart-3: #7fe0cf; --chart-4: #d4bbff; --chart-5: #ffadb8; --chart-6: #b5e28f;
  --heat-0: #303a45; --heat-0-text: #bcc6d0; --heat-1: #34506b; --heat-1-text: #e3efff; --heat-2: #4a6f94; --heat-2-text: #f2f8ff;
  --heat-3: #7fa6d1; --heat-3-text: #0c1a2c; --heat-4: #a7cbff; --heat-4-text: #0c1a2c;
}
@media (prefers-color-scheme: dark) {
  [data-theme="system"] {
    color-scheme: dark;
    --bg: #0d1218; --surface: #141b23; --surface-2: #1b242e; --surface-3: #243039;
    --border: #2a3642; --border-strong: #41505f; --field-border: #738394;
    --text: #e8eef4; --text-muted: #a0aebb;
    --primary: #f0c26c; --primary-hover: #f6d391; --on-primary: #1b1405;
    --accent: #f0c26c; --link: #8cc2ff; --focus: #8cc2ff;
    --danger: #ff8f85; --on-danger: #200605; --success: #74d6a0; --warning: #f5c56f;
    --info-bg: #142739; --info-text: #b2d6ff; --warn-bg: #33270e; --warn-text: #f7d995;
    --ok-bg: #10301e; --ok-text: #a3e8bd; --err-bg: #3b1613; --err-text: #ffbab2;
    --chip-bg: #222d38; --chip-text: #d5dee7;
    --overlay: rgba(0, 0, 0, .65); --viewer-bg: rgba(0, 0, 0, .95);
    --shadow: 0 1px 2px rgba(0,0,0,.4), 0 6px 18px rgba(0,0,0,.35);
    --chart-1: #f0c26c; --chart-2: #7fb8ff; --chart-3: #5fd0c0; --chart-4: #c3a3ff; --chart-5: #ff8f9c; --chart-6: #9ad27a;
    --heat-0: #1b242e; --heat-0-text: #a0aebb; --heat-1: #2a3a2c; --heat-1-text: #d7f0d9; --heat-2: #3d5a37; --heat-2-text: #e6f6e3;
    --heat-3: #6a8f3f; --heat-3-text: #0d1406; --heat-4: #a7cf62; --heat-4-text: #0e1505;
  }
}

/* ---------------------------------------------------------------- base */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font-family: "Poppins", system-ui, -apple-system, "Segoe UI", sans-serif; font-size: 15px; line-height: 1.55; color: var(--text); background: var(--bg); -webkit-font-smoothing: antialiased; }
h1, h2, h3, h4, .h1, .h2, .h3 { font-family: "Manrope", system-ui, sans-serif; line-height: 1.2; margin: 0 0 .5em; letter-spacing: -.01em; color: var(--text); }
h1, .h1 { font-size: 1.75rem; font-weight: 800; }
h2, .h2 { font-size: 1.3rem; font-weight: 700; }
h3, .h3 { font-size: 1.05rem; font-weight: 700; }
p { margin: 0 0 .9em; }
a { color: var(--link); text-underline-offset: 2px; }
a:hover { text-decoration-thickness: 2px; }
code, .mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: .9em; }
code { background: var(--surface-2); color: var(--text); padding: .1em .35em; border-radius: 5px; overflow-wrap: anywhere; }
img { max-width: 100%; }
hr { border: 0; border-top: 1px solid var(--border); margin: 1.5rem 0; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
.sr-only { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.sprite { display: none; }
.ic { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; vertical-align: -3px; }
.muted { color: var(--text-muted); }
.small { font-size: .86rem; }
.kbd { display: inline-block; min-width: 1.5em; padding: 0 .35em; border: 1px solid var(--border-strong); border-bottom-width: 2px; border-radius: 5px; font-size: .78rem; line-height: 1.5; text-align: center; background: var(--surface); color: var(--text); font-family: "Manrope", sans-serif; font-weight: 700; }
.skip { position: absolute; left: -999px; top: 8px; background: var(--primary); color: var(--on-primary); padding: 8px 14px; border-radius: 8px; z-index: 2000; }
.skip:focus { left: 8px; }
[hidden] { display: none !important; }

/* ---------------------------------------------------------------- shell */
.topbar { position: sticky; top: 0; z-index: 50; display: flex; align-items: center; gap: 14px; height: 60px; padding: 0 18px; background: var(--surface); border-bottom: 1px solid var(--border); }
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--text); flex: none; }
.logo-mark { display: inline-grid; place-items: center; width: 32px; height: 32px; border-radius: 9px; background: var(--primary); color: var(--on-primary); font-family: "Manrope", sans-serif; font-weight: 800; font-size: 17px; }
.logo-text { font-family: "Manrope", sans-serif; font-weight: 600; font-size: 15px; white-space: nowrap; }
.logo-text strong { font-weight: 800; }
.top-search { position: relative; flex: 1; max-width: 560px; margin-left: 12px; }
body .top-search input { padding-left: 40px; background: var(--surface-2); border-color: var(--field-border); }
.top-search .search-ic { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--text-muted); }
.top-actions { display: flex; align-items: center; gap: 8px; margin-left: auto; }
.icon-btn { display: inline-grid; place-items: center; width: 38px; height: 38px; border-radius: 9px; border: 1px solid transparent; background: transparent; color: var(--text); cursor: pointer; }
.icon-btn:hover { background: var(--surface-2); }
.avatar { width: 36px; height: 36px; border-radius: 50%; border: 0; background: var(--surface-3); color: var(--text); font-family: "Manrope", sans-serif; font-weight: 800; cursor: pointer; }
.nav-toggle { display: none; }
.shell { display: grid; grid-template-columns: 236px minmax(0, 1fr); min-height: calc(100vh - 60px - 52px); }
.sidebar { position: sticky; top: 60px; align-self: start; height: calc(100vh - 60px); overflow-y: auto; padding: 14px 10px 24px; background: var(--surface); border-right: 1px solid var(--border); }
.sidebar ul { list-style: none; margin: 0; padding: 0; }
.sidebar a { display: flex; align-items: center; gap: 11px; padding: 8px 12px; margin: 1px 0; border-radius: 9px; color: var(--text); text-decoration: none; font-weight: 500; font-size: .94rem; }
.sidebar a:hover { background: var(--surface-2); }
.sidebar a.active { background: var(--surface-3); font-weight: 600; }
.sidebar a.active .ic { color: var(--accent); }
.sidebar .count { margin-left: auto; min-width: 22px; padding: 0 7px; border-radius: 99px; background: var(--warn-bg); color: var(--warn-text); font-size: .78rem; font-weight: 600; text-align: center; }
.nav-label { margin: 18px 12px 6px; font-size: .74rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--text-muted); font-family: "Manrope", sans-serif; }
.nav-hint { margin: 22px 12px 0; font-size: .78rem; line-height: 2; }
.main { padding: 26px 30px 40px; min-width: 0; outline: none; }
.site-footer { padding: 16px 24px; text-align: center; font-size: .82rem; color: var(--text-muted); border-top: 1px solid var(--border); background: var(--surface); }
.nav-scrim { position: fixed; inset: 60px 0 0; background: var(--overlay); z-index: 40; }

.page-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 12px 20px; margin-bottom: 20px; }
.page-head h1 { margin: 0; }
.page-head .sub { margin: 4px 0 0; color: var(--text-muted); }
.actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }

/* ---------------------------------------------------------------- menus */
.menu { position: relative; }
.menu-pop { position: absolute; top: calc(100% + 6px); right: 0; min-width: 200px; padding: 6px; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; box-shadow: var(--shadow); z-index: 60; }
.menu-pop a, .menu-pop button { display: flex; align-items: center; gap: 10px; width: 100%; padding: 8px 10px; border: 0; border-radius: 8px; background: none; color: var(--text); font: inherit; text-align: left; text-decoration: none; cursor: pointer; }
.menu-pop a:hover, .menu-pop button:hover { background: var(--surface-2); }
.menu-pop [aria-checked="true"] { font-weight: 600; }
.menu-pop [aria-checked="true"]::after { content: "✓"; margin-left: auto; color: var(--text); }
.menu-pop form { margin: 0; }
.menu-head { padding: 8px 10px 10px; border-bottom: 1px solid var(--border); margin-bottom: 4px; display: grid; }
.menu-head .muted { font-size: .82rem; }
.theme-dot { width: 14px; height: 14px; border-radius: 50%; border: 1px solid var(--border-strong); }
.t-light { background: #ffffff; } .t-dark { background: #141b23; } .t-oled { background: #000000; } .t-slate { background: #283039; }
.t-system { background: linear-gradient(90deg, #ffffff 50%, #141b23 50%); }

/* ---------------------------------------------------------------- buttons & forms */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 38px; padding: 7px 14px; border: 1px solid var(--border-strong); border-radius: 9px; background: var(--surface); color: var(--text); font: 500 .92rem/1.2 "Poppins", sans-serif; text-decoration: none; cursor: pointer; white-space: nowrap; }
.btn:hover { background: var(--surface-2); }
.btn-primary { background: var(--primary); border-color: var(--primary); color: var(--on-primary); }
.btn-primary:hover { background: var(--primary-hover); border-color: var(--primary-hover); }
.btn-danger { background: var(--danger); border-color: var(--danger); color: var(--on-danger); }
.btn-danger:hover { filter: brightness(.95); background: var(--danger); }
.btn-ghost { border-color: transparent; background: transparent; }
.btn-sm { min-height: 32px; padding: 4px 10px; font-size: .85rem; }
.btn-lg { min-height: 46px; padding: 10px 20px; font-size: 1rem; }
.btn-block { width: 100%; }
.btn[disabled], .btn[aria-disabled="true"] { opacity: .55; cursor: not-allowed; }
label { display: block; font-weight: 500; font-size: .9rem; margin: 0 0 5px; }
input[type="text"], input[type="email"], input[type="password"], input[type="search"], input[type="url"], input[type="number"], input:not([type]), select, textarea {
  width: 100%; padding: 9px 12px; border: 1px solid var(--field-border); border-radius: 9px; background: var(--surface); color: var(--text); font: inherit; font-size: .95rem; min-height: 40px; }
textarea { min-height: 120px; resize: vertical; line-height: 1.5; }
input::placeholder, textarea::placeholder { color: var(--text-muted); opacity: 1; }
input[type="color"] { width: 44px; height: 38px; padding: 2px; border: 1px solid var(--field-border); border-radius: 9px; background: var(--surface); cursor: pointer; }
input[type="checkbox"], input[type="radio"] { width: 18px; height: 18px; accent-color: var(--primary); vertical-align: -3px; }
fieldset { border: 1px solid var(--border); border-radius: 12px; padding: 14px 16px 6px; margin: 0 0 16px; }
legend { padding: 0 6px; font-family: "Manrope", sans-serif; font-weight: 700; }
.stack > * + * { margin-top: 12px; }
.stack > label + input, .stack > label + select, .stack > label + textarea { margin-top: 0; }
fieldset > label { margin-top: 10px; }
.check { display: flex; gap: 10px; align-items: flex-start; font-weight: 400; margin: 8px 0; }
.hint { font-size: .84rem; color: var(--text-muted); margin: 4px 0 0; }
.field-error { color: var(--err-text); background: var(--err-bg); padding: 4px 8px; border-radius: 6px; font-size: .86rem; margin: 6px 0 0; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.row3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px 16px; }
.code-input { font-size: 1.4rem !important; letter-spacing: .3em; text-align: center; font-family: ui-monospace, monospace; }
.row-gap { display: flex; flex-wrap: wrap; gap: 8px; }

/* ---------------------------------------------------------------- cards, alerts, badges */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: 14px; padding: 20px; box-shadow: var(--shadow); }
.card + .card { margin-top: 18px; }
.card h2:first-child, .card h3:first-child { margin-top: 0; }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 18px; }
.cards .card + .card { margin-top: 0; }
.alert { padding: 11px 14px; border-radius: 10px; margin: 0 0 16px; border: 1px solid transparent; }
.alert-ok { background: var(--ok-bg); color: var(--ok-text); }
.alert-error { background: var(--err-bg); color: var(--err-text); }
.alert-warn { background: var(--warn-bg); color: var(--warn-text); }
.alert-info { background: var(--info-bg); color: var(--info-text); }
.alert h2, .alert h3 { color: inherit; }
.alert code { background: var(--surface); color: var(--text); }
.alert a { color: inherit; font-weight: 600; }
.badge { display: inline-flex; align-items: center; gap: 4px; padding: 1px 8px; border-radius: 99px; font-size: .76rem; font-weight: 600; background: var(--chip-bg); color: var(--chip-text); white-space: nowrap; }
.badge-ai { background: var(--info-bg); color: var(--info-text); }
.badge-warn { background: var(--warn-bg); color: var(--warn-text); }
.badge-ok { background: var(--ok-bg); color: var(--ok-text); }
.badge-err { background: var(--err-bg); color: var(--err-text); }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: 99px; background: var(--chip-bg); color: var(--chip-text); font-size: .82rem; text-decoration: none; border: 1px solid transparent; }
a.chip:hover { border-color: var(--border-strong); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.swatch { display: inline-block; width: 18px; height: 18px; border-radius: 5px; border: 1px solid var(--border-strong); vertical-align: -4px; }
.swatches { display: flex; gap: 4px; flex-wrap: wrap; }
.swatch-lg { width: 34px; height: 34px; border-radius: 8px; }
.empty { text-align: center; padding: 48px 20px; color: var(--text-muted); }
.empty .ic { width: 40px; height: 40px; margin-bottom: 10px; }
.divider { display: flex; align-items: center; gap: 12px; margin: 18px 0; color: var(--text-muted); font-size: .85rem; }
.divider::before, .divider::after { content: ""; flex: 1; border-top: 1px solid var(--border); }
.secret { display: inline-block; padding: 6px 10px; font-size: .95rem; user-select: all; }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 18px; overflow-x: auto; }
.tabs a { padding: 9px 14px; border-bottom: 3px solid transparent; color: var(--text-muted); text-decoration: none; font-weight: 500; white-space: nowrap; }
.tabs a.active { color: var(--text); border-color: var(--accent); font-weight: 600; }
.checklist { list-style: none; padding: 0; margin: 0 0 18px; }
.checklist li { display: flex; align-items: center; gap: 10px; padding: 7px 0; border-bottom: 1px solid var(--border); }
.checklist .dot { width: 10px; height: 10px; border-radius: 50%; flex: none; }
.checklist .ok .dot { background: var(--success); } .checklist .bad .dot { background: var(--danger); } .checklist .warn .dot { background: var(--warning); }
.checklist .detail { margin-left: auto; color: var(--text-muted); font-size: .86rem; text-align: right; }
.steps li { margin-bottom: 12px; }
.codes { columns: 2; font-size: 1.05rem; padding-left: 1.4em; }
.codes code { background: none; padding: 0; }
.pager { display: flex; align-items: center; justify-content: center; gap: 14px; margin: 22px 0; }

/* ---------------------------------------------------------------- tables */
.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: 12px; background: var(--surface); }
table.table { width: 100%; border-collapse: collapse; font-size: .9rem; }
.table th, .table td { padding: 10px 12px; text-align: left; border-bottom: 1px solid var(--border); vertical-align: top; }
.table th { font-family: "Manrope", sans-serif; font-weight: 700; font-size: .8rem; text-transform: uppercase; letter-spacing: .04em; color: var(--text-muted); background: var(--surface-2); white-space: nowrap; }
.table tr:last-child td { border-bottom: 0; }
.table td.num, .table th.num { text-align: right; font-variant-numeric: tabular-nums; }
.table .actions { justify-content: flex-end; }
.table form { margin: 0; display: inline; }

/* ---------------------------------------------------------------- bare (sign-in) */
body.bare { display: flex; flex-direction: column; min-height: 100vh; }
.bare-main { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 32px 16px; }
.bare-brand { display: flex; align-items: center; gap: 10px; margin-bottom: 22px; font-size: 17px; }
.bare-card { width: 100%; max-width: 430px; padding: 28px; }
.bare-card.wide { max-width: 720px; }
.qr { display: grid; place-items: center; margin: 12px auto; padding: 14px; width: 232px; height: 232px; background: #ffffff; border-radius: 12px; }
.qr svg, .qr img { width: 200px; height: 200px; }

/* ---------------------------------------------------------------- dashboard */
.stats { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 14px; margin-bottom: 20px; }
.stat { background: var(--surface); border: 1px solid var(--border); border-radius: 14px; padding: 16px 18px; box-shadow: var(--shadow); text-decoration: none; color: var(--text); display: block; }
a.stat:hover { border-color: var(--border-strong); }
.stat .label { font-size: .82rem; color: var(--text-muted); font-weight: 500; }
.stat .value { font-family: "Manrope", sans-serif; font-size: 1.75rem; font-weight: 800; line-height: 1.2; margin-top: 2px; }
.stat .foot { font-size: .8rem; color: var(--text-muted); margin-top: 4px; }
.stat.warn .value { color: var(--warning); }
.meter { height: 8px; border-radius: 99px; background: var(--surface-3); overflow: hidden; margin-top: 8px; }
.meter span { display: block; height: 100%; background: var(--chart-1); border-radius: 99px; width: 0; }
.meter.over span { background: var(--danger); }
.dash-grid { display: grid; grid-template-columns: repeat(12, 1fr); gap: 18px; }
.dash-grid > .card { margin: 0; }
.span-4 { grid-column: span 4; } .span-6 { grid-column: span 6; } .span-8 { grid-column: span 8; } .span-12 { grid-column: span 12; }
.chart { width: 100%; height: auto; display: block; }
.hbars { list-style: none; margin: 0; padding: 0; display: grid; gap: 7px; }
.hbars li { display: grid; grid-template-columns: minmax(70px, 34%) 1fr 3.2em; align-items: center; gap: 10px; font-size: .86rem; }
.hb-l { color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hb-t { width: 100%; height: 12px; display: block; border-radius: 4px; background: var(--surface-2); overflow: hidden; }
.hb-f { fill: var(--chart-1); } .hb-f.c2 { fill: var(--chart-2); } .hb-f.c3 { fill: var(--chart-3); }
.hb-v { color: var(--text-muted); font: 600 .84rem "Manrope", sans-serif; text-align: right; font-variant-numeric: tabular-nums; }
.chart .bar { fill: var(--chart-1); }
.chart .bar.c2 { fill: var(--chart-2); } .chart .bar.c3 { fill: var(--chart-3); }
.chart .lbl { fill: var(--text); font: 500 12px "Poppins", sans-serif; }
.chart .val { fill: var(--text-muted); font: 600 12px "Manrope", sans-serif; }
.chart .grid-line { stroke: var(--border); stroke-width: 1; }
.heat { border-collapse: separate; border-spacing: 3px; font-size: .8rem; width: 100%; }
.heat th { font-weight: 600; color: var(--text-muted); text-align: left; padding: 2px 6px; font-size: .76rem; white-space: nowrap; }
.heat td { text-align: center; padding: 6px 4px; border-radius: 6px; font-weight: 600; min-width: 34px; }
.heat-0 { background: var(--heat-0); color: var(--heat-0-text); } .heat-1 { background: var(--heat-1); color: var(--heat-1-text); }
.heat-2 { background: var(--heat-2); color: var(--heat-2-text); } .heat-3 { background: var(--heat-3); color: var(--heat-3-text); }
.heat-4 { background: var(--heat-4); color: var(--heat-4-text); }
.mini-list { list-style: none; margin: 0; padding: 0; }
.mini-list li { display: flex; gap: 12px; align-items: center; padding: 8px 0; border-bottom: 1px solid var(--border); }
.mini-list li:last-child { border-bottom: 0; }
.mini-list img { width: 56px; height: 42px; object-fit: cover; object-position: top; border-radius: 6px; background: var(--surface-2); flex: none; }
.mini-list .t { flex: 1; min-width: 0; }
.mini-list .t a { color: var(--text); text-decoration: none; font-weight: 500; display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mini-list .t span { font-size: .8rem; color: var(--text-muted); }

/* ---------------------------------------------------------------- designs grid */
.lib { display: grid; grid-template-columns: 250px minmax(0, 1fr); gap: 22px; align-items: start; }
.filters { position: sticky; top: 76px; max-height: calc(100vh - 92px); overflow-y: auto; background: var(--surface); border: 1px solid var(--border); border-radius: 14px; padding: 14px; }
.filters > summary { display: none; }
.filters h2 { font-size: .95rem; margin-bottom: 10px; }
.filters label { font-size: .82rem; margin-top: 10px; color: var(--text-muted); }
.filters select, .filters input { min-height: 36px; padding: 6px 10px; font-size: .9rem; }
.filters .color-row { display: flex; gap: 8px; align-items: center; }
.filters .preset-colors { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 6px; }
.filters .preset-colors button { width: 22px; height: 22px; border-radius: 6px; border: 1px solid var(--border-strong); cursor: pointer; padding: 0; }
.toolbar { display: flex; flex-wrap: wrap; gap: 8px 12px; align-items: center; margin-bottom: 14px; }
.toolbar .grow { flex: 1; min-width: 220px; }
.toolbar .smart { display: flex; gap: 8px; }
.toolbar .count { color: var(--text-muted); font-size: .9rem; }
.seg { display: inline-flex; border: 1px solid var(--field-border); border-radius: 9px; overflow: hidden; }
.seg button { border: 0; background: var(--surface); color: var(--text); padding: 6px 10px; font: inherit; font-size: .85rem; cursor: pointer; }
.seg button[aria-pressed="true"] { background: var(--surface-3); font-weight: 600; }
:root { --card-min: 220px; }
[data-density="compact"] { --card-min: 160px; }
[data-density="large"] { --card-min: 310px; }
.dgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(var(--card-min), 1fr)); gap: 16px; }
.dcard { position: relative; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; overflow: hidden; box-shadow: var(--shadow); transition: transform .12s ease, border-color .12s; }
.dcard:hover { transform: translateY(-2px); border-color: var(--border-strong); }
.dcard .thumb-link { display: block; aspect-ratio: 4 / 3; background: var(--surface-2); overflow: hidden; }
.dcard img.thumb { width: 100%; height: 100%; object-fit: cover; object-position: top center; display: block; }
.dcard .meta { padding: 9px 11px 11px; }
.dcard .title { display: block; font-weight: 600; font-size: .9rem; color: var(--text); text-decoration: none; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dcard .sub { display: flex; justify-content: space-between; align-items: center; gap: 6px; margin-top: 4px; font-size: .78rem; color: var(--text-muted); }
.dcard .score { font-family: "Manrope", sans-serif; font-weight: 800; color: var(--text); }
.dcard .sel { position: absolute; top: 8px; left: 8px; width: 26px; height: 26px; border-radius: 7px; background: var(--surface); border: 1px solid var(--field-border); display: none; place-items: center; cursor: pointer; }
.dcard .sel .ic { width: 16px; height: 16px; opacity: 0; }
.dcard .open-viewer { position: absolute; top: 8px; right: 8px; width: 30px; height: 30px; border-radius: 8px; border: 0; background: var(--surface); color: var(--text); display: grid; place-items: center; opacity: 0; cursor: pointer; box-shadow: var(--shadow); }
.dcard:hover .open-viewer, .dcard:focus-within .open-viewer { opacity: 1; }
.selecting .dcard .sel { display: grid; }
.dcard.selected { outline: 3px solid var(--focus); outline-offset: -1px; }
.dcard.selected .sel { background: var(--primary); border-color: var(--primary); color: var(--on-primary); }
.dcard.selected .sel .ic { opacity: 1; }
.dcard .flag { position: absolute; bottom: calc(100% - 26px); left: 8px; }
[data-density="compact"] .dcard .meta { padding: 6px 8px; }
[data-density="compact"] .dcard .sub { display: none; }
.bulkbar { position: sticky; bottom: 14px; z-index: 30; display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-top: 14px; padding: 10px 14px; background: var(--surface); border: 1px solid var(--border-strong); border-radius: 14px; box-shadow: var(--shadow); }
.bulkbar select, .bulkbar input { width: auto; min-height: 34px; padding: 4px 8px; font-size: .86rem; }
.load-more { display: flex; justify-content: center; margin: 24px 0; }
.spinner { width: 22px; height: 22px; border: 3px solid var(--surface-3); border-top-color: var(--text-muted); border-radius: 50%; animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------------------------------------------------------------- design detail */
.detail { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(300px, 1fr); gap: 24px; align-items: start; }
.preview-box { background: var(--surface-2); border: 1px solid var(--border); border-radius: 14px; overflow: hidden; cursor: zoom-in; position: relative; }
.preview-box img { display: block; width: 100%; height: auto; }
.fields { display: grid; grid-template-columns: 120px 1fr; gap: 8px 14px; margin: 0; font-size: .92rem; }
.fields dt { color: var(--text-muted); font-weight: 500; }
.fields dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }
.why { background: var(--surface-2); border-radius: 12px; padding: 14px 16px; }
.why h3 { display: flex; align-items: center; gap: 8px; }
.similar { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 12px; }
.similar a { display: block; border-radius: 10px; overflow: hidden; border: 1px solid var(--border); background: var(--surface-2); }
.similar img { width: 100%; aspect-ratio: 4/3; object-fit: cover; object-position: top; display: block; }
.versions { display: flex; gap: 10px; flex-wrap: wrap; }
.versions a { width: 90px; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; display: block; }
.versions a.primary { border-color: var(--accent); border-width: 2px; }
.versions img { width: 100%; aspect-ratio: 4/3; object-fit: cover; display: block; }

/* ---------------------------------------------------------------- viewer */
.viewer { position: fixed; inset: 0; z-index: 1000; background: var(--viewer-bg); display: flex; flex-direction: column; color: #f2f2f2; }
.viewer-bar { display: flex; align-items: center; gap: 8px; padding: 10px 14px; background: rgba(0,0,0,.55); }
.viewer-bar .title { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; color: #f2f2f2; }
.viewer-bar .zoom-level { min-width: 52px; text-align: center; font-variant-numeric: tabular-nums; color: #f2f2f2; }
.viewer button, .viewer a.vbtn { display: inline-grid; place-items: center; width: 40px; height: 40px; border-radius: 10px; border: 1px solid rgba(255,255,255,.25); background: rgba(0,0,0,.4); color: #ffffff; cursor: pointer; text-decoration: none; }
.viewer button:hover, .viewer a.vbtn:hover { background: rgba(255,255,255,.14); }
.viewer-stage { flex: 1; position: relative; overflow: hidden; touch-action: none; cursor: grab; }
.viewer-stage.dragging { cursor: grabbing; }
.viewer-stage img { position: absolute; left: 50%; top: 50%; max-width: none; transform-origin: 0 0; user-select: none; -webkit-user-drag: none; }
.viewer .nav-prev, .viewer .nav-next { position: absolute; top: 50%; transform: translateY(-50%); z-index: 2; width: 48px; height: 48px; }
.viewer .nav-prev { left: 14px; } .viewer .nav-next { right: 14px; }

/* ---------------------------------------------------------------- upload */
.dropzone { border: 2px dashed var(--border-strong); border-radius: 16px; padding: 42px 20px; text-align: center; background: var(--surface); transition: background .15s, border-color .15s; }
.dropzone.over { border-color: var(--focus); background: var(--info-bg); color: var(--info-text); }
.dropzone .ic { width: 42px; height: 42px; color: var(--text-muted); }
.dropzone h2 { margin: 10px 0 4px; }
.dropzone .pick { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; margin-top: 16px; }
.progress { height: 10px; border-radius: 99px; background: var(--surface-3); overflow: hidden; }
.progress > span { display: block; height: 100%; background: var(--chart-3); width: 0; transition: width .2s; }
.upload-summary { display: grid; gap: 8px; margin: 18px 0; }
.file-list { list-style: none; padding: 0; margin: 0; max-height: 420px; overflow-y: auto; border: 1px solid var(--border); border-radius: 12px; background: var(--surface); }
.file-list li { display: grid; grid-template-columns: minmax(0, 1fr) 90px 140px; gap: 12px; align-items: center; padding: 8px 12px; border-bottom: 1px solid var(--border); font-size: .86rem; }
.file-list li:last-child { border-bottom: 0; }
.file-list .name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-list .st { text-align: right; color: var(--text-muted); }
.file-list .st.ok { color: var(--success); } .file-list .st.err { color: var(--danger); }
.report-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; margin-bottom: 18px; }

/* ---------------------------------------------------------------- knowledge / markdown */
.md { line-height: 1.7; max-width: 820px; overflow-wrap: anywhere; }
.md h1 { font-size: 1.55rem; } .md h2 { font-size: 1.25rem; margin-top: 1.4em; } .md h3 { font-size: 1.05rem; margin-top: 1.2em; }
.md pre { background: var(--surface-2); color: var(--text); padding: 12px 14px; border-radius: 10px; overflow-x: auto; }
.md pre code { background: none; padding: 0; word-break: normal; }
.md blockquote { margin: 0 0 1em; padding: 6px 14px; border-left: 4px solid var(--border-strong); color: var(--text-muted); }
.md table { border-collapse: collapse; margin: 0 0 1em; }
.md th, .md td { border: 1px solid var(--border); padding: 6px 10px; }
.md ul, .md ol { padding-left: 1.4em; }
.split { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 24px; align-items: start; }
.side-card { position: sticky; top: 76px; }
.editor { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.editor textarea { min-height: 520px; font-family: ui-monospace, monospace; font-size: .88rem; }
.editor .md { border: 1px solid var(--border); border-radius: 10px; padding: 14px; max-height: 560px; overflow-y: auto; background: var(--surface); }
.diff { font-family: ui-monospace, monospace; font-size: .84rem; white-space: pre-wrap; background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 10px; max-height: 520px; overflow: auto; }
.diff .add { background: var(--ok-bg); color: var(--ok-text); display: block; }
.diff .del { background: var(--err-bg); color: var(--err-text); display: block; }
.doc-list { list-style: none; padding: 0; margin: 0; }
.doc-list li { padding: 12px 0; border-bottom: 1px solid var(--border); }
.doc-list li:last-child { border-bottom: 0; }
.doc-list a.t { font-weight: 600; color: var(--text); text-decoration: none; font-size: 1rem; }
.doc-list a.t:hover { text-decoration: underline; }
.doc-list p { margin: 4px 0 0; color: var(--text-muted); font-size: .88rem; }
mark { background: var(--warn-bg); color: var(--warn-text); padding: 0 2px; border-radius: 3px; }

/* ---------------------------------------------------------------- misc */
.toasts { position: fixed; right: 16px; bottom: 16px; z-index: 1100; display: grid; gap: 8px; }
.toast { padding: 11px 16px; border-radius: 10px; background: var(--surface); color: var(--text); border: 1px solid var(--border-strong); box-shadow: var(--shadow); max-width: 360px; }
.toast.err { background: var(--err-bg); color: var(--err-text); border-color: transparent; }
.toast.ok { background: var(--ok-bg); color: var(--ok-text); border-color: transparent; }
dialog.modal { border: 1px solid var(--border); border-radius: 16px; padding: 22px; background: var(--surface); color: var(--text); max-width: min(560px, 92vw); width: 100%; box-shadow: var(--shadow); }
dialog.modal::backdrop { background: var(--overlay); }
.shortcut-list { display: grid; grid-template-columns: auto 1fr; gap: 10px 16px; }
.shortcut-list dd { margin: 0; }
.kv { display: grid; grid-template-columns: 180px 1fr; gap: 6px 14px; }
.kv dt { color: var(--text-muted); }
.kv dd { margin: 0; overflow-wrap: anywhere; }
.inline-form { display: flex; flex-wrap: wrap; gap: 8px; align-items: flex-end; }
.inline-form > div { min-width: 160px; }
.consent { max-width: 520px; }
.consent .scopes { list-style: none; padding: 0; margin: 14px 0; }
.consent .scopes li { display: flex; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--border); }
.consent .host { font-size: 1.1rem; font-weight: 700; font-family: "Manrope", sans-serif; }
.spend { display: flex; align-items: baseline; gap: 6px; font-family: "Manrope", sans-serif; }
.spend strong { font-size: 1.5rem; font-weight: 800; }
.thumb-sm { width: 64px; height: 48px; object-fit: cover; object-position: top; border-radius: 6px; background: var(--surface-2); display: block; }
.review-item { display: grid; grid-template-columns: 28px 120px minmax(0, 1fr) auto; gap: 14px; align-items: center; padding: 12px 0; border-bottom: 1px solid var(--border); }
.review-item img { width: 120px; height: 90px; object-fit: cover; object-position: top; border-radius: 8px; background: var(--surface-2); }
.review-item .reason { color: var(--warn-text); background: var(--warn-bg); display: inline-block; padding: 2px 8px; border-radius: 6px; font-size: .84rem; margin-top: 4px; }

/* ---------------------------------------------------------------- responsive */
@media (max-width: 1180px) {
  .span-4 { grid-column: span 6; } .span-8 { grid-column: span 12; }
  .detail { grid-template-columns: 1fr; }
  .split { grid-template-columns: 1fr; }
  .side-card { position: static; }
}
@media (max-width: 900px) {
  .nav-toggle { display: inline-grid; }
  .shell { grid-template-columns: 1fr; }
  .sidebar { position: fixed; top: 60px; left: 0; bottom: 0; width: 270px; z-index: 45; transform: translateX(-102%); transition: transform .2s ease; box-shadow: var(--shadow); }
  body.nav-open .sidebar { transform: none; }
  .main { padding: 18px 14px 32px; }
  .lib { grid-template-columns: 1fr; }
  .filters { position: static; max-height: none; }
  .filters > summary { display: block; cursor: pointer; font-weight: 600; font-family: "Manrope", sans-serif; }
  .filters:not([open]) > :not(summary) { display: none; }
  .filters h2 { display: none; }
  .filters > summary::after { content: "▾"; float: right; color: var(--text-muted); }
  .filters[open] > summary::after { content: "▴"; }
  .filters[open] > summary { margin-bottom: 8px; }
  .span-4, .span-6 { grid-column: span 12; }
  .editor { grid-template-columns: 1fr; }
  .logo-text { display: none; }
  .hide-sm { display: none !important; }
  .row3 { grid-template-columns: 1fr; }
}
@media (max-width: 560px) {
  :root { --card-min: 150px; }
  [data-density="large"] { --card-min: 260px; }
  .dgrid { gap: 10px; }
  .top-search { margin-left: 0; }
  .row2 { grid-template-columns: 1fr; }
  .fields, .kv { grid-template-columns: 1fr; }
  .fields dt { margin-top: 6px; }
  .file-list li { grid-template-columns: minmax(0, 1fr) 70px; }
  .file-list li .bar { display: none; }
  .review-item { grid-template-columns: 28px 80px minmax(0, 1fr); }
  .review-item img { width: 80px; height: 60px; }
  .review-item .actions { grid-column: 1 / -1; }
  .codes { columns: 1; }
  .bare-card { padding: 20px; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }
@media print {
  .topbar, .sidebar, .site-footer, .btn, .toasts { display: none !important; }
  .shell { display: block; } body { background: #fff; color: #000; }
}

/* ---------------------------------------------------------------- additions */
.heat-link { display: block; color: inherit; text-decoration: none; }
.heat-link:hover { text-decoration: underline; }
.label { font-weight: 500; font-size: .9rem; margin: 0 0 5px; }
.grow { flex: 1; min-width: 200px; }
.consent .scopes .ic { margin-top: 3px; color: var(--accent); }
.doc-list input[type="checkbox"] { margin-right: 6px; }
.mini-list form { margin: 0; }
.chips form.chip { padding-right: 2px; }
.chips form.chip .btn { min-height: 22px; padding: 0 6px; }
details summary { cursor: pointer; font-weight: 500; margin: 8px 0; }
.toolbar form { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.toolbar form.grow input { flex: 1; min-width: 160px; }
