:root {
  --bg: #090d12;
  --bg-soft: #0f151f;
  --panel: #131b27;
  --panel-2: #1a2332;
  --line: #2b3750;
  --text: #e7eef9;
  --muted: #95a4bd;
  --accent: #2dd4bf;
  --accent-2: #38bdf8;
  --danger: #f87171;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "IBM Plex Sans", "Segoe UI", sans-serif;
  color: var(--text);
  background:
    radial-gradient(900px 420px at 0% -10%, #1b2d3f 0%, transparent 65%),
    radial-gradient(1000px 500px at 100% 110%, #183f50 0%, transparent 70%),
    var(--bg);
}

.page {
  width: min(1100px, 100% - 32px);
  margin: 24px auto;
}

.panel {
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.02), transparent), var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: 0 20px 48px rgba(0, 0, 0, 0.35);
}

.header {
  padding: 20px 22px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--line);
}

h1, h2, h3, p {
  margin: 0;
}

h1 {
  font-family: "IBM Plex Mono", "Cascadia Code", monospace;
  font-size: 1.35rem;
}

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

.button {
  display: inline-block;
  text-decoration: none;
  border: 0;
  border-radius: 10px;
  padding: 10px 14px;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}

.button-primary {
  color: #07221f;
  background: var(--accent);
}

.button-primary:hover,
.button-primary:focus-visible {
  background: #23bca8;
}

.button-soft {
  color: var(--text);
  background: var(--panel-2);
  border: 1px solid var(--line);
}

.button-soft:hover,
.button-soft:focus-visible {
  background: #202b3d;
}

.button-danger {
  color: #fff;
  background: #992f3a;
}

.button-danger:hover,
.button-danger:focus-visible {
  background: #7f2630;
}

.grid {
  display: grid;
  gap: 14px;
}

.grid-cards {
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  padding: 18px;
}

.card {
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--panel-2);
  padding: 16px;
}

.card p {
  margin-top: 8px;
  margin-bottom: 14px;
}

.form-wrap {
  width: min(860px, 100% - 32px);
  margin: 24px auto;
}

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  padding: 18px;
}

.field label {
  display: block;
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 0.9rem;
}

.field input,
.field select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px;
  color: var(--text);
  background: #0f151f;
}

.actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 12px;
}

.table {
  width: 100%;
  border-collapse: collapse;
}

.table th,
.table td {
  border-bottom: 1px solid var(--line);
  padding: 10px;
  text-align: left;
  font-size: 0.92rem;
  vertical-align: top;
}

.table-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.status-pill {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 5px 10px;
  font-size: 0.82rem;
  color: var(--muted);
}

.layout-editor {
  display: grid;
  grid-template-columns: auto 260px;
  gap: 16px;
  padding: 16px;
}

#grid {
  display: grid;
  grid-template-columns: repeat(16, 22px);
  grid-template-rows: repeat(16, 22px);
  gap: 2px;
  border: 1px solid #2c3b52;
  background: #000;
  padding: 4px;
}

.cell {
  width: 22px;
  height: 22px;
  background: #000;
  border: 1px solid #1c2534;
  cursor: crosshair;
}

.editor-side {
  display: grid;
  gap: 12px;
  align-content: start;
}

.presence-list {
  display: grid;
  gap: 8px;
}

.presence-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.02);
}

.scene-list {
  max-height: 290px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 10px;
}

.scene-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border-bottom: 1px solid var(--line);
}

.scene-item:last-child {
  border-bottom: 0;
}

@media (max-width: 900px) {
  .layout-editor {
    grid-template-columns: 1fr;
  }

  #grid {
    grid-template-columns: repeat(16, 1fr);
    grid-template-rows: repeat(16, 1fr);
    width: min(calc(100vw - 64px), 560px);
    aspect-ratio: 1 / 1;
  }

  .cell {
    width: 100%;
    aspect-ratio: 1;
    height: 100%;
  }

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