:root {
  --bg: #0d0f13;
  --panel: #151820;
  --panel-2: #1c2029;
  --line: #2a2f3b;
  --text: #e9e4d8;
  --muted: #9a958a;
  --gold: #d9b45a;
  --gold-2: #f0d48a;
  --accent-bg: rgba(217, 180, 90, .12);
  --radius: 10px;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 14px/1.4 Inter, system-ui, sans-serif;
}
button { font: inherit; color: inherit; cursor: pointer; }

.app {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 380px;
  height: 100vh;
  height: 100dvh;
}

/* ---- stage */
.stage {
  position: relative;
  overflow: hidden;
  background:
    radial-gradient(ellipse 60% 55% at 50% 45%, #2a2f3c 0%, #171a22 55%, #0d0f13 100%);
}
#view { position: absolute; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; }
.stage-top {
  position: absolute; top: 16px; left: 20px; right: 20px;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  pointer-events: none;
}
.stage-top > * { pointer-events: auto; }
h1 {
  margin: 0;
  font: 700 26px/1 Cinzel, serif;
  letter-spacing: .04em;
  color: var(--gold-2);
  text-shadow: 0 2px 12px rgba(0, 0, 0, .6);
}
.seg { display: flex; background: rgba(13, 15, 19, .7); border: 1px solid var(--line); border-radius: 999px; padding: 3px; }
.seg button { background: none; border: 0; padding: 6px 14px; border-radius: 999px; color: var(--muted); }
.seg button[aria-pressed="true"] { background: var(--gold); color: #1a1408; font-weight: 600; }

.stage-tools {
  position: absolute; left: 50%; bottom: 18px; transform: translateX(-50%);
  display: flex; gap: 6px; align-items: center;
  background: rgba(13, 15, 19, .72); border: 1px solid var(--line); border-radius: 999px; padding: 5px;
  backdrop-filter: blur(6px);
}
.stage-tools button { background: none; border: 0; padding: 7px 13px; border-radius: 999px; white-space: nowrap; }
.stage-tools button:hover { background: var(--panel-2); }
.stage-tools button[aria-pressed="true"] { background: var(--accent-bg); color: var(--gold-2); }
.stage-tools .sep { width: 1px; height: 20px; background: var(--line); }

.loading {
  position: absolute; top: 64px; left: 50%; transform: translateX(-50%);
  background: rgba(13, 15, 19, .8); border: 1px solid var(--line); border-radius: 999px; padding: 5px 14px; color: var(--muted);
}
.toast {
  position: absolute; left: 50%; bottom: 72px; transform: translateX(-50%) translateY(8px);
  background: var(--panel-2); border: 1px solid var(--line); border-radius: 8px; padding: 8px 14px;
  opacity: 0; transition: opacity .2s, transform .2s; pointer-events: none;
}
.toast.show { opacity: 1; transform: translateX(-50%); }

/* ---- panel */
.panel {
  display: flex; flex-direction: column; min-height: 0; min-width: 0;
  background: var(--panel); border-left: 1px solid var(--line);
}
.slots {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px;
  padding: 14px; border-bottom: 1px solid var(--line);
}
.slot {
  display: grid; grid-template-columns: auto 1fr; grid-template-rows: auto auto; column-gap: 7px; align-items: center; min-width: 0;
  background: var(--panel-2); border: 1px solid var(--line); border-radius: 8px; padding: 7px 9px; text-align: left;
  position: relative;
}
.slot:hover { border-color: #3a4150; }
.slot.active { border-color: var(--gold); background: var(--accent-bg); }
.slot .ic { grid-row: 1 / 3; }
.slot .k, .slot .v { grid-column: 2; }
.slot .k { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.slot .v { font-size: 12.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.slot .v.empty { color: #5d5a54; }
.slot .x {
  position: absolute; top: 4px; right: 5px; width: 18px; height: 18px; line-height: 16px; text-align: center;
  border-radius: 50%; color: var(--muted); font-size: 14px;
}
.slot .x:hover { background: #3a2a2a; color: #f0a0a0; }

.browser { flex: 1; display: flex; flex-direction: column; min-height: 0; }
.search { display: flex; gap: 6px; padding: 12px 14px 8px; align-items: center; }
.search input {
  flex: 1; min-width: 0; background: var(--bg); border: 1px solid var(--line); border-radius: 8px;
  color: var(--text); padding: 9px 11px; font: inherit;
}
.search input:focus { outline: none; border-color: var(--gold); }
.chip {
  background: var(--accent-bg); border: 1px solid var(--gold); color: var(--gold-2);
  border-radius: 999px; padding: 6px 10px; font-size: 12px; white-space: nowrap;
}
.list { list-style: none; margin: 0; padding: 0 8px 8px; overflow-y: auto; flex: 1; }
.count { padding: 0 16px 6px; color: var(--muted); font-size: 12px; }
.list li.pad { padding: 0; pointer-events: none; }
.list li.item {
  display: flex; align-items: center; gap: 10px; height: 44px;
  padding: 0 10px 0 6px; border-radius: 7px; cursor: pointer;
}
.list li.item .n { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ic {
  flex: none; display: inline-block; border-radius: 6px;
  background-color: rgba(255, 255, 255, .03); background-repeat: no-repeat;
}
.list li:hover, .list li.hover { background: var(--panel-2); }
.list li.on { background: var(--accent-bg); color: var(--gold-2); }
.list li.na { opacity: .45; }
.list .s { color: var(--muted); font-size: 12px; white-space: nowrap; }
.list .empty-msg { color: var(--muted); cursor: default; }

.foot {
  display: flex; flex-direction: column; gap: 6px;
  padding: 10px 14px 14px; border-top: 1px solid var(--line); color: #6f6b62; font-size: 11.5px;
}
.link { background: none; border: 0; padding: 0; color: var(--muted); text-decoration: underline; text-align: left; font-size: 12.5px; }
.link:hover { color: var(--text); }

/* ---- phones */
@media (max-width: 820px) {
  .app { grid-template-columns: minmax(0, 1fr); grid-template-rows: 52vh 1fr; }
  .panel { border-left: 0; border-top: 1px solid var(--line); }
  h1 { font-size: 20px; }
  .stage-top { top: 12px; left: 16px; right: 16px; }
  .stage-tools { bottom: 10px; max-width: calc(100% - 24px); overflow-x: auto; }
  .stage-tools button { padding: 6px 10px; }
  .app { grid-template-rows: 48vh 1fr; }
  .slots { display: flex; overflow-x: auto; padding: 10px 16px; scrollbar-width: thin; }
  .slot { flex: none; width: 150px; }
  .search { padding: 10px 16px 6px; }
}
