:root {
  --bg: #14161a;
  --card: #1c1f26;
  --card-2: #242833;
  --line: rgba(255, 255, 255, 0.08);
  --text: #ebecf0;
  --muted: #9aa0ab;
  --accent: #5b8cff;
  --accent-deep: #3d6fe0;
  --green: #3ddc97;
  --danger: #ff6b81;
  --shadow: 0 12px 32px rgba(0, 0, 0, 0.28);
  color-scheme: dark;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: "Segoe UI", system-ui, sans-serif;
}

button, input, textarea, select { font: inherit; color: inherit; }

.top {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 64px;
  padding: 10px 16px;
  background: #14161a;
  border-bottom: 1px solid var(--line);
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  border: 0;
  background: transparent;
  cursor: pointer;
  padding: 0;
  text-align: left;
}

.brand strong { display: block; font-size: 17px; letter-spacing: -0.02em; }
.brand small { display: block; color: var(--muted); font-size: 12px; }

.gem {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  background: linear-gradient(145deg, #8eb6ff, #5b8cff 45%, #2f5ac4);
  box-shadow: 0 8px 18px rgba(91, 140, 255, 0.35);
}

.top-status {
  color: var(--muted);
  font-size: 12px;
  text-align: right;
  max-width: 42%;
}

.shell {
  display: grid;
  grid-template-columns: 180px 1fr;
  gap: 0;
  min-height: calc(100vh - 64px);
}

#nav {
  padding: 14px 10px;
  border-right: 1px solid var(--line);
  background: #171a20;
}

.nav-btn {
  display: block;
  width: 100%;
  text-align: left;
  border: 0;
  background: transparent;
  color: var(--muted);
  padding: 10px 12px;
  border-radius: 10px;
  cursor: pointer;
  margin-bottom: 4px;
}

.nav-btn.on, .nav-btn:hover {
  background: var(--card-2);
  color: var(--text);
}

#main {
  padding: 18px 18px 40px;
  max-width: 820px;
}

h1 { margin: 0 0 8px; font-size: 24px; letter-spacing: -0.03em; }
h2 { margin: 22px 0 10px; font-size: 16px; }
.muted, .note { color: var(--muted); font-size: 13px; line-height: 1.45; }
.warn { color: #ffb86b; font-size: 13px; }

.panel {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 14px;
  margin-top: 12px;
}

.row {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
}
.row:last-child { border-bottom: 0; }
.row span span { display: block; color: var(--muted); font-size: 12px; margin-top: 2px; }

.stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 10px;
  margin-top: 12px;
}

.stat {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px;
}
.stat b { display: block; font-size: 18px; margin-top: 4px; }
.stat small { color: var(--muted); font-size: 12px; }

label.field {
  display: block;
  margin: 10px 0;
}
label.field > span {
  display: block;
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 12px;
}

input, textarea, select {
  width: 100%;
  border: 1px solid var(--line);
  background: var(--card-2);
  border-radius: 10px;
  padding: 10px 12px;
  outline: none;
}
textarea { min-height: 90px; resize: vertical; }
input:focus, textarea:focus, select:focus {
  box-shadow: 0 0 0 2px rgba(91, 140, 255, 0.55);
}

.btn {
  border: 0;
  border-radius: 10px;
  padding: 10px 14px;
  background: var(--accent);
  color: #fff;
  cursor: pointer;
  font-weight: 600;
}
.btn:hover { background: var(--accent-deep); }
.btn.secondary { background: var(--card-2); color: var(--text); }
.btn.danger { background: var(--danger); }
.btn:disabled { opacity: 0.5; cursor: default; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }

.switch {
  position: relative;
  width: 44px;
  height: 26px;
  flex: 0 0 auto;
}
.switch input {
  opacity: 0;
  width: 0;
  height: 0;
  position: absolute;
}
.switch i {
  position: absolute;
  inset: 0;
  background: #343844;
  border-radius: 999px;
  transition: 0.15s;
}
.switch i::after {
  content: "";
  position: absolute;
  width: 20px;
  height: 20px;
  left: 3px;
  top: 3px;
  background: #fff;
  border-radius: 50%;
  transition: 0.15s;
}
.switch input:checked + i { background: var(--green); }
.switch input:checked + i::after { transform: translateX(18px); }

.binding, .shop-card {
  background: var(--card-2);
  border-radius: 12px;
  padding: 12px;
  margin-top: 10px;
  border: 1px solid var(--line);
}
.binding .meta, .shop-card .meta {
  color: var(--muted);
  font-size: 12px;
  margin-top: 4px;
}
.empty {
  padding: 16px;
  color: var(--muted);
  border: 1px dashed var(--line);
  border-radius: 12px;
  margin-top: 10px;
}

.inline-row {
  display: flex;
  gap: 8px;
  align-items: center;
}
.inline-row input { flex: 1; }

.catalog-list {
  display: grid;
  gap: 6px;
  max-height: 320px;
  overflow: auto;
  margin-top: 8px;
}
.catalog-item {
  display: block;
  width: 100%;
  text-align: left;
  border: 1px solid var(--line);
  background: var(--card-2);
  border-radius: 10px;
  padding: 10px 12px;
  cursor: pointer;
}
.catalog-item span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  margin-top: 2px;
}
.catalog-item:hover { border-color: rgba(91, 140, 255, 0.55); }

code {
  font-family: ui-monospace, Consolas, monospace;
  font-size: 0.95em;
}

#toast {
  position: fixed;
  left: 50%;
  bottom: 18px;
  transform: translateX(-50%) translateY(20px);
  background: #222632;
  border: 1px solid var(--line);
  padding: 10px 14px;
  border-radius: 12px;
  opacity: 0;
  pointer-events: none;
  transition: 0.2s;
  box-shadow: var(--shadow);
  z-index: 50;
  max-width: min(90vw, 420px);
}
#toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

@media (max-width: 720px) {
  .shell { grid-template-columns: 1fr; }
  #nav {
    display: flex;
    gap: 4px;
    overflow-x: auto;
    border-right: 0;
    border-bottom: 1px solid var(--line);
    padding: 10px;
  }
  .nav-btn {
    white-space: nowrap;
    margin: 0;
    width: auto;
  }
  #main { padding: 14px 12px 36px; }
}
