/* Ассеты — tokens and components. Values come from DESIGN.md; add roles there first. */

@font-face {
  font-family: "Geologica"; font-style: normal; font-display: swap; font-weight: 100 900;
  src: url("/fonts/geologica-cyrillic.woff2") format("woff2-variations"), url("/fonts/geologica-cyrillic.woff2") format("woff2");
  unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116;
}
@font-face {
  font-family: "Geologica"; font-style: normal; font-display: swap; font-weight: 100 900;
  src: url("/fonts/geologica-latin.woff2") format("woff2-variations"), url("/fonts/geologica-latin.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

:root {
  color-scheme: dark;
  /* color */
  --color-canvas: #000000;
  --color-surface: #161617;
  --color-surface-raised: #1d1d1f;
  --color-text: #f5f5f7;
  --color-text-secondary: #a1a1a6;
  --color-hairline: rgb(255 255 255 / 0.1);
  --color-field-border: #86868b;
  --color-action: #f5f5f7;
  --color-on-action: #000000;
  --color-link: #2997ff;
  --color-focus: #2997ff;
  --color-danger: #ff453a;
  --color-glass: rgb(22 22 23 / 0.8);
  /* space */
  --space-4: 4px; --space-8: 8px; --space-12: 12px; --space-16: 16px; --space-20: 20px;
  --space-24: 24px; --space-32: 32px; --space-40: 40px; --space-48: 48px; --space-64: 64px;
  /* radius */
  --radius-card: 18px; --radius-sheet: 20px; --radius-field: 12px; --radius-pill: 9999px;
  /* motion */
  --motion-micro: 200ms; --motion-small: 300ms; --motion-medium: 400ms;
  --ease-standard: cubic-bezier(0.28, 0.11, 0.32, 1);
  /* layout */
  --sidebar-w: 248px;
  --page-pad: var(--space-24);
  --topbar-h: 64px;
  /* interaction kit mapping */
  --ui-focus-ring: var(--color-focus);
  --ui-check-on: var(--color-link);
  --ui-check-border: var(--color-field-border);
  --ui-seg-track: var(--color-surface);
  --ui-seg-indicator: var(--color-surface-raised);
  --font: "Geologica", -apple-system, BlinkMacSystemFont, system-ui, "Segoe UI", Roboto, sans-serif;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scrollbar-color: #3a3a3c transparent; }
body {
  margin: 0; background: var(--color-canvas); color: var(--color-text);
  font: 400 15px/22px var(--font);
  font-variation-settings: "CRSV" 0, "SHRP" 0, "slnt" 0;
  -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale;
}
button, input, select { font: inherit; color: inherit; font-variation-settings: inherit; }
h1, h2, p, dl, dd { margin: 0; }
img { display: block; max-width: 100%; }
[hidden] { display: none !important; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.icon { width: 20px; height: 20px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; }
:focus-visible { outline: 2px solid var(--color-focus); outline-offset: 2px; }

/* type roles */
.type-large { font-size: 28px; line-height: 34px; font-weight: 500; letter-spacing: -0.025em; }
.type-title { font-size: 22px; line-height: 28px; font-weight: 500; letter-spacing: -0.02em; }
.type-headline { font-size: 15px; line-height: 20px; font-weight: 500; letter-spacing: -0.005em; }

/* ── top bar ─────────────────────────────────────────────── */
.topbar {
  position: sticky; top: 0; z-index: 10;
  background: var(--color-glass); -webkit-backdrop-filter: blur(20px) saturate(180%); backdrop-filter: blur(20px) saturate(180%);
  border-bottom: 1px solid var(--color-hairline);
}
.topbar__inner {
  max-width: 1680px; margin: 0 auto; height: var(--topbar-h); padding: 0 var(--page-pad);
  display: grid; grid-template-columns: var(--sidebar-w) minmax(0, 1fr) auto; column-gap: var(--space-40); align-items: center;
}
.brand { justify-self: start; font-size: 17px; line-height: 22px; font-weight: 500; letter-spacing: -0.01em; color: var(--color-text); text-decoration: none; border-radius: 6px; }
.search { position: relative; max-width: 560px; width: 100%; }
.search__input {
  width: 100%; height: 40px; padding: 0 44px 0 40px; border-radius: var(--radius-field);
  background: var(--color-surface-raised); border: 1px solid var(--color-field-border); outline: none;
  font-size: 15px; -webkit-appearance: none; appearance: none;
}
.search__input::placeholder { color: var(--color-text-secondary); }
.search__input::-webkit-search-cancel-button { display: none; }
.search__icon { position: absolute; left: 12px; top: 10px; color: var(--color-text-secondary); pointer-events: none; }
.search__key {
  position: absolute; right: 10px; top: 9px; min-width: 22px; height: 22px; padding: 0 6px; border-radius: 6px;
  border: 1px solid var(--color-hairline); color: var(--color-text-secondary); font: 400 12px/20px var(--font); text-align: center;
}
.search__input:focus ~ .search__key, .search__input:not(:placeholder-shown) ~ .search__key { display: none; }
.search__clear { position: absolute; right: 4px; top: 4px; width: 32px; height: 32px; }

/* ── page ────────────────────────────────────────────────── */
.page {
  max-width: 1680px; margin: 0 auto; padding: 0 var(--page-pad) var(--space-64);
  display: grid; grid-template-columns: var(--sidebar-w) minmax(0, 1fr); column-gap: var(--space-40); align-items: start;
}
.sidebar {
  position: sticky; top: var(--topbar-h); max-height: calc(100dvh - var(--topbar-h)); overflow-y: auto;
  padding: var(--space-24) 0 var(--space-24); margin: 0 calc(-1 * var(--space-8)); padding-inline: var(--space-8);
  scrollbar-width: thin;
}
.side-head { display: flex; align-items: center; justify-content: space-between; gap: var(--space-12); min-height: 32px; margin-bottom: var(--space-8); padding-inline: var(--space-8); }
.text-btn { border: 0; background: none; padding: 4px 0; color: var(--color-link); font-size: 13px; line-height: 18px; cursor: pointer; border-radius: 6px; }

.cat-list { display: flex; flex-direction: column; }
.cat-row {
  display: grid; grid-template-columns: 22px minmax(0, 1fr) auto; align-items: center; column-gap: var(--space-12);
  min-height: 36px; padding: 0 var(--space-8); border: 0; border-radius: var(--radius-field);
  background: transparent; text-align: left; cursor: pointer; font-size: 13px; line-height: 18px; color: var(--color-text-secondary);
}
.cat-row[aria-checked="true"] { color: var(--color-text); }
@media (hover: hover) and (pointer: fine) { .cat-row:hover { background: var(--color-surface); color: var(--color-text); } }
.cat-row .ui-check { width: 18px; height: 18px; border-radius: 6px; pointer-events: none; justify-self: center; }
.cat-row .ui-check svg { width: 12px; height: 12px; }
.cat-row__label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cat-row__n { font-size: 12px; line-height: 16px; color: var(--color-text-secondary); font-variant-numeric: tabular-nums; }
.cat-row[data-empty] { opacity: 0.45; }
.cat-more { display: flex; align-items: center; gap: var(--space-8); margin-top: var(--space-4); padding: 8px var(--space-8); min-height: 36px; }
.cat-more .icon { width: 16px; height: 16px; transition: transform var(--motion-small) var(--ease-standard); }
.cat-more[aria-expanded="true"] .icon { transform: rotate(180deg); }

/* ── content ─────────────────────────────────────────────── */
.content { min-width: 0; padding-top: var(--space-24); }
.summary { display: flex; align-items: baseline; gap: var(--space-12); min-height: 34px; }
.count { font-variant-numeric: tabular-nums; }
.toolbar { display: flex; align-items: center; justify-content: space-between; gap: var(--space-16); margin-top: var(--space-16); flex-wrap: wrap; }
.toolbar__end { display: flex; align-items: center; gap: var(--space-12); }

.formats { max-width: 100%; overflow-x: auto; scrollbar-width: none; }
.formats::-webkit-scrollbar { display: none; }
.formats > button { display: inline-flex; align-items: center; gap: var(--space-8); height: 32px; padding: 0 14px; font-size: 13px; line-height: 18px; white-space: nowrap; opacity: 0.72; }
.seg-count { color: var(--color-text-secondary); font-size: 12px; font-variant-numeric: tabular-nums; }

/* provenance marks: shape carries the meaning, not colour */
.mark { width: 10px; height: 10px; border-radius: 50%; flex: none; border: 1.5px solid currentColor; display: inline-block; }
.mark--bought { background: currentColor; }
.mark--free { background: transparent; }
.mark--pirate { background: linear-gradient(90deg, currentColor 50%, transparent 50%); }

.pill-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--space-8);
  height: 44px; padding: 0 22px; border-radius: var(--radius-pill); border: 0; cursor: pointer;
  background: var(--color-action); color: var(--color-on-action); font-size: 15px; line-height: 20px; text-decoration: none; white-space: nowrap;
}
.pill-btn--secondary { background: transparent; color: var(--color-text); box-shadow: inset 0 0 0 1px var(--color-field-border); }
.pill-btn--sm { height: 32px; padding: 0 14px; font-size: 13px; background: var(--color-surface); color: var(--color-text); }
.pill-btn--sm .icon { width: 16px; height: 16px; }
.icon-btn { display: inline-grid; place-items: center; width: 40px; height: 40px; border-radius: var(--radius-pill); border: 0; background: transparent; color: var(--color-text); cursor: pointer; }
.icon-btn .icon { width: 18px; height: 18px; }
.icon-btn--glass { background: rgb(0 0 0 / 0.55); -webkit-backdrop-filter: blur(20px) saturate(180%); backdrop-filter: blur(20px) saturate(180%); }
.cats-btn { display: none; }
.cats-btn__n { min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px; background: var(--color-link); color: #fff; font-size: 12px; line-height: 18px; text-align: center; }

.sort { position: relative; display: inline-flex; }
.sort__select {
  height: 32px; padding: 0 32px 0 14px; border-radius: var(--radius-pill); border: 0; background: var(--color-surface);
  font-size: 13px; line-height: 18px; cursor: pointer; -webkit-appearance: none; appearance: none;
}
.sort__select option { background: var(--color-surface-raised); }
.sort__chevron { position: absolute; right: 10px; top: 8px; width: 16px; height: 16px; color: var(--color-text-secondary); pointer-events: none; }

.active { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-8); margin-top: var(--space-16); }
.chip {
  display: inline-flex; align-items: center; gap: 6px; height: 32px; padding: 0 12px; border-radius: var(--radius-pill);
  border: 0; background: var(--color-surface-raised); color: var(--color-text); font-size: 13px; line-height: 18px; cursor: pointer; white-space: nowrap;
}
.chip .icon { width: 14px; height: 14px; color: var(--color-text-secondary); }

/* ── grid ────────────────────────────────────────────────── */
.grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(232px, 1fr)); gap: var(--space-24);
  margin-top: var(--space-24);
}
.grid[data-refresh] { animation: grid-in var(--motion-small) var(--ease-standard); }
@keyframes grid-in { from { opacity: 0.35; } to { opacity: 1; } }

.card {
  display: flex; flex-direction: column; min-width: 0; padding: 0; border: 0; text-align: left; cursor: pointer;
  background: var(--color-surface); border-radius: var(--radius-card); color: inherit;
  content-visibility: auto; contain-intrinsic-size: auto 260px;
}
.card__media { aspect-ratio: 3 / 2; width: 100%; background: var(--color-surface-raised); overflow: hidden; }
.card__media img { width: 100%; height: 100%; object-fit: cover; opacity: 0; transition: opacity var(--motion-small) var(--ease-standard); }
.card__media img[data-loaded] { opacity: 1; }
.card__media--none { display: grid; place-items: center; color: var(--color-text-secondary); font-size: 28px; font-weight: 500; letter-spacing: -0.02em; }
.card__body { display: flex; flex-direction: column; gap: var(--space-4); padding: var(--space-12) var(--space-16) var(--space-16); }
.card__name { overflow-wrap: anywhere; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; min-height: 40px; }
.card__meta { display: flex; align-items: center; gap: var(--space-8); color: var(--color-text-secondary); font-size: 13px; line-height: 18px; }
.card__cats { min-width: 0; flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.skeleton { background: var(--color-surface); border-radius: var(--radius-card); overflow: hidden; }
.skeleton__media { aspect-ratio: 3 / 2; background: var(--color-surface-raised); }
.skeleton__line { height: 12px; margin: 16px 16px 0; border-radius: 6px; background: var(--color-surface-raised); }
.skeleton__line + .skeleton__line { width: 55%; margin-bottom: 20px; }
.skeleton > * { animation: shimmer 1.4s ease-in-out infinite; }
@keyframes shimmer { 50% { opacity: 0.55; } }

.state { display: flex; flex-direction: column; align-items: flex-start; gap: var(--space-8); margin-top: var(--space-48); max-width: 480px; }
.state .pill-btn { margin-top: var(--space-16); }
.state__text { color: var(--color-text-secondary); }
.state__error { display: inline-flex; align-items: center; gap: var(--space-8); }
.state__error .icon { color: var(--color-danger); }
.foot { margin-top: var(--space-48); color: var(--color-text-secondary); font-size: 12px; line-height: 16px; }

/* ── sheet ───────────────────────────────────────────────── */
.sheet {
  width: min(720px, calc(100vw - 32px)); max-height: calc(100dvh - 48px); padding: 0; border: 0; border-radius: var(--radius-sheet);
  background: var(--color-surface); color: var(--color-text); overflow: auto; overscroll-behavior: contain;
}
.sheet::backdrop { -webkit-backdrop-filter: blur(4px); backdrop-filter: blur(4px); }
.sheet__media { aspect-ratio: 3 / 2; background: var(--color-surface-raised); }
.sheet__media img { width: 100%; height: 100%; object-fit: cover; }
.sheet__close { position: absolute; top: var(--space-12); right: var(--space-12); }
.sheet__body { display: flex; flex-direction: column; gap: var(--space-16); padding: var(--space-24); }
.chips { display: flex; flex-wrap: wrap; gap: var(--space-8); }
.facts { display: grid; grid-template-columns: max-content 1fr; column-gap: var(--space-24); }
.facts__row { display: contents; }
.facts dt, .facts dd { padding: 10px 0; border-top: 1px solid var(--color-hairline); font-size: 13px; line-height: 18px; }
.facts dt { color: var(--color-text-secondary); }
.facts dd { display: flex; align-items: center; gap: var(--space-8); font-variant-numeric: tabular-nums; }
.sheet__note { color: var(--color-text-secondary); font-size: 13px; line-height: 18px; }
.sheet__actions { display: flex; align-items: center; flex-wrap: wrap; gap: var(--space-12); padding-top: var(--space-8); }
.sheet__actions .pill-btn .icon { width: 18px; height: 18px; }
.sheet__spacer { flex: 1; }
.sheet--cats { width: min(480px, calc(100vw - 32px)); display: none; flex-direction: column; overflow: hidden; }
.sheet--cats[open] { display: flex; }
.sheet--cats .sheet__body { overflow-y: auto; padding-bottom: var(--space-8); }
.sheet--cats .cat-row { min-height: 44px; font-size: 15px; }
.sheet__footer { padding: var(--space-16) var(--space-24) var(--space-24); border-top: 1px solid var(--color-hairline); }
.sheet__footer .pill-btn { width: 100%; }

/* ── owner tools ─────────────────────────────────────────── */
.topbar__end { display: flex; align-items: center; justify-content: flex-end; gap: var(--space-8); }
.topbar__end:empty { display: none; }
.text-btn--quiet { color: var(--color-text-secondary); }
.text-btn--danger { display: inline-flex; align-items: center; gap: 6px; color: var(--color-danger); }
.text-btn--danger .icon { width: 16px; height: 16px; }
.pill-btn--outline { background: transparent; box-shadow: inset 0 0 0 1px var(--color-field-border); }
.pill-btn--primary { background: var(--color-action); color: var(--color-on-action); }
.pill-btn--glass { background: rgb(0 0 0 / 0.55); color: var(--color-text); -webkit-backdrop-filter: blur(20px) saturate(180%); backdrop-filter: blur(20px) saturate(180%); }
.link-btn { border: 0; background: none; padding: 0; color: var(--color-link); font: inherit; cursor: pointer; }

.spinner, .ui-state-pending::before {
  width: 16px; height: 16px; border-radius: 50%; border: 2px solid currentColor; border-right-color: transparent;
  animation: spin 0.8s linear infinite; display: inline-block; content: "";
}
@keyframes spin { to { transform: rotate(360deg); } }

.sheet--narrow { width: min(400px, calc(100vw - 32px)); }
.sheet--form { width: min(640px, calc(100vw - 32px)); }
.sheet--form { overflow: hidden; }
.sheet--form[open] { display: flex; }
.sheet--form > form { display: flex; flex-direction: column; width: 100%; max-height: inherit; min-height: 0; }
.sheet--form .sheet__body { overflow-y: auto; min-height: 0; }
.sheet__head { display: flex; align-items: center; justify-content: space-between; gap: var(--space-16); padding: var(--space-16) var(--space-16) 0 var(--space-24); }
.form { gap: var(--space-20); }
.form-actions { display: flex; align-items: center; justify-content: flex-end; gap: var(--space-12); }
.sheet__footer.form-actions { padding: var(--space-16) var(--space-24); }
.sheet__footer.form-actions .pill-btn { width: auto; }

.field { display: flex; flex-direction: column; gap: var(--space-8); min-width: 0; border: 0; padding: 0; margin: 0; }
.field__label { font-size: 13px; line-height: 18px; color: var(--color-text-secondary); }
.field__row { display: flex; gap: var(--space-8); align-items: center; }
.field__row .input { flex: 1; min-width: 0; }
.field__row--new { max-width: 360px; }
.field__error { display: flex; align-items: center; gap: 6px; color: var(--color-danger); font-size: 13px; line-height: 18px; }
.field__error::before { content: "!"; display: inline-grid; place-items: center; width: 16px; height: 16px; flex: none; border-radius: 50%; border: 1.5px solid currentColor; font-size: 11px; font-weight: 500; line-height: 1; }
.field__note { font-size: 13px; line-height: 18px; color: var(--color-text-secondary); }
.field__note a, .field__note button { color: var(--color-link); }
.input {
  width: 100%; height: 44px; padding: 0 14px; border-radius: var(--radius-field); border: 1px solid var(--color-field-border);
  background: var(--color-surface-raised); font-size: 15px; outline: none; -webkit-appearance: none; appearance: none;
}
.input::placeholder { color: var(--color-text-secondary); opacity: 0.7; }
.input[aria-invalid="true"] { border-color: var(--color-danger); }
.input--sm { height: 32px; font-size: 13px; padding: 0 12px; border-radius: var(--radius-pill); }
.formats--form { align-self: flex-start; }

.cat-picker { display: flex; flex-wrap: wrap; gap: var(--space-8); max-height: 172px; overflow-y: auto; padding: 2px; margin: -2px; }
.cat-picker .chip { color: var(--color-text-secondary); }
.cat-picker .chip[aria-pressed="true"] { background: var(--color-text); color: var(--color-canvas); }
.cat-picker .chip .icon { color: inherit; }

/* drop zone: dashed frame at rest, solid link-coloured frame while a file is over the window */
.drop {
  position: relative; display: grid; aspect-ratio: 3 / 2; max-height: 280px; width: 100%; border-radius: var(--radius-card);
  background: var(--color-surface-raised); outline: 1.5px dashed var(--color-field-border); outline-offset: -1.5px; overflow: hidden;
  transition: outline-color var(--motion-micro) var(--ease-standard), background-color var(--motion-micro) var(--ease-standard);
}
.drop > * { grid-area: 1 / 1; }
.drop[data-drag] { outline-style: solid; outline-color: var(--color-link); }
.drop[data-drag="over"] { background: color-mix(in srgb, var(--color-link) 14%, var(--color-surface-raised)); }
.drop__empty, .drop__busy { display: none; flex-direction: column; align-items: center; justify-content: center; gap: var(--space-8); padding: var(--space-24); text-align: center; }
.drop[data-state="empty"] .drop__empty, .drop[data-state="busy"] .drop__busy { display: flex; }
.drop__busy { flex-direction: row; color: var(--color-text-secondary); font-size: 13px; }
.drop__icon { width: 28px; height: 28px; color: var(--color-text-secondary); }
.drop__title { font-size: 15px; line-height: 20px; }
.drop__hint { font-size: 12px; line-height: 16px; color: var(--color-text-secondary); }
.drop__filled { display: none; }
.drop[data-state="filled"] { outline-color: transparent; }
.drop[data-state="filled"] .drop__filled { display: block; }
.drop__filled img { width: 100%; height: 100%; object-fit: cover; }
.drop__tools { position: absolute; right: var(--space-12); bottom: var(--space-12); display: flex; gap: var(--space-8); }
.drop__error { position: absolute; left: var(--space-12); right: var(--space-12); bottom: var(--space-12); padding: 8px 12px; border-radius: var(--radius-field);
  background: rgb(0 0 0 / 0.75); color: var(--color-text); font-size: 13px; line-height: 18px; display: flex; gap: 8px; align-items: center; }
.drop__error::before { content: "!"; color: var(--color-danger); font-weight: 500; }

.toast {
  position: fixed; left: 50%; bottom: calc(var(--space-24) + env(safe-area-inset-bottom)); z-index: 30; transform: translateX(-50%);
  display: flex; align-items: center; gap: var(--space-16); max-width: calc(100vw - 32px); min-height: 44px; padding: 10px 12px 10px 20px; border-radius: var(--radius-pill);
  background: var(--color-surface-raised); color: var(--color-text); font-size: 13px; line-height: 18px; box-shadow: 0 0 0 1px var(--color-hairline);
  animation: toast-in var(--motion-small) var(--ease-standard);
}
.toast .text-btn { padding: 6px 8px; }
@keyframes toast-in { from { opacity: 0; transform: translate(-50%, 8px); } }

/* ── accounts ────────────────────────────────────────────── */
body[data-auth="out"] .topbar, body[data-auth="out"] .page, body[data-auth="out"] .toast { display: none; }
body[data-auth="checking"] .topbar__end, body[data-auth="checking"] .page { visibility: hidden; }
.gate { min-height: 100dvh; display: grid; place-items: center; padding: var(--space-24) var(--space-16); }
.gate__card { width: min(360px, 100%); display: flex; flex-direction: column; gap: var(--space-16); }
.gate__logo { width: 40px; height: 40px; color: var(--color-text); }
.gate__card h1 { margin-bottom: var(--space-8); }
.gate__submit { margin-top: var(--space-8); width: 100%; }

.account-btn { display: inline-grid; place-items: center; width: 40px; height: 40px; padding: 0; border: 0; border-radius: var(--radius-pill); background: transparent; cursor: pointer; }
.avatar { display: inline-grid; place-items: center; width: 30px; height: 30px; border-radius: 50%; background: var(--color-surface-raised); color: var(--color-text); font-size: 13px; font-weight: 500; text-transform: uppercase; }
.menu {
  position: fixed; inset: auto; margin: 0; min-width: 220px; padding: var(--space-8); border: 0; border-radius: var(--radius-card);
  background: var(--color-surface-raised); color: var(--color-text); box-shadow: 0 0 0 1px var(--color-hairline), 0 16px 48px rgb(0 0 0 / 0.5);
}
.menu__who { display: flex; flex-direction: column; padding: var(--space-8) var(--space-12) var(--space-12); border-bottom: 1px solid var(--color-hairline); margin-bottom: var(--space-4); font-weight: 500; }
.menu__role { color: var(--color-text-secondary); font-size: 12px; line-height: 16px; font-weight: 400; }
.menu__item { display: flex; align-items: center; gap: var(--space-12); width: 100%; min-height: 40px; padding: 0 var(--space-12); border: 0; border-radius: var(--radius-field); background: transparent; text-align: left; font-size: 15px; cursor: pointer; }
.menu__item .icon { width: 18px; height: 18px; color: var(--color-text-secondary); }
@media (hover: hover) and (pointer: fine) { .menu__item:hover { background: rgb(255 255 255 / 0.06); } }

.sheet__inner { display: flex; flex-direction: column; width: 100%; max-height: inherit; min-height: 0; }
.sheet__inner .sheet__body { overflow-y: auto; min-height: 0; }
.users { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.user { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: var(--space-12); padding: var(--space-12) 0; border-top: 1px solid var(--color-hairline); }
.user:first-child { border-top: 0; }
.user__name { font-weight: 500; overflow-wrap: anywhere; }
.user__meta { color: var(--color-text-secondary); font-size: 12px; line-height: 16px; }
.user__tools { display: flex; align-items: center; gap: var(--space-4); }
.user__role { height: 32px; padding: 0 28px 0 12px; border: 0; border-radius: var(--radius-pill); background: var(--color-surface-raised); font-size: 13px; cursor: pointer; -webkit-appearance: none; appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, var(--color-text-secondary) 50%), linear-gradient(135deg, var(--color-text-secondary) 50%, transparent 50%);
  background-position: calc(100% - 15px) 14px, calc(100% - 10px) 14px; background-size: 5px 5px; background-repeat: no-repeat; }
.user__reset { display: flex; gap: var(--space-8); grid-column: 1 / -1; }
.user__reset .input { flex: 1; min-width: 0; }
.new-user { display: flex; flex-direction: column; gap: var(--space-16); padding-top: var(--space-20); border-top: 1px solid var(--color-hairline); }
.new-user__grid { display: grid; grid-template-columns: 1fr 1fr; gap: var(--space-16); }
.form-actions--start { justify-content: flex-start; }
.icon-btn.is-confirm { color: var(--color-danger); background: rgb(255 69 58 / 0.14); }

/* ── responsive ──────────────────────────────────────────── */
@media (max-width: 1067px) {
  .topbar__inner, .page { grid-template-columns: minmax(0, 1fr); }
  .topbar__inner { grid-template-columns: auto minmax(0, 1fr) auto; column-gap: var(--space-24); }
  .search { justify-self: end; }
  .sidebar { display: none; }
  .cats-btn { display: inline-flex; }
}
@media (max-width: 733px) {
  :root { --page-pad: var(--space-16); --topbar-h: 60px; }
  .topbar__inner { column-gap: var(--space-12); }
  .add-label { display: none; }
  .pill-btn--primary { width: 32px; padding: 0; }
  .sheet--form, .sheet--narrow { width: 100vw; }
  .sheet__head { padding-left: var(--space-16); }
  .sheet__footer.form-actions { padding: var(--space-12) var(--space-16) calc(var(--space-12) + env(safe-area-inset-bottom)); }
  .field__row--new { max-width: none; }
  .new-user__grid { grid-template-columns: 1fr; }
  .type-large { font-size: 24px; line-height: 30px; }
  .search__key { display: none; }
  .grid { grid-template-columns: repeat(auto-fill, minmax(156px, 1fr)); gap: var(--space-16); }
  .card__body { padding: var(--space-12); }
  .card__name { font-size: 14px; line-height: 19px; min-height: 38px; }
  .card__meta { font-size: 12px; line-height: 16px; }
  .toolbar { flex-direction: column; align-items: stretch; }
  .formats > button { padding: 0 10px; gap: 6px; }
  .formats .seg-count { display: none; }
  .toolbar__end { justify-content: space-between; }
  .sheet { width: 100vw; max-width: 100vw; max-height: 92dvh; margin: auto auto 0; border-radius: var(--radius-sheet) var(--radius-sheet) 0 0; }
  .sheet--cats { width: 100vw; }
  .sheet__body { padding: var(--space-20) var(--space-16) var(--space-24); }
  .sheet__actions .pill-btn { flex: 1 1 auto; }
  .sheet__spacer { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  .grid[data-refresh] { animation: none; }
  .skeleton > * { animation: none; }
  .cat-more .icon { transition: none; }
  .toast { animation: none; }
  .spinner, .ui-state-pending::before { animation-duration: 2.4s; }
}
