/* MORPHO 2027 — design tokens, light & dark themes, components */

:root {
  --brand: #6a2c91;
  --brand-strong: #561f78;
  --brand-soft: #f3ecf8;
  --accent: #b2489a;
  --bg: #f7f6f9;
  --surface: #ffffff;
  --surface-2: #f1eff5;
  --surface-3: #e7e4ee;
  --border: #e2dee9;
  --border-strong: #cbc5d6;
  --text: #1d1a24;
  --text-2: #5a5466;
  --text-3: #8a8496;
  --ok: #1f8a5b;
  --ok-soft: #e3f4ec;
  --warn: #a86a00;
  --warn-soft: #fff3d9;
  --danger: #c23b3b;
  --danger-soft: #fde8e8;
  --info: #2f6db3;
  --info-soft: #e5effa;
  --focus: 0 0 0 3px color-mix(in srgb, var(--brand) 35%, transparent);
  --shadow-1: 0 1px 2px rgba(25, 15, 40, .06), 0 1px 1px rgba(25, 15, 40, .04);
  --shadow-2: 0 6px 24px -6px rgba(25, 15, 40, .16), 0 2px 6px rgba(25, 15, 40, .06);
  --radius: 12px;
  --radius-sm: 8px;
  --radius-lg: 18px;
  --font: ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --nav-h: 60px;
  --maxw: 1280px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --brand: #b98ae0;
    --brand-strong: #cfa8ef;
    --brand-soft: #2c2236;
    --accent: #e07fc9;
    --bg: #121016;
    --surface: #1b1820;
    --surface-2: #231f2a;
    --surface-3: #2d2836;
    --border: #2f2a38;
    --border-strong: #433c4f;
    --text: #eeeaf3;
    --text-2: #b4adbf;
    --text-3: #847d90;
    --ok: #5fcf98;
    --ok-soft: #173126;
    --warn: #f0b545;
    --warn-soft: #332810;
    --danger: #f07878;
    --danger-soft: #3a1b1d;
    --info: #79acec;
    --info-soft: #182841;
    --shadow-1: 0 1px 2px rgba(0, 0, 0, .4);
    --shadow-2: 0 10px 30px -8px rgba(0, 0, 0, .6);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --brand: #b98ae0;
  --brand-strong: #cfa8ef;
  --brand-soft: #2c2236;
  --accent: #e07fc9;
  --bg: #121016;
  --surface: #1b1820;
  --surface-2: #231f2a;
  --surface-3: #2d2836;
  --border: #2f2a38;
  --border-strong: #433c4f;
  --text: #eeeaf3;
  --text-2: #b4adbf;
  --text-3: #847d90;
  --ok: #5fcf98;
  --ok-soft: #173126;
  --warn: #f0b545;
  --warn-soft: #332810;
  --danger: #f07878;
  --danger-soft: #3a1b1d;
  --info: #79acec;
  --info-soft: #182841;
  --shadow-1: 0 1px 2px rgba(0, 0, 0, .4);
  --shadow-2: 0 10px 30px -8px rgba(0, 0, 0, .6);
  color-scheme: dark;
}

/* ---------- base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font: 15px/1.55 var(--font);
  color: var(--text);
  background: var(--bg);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
img { max-width: 100%; display: block; }
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 2px; }
h1, h2, h3, h4 { line-height: 1.2; margin: 0 0 .5em; letter-spacing: -.01em; }
h1 { font-size: clamp(1.6rem, 2.6vw, 2.15rem); font-weight: 700; }
h2 { font-size: 1.3rem; font-weight: 650; }
h3 { font-size: 1.05rem; font-weight: 650; }
p { margin: 0 0 1em; }
small, .small { font-size: .85em; }
hr { border: 0; border-top: 1px solid var(--border); margin: 1.5rem 0; }
code { font-family: var(--mono); font-size: .9em; background: var(--surface-2); padding: .1em .35em; border-radius: 4px; }
:focus-visible { outline: none; box-shadow: var(--focus); border-radius: 6px; }
.muted { color: var(--text-2); }
.faint { color: var(--text-3); }
.nowrap { white-space: nowrap; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.icon { width: 1.15em; height: 1.15em; flex: none; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; vertical-align: -.2em; }
.stack > * + * { margin-top: var(--gap, 1rem); }
.row { display: flex; gap: .75rem; align-items: center; flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.row.end { justify-content: flex-end; }
.grow { flex: 1 1 auto; min-width: 0; }
.mt-0 { margin-top: 0; } .mt-1 { margin-top: .5rem; } .mt-2 { margin-top: 1rem; } .mt-3 { margin-top: 1.5rem; } .mt-4 { margin-top: 2.5rem; }
.mb-0 { margin-bottom: 0; } .mb-1 { margin-bottom: .5rem; } .mb-2 { margin-bottom: 1rem; }
.center { text-align: center; }
[hidden] { display: none !important; }

/* ---------- top navigation ---------- */
.topbar {
  position: sticky; top: 0; z-index: 50;
  height: var(--nav-h);
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  backdrop-filter: saturate(1.4) blur(10px);
  border-bottom: 1px solid var(--border);
}
.topbar-inner { max-width: var(--maxw); margin: 0 auto; height: 100%; padding: 0 20px; display: flex; align-items: center; gap: 18px; }
.brand { display: flex; align-items: center; gap: 10px; color: var(--text); font-weight: 750; letter-spacing: .06em; font-size: 1.05rem; }
.brand:hover { text-decoration: none; }
.brand-mark {
  width: 32px; height: 32px; border-radius: 10px; display: grid; place-items: center;
  background: radial-gradient(circle at 35% 35%, #d9a6e6 0 18%, transparent 19%), radial-gradient(circle at 50% 50%, var(--accent), var(--brand) 70%);
  box-shadow: inset 0 0 0 2px rgba(255,255,255,.25);
}
.brand small { font-weight: 500; letter-spacing: 0; color: var(--text-3); font-size: .72rem; display: block; line-height: 1; }
.mainnav { display: flex; gap: 2px; }
.mainnav a {
  display: flex; align-items: center; gap: 7px; padding: 7px 11px; border-radius: 9px;
  color: var(--text-2); font-weight: 550; font-size: .93rem;
}
.mainnav a:hover { background: var(--surface-2); color: var(--text); text-decoration: none; }
.mainnav a.active { color: var(--brand); background: var(--brand-soft); }
.nav-search { margin-left: auto; position: relative; width: min(320px, 30vw); }
.nav-search input[type="search"] { width: 100%; padding: 8px 12px 8px 36px; border-radius: 10px; background: var(--surface-2); border: 1px solid transparent; }
.nav-search input[type="search"]:focus { background: var(--surface); border-color: var(--border-strong); }
.nav-search .icon { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); color: var(--text-3); }
.navtoggle { display: none; }

.menu { position: relative; }
.menu > summary { list-style: none; cursor: pointer; display: flex; align-items: center; gap: 8px; padding: 5px 8px 5px 5px; border-radius: 999px; }
.menu > summary::-webkit-details-marker { display: none; }
.menu > summary:hover { background: var(--surface-2); }
.menu-panel {
  position: absolute; right: 0; top: calc(100% + 8px); min-width: 230px; z-index: 60;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-2); padding: 6px;
}
.menu-panel a, .menu-panel button {
  display: flex; align-items: center; gap: 10px; width: 100%; padding: 8px 10px; border-radius: 8px;
  color: var(--text); background: none; border: 0; font: inherit; text-align: left; cursor: pointer;
}
.menu-panel a:hover, .menu-panel button:hover { background: var(--surface-2); text-decoration: none; }
.menu-panel hr { margin: 6px 0; }
.menu-head { padding: 8px 10px 10px; border-bottom: 1px solid var(--border); margin-bottom: 6px; }
.avatar {
  width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center; flex: none;
  background: linear-gradient(135deg, var(--brand), var(--accent)); color: #fff; font-weight: 700; font-size: .8rem;
}

/* ---------- layout ---------- */
main { flex: 1; }
.container { max-width: var(--maxw); margin: 0 auto; padding: 28px 20px 60px; }
.container.narrow { max-width: 760px; }
.container.tight { max-width: 460px; }
.page-head { display: flex; gap: 16px; align-items: flex-end; justify-content: space-between; flex-wrap: wrap; margin-bottom: 22px; }
.page-head h1 { margin: 0; }
.page-head p { margin: .35rem 0 0; color: var(--text-2); }
.eyebrow { text-transform: uppercase; letter-spacing: .09em; font-size: .72rem; font-weight: 700; color: var(--accent); margin-bottom: .4rem; }
.breadcrumbs { font-size: .88rem; color: var(--text-3); margin-bottom: .5rem; display: flex; gap: 6px; flex-wrap: wrap; }
.breadcrumbs a { color: var(--text-2); }

.grid { display: grid; gap: 18px; }
.grid.cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid.cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid.auto { grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); }
.layout-sidebar { display: grid; grid-template-columns: 260px minmax(0, 1fr); gap: 28px; align-items: start; }
.layout-aside { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 28px; align-items: start; }

.footer { border-top: 1px solid var(--border); color: var(--text-3); font-size: .85rem; }
.footer .container { padding: 22px 20px; display: flex; gap: 18px; flex-wrap: wrap; justify-content: space-between; }
.footer a { color: var(--text-2); }

/* ---------- cards ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-1); }
.card-body { padding: 18px 20px; }
.card-head { padding: 14px 20px; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.card-head h2, .card-head h3 { margin: 0; }
.card.pad { padding: 18px 20px; }
.card.hover { transition: transform .15s ease, box-shadow .15s ease, border-color .15s; }
.card.hover:hover { transform: translateY(-2px); box-shadow: var(--shadow-2); border-color: var(--border-strong); }
.sticky { position: sticky; top: calc(var(--nav-h) + 16px); }

.case-card { display: flex; flex-direction: column; overflow: hidden; color: var(--text); }
.case-card:hover { text-decoration: none; }
.case-card .thumb { aspect-ratio: 16 / 10; background: var(--surface-3); position: relative; overflow: hidden; }
.case-card .thumb img { width: 100%; height: 100%; object-fit: cover; transition: transform .4s ease; }
.case-card:hover .thumb img { transform: scale(1.04); }
.case-card .thumb .badges { position: absolute; left: 10px; bottom: 10px; display: flex; gap: 6px; flex-wrap: wrap; }
.case-card .body { padding: 14px 16px 16px; display: flex; flex-direction: column; gap: 6px; flex: 1; }
.case-card .title { font-weight: 650; line-height: 1.3; }
.case-card .meta { color: var(--text-2); font-size: .86rem; display: flex; gap: 10px; flex-wrap: wrap; margin-top: auto; }
.case-card .meta span { display: inline-flex; align-items: center; gap: 4px; }
.noimg { display: grid; place-items: center; height: 100%; color: var(--text-3); }

.stat { padding: 16px 18px; }
.stat .value { font-size: 1.75rem; font-weight: 750; letter-spacing: -.02em; }
.stat .label { color: var(--text-2); font-size: .86rem; }

.tile { display: flex; gap: 14px; padding: 18px; align-items: flex-start; color: var(--text); }
.tile:hover { text-decoration: none; }
.tile .tile-icon { width: 44px; height: 44px; border-radius: 12px; display: grid; place-items: center; background: var(--brand-soft); color: var(--brand); flex: none; }
.tile .tile-icon .icon { width: 22px; height: 22px; }
.tile h3 { margin: 2px 0 4px; }
.tile p { margin: 0; color: var(--text-2); font-size: .9rem; }

/* ---------- hero ---------- */
.hero {
  position: relative; overflow: hidden; border-radius: var(--radius-lg); padding: 44px 40px;
  background:
    radial-gradient(600px 300px at 85% 10%, color-mix(in srgb, var(--accent) 35%, transparent), transparent 70%),
    radial-gradient(500px 280px at 0% 100%, color-mix(in srgb, var(--brand) 30%, transparent), transparent 70%),
    linear-gradient(135deg, #2a1340, #4b1f6c 60%, #6a2c91);
  color: #fff;
}
.hero h1 { color: #fff; font-size: clamp(1.9rem, 3.4vw, 2.7rem); max-width: 18ch; }
.hero p { color: rgba(255,255,255,.82); max-width: 60ch; font-size: 1.05rem; }
.hero .cells-deco { position: absolute; right: -40px; top: -40px; width: 380px; opacity: .55; pointer-events: none; }
.hero-search { display: flex; gap: 8px; max-width: 640px; margin-top: 22px; position: relative; }
.hero-search input[type="search"] { flex: 1; padding: 14px 16px 14px 44px; font-size: 1rem; border-radius: 12px; border: 0; background: rgba(255,255,255,.96); color: #1d1a24; }
.hero-search .icon { position: absolute; left: 15px; top: 50%; transform: translateY(-50%); color: #7a7388; }
.hero .chips a { background: rgba(255,255,255,.14); color: #fff; border-color: rgba(255,255,255,.2); }
.hero .chips a:hover { background: rgba(255,255,255,.24); }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  padding: 9px 15px; border-radius: 10px; border: 1px solid var(--border-strong);
  background: var(--surface); color: var(--text); font: 600 .92rem/1.2 var(--font); cursor: pointer;
  transition: background .12s, border-color .12s, color .12s, transform .05s;
  white-space: nowrap; text-decoration: none !important;
}
.btn:hover { background: var(--surface-2); }
.btn:active { transform: translateY(1px); }
.btn:disabled, .btn.disabled { opacity: .5; pointer-events: none; }
.btn-primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn-primary:hover { background: var(--brand-strong); border-color: var(--brand-strong); }
:root[data-theme="dark"] .btn-primary { color: #1b1022; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .btn-primary { color: #1b1022; } }
.btn-ghost { background: transparent; border-color: transparent; color: var(--text-2); }
.btn-ghost:hover { background: var(--surface-2); color: var(--text); }
.btn-danger { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 40%, transparent); }
.btn-danger:hover { background: var(--danger-soft); }
.btn-ok { background: var(--ok); border-color: var(--ok); color: #fff; }
.btn-ok:hover { filter: brightness(.95); background: var(--ok); }
.btn-sm { padding: 6px 10px; font-size: .84rem; border-radius: 8px; }
.btn-lg { padding: 13px 20px; font-size: 1rem; border-radius: 12px; }
.btn-icon { padding: 8px; }
.btn-block { width: 100%; }
.btn-group { display: inline-flex; }
.btn-group .btn { border-radius: 0; margin-left: -1px; }
.btn-group .btn:first-child { border-radius: 10px 0 0 10px; margin-left: 0; }
.btn-group .btn:last-child { border-radius: 0 10px 10px 0; }
.btn-group .btn.active { background: var(--brand-soft); color: var(--brand); border-color: var(--brand); z-index: 1; position: relative; }

/* ---------- chips & badges ---------- */
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  display: inline-flex; align-items: center; gap: 5px; padding: 4px 10px; border-radius: 999px; font-size: .83rem;
  background: var(--surface-2); color: var(--text-2); border: 1px solid var(--border); font-weight: 550;
}
a.chip:hover { border-color: var(--brand); color: var(--brand); text-decoration: none; }
.chip.active { background: var(--brand-soft); border-color: var(--brand); color: var(--brand); }
.chip.dx { background: var(--brand-soft); color: var(--brand); border-color: transparent; }
.chip.ct { background: var(--info-soft); color: var(--info); border-color: transparent; }
.chip.material { background: var(--ok-soft); color: var(--ok); border-color: transparent; }
.chip.term { background: var(--surface-3); }
.badge { display: inline-flex; align-items: center; gap: 4px; padding: 2px 8px; border-radius: 6px; font-size: .74rem; font-weight: 700; letter-spacing: .02em; background: var(--surface-3); color: var(--text-2); }
.badge.pending { background: var(--warn-soft); color: var(--warn); }
.badge.verified, .badge.public, .badge.active { background: var(--ok-soft); color: var(--ok); }
.badge.rejected, .badge.trash, .badge.blocked { background: var(--danger-soft); color: var(--danger); }
.badge.draft { background: var(--info-soft); color: var(--info); }
.badge.dark { background: rgba(15, 10, 20, .72); color: #fff; backdrop-filter: blur(4px); }
.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; background: currentColor; }

/* ---------- forms ---------- */
label { font-weight: 600; font-size: .9rem; }
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.field .hint { font-size: .82rem; color: var(--text-3); font-weight: 400; }
.field .error, .error-text { color: var(--danger); font-size: .84rem; }
input:not([type]), input[type="text"], input[type="email"], input[type="password"], input[type="search"], input[type="number"], input[type="url"],
select, textarea {
  width: 100%; padding: 9px 12px; border-radius: 10px; border: 1px solid var(--border-strong);
  background: var(--surface); color: var(--text); font: inherit; transition: border-color .12s, box-shadow .12s;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--brand); box-shadow: var(--focus); }
textarea { min-height: 90px; resize: vertical; }
select { appearance: none; background-image: linear-gradient(45deg, transparent 50%, var(--text-3) 50%), linear-gradient(135deg, var(--text-3) 50%, transparent 50%); background-position: calc(100% - 17px) 55%, calc(100% - 12px) 55%; background-size: 5px 5px; background-repeat: no-repeat; padding-right: 32px; }
input[type="checkbox"], input[type="radio"] { accent-color: var(--brand); width: 16px; height: 16px; }
.check { display: flex; gap: 9px; align-items: flex-start; font-weight: 500; cursor: pointer; }
.check input { margin-top: 3px; flex: none; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 16px; }
.form-grid .full { grid-column: 1 / -1; }
.form-grid.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.form-grid.cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
fieldset { border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px 4px; margin: 0 0 16px; }
legend { font-weight: 650; padding: 0 6px; }
.input-icon { position: relative; }
.input-icon .icon { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); color: var(--text-3); }
.input-icon input[type] { padding-left: 36px; }

/* ---------- alerts / flash ---------- */
.flashes { display: flex; flex-direction: column; gap: 8px; margin-bottom: 18px; }
.alert { padding: 11px 14px; border-radius: 10px; border: 1px solid; display: flex; gap: 10px; align-items: flex-start; font-size: .93rem; }
.alert.success { background: var(--ok-soft); border-color: color-mix(in srgb, var(--ok) 30%, transparent); color: var(--ok); }
.alert.error { background: var(--danger-soft); border-color: color-mix(in srgb, var(--danger) 30%, transparent); color: var(--danger); }
.alert.info { background: var(--info-soft); border-color: color-mix(in srgb, var(--info) 30%, transparent); color: var(--info); }
.alert.warn { background: var(--warn-soft); border-color: color-mix(in srgb, var(--warn) 30%, transparent); color: var(--warn); }
.alert .icon { margin-top: 2px; }

.toast-host { position: fixed; right: 18px; bottom: 18px; display: flex; flex-direction: column; gap: 8px; z-index: 200; }
.toast { background: var(--text); color: var(--bg); padding: 10px 14px; border-radius: 10px; box-shadow: var(--shadow-2); font-size: .9rem; animation: toast-in .2s ease; max-width: 360px; }
.toast.error { background: var(--danger); color: #fff; }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } }

/* ---------- tables ---------- */
.table-wrap { overflow-x: auto; }
table.table { width: 100%; border-collapse: collapse; font-size: .92rem; }
.table th { text-align: left; font-weight: 650; color: var(--text-2); font-size: .8rem; text-transform: uppercase; letter-spacing: .04em; padding: 10px 12px; border-bottom: 1px solid var(--border); background: var(--surface-2); white-space: nowrap; }
.table td { padding: 10px 12px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table tr:hover td { background: color-mix(in srgb, var(--surface-2) 60%, transparent); }
.table .thumb-sm { width: 64px; height: 44px; border-radius: 6px; object-fit: cover; background: var(--surface-3); }
.table.compact td { padding: 7px 10px; }
.data-table { border-collapse: collapse; width: 100%; font-size: .9rem; }
.data-table th, .data-table td { border: 1px solid var(--border); padding: 6px 10px; text-align: left; }
.data-table th { background: var(--surface-2); font-weight: 650; }
.data-table tr:nth-child(even) td { background: color-mix(in srgb, var(--surface-2) 45%, transparent); }

/* ---------- tabs & filters ---------- */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 18px; overflow-x: auto; }
.tabs a, .tabs button { padding: 10px 14px; color: var(--text-2); font-weight: 600; border: 0; background: none; border-bottom: 2px solid transparent; margin-bottom: -1px; cursor: pointer; font: 600 .93rem var(--font); white-space: nowrap; }
.tabs a:hover, .tabs button:hover { color: var(--text); text-decoration: none; }
.tabs .active { color: var(--brand); border-bottom-color: var(--brand); }
.filters { display: flex; flex-direction: column; gap: 18px; }
.filter-group h4 { font-size: .78rem; text-transform: uppercase; letter-spacing: .06em; color: var(--text-3); margin-bottom: 8px; }
.filter-list { display: flex; flex-direction: column; gap: 1px; max-height: 320px; overflow: auto; }
.filter-list a { display: flex; justify-content: space-between; gap: 8px; padding: 5px 9px; border-radius: 7px; color: var(--text-2); font-size: .9rem; }
.filter-list a:hover { background: var(--surface-2); color: var(--text); text-decoration: none; }
.filter-list a.active { background: var(--brand-soft); color: var(--brand); font-weight: 600; }
.filter-list a.depth-1 { padding-left: 22px; } .filter-list a.depth-2 { padding-left: 36px; }

.pagination { display: flex; gap: 4px; justify-content: center; margin-top: 28px; flex-wrap: wrap; }
.pagination a, .pagination span { min-width: 36px; height: 36px; display: grid; place-items: center; padding: 0 10px; border-radius: 9px; border: 1px solid var(--border); color: var(--text-2); background: var(--surface); }
.pagination a:hover { border-color: var(--brand); color: var(--brand); text-decoration: none; }
.pagination .current { background: var(--brand); border-color: var(--brand); color: #fff; }

.empty { text-align: center; padding: 50px 20px; color: var(--text-2); }
.empty .icon { width: 42px; height: 42px; color: var(--text-3); margin: 0 auto 10px; stroke-width: 1.5; display: block; }

/* ---------- cell gallery ---------- */
.cells { display: grid; grid-template-columns: repeat(auto-fill, minmax(var(--cell, 150px), 1fr)); gap: 10px; }
.cell { position: relative; border-radius: 10px; overflow: hidden; background: var(--surface-3); aspect-ratio: 1; display: block; color: #fff; box-shadow: var(--shadow-1); }
.cell img { width: 100%; height: 100%; object-fit: cover; transition: transform .25s ease; }
.cell:hover img { transform: scale(1.06); }
.cell .cap {
  position: absolute; inset: auto 0 0 0; padding: 18px 8px 7px; font-size: .76rem; line-height: 1.25;
  background: linear-gradient(transparent, rgba(10, 5, 15, .82)); opacity: 0; transition: opacity .15s;
}
.cell:hover .cap, .cell:focus .cap, .cells.captions .cell .cap { opacity: 1; }
.cell .cap b { display: block; font-size: .8rem; }
.cell .state { position: absolute; top: 6px; right: 6px; }
.cell:hover { text-decoration: none; }
.compare-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 22px; }
.compare-side h3 { display: flex; gap: 8px; align-items: center; }
.compare-a { --side: var(--brand); }
.compare-b { --side: var(--accent); }
.compare-side .card-head { border-top: 3px solid var(--side); border-radius: var(--radius) var(--radius) 0 0; }

/* atlas */
.atlas-type { display: flex; gap: 12px; align-items: center; padding: 10px; color: var(--text); border-radius: 12px; }
.atlas-type:hover { background: var(--surface-2); text-decoration: none; }
.atlas-type img, .atlas-type .ph { width: 64px; height: 64px; border-radius: 10px; object-fit: cover; flex: none; background: var(--surface-3); }
.atlas-type .n { color: var(--text-3); font-size: .82rem; }

/* wiki content */
.prose { line-height: 1.65; }
.prose p:last-child { margin-bottom: 0; }
.prose ul, .prose ol { padding-left: 1.3em; }
.prose blockquote { margin: 0 0 1em; padding: 4px 14px; border-left: 3px solid var(--brand); color: var(--text-2); }
.prose table { border-collapse: collapse; margin-bottom: 1em; }
.prose td, .prose th { border: 1px solid var(--border); padding: 4px 8px; }
.prose ins { background: var(--ok-soft); color: var(--ok); text-decoration: none; }
.prose del { background: var(--danger-soft); color: var(--danger); }

.editor { border: 1px solid var(--border-strong); border-radius: 10px; background: var(--surface); overflow: hidden; }
.editor-toolbar { display: flex; gap: 2px; padding: 5px; border-bottom: 1px solid var(--border); background: var(--surface-2); flex-wrap: wrap; }
.editor-toolbar button { border: 0; background: none; color: var(--text-2); padding: 5px 8px; border-radius: 6px; cursor: pointer; font: 600 .85rem var(--font); min-width: 30px; }
.editor-toolbar button:hover { background: var(--surface-3); color: var(--text); }
.editor-area { min-height: 140px; max-height: 50vh; overflow: auto; padding: 12px 14px; outline: none; }
.editor-area:empty::before { content: attr(data-placeholder); color: var(--text-3); }

/* timeline / list */
.list { display: flex; flex-direction: column; }
.list-item { display: flex; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--border); align-items: flex-start; }
.list-item:last-child { border-bottom: 0; }

/* progress bars */
.bar { height: 8px; border-radius: 999px; background: var(--surface-3); overflow: hidden; }
.bar > span { display: block; height: 100%; border-radius: inherit; background: linear-gradient(90deg, var(--brand), var(--accent)); }
.bar.ok > span { background: var(--ok); } .bar.warn > span { background: var(--warn); } .bar.bad > span { background: var(--danger); }
.spark { display: flex; align-items: flex-end; gap: 3px; height: 56px; }
.spark span { flex: 1; background: var(--brand-soft); border-radius: 3px 3px 0 0; position: relative; min-height: 2px; }
.spark span i { position: absolute; inset: auto 0 0 0; background: var(--brand); border-radius: inherit; }

/* dialog */
dialog { border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 0; background: var(--surface); color: var(--text); box-shadow: var(--shadow-2); max-width: min(560px, 94vw); width: 100%; }
dialog::backdrop { background: rgba(15, 8, 25, .45); backdrop-filter: blur(2px); }
.dialog-head { padding: 16px 20px; border-bottom: 1px solid var(--border); display: flex; justify-content: space-between; align-items: center; }
.dialog-head h3 { margin: 0; }
.dialog-body { padding: 18px 20px; }
.dialog-foot { padding: 14px 20px; border-top: 1px solid var(--border); display: flex; gap: 8px; justify-content: flex-end; background: var(--surface-2); }

/* auth */
.auth-wrap { min-height: calc(100vh - var(--nav-h) - 80px); display: grid; place-items: center; padding: 30px 16px; }
.auth-card { width: min(440px, 100%); }
.auth-card.wide { width: min(640px, 100%); }

/* ---------- trainer ---------- */
.trainer { max-width: 980px; margin: 0 auto; }
.trainer-progress { display: flex; gap: 14px; align-items: center; margin-bottom: 16px; }
.trainer-progress .bar { flex: 1; height: 10px; }
.trainer-stage { display: grid; grid-template-columns: minmax(0, min(460px, 52%)) minmax(0, 1fr); gap: 26px; align-items: start; }
.trainer-image { position: relative; border-radius: var(--radius-lg); overflow: hidden; background: #000; aspect-ratio: 1; box-shadow: var(--shadow-2); }
.trainer-image img { width: 100%; height: 100%; object-fit: contain; }
.trainer-image .ctx-toggle { position: absolute; left: 12px; bottom: 12px; }
.trainer-more { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 8px; }
.trainer-more img { border-radius: 10px; aspect-ratio: 1; object-fit: cover; }
.options { display: grid; gap: 10px; }
.option {
  display: flex; align-items: center; gap: 12px; padding: 14px 16px; border-radius: 12px; border: 1.5px solid var(--border-strong);
  background: var(--surface); color: var(--text); font: 600 1rem var(--font); cursor: pointer; text-align: left; transition: all .12s;
}
.option:hover:not(:disabled) { border-color: var(--brand); background: var(--brand-soft); }
.option kbd { font: 700 .75rem var(--mono); width: 24px; height: 24px; display: grid; place-items: center; border-radius: 6px; background: var(--surface-3); color: var(--text-2); flex: none; }
.option.correct { border-color: var(--ok); background: var(--ok-soft); color: var(--ok); }
.option.wrong { border-color: var(--danger); background: var(--danger-soft); color: var(--danger); }
.option:disabled { cursor: default; }
.feedback { border-radius: 14px; padding: 16px 18px; margin-top: 14px; animation: toast-in .2s ease; }
.feedback.ok { background: var(--ok-soft); }
.feedback.bad { background: var(--danger-soft); }
.feedback h3 { display: flex; gap: 8px; align-items: center; }
.feedback.ok h3 { color: var(--ok); } .feedback.bad h3 { color: var(--danger); }
.score-ring { width: 140px; height: 140px; margin: 0 auto 10px; }
.select-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 6px 18px; }
.select-grid .check { padding: 4px 0; font-size: .92rem; }
.select-grid .check .faint { margin-left: auto; font-weight: 500; font-size: .82rem; }
.cat-block { padding: 14px 0; border-bottom: 1px solid var(--border); }
.cat-block:last-child { border-bottom: 0; }

/* ---------- admin ---------- */
.admin-shell { display: grid; grid-template-columns: 236px minmax(0, 1fr); min-height: calc(100vh - var(--nav-h)); }
.admin-nav { border-right: 1px solid var(--border); background: var(--surface); padding: 18px 12px; position: sticky; top: var(--nav-h); height: calc(100vh - var(--nav-h)); overflow: auto; }
.admin-nav h4 { font-size: .72rem; text-transform: uppercase; letter-spacing: .08em; color: var(--text-3); margin: 16px 10px 6px; }
.admin-nav a { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 9px; color: var(--text-2); font-weight: 550; font-size: .93rem; }
.admin-nav a:hover { background: var(--surface-2); color: var(--text); text-decoration: none; }
.admin-nav a.active { background: var(--brand-soft); color: var(--brand); }
.admin-nav a .count { margin-left: auto; background: var(--warn-soft); color: var(--warn); font-size: .75rem; font-weight: 700; padding: 1px 7px; border-radius: 999px; }
.admin-main { padding: 26px 30px 60px; min-width: 0; }
.slide-block { margin-bottom: 18px; scroll-margin-top: calc(var(--nav-h) + 16px); }
.slide-block .card-head { background: var(--surface-2); border-radius: var(--radius) var(--radius) 0 0; }
.view-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 12px; }
.view-tile { border: 1px solid var(--border); border-radius: 10px; overflow: hidden; background: var(--surface); scroll-margin-top: calc(var(--nav-h) + 16px); }
.view-tile.inactive { opacity: .55; }
.view-tile .vt-img { aspect-ratio: 4 / 3; background: var(--surface-3); position: relative; cursor: grab; }
.view-tile .vt-img img { width: 100%; height: 100%; object-fit: cover; }
.view-tile .vt-img .badges { position: absolute; left: 6px; top: 6px; display: flex; gap: 4px; }
.view-tile .vt-body { padding: 8px 10px; }
.view-tile.dragging { opacity: .4; }
.view-tile.drop-target { outline: 2px dashed var(--brand); }
.dropzone {
  border: 2px dashed var(--border-strong); border-radius: var(--radius); padding: 26px; text-align: center; color: var(--text-2);
  transition: border-color .15s, background .15s; cursor: pointer; background: var(--surface);
}
.dropzone.over { border-color: var(--brand); background: var(--brand-soft); }
.dropzone .icon { width: 30px; height: 30px; color: var(--brand); margin: 0 auto 6px; display: block; }
.upload-list { display: flex; flex-direction: column; gap: 8px; margin-top: 12px; }
.upload-item { display: grid; grid-template-columns: 56px minmax(0, 1fr) 120px 180px 32px; gap: 10px; align-items: center; padding: 8px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface); }
.upload-item img, .upload-item .ph { width: 56px; height: 42px; object-fit: cover; border-radius: 6px; background: var(--surface-3); display: grid; place-items: center; color: var(--text-3); }
.upload-item .name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: .9rem; }
.review-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 14px; }
.review-card { overflow: hidden; }
.review-card .imgs { display: grid; grid-template-columns: 1fr 1fr; gap: 2px; background: #000; }
.review-card .imgs img { aspect-ratio: 1; object-fit: cover; width: 100%; }
.review-card .rc-body { padding: 10px 12px; }
.review-card .rc-actions { display: flex; gap: 6px; padding: 0 12px 12px; flex-wrap: wrap; }
.review-card.done { opacity: .5; }
.review-card .sel { position: absolute; top: 8px; left: 8px; z-index: 2; }
.review-card { position: relative; }
.diff { font-size: .9rem; line-height: 1.6; }
.diff ins { background: var(--ok-soft); color: var(--ok); text-decoration: none; padding: 0 2px; border-radius: 3px; }
.diff del { background: var(--danger-soft); color: var(--danger); padding: 0 2px; border-radius: 3px; }
.inline-form { display: inline; }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: 6px 16px; font-size: .92rem; }
.kv dt { color: var(--text-3); }
.kv dd { margin: 0; }

/* ---------- responsive ---------- */
@media (max-width: 1080px) {
  .mainnav a span { display: none; }
  .layout-aside { grid-template-columns: 1fr; }
}
@media (max-width: 860px) {
  .grid.cols-3, .grid.cols-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .layout-sidebar { grid-template-columns: 1fr; }
  .compare-cols { grid-template-columns: 1fr; }
  .admin-shell { grid-template-columns: 1fr; }
  .admin-nav { position: static; height: auto; display: flex; flex-wrap: wrap; gap: 4px; border-right: 0; border-bottom: 1px solid var(--border); }
  .admin-nav h4 { display: none; }
  .admin-main { padding: 20px 16px 50px; }
  .upload-item { grid-template-columns: 56px minmax(0, 1fr); }
  .nav-search { display: none; }
  .form-grid, .form-grid.cols-3, .form-grid.cols-4 { grid-template-columns: 1fr; }
}
@media (max-width: 640px) {
  .trainer-stage { grid-template-columns: 1fr; }
  .trainer-image { max-width: 420px; margin: 0 auto; }
  .grid.cols-2, .grid.cols-3, .grid.cols-4 { grid-template-columns: 1fr; }
  .topbar-inner { padding: 0 12px; gap: 8px; }
  .mainnav { gap: 0; }
  .mainnav a { padding: 7px 8px; }
  .hero { padding: 30px 22px; }
  .container { padding: 20px 14px 50px; }
  .brand small { display: none; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }

/* forms inside the narrow right-hand column are always single column */
.layout-aside > aside .form-grid { grid-template-columns: 1fr; }

/* cell features (qualifiers) */
.chip.feat { background: var(--warn-soft); color: var(--warn); border-color: transparent; }
.badge.feat { background: var(--warn-soft); color: var(--warn); font-weight: 650; }
.fchips { display: flex; flex-wrap: wrap; gap: 5px; }
.fchip {
  border: 1px dashed var(--border-strong); background: var(--surface); color: var(--text-2);
  border-radius: 999px; padding: 3px 10px; font: 600 .8rem var(--font); cursor: pointer;
}
.fchip:hover { border-color: var(--warn); color: var(--text); }
.fchip.on { border-style: solid; border-color: var(--warn); background: var(--warn-soft); color: var(--warn); }
.fchip.more { border-style: solid; color: var(--text-3); }

/* compare: true size – every tile shows the same physical area */
.cells.true-size { grid-template-columns: repeat(auto-fill, var(--cell)); justify-content: start; }
.cells.true-size .cell { width: var(--cell); height: var(--cell); }
.cells.true-size .cell:hover img { transform: none; }
.scale-note { display: flex; gap: 14px; align-items: center; flex-wrap: wrap; padding: 10px 14px; border-radius: 10px; background: var(--surface); border: 1px solid var(--border); font-size: .88rem; color: var(--text-2); }
.scale-bar { display: inline-flex; flex-direction: column; align-items: center; gap: 3px; font-weight: 700; color: var(--text); font-size: .8rem; }
.scale-bar i { display: block; height: 6px; border: 2px solid var(--text); border-top: 0; }

/* trainer: magnification of the shown cell */
.trainer-image .mag-badge { position: absolute; top: 12px; left: 12px; }
