@import url("https://fonts.googleapis.com/css2?family=Exo+2:wght@400;500;600;700&family=Inter:wght@400;500;600;700&family=Lato:wght@400;700&family=Montserrat:wght@500;600;700&display=swap");

:root {
  color-scheme: dark;
  --bg: #141210;
  --bg-2: #1c1916;
  --bg-deep: #0c0b0a;
  --panel: #24211d;
  --panel-2: #2e2a24;
  --line: #4a4036;
  --text: #f6efe6;
  --muted: #c4b4a4;
  --copper: #e08a2c;
  --copper-hot: #f0a04a;
  --copper-ink: #1a1208;
  --ember: #c45c26;
  --danger: #e07a62;
  --ok: #8fbf8a;
  --glow: rgba(224, 138, 44, 0.28);
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  --font-ui: "Inter", sans-serif;
  --font-brand: "Inter", sans-serif;
}
html[data-theme="modrinth"] {
  --bg: #16181c;
  --bg-2: #1e2126;
  --bg-deep: #0e1013;
  --panel: #23262b;
  --panel-2: #2c3036;
  --line: #3d444d;
  --text: #e8eef2;
  --muted: #a8b3bd;
  --copper: #1bd96a;
  --copper-hot: #3eec84;
  --copper-ink: #06210f;
  --ember: #0e9f4d;
  --glow: rgba(27, 217, 106, 0.28);
  --ok: #1bd96a;
  --font-ui: "Inter", sans-serif;
  --font-brand: "Inter", sans-serif;
}
html[data-theme="curseforge"] {
  --bg: #121212;
  --bg-2: #1a1a1a;
  --bg-deep: #0a0a0a;
  --panel: #1f1f1f;
  --panel-2: #2a2a2a;
  --line: #453833;
  --text: #f4ece8;
  --muted: #c2b2aa;
  --copper: #f16436;
  --copper-hot: #ff8a5b;
  --copper-ink: #2a100a;
  --ember: #c2410c;
  --glow: rgba(241, 100, 54, 0.3);
  --font-ui: "Lato", sans-serif;
  --font-brand: "Montserrat", sans-serif;
}
html[data-theme="steam"] {
  --bg: #171a21;
  --bg-2: #1b2838;
  --bg-deep: #0e141b;
  --panel: #1e2a38;
  --panel-2: #243447;
  --line: #3d556c;
  --text: #e8f4fc;
  --muted: #8f98a0;
  --copper: #66c0f4;
  --copper-hot: #8fd4ff;
  --copper-ink: #0b1b28;
  --ember: #1a9fff;
  --glow: rgba(102, 192, 244, 0.3);
  --ok: #5ba32b;
  --font-ui: "Motiva Sans", "Exo 2", Arial, Helvetica, sans-serif;
  --font-brand: "Motiva Sans", "Exo 2", Arial, Helvetica, sans-serif;
}
html[data-theme="rawg"] {
  --bg: #151515;
  --bg-2: #1a1a1a;
  --bg-deep: #0d0d0d;
  --panel: #202020;
  --panel-2: #2a2a2a;
  --line: #3a3a3a;
  --text: #ffffff;
  --muted: rgba(255, 255, 255, 0.55);
  --copper: #ffffff;
  --copper-hot: #f4f4f4;
  --copper-ink: #151515;
  --ember: #d0d0d0;
  --glow: rgba(255, 255, 255, 0.16);
  --font-ui: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  --font-brand: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
}

* { box-sizing: border-box; }

*::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}
*::-webkit-scrollbar-track {
  background: color-mix(in srgb, var(--bg-deep) 88%, var(--copper));
}
*::-webkit-scrollbar-thumb {
  background: var(--copper);
  border: 2px solid color-mix(in srgb, var(--bg-deep) 88%, var(--copper));
  border-radius: 999px;
}
*::-webkit-scrollbar-thumb:hover {
  background: var(--copper-hot);
}

html {
  height: 100%;
  scroll-behavior: smooth;
}

body {
  margin: 0;
  height: 100%;
  display: flex;
  flex-direction: column;
  color: var(--text);
  font-family: var(--font-ui);
  background:
    radial-gradient(900px 480px at 8% -10%, color-mix(in srgb, var(--ember) 22%, transparent), transparent 55%),
    radial-gradient(700px 420px at 100% 0%, color-mix(in srgb, var(--copper) 18%, transparent), transparent 50%),
    linear-gradient(165deg, var(--bg-2) 0%, var(--bg) 42%, var(--bg-deep) 100%);
  overflow: hidden;
}

body::before {
  content: "";
  pointer-events: none;
  position: fixed;
  inset: 0;
  opacity: 0.045;
  background-image:
    radial-gradient(circle at 20% 30%, #fff 0.6px, transparent 0.7px),
    radial-gradient(circle at 70% 60%, #fff 0.5px, transparent 0.6px);
  background-size: 120px 120px, 180px 180px;
  animation: dust 28s linear infinite;
  z-index: 0;
}

body > * { position: relative; z-index: 1; }

@keyframes dust {
  from { transform: translateY(0); }
  to { transform: translateY(-40px); }
}

button, input, textarea, select { font: inherit; color: inherit; }
button {
  cursor: pointer;
  transition: transform 0.18s var(--ease), background 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease, opacity 0.2s ease;
}
button:active:not(:disabled) { transform: scale(0.97); }
button:disabled { opacity: 0.55; cursor: wait; }
a {
  color: var(--copper);
  transition: color 0.15s ease;
}
a:hover { color: var(--copper-hot); }

.top {
  display: flex;
  flex: 0 0 auto;
  gap: 12px;
  align-items: center;
  padding: 12px 18px;
  border-bottom: 1px solid color-mix(in srgb, var(--line) 80%, transparent);
  position: sticky;
  top: 0;
  background: rgba(18, 16, 14, 0.82);
  backdrop-filter: blur(14px);
  z-index: 5;
  animation: slide-down 0.45s var(--ease);
}

@keyframes slide-down {
  from { opacity: 0; transform: translateY(-10px); }
  to { opacity: 1; transform: none; }
}

.brand {
  font-family: var(--font-brand);
  font-weight: 700;
  font-size: 1.25rem;
  letter-spacing: 0.02em;
  background: linear-gradient(120deg, var(--copper-hot), var(--ember));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  position: relative;
  padding-right: 18px;
}

.brand::after {
  content: "";
  position: absolute;
  right: 0;
  top: 0.35em;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, #fff6, var(--ember));
  box-shadow: 0 0 10px var(--ember);
  animation: blink 4.5s ease-in-out infinite;
}

@keyframes blink {
  0%, 92%, 100% { transform: scaleY(1); opacity: 1; }
  94% { transform: scaleY(0.15); opacity: 0.7; }
}

.game-scope {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
  position: relative;
}
.game-scope > span {
  font-size: 0.72rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  white-space: nowrap;
}
.game-picker-wrap { position: relative; }
.game-picker {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 12rem;
  max-width: min(40rem, 52vw);
  flex: 0 1 auto;
  background: color-mix(in srgb, var(--panel) 90%, black);
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--text);
  padding: 4px 12px 4px 4px;
  font: inherit;
  text-align: left;
  cursor: pointer;
}
.game-picker:hover,
.game-picker[aria-expanded="true"] {
  border-color: var(--copper);
  box-shadow: 0 0 0 3px var(--glow);
}
.game-picker img {
  width: 36px;
  height: 22px;
  object-fit: cover;
  object-position: center;
  border-radius: 6px;
  background: #120e0b;
  flex: 0 0 auto;
}
.game-picker img.is-logo,
.game-menu img.is-logo {
  object-fit: cover;
  object-position: center 22%;
  background: transparent;
}
.game-picker img.is-logo {
  width: 64px;
  height: 28px;
}
.game-menu img.is-logo {
  width: 84px;
  height: 36px;
}
.game-picker span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}
.game-menu {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  min-width: 100%;
  width: max(100%, 280px);
  max-height: min(50vh, 360px);
  overflow: auto;
  z-index: 40;
  background: linear-gradient(180deg, var(--panel-2), var(--panel));
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 6px;
  box-shadow: 0 16px 36px rgba(0, 0, 0, 0.45);
}
.game-menu button {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 10px;
  text-align: left;
  border: 0;
  background: transparent;
  color: var(--text);
  border-radius: 10px;
  padding: 6px 8px;
  font: inherit;
  cursor: pointer;
}
.game-menu button:hover,
.game-menu button.on {
  background: rgba(226, 164, 92, 0.14);
  color: var(--copper-hot);
}
.game-menu img {
  width: 48px;
  height: 28px;
  object-fit: cover;
  border-radius: 6px;
  background: var(--panel-2);
  flex: 0 0 auto;
}
.game-scope .side-add {
  flex: 0 0 28px;
  width: 28px !important;
  min-width: 28px !important;
  height: 28px !important;
}
.game-hero {
  border: 1px solid var(--line);
  border-radius: 18px;
  overflow: hidden;
  margin-bottom: 16px;
  background: linear-gradient(180deg, var(--panel-2), var(--bg));
  animation: fade-in 0.45s var(--ease);
}
.game-hero-inner {
  display: grid;
  grid-template-columns: minmax(240px, 38%) 1fr;
  gap: 16px;
  padding: 12px;
  align-items: stretch;
}
.game-hero-cover {
  width: 100%;
  height: 100%;
  min-height: 168px;
  aspect-ratio: 16 / 9;
  object-fit: cover;
  border-radius: 16px;
  border: 1px solid var(--line);
  background: var(--panel-2);
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.35);
}
.game-hero h2 {
  margin: 0 0 6px;
  font-family: var(--font-brand);
  font-size: 1.55rem;
  font-weight: 700;
}
.game-hero .meta { margin: 0 0 8px; }
.game-hero .desc {
  margin: 0;
  color: var(--muted);
  font-size: 0.92rem;
  line-height: 1.45;
  display: -webkit-box;
  -webkit-line-clamp: 5;
  -webkit-box-orient: vertical;
  overflow: hidden;
  max-width: 62ch;
}
.game-hero-links {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}
.game-hero-links a {
  color: var(--copper-hot);
  font-size: 0.85rem;
}
@media (max-width: 720px) {
  .game-hero-inner { grid-template-columns: 1fr; }
  .game-hero-cover { width: 100%; max-height: 220px; }
}
.game-results {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: min(52vh, 420px);
  overflow: auto;
  margin: 8px 0;
}
.game-hit {
  display: grid;
  grid-template-columns: 72px 1fr auto;
  gap: 10px;
  align-items: center;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(12, 10, 8, 0.35);
}
.game-hit img {
  width: 72px;
  height: 42px;
  object-fit: cover;
  border-radius: 8px;
  background: var(--panel-2);
}
.game-hit b {
  display: block;
  font-size: 0.92rem;
}
.game-hit .meta { margin: 2px 0 0; }

.search-wrap { position: relative; flex: 1; min-width: 180px; }
.search-field { position: relative; }
#search {
  width: 100%;
  background: color-mix(in srgb, var(--panel) 90%, black);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 9px 128px 9px 14px;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}
.search-platform {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  display: flex;
  align-items: center;
  gap: 4px;
  pointer-events: none;
  max-width: calc(100% - 28px);
}
.search-platform span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 12px;
  color: var(--copper);
  background: color-mix(in srgb, var(--copper) 16%, transparent);
  border-radius: 999px;
  padding: 2px 8px;
}
#search:focus {
  outline: none;
  border-color: var(--copper);
  box-shadow: 0 0 0 3px var(--glow);
}
.search-remote {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  z-index: 30;
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: min(52vh, 380px);
  overflow: auto;
  padding: 8px;
  background: linear-gradient(180deg, var(--panel-2), var(--panel));
  border: 1px solid color-mix(in srgb, var(--copper) 25%, var(--line));
  border-radius: 16px;
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.45);
}
.search-remote[hidden] { display: none !important; }
.search-remote .hint { padding: 6px 8px; }
.search-hit {
  display: grid;
  grid-template-columns: 72px 1fr auto;
  gap: 10px;
  align-items: center;
  padding: 6px;
  border-radius: 12px;
}
.search-hit img {
  width: 72px;
  height: 42px;
  object-fit: cover;
  border-radius: 8px;
  background: var(--panel-2);
}
.search-hit b { display: block; font-size: 0.92rem; }
.search-hit .meta { margin: 2px 0 0; }

.top-actions { display: flex; gap: 8px; align-items: center; flex-shrink: 0; }
.app-menu-wrap { position: relative; }
.app-menu-btn {
  padding: 8px 14px;
  white-space: nowrap;
}
.app-menu {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  min-width: 180px;
  z-index: 50;
  background: linear-gradient(180deg, var(--panel-2), var(--panel));
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 6px;
  box-shadow: 0 16px 36px rgba(0, 0, 0, 0.45);
}
.app-menu button {
  width: 100%;
  display: block;
  text-align: left;
  border: 0;
  background: transparent;
  color: var(--text);
  border-radius: 10px;
  padding: 9px 12px;
  font: inherit;
  cursor: pointer;
}
.app-menu button:hover {
  background: rgba(226, 164, 92, 0.14);
  color: var(--copper-hot);
}
.app-menu button#add-open {
  color: var(--copper-hot);
  font-weight: 700;
}

.solid, .ghost, .icon {
  border-radius: 999px;
  border: 1px solid var(--line);
  background: transparent;
  padding: 8px 14px;
  position: relative;
  overflow: hidden;
}
.ghost:hover { background: var(--panel-2); border-color: color-mix(in srgb, var(--copper) 35%, var(--line)); }
.solid {
  background: linear-gradient(135deg, var(--copper-hot), var(--copper) 55%, var(--ember));
  color: var(--copper-ink);
  border-color: transparent;
  font-weight: 700;
  box-shadow: 0 6px 18px rgba(226, 164, 92, 0.22);
}
.solid:hover { box-shadow: 0 8px 22px rgba(226, 164, 92, 0.35); filter: brightness(1.04); }
.icon { padding: 4px 8px; border-radius: 10px; }

.btn-loading {
  pointer-events: none;
  color: transparent !important;
}
.btn-loading > * { visibility: hidden; }
.btn-loading::after {
  content: "";
  position: absolute;
  inset: 50% auto auto 50%;
  width: 16px;
  height: 16px;
  margin: -8px 0 0 -8px;
  border: 2px solid color-mix(in srgb, var(--copper) 35%, transparent);
  border-top-color: var(--copper);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  visibility: visible;
}
.solid.btn-loading::after {
  border-color: color-mix(in srgb, var(--copper-ink) 30%, transparent);
  border-top-color: var(--copper-ink);
}

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

.mute-btn {
  width: 36px;
  height: 36px;
  padding: 0;
  display: grid;
  place-items: center;
  border-radius: 50%;
  border: 1px solid rgba(36, 24, 12, 0.28);
  background: rgba(255, 248, 240, 0.28);
  color: var(--copper-ink);
  font-size: 15px;
}
.mute-btn:hover { background: rgba(255, 248, 240, 0.46); }
.mute-btn.on { opacity: 0.55; }

.dock {
  flex: 0 0 auto;
  display: grid;
  grid-template-columns: max-content 1fr max-content;
  grid-template-areas: "user . actions";
  align-items: center;
  gap: 8px 12px;
  width: 100%;
  max-width: 100%;
  min-height: 52px;
  padding: 8px 12px;
  background: linear-gradient(120deg, var(--copper-hot), var(--ember));
  color: var(--copper-ink);
  z-index: 60;
}
.dock-lead {
  grid-area: user;
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}
button.dock-user {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  max-width: 220px;
  margin: 0;
  padding: 2px 8px 2px 2px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: inherit;
  cursor: pointer;
  font: inherit;
}
button.dock-user:hover {
  background: rgba(255, 248, 240, 0.22);
}
button.dock-user[aria-expanded="true"] {
  background: rgba(255, 248, 240, 0.3);
}
.dock-user img {
  width: 36px;
  height: 36px;
  flex: 0 0 auto;
  border-radius: 50%;
  background: #fff8f0;
  border: 2px solid rgba(36, 24, 12, 0.28);
  object-fit: cover;
}
.dock-user span {
  font-family: var(--font-brand);
  font-weight: 700;
  font-size: 1.05rem;
  letter-spacing: 0.04em;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.dock-caret {
  flex: 0 0 auto;
  opacity: 0.78;
  transition: transform 0.16s var(--ease);
}
button.dock-user[aria-expanded="true"] .dock-caret {
  transform: rotate(180deg);
  opacity: 1;
}
.dock-keys {
  position: relative;
  z-index: 70;
  flex: 0 0 auto;
  width: auto;
  height: 34px;
}
.keys-summary {
  position: relative;
  z-index: 3;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 34px;
  padding: 0 10px;
  border-radius: 999px;
  border: 1px solid rgba(36, 24, 12, 0.28);
  background: rgba(255, 248, 240, 0.55);
  color: var(--copper-ink);
  font-size: 12px;
  font-weight: 750;
  white-space: nowrap;
}
.keys-summary svg { display: block; flex: 0 0 auto; }
.keys-summary b {
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  min-width: 0.9em;
  text-align: center;
}
.keys-summary.ready {
  background: rgba(220, 245, 228, 0.85);
  color: #167a3a;
  border-color: rgba(22, 122, 58, 0.35);
  padding: 0 9px;
}
.keys-summary.ready b { display: none; }
.keys-summary.ready svg { color: #1f9d4a; }
.keys-panel {
  position: absolute;
  right: 0;
  left: auto;
  bottom: calc(100% + 8px);
  transform: translateY(6px);
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 168px;
  padding: 8px;
  border-radius: 14px;
  border: 1px solid rgba(36, 24, 12, 0.22);
  background: color-mix(in srgb, var(--copper-hot) 82%, #fff8f0);
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.28);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 0.14s ease, transform 0.14s var(--ease), visibility 0.14s;
  z-index: 4;
}
.dock-keys::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: 100%;
  height: 12px;
}
.dock-keys:is(:hover, :focus-within, .open) .keys-panel {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  transform: translateY(0);
}
/* Un solo pop a la vez */
.dock-actions:has(.dock-keys:is(:hover, :focus-within, .open)) .theme-panel {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}
.dock-actions:has(.theme-switch:is(:hover, :focus-within, .open)):not(:has(.dock-keys:is(:hover, :focus-within, .open))) .keys-panel {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}
.key-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  width: 100%;
  height: 32px;
  padding: 0 10px;
  border-radius: 999px;
  border: 1px dashed rgba(36, 24, 12, 0.4);
  background: rgba(255, 248, 240, 0.42);
  color: rgba(26, 18, 8, 0.62);
  font-size: 12px;
  font-weight: 750;
  letter-spacing: 0.02em;
  white-space: nowrap;
  filter: grayscale(1);
  opacity: 0.78;
  transition: filter 0.16s ease, opacity 0.16s ease, background 0.16s ease, border-color 0.16s ease, box-shadow 0.16s ease;
}
button.key-pill { cursor: pointer; }
.key-pill img {
  width: 14px;
  height: 14px;
  object-fit: contain;
  display: block;
  flex: 0 0 auto;
}
.key-pill em {
  margin-left: auto;
  font-style: normal;
  font-weight: 650;
  opacity: 0.7;
}
.key-pill.on {
  filter: none;
  opacity: 1;
  border-style: solid;
  border-color: rgba(36, 24, 12, 0.34);
  background: #fff8f0;
  color: var(--copper-ink);
  box-shadow: 0 0 0 1px rgba(36, 24, 12, 0.12), 0 4px 12px rgba(36, 24, 12, 0.14);
}
.key-pill.on em { opacity: 1; font-weight: 800; }
.key-pop {
  position: fixed;
  z-index: 80;
  width: min(300px, calc(100vw - 16px));
  padding: 12px;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: var(--panel, #1c1612);
  color: var(--text);
  box-shadow: 0 16px 36px rgba(0, 0, 0, 0.45);
}
.key-pop[hidden] { display: none; }
.key-pop .hint { margin: 0 0 8px; }
.key-pop-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-top: 10px;
}
.key-pop-row a { color: var(--copper-hot); font-size: 12px; }
.key-pop .status { min-height: 0; margin: 8px 0 0; }
.key-pop .status:empty { display: none; }
.dock-actions {
  grid-area: actions;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  min-width: 0;
}
.dock-icon {
  width: 34px;
  height: 34px;
  padding: 0;
  display: grid;
  place-items: center;
  border-radius: 50%;
  border: 1px solid rgba(36, 24, 12, 0.28);
  background: rgba(255, 248, 240, 0.28);
  color: var(--copper-ink);
}
.dock-icon:hover { background: rgba(255, 248, 240, 0.5); }
.dock-icon svg { display: block; }
.tape-pop {
  width: auto;
  min-width: 160px;
  display: grid;
  gap: 4px;
  padding: 8px;
}
.tape-pop[hidden] { display: none; }
.tape-pop button {
  display: flex;
  align-items: center;
  gap: 8px;
  text-align: left;
  border: 0;
  background: transparent;
  color: var(--text);
  border-radius: 10px;
  padding: 8px 10px;
}
.more-pop { min-width: 210px; }
.more-pop svg { flex: 0 0 auto; }
.tape-pop button:hover {
  background: rgba(226, 164, 92, 0.14);
  color: var(--copper-hot);
}
@media (max-width: 1080px) {
  .dock {
    grid-template-columns: minmax(0, 1fr) max-content;
    grid-template-areas: "user actions";
  }
}
@media (max-width: 560px) {
  .dock-user { max-width: 120px; }
  .lang-switch button { min-width: 32px; padding: 0 8px; }
}
.lang-switch {
  display: inline-flex;
  border-radius: 999px;
  overflow: hidden;
  border: 1px solid rgba(36, 24, 12, 0.28);
  background: rgba(255, 248, 240, 0.22);
}
.lang-switch button {
  min-width: 40px;
  height: 32px;
  padding: 0 10px;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: var(--copper-ink);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.06em;
}
.lang-switch button + button { border-left: 1px solid rgba(36, 24, 12, 0.22); }
.lang-switch button.on {
  background: var(--copper-ink);
  color: #f6e7d4;
}
.theme-switch {
  position: relative;
  z-index: 70;
  flex: 0 0 auto;
  width: 30px;
  height: 30px;
}
.theme-summary {
  position: relative;
  z-index: 3;
  width: 30px;
  height: 30px;
  padding: 3px;
  border-radius: 50%;
  border: 2px solid rgba(36, 24, 12, 0.28);
  background: rgba(255, 248, 240, 0.72);
  display: grid;
  place-items: center;
  overflow: hidden;
  cursor: pointer;
}
.theme-summary img,
.theme-panel img {
  width: 18px;
  height: 18px;
  object-fit: contain;
  display: block;
  margin: 0 auto;
}
.theme-panel {
  position: absolute;
  left: 50%;
  right: auto;
  bottom: calc(100% + 8px);
  transform: translateX(-50%) translateY(6px);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 5px;
  width: 44px;
  padding: 7px;
  border-radius: 14px;
  border: 1px solid rgba(36, 24, 12, 0.22);
  background: color-mix(in srgb, var(--copper-hot) 82%, #fff8f0);
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.28);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 0.14s ease, transform 0.14s var(--ease), visibility 0.14s;
  z-index: 4;
}
.theme-switch::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: 100%;
  height: 12px;
}
.theme-switch:is(:hover, :focus-within, .open) .theme-panel {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  transform: translateX(-50%) translateY(0);
}
.theme-panel button {
  flex: 0 0 auto;
  box-sizing: border-box;
  width: 30px;
  height: 30px;
  margin: 0;
  padding: 3px;
  border-radius: 50%;
  border: 2px solid rgba(36, 24, 12, 0.22);
  background: rgba(255, 248, 240, 0.72);
  display: grid;
  place-items: center;
  overflow: hidden;
  cursor: pointer;
  filter: grayscale(1);
  opacity: 0.78;
}
.theme-panel button.on {
  filter: none;
  opacity: 1;
  border-color: var(--copper-ink);
  box-shadow: 0 0 0 2px rgba(36, 24, 12, 0.35);
  background: #fff8f0;
}
.brand-mark {
  width: 18px;
  height: 18px;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
}
.brand-mark img { width: 18px; height: 18px; object-fit: contain; display: block; }

.layout {
  display: grid;
  grid-template-columns: 230px 1fr;
  flex: 1;
  min-height: 0;
  overflow: hidden;
  animation: fade-in 0.5s var(--ease) 0.05s both;
}

@keyframes fade-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

.side {
  border-right: 1px solid color-mix(in srgb, var(--line) 75%, transparent);
  padding: 16px 12px;
  background: linear-gradient(180deg, color-mix(in srgb, var(--panel) 70%, transparent), transparent 70%);
  min-height: 0;
  overflow: auto;
}
.side-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin: 16px 4px 6px;
}
.side-head:first-child { margin-top: 0; }
.side-head .side-label { margin: 0; flex: 1; min-width: 0; }
.side-label {
  margin: 16px 8px 6px;
  color: var(--muted);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 600;
}
.side-add {
  flex: 0 0 26px;
  width: 26px !important;
  min-width: 26px !important;
  max-width: 26px;
  height: 26px !important;
  padding: 0 !important;
  margin: 0 !important;
  border-radius: 8px !important;
  border: 1px solid var(--line) !important;
  background: rgba(12, 10, 8, 0.45) !important;
  color: var(--copper) !important;
  font-size: 18px;
  line-height: 1 !important;
  font-weight: 600;
  box-shadow: none !important;
  display: grid !important;
  place-items: center;
  text-align: center !important;
}
.side-add:hover {
  border-color: var(--copper) !important;
  background: rgba(226, 164, 92, 0.12) !important;
}
.pc-preview {
  width: 100%;
  max-height: 160px;
  object-fit: cover;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--panel-2);
}
.mp-cats { display: grid; gap: 6px; margin: 0 0 10px; }
.mp-cat-row { display: grid; grid-template-columns: 1fr auto; gap: 6px; }
.mp-cat-row .ghost { width: auto; padding: 8px 10px; }
.pack-cats { margin: 8px 0 4px 8px; }
.pack-cat-chip {
  display: flex;
  align-items: center;
  gap: 6px;
}
.pack-cat-chip .pc-ico {
  width: 18px;
  height: 18px;
  border-radius: 4px;
  object-fit: cover;
  flex: 0 0 auto;
}
.side .pack-cat-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 4px;
  align-items: center;
  margin-bottom: 2px;
}
.side .pack-cat-row .ghost {
  width: auto;
  padding: 4px 8px;
  font-size: 11px;
  color: var(--muted);
}
.side button:not(.side-add) {
  width: 100%;
  text-align: left;
  background: transparent;
  border: 0;
  border-radius: 12px;
  padding: 8px 10px;
  color: var(--text);
}
.side button:not(.side-add):hover { background: color-mix(in srgb, var(--panel-2) 80%, transparent); }
.side button:not(.side-add).on {
  background: linear-gradient(90deg, color-mix(in srgb, var(--copper) 18%, transparent), transparent);
  color: var(--copper-hot);
  box-shadow: inset 3px 0 0 var(--copper);
}
.side-name {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 4px;
  margin: 0 0 6px;
}
.side .side-name button {
  width: auto;
  padding: 6px 10px;
}

main {
  padding: 16px 18px 40px;
  min-height: 0;
  overflow: auto;
}
.bar {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 12px;
  margin-top: 4px;
  color: var(--muted);
}
.bar #count { margin: 0; justify-self: start; }
.bar-balance { justify-self: end; }
.bulk[hidden] { display: none; }
.bulk {
  display: flex;
  flex-wrap: wrap;
  align-items: end;
  gap: 12px 16px;
  margin: 10px 0 4px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(18, 14, 11, 0.72);
}
.bulk-tools,
.bulk-action {
  display: flex;
  flex: 0 0 auto;
  flex-wrap: wrap;
  align-items: end;
  gap: 8px;
  width: max-content;
  max-width: 100%;
}
.bulk p {
  margin: 0;
  align-self: center;
  color: var(--copper-hot);
  white-space: nowrap;
}
.bulk label {
  display: grid;
  gap: 4px;
  width: 190px;
  max-width: 100%;
  color: var(--muted);
  font-size: 12px;
}
.bulk select {
  width: 100%;
  min-width: 0;
}
.bulk .solid,
.bulk .ghost { white-space: nowrap; }
@media (max-width: 720px) {
  .bulk-tools,
  .bulk-action { width: 100%; }
  .bulk label { width: auto; flex: 1 1 140px; }
}
.view-dock {
  justify-self: center;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(18, 14, 11, 0.72);
  box-shadow: 0 8px 22px rgba(0, 0, 0, 0.22);
}
.view-toggle {
  display: inline-flex;
  align-items: center;
  border: 1px solid color-mix(in srgb, var(--line) 80%, transparent);
  border-radius: 999px;
  overflow: hidden;
  background: rgba(12, 10, 8, 0.45);
}
.view-toggle button {
  width: 36px;
  height: 32px;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: var(--muted);
  font-size: 15px;
  line-height: 1;
}
.view-toggle button + button { border-left: 1px solid var(--line); }
.view-toggle button.on {
  background: linear-gradient(180deg, rgba(240, 185, 111, 0.28), rgba(226, 164, 92, 0.12));
  color: var(--copper-hot);
}
.view-toggle button:hover { color: var(--text); }
.sort-pick {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0;
  padding: 0 4px 0 8px;
  color: var(--muted);
  font-size: 12px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.sort-pick span { white-space: nowrap; }

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 14px;
  margin-top: 14px;
}
.grid.size-sm { grid-template-columns: repeat(auto-fill, minmax(168px, 1fr)); gap: 10px; }
.grid.size-lg { grid-template-columns: repeat(auto-fill, minmax(340px, 1fr)); gap: 18px; }
.grid.size-sm .card { min-height: 0; }
.grid.size-sm .card h3 { font-size: 14px; }
.grid.size-sm .card .sub { -webkit-line-clamp: 2; font-size: 12px; }
.grid.size-lg .card { min-height: 360px; }
.grid.size-lg .card h3 { font-size: 1.28rem; }
.grid.size-lg .card .sub { -webkit-line-clamp: 5; font-size: 14.5px; }
.grid.size-lg .shot span { font-size: 13px; }
.grid.list {
  grid-template-columns: 1fr;
  gap: 8px;
}
.grid.list .card {
  min-height: 0;
  flex-direction: row;
  align-items: stretch;
  border-radius: 12px;
}
.grid.list .card:hover { transform: none; }
.grid.list .shot {
  width: 120px;
  flex: 0 0 120px;
  aspect-ratio: auto;
  min-height: 72px;
}
.grid.list .card-body {
  flex: 1;
  min-width: 0;
  justify-content: center;
  padding: 8px 14px;
  gap: 3px;
}
.grid.list .card h3 {
  font-size: 0.95rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.grid.list .card .sub {
  -webkit-line-clamp: 2;
  flex: 0 1 auto;
  line-height: 1.35;
}
.grid.list .shot span,
.grid.list .shot::after { display: none; }
.grid.list .card footer {
  flex: 0 0 auto;
  border: 0;
  padding: 10px 12px;
  align-self: center;
  flex-direction: column;
  gap: 4px;
}
.grid.list.size-sm .shot { width: 84px; flex-basis: 84px; min-height: 56px; }
.grid.list.size-sm .card h3 { font-size: 0.88rem; }
.grid.list.size-sm .card .sub { -webkit-line-clamp: 1; }
.grid.list.size-lg .shot { width: 210px; flex-basis: 210px; min-height: 118px; }
.grid.list.size-lg .card h3 { font-size: 1.15rem; white-space: normal; }
.grid.list.size-lg .card .sub { -webkit-line-clamp: 3; }

.card {
  background: linear-gradient(165deg, var(--panel-2), var(--panel));
  border: 1px solid var(--line);
  border-radius: 16px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  min-height: 280px;
  cursor: pointer;
  animation: card-in 0.45s var(--ease) both;
  transition: transform 0.25s var(--ease), border-color 0.2s ease, box-shadow 0.25s ease;
}
.card:hover {
  transform: translateY(-4px) scale(1.01);
  border-color: color-mix(in srgb, var(--copper) 45%, var(--line));
  box-shadow: 0 14px 30px rgba(0, 0, 0, 0.35), 0 0 0 1px rgba(226, 164, 92, 0.08);
}
#pick-mode.on {
  border-color: var(--copper);
  color: var(--copper-hot);
  background: rgba(226, 164, 92, 0.14);
}
#pick-all[hidden] { display: none !important; }
.grid.picking .card { cursor: pointer; }
.card.on {
  border-color: var(--copper);
  box-shadow: 0 0 0 1px var(--glow), 0 12px 28px rgba(0, 0, 0, 0.3);
}

@keyframes card-in {
  from { opacity: 0; transform: translateY(14px) scale(0.98); }
  to { opacity: 1; transform: none; }
}

.shot {
  aspect-ratio: 16/9;
  background: var(--panel-2) center/cover no-repeat;
  position: relative;
  overflow: hidden;
}
.shot::after {
  content: "";
  position: absolute;
  inset: auto 0 0 0;
  height: 45%;
  background: linear-gradient(transparent, rgba(18, 16, 14, 0.75));
}
.shot span {
  position: absolute;
  left: 8px;
  bottom: 8px;
  z-index: 1;
  background: rgba(0, 0, 0, 0.55);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 999px;
  padding: 2px 8px;
  font-size: 12px;
  backdrop-filter: blur(6px);
}
.card-body {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-width: 0;
  padding: 10px 12px 4px;
  gap: 4px;
}
.card h3 {
  margin: 0;
  font-size: 16px;
  font-family: var(--font-brand);
  font-weight: 600;
}
.meta, .sub { margin: 0; color: var(--muted); font-size: 13px; }
.card .sub {
  flex: 1;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.card footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 12px;
}
.check { display: flex; gap: 6px; align-items: center; color: var(--muted); font-size: 13px; }

.empty {
  grid-column: 1 / -1;
  color: var(--muted);
  padding: 48px 8px;
  text-align: center;
  animation: fade-in 0.4s ease;
}

#detail-dialog {
  width: min(680px, calc(100vw - 24px));
  max-height: calc(100vh - 24px);
  overflow: auto;
}

dialog {
  width: min(520px, calc(100vw - 24px));
  background: linear-gradient(180deg, var(--panel-2), var(--panel));
  color: var(--text);
  border: 1px solid color-mix(in srgb, var(--copper) 25%, var(--line));
  border-radius: 18px;
  padding: 0;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.55), 0 0 40px rgba(226, 164, 92, 0.08);
}
dialog[open] { animation: dialog-in 0.32s var(--ease); }
dialog::backdrop {
  background: rgba(8, 6, 5, 0.62);
  backdrop-filter: blur(4px);
  animation: fade-in 0.25s ease;
}

@keyframes dialog-in {
  from { opacity: 0; transform: translateY(12px) scale(0.96); }
  to { opacity: 1; transform: none; }
}

dialog form, #detail { padding: 12px; display: grid; gap: 8px; }
dialog header, dialog footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
dialog h2 {
  margin: 0;
  font-size: 17px;
  font-family: var(--font-brand);
}
label { display: grid; gap: 3px; color: var(--muted); font-size: 12px; }
label[hidden] { display: none !important; }
input, textarea, select {
  background: rgba(12, 10, 8, 0.55);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 8px 12px;
  color: var(--text);
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
  box-shadow: none;
}
input:focus, textarea:focus, select:focus {
  outline: none;
  border-color: var(--copper);
  box-shadow: 0 0 0 3px var(--glow);
}
select {
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  cursor: pointer;
  padding-right: 36px;
  background-color: rgba(12, 10, 8, 0.55);
  background-image:
    linear-gradient(45deg, transparent 50%, var(--copper) 50%),
    linear-gradient(135deg, var(--copper) 50%, transparent 50%);
  background-position:
    calc(100% - 16px) calc(50% - 2px),
    calc(100% - 10px) calc(50% - 2px);
  background-size: 6px 6px, 6px 6px;
  background-repeat: no-repeat;
  color-scheme: dark;
}
select:hover {
  border-color: color-mix(in srgb, var(--copper) 40%, var(--line));
}
select option,
select optgroup {
  background: var(--panel);
  color: var(--text);
}
.bar select {
  border-radius: 999px;
  padding: 7px 34px 7px 12px;
  background-color: rgba(33, 27, 22, 0.9);
  min-width: 168px;
}
.pick-add {
  display: flex;
  gap: 6px;
  align-items: center;
}
.pick-add select { flex: 1; min-width: 0; }
.pick-add .side-add { flex: 0 0 28px; }
.status { min-height: 1.2em; margin: 0; color: var(--ok); transition: color 0.2s ease; }
.status.bad { color: var(--danger); }
.hint { color: var(--muted); margin: 0; font-size: 12px; }
.lang-pick {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px 12px;
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
}
.lang-pick legend {
  padding: 0 6px;
  color: var(--muted);
  font-size: 12px;
}
.lang-pick label {
  display: flex;
  gap: 6px;
  align-items: center;
}
.preview {
  display: grid;
  grid-template-columns: 120px 1fr;
  gap: 8px;
  background: rgba(12, 10, 8, 0.45);
  border-radius: 12px;
  overflow: hidden;
  border: 1px solid var(--line);
  animation: card-in 0.35s var(--ease);
}
.preview img { width: 100%; height: 100%; object-fit: cover; min-height: 72px; background: var(--panel-2); }
.preview h3 { margin: 8px 8px 4px; font-family: var(--font-brand); }
.preview p { margin: 0 8px 8px; color: var(--muted); font-size: 13px; }

#detail { width: auto; }
.row {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}
.detail-head {
  display: grid;
  grid-template-columns: minmax(200px, 42%) 1fr;
  gap: 12px;
  align-items: start;
}
.detail-head.solo { grid-template-columns: 1fr; }
.detail-side { display: grid; gap: 4px; align-content: start; min-width: 0; }
.hero {
  width: 100%;
  height: auto;
  object-fit: contain;
  border-radius: 12px;
  background: var(--panel-2);
}
#detail textarea { resize: vertical; min-height: 72px; }
#detail .summary {
  -webkit-line-clamp: 8;
}
.summary {
  margin: 0;
  color: var(--text);
  font-size: 13px;
  line-height: 1.35;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.meta { margin: 0; color: var(--muted); font-size: 12px; }
.stat-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 14px;
}
.stat {
  display: grid;
  grid-template-columns: 18px auto;
  grid-template-rows: auto auto;
  column-gap: 6px;
  align-items: center;
}
.stat svg {
  grid-row: 1 / span 2;
  width: 18px;
  height: 18px;
  color: var(--copper);
}
.stat span { color: var(--muted); font-size: 11px; line-height: 1.1; }
.stat strong { font-size: 13px; font-weight: 700; line-height: 1.15; }
.files { display: grid; gap: 4px; max-height: 72px; overflow: auto; }
.file { display: flex; justify-content: space-between; gap: 8px; align-items: center; font-size: 12px; }
.danger { color: var(--danger); background: transparent; border: 0; }
.refresh-btn {
  display: grid;
  gap: 2px;
  text-align: left;
  line-height: 1.2;
  padding: 12px 22px;
  font-size: 16px;
  min-height: 52px;
}
.refresh-btn small { color: var(--muted); font-size: 13px; font-weight: 400; }
.dep-row a { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.toast {
  position: fixed;
  bottom: 70px;
  right: 18px;
  background: linear-gradient(135deg, #32281f, #241e18);
  border: 1px solid var(--copper);
  padding: 12px 16px;
  border-radius: 14px;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.4);
  max-width: min(360px, calc(100vw - 32px));
  z-index: 20;
  animation: toast-in 0.35s var(--ease);
}
.toast.out { animation: toast-out 0.25s ease forwards; }
.toast.ok { border-color: var(--ok); }
.toast.bad { border-color: var(--danger); }

@keyframes toast-in {
  from { opacity: 0; transform: translateY(12px) scale(0.96); }
  to { opacity: 1; transform: none; }
}
@keyframes toast-out {
  to { opacity: 0; transform: translateY(8px); }
}

.login {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  padding-bottom: 64px;
  background: rgba(12, 10, 8, 0.92);
}
.login[hidden] { display: none; }
.login:not([hidden]) ~ .dock { display: none; }
.login-card {
  width: min(380px, calc(100vw - 32px));
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 22px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: linear-gradient(180deg, var(--panel-2), var(--panel));
}
.login-keep {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--muted);
}
.login-keep input { width: auto; }
.login-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.login-card .text-btn {
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--copper-hot);
  font-size: 13px;
  text-decoration: underline;
}
.login-card .solid:disabled {
  opacity: 0.45;
  cursor: default;
}
.boot {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: grid;
  place-items: center;
  background: #100e0c;
  transition: opacity 0.45s ease, visibility 0.45s ease;
}
.boot.hide { opacity: 0; visibility: hidden; pointer-events: none; }
.boot-mark {
  font-family: var(--font-brand);
  font-size: 2rem;
  letter-spacing: 0.04em;
  background: linear-gradient(120deg, var(--copper-hot), var(--ember));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  animation: pulse 1.2s ease-in-out infinite;
}
.boot-mark small {
  display: block;
  margin-top: 8px;
  font-family: var(--font-ui);
  font-size: 0.75rem;
  color: var(--muted);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  background: none;
  -webkit-background-clip: initial;
  color: var(--muted);
}

@keyframes pulse {
  0%, 100% { transform: scale(1); filter: brightness(1); }
  50% { transform: scale(1.03); filter: brightness(1.12); }
}

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

@media (max-width: 800px) {
  .layout { grid-template-columns: 1fr; }
  .side { border-right: 0; border-bottom: 1px solid var(--line); }
  .top { flex-wrap: wrap; }
  .preview { grid-template-columns: 1fr; }
}
