/* Gallery Control — vibrant dark SaaS theme.
   No hover-triggered movement anywhere (no translate/scale on :hover) — only
   color, border, background, shadow, opacity and filter feedback. */

:root {
  --bg: #0a0a12;
  --surface: #121220;
  --surface-2: #191928;
  --surface-3: #212133;
  --surface-4: #292941;
  --border: #272740;
  --border-strong: rgba(255, 255, 255, 0.16);
  --border-subtle: #1c1c2c;
  --text: #f8f8fc;
  --text-muted: #9d9db4;
  --text-faint: #6f6f88;

  --accent: #8b5cf6;
  --accent-hover: #a78bfa;
  --accent-dim: rgba(139, 92, 246, 0.16);
  --accent-glow: rgba(139, 92, 246, 0.4);
  --accent-2: #22d3ee;
  --accent-2-dim: rgba(34, 211, 238, 0.14);
  --pink: #ec4899;
  --brand-grad: linear-gradient(135deg, #8b5cf6 0%, #ec4899 100%);
  --brand-grad-soft: linear-gradient(135deg, rgba(139, 92, 246, 0.16), rgba(236, 72, 153, 0.1));

  --danger: #f43f5e;
  --danger-dim: rgba(244, 63, 94, 0.14);
  --success: #22c55e;
  --success-dim: rgba(34, 197, 94, 0.14);
  --warn: #f59e0b;
  --warn-dim: rgba(245, 158, 11, 0.13);

  --radius-sm: 6px;
  --radius: 10px;
  --radius-lg: 16px;
  --radius-xl: 20px;
  --space: 8px;
  --space-lg: 16px;
  --sidebar-w: 216px;
  --ease: 0.16s ease;
  --ease-out: 0.35s cubic-bezier(0.22, 1, 0.36, 1);
  --font: 'Sora', system-ui, -apple-system, sans-serif;
  --mono: 'IBM Plex Mono', ui-monospace, monospace;
  --shadow: 0 16px 44px rgba(0, 0, 0, 0.55);
  --shadow-sm: 0 4px 16px rgba(0, 0, 0, 0.3);
  --card-ratio: 59 / 86;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  color-scheme: dark;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.5;
  color: var(--text);
  background:
    radial-gradient(ellipse 65% 55% at 8% -8%, rgba(139, 92, 246, 0.16), transparent 55%),
    radial-gradient(ellipse 55% 45% at 100% 0%, rgba(236, 72, 153, 0.08), transparent 50%),
    radial-gradient(ellipse 60% 45% at 50% 100%, rgba(34, 211, 238, 0.05), transparent 55%),
    var(--bg);
  background-attachment: fixed;
}

body::before {
  content: '';
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  opacity: 0.025;
  background-image:
    repeating-linear-gradient(0deg, transparent, transparent 2px, rgba(255, 255, 255, 0.4) 2px, rgba(255, 255, 255, 0.4) 3px),
    repeating-linear-gradient(90deg, transparent, transparent 3px, rgba(0, 0, 0, 0.3) 3px, rgba(0, 0, 0, 0.3) 4px);
}

#app-shell,
#auth-gate {
  position: relative;
  z-index: 1;
}

code {
  font-family: var(--mono);
  font-size: 0.88em;
  padding: 0.1em 0.4em;
  border-radius: 4px;
  background: var(--surface-3);
  border: 1px solid var(--border);
  color: var(--accent-hover);
}

.hidden,
[hidden] {
  display: none !important;
}

.hint {
  margin: 0;
  font-size: 0.85rem;
  color: var(--text-muted);
}

/* ─── Card route / page-open ─── */
html.card-route #panel-overview,
html.card-route #panel-gallery,
html.card-route #panel-review,
html.card-route #panel-artworks,
body.card-page-open #panel-overview,
body.card-page-open #panel-gallery,
body.card-page-open #panel-review,
body.card-page-open #panel-artworks {
  display: none !important;
}

html.card-route #panel-card-page,
body.card-page-open #panel-card-page {
  display: block !important;
}

html.card-route .app-sidebar,
html.card-route .header,
body.card-page-open .app-sidebar,
body.card-page-open .header {
  display: none !important;
}

html.card-route #card-shell-header,
body.card-page-open #card-shell-header {
  display: block;
}

html.card-route body,
body.card-page-open {
  background:
    radial-gradient(ellipse 100% 65% at 50% -15%, rgba(139, 92, 246, 0.14), transparent 55%),
    var(--bg);
}

html.card-route .app-shell,
body.card-page-open .app-shell {
  display: block;
  grid-template-columns: 1fr;
}

html.card-route .app-frame,
body.card-page-open .app-frame {
  min-height: 100vh;
}

html.card-route .main,
body.card-page-open .main {
  max-width: none;
  margin: 0;
  padding: 76px 24px 48px;
}

/* ─── Auth gate ─── */
.auth-gate {
  display: none;
  place-items: center;
  min-height: 100vh;
  padding: 24px;
  position: relative;
  overflow: hidden;
}

html.auth-locked .auth-gate {
  display: grid;
}

.auth-gate__atmosphere {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(ellipse 55% 50% at 22% 30%, rgba(139, 92, 246, 0.28), transparent 60%),
    radial-gradient(ellipse 50% 45% at 82% 70%, rgba(236, 72, 153, 0.18), transparent 58%),
    radial-gradient(ellipse 45% 40% at 50% 100%, rgba(34, 211, 238, 0.1), transparent 55%),
    radial-gradient(circle at 50% 100%, rgba(6, 8, 14, 0.95), transparent 45%);
  pointer-events: none;
}

.auth-gate__atmosphere::after {
  content: '';
  position: absolute;
  inset: 0;
  opacity: 0.035;
  background-image: repeating-linear-gradient(
    -12deg,
    transparent,
    transparent 6px,
    rgba(255, 255, 255, 0.5) 6px,
    rgba(255, 255, 255, 0.5) 7px
  );
}

.auth-gate__card {
  position: relative;
  z-index: 1;
  width: min(408px, 100%);
  padding: 40px 34px;
  border-radius: var(--radius-xl);
  background: linear-gradient(180deg, var(--surface-2), var(--surface));
  border: 1px solid var(--border-strong);
  box-shadow: var(--shadow), 0 0 80px rgba(139, 92, 246, 0.1);
  animation: fadeUp 0.45s var(--ease-out) both;
}

.auth-gate__brand {
  margin: 0 0 10px;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  background: var(--brand-grad);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.auth-gate__title {
  margin: 0 0 8px;
  font-size: 1.8rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.auth-gate__hint {
  margin: 0 0 26px;
  font-size: 0.92rem;
  color: var(--text-muted);
}

.auth-gate__field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 16px;
  font-size: 0.8rem;
  color: var(--text-muted);
}

.auth-gate__field input {
  width: 100%;
  padding: 12px 14px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  font-family: inherit;
  font-size: 0.95rem;
  outline: none;
  transition: border-color var(--ease), box-shadow var(--ease);
}

.auth-gate__field input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-dim);
}

.auth-gate__error {
  margin: 0 0 12px;
  font-size: 0.85rem;
  color: var(--danger);
}

.auth-gate__submit {
  width: 100%;
  margin-top: 10px;
  padding: 13px 16px;
  font-size: 0.95rem;
}

/* ─── App shell ─── */
.app-shell {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  min-height: 100vh;
  align-items: start;
}

.app-shell[hidden] {
  display: none !important;
}

.app-sidebar {
  position: sticky;
  top: 0;
  align-self: start;
  height: 100vh;
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 16px 12px;
  background: linear-gradient(180deg, rgba(139, 92, 246, 0.05), transparent 45%), var(--surface);
  border-right: 1px solid var(--border);
  z-index: 40;
}

.app-sidebar__brand {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 4px 6px 16px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 10px;
}

.app-sidebar__logo {
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  background: var(--brand-grad);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  text-decoration: none;
  transition: filter var(--ease);
}

.app-sidebar__logo:hover {
  filter: brightness(1.2);
}

.app-version-chip {
  font-family: var(--mono);
  font-size: 0.66rem;
  font-weight: 500;
  padding: 3px 8px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface-3);
  color: var(--text-muted);
  white-space: nowrap;
}

.app-sidebar__nav {
  display: flex;
  flex-direction: column;
  gap: 3px;
  flex: 0 0 auto;
  overflow-y: auto;
  min-height: 0;
}

.app-sidebar__foot {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
  margin-top: auto;
}

.auth-user-chip {
  font-family: var(--mono);
  font-size: 0.68rem;
  padding: 5px 9px;
  border-radius: var(--radius-sm);
  background: var(--accent-dim);
  border: 1px solid rgba(139, 92, 246, 0.3);
  color: var(--accent-hover);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.app-frame {
  min-width: 0;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.app-topbar,
.header.app-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  padding: 18px 28px;
  border-bottom: 1px solid var(--border);
  background: rgba(10, 10, 18, 0.7);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  position: sticky;
  top: 0;
  z-index: 30;
}

/* Gallery: filters are the chrome — drop redundant page header */
html[data-tab='gallery'] .app-topbar {
  display: none;
}

.app-topbar__copy {
  min-width: 0;
}

.app-topbar__eyebrow {
  display: block;
  margin: 0 0 3px;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent-2);
}

.app-topbar__title {
  margin: 0;
  font-size: 1.4rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.app-topbar__actions,
.header__tools {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

/* ─── Nav tabs ─── */
.nav__tab {
  position: relative;
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 9px 12px;
  border: 1px solid transparent;
  border-radius: var(--radius);
  background: transparent;
  color: var(--text-muted);
  font-family: inherit;
  text-align: left;
  cursor: pointer;
  transition: background var(--ease), color var(--ease), border-color var(--ease);
}

.nav__tab-icon {
  flex-shrink: 0;
  width: 18px;
  height: 18px;
  opacity: 0.75;
  transition: opacity var(--ease);
}

.nav__tab--active .nav__tab-icon {
  opacity: 1;
  color: #fff;
}

.nav__tab-text {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  min-width: 0;
}

.nav__tab:hover {
  background: var(--surface-3);
  color: var(--text);
}

.nav__tab--active {
  background: var(--brand-grad);
  border-color: transparent;
  color: #fff;
  box-shadow: 0 6px 18px rgba(139, 92, 246, 0.3);
}

.nav__tab-label {
  font-size: 0.85rem;
  font-weight: 600;
}

.nav__tab--active .nav__tab-label {
  color: #fff;
}

.nav__tab-hint {
  display: none;
}

/* ─── Buttons ─── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 9px 15px;
  border-radius: var(--radius);
  border: 1px solid transparent;
  font-family: inherit;
  font-size: 0.875rem;
  font-weight: 600;
  line-height: 1.2;
  cursor: pointer;
  transition: background var(--ease), border-color var(--ease), color var(--ease),
    box-shadow var(--ease), filter var(--ease), opacity var(--ease);
}

.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.btn--primary {
  background: var(--brand-grad);
  color: #fff;
  border-color: transparent;
  box-shadow: 0 4px 14px rgba(139, 92, 246, 0.25);
}

.btn--primary:hover:not(:disabled) {
  filter: brightness(1.1);
  box-shadow: 0 6px 22px var(--accent-glow);
}

.btn--secondary {
  background: var(--surface-3);
  color: var(--text);
  border-color: var(--border);
}

.btn--secondary:hover:not(:disabled) {
  border-color: var(--border-strong);
  background: var(--surface-4);
}

.btn--ghost {
  background: transparent;
  color: var(--text-muted);
  border-color: transparent;
}

.btn--ghost:hover:not(:disabled) {
  color: var(--text);
  background: var(--surface-3);
}

.btn--accent {
  background: var(--brand-grad);
  color: #fff;
  border: none;
  font-weight: 700;
  box-shadow: 0 4px 14px rgba(139, 92, 246, 0.3);
}

.btn--accent:hover:not(:disabled) {
  filter: brightness(1.1);
  box-shadow: 0 6px 22px var(--accent-glow);
}

.btn--pause {
  background: var(--warn-dim);
  color: var(--warn);
  border-color: rgba(245, 158, 11, 0.35);
}

.btn--pause:hover:not(:disabled) {
  background: rgba(245, 158, 11, 0.22);
}

.btn--resume {
  background: var(--success-dim);
  color: var(--success);
  border-color: rgba(34, 197, 94, 0.35);
}

.btn--resume:hover:not(:disabled) {
  background: rgba(34, 197, 94, 0.22);
}

.btn svg {
  flex-shrink: 0;
  display: block;
}

.btn--header {
  padding: 9px 15px;
  font-size: 0.85rem;
  white-space: nowrap;
}

.btn--sidebar {
  width: 100%;
  justify-content: flex-start;
  padding: 8px 10px;
  font-size: 0.8rem;
}

.btn--small {
  padding: 6px 11px;
  font-size: 0.78rem;
}

.btn--icon {
  padding: 6px;
  width: 30px;
  height: 30px;
  border: 1px solid var(--border);
  background: var(--surface-3);
}

.btn--loading {
  position: relative;
  color: transparent !important;
  pointer-events: none;
}

.btn--loading::after {
  content: '';
  position: absolute;
  left: 50%;
  top: 50%;
  width: 18px;
  height: 18px;
  margin: -9px 0 0 -9px;
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

/* ─── Panels / main ─── */
.main {
  flex: 1;
  padding: 24px 28px 40px;
  max-width: none;
  width: 100%;
}

html[data-tab='gallery'] .main {
  padding: 10px 14px 20px;
}

.visually-hidden {
  position: absolute !important;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.panel {
  display: none;
}

.panel--active {
  display: block;
  animation: fadeUp 0.4s var(--ease-out) both;
}

.version-strip {
  margin: 0 0 16px;
  padding: 7px 12px;
  font-family: var(--mono);
  font-size: 0.72rem;
  color: var(--text-muted);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface);
  display: inline-block;
}

.section-intro {
  margin-bottom: 18px;
}

.section-intro__title {
  margin: 0 0 4px;
  font-size: 1.4rem;
  font-weight: 700;
  letter-spacing: -0.01em;
}

/* ─── Coverage board: bold stat cards ─── */
.coverage-board {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin: 0 0 16px;
}

.coverage-meter {
  padding: 16px 18px;
  border-radius: var(--radius-lg);
  background: linear-gradient(160deg, var(--surface-2), var(--surface));
  border: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 10px;
  transition: border-color var(--ease), box-shadow var(--ease);
}

.coverage-meter:hover {
  border-color: rgba(139, 92, 246, 0.35);
  box-shadow: var(--shadow-sm);
}

.coverage-meter__head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
}

.coverage-meter__title {
  margin: 0;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-muted);
}

.coverage-meter__icon {
  flex-shrink: 0;
  width: 18px;
  height: 18px;
  color: var(--accent-hover);
  opacity: 0.95;
}

.coverage-meter__ratio {
  margin: 0;
  font-family: var(--mono);
  font-size: 1.35rem;
  font-weight: 700;
  color: var(--text);
  white-space: nowrap;
  letter-spacing: -0.02em;
}

.coverage-meter__of {
  margin: 0 0.15em;
  color: var(--text-faint);
  font-weight: 400;
  font-size: 0.85rem;
}

.coverage-meter__track {
  height: 7px;
  border-radius: 999px;
  background: var(--surface-4);
  overflow: hidden;
}

.coverage-meter__fill {
  height: 100%;
  width: 0%;
  border-radius: inherit;
  background: var(--brand-grad);
  box-shadow: 0 0 14px var(--accent-glow);
  transition: width 0.55s var(--ease-out);
}

.coverage-meter__hint {
  margin: 0;
  font-size: 0.7rem;
  color: var(--text-faint);
  line-height: 1.25;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.dash-grid--wide {
  grid-template-columns: 1.45fr 1fr;
}

.dash-grid--ops {
  grid-template-columns: 1fr 1.25fr;
  margin-top: 16px;
}

@media (max-width: 1100px) {
  .coverage-board {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .dash-grid--wide,
  .dash-grid--ops {
    grid-template-columns: 1fr;
  }
}

/* ─── Dashboard cards ─── */
.dash-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 12px;
  margin-bottom: 12px;
}

.dash-card {
  padding: 18px 20px;
  border-radius: var(--radius-lg);
  background: var(--surface);
  border: 1px solid var(--border);
}

.dash-card--wide {
  grid-column: 1 / -1;
}

.dash-card--chart {
  min-height: 130px;
}

.dash-card__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}

.dash-card__head .dash-card__title {
  margin-bottom: 0;
}

.dash-card__title {
  margin: 0 0 16px;
  font-size: 0.85rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.dash-meta {
  margin: 0 0 14px;
  font-size: 0.85rem;
  font-family: var(--mono);
  color: var(--accent-2);
}

/* Charts */
.bar-chart {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.bar-chart__row {
  display: grid;
  grid-template-columns: minmax(96px, 32%) 1fr minmax(40px, auto);
  align-items: center;
  gap: 10px;
  font-size: 0.8rem;
}

.bar-chart__label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
  color: var(--text-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.bar-chart__attr-icon {
  width: 16px;
  height: 16px;
  object-fit: contain;
  flex-shrink: 0;
}

.bar-chart__track {
  height: 9px;
  border-radius: 999px;
  background: var(--surface-3);
  overflow: hidden;
}

.bar-chart__fill {
  height: 100%;
  border-radius: 999px;
  background: var(--brand-grad);
  transition: width 0.6s cubic-bezier(0.22, 1, 0.36, 1);
}

.bar-chart__val {
  text-align: right;
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
  color: var(--text-muted);
}

.bar-chart--compact .bar-chart__row {
  grid-template-columns: minmax(88px, 34%) 1fr minmax(36px, auto);
}

.spark-chart {
  display: flex;
  align-items: flex-end;
  gap: 4px;
  height: 130px;
  padding-top: 8px;
}

.spark-chart__col {
  flex: 1;
  min-width: 4px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  height: 100%;
  justify-content: flex-end;
}

.spark-chart__bar {
  width: 100%;
  max-width: 24px;
  border-radius: 4px 4px 0 0;
  background: var(--brand-grad);
  transition: height 0.5s ease;
}

.spark-chart__year {
  font-family: var(--mono);
  font-size: 0.65rem;
  color: var(--text-faint);
  writing-mode: vertical-rl;
  transform: rotate(180deg);
  max-height: 28px;
}

/* Banlist / format notes */
.banlist-matrix {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}

.banlist-matrix__region {
  padding: 14px;
  border-radius: var(--radius);
  background: var(--surface-2);
  border: 1px solid var(--border);
}

.banlist-matrix__region h4 {
  margin: 0 0 8px;
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
}

.banlist-matrix__date {
  margin: 0 0 10px;
  font-family: var(--mono);
  font-size: 0.75rem;
  color: var(--accent-2);
}

.banlist-matrix__date--muted {
  color: var(--text-faint);
}

.banlist-matrix__stat {
  display: flex;
  justify-content: space-between;
  font-size: 0.8rem;
  padding: 4px 0;
}

.banlist-matrix__stat--forbidden span:last-child { color: var(--danger); font-weight: 600; }
.banlist-matrix__stat--limited span:last-child { color: var(--warn); font-weight: 600; }
.banlist-matrix__stat--semi span:last-child { color: #fbbf24; font-weight: 600; }

.format-notes {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.format-note {
  padding: 12px 14px;
  border-radius: var(--radius);
  border-left: 3px solid var(--accent);
  background: var(--surface-2);
}

.format-note__title {
  margin: 0 0 4px;
  font-weight: 600;
  font-size: 0.9rem;
}

.format-note__body {
  margin: 0;
  font-size: 0.8rem;
  color: var(--text-muted);
  line-height: 1.45;
}

.sync-download {
  margin-top: 4px;
}

.sync-job-status {
  margin: 0 0 14px;
  font-size: 0.85rem;
  color: var(--text-muted);
  min-height: 1.2em;
}

.sync-job-status--error {
  color: var(--danger);
}

/* Progress stats */
.progress-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}

.progress-stat {
  padding: 14px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--surface-2);
}

.progress-stat__label {
  display: block;
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-faint);
  margin-bottom: 6px;
}

.progress-stat__value {
  display: block;
  font-family: var(--mono);
  font-size: 1.15rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.progress-stat__sub {
  display: block;
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-bottom: 10px;
}

/* Job panels */
.job-panel {
  margin-bottom: 20px;
  padding: 18px 20px;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  background: var(--surface);
}

.job-panel--sync {
  border-color: rgba(139, 92, 246, 0.4);
  background: var(--brand-grad-soft);
}

.job-panel--download {
  border-color: rgba(34, 211, 238, 0.35);
  background: linear-gradient(135deg, rgba(34, 211, 238, 0.1), transparent);
}

.job-panel--summary {
  border-color: rgba(34, 197, 94, 0.4);
  background: linear-gradient(135deg, var(--success-dim), transparent);
}

.job-panel__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

.job-panel__title {
  font-weight: 700;
  font-size: 0.95rem;
}

.job-panel__pct {
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
  font-weight: 700;
  color: var(--accent-hover);
}

.job-panel__message,
.job-panel__detail {
  margin: 0 0 10px;
  font-size: 0.875rem;
  color: var(--text-muted);
}

.job-summary__list {
  margin: 8px 0 0;
  padding-left: 1.2rem;
}

.job-summary__files {
  margin: 6px 0 0;
  padding-left: 1rem;
  font-size: 0.8rem;
  font-family: var(--mono);
  max-height: 120px;
  overflow: auto;
}

.job-summary__when {
  margin: 0;
  font-size: 0.85rem;
  color: var(--text-muted);
}

.job-summary__error {
  color: var(--danger);
  margin: 0;
}

/* ─── Progress / badges ─── */
.progress {
  display: flex;
  align-items: center;
  gap: 10px;
}

.progress__bar {
  flex: 1;
  min-width: 0;
  height: 8px;
  border-radius: 999px;
  background: var(--surface-3);
  overflow: hidden;
  border: 1px solid var(--border);
}

.progress__fill {
  height: 100%;
  width: 0%;
  border-radius: inherit;
  background: var(--brand-grad);
  transition: width 0.35s ease;
}

.progress--animated .progress__fill {
  transition: width 0.35s ease;
}

.progress__fill--indeterminate {
  width: 40% !important;
  animation: progress-indeterminate 1.4s ease-in-out infinite;
}

.progress__pct {
  font-family: var(--mono);
  font-size: 0.78rem;
  font-variant-numeric: tabular-nums;
  color: var(--text-muted);
  min-width: 2.5em;
}

.progress--stat {
  display: flex;
  align-items: center;
  gap: 10px;
}

.progress--stat .progress__bar {
  flex: 1;
  min-width: 0;
}

.badge {
  display: inline-flex;
  align-items: center;
  padding: 4px 11px;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
  border: 1px solid var(--border);
  background: var(--surface-3);
  color: var(--text-muted);
}

.badge--idle {
  background: var(--surface-3);
  color: var(--text-muted);
}

.badge--running,
.badge--downloading {
  background: var(--accent-dim);
  border-color: rgba(139, 92, 246, 0.4);
  color: var(--accent-hover);
}

.badge--paused {
  background: var(--warn-dim);
  border-color: rgba(245, 158, 11, 0.4);
  color: var(--warn);
}

.badge--done {
  background: var(--success-dim);
  border-color: rgba(34, 197, 94, 0.4);
  color: var(--success);
}

.badge--error {
  background: var(--danger-dim);
  border-color: rgba(244, 63, 94, 0.4);
  color: var(--danger);
}

.badge--small,
.badge-small {
  padding: 2px 8px;
  font-size: 0.68rem;
}

.badge-small--complete {
  background: var(--success-dim);
  color: #6ee7b7;
  border: 1px solid rgba(34, 197, 94, 0.4);
}

.badge-small--pending {
  background: var(--warn-dim);
  color: #fdba74;
  border: 1px solid rgba(245, 158, 11, 0.4);
}

/* ─── Forms / toolbar ─── */
.input,
.select {
  padding: 9px 12px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  font-family: inherit;
  font-size: 0.875rem;
  outline: none;
  transition: border-color var(--ease), box-shadow var(--ease);
}

.input:focus,
.select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-dim);
}

.input { min-width: 180px; }
.input--short { min-width: 100px; }
.input--date {
  min-width: 140px;
  font-family: var(--mono);
  font-size: 0.82rem;
}
.input--textarea {
  min-height: 88px;
  resize: vertical;
  width: 100%;
  min-width: 0;
}
.input--inline { width: auto; min-width: 0; }

.select { min-width: 130px; }
.select--narrow { min-width: 72px; }
.select--preset { min-width: 120px; }

.toolbar {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 16px;
  padding: 14px 16px;
  border-radius: var(--radius-lg);
  background: var(--surface);
  border: 1px solid var(--border);
}

.toolbar__row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 10px;
}

.toolbar__label {
  font-size: 0.78rem;
  color: var(--text-muted);
  white-space: nowrap;
}

.toolbar__count {
  font-family: var(--mono);
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-left: auto;
}

.toolbar__sep {
  color: var(--text-muted);
}

.release-filter {
  margin-bottom: 4px;
  padding: 12px 14px;
  border-radius: var(--radius);
  background: var(--surface-2);
  border: 1px solid var(--border);
}

.release-filter__row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 10px;
}

.release-filter__title {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--accent-2);
  margin-right: 4px;
}

.release-filter .toolbar__label { margin: 0; }
.release-filter .input,
.release-filter .select { min-width: 0; }
.release-filter .input--date { min-width: 130px; }
.release-filter .select--preset { min-width: 110px; }
.release-filter .btn { flex-shrink: 0; }

/* ─── Browse (Gallery toolbar) ─── */
.browse-shell {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin: 0 0 10px;
  padding: 10px 12px;
  border-radius: var(--radius-lg);
  background: var(--surface);
  border: 1px solid var(--border-subtle);
  box-shadow: var(--shadow-sm);
  position: sticky;
  top: 0;
  z-index: 20;
}

.browse-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
}

.browse-search {
  flex: 1 1 200px;
  min-width: 160px;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 12px;
  height: 36px;
  border-radius: var(--radius);
  background: var(--bg);
  border: 1px solid var(--border);
  transition: border-color var(--ease), box-shadow var(--ease);
}

.browse-search:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-dim);
}

.browse-search__icon {
  color: var(--text-muted);
  flex-shrink: 0;
}

.browse-search__input {
  flex: 1;
  min-width: 0;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--text);
  font: inherit;
  font-size: 0.92rem;
}

.browse-setcode {
  width: 100px;
  height: 36px;
  padding: 0 10px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  font: inherit;
  font-size: 0.8rem;
  transition: border-color var(--ease);
}

.browse-setcode:focus {
  border-color: var(--accent);
  outline: none;
}

.browse-bar__tools {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  margin-left: auto;
}

.browse-select {
  height: 34px;
  padding: 0 9px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--surface-3);
  color: var(--text);
  font: inherit;
  font-size: 0.76rem;
}

.browse-select--narrow {
  width: auto;
  max-width: 72px;
}

.browse-count {
  flex: 1 1 auto;
  min-width: 140px;
  font-family: var(--mono);
  font-size: 0.68rem;
  color: var(--text-faint);
  padding: 0 2px;
  line-height: 1.25;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.chip-filters {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}

@media (min-width: 900px) {
  .chip-filters {
    flex-direction: row;
    align-items: center;
    gap: 10px;
  }

  .chip-filters .chip-row {
    flex: 1 1 0;
    min-width: 0;
  }

  .chip-filters .chip-row__label {
    width: 28px;
  }
}

.chip-row {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
}

.chip-row__label {
  flex-shrink: 0;
  width: 32px;
  font-size: 0.64rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-faint);
}

.chip-row__scroller {
  display: flex;
  gap: 5px;
  overflow-x: auto;
  padding: 2px 0;
  min-width: 0;
  scrollbar-width: thin;
}

.filter-chip {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--border);
  background: var(--surface-3);
  color: var(--text);
  cursor: pointer;
  transition: border-color var(--ease), background var(--ease), color var(--ease);
}

.filter-chip:hover {
  border-color: var(--accent);
  background: var(--surface-4);
}

.filter-chip--active {
  border-color: transparent;
  background: var(--brand-grad);
  color: #fff;
  box-shadow: 0 3px 10px rgba(139, 92, 246, 0.35);
}

.filter-chip--icon {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  padding: 0;
}

.filter-chip--icon img {
  width: 20px;
  height: 20px;
  object-fit: contain;
  display: block;
}

.filter-chip--text {
  height: 30px;
  padding: 0 12px;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 600;
}

.browse-more {
  border-top: 1px solid var(--border-subtle);
  padding-top: 6px;
}

.browse-more .chip-row {
  margin-bottom: 6px;
}

.browse-more > summary {
  cursor: pointer;
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--accent-2);
  list-style: none;
}

.browse-more > summary::-webkit-details-marker {
  display: none;
}

.browse-more[open] > summary {
  margin-bottom: 8px;
}

/* ─── Gallery grid (dense tiles) ─── */
.gallery-container {
  content-visibility: auto;
  contain-intrinsic-size: 800px;
  margin: 0 -4px;
}

.gallery {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(104px, 1fr));
  gap: 6px;
}

.gallery-item {
  position: relative;
  margin: 0;
  padding: 0;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius);
  background: var(--surface-2);
  cursor: pointer;
  content-visibility: auto;
  contain-intrinsic-size: 160px;
  overflow: hidden;
  animation: fadeUp 0.28s var(--ease-out) both;
  transition: border-color var(--ease), box-shadow var(--ease);
}

.gallery-item:hover,
.gallery-item:focus-visible {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px var(--accent), 0 8px 20px rgba(0, 0, 0, 0.35);
  z-index: 2;
}

.gallery-item__art {
  position: relative;
  width: 100%;
  aspect-ratio: var(--card-ratio);
  background: var(--surface-2);
}

.gallery-item__art > img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  object-position: center;
  display: block;
}

.gallery-item__set {
  position: absolute;
  left: 4px;
  bottom: 4px;
  max-width: calc(100% - 8px);
  padding: 2px 5px;
  border-radius: 3px;
  font-family: var(--mono);
  font-size: 0.58rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: #fff;
  background: rgba(0, 0, 0, 0.72);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.gallery-item__banlist {
  position: absolute;
  top: 4px;
  right: 4px;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 2px;
  max-width: 55%;
}

.gallery-item__banlist .banlist-chip {
  font-size: 0.55rem;
  padding: 1px 4px;
  border-radius: 3px;
  line-height: 1.2;
}

.gallery-item__caption {
  display: block;
  padding: 4px 6px;
  font-size: 0.66rem;
  font-weight: 500;
  line-height: 1.25;
  color: var(--text-muted);
  background: var(--surface-2);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  border-top: 1px solid var(--border-subtle);
}

.gallery-item__label,
.gallery-item__meta,
.gallery-item__sets {
  display: none;
}

.gallery-pagination {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin-top: 24px;
  padding: 12px;
}

.gallery-pagination__info {
  font-family: var(--mono);
  font-size: 0.8rem;
  color: var(--text-muted);
}

.gallery-pagination__info--only {
  margin: 0;
}

.gallery-pagination__btn:disabled {
  opacity: 0.4;
}

.gallery-group {
  margin-bottom: 26px;
}

.gallery-group__title {
  margin: 0 0 12px;
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text-muted);
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
}

.gallery-group .gallery {
  margin-top: 8px;
}

/* ─── Mapping / review ─── */
.mapping-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: stretch;
  gap: 10px 14px;
  padding: 12px 14px;
  margin-bottom: 18px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
}

.mapping-toolbar__search {
  flex: 1 1 200px;
  min-width: 0;
  display: flex;
  align-items: center;
}

.mapping-toolbar__input {
  width: 100%;
  min-width: 0;
  margin: 0;
}

.mapping-toolbar__metrics {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  flex: 0 1 auto;
}

.mapping-metric {
  display: inline-flex;
  align-items: baseline;
  gap: 6px;
  padding: 7px 13px;
  border-radius: 999px;
  font-size: 0.8rem;
  line-height: 1.2;
  border: 1px solid var(--border);
  background: var(--surface-2);
  white-space: nowrap;
}

.mapping-metric__value {
  font-family: var(--mono);
  font-size: 1rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  line-height: 1;
}

.mapping-metric__label {
  font-size: 0.72rem;
  font-weight: 500;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  opacity: 0.9;
}

.mapping-metric--complete {
  border-color: rgba(34, 197, 94, 0.45);
  background: var(--success-dim);
  color: #6ee7b7;
}

.mapping-metric--pending {
  border-color: rgba(245, 158, 11, 0.4);
  background: var(--warn-dim);
  color: #fdba74;
}

.mapping-metric--total {
  border-color: var(--border);
  background: var(--surface-2);
  color: var(--text-muted);
}

.mapping-metric--total .mapping-metric__value {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text);
}

.mapping-metric--total .mapping-metric__label {
  text-transform: none;
  font-size: 0.75rem;
  letter-spacing: 0;
}

.mapping-metric--total:empty,
.mapping-metric--total[hidden] {
  display: none;
}

.review-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.review-card {
  border-radius: var(--radius-lg);
  overflow: hidden;
  background: var(--surface);
  border: 1px solid var(--border);
  transition: border-color var(--ease);
}

.review-card__header {
  padding: 14px 18px;
  display: flex;
  align-items: center;
  gap: 16px;
  cursor: pointer;
  transition: background var(--ease);
}

.review-card__header:hover {
  background: var(--surface-2);
}

.review-card__thumb {
  flex-shrink: 0;
  width: 72px;
  height: 105px;
  object-fit: cover;
  border-radius: var(--radius-sm);
  border: 2px solid var(--border);
  box-shadow: var(--shadow-sm);
  background: var(--bg);
}

.review-card__header-main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.review-card__name {
  font-weight: 700;
  font-size: 0.95rem;
}

.review-card__meta {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.review-card__body {
  display: none;
  padding: 0 18px 18px;
  border-top: 1px solid var(--border);
}

.review-card--open .review-card__body {
  display: block;
  animation: fadeUp 0.3s var(--ease-out) both;
}

.review-card__chevron {
  margin-left: auto;
  color: var(--text-muted);
  transition: transform var(--ease);
}

.review-card--open .review-card__chevron {
  transform: rotate(180deg);
}

.review-card--complete {
  border-color: rgba(34, 197, 94, 0.4);
}

.review-card--incomplete {
  border-color: rgba(245, 158, 11, 0.3);
}

.review-card--busy {
  position: relative;
  pointer-events: none;
}

.review-card--busy::after {
  content: '';
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.18);
  border-radius: inherit;
  z-index: 5;
  pointer-events: none;
}

.review-card--busy::before {
  content: '';
  position: absolute;
  right: 12px;
  top: 12px;
  width: 22px;
  height: 22px;
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  z-index: 6;
}

.review-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
  align-items: center;
}

.save-status {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.save-status.saved { color: var(--success); }
.save-status.error { color: var(--danger); }

.save-status--saving::after {
  content: '';
  display: inline-block;
  width: 12px;
  height: 12px;
  margin-left: 6px;
  vertical-align: -2px;
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

/* Mapping studio */
.mapping-studio {
  padding: 10px 0;
}

.mapping-artwork-gallery {
  display: flex;
  gap: 16px;
  overflow-x: auto;
  padding-bottom: 8px;
  scroll-snap-type: x mandatory;
}

.mapping-artwork {
  flex: 0 0 min(200px, 42vw);
  scroll-snap-align: start;
  border-radius: var(--radius-lg);
  border: 2px solid var(--border);
  background: var(--surface-2);
  padding: 10px;
  transition: border-color var(--ease), box-shadow var(--ease);
}

.mapping-artwork--active {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px var(--accent-glow);
}

.mapping-artwork__img-wrap {
  position: relative;
  border-radius: var(--radius);
  overflow: hidden;
  aspect-ratio: 59 / 86;
  margin-bottom: 8px;
}

.mapping-artwork__img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
  background: #050a12;
}

.mapping-artwork__badge {
  position: absolute;
  top: 6px;
  left: 6px;
  font-size: 0.7rem;
  padding: 2px 8px;
  border-radius: var(--radius-sm);
  background: rgba(0, 0, 0, 0.78);
  color: var(--accent-hover);
  font-weight: 600;
}

.mapping-artwork__label {
  font-size: 0.8rem;
  font-weight: 600;
  margin-bottom: 8px;
  color: var(--text-muted);
}

.mapping-artwork__overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  background: rgba(0, 0, 0, 0.55);
  opacity: 0;
  transition: opacity 0.15s ease;
  pointer-events: none;
}

.mapping-artwork__img-wrap:hover .mapping-artwork__overlay,
.mapping-artwork__img-wrap:focus-within .mapping-artwork__overlay,
.mapping-artwork--active .mapping-artwork__overlay {
  opacity: 1;
  pointer-events: auto;
}

@media (hover: hover) {
  .mapping-artwork--active:not(:hover) .mapping-artwork__overlay {
    opacity: 0;
    pointer-events: none;
  }
  .mapping-artwork--active:hover .mapping-artwork__overlay {
    opacity: 1;
    pointer-events: auto;
  }
}

.mapping-artwork__img-wrap--busy .mapping-artwork__overlay {
  opacity: 1;
  pointer-events: auto;
}

.mapping-artwork__img-wrap--busy::after {
  content: '';
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  z-index: 2;
}

.mapping-artwork__img-wrap--busy::before {
  content: '';
  position: absolute;
  left: 50%;
  top: 50%;
  width: 28px;
  height: 28px;
  margin: -14px 0 0 -14px;
  border: 3px solid rgba(255, 255, 255, 0.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  z-index: 3;
}

.mapping-artwork__action {
  width: 36px;
  height: 36px;
  padding: 0;
  border: none;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  background: rgba(255, 255, 255, 0.95);
  color: #111;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.35);
  transition: background 0.12s ease, filter 0.12s ease;
}

.mapping-artwork__action:hover {
  filter: brightness(1.08);
}

.mapping-artwork__action--remove {
  background: var(--danger);
  color: #fff;
}

.mapping-artwork__img--missing {
  background: #171a24;
  min-height: 120px;
}

.mapping-artwork__img--missing-file {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 120px;
  background: rgba(244, 63, 94, 0.14);
  border: 2px solid var(--danger);
  box-sizing: border-box;
}

.mapping-artwork__missing-label {
  color: #fca5a5;
  font-size: 0.8rem;
  font-weight: 700;
  text-align: center;
  padding: 8px;
  line-height: 1.3;
}

.mapping-artwork--has-missing .mapping-artwork__img-wrap {
  outline: 2px solid var(--danger);
  outline-offset: -2px;
}

.mapping-artwork-add {
  flex: 0 0 min(200px, 42vw);
  scroll-snap-align: start;
  align-self: flex-start;
  padding: 0;
  margin: 0;
  border: none;
  background: transparent;
  cursor: pointer;
  font: inherit;
}

.mapping-artwork-add__card {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  aspect-ratio: 59 / 86;
  border-radius: var(--radius);
  border: 2px dashed var(--border);
  background: var(--surface-2);
  color: var(--text-muted);
  font-size: 2rem;
  font-weight: 300;
  line-height: 1;
  transition: border-color 0.15s ease, color 0.15s ease, background 0.15s ease;
}

.mapping-artwork-add:hover .mapping-artwork-add__card,
.mapping-artwork-add:focus-visible .mapping-artwork-add__card {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-dim);
}

.mapping-artwork-add:disabled .mapping-artwork-add__card {
  opacity: 0.5;
  cursor: not-allowed;
}

.set-chip-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.set-chip {
  font-family: var(--mono);
  font-size: 0.72rem;
  padding: 6px 11px;
  border-radius: var(--radius-sm);
  border: 2px solid var(--border);
  background: var(--bg);
  color: var(--text);
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease, color 0.15s ease, box-shadow 0.15s ease;
  line-height: 1.2;
}

.set-chip:hover {
  border-color: var(--text-muted);
}

.set-chip--active {
  border-color: var(--accent);
  background: var(--accent-dim);
  color: var(--accent-hover);
  box-shadow: 0 0 12px var(--accent-glow);
}

.set-chip--elsewhere {
  opacity: 0.35;
  pointer-events: none;
}

.mapping-deleted {
  margin-top: 16px;
  padding: 14px;
  border-radius: var(--radius);
  background: rgba(0, 0, 0, 0.25);
  border: 1px dashed var(--border);
}

.mapping-deleted__title {
  margin: 0 0 10px;
  font-size: 0.8rem;
  color: var(--text-muted);
}

.mapping-deleted__list {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.mapping-deleted__item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 8px;
  border-radius: var(--radius);
  background: var(--surface-2);
  opacity: 0.75;
}

.mapping-deleted__item img {
  width: 48px;
  height: 70px;
  object-fit: cover;
  border-radius: 4px;
}

.mapping-deleted__item span {
  font-size: 0.72rem;
  color: var(--text-muted);
}

/* ─── Artworks upload ─── */
.artwork-picker {
  display: grid;
  grid-template-columns: 150px 1fr;
  gap: 26px;
  align-items: start;
  padding: 22px;
  border-radius: var(--radius-lg);
  background: var(--surface);
  border: 1px solid var(--border);
}

.artwork-picker__preview {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.artwork-picker__preview img {
  width: 100%;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  background: var(--bg);
}

.artwork-picker__preview h3 {
  margin: 0;
  font-size: 1rem;
}

.upload-form {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.upload-form label {
  display: block;
}

.upload-drop {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-height: 150px;
  padding: 22px;
  border-radius: var(--radius-lg);
  border: 2px dashed var(--border);
  background: var(--bg);
  cursor: pointer;
  text-align: center;
  transition: border-color var(--ease), background var(--ease);
}

.upload-drop:hover,
.upload-drop--active {
  border-color: var(--accent);
  background: var(--accent-dim);
}

.upload-drop__text {
  color: var(--text-muted);
  font-size: 0.9rem;
}

.upload-drop__preview {
  max-height: 160px;
  max-width: 100%;
  border-radius: var(--radius);
  object-fit: contain;
}

.upload-drop__preview.hidden,
.upload-drop__text.hidden {
  display: none !important;
}

.artwork-slot-picker__label {
  display: block;
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-bottom: 4px;
}

.slot-gallery {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 8px;
}

.slot-gallery__item {
  position: relative;
  width: 88px;
  padding: 0;
  border: 2px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface-2);
  cursor: pointer;
  overflow: hidden;
  transition: border-color var(--ease);
}

.slot-gallery__item:hover {
  border-color: var(--accent);
}

.slot-gallery__item--selected {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent-glow);
}

.slot-gallery__item img {
  width: 100%;
  aspect-ratio: 59 / 86;
  object-fit: cover;
  display: block;
}

.slot-gallery__num {
  display: block;
  text-align: center;
  font-size: 0.7rem;
  padding: 4px;
  color: var(--text-muted);
  background: rgba(0, 0, 0, 0.5);
}

.artwork-pick-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}

.artwork-pick-card {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--surface);
  cursor: pointer;
  transition: border-color var(--ease);
}

.artwork-pick-card:hover {
  border-color: var(--accent);
}

.artwork-pick-card img {
  width: 32px;
  height: 46px;
  object-fit: cover;
  border-radius: 4px;
}

/* ─── Modals ─── */
.modal {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.modal.is-open {
  display: flex;
}

.modal__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(4, 4, 10, 0.8);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}

.modal__box {
  position: relative;
  z-index: 1;
  width: min(940px, 100%);
  max-height: min(90vh, 900px);
  overflow: auto;
  padding: 28px;
  border-radius: var(--radius-xl);
  background: var(--surface);
  border: 1px solid var(--border-strong);
  box-shadow: var(--shadow);
  animation: fadeUp 0.3s var(--ease-out) both;
}

.modal__close {
  position: absolute;
  top: 14px;
  right: 14px;
  width: 36px;
  height: 36px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface-3);
  color: var(--text-muted);
  font-size: 1.4rem;
  line-height: 1;
  cursor: pointer;
  z-index: 2;
  transition: color var(--ease), border-color var(--ease), background var(--ease);
}

.modal__close:hover {
  color: var(--text);
  border-color: var(--border-strong);
  background: var(--surface-4);
}

.modal__content {
  display: grid;
  grid-template-columns: minmax(180px, 280px) 1fr;
  gap: 28px;
  align-items: start;
}

.modal__image-wrap {
  position: sticky;
  top: 0;
}

.modal__image {
  width: 100%;
  border-radius: var(--radius-lg);
  display: block;
  background: var(--bg);
  box-shadow: var(--shadow);
}

.modal__info {
  min-width: 0;
}

.modal__name {
  margin: 0 0 4px;
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  padding-right: 40px;
}

.modal__id {
  margin: 0 0 8px;
  font-family: var(--mono);
  font-size: 0.8rem;
  color: var(--text-faint);
}

.modal__meta {
  margin: 0 0 10px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 8px;
  font-size: 0.9rem;
  color: var(--text-muted);
}

.meta-attr {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-weight: 600;
  color: var(--text);
}

.meta-attr img,
.combat-attr img {
  width: 18px;
  height: 18px;
  object-fit: contain;
  display: block;
}

.combat-attr {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  vertical-align: middle;
}

.modal__release {
  margin: 0 0 10px;
  font-family: var(--mono);
  font-size: 0.8rem;
  color: var(--accent-2);
}

.modal__desc {
  margin: 0;
  padding: 14px 16px;
  border-radius: var(--radius);
  background: var(--surface-2);
  border: 1px solid var(--border);
  font-size: 0.88rem;
  line-height: 1.55;
  white-space: pre-wrap;
  max-height: 220px;
  overflow: auto;
}

.modal__section {
  margin-top: 20px;
}

.modal__section:last-child {
  margin-bottom: 0;
}

.modal__section-title {
  margin: 0 0 10px;
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--accent-2);
}

.modal__setcodes-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.modal__table-wrap {
  overflow-x: auto;
  border-radius: var(--radius);
  border: 1px solid var(--border);
}

.modal__sets-collapsible {
  margin-top: 8px;
}

.modal__sets-collapsible--collapsed .modal__tr--extra {
  display: none;
}

.modal__sets-toggle {
  margin-top: 8px;
}

.modal__table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.8rem;
}

.modal__table th,
.modal__table td {
  padding: 9px 11px;
  text-align: left;
  border-bottom: 1px solid var(--border);
}

.modal__table th {
  background: var(--surface-2);
  color: var(--text-muted);
  font-weight: 700;
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.modal__table td {
  font-family: var(--mono);
  font-size: 0.78rem;
}

.modal__td-code {
  position: relative;
  white-space: nowrap;
}

.modal__set-code {
  display: inline-block;
  vertical-align: middle;
}

.modal__set-add {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.65rem;
  height: 1.65rem;
  margin-left: 0.35rem;
  padding: 0;
  vertical-align: middle;
  border: 1px solid rgba(139, 92, 246, 0.45);
  border-radius: var(--radius-sm);
  background: var(--accent-dim);
  color: var(--accent-hover);
  font-size: 1rem;
  font-weight: 600;
  line-height: 1;
  cursor: pointer;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s ease, background 0.15s ease, border-color 0.15s ease;
}

.modal__table tbody tr:hover .modal__set-add,
.modal__set-add:focus-visible {
  opacity: 1;
  pointer-events: auto;
}

.modal__set-add:hover {
  background: rgba(139, 92, 246, 0.3);
  border-color: rgba(139, 92, 246, 0.8);
}

.modal__set-add:disabled {
  opacity: 0.45;
  cursor: wait;
}

.modal-artwork-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin: 10px 0 14px;
}

.modal-artwork-tab {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  min-width: 72px;
  padding: 8px 10px 10px;
  font-size: 0.75rem;
  font-weight: 600;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text-muted);
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, color 0.15s, box-shadow 0.15s;
}

.modal-artwork-tab:hover {
  border-color: rgba(139, 92, 246, 0.5);
  color: var(--text);
}

.modal-artwork-tab--active {
  border-color: transparent;
  background: var(--brand-grad);
  color: #fff;
  box-shadow: 0 3px 10px rgba(139, 92, 246, 0.35);
}

.modal-artwork-tab__thumb {
  width: 48px;
  height: 70px;
  object-fit: cover;
  border-radius: var(--radius-sm);
  background: rgba(0, 0, 0, 0.35);
  display: block;
}

.modal-artwork-tab__thumb--empty {
  width: 48px;
  height: 70px;
}

.modal-artwork-tab__label {
  line-height: 1.2;
  text-align: center;
  white-space: nowrap;
}

/* Combat stats */
.modal-combat {
  margin: 16px 0;
  padding: 14px;
  border-radius: var(--radius);
  background: var(--surface-2);
  border: 1px solid var(--border);
}

.modal-combat__extra {
  margin-bottom: 8px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 8px;
  font-size: 0.8rem;
  color: var(--text-muted);
}

.modal-combat__values {
  display: flex;
  gap: 12px;
}

.modal-combat__stat {
  flex: 1;
  padding: 12px;
  border-radius: var(--radius);
  background: var(--bg);
  border: 1px solid var(--border);
  text-align: center;
}

.modal-combat__stat--atk {
  border-color: rgba(244, 63, 94, 0.35);
}

.modal-combat__stat--def {
  border-color: rgba(34, 211, 238, 0.35);
}

.modal-combat__label {
  display: block;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 2px;
}

.modal-combat__stat--atk .modal-combat__label { color: var(--danger); }
.modal-combat__stat--def .modal-combat__label { color: var(--accent-2); }

.modal-combat__num {
  font-family: var(--mono);
  font-size: 1.3rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.modal-combat__stat--atk .modal-combat__num { color: #fca5a5; }
.modal-combat__stat--def .modal-combat__num { color: #7de3f4; }

/* Banlist chips */
.card-banlist {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 8px 0 12px;
}

.card-banlist[hidden] {
  display: none !important;
}

.banlist-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 0.7rem;
  font-weight: 700;
  border: 1px solid var(--border);
  background: var(--surface-3);
}

.banlist-chip--forbidden {
  background: var(--danger-dim);
  border-color: rgba(244, 63, 94, 0.45);
  color: var(--danger);
}

.banlist-chip--limited {
  background: var(--warn-dim);
  border-color: rgba(245, 158, 11, 0.45);
  color: var(--warn);
}

.banlist-chip--semi {
  background: rgba(251, 191, 36, 0.13);
  border-color: rgba(251, 191, 36, 0.45);
  color: #fbbf24;
}

.banlist-chip--default {
  color: var(--text-muted);
}

/* Form modal */
.form-modal .modal__box--form {
  max-width: 580px;
  width: calc(100% - 32px);
  max-height: 90vh;
  overflow-y: auto;
}

.form-modal__title {
  margin: 0 0 8px;
  font-size: 1.4rem;
}

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.form-field {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.form-field span {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.form-field--wide {
  grid-column: 1 / -1;
}

.form-modal__sets {
  margin-top: 20px;
  padding-top: 18px;
  border-top: 1px solid var(--border);
}

.form-modal__sets-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
}

.form-modal__sets-head h3 {
  margin: 0;
  font-size: 0.95rem;
}

.sets-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.sets-list__row {
  display: grid;
  grid-template-columns: 1fr 1fr auto auto;
  gap: 8px;
  margin-bottom: 8px;
  align-items: end;
}

.form-modal__actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 18px;
}

.form-modal__status {
  min-height: 1.2em;
  font-size: 0.875rem;
  margin: 8px 0 0;
}

.form-modal__status--ok { color: var(--success); }
.form-modal__status--err { color: var(--danger); }

/* ─── Card page / shell ─── */
#card-shell-header {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 200;
  border-bottom: 1px solid var(--border);
  background: rgba(10, 10, 18, 0.92);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.4);
}

.card-shell-header__inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  max-width: 1200px;
  margin: 0 auto;
  padding: 12px 20px;
  min-height: 52px;
}

.card-shell-header__back {
  flex-shrink: 0;
  padding: 8px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface-3);
  color: var(--text);
  font-family: inherit;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: border-color var(--ease), color var(--ease), background var(--ease);
}

.card-shell-header__back:hover {
  border-color: var(--accent);
  color: var(--accent-hover);
}

.card-shell-header__titles {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  flex: 1;
  justify-content: center;
}

.card-shell-header__brand {
  font-size: 0.8rem;
  font-weight: 700;
  background: var(--brand-grad);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  white-space: nowrap;
}

.card-shell-header__crumb {
  color: var(--text-faint);
}

.card-shell-header__card {
  font-size: 0.9rem;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.card-shell-header__home {
  flex-shrink: 0;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-muted);
  text-decoration: none;
  padding: 8px 12px;
  border-radius: var(--radius);
  transition: color var(--ease), background var(--ease);
}

.card-shell-header__home:hover {
  color: var(--accent-hover);
  background: var(--accent-dim);
}

.card-page {
  max-width: 1100px;
  margin: 0 auto;
  animation: fadeUp 0.4s var(--ease-out) both;
}

.card-page__layout {
  display: grid;
  grid-template-columns: minmax(200px, 320px) 1fr;
  gap: 32px;
  align-items: start;
}

.card-page__visual {
  position: sticky;
  top: 80px;
}

html.card-route .card-page__visual,
body.card-page-open .card-page__visual {
  top: 80px;
}

.card-page__image {
  width: 100%;
  border-radius: var(--radius-lg);
  display: block;
  background: var(--bg);
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
}

.card-page__body {
  min-width: 0;
}

.card-page__title {
  margin: 0 0 6px;
  font-size: 1.85rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.card-page__id {
  margin: 0 0 8px;
  font-family: var(--mono);
  font-size: 0.85rem;
  color: var(--text-faint);
}

.card-page__meta {
  margin: 0 0 12px;
  font-size: 0.95rem;
  color: var(--text-muted);
}

.card-page__release {
  margin: 0 0 12px;
  font-family: var(--mono);
  font-size: 0.85rem;
  color: var(--accent-2);
}

.card-page__desc {
  margin: 0 0 16px;
  padding: 16px 18px;
  border-radius: var(--radius);
  background: var(--surface);
  border: 1px solid var(--border);
  font-size: 0.92rem;
  line-height: 1.55;
  white-space: pre-wrap;
}

.card-page-combat {
  margin-bottom: 16px;
}

.card-page__sets {
  margin-top: 8px;
}

/* Misc */
.loading,
.error {
  padding: 24px;
  text-align: center;
  color: var(--text-muted);
}

.error {
  color: var(--danger);
}

.auth-card {
  padding: 20px;
  border-radius: var(--radius);
  background: var(--surface);
  border: 1px solid var(--border);
}

.auth-card__form {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

/* ─── Motion ─── */
@keyframes fadeUp {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes slideInRight {
  from {
    opacity: 0;
    transform: translateX(24px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

@keyframes progress-indeterminate {
  0% { transform: translateX(-120%); }
  100% { transform: translateX(320%); }
}

@keyframes cardIn {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ─── Responsive ─── */
@media (min-width: 720px) {
  .mapping-toolbar {
    flex-wrap: nowrap;
    align-items: center;
    padding: 10px 12px 10px 14px;
  }

  .mapping-toolbar__metrics {
    margin-left: auto;
    flex-shrink: 0;
  }
}

@media (max-width: 960px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .app-sidebar {
    position: relative;
    height: auto;
    max-height: none;
    border-right: none;
    border-bottom: 1px solid var(--border);
    padding: 12px 14px;
  }

  .app-sidebar__brand {
    padding-bottom: 10px;
    margin-bottom: 4px;
  }

  .app-sidebar__nav {
    flex-direction: row;
    overflow-x: auto;
    overflow-y: hidden;
    gap: 6px;
    padding-bottom: 4px;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin;
  }

  .nav__tab {
    flex: 0 0 auto;
    width: auto;
    min-width: 120px;
    padding: 8px 12px;
  }

  .nav__tab-hint {
    display: none;
  }

  .app-sidebar__foot {
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
    margin-top: 10px;
  }

  .app-sidebar__foot .btn--sidebar {
    width: auto;
    flex: 1 1 auto;
  }

  .auth-user-chip {
    flex: 1 1 100%;
  }

  .main {
    padding: 18px 16px 40px;
  }

  .app-topbar,
  .header.app-topbar {
    padding: 14px 16px;
  }

  .banlist-matrix {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 820px) {
  .card-page__layout {
    grid-template-columns: 1fr;
    gap: 20px;
  }

  .card-page__visual {
    position: static;
    max-width: 280px;
    margin: 0 auto;
  }
}

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

  .review-card__thumb {
    width: 56px;
    height: 82px;
  }

  .artwork-picker {
    grid-template-columns: 1fr;
  }

  .form-grid {
    grid-template-columns: 1fr;
  }

  .sets-list__row {
    grid-template-columns: 1fr;
  }

  .mapping-toolbar__metrics {
    width: 100%;
    justify-content: flex-start;
  }

  .modal__content {
    grid-template-columns: 1fr;
  }

  .modal__image-wrap {
    position: static;
    max-width: 220px;
    margin: 0 auto;
  }
}

@media (max-width: 600px) {
  .modal__box {
    padding: 18px 14px;
  }
}

@media (max-width: 480px) {
  .gallery {
    grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
    gap: 10px;
  }

  .app-topbar__actions .btn--header {
    font-size: 0.78rem;
    padding: 7px 10px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
