:root {
  --bg: #101012;
  --bg-2: #141417;
  --bg-3: #19191d;
  --bg-4: #1e1e23;
  --bg-5: #24242a;
  --line: #2a2a31;
  --line-2: #35353e;
  --text: #ececef;
  --muted: #8b8b96;
  --faint: #5c5c66;
  --cyan: #3ec6ff;
  --cyan-2: #1aa3e0;
  --cyan-dim: rgba(62, 198, 255, 0.12);
  --ok: #4ade80;
  --warn: #f5b942;
  --nsfw: #f07178;
  --shadow: 0 8px 28px rgba(0, 0, 0, 0.35);
  --font: Inter, "Segoe UI", system-ui, sans-serif;
  --mono: "IBM Plex Mono", "JetBrains Mono", ui-monospace, monospace;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 13px;
  overflow: hidden;
}
button, input, textarea { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: none; }
.app { height: 100%; display: grid; grid-template-rows: 76px 1fr; }

.topbar {
  position: sticky; top: 0; z-index: 40;
  display: grid;
  grid-template-columns: minmax(140px, 1fr) auto minmax(140px, 1fr);
  align-items: center;
  padding: 0 16px;
  border-bottom: 1px solid var(--line);
  background: linear-gradient(180deg, #16161c 0%, #121218 100%);
  box-shadow: 0 10px 28px rgba(0,0,0,.28);
}
.topbar-left, .topbar-right { display: flex; align-items: center; gap: 10px; min-width: 0; }
.topbar-right { justify-content: flex-end; }
.topbar-center { display: flex; align-items: center; gap: 12px; justify-content: center; }
.brand { display: flex; align-items: center; gap: 8px; font-weight: 600; cursor: pointer; }
.brand-mark { width: 22px; height: 22px; flex: none; }
.brand-name { letter-spacing: .02em; }
.ws-switch {
  display: flex; align-items: center; gap: 6px;
  padding: 6px 10px; border-radius: 10px;
  background: var(--bg-4); color: var(--muted); border: 1px solid var(--line);
  max-width: 150px; overflow: hidden;
}
.ws-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--warn); flex: none; }

.mascot {
  width: 56px; height: 56px; padding: 0; flex: none;
  border-radius: 50%; overflow: hidden;
  border: 2px solid #3ec6ff;
  box-shadow: 0 0 0 3px rgba(62,198,255,.16), 0 0 18px rgba(62,198,255,.18);
  background: #0b0b0e;
}
.mascot img {
  width: 100%; height: 100%; object-fit: cover; object-position: 50% 18%;
  transform: scale(1.35);
}
.mascot .mascot-fallback {
  width: 70%; height: 70%; margin: 15%; display: block;
}
.mascot:hover { box-shadow: 0 0 0 3px rgba(62,198,255,.28), 0 0 22px rgba(62,198,255,.28); }

.head-search { position: relative; width: min(520px, 42vw); }
.head-search-icon {
  position: absolute; left: 12px; top: 50%; transform: translateY(-50%);
  color: var(--faint); pointer-events: none;
}
.head-search input {
  width: 100%; height: 38px; padding: 0 12px 0 36px; border-radius: 10px;
  background: #0c0c10; border: 1px solid #2a2a34; outline: none;
}
.head-search input::placeholder { color: #6a6a74; }
.head-search input:focus { border-color: var(--cyan-2); box-shadow: 0 0 0 3px var(--cyan-dim); }

.lang-switch {
  position: relative; display: flex; align-items: stretch;
  border: 1px solid #3a3428; border-radius: 10px; background: #1a1814;
}
.lang-current {
  height: 34px; padding: 0 10px; color: #e6c36a;
  font-weight: 650; letter-spacing: .04em; font-size: 12px;
}
.lang-toggle {
  width: 28px; color: #c4a45a; border-left: 1px solid #3a3428;
  display: grid; place-items: center;
}
.lang-toggle:hover, .lang-current:hover { background: #241f18; }
.lang-menu {
  position: absolute; top: calc(100% + 6px); right: 0; min-width: 140px;
  background: #1c1c22; border: 1px solid var(--line-2); border-radius: 10px;
  padding: 4px; box-shadow: var(--shadow); z-index: 50;
}
.lang-menu button { width: 100%; text-align: left; padding: 7px 10px; border-radius: 7px; color: var(--muted); }
.lang-menu button:hover { background: var(--bg-5); color: var(--text); }
.lang-menu button[aria-current="true"] { color: #e6c36a; }
.side-search-hint { margin: 0 12px 8px; color: var(--faint); font-size: 11px; }
.icon-btn {
  width: 34px; height: 34px; border-radius: 9px; color: var(--muted);
  border: 1px solid transparent;
}
.icon-btn:hover, .icon-btn.active { background: var(--bg-4); color: var(--text); border-color: var(--line); }
.share-btn {
  height: 32px; padding: 0 12px; border-radius: 9px;
  border: 1px solid var(--line-2); background: var(--bg-4);
}

.body { display: grid; grid-template-columns: 292px 1fr; min-height: 0; }

.app.locked .body { display: none; }
.app.locked .topbar-center .lang-switch,
.app.locked #btnHeart,
.app.locked #btnLayout,
.app.locked #btnFilter { display: none; }
.app.locked .ws-switch { display: none; }
/* head-search stays visible when locked */
.sidebar {
  background: var(--bg-2); border-right: 1px solid var(--line);
  display: flex; flex-direction: column; min-height: 0;
}
.side-tabs { display: flex; gap: 4px; padding: 10px 10px 8px; }
.side-tab {
  flex: 1; height: 30px; border-radius: 999px; color: var(--muted);
  font-size: 12px; font-weight: 500;
}
.side-tab:hover { color: var(--text); background: var(--bg-4); }
.side-tab.active {
  background: var(--bg-5); color: var(--text);
  box-shadow: inset 0 0 0 1px var(--line-2);
}
.tool-head {
  margin: 0 10px 10px; padding: 10px;
  border-radius: 12px; background: #1a1b22; border: 1px solid var(--line);
  display: flex; align-items: center; justify-content: space-between;
}
.tool-title { font-weight: 600; }
.tool-sub { color: var(--muted); font-size: 11px; margin-top: 2px; }
.save-chip {
  height: 28px; padding: 0 10px; border-radius: 8px;
  background: var(--bg-5); border: 1px solid var(--line-2); color: var(--muted); font-size: 12px;
}
.save-chip.dirty { color: var(--cyan); border-color: var(--cyan-2); background: var(--cyan-dim); }
.side-search { margin: 0 10px 8px; }
.side-search input {
  width: 100%; height: 34px; padding: 0 10px; border-radius: 9px;
  background: var(--bg-4); border: 1px solid var(--line); outline: none;
}
.side-search input:focus { border-color: var(--cyan-2); box-shadow: 0 0 0 3px var(--cyan-dim); }

.entity-list { flex: 1; overflow: auto; padding: 4px 8px 12px; }
.entity-list::-webkit-scrollbar, .grid-wrap::-webkit-scrollbar, .inspector::-webkit-scrollbar { width: 8px; }
.entity-list::-webkit-scrollbar-thumb, .grid-wrap::-webkit-scrollbar-thumb { background: #2e2e36; border-radius: 8px; }

.entity-row {
  width: 100%; display: grid; grid-template-columns: 36px 1fr auto;
  gap: 8px; align-items: center; padding: 7px 8px; border-radius: 10px; text-align: left;
}
.entity-row:hover { background: var(--bg-4); }
.entity-row.active { background: var(--cyan-dim); box-shadow: inset 0 0 0 1px rgba(62,198,255,.25); }
.thumb {
  width: 36px; height: 36px; border-radius: 8px; background: #0d0d10;
  border: 1px solid var(--line); display: grid; place-items: center; color: var(--cyan);
}
.thumb svg { width: 22px; height: 22px; }
.entity-name { font-weight: 550; }
.entity-meta { color: var(--muted); font-size: 11px; margin-top: 2px; }
.badge {
  font-size: 10px; padding: 2px 6px; border-radius: 999px;
  background: var(--bg-5); color: var(--muted); border: 1px solid var(--line);
}
.badge.nsfw { color: var(--nsfw); border-color: rgba(240,113,120,.35); background: rgba(240,113,120,.08); }
.badge.ok { color: var(--ok); border-color: rgba(74,222,128,.3); }
.badge.cyan { color: var(--cyan); border-color: rgba(62,198,255,.3); background: var(--cyan-dim); }

.inspector {
  border-top: 1px solid var(--line); background: var(--bg-3);
  max-height: 46%; overflow: auto; padding: 12px;
}
.insp-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.insp-kicker { color: var(--muted); font-size: 10px; text-transform: uppercase; letter-spacing: .08em; }
.field { margin-bottom: 8px; }
.field label {
  display: block; color: var(--faint); font-size: 10.5px;
  text-transform: uppercase; letter-spacing: .06em; margin-bottom: 4px;
}
.field input, .field textarea {
  width: 100%; background: var(--bg-4); border: 1px solid var(--line);
  border-radius: 8px; padding: 7px 8px; outline: none;
}
.field textarea { min-height: 54px; resize: vertical; }
.field input:focus, .field textarea:focus { border-color: var(--cyan-2); }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.toggle-row { display: flex; align-items: center; justify-content: space-between; padding: 6px 0; color: var(--muted); }
.switch {
  width: 32px; height: 18px; border-radius: 999px; background: #33333b;
  position: relative; border: 1px solid var(--line-2);
}
.switch.on { background: var(--cyan-2); border-color: var(--cyan); }
.switch i { position: absolute; top: 2px; left: 2px; width: 12px; height: 12px; border-radius: 50%; background: #fff; }
.switch.on i { left: 16px; }

.gen-btn {
  height: 38px; border-radius: 11px; background: linear-gradient(90deg, #5b63f6, #6d5cf0);
  color: #fff; font-weight: 600; margin: 8px 10px 12px;
}
.gen-btn:hover { filter: brightness(1.06); }

.main { display: flex; flex-direction: column; min-width: 0; min-height: 0; background: var(--bg); }
.main-nav { display: flex; align-items: center; justify-content: space-between; padding: 10px 16px 6px; }
.crumbs { display: flex; align-items: center; gap: 6px; color: var(--muted); }
.crumbs b { color: var(--text); font-weight: 550; }
.crumbs button { color: var(--muted); }
.crumbs button:hover { color: var(--text); }
.seg { display: flex; gap: 2px; background: var(--bg-3); border: 1px solid var(--line); border-radius: 10px; padding: 3px; }
.seg button { height: 28px; padding: 0 10px; border-radius: 8px; color: var(--muted); font-size: 12px; }
.seg button.active { background: var(--bg-5); color: var(--text); }
.seg button:disabled { opacity: .35; cursor: default; }

.prompt-strip {
  margin: 4px 16px 10px; color: var(--muted); font-size: 12.5px;
  display: flex; justify-content: space-between; gap: 12px; align-items: center;
}
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip {
  font-size: 11px; padding: 3px 8px; border-radius: 6px;
  background: var(--bg-4); border: 1px solid var(--line); color: var(--muted);
}

.stats-bar { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin: 0 16px 12px; }
.stat { background: var(--bg-3); border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; }
.stat .n { font-size: 18px; font-weight: 650; }
.stat .l { color: var(--muted); font-size: 11px; margin-top: 2px; }

.grid-wrap { flex: 1; overflow: auto; padding: 0 16px 24px; }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px; }
.cards.dense { grid-template-columns: repeat(auto-fill, minmax(168px, 1fr)); }
.card {
  background: var(--bg-3); border: 1px solid var(--line); border-radius: 14px;
  overflow: hidden; text-align: left; box-shadow: var(--shadow);
}
.card:hover { border-color: var(--line-2); }
.card.selected { border-color: rgba(62,198,255,.45); }
.card-art {
  aspect-ratio: 1/1;
  background-image:
    linear-gradient(rgba(62,198,255,.06) 1px, transparent 1px),
    linear-gradient(90deg, rgba(62,198,255,.06) 1px, transparent 1px),
    radial-gradient(ellipse at 50% 20%, rgba(62,198,255,.08), transparent 55%),
    linear-gradient(180deg, #15151a, #0c0c10);
  background-size: 18px 18px, 18px 18px, auto, auto;
  display: grid; place-items: center;
}
.mono-icon { width: 72%; height: 72%; }
.card-foot { padding: 9px 10px 11px; }
.card-title { font-weight: 560; }
.card-sub { color: var(--muted); font-size: 11px; margin-top: 3px; }
.card-tags { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 7px; }
.fillbar { height: 3px; background: #2a2a32; border-radius: 99px; margin-top: 8px; overflow: hidden; }
.fillbar > i { display: block; height: 100%; background: linear-gradient(90deg, var(--cyan-2), var(--cyan)); }

.detail {
  display: grid; grid-template-columns: minmax(280px, 42%) 1fr;
  gap: 16px; min-height: 0;
}
.detail-art {
  border-radius: 16px; border: 1px solid var(--line); min-height: 420px;
  display: grid; place-items: center;
  background-image:
    linear-gradient(rgba(62,198,255,.05) 1px, transparent 1px),
    linear-gradient(90deg, rgba(62,198,255,.05) 1px, transparent 1px),
    #0d0d11;
  background-size: 22px 22px, 22px 22px, auto;
}
.detail-panel { background: var(--bg-3); border: 1px solid var(--line); border-radius: 16px; padding: 16px; }
.ids {
  font-family: var(--mono); font-size: 12px; line-height: 1.7;
  background: #111116; border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; color: #c9e9ff;
}
.ids .k { color: var(--muted); }
.ids .v { color: var(--cyan); }
.kv { display: grid; grid-template-columns: 88px 1fr; gap: 4px 10px; margin-top: 14px; }
.kv .k { color: var(--muted); }
.tag-groups { margin-top: 16px; display: flex; flex-direction: column; gap: 10px; }
.tag-group .lab { color: var(--faint); font-size: 11px; margin-bottom: 6px; text-transform: uppercase; letter-spacing: .06em; }
.tag-pills { display: flex; flex-wrap: wrap; gap: 6px; }
.pill {
  padding: 4px 8px; border-radius: 999px; background: var(--bg-5);
  border: 1px solid var(--line-2); color: #cfcfd6; font-size: 12px;
}
.os-list { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 14px; }
.os {
  font-family: var(--mono); font-size: 11px; padding: 4px 8px; border-radius: 6px;
  background: var(--cyan-dim); color: var(--cyan); border: 1px solid rgba(62,198,255,.25);
}
.empty { color: var(--muted); padding: 48px 16px; text-align: center; }

@media (max-width: 1100px) {
  .brand-name, .ws-switch { display: none; }
  .head-search { width: min(380px, 36vw); }
}
@media (max-width: 980px) {
  .body { grid-template-columns: 1fr; }
  .sidebar { display: none; }
  .detail { grid-template-columns: 1fr; }
  .topbar { grid-template-columns: auto 1fr auto; }
  .head-search { width: min(280px, 40vw); }
}
