:root {
  --bg: #0d1023;
  --panel: rgba(255, 255, 255, 0.12);
  --panel-strong: rgba(255, 255, 255, 0.18);
  --line: rgba(255, 255, 255, 0.16);
  --text: #f7f8ff;
  --muted: #aeb7d9;
  --soft: #dfe6ff;
  --accent: #8d7bff;
  --accent-2: #56d7ff;
  --danger: #ff6b86;
  --success: #5df7b2;
  --shadow: 0 24px 80px rgba(0, 0, 0, 0.36);
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background:
    radial-gradient(circle at 18% 12%, rgba(141, 123, 255, 0.36), transparent 34%),
    radial-gradient(circle at 78% 8%, rgba(86, 215, 255, 0.24), transparent 26%),
    linear-gradient(145deg, #090b18 0%, #101631 50%, #17112b 100%);
  overflow-x: hidden;
}

button, input, textarea { font: inherit; }
button { cursor: pointer; }
.hidden { display: none !important; }

.glass {
  background: var(--panel);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  backdrop-filter: blur(22px);
  -webkit-backdrop-filter: blur(22px);
}

.login-view {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 28px;
  position: relative;
}

.aurora {
  position: fixed;
  width: 380px;
  height: 380px;
  border-radius: 999px;
  filter: blur(48px);
  opacity: 0.46;
  pointer-events: none;
}
.aurora-a { left: -80px; top: 18%; background: #8d7bff; }
.aurora-b { right: -80px; bottom: 12%; background: #56d7ff; }

.login-card {
  width: min(460px, 100%);
  padding: 36px;
  border-radius: 32px;
  position: relative;
}

.brand-mark {
  width: 58px;
  height: 58px;
  display: grid;
  place-items: center;
  border-radius: 20px;
  background: linear-gradient(145deg, var(--accent), var(--accent-2));
  color: white;
  font-weight: 900;
  letter-spacing: -0.06em;
  box-shadow: 0 16px 38px rgba(86, 215, 255, 0.24);
}
.brand-mark.small { width: 42px; height: 42px; border-radius: 14px; font-size: 14px; }

.eyebrow {
  color: var(--accent-2);
  text-transform: uppercase;
  letter-spacing: 0.16em;
  font-size: 12px;
  font-weight: 800;
  margin: 22px 0 6px;
}
h1, h2, h3, h4, p { margin-top: 0; }
h1 { font-size: clamp(34px, 6vw, 54px); line-height: 0.96; margin-bottom: 14px; }
h2 { font-size: 28px; margin-bottom: 0; }
h3 { font-size: 22px; margin-bottom: 6px; }
h4 { font-size: 17px; margin-bottom: 8px; }
.muted, .panel-head p, .doc-grid p { color: var(--muted); line-height: 1.65; }

.form-stack { display: grid; gap: 16px; margin-top: 24px; }
label span { display: block; color: var(--soft); margin-bottom: 8px; font-size: 14px; font-weight: 700; }
input, textarea {
  width: 100%;
  border: 1px solid var(--line);
  color: var(--text);
  background: rgba(4, 8, 22, 0.46);
  border-radius: 16px;
  outline: none;
  padding: 13px 15px;
  transition: border-color 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
}
input:focus, textarea:focus {
  border-color: rgba(86, 215, 255, 0.72);
  box-shadow: 0 0 0 4px rgba(86, 215, 255, 0.12);
  background: rgba(4, 8, 22, 0.64);
}
textarea { min-height: 180px; resize: vertical; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 13px; }

.primary-btn, .secondary-btn, .ghost-btn, .icon-btn {
  border: 0;
  border-radius: 16px;
  color: var(--text);
  font-weight: 800;
  transition: transform 0.18s ease, opacity 0.18s ease, background 0.18s ease;
}
.primary-btn, .secondary-btn { padding: 13px 18px; }
.primary-btn { background: linear-gradient(135deg, var(--accent), var(--accent-2)); box-shadow: 0 16px 34px rgba(86, 215, 255, 0.20); }
.secondary-btn { background: rgba(141, 123, 255, 0.72); }
.ghost-btn { background: rgba(255, 255, 255, 0.10); border: 1px solid var(--line); padding: 12px 16px; }
.ghost-btn.inline { padding: 12px 15px; }
.icon-btn { width: 38px; height: 38px; background: rgba(255, 255, 255, 0.10); font-size: 24px; }
button:hover { transform: translateY(-1px); }
button:disabled { opacity: 0.6; cursor: not-allowed; transform: none; }

.message { min-height: 22px; color: var(--danger); font-weight: 700; }

.app-view {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
  gap: 22px;
  padding: 22px;
}

.sidebar {
  border-radius: 30px;
  padding: 22px;
  min-height: calc(100vh - 44px);
  position: sticky;
  top: 22px;
  display: flex;
  flex-direction: column;
}
.sidebar-head { display: flex; gap: 14px; align-items: center; margin-bottom: 26px; }
.sidebar-head span { display: block; color: var(--muted); font-size: 13px; margin-top: 2px; }
.nav-tabs { display: grid; gap: 10px; }
.nav {
  width: 100%;
  border: 1px solid transparent;
  color: var(--muted);
  background: transparent;
  text-align: left;
  padding: 14px 16px;
  border-radius: 16px;
  font-weight: 800;
}
.nav:hover, .nav.active { color: var(--text); background: rgba(255, 255, 255, 0.10); border-color: var(--line); }
#logoutBtn { margin-top: auto; }

.main { min-width: 0; display: grid; align-content: start; gap: 20px; }
.topbar {
  border-radius: 28px;
  padding: 22px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.topbar .eyebrow { margin-top: 0; }
.admin-chip {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 10px 14px;
  background: rgba(255, 255, 255, 0.09);
  border: 1px solid var(--line);
  border-radius: 999px;
  font-weight: 800;
}
.pulse {
  width: 9px;
  height: 9px;
  background: var(--success);
  border-radius: 50%;
  box-shadow: 0 0 0 6px rgba(93, 247, 178, 0.12);
}

.stats-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; }
.stat-card { border-radius: 24px; padding: 20px; }
.stat-card span { color: var(--muted); font-size: 13px; font-weight: 800; }
.stat-card strong { display: block; font-size: 32px; margin-top: 8px; }

.panel { border-radius: 28px; padding: 22px; min-width: 0; }
.panel-head { display: flex; justify-content: space-between; gap: 18px; align-items: flex-start; margin-bottom: 18px; }
.toolbar { display: flex; gap: 10px; align-items: center; min-width: min(420px, 100%); }
.toolbar.multi { min-width: min(720px, 100%); }
.toolbar input { min-width: 0; }
.toolbar.multi input { width: 110px; }
.toolbar.multi input:first-child { width: 180px; }

.table-wrap { overflow: auto; border: 1px solid var(--line); border-radius: 22px; }
table { width: 100%; border-collapse: collapse; min-width: 980px; }
th, td { padding: 14px 16px; text-align: left; border-bottom: 1px solid rgba(255, 255, 255, 0.09); vertical-align: middle; }
th { color: var(--soft); font-size: 12px; text-transform: uppercase; letter-spacing: 0.08em; background: rgba(255, 255, 255, 0.06); }
.sort-btn {
  appearance: none;
  width: 100%;
  border: 0;
  padding: 0;
  color: inherit;
  background: transparent;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  justify-content: flex-start;
  font: inherit;
  font-weight: 900;
  letter-spacing: inherit;
  text-transform: inherit;
}
.sort-btn:hover,
.sort-btn.active { color: var(--accent-2); transform: none; }
.sort-indicator::before { content: '↕'; opacity: 0.56; font-size: 11px; }
.sort-btn.active[aria-sort="ascending"] .sort-indicator::before { content: '↑'; opacity: 1; }
.sort-btn.active[aria-sort="descending"] .sort-indicator::before { content: '↓'; opacity: 1; }
td { color: #eef2ff; font-size: 14px; }
tr.clickable:hover { background: rgba(255, 255, 255, 0.07); cursor: pointer; }
.badge { display: inline-flex; align-items: center; border-radius: 999px; padding: 5px 9px; background: rgba(86, 215, 255, 0.14); color: #c8f6ff; font-size: 12px; font-weight: 800; }
.badge.warn { background: rgba(255, 107, 134, 0.14); color: #ffd1da; }
.small-text { color: var(--muted); font-size: 12px; }

.drawer {
  position: fixed;
  right: 22px;
  top: 22px;
  bottom: 22px;
  width: min(620px, calc(100vw - 44px));
  border-radius: 30px;
  z-index: 20;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.drawer-head { display: flex; align-items: flex-start; justify-content: space-between; padding: 24px; border-bottom: 1px solid var(--line); }
.drawer-head .eyebrow { margin-top: 0; }
.drawer-body { padding: 22px; overflow: auto; display: grid; gap: 16px; }
.editor-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.actions { display: flex; flex-wrap: wrap; gap: 10px; }
.secret-box {
  border: 1px dashed rgba(86, 215, 255, 0.45);
  background: rgba(86, 215, 255, 0.08);
  border-radius: 18px;
  padding: 14px;
  word-break: break-all;
}

.feedback-list { display: grid; gap: 14px; }
.feedback-card { border: 1px solid var(--line); background: rgba(255, 255, 255, 0.06); border-radius: 22px; padding: 18px; }
.feedback-meta { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; }
.feedback-card p { color: #edf2ff; line-height: 1.7; white-space: pre-wrap; }

.doc-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
.doc-grid article { border: 1px solid var(--line); border-radius: 22px; padding: 18px; background: rgba(255, 255, 255, 0.06); }
code { color: #d6f8ff; background: rgba(86, 215, 255, 0.11); border-radius: 8px; padding: 2px 6px; }
.warn { color: #ffd1da !important; }
.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%);
  z-index: 99;
  max-width: min(520px, calc(100vw - 32px));
  padding: 13px 18px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: rgba(11, 14, 32, 0.88);
  box-shadow: var(--shadow);
}

@media (max-width: 1120px) {
  .app-view { grid-template-columns: 1fr; }
  .sidebar { position: relative; top: 0; min-height: auto; }
  .nav-tabs { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  #logoutBtn { margin-top: 18px; }
  .stats-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .panel-head { flex-direction: column; }
  .toolbar { width: 100%; }
  .doc-grid { grid-template-columns: 1fr; }
}

@media (max-width: 720px) {
  .app-view { padding: 14px; gap: 14px; }
  .login-card { padding: 24px; }
  .sidebar, .topbar, .panel { border-radius: 22px; }
  .topbar { align-items: flex-start; flex-direction: column; gap: 14px; }
  .nav-tabs { grid-template-columns: 1fr 1fr; }
  .stats-grid { grid-template-columns: 1fr; }
  .toolbar, .toolbar.multi { flex-direction: column; align-items: stretch; min-width: 0; }
  .toolbar.multi input, .toolbar.multi input:first-child { width: 100%; }
  .editor-grid { grid-template-columns: 1fr; }
  .drawer { inset: 10px; width: auto; }
}

.doc-grid article.wide {
  grid-column: 1 / -1;
}
.status-box {
  display: grid;
  gap: 10px;
  margin-top: 10px;
  margin-bottom: 14px;
}
.status-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  border: 1px solid rgba(255, 255, 255, 0.11);
  background: rgba(255, 255, 255, 0.055);
  border-radius: 14px;
  padding: 10px 12px;
}
.status-row strong {
  color: var(--soft);
}
.status-row span {
  text-align: right;
  word-break: break-all;
}
.status-actions {
  margin-top: 10px;
}

/* Logo image support */
.brand-mark {
  overflow: hidden;
  padding: 0;
}

.brand-mark img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
}

/* Enhanced player editor */
.drawer {
  width: min(760px, calc(100vw - 44px));
}
.editor-section {
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(255, 255, 255, 0.055);
  border-radius: 22px;
  padding: 16px;
}
.section-title {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 14px;
}
.section-title h4,
.section-title p {
  margin-bottom: 0;
}
.wide-field {
  grid-column: 1 / -1;
}
.json-panel summary {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: baseline;
  cursor: pointer;
  color: var(--soft);
  font-weight: 900;
  list-style: none;
}
.json-panel summary::-webkit-details-marker {
  display: none;
}
.json-panel summary::after {
  content: '展开/收起';
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}
.json-panel summary small {
  color: var(--muted);
  font-weight: 700;
}
.json-actions {
  display: flex;
  justify-content: flex-end;
  margin: 14px 0;
}
.hint-box {
  border: 1px dashed rgba(86, 215, 255, 0.38);
  background: rgba(86, 215, 255, 0.07);
  border-radius: 16px;
  padding: 12px 14px;
  line-height: 1.7;
}
.sticky-actions {
  position: sticky;
  bottom: -22px;
  z-index: 2;
  padding: 14px 0 2px;
  background: linear-gradient(180deg, rgba(13, 16, 35, 0), rgba(13, 16, 35, 0.94) 24%);
}
@media (max-width: 720px) {
  .section-title,
  .json-panel summary {
    flex-direction: column;
    align-items: flex-start;
  }
  .sticky-actions {
    bottom: -22px;
  }
}
