:root {
  --ground: #f2f6f5;
  --surface: #ffffff;
  --raised: #edf2f1;
  --active: #e5ebea;
  --border: #e3e8e7;
  --control: #c4cdcb;
  --text: #131716;
  --muted: #59615f;
  --accent: #176c80;
  --radius-card: 8px;
  --radius-control: 6px;
  --radius-sheet: 16px;
  --gap: 12px;
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

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

body {
  background: var(--ground);
  color: var(--text);
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 14px;
  line-height: 1.45;
}

button, input, select { font: inherit; }

button, input, select {
  border: 1px solid var(--control);
  border-radius: var(--radius-control);
  min-height: 36px;
}

button {
  cursor: pointer;
  background: #1d2221;
  color: #fff;
  padding: 0 16px;
  font-weight: 600;
}

button:hover { background: #343a38; }
button:active { transform: translateY(1px); }
button:focus-visible, input:focus-visible, select:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.secondary-button { background: var(--surface); color: var(--text); }
.secondary-button:hover { background: var(--active); }

.start-screen {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.start-sheet {
  width: min(460px, 100%);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sheet);
  padding: 40px;
}

.start-sheet h1 { margin: 22px 0 8px; font-size: 28px; line-height: 1.1; }
.start-sheet > p { margin: 0 0 28px; color: var(--muted); }
.start-sheet form { display: grid; gap: 9px; }
.start-sheet input { padding: 0 12px; margin-bottom: 8px; }

.brand-mark { display: flex; align-items: end; gap: 4px; width: 34px; height: 28px; }
.brand-mark span { display: block; width: 8px; background: var(--accent); border-radius: 4px 4px 1px 1px; }
.brand-mark span:nth-child(1) { height: 16px; }
.brand-mark span:nth-child(2) { height: 27px; }
.brand-mark span:nth-child(3) { height: 21px; }
.brand-mark.small { width: 25px; height: 22px; gap: 3px; }
.brand-mark.small span { width: 6px; }
.brand-mark.small span:nth-child(1) { height: 12px; }
.brand-mark.small span:nth-child(2) { height: 21px; }
.brand-mark.small span:nth-child(3) { height: 16px; }

.prototype-note { color: var(--muted); font-size: 12px; }
.start-sheet .prototype-note { margin: 24px 0 0; }

.editor { min-height: 100vh; }

.top-bar {
  height: 48px;
  padding: 0 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.wordmark, .room-actions { display: flex; align-items: center; gap: 12px; }
.wordmark h1 { margin: 0; font-size: 16px; font-weight: 650; }
.status, .sequence-status {
  color: var(--muted);
  background: var(--active);
  border-radius: 999px;
  padding: 3px 9px;
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}
.status.connected { color: #175b3d; background: #dcfae5; }
.status.error { color: #831c1e; background: #ffedea; }
.room-label { color: var(--muted); font-size: 12px; }

.workspace {
  height: calc(100vh - 48px);
  display: grid;
  grid-template-columns: 228px minmax(0, 1fr);
  gap: var(--gap);
  padding: 0 8px 8px;
}

.palette, .canvas-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sheet);
}

.palette {
  padding: 18px 16px;
  display: flex;
  flex-direction: column;
  gap: 28px;
  overflow: auto;
}

.palette section { display: grid; gap: 8px; }
.palette h2, .canvas-heading h2 { margin: 0; font-size: 16px; }
.palette label { color: var(--muted); margin-top: 6px; }
.palette select { background: var(--surface); padding: 0 10px; color: var(--text); }
.palette input[type="range"] { min-height: 28px; width: 100%; accent-color: var(--accent); }
.palette input[type="color"] { width: 100%; padding: 3px; background: var(--surface); }
.palette output { float: right; color: var(--text); font-variant-numeric: tabular-nums; }
.palette .prototype-note { margin-top: auto; }

.painter-list { list-style: none; padding: 0; margin: 0; display: grid; gap: 4px; }
.painter-list li { display: flex; align-items: center; gap: 9px; min-height: 32px; }
.painter-dot { width: 9px; height: 9px; border-radius: 50%; flex: none; }
.painter-list .you { color: var(--muted); font-size: 12px; margin-left: auto; }

.canvas-panel {
  min-width: 0;
  padding: 18px;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  gap: 16px;
}

.canvas-heading { display: flex; align-items: start; justify-content: space-between; gap: 16px; }
.canvas-heading p { margin: 4px 0 0; color: var(--muted); }
.canvas-host {
  min-height: 0;
  overflow: hidden;
  background: var(--raised);
  border-radius: var(--radius-card);
  touch-action: none;
  position: relative;
}
.canvas-host canvas { display: block; width: 100%; height: 100%; cursor: crosshair; }

@media (max-width: 760px) {
  .top-bar { height: auto; min-height: 56px; flex-wrap: wrap; padding: 8px 12px; }
  .room-label { display: none; }
  .workspace {
    height: auto;
    min-height: calc(100vh - 56px);
    grid-template-columns: 1fr;
    padding: 0;
  }
  .canvas-panel { order: 1; border-radius: 0; min-height: 68vh; padding: 14px; }
  .palette { order: 2; border-radius: 0; display: grid; grid-template-columns: 1fr 1fr; }
  .palette .prototype-note { grid-column: 1 / -1; }
  .canvas-heading p, .sequence-status { display: none; }
  .start-sheet { padding: 28px 22px; }
}
