:root {
  color-scheme: dark;
  --bg: #080a0f;
  --panel: #10141d;
  --panel-2: #151b26;
  --line: #293242;
  --text: #e8edf7;
  --muted: #8d9aad;
  --green: #24c58a;
  --cyan: #21a8ff;
  --yellow: #d6b94d;
  --red: #e05c65;
  --gray: #6e7685;
  --purple: #a070ff;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
}

button,
input,
select {
  font: inherit;
}

button {
  border: 1px solid var(--cyan);
  border-radius: 6px;
  background: #12344d;
  color: var(--text);
  cursor: pointer;
  padding: 0.65rem 0.8rem;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

button.ghost {
  border-color: var(--line);
  background: #111722;
  color: var(--muted);
}

button.selected {
  border-color: var(--green);
  background: #103827;
}

input,
select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #090d14;
  color: var(--text);
  padding: 0.65rem 0.7rem;
}

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

.app-shell {
  padding: 1rem;
}

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

.top-bar h1 {
  font-size: clamp(1.4rem, 2vw, 2rem);
}

.room-meta,
.legend,
.score-line,
.vote-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.room-meta span,
.chip,
.legend-item {
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #0c111a;
  color: var(--muted);
  padding: 0.25rem 0.5rem;
  font-size: 0.78rem;
}

.eyebrow,
.muted {
  color: var(--muted);
  font-size: 0.82rem;
}

.hidden {
  display: none !important;
}

.gate {
  display: grid;
  gap: 1rem;
  max-width: 560px;
  margin: 12vh auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  padding: 1rem;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(280px, 360px) 1fr;
  gap: 1rem;
  padding-top: 1rem;
}

.control-rail,
.main-stage,
.stack,
.list,
.identity-list,
.status-tools,
.window-list,
.block-list,
.vote-list {
  display: grid;
  gap: 0.75rem;
}

.panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  padding: 0.85rem;
}

.panel-header,
.member-title,
.window-title,
.list-row,
.block-row,
.vote-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}

.panel-header {
  margin-bottom: 0.75rem;
}

.inline-form {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0.5rem;
}

.compact {
  margin-top: 0.6rem;
}

.grid-form {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.7rem;
}

.grid-form label {
  display: grid;
  gap: 0.35rem;
  color: var(--muted);
  font-size: 0.78rem;
}

.data-actions {
  display: grid;
  gap: 0.5rem;
}

.import-button {
  display: grid;
  place-items: center;
  min-height: 42px;
  border: 1px solid var(--cyan);
  border-radius: 6px;
  background: #12344d;
  color: var(--text);
  cursor: pointer;
  padding: 0.65rem 0.8rem;
  text-align: center;
}

.import-button input {
  display: none;
}

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

.token-box {
  overflow-wrap: anywhere;
}

.token-box code {
  display: block;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #080d14;
  margin: 0.35rem 0;
  padding: 0.5rem;
}

.identity-list {
  grid-template-columns: 1fr 1fr;
}

.identity-button,
.status-tool {
  min-height: 42px;
  text-align: center;
}

.locked-identity {
  display: flex;
  align-items: center;
  justify-content: space-between;
  border: 1px solid var(--cyan);
  border-radius: 6px;
  background: #0c1724;
  padding: 0.7rem;
}

.status-tools {
  grid-template-columns: 1fr 1fr;
}

.status-tool {
  border-color: var(--line);
  color: #04070b;
  font-weight: 800;
}

.status-tool.is-selected {
  outline: 2px solid var(--text);
  outline-offset: 2px;
}

.schedule-panel {
  min-width: 0;
}

.schedule-grid {
  display: grid;
  grid-template-columns: 84px repeat(7, minmax(44px, 1fr));
  max-height: 62vh;
  overflow: auto;
  border: 1px solid var(--line);
  background: #080d14;
  user-select: none;
}

.grid-head,
.time-cell,
.slot-cell {
  min-height: 24px;
  border-right: 1px solid #17202d;
  border-bottom: 1px solid #17202d;
  padding: 0.2rem 0.3rem;
  font-size: 0.72rem;
}

.grid-head {
  position: sticky;
  top: 0;
  z-index: 2;
  background: var(--panel-2);
  color: var(--muted);
}

.time-cell {
  position: sticky;
  left: 0;
  z-index: 1;
  background: #0b1018;
  color: var(--muted);
}

.time-head {
  left: 0;
  z-index: 3;
}

.slot-cell {
  display: grid;
  place-items: center;
  color: #020403;
  font-weight: 700;
  width: 100%;
  min-height: 24px;
  border-top: 0;
  border-left: 0;
  border-radius: 0;
  cursor: crosshair;
  padding: 0;
  touch-action: none;
}

.slot-cell:disabled {
  cursor: not-allowed;
  opacity: 1;
}

.slot-cell.own-status {
  box-shadow: inset 0 0 0 2px #f4f7fb;
}

.slot-cell.own-working,
.slot-cell.own-busy {
  box-shadow: inset 0 0 0 2px #11151d, inset 0 0 0 4px #f4f7fb;
}

.slot-cell.is-painting {
  outline: 2px solid var(--text);
  outline-offset: -2px;
}

.split {
  display: grid;
  grid-template-columns: minmax(280px, 0.85fr) minmax(320px, 1.15fr);
  gap: 1rem;
}

.member-card,
.window-card,
.list-row {
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #0c111a;
  padding: 0.7rem;
}

.member-card.is-active {
  border-color: var(--cyan);
}

.range-group,
.vote-row {
  border-radius: 6px;
  padding: 0.4rem 0.45rem;
  font-size: 0.78rem;
}

.range-group {
  border: 1px solid var(--line);
  background: #080d14;
}

.range-group-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 0.45rem;
}

.range-chip-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

.range-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  border: 1px solid color-mix(in srgb, currentColor 30%, var(--line));
  border-radius: 999px;
  color: #020403;
  font-weight: 800;
  line-height: 1.2;
  padding: 0.28rem 0.35rem 0.28rem 0.5rem;
}

.range-chip button {
  display: grid;
  width: 20px;
  height: 20px;
  place-items: center;
  border: 1px solid #0f1623;
  border-radius: 50%;
  background: #0a111c;
  color: var(--text);
  line-height: 1;
  padding: 0;
}

.vote-row {
  display: grid;
  grid-template-columns: 1fr auto auto;
}

.status-available {
  background: color-mix(in srgb, var(--green) 72%, #0c111a);
}

.status-preferred {
  background: color-mix(in srgb, var(--cyan) 72%, #0c111a);
}

.status-maybe {
  background: color-mix(in srgb, var(--yellow) 72%, #0c111a);
}

.status-working {
  background: color-mix(in srgb, var(--red) 70%, #0c111a);
}

.status-busy {
  background: color-mix(in srgb, var(--gray) 75%, #0c111a);
}

.status-empty {
  background: #0b1018;
  color: var(--muted);
}

@media (max-width: 980px) {
  .workspace,
  .split {
    grid-template-columns: 1fr;
  }

  .top-bar,
  .panel-header,
  .inline-form,
  .vote-row {
    align-items: stretch;
    flex-direction: column;
    grid-template-columns: 1fr;
  }

  .schedule-grid {
    grid-template-columns: 76px repeat(7, minmax(38px, 1fr));
  }
}
