:root {
  --bg: #08090b;
  --bg-soft: #0b0d10;
  --surface: #101317;
  --surface-2: #151920;
  --surface-3: #1b2029;
  --line: #222831;
  --line-strong: #333b47;
  --text: #eceef2;
  --muted: #8c95a3;
  --accent: #7c9cff;
  --accent-strong: #a5b8ff;
  --accent-soft: rgba(124, 156, 255, 0.14);
  --info: #60a5fa;
  --ok: #4ade80;
  --warn: #fbbf24;
  --danger: #f87171;
  --radius: 12px;
  --radius-sm: 8px;
  --font: "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: ui-monospace, "JetBrains Mono", "Cascadia Mono", Consolas, monospace;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html {
  color-scheme: dark;
}

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  font-family: var(--font);
  font-size: 14px;
  color: var(--text);
  background:
    radial-gradient(1000px 520px at 50% -18%, rgba(124, 156, 255, 0.08), transparent 70%),
    var(--bg);
  padding: 22px clamp(16px, 2.6vw, 32px) 48px;
  -webkit-font-smoothing: antialiased;
}

h1,
h2,
h3 {
  margin: 0;
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--text);
}

h2 {
  font-size: 15px;
}

h3 {
  margin-top: 22px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
}

p {
  margin: 0;
}

.muted {
  color: var(--muted);
}

.small {
  font-size: 12px;
  line-height: 1.5;
}

.eyebrow {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
}

.app {
  max-width: 1340px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* ---------- top bar ---------- */

.topbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding-bottom: 18px;
  border-bottom: 1px solid var(--line);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-mark {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border-radius: 10px;
  background: linear-gradient(180deg, #2a3242, #191e27);
  border: 1px solid var(--line-strong);
  color: var(--accent-strong);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.04em;
}

.brand-copy h1 {
  font-size: 17px;
  line-height: 1.2;
}

.brand-copy p {
  color: var(--muted);
  font-size: 11.5px;
}

.topbar-controls {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 10px;
}

.identity {
  display: flex;
  align-items: center;
  gap: 10px;
  padding-left: 14px;
  border-left: 1px solid var(--line);
}

.avatar {
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  width: 36px;
  height: 36px;
  overflow: hidden;
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  background: var(--surface-2);
  color: var(--text);
  font-size: 12px;
  font-weight: 700;
}

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

.identity-copy {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.identity-copy strong {
  max-width: 160px;
  overflow: hidden;
  color: var(--text);
  font-size: 12.5px;
  line-height: 1.2;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.role-badge {
  color: var(--muted);
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.role-badge[data-role="ADMIN"] {
  color: var(--accent-strong);
}

.role-badge[data-role="STAFF"] {
  color: var(--info);
}

.role-badge[data-role="MEMBER"] {
  color: var(--ok);
}

.role-badge[data-role="NONE"] {
  color: var(--danger);
}

.role-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 4px;
  max-width: 230px;
}

.role-chip {
  font-size: 9px;
  line-height: 1.5;
  padding: 1px 7px;
  border-radius: 999px;
  border: 1px solid var(--line-strong);
  background: var(--surface-2);
  color: var(--muted);
  max-width: 120px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.role-chip.more {
  color: var(--accent-strong);
  border-color: color-mix(in srgb, var(--accent) 40%, transparent);
  background: var(--accent-soft);
}

/* ---------- workspace tabs ---------- */

.view-tabs {
  display: flex;
  gap: 4px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
  overflow-x: auto;
  scrollbar-width: thin;
}

.view-tab {
  appearance: none;
  flex: 0 0 auto;
  border: 1px solid transparent;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  padding: 9px 16px;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}

.view-tab:hover {
  color: var(--text);
  background: var(--surface-2);
}

.view-tab.active {
  background: var(--surface-3);
  border-color: var(--line-strong);
  color: var(--text);
}

.subtabs {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 20px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--line);
}

.subtab {
  appearance: none;
  border: 1px solid var(--line);
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 12px;
  font-weight: 600;
  padding: 6px 13px;
  border-radius: 999px;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

.subtab:hover {
  color: var(--text);
  border-color: var(--line-strong);
}

.subtab.active {
  background: var(--accent-soft);
  border-color: color-mix(in srgb, var(--accent) 45%, transparent);
  color: var(--accent-strong);
}

/* ---------- fields and buttons ---------- */

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 11px;
  font-weight: 500;
  color: var(--muted);
}

.field.narrow {
  width: 88px;
}

.field select,
.field input,
.field textarea,
.access-note input {
  appearance: none;
  background: var(--bg-soft);
  border: 1px solid var(--line-strong);
  color: var(--text);
  border-radius: var(--radius-sm);
  padding: 9px 11px;
  font: inherit;
  font-size: 13px;
  min-width: 180px;
  transition: border-color 0.15s ease, background 0.15s ease;
}

.field.narrow input {
  min-width: 0;
  width: 100%;
}

.field select:hover,
.field input:hover,
.field textarea:hover {
  border-color: #424b59;
}

.field textarea {
  min-height: 62px;
  resize: vertical;
  font-family: inherit;
  line-height: 1.45;
}

.field input[type="file"] {
  padding: 7px;
  background: var(--surface-2);
  font-size: 11.5px;
  color: var(--muted);
}

.field select:focus-visible,
.field input:focus-visible,
.field textarea:focus-visible,
.access-note input:focus-visible,
button:focus-visible,
.item:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
  border-color: transparent;
}

button {
  font: inherit;
  cursor: pointer;
}

.primary {
  appearance: none;
  border: 1px solid color-mix(in srgb, var(--accent) 70%, transparent);
  background: var(--accent);
  color: #0a0c12;
  font-weight: 650;
  font-size: 13px;
  padding: 9px 16px;
  border-radius: var(--radius-sm);
  transition: filter 0.15s ease;
}

.primary:hover {
  filter: brightness(1.08);
}

.ghost {
  appearance: none;
  background: var(--surface-2);
  border: 1px solid var(--line-strong);
  color: var(--text);
  border-radius: var(--radius-sm);
  padding: 9px 14px;
  font-size: 13px;
  transition: border-color 0.15s ease, background 0.15s ease;
}

.ghost:hover {
  border-color: var(--accent);
  background: var(--surface-3);
}

.danger {
  appearance: none;
  background: rgba(248, 113, 113, 0.1);
  border: 1px solid rgba(248, 113, 113, 0.4);
  color: #fca5a5;
  font-size: 12px;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
}

.danger:hover {
  background: rgba(248, 113, 113, 0.18);
}

.small.primary,
.small.ghost {
  padding: 6px 11px;
  font-size: 12px;
}

.row {
  display: flex;
  gap: 10px;
  align-items: flex-end;
  flex-wrap: wrap;
}

.row.tight {
  gap: 6px;
  align-items: center;
}

.stack {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  margin-top: 18px;
}

.form-grid .field.wide {
  grid-column: span 2;
}

.form-grid .field.full {
  grid-column: 1 / -1;
}

.form-grid .field select,
.form-grid .field input,
.form-grid .field textarea {
  min-width: 0;
  width: 100%;
}

.form-actions {
  grid-column: 1 / -1;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
}

/* ---------- status / notes ---------- */

.statusbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  padding: 11px 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--muted);
  font-size: 12px;
  min-height: 42px;
}

.statusbar.warn {
  border-color: rgba(248, 113, 113, 0.35);
  color: #fca5a5;
}

.statusbar .pill-strong {
  color: var(--text);
  font-weight: 650;
}

.statusbar .sep {
  opacity: 0.4;
}

.permission-note {
  padding: 11px 14px;
  border: 1px solid rgba(96, 165, 250, 0.3);
  border-radius: var(--radius-sm);
  background: rgba(96, 165, 250, 0.07);
  color: #bfdbfe;
  font-size: 12px;
  line-height: 1.5;
}

.access-note {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  padding: 11px 14px;
  border: 1px solid rgba(251, 191, 36, 0.28);
  border-radius: var(--radius-sm);
  background: rgba(251, 191, 36, 0.06);
  font-size: 12px;
  color: #fcd34d;
}

.access-note input {
  min-width: 140px;
  padding: 7px 10px;
}

/* ---------- views and panels ---------- */

.view {
  display: flex;
  flex-direction: column;
  gap: 14px;
  animation: view-in 0.18s ease-out;
}

@keyframes view-in {
  from {
    opacity: 0;
    transform: translateY(3px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

.context-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.context-hint {
  color: var(--muted);
  font-size: 12px;
}

.access {
  display: flex;
  padding: 3px;
  gap: 3px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
}

.access-btn {
  appearance: none;
  border: 1px solid transparent;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 12px;
  font-weight: 600;
  padding: 8px 13px;
  border-radius: 7px;
  transition: background 0.15s ease, color 0.15s ease;
}

.access-btn:hover {
  color: var(--text);
  background: var(--surface-2);
}

.access-btn.active {
  background: var(--accent-soft);
  border-color: color-mix(in srgb, var(--accent) 40%, transparent);
  color: var(--accent-strong);
}

.access-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 340px;
  gap: 14px;
  align-items: start;
}

.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.03);
}

.inventory {
  min-width: 0;
}

.inventory-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}

.section-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.section-note {
  font-size: 11px;
  color: var(--muted);
}

.side {
  display: flex;
  flex-direction: column;
  gap: 14px;
  min-width: 0;
}

/* ---------- container tabs ---------- */

.tabs {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--bg-soft);
}

.tab {
  appearance: none;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--muted);
  padding: 7px 12px;
  border-radius: 7px;
  font-size: 12.5px;
  font-weight: 600;
  transition: background 0.15s ease, color 0.15s ease;
}

.tab:hover {
  color: var(--text);
  background: var(--surface-2);
}

.tab.active {
  background: var(--surface-3);
  border-color: var(--line-strong);
  color: var(--text);
}

.tab.locked {
  opacity: 0.55;
}

.tab.drop-target {
  border-color: var(--ok);
  color: var(--ok);
}

.tab-meta {
  font-family: var(--mono);
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 1px 7px;
}

.tab.active .tab-meta {
  color: var(--accent-strong);
  border-color: color-mix(in srgb, var(--accent) 30%, transparent);
}

.capacity {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--muted);
}

/* ---------- grid ---------- */

.grid-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  padding: 14px 4px 2px;
  overflow: auto;
}

.grid {
  --cell: 46px;
  position: relative;
  flex: 0 0 auto;
  border-radius: 8px;
  background-color: #0b0e12;
  background-image:
    linear-gradient(to right, rgba(255, 255, 255, 0.055) 1px, transparent 1px),
    linear-gradient(to bottom, rgba(255, 255, 255, 0.055) 1px, transparent 1px);
  background-size: var(--cell) var(--cell);
  box-shadow:
    inset 0 0 0 1px #262d38,
    0 24px 60px -40px #000;
}

.grid-hint {
  color: var(--muted);
  font-size: 11px;
  text-align: center;
}

.locked {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  text-align: center;
  padding: 72px 24px;
  margin-top: 6px;
  border: 1px dashed var(--line-strong);
  border-radius: 10px;
  background: repeating-linear-gradient(
    -45deg,
    rgba(255, 255, 255, 0.015) 0 12px,
    transparent 12px 24px
  );
}

.locked h2 {
  font-size: 15px;
}

.locked p {
  color: var(--muted);
  font-size: 13px;
  max-width: 46ch;
  line-height: 1.55;
}

/* ---------- items ---------- */

.item {
  position: absolute;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1px;
  padding: 2px;
  border-radius: 7px;
  border: 1px solid color-mix(in srgb, var(--cat, #94a3b8) 38%, var(--line));
  background: color-mix(in srgb, var(--cat, #94a3b8) 13%, #12161c);
  color: var(--text);
  cursor: grab;
  overflow: hidden;
  user-select: none;
  transition: box-shadow 0.12s ease, border-color 0.12s ease;
}

.item:hover {
  border-color: color-mix(in srgb, var(--cat, #94a3b8) 65%, transparent);
  box-shadow: 0 0 0 1px color-mix(in srgb, var(--cat, #94a3b8) 30%, transparent);
}

.item.selected {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

.item.dragging {
  opacity: 0.4;
}

.item-icon {
  font-size: 17px;
  line-height: 1;
  pointer-events: none;
}

.item-image {
  display: block;
  flex: 1 1 auto;
  min-height: 0;
  width: 100%;
  max-height: 100%;
  padding: 2px;
  object-fit: contain;
  pointer-events: none;
}

.item-name {
  max-width: 100%;
  font-size: 8.5px;
  line-height: 1.1;
  text-align: center;
  color: #dfe6f0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  padding: 0 2px;
  pointer-events: none;
}

.item-qty {
  position: absolute;
  right: 3px;
  bottom: 2px;
  font-family: var(--mono);
  font-size: 9px;
  font-weight: 600;
  color: #0a0c12;
  background: color-mix(in srgb, var(--cat, #94a3b8) 78%, #fff);
  border-radius: 3px;
  padding: 0 3px;
  pointer-events: none;
}

.item-rot {
  position: absolute;
  left: 3px;
  top: 2px;
  font-size: 8px;
  font-weight: 600;
  color: var(--muted);
  pointer-events: none;
}

.cat-weapon { --cat: #fb923c; }
.cat-armor { --cat: #a78bfa; }
.cat-medical { --cat: #34d399; }
.cat-valuable { --cat: #fbbf24; }
.cat-tool { --cat: #38bdf8; }
.cat-key { --cat: #2dd4bf; }
.cat-food { --cat: #fb7185; }
.cat-ammo { --cat: #94a3b8; }
.cat-misc { --cat: #cbd5e1; }
.cat-supply { --cat: #e879f9; }

.drop-ghost {
  position: absolute;
  border: 1px dashed var(--ok);
  background: rgba(74, 222, 128, 0.12);
  border-radius: 7px;
  pointer-events: none;
  z-index: 5;
}

.drop-ghost.merge {
  border-color: var(--accent);
  background: rgba(124, 156, 255, 0.16);
}

.drop-ghost.blocked {
  border-color: var(--danger);
  background: rgba(248, 113, 113, 0.14);
}

/* ---------- selected item ---------- */

.detail {
  margin-top: 14px;
  font-size: 13px;
}

.detail.muted {
  color: var(--muted);
}

.detail-head {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  border-radius: 10px;
  border: 1px solid color-mix(in srgb, var(--cat, #94a3b8) 32%, var(--line));
  background: color-mix(in srgb, var(--cat, #94a3b8) 8%, var(--bg-soft));
  margin-bottom: 14px;
}

.detail-head .detail-icon {
  font-size: 22px;
  line-height: 1;
}

.detail-image {
  flex: 0 0 auto;
  width: 46px;
  height: 46px;
  object-fit: contain;
  border-radius: 6px;
}

.detail-head strong {
  display: block;
  font-size: 14px;
}

.detail-description {
  margin: -2px 0 12px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}

.kv {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin: 0 0 14px;
}

.kv div {
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
  background: var(--bg-soft);
}

.kv dt {
  font-size: 9px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}

.kv dd {
  margin: 3px 0 0;
  font-size: 13px;
  font-variant-numeric: tabular-nums;
}

#item-detail .ghost.small {
  width: 100%;
}

#detail-move {
  margin-top: 12px;
}

.staff-row {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}

.staff-row .field {
  flex: 1;
}

/* ---------- feed / activity ---------- */

.feed {
  margin: 14px 0 0;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #0a0d11;
  color: #a9c4e4;
  font-family: var(--mono);
  font-size: 11px;
  line-height: 1.7;
  max-height: 460px;
  min-height: 120px;
  overflow: auto;
  white-space: pre;
}

.activity {
  list-style: none;
  margin: 14px 0 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.activity li {
  display: flex;
  gap: 10px;
  align-items: baseline;
  font-size: 12px;
  color: #c8d2e0;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
  background: var(--bg-soft);
}

.activity li.muted {
  border-style: dashed;
  justify-content: center;
}

.activity-action {
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.06em;
  color: var(--accent-strong);
  background: var(--accent-soft);
  border-radius: 4px;
  padding: 2px 6px;
  flex: 0 0 auto;
}

/* ---------- permissions ---------- */

.access-summary {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--bg-soft);
}

.access-summary h2 {
  margin: 6px 0 4px;
  font-size: 18px;
}

.access-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 8px;
}

.access-item {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--bg-soft);
  opacity: 0.55;
}

.access-item.allowed {
  opacity: 1;
  border-color: color-mix(in srgb, var(--accent) 26%, var(--line));
  background: color-mix(in srgb, var(--accent) 6%, var(--bg-soft));
}

.access-mark {
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  font-size: 11px;
  font-weight: 700;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.05);
}

.access-item.allowed .access-mark {
  color: #0a0c12;
  background: var(--ok);
}

.access-copy {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.access-copy strong {
  font-size: 12.5px;
  font-weight: 600;
}

.role-columns {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px;
  margin-top: 4px;
}

.role-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
  max-height: 320px;
  margin: 10px 0 4px;
  overflow: auto;
  padding-right: 4px;
}

.role-option {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--bg-soft);
  color: #cbd5e1;
  font-size: 12px;
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease;
}

.role-option:hover {
  border-color: var(--line-strong);
  background: var(--surface-2);
}

.role-option input {
  accent-color: var(--accent);
}

.role-dot {
  flex: 0 0 auto;
  width: 8px;
  height: 8px;
  border-radius: 50%;
}

.toggle-row {
  display: flex;
  align-items: flex-start;
  gap: 9px;
  margin: 16px 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.toggle-row input {
  margin-top: 2px;
  accent-color: var(--accent);
}

#save-roles {
  width: 100%;
  max-width: 260px;
}

#access-hint {
  margin-top: 12px;
}

/* ---------- world pairing ---------- */

.otp-box {
  margin-top: 16px;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  align-items: flex-start;
  border: 1px dashed color-mix(in srgb, var(--accent) 45%, transparent);
  border-radius: 10px;
  background: var(--accent-soft);
  max-width: 340px;
}

.otp-label {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.09em;
  color: var(--muted);
}

.otp-value {
  font-family: var(--mono);
  font-size: 30px;
  line-height: 1.1;
  letter-spacing: 0.16em;
  color: var(--accent-strong);
}

.world-list {
  list-style: none;
  margin: 12px 0 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 280px;
  overflow: auto;
}

.world-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--bg-soft);
}

.world-row-copy {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.world-row-copy strong {
  font-size: 12.5px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ---------- image preview ---------- */

.image-preview {
  grid-column: 1 / -1;
  padding: 12px;
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius-sm);
  background: var(--bg-soft);
  text-align: center;
}

.image-preview img {
  display: block;
  max-width: 100%;
  max-height: 140px;
  margin: 0 auto;
  object-fit: contain;
  border-radius: 6px;
}

/* ---------- toasts ---------- */

.toast-host {
  position: fixed;
  right: 20px;
  bottom: 20px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 50;
  max-width: min(420px, calc(100vw - 40px));
}

.toast {
  border: 1px solid var(--line-strong);
  background: var(--surface-2);
  color: var(--text);
  border-radius: 10px;
  padding: 12px 15px;
  font-size: 12.5px;
  line-height: 1.45;
  box-shadow: 0 22px 50px -26px #000;
  animation: toast-in 0.18s ease-out;
}

.toast.ok {
  border-color: rgba(74, 222, 128, 0.4);
  background: #0f1c15;
  color: #bbf7d0;
}

.toast.error {
  border-color: rgba(248, 113, 113, 0.45);
  background: #1f1214;
  color: #fecaca;
}

.toast.leaving {
  opacity: 0;
  transition: opacity 0.22s ease;
}

@keyframes toast-in {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

/* ---------- login ---------- */

.login-view {
  min-height: calc(100vh - 70px);
  display: grid;
  place-items: center;
}

.login-card {
  width: min(440px, 100%);
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 26px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--surface);
  box-shadow: 0 40px 100px -60px #000;
}

.login-card h2 {
  margin-top: 4px;
  font-size: 21px;
}

.login-lead {
  font-size: 13px;
  line-height: 1.6;
}

.discord-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 16px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 10px;
  background: #5865f2;
  color: #fff;
  font-size: 14px;
  font-weight: 650;
  text-decoration: none;
}

.discord-button:hover {
  filter: brightness(1.08);
}

.discord-button.is-disabled {
  opacity: 0.5;
}

.login-error {
  padding: 10px 12px;
  border: 1px solid rgba(248, 113, 113, 0.45);
  border-radius: var(--radius-sm);
  background: rgba(248, 113, 113, 0.1);
  color: #fecaca;
  font-size: 12.5px;
  line-height: 1.5;
}

.setup {
  display: flex;
  flex-direction: column;
  gap: 9px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
  color: #c3cbd8;
  font-size: 12.5px;
  line-height: 1.55;
}

.setup code {
  padding: 1px 5px;
  border: 1px solid var(--line);
  border-radius: 5px;
  background: var(--bg-soft);
  font-family: var(--mono);
  font-size: 11.5px;
}

.setup-code {
  display: block;
  padding: 9px 10px;
  border: 1px dashed var(--line-strong);
  border-radius: 7px;
  background: var(--bg-soft);
  color: #a9c4e4;
  font-family: var(--mono);
  font-size: 11.5px;
  word-break: break-all;
}

.setup a {
  color: var(--accent-strong);
}

.login-user {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
}

/* ---------- responsive ---------- */

@media (max-width: 1120px) {
  .layout {
    grid-template-columns: minmax(0, 1fr);
  }

  .side {
    display: grid;
    grid-template-columns: 1fr;
    align-items: start;
  }
}

@media (max-width: 880px) {
  .form-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .form-grid .field.wide {
    grid-column: 1 / -1;
  }

  .role-columns {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 760px) {
  body {
    padding: 16px 14px 40px;
  }

  .topbar-controls {
    width: 100%;
  }

  .topbar-controls .field {
    flex: 1;
  }

  .field select {
    min-width: 0;
    width: 100%;
  }

  .identity {
    width: 100%;
    padding-left: 0;
    border-left: 0;
    padding-top: 12px;
    border-top: 1px solid var(--line);
  }

  .identity-copy {
    flex: 1;
  }

  .access {
    width: 100%;
    overflow-x: auto;
  }

  .access-btn {
    flex: 1 0 auto;
  }

  .grid-wrap {
    align-items: flex-start;
  }

  .form-grid {
    grid-template-columns: minmax(0, 1fr);
  }

  .field.narrow {
    width: 100%;
  }

  .batch-layout {
    grid-template-columns: minmax(0, 1fr);
  }
}

/* ---------- account link gate ---------- */

.link-gate {
  display: flex;
  flex-direction: column;
  gap: 14px;
  border-color: color-mix(in srgb, var(--accent) 30%, var(--line));
  background:
    linear-gradient(180deg, rgba(124, 156, 255, 0.05), transparent 60%),
    var(--surface);
}

.link-gate-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.link-gate-head h2 {
  margin-top: 6px;
  font-size: 18px;
}

.link-gate .otp-box {
  margin-top: 0;
}

/* ---------- character servers ---------- */

.inline-select {
  appearance: none;
  background: var(--bg-soft);
  border: 1px solid var(--line-strong);
  color: var(--text);
  border-radius: var(--radius-sm);
  padding: 7px 10px;
  font: inherit;
  font-size: 12px;
  min-width: 180px;
}

.inline-select:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

/* ---------- batch catalog editing ---------- */

.batch-layout {
  display: grid;
  grid-template-columns: minmax(240px, 320px) minmax(0, 1fr);
  gap: 18px;
  margin-top: 18px;
  align-items: start;
}

.batch-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 0;
}

.definition-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
  max-height: 520px;
  overflow: auto;
  padding-right: 4px;
}

.definition-option {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--bg-soft);
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease;
}

.definition-option:hover {
  border-color: var(--line-strong);
  background: var(--surface-2);
}

.definition-option input {
  accent-color: var(--accent);
}

.definition-icon {
  width: 20px;
  font-size: 16px;
  line-height: 1;
  text-align: center;
}

.definition-copy {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.definition-copy strong {
  font-size: 12.5px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.batch-form {
  margin-top: 0;
}

@media (max-width: 880px) {
  .batch-layout {
    grid-template-columns: minmax(0, 1fr);
  }
}

/* ---------- link account, catalog tools, analytics, audit, backups ---------- */

.link-account {
  margin-top: 18px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-2);
}

.link-account-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 14px;
}

.link-account-head strong {
  display: block;
  font-size: 15px;
}

.link-account .row {
  margin-top: 0;
}

.link-account .otp-box {
  margin-top: 12px;
}

.catalog-toolbar {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 150px;
  gap: 8px;
  margin-bottom: 10px;
}

.catalog-toolbar input,
.catalog-toolbar select {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  background: var(--surface-3);
  color: var(--text);
  font: inherit;
}

.catalog-toolbar input:focus,
.catalog-toolbar select:focus {
  outline: 2px solid var(--accent-soft);
  border-color: var(--accent);
}

.file-button {
  display: inline-flex;
  align-items: center;
  cursor: pointer;
}

.definition-option {
  align-items: flex-start;
}

.definition-actions {
  margin-left: auto;
  display: flex;
  gap: 6px;
  flex-shrink: 0;
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(128px, 1fr));
  gap: 10px;
  margin: 14px 0;
}

.metric {
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
}

.metric span {
  display: block;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
}

.metric strong {
  display: block;
  margin-top: 4px;
  font-size: 21px;
  letter-spacing: -0.02em;
}

.bar-chart {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin: 10px 0 18px;
}

.bar-row {
  display: grid;
  grid-template-columns: 78px minmax(0, 1fr) 48px;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--muted);
}

.bar-track {
  height: 8px;
  border-radius: 999px;
  background: var(--surface-3);
  overflow: hidden;
}

.bar-fill {
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--accent), var(--accent-strong));
}

.bar-fill.alt {
  background: linear-gradient(90deg, #4ade80, #a7f3d0);
}

.audit-detail {
  display: block;
  margin-top: 4px;
  font-family: var(--mono);
  font-size: 11px;
  color: var(--muted);
  word-break: break-word;
}

.system-line {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 18px;
  padding: 12px 14px;
  margin-bottom: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  font-size: 12px;
  color: var(--muted);
}

.system-line strong {
  color: var(--text);
  font-weight: 600;
}

.row.tight {
  flex-wrap: wrap;
}

@media (max-width: 760px) {
  .catalog-toolbar {
    grid-template-columns: 1fr;
  }

  .definition-actions {
    width: 100%;
    justify-content: flex-end;
  }

  .bar-row {
    grid-template-columns: 62px minmax(0, 1fr) 40px;
  }
}

.form-grid .toggle-row.full {
  grid-column: 1 / -1;
}

/* ---------- world installer page ---------- */

.installer-body {
  max-width: 1180px;
  margin: 0 auto;
}

.install-topbar {
  position: static;
}

.install-topbar .brand {
  text-decoration: none;
}

.install-main {
  display: flex;
  flex-direction: column;
  gap: 16px;
  margin-top: 22px;
}

.install-hero {
  padding: 6px 2px 2px;
}

.install-hero h1 {
  margin: 6px 0 8px;
  font-size: clamp(26px, 4vw, 38px);
  letter-spacing: -0.02em;
}

.install-hero p {
  max-width: 760px;
  line-height: 1.55;
}

.install-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 14px;
}

.install-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 16px;
}

.install-config {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.install-config .section-head {
  margin-bottom: 2px;
}

.install-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-top: 4px;
}

.install-endpoint {
  margin: 0;
  font-family: var(--mono);
  font-size: 11px;
  color: var(--accent-strong);
  word-break: break-all;
}

.install-files {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.install-files li {
  display: flex;
  flex-direction: column;
  gap: 3px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
}

.install-files code {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--accent-strong);
}

.install-files span {
  font-size: 12px;
  color: var(--muted);
}

.install-list {
  margin: 0;
  padding-left: 18px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.7;
}

.install-steps {
  margin: 4px 0 0;
  padding-left: 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  color: var(--muted);
  line-height: 1.6;
}

.install-steps strong {
  color: var(--text);
}

.install-note {
  margin: 12px 0 0;
  padding-left: 12px;
  border-left: 2px solid var(--accent);
  color: var(--muted);
  line-height: 1.6;
}

.install-footer {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 10px;
  margin-top: 26px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 12px;
}

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

  .install-topbar {
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
  }
}

/* ---------- world view URL ---------- */

.world-url-block {
  margin-top: 18px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  padding-top: 16px;
}

.world-url-value {
  width: 100%;
  word-break: break-all;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.72rem;
}

/* ---------- staff VRChat linking ---------- */

.link-form {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
  align-items: end;
  margin-bottom: 16px;
}

.link-form button {
  justify-self: start;
}
