:root {
  --bg: #07070c;
  --bg-elevated: #0d0d15;
  --bg-card: #11111b;
  --bg-hover: #171724;
  --bg-input: #0b0b13;
  --border: #22222f;
  --border-soft: #191925;
  --text: #ececf3;
  --text-dim: #a0a0b4;
  --text-faint: #666679;
  --accent: #8b7bff;
  --accent-2: #22d3ee;
  --accent-dim: rgba(139, 123, 255, 0.13);
  --accent-text: #c4bbff;
  --gradient: linear-gradient(135deg, #8b7bff 0%, #5b8cff 50%, #22d3ee 100%);
  --green: #34d399;
  --green-dim: rgba(52, 211, 153, 0.12);
  --red: #f87171;
  --red-dim: rgba(248, 113, 113, 0.12);
  --amber: #fbbf24;
  --amber-dim: rgba(251, 191, 36, 0.12);
  --blue: #60a5fa;
  --blue-dim: rgba(96, 165, 250, 0.12);
  --radius: 14px;
  --radius-sm: 9px;
  --shadow: 0 1px 0 rgba(255, 255, 255, 0.03) inset, 0 12px 32px -12px rgba(0, 0, 0, 0.6);
  --mono: "JetBrains Mono", ui-monospace, Menlo, Consolas, monospace;
  color-scheme: dark;
  --sans: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 14px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(900px 500px at 85% -10%, rgba(139, 123, 255, 0.10), transparent 60%),
    radial-gradient(700px 400px at 10% 110%, rgba(34, 211, 238, 0.06), transparent 60%);
  z-index: 0;
}

svg.i { width: 16px; height: 16px; flex: none; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

.shell {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: 256px 1fr;
  min-height: 100vh;
}

/* ---------- Sidebar ---------- */

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  background: rgba(13, 13, 21, 0.85);
  backdrop-filter: blur(12px);
  border-right: 1px solid var(--border-soft);
  display: flex;
  flex-direction: column;
  padding: 18px 12px;
  gap: 18px;
  overflow-y: auto;
}

.brand { display: flex; align-items: center; gap: 11px; padding: 2px 8px; }
.brand-logo {
  width: 34px; height: 34px; border-radius: 10px;
  background: var(--gradient);
  box-shadow: 0 6px 20px -6px rgba(139, 123, 255, 0.7);
  display: grid; place-items: center;
}
.brand-logo svg { width: 20px; height: 20px; stroke: #fff; stroke-width: 2.6; fill: none; stroke-linecap: round; stroke-linejoin: round; }
.brand-text { display: flex; flex-direction: column; line-height: 1.15; }
.brand-name { font-weight: 700; letter-spacing: -0.02em; font-size: 15.5px; }
.brand-sub { font-size: 11.5px; color: var(--text-faint); }

.tenant-picker { display: flex; flex-direction: column; gap: 6px; padding: 0 6px; }
.tenant-picker label, .nav-section {
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.09em;
  color: var(--text-faint);
  font-weight: 600;
}

.select-wrap { position: relative; }
.select-wrap::after {
  content: "";
  position: absolute; right: 12px; top: 50%;
  width: 6px; height: 6px;
  border-right: 1.6px solid var(--text-dim); border-bottom: 1.6px solid var(--text-dim);
  transform: translateY(-70%) rotate(45deg);
  pointer-events: none;
}
.select-wrap select { width: 100%; appearance: none; padding-right: 30px; }

select, input, textarea {
  background: var(--bg-input);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: var(--radius-sm);
  padding: 9px 12px;
  font-family: var(--sans);
  font-size: 13px;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}
select:focus, input:focus, textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-dim); }
input::placeholder, textarea::placeholder { color: var(--text-faint); }

.nav { display: flex; flex-direction: column; gap: 2px; }
.nav-section { padding: 14px 10px 6px; }
.nav-section:first-child { padding-top: 0; }

.nav-item {
  display: flex; align-items: center; gap: 11px;
  background: none; border: none;
  color: var(--text-dim);
  font-size: 13.5px; font-family: var(--sans); font-weight: 500;
  text-align: left;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  position: relative;
  transition: background 0.12s, color 0.12s;
}
.nav-item:hover { background: var(--bg-hover); color: var(--text); }
.nav-item.active { background: var(--accent-dim); color: var(--text); }
.nav-item.active::before {
  content: ""; position: absolute; left: -12px; top: 8px; bottom: 8px; width: 3px;
  border-radius: 0 3px 3px 0; background: var(--gradient);
}
.nav-item.active svg.i { color: var(--accent-text); }
.nav-count {
  margin-left: auto; font-size: 11px; font-weight: 600;
  background: var(--amber-dim); color: var(--amber);
  padding: 1px 7px; border-radius: 100px;
}
.nav-count:empty { display: none; }
a.nav-item { text-decoration: none; }
.module-nav:empty { display: none; }
.module-nav { border-top: 1px solid var(--border-soft); padding-top: 10px; }

.sidebar-footer {
  margin-top: auto;
  display: flex; align-items: center; gap: 9px;
  font-size: 12px; color: var(--text-faint);
  border-top: 1px solid var(--border-soft);
  padding: 14px 8px 2px;
}
.conn-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--text-faint); transition: background 0.2s; }
.conn-dot.ok { background: var(--green); box-shadow: 0 0 0 3px var(--green-dim); animation: pulse 2.4s infinite; }
.conn-dot.err { background: var(--red); box-shadow: 0 0 0 3px var(--red-dim); }
@keyframes pulse { 50% { box-shadow: 0 0 0 5px rgba(52, 211, 153, 0.05); } }

/* ---------- Main ---------- */

.main { display: flex; flex-direction: column; min-width: 0; }

.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 16px 32px;
  background: rgba(7, 7, 12, 0.75);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border-soft);
}
.topbar-left { display: flex; align-items: center; gap: 12px; min-width: 0; }
.topbar-right { display: flex; align-items: center; gap: 12px; }
.crumb { font-size: 12px; color: var(--text-faint); margin-bottom: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar h1 { font-size: 20px; font-weight: 650; letter-spacing: -0.02em; margin: 0; }
.topbar-actions { display: flex; gap: 8px; }

.icon-btn {
  display: inline-grid; place-items: center;
  width: 36px; height: 36px;
  border-radius: var(--radius-sm);
  background: var(--bg-card); border: 1px solid var(--border); color: var(--text-dim);
  cursor: pointer;
}
.menu-btn { display: none; }
.scrim { display: none; }

.user-menu { position: relative; }
.user-chip {
  display: flex; align-items: center; gap: 10px;
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: 100px; padding: 4px 14px 4px 4px;
  color: var(--text); font-family: var(--sans); cursor: pointer;
  transition: border-color 0.15s;
}
.user-chip:hover { border-color: var(--accent); }
.avatar {
  width: 30px; height: 30px; border-radius: 50%;
  background: var(--gradient); color: #fff;
  display: grid; place-items: center;
  font-size: 12px; font-weight: 700;
}
.user-meta { display: flex; flex-direction: column; text-align: left; line-height: 1.15; }
.user-meta span:first-child { font-size: 13px; font-weight: 600; }
.user-meta span:last-child { font-size: 11px; color: var(--text-faint); }

.menu {
  position: absolute; right: 0; top: calc(100% + 8px);
  min-width: 200px; padding: 6px;
  background: var(--bg-elevated); border: 1px solid var(--border);
  border-radius: 12px; box-shadow: 0 20px 50px rgba(0, 0, 0, 0.55);
  animation: pop 0.14s ease-out;
}
.menu-item {
  display: flex; align-items: center; gap: 10px; width: 100%;
  background: none; border: none; color: var(--text-dim);
  font: 500 13px var(--sans); padding: 9px 10px; border-radius: 8px; cursor: pointer; text-align: left;
}
.menu-item:hover { background: var(--bg-hover); color: var(--text); }
.menu-item.danger:hover { color: var(--red); }

.content { padding: 28px 32px 64px; max-width: 1400px; width: 100%; animation: fade 0.25s ease-out; }
@keyframes fade { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }
@keyframes pop { from { opacity: 0; transform: translateY(-4px) scale(0.98); } to { opacity: 1; transform: none; } }

/* ---------- Buttons ---------- */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  background: var(--bg-card); border: 1px solid var(--border); color: var(--text);
  padding: 8px 14px; border-radius: var(--radius-sm);
  font: 500 13px var(--sans);
  cursor: pointer; white-space: nowrap;
  transition: border-color 0.12s, background 0.12s, filter 0.12s, transform 0.06s;
}
.btn:hover { border-color: #3a3a4d; background: var(--bg-hover); }
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--gradient); border-color: transparent; color: #fff; box-shadow: 0 6px 18px -8px rgba(139, 123, 255, 0.8); }
.btn.primary:hover { filter: brightness(1.1); }
.btn.danger { border-color: rgba(248, 113, 113, 0.35); color: var(--red); background: transparent; }
.btn.danger:hover { background: var(--red-dim); }
.btn.ghost { background: transparent; border-color: transparent; color: var(--text-dim); }
.btn.ghost:hover { background: var(--bg-hover); color: var(--text); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn.sm { padding: 5px 10px; font-size: 12px; border-radius: 7px; }
.btn.sm svg.i { width: 14px; height: 14px; }
.btn.block { width: 100%; }
.btn.loading { pointer-events: none; opacity: 0.75; }

.seg { display: inline-flex; padding: 3px; gap: 2px; background: var(--bg-input); border: 1px solid var(--border); border-radius: 10px; }
.seg button {
  background: none; border: none; color: var(--text-dim);
  font: 500 12px var(--sans); padding: 5px 11px; border-radius: 7px; cursor: pointer; text-transform: capitalize;
}
.seg button:hover { color: var(--text); }
.seg button.on { background: var(--bg-hover); color: var(--text); box-shadow: 0 1px 2px rgba(0, 0, 0, 0.4); }

/* ---------- Hero / stats ---------- */

.hero {
  position: relative; overflow: hidden;
  border-radius: 18px; padding: 26px 28px; margin-bottom: 22px;
  border: 1px solid rgba(139, 123, 255, 0.25);
  background:
    radial-gradient(600px 220px at 100% 0%, rgba(34, 211, 238, 0.18), transparent 70%),
    radial-gradient(500px 240px at 0% 100%, rgba(139, 123, 255, 0.22), transparent 70%),
    var(--bg-card);
  display: flex; justify-content: space-between; align-items: center; gap: 20px; flex-wrap: wrap;
}
.hero::after {
  content: ""; position: absolute; inset: 0; pointer-events: none;
  background-image: linear-gradient(rgba(255,255,255,0.035) 1px, transparent 1px), linear-gradient(90deg, rgba(255,255,255,0.035) 1px, transparent 1px);
  background-size: 28px 28px;
  mask-image: linear-gradient(90deg, transparent 20%, #000 100%);
}
.hero h2 { margin: 0 0 6px; font-size: 22px; letter-spacing: -0.02em; font-weight: 700; }
.hero p { margin: 0; color: var(--text-dim); max-width: 560px; }
.hero-tags { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 14px; position: relative; z-index: 1; }
.hero > * { position: relative; z-index: 1; }

.stat-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; margin-bottom: 22px; }
.stat-card {
  background: var(--bg-card); border: 1px solid var(--border-soft);
  border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow);
  display: flex; flex-direction: column; gap: 12px;
  transition: border-color 0.15s, transform 0.15s;
}
.stat-card.link { cursor: pointer; }
.stat-card.link:hover { border-color: var(--border); transform: translateY(-2px); }
.stat-top { display: flex; align-items: center; justify-content: space-between; }
.stat-label { font-size: 12.5px; color: var(--text-dim); font-weight: 500; }
.stat-icon { width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; }
.stat-icon svg.i { width: 17px; height: 17px; }
.stat-value { font-size: 30px; font-weight: 700; letter-spacing: -0.03em; line-height: 1; }
.stat-foot { font-size: 12px; color: var(--text-faint); }
.tone-violet { background: var(--accent-dim); color: var(--accent-text); }
.tone-cyan { background: rgba(34, 211, 238, 0.12); color: var(--accent-2); }
.tone-green { background: var(--green-dim); color: var(--green); }
.tone-amber { background: var(--amber-dim); color: var(--amber); }
.tone-red { background: var(--red-dim); color: var(--red); }
.tone-blue { background: var(--blue-dim); color: var(--blue); }

.grid-2 { display: grid; grid-template-columns: 1.4fr 1fr; gap: 18px; }

/* ---------- Panels & tables ---------- */

.panel {
  background: var(--bg-card); border: 1px solid var(--border-soft);
  border-radius: var(--radius); overflow: hidden; margin-bottom: 18px; box-shadow: var(--shadow);
}
.panel-header {
  display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
  padding: 15px 20px; border-bottom: 1px solid var(--border-soft);
}
.panel-header h2 { font-size: 14.5px; font-weight: 600; margin: 0; letter-spacing: -0.01em; }
.panel-header p { margin: 2px 0 0; font-size: 12.5px; color: var(--text-faint); }
.panel-body { padding: 18px 20px; }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th {
  text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: 0.07em;
  color: var(--text-faint); font-weight: 600;
  padding: 11px 20px; background: rgba(255, 255, 255, 0.012);
  border-bottom: 1px solid var(--border-soft); white-space: nowrap;
}
td { padding: 12px 20px; border-bottom: 1px solid var(--border-soft); font-size: 13px; vertical-align: middle; }
tr:last-child td { border-bottom: none; }
tbody tr { transition: background 0.1s; }
tbody tr:hover { background: rgba(255, 255, 255, 0.018); }
td.actions { text-align: right; white-space: nowrap; }
td.nowrap { white-space: nowrap; }
td.actions .btn + .btn { margin-left: 6px; }
.strong { font-weight: 600; }

.mono { font-family: var(--mono); font-size: 12px; color: var(--text-dim); }
.id-chip {
  font-family: var(--mono); font-size: 11.5px; color: var(--text-dim);
  background: var(--bg-input); border: 1px solid var(--border-soft);
  padding: 2px 7px; border-radius: 6px; cursor: copy; transition: color 0.12s, border-color 0.12s;
}
.id-chip:hover { color: var(--accent-text); border-color: var(--accent); }

.person { display: inline-flex; align-items: center; gap: 8px; white-space: nowrap; font-weight: 500; }
.person[data-player] { cursor: pointer; }
.person[data-player]:hover { color: var(--accent-text); }
.avatar.xs { width: 22px; height: 22px; font-size: 9.5px; }
.avatar.bot { background: var(--blue-dim); color: var(--blue); }
.avatar.bot svg.i { width: 12px; height: 12px; }

.badge {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 3px 10px; border-radius: 100px;
  font-size: 11.5px; font-weight: 600; white-space: nowrap; text-transform: capitalize;
}
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge.plain::before { display: none; }
.badge.plain { text-transform: none; }
.badge.green { background: var(--green-dim); color: var(--green); }
.badge.red { background: var(--red-dim); color: var(--red); }
.badge.amber { background: var(--amber-dim); color: var(--amber); }
.badge.blue { background: var(--blue-dim); color: var(--blue); }
.badge.violet { background: var(--accent-dim); color: var(--accent-text); }
.badge.neutral { background: rgba(255, 255, 255, 0.05); color: var(--text-dim); }

.empty-state { padding: 48px 20px; text-align: center; color: var(--text-faint); font-size: 13px; }
.empty-state .empty-icon {
  width: 44px; height: 44px; margin: 0 auto 12px; border-radius: 12px;
  display: grid; place-items: center; background: var(--bg-hover); color: var(--text-dim);
}
.empty-state .empty-icon svg.i { width: 20px; height: 20px; }
.empty-state strong { display: block; color: var(--text); font-weight: 600; margin-bottom: 4px; font-size: 14px; }

.form-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px;
  padding: 18px 20px; align-items: end;
}
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field > span { font-size: 12px; color: var(--text-dim); font-weight: 500; }
.field input, .field select, .field textarea { width: 100%; }
.field-wide { grid-column: 1 / -1; }

.kv { display: grid; grid-template-columns: 170px 1fr; }
.kv > div { padding: 12px 20px; border-bottom: 1px solid var(--border-soft); font-size: 13px; }
.kv > div:nth-child(odd) { color: var(--text-faint); }
.kv > div:nth-last-child(-n+2) { border-bottom: none; }

.feed { list-style: none; margin: 0; padding: 6px 0; }
.feed li { display: flex; gap: 12px; padding: 10px 20px; align-items: flex-start; }
.feed .dot { width: 30px; height: 30px; border-radius: 9px; display: grid; place-items: center; flex: none; }
.feed .dot svg.i { width: 15px; height: 15px; }
.feed .what { font-size: 13px; }
.feed .when { font-size: 11.5px; color: var(--text-faint); margin-top: 2px; }

.quick { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; padding: 16px 20px; }
.quick button {
  display: flex; align-items: center; gap: 10px; text-align: left;
  background: var(--bg-input); border: 1px solid var(--border-soft); color: var(--text);
  padding: 12px; border-radius: 11px; cursor: pointer; font: 500 13px var(--sans);
  transition: border-color 0.15s, background 0.15s;
}
.quick button:hover { border-color: var(--accent); background: var(--bg-hover); }

.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.swatch { display: inline-block; width: 14px; height: 14px; border-radius: 50%; border: 2px solid rgba(255,255,255,0.15); vertical-align: middle; }

audio { height: 32px; width: 160px; border-radius: 8px; }

/* ---------- Skeleton ---------- */

.skeleton {
  background: linear-gradient(90deg, var(--bg-card) 0%, var(--bg-hover) 50%, var(--bg-card) 100%);
  background-size: 200% 100%; animation: shimmer 1.2s infinite; border-radius: var(--radius);
  border: 1px solid var(--border-soft);
}
@keyframes shimmer { from { background-position: 200% 0; } to { background-position: -200% 0; } }

/* ---------- Toasts ---------- */

.toast-stack { position: fixed; bottom: 22px; right: 22px; display: flex; flex-direction: column; gap: 8px; z-index: 300; }
.toast {
  display: flex; align-items: center; gap: 10px;
  background: var(--bg-elevated); border: 1px solid var(--border); color: var(--text);
  padding: 11px 16px; border-radius: 11px; font-size: 13px; min-width: 240px; max-width: 380px;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.5);
  animation: toast-in 0.2s ease-out;
}
.toast.success svg.i { color: var(--green); }
.toast.error { border-color: rgba(248, 113, 113, 0.4); }
.toast.error svg.i { color: var(--red); }
.toast.out { opacity: 0; transform: translateY(6px); transition: all 0.2s; }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* ---------- Modal ---------- */

.modal-backdrop {
  position: fixed; inset: 0; z-index: 250;
  background: rgba(3, 3, 8, 0.7); backdrop-filter: blur(6px);
  display: grid; place-items: center; padding: 16px;
  animation: fade 0.15s ease-out;
}
.modal {
  width: 100%; max-width: 440px;
  background: var(--bg-elevated); border: 1px solid var(--border);
  border-radius: 16px; box-shadow: 0 30px 80px rgba(0, 0, 0, 0.6);
  animation: pop 0.16s ease-out;
}
.modal-head { padding: 20px 22px 4px; }
.modal-head h3 { margin: 0; font-size: 16px; font-weight: 650; }
.modal-head p { margin: 6px 0 0; color: var(--text-dim); font-size: 13px; }
.modal-body { padding: 16px 22px; display: flex; flex-direction: column; gap: 12px; }
.modal-foot { padding: 14px 22px 20px; display: flex; justify-content: flex-end; gap: 8px; }
.form-error { color: var(--red); font-size: 12.5px; min-height: 0; }
.form-error:empty { display: none; }

/* ---------- Live world ---------- */

.nav-live {
  margin-left: auto; font-size: 9.5px; font-weight: 700; letter-spacing: 0.08em;
  color: #fff; background: linear-gradient(135deg, #f43f5e, #f97316); padding: 2px 6px; border-radius: 5px;
}
.content:has(.world-layout) { max-width: none; }
.world-layout { display: grid; grid-template-columns: 1fr 340px; gap: 18px; height: calc(100vh - 150px); min-height: 520px; }
.world-stage {
  position: relative; overflow: hidden; border-radius: var(--radius);
  border: 1px solid var(--border-soft); background: #07070c; box-shadow: var(--shadow);
}
.world-stage canvas { position: absolute; inset: 0; display: block; z-index: 0; cursor: crosshair; }
.world-stage .w-labels { position: absolute; inset: 0; pointer-events: none; z-index: 1; }
.world-loading { position: absolute; inset: 0; z-index: 5; }
.world-hud {
  position: absolute; top: 14px; left: 14px; z-index: 3; pointer-events: none;
  background: rgba(7, 7, 12, 0.6); backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, 0.08); border-radius: 12px; padding: 12px 14px;
}
.hud-title { font-weight: 700; font-size: 16px; letter-spacing: -0.01em; text-transform: capitalize; margin-bottom: 8px; }
.hud-tags { display: flex; flex-wrap: wrap; gap: 6px; max-width: 420px; }
.hud-tags .badge svg.i { width: 12px; height: 12px; }
.world-controls { position: absolute; left: 50%; bottom: 16px; transform: translateX(-50%); z-index: 3; width: min(620px, calc(100% - 32px)); display: flex; justify-content: center; }
.say-form {
  display: flex; gap: 8px; align-items: center; width: 100%;
  background: rgba(7, 7, 12, 0.72); backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, 0.1); border-radius: 14px; padding: 8px;
}
.say-form input { flex: 1; min-width: 0; background: rgba(255, 255, 255, 0.04); }
.say-form .hint { display: inline-flex; align-items: center; gap: 6px; font-size: 11.5px; color: var(--text-faint); white-space: nowrap; padding-left: 6px; }
.world-side { display: flex; flex-direction: column; gap: 18px; min-height: 0; }
.world-side .panel { margin: 0; display: flex; flex-direction: column; min-height: 0; }
.world-side .panel:last-child { flex: 1; }
.world-side .panel:first-child { max-height: 45%; }
.roster, .world-feed { overflow-y: auto; }
.roster { list-style: none; margin: 0; padding: 6px 0; }
.roster li { display: flex; align-items: center; gap: 10px; padding: 7px 18px; }
.roster .who { flex: 1; min-width: 0; display: flex; flex-direction: column; line-height: 1.25; }
.roster .who b { font-size: 13px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.roster .who span { font-size: 11.5px; color: var(--text-faint); }
.roster .muted, .feed .muted { color: var(--text-faint); font-size: 13px; }
.ai-chip {
  display: inline-block; font-size: 9.5px; font-weight: 800; letter-spacing: 0.06em;
  color: #031a1f; background: #22d3ee; border-radius: 4px; padding: 0 4px; vertical-align: 1px;
}

.w-tag {
  display: inline-flex; align-items: center; gap: 6px; white-space: nowrap;
  font: 600 12px var(--sans); color: #fff;
  background: rgba(10, 10, 18, 0.72); border: 1px solid rgba(255, 255, 255, 0.14);
  padding: 3px 9px; border-radius: 100px; transform: translateY(-4px);
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.6);
}
.w-tag.agent { border-color: rgba(34, 211, 238, 0.75); box-shadow: 0 0 14px rgba(34, 211, 238, 0.35); }
.w-tag.self { border-color: var(--accent); }
.w-tag.obj { font-size: 10.5px; color: var(--accent-text); border-color: rgba(139, 123, 255, 0.4); }
.w-ai { font-size: 9.5px; font-weight: 800; letter-spacing: 0.06em; color: #031a1f; background: #22d3ee; border-radius: 4px; padding: 0 4px; }
.w-you { font-size: 9.5px; font-weight: 800; color: #fff; background: var(--accent); border-radius: 4px; padding: 0 4px; }
.w-tier { font-size: 10px; color: #67e8f9; font-weight: 700; }
.w-bubble {
  max-width: 240px; white-space: normal; text-align: left;
  font: 500 12.5px/1.35 var(--sans); color: #0b0b14; background: #fff;
  padding: 7px 11px; border-radius: 12px 12px 12px 4px; transform: translateY(-10px);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35); animation: pop 0.18s ease-out;
}

@media (max-width: 1100px) {
  .world-layout { grid-template-columns: 1fr; height: auto; }
  .world-stage { height: 62vh; min-height: 420px; }
  .world-side .panel:first-child { max-height: none; }
  .world-feed { max-height: 360px; }
}

.space-list li { cursor: pointer; border-left: 3px solid transparent; }
.space-list li:hover { background: var(--bg-hover); }
.space-list li.on { background: var(--accent-dim); border-left-color: var(--accent); }
.space-list .badge svg.i { width: 12px; height: 12px; }

.wallet-card {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  margin: 8px 22px 12px; padding: 14px 16px; border-radius: 12px;
  background: linear-gradient(135deg, rgba(251, 191, 36, 0.12), rgba(139, 123, 255, 0.10));
  border: 1px solid rgba(251, 191, 36, 0.25);
}
.wallet-balance { font-size: 26px; font-weight: 700; letter-spacing: -0.02em; color: var(--amber); line-height: 1; }
.wallet-sub { font-size: 11.5px; color: var(--text-dim); margin-top: 4px; }
.chip-x { background: none; border: none; color: inherit; cursor: pointer; padding: 0 0 0 4px; font-size: 13px; line-height: 1; opacity: 0.7; }
.chip-x:hover { opacity: 1; color: var(--red); }
.ledger { padding: 0 22px 12px; }
.ledger summary { cursor: pointer; font-size: 12.5px; color: var(--text-dim); padding: 6px 0; }
.ledger .feed li { padding: 7px 0; }

/* ---------- Side sheet ---------- */

.sheet-backdrop { position: fixed; inset: 0; z-index: 240; background: rgba(3, 3, 8, 0.6); backdrop-filter: blur(4px); animation: fade 0.15s ease-out; }
.sheet {
  position: absolute; top: 0; right: 0; bottom: 0; width: 460px; max-width: 100%;
  background: var(--bg-elevated); border-left: 1px solid var(--border);
  overflow-y: auto; box-shadow: -30px 0 80px rgba(0, 0, 0, 0.5);
  animation: slide-in 0.2s ease-out;
}
@keyframes slide-in { from { transform: translateX(40px); opacity: 0; } to { transform: none; opacity: 1; } }
.sheet-head { display: flex; gap: 14px; align-items: center; padding: 24px 22px 18px; border-bottom: 1px solid var(--border-soft); }
.sheet-head h3 { margin: 0; font-size: 18px; letter-spacing: -0.02em; }
.sheet .kv { grid-template-columns: 120px 1fr; }
.sheet-section { border-top: 1px solid var(--border-soft); }
.sheet-section h4 { margin: 0; padding: 16px 22px 4px; font-size: 11px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--text-faint); }
.sheet-section .feed li { padding: 9px 22px; }
.sheet-empty { padding: 10px 22px 16px; color: var(--text-faint); font-size: 13px; }
.sheet-foot { padding: 18px 22px 26px; border-top: 1px solid var(--border-soft); }

/* ---------- Login ---------- */

#login-gate {
  position: fixed; inset: 0; z-index: 200;
  display: grid; grid-template-columns: 1.1fr 1fr;
  background: var(--bg);
}
.login-art {
  position: relative; overflow: hidden;
  padding: 48px;
  display: flex; flex-direction: column; justify-content: space-between;
  background:
    radial-gradient(700px 500px at 20% 20%, rgba(139, 123, 255, 0.35), transparent 60%),
    radial-gradient(600px 500px at 90% 90%, rgba(34, 211, 238, 0.25), transparent 60%),
    #0a0a14;
  border-right: 1px solid var(--border-soft);
}
.login-art::before {
  content: ""; position: absolute; left: -50%; right: -50%; bottom: -10%; height: 70%;
  background-image: linear-gradient(rgba(139, 123, 255, 0.35) 1px, transparent 1px), linear-gradient(90deg, rgba(139, 123, 255, 0.35) 1px, transparent 1px);
  background-size: 48px 48px;
  transform: perspective(500px) rotateX(62deg);
  transform-origin: bottom;
  mask-image: linear-gradient(to top, #000 10%, transparent 90%);
  animation: grid-move 6s linear infinite;
}
@keyframes grid-move { from { background-position: 0 0; } to { background-position: 0 48px; } }
.orb {
  width: 260px; height: 260px; border-radius: 50%;
  right: 10%; top: 12%; width: 210px; height: 210px;
  background: radial-gradient(circle at 30% 30%, #fff 0%, #b9adff 12%, #6b5cff 45%, #1b1440 75%);
  box-shadow: 0 0 120px 20px rgba(139, 123, 255, 0.45);
  animation: float 7s ease-in-out infinite;
}
.orb::after {
  content: ""; position: absolute; inset: -30px; border-radius: 50%;
  border: 1px solid rgba(34, 211, 238, 0.35);
  transform: rotateX(70deg) rotateZ(20deg);
}
@keyframes float { 50% { transform: translateY(-16px); } }
.login-art > * { position: relative; z-index: 1; }
.login-art > .orb { position: absolute; z-index: 0; }
.login-art h1 { font-size: 40px; line-height: 1.08; letter-spacing: -0.035em; margin: 0 0 14px; max-width: 460px; }
.login-art h1 span { background: var(--gradient); -webkit-background-clip: text; background-clip: text; color: transparent; }
.login-art p { color: var(--text-dim); max-width: 420px; margin: 0; font-size: 15px; }
.login-feats { display: flex; gap: 22px; flex-wrap: wrap; color: var(--text-dim); font-size: 13px; }
.login-feats span { display: inline-flex; align-items: center; gap: 8px; }
.login-feats svg.i { color: var(--accent-2); }

.login-side { display: grid; place-items: center; padding: 32px; }
.login-card { width: 100%; max-width: 380px; }
.login-card h2 { font-size: 24px; letter-spacing: -0.02em; margin: 26px 0 6px; }
.login-card .sub { color: var(--text-dim); margin: 0 0 24px; font-size: 13.5px; }
.login-card .field { margin-bottom: 14px; }
.login-card .btn { padding: 11px 14px; font-size: 14px; margin-top: 6px; }
.login-alt { display: block; margin-top: 18px; font-size: 12.5px; color: var(--text-faint); text-align: center; text-decoration: none; }
.login-alt:hover { color: var(--accent-text); }
.login-legal { margin-top: 36px; font-size: 11.5px; color: var(--text-faint); text-align: center; }

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 8px; border: 2px solid var(--bg); }
::-webkit-scrollbar-track { background: transparent; }

/* ---------- Responsive ---------- */

@media (max-width: 1100px) {
  .grid-2 { grid-template-columns: 1fr; }
}

@media (max-width: 860px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed; left: 0; top: 0; bottom: 0; width: 272px; z-index: 60;
    transform: translateX(-100%); transition: transform 0.2s ease;
    background: var(--bg-elevated);
  }
  body.nav-open .sidebar { transform: none; }
  .scrim { position: fixed; inset: 0; background: rgba(0, 0, 0, 0.55); z-index: 50; display: none; }
  body.nav-open .scrim { display: block; }
  .menu-btn { display: inline-grid; }
  .topbar { padding: 12px 16px; }
  .content { padding: 20px 16px 48px; }
  .user-meta { display: none; }
  .user-chip { padding: 4px; }
  .topbar-actions .btn span.lbl { display: none; }
  #login-gate { grid-template-columns: 1fr; }
  .login-art { display: none; }
  .kv { grid-template-columns: 1fr; }
  .kv > div:nth-child(odd) { border-bottom: none; padding-bottom: 0; }
  .quick { grid-template-columns: 1fr; }
  .stat-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .stat-card { padding: 14px; }
  .stat-value { font-size: 24px; }
}

/* ---------- Asset files ---------- */

.asset-cell { display: flex; align-items: center; gap: 10px; }
.asset-thumb {
  width: 34px; height: 34px; flex: none; border-radius: 8px; overflow: hidden;
  background: radial-gradient(circle at 50% 40%, #2d2752, #0c0b18); border: 1px solid var(--border);
  display: inline-grid; place-items: center; color: var(--text-faint);
}
.asset-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.asset-thumb.none svg.i { width: 16px; height: 16px; }
.asset-thumb.lg { width: 52px; height: 52px; border-radius: 12px; }
.asset-thumb.lg.none svg.i { width: 22px; height: 22px; }

.sheet.wide { width: 560px; }
.model-stage {
  position: relative; height: 320px; margin: 18px 22px 0; border-radius: var(--radius); overflow: hidden;
  background: radial-gradient(ellipse at 50% 35%, #2a2450 0%, #121022 55%, #08080f 100%);
  border: 1px solid var(--border);
}
.model-stage canvas { position: absolute; inset: 0; display: block; cursor: grab; }
.model-stage canvas:active { cursor: grabbing; }
.model-loading { position: absolute; inset: 0; display: grid; place-items: center; color: var(--text-dim); font-size: 13px; }
.model-meta { position: absolute; left: 12px; bottom: 10px; display: flex; gap: 6px; pointer-events: none; z-index: 1; }
.model-meta span { background: rgba(7, 7, 12, 0.72); border: 1px solid var(--border); border-radius: 999px; padding: 3px 9px; font-size: 11px; color: var(--text-dim); }
.model-meta:empty { display: none; }
.model-empty { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; padding: 30px; text-align: center; color: var(--text-dim); font-size: 12.5px; }
.model-empty svg.i { width: 34px; height: 34px; color: var(--accent); opacity: 0.8; }
.model-empty b { color: var(--text); font-size: 14px; }
.file-tiles { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; padding: 14px 22px 20px; }
.file-tile { border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--bg-card); padding: 12px; display: flex; flex-direction: column; gap: 10px; min-width: 0; }
.file-tile-head { display: flex; align-items: center; gap: 8px; font-size: 13px; }
.file-tile-head svg.i { width: 16px; height: 16px; color: var(--accent-text); }
.file-tile-body { display: flex; flex-direction: column; gap: 3px; font-size: 12px; color: var(--text-faint); min-height: 34px; }
.file-tile-body .mono { color: var(--text-dim); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-tile-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.file-tile label.btn { align-self: flex-start; cursor: pointer; }
@media (max-width: 600px) {
  .file-tiles { grid-template-columns: 1fr; }
  .model-stage { height: 260px; margin: 14px 14px 0; }
}
