:root {
  color-scheme: light;
  font: 14px/1.5 system-ui, sans-serif;
  color: #202337;
  background: #f2f3f8;
  --line: #dde0eb;
  --accent: #493abb;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; }
button, input { font: inherit; }
button {
  border: 1px solid var(--line);
  background: white;
  color: inherit;
  border-radius: 7px;
  padding: .42rem .7rem;
  cursor: pointer;
}
button[aria-pressed="true"] { background: #ebe8ff; border-color: #aa9ff1; color: #3828a0; }
button:disabled { opacity: .5; cursor: default; }
.room-header, .toolbar, .sidebar, .chat { background: white; }
.room-header, .room-header > div, .toolbar, fieldset, .view-tools {
  display: flex; align-items: center; gap: .65rem;
}
.room-header { justify-content: space-between; padding: .8rem 1.2rem; border-bottom: 1px solid var(--line); }
.brand { color: var(--accent); font-weight: 800; }
h1, h2 { margin: 0; font-size: 1rem; }
.connection { color: #494d65; }
.workspace { display: grid; grid-template-columns: minmax(0, 1fr) 270px; grid-template-areas: "drawing sidebar" "chat sidebar"; grid-template-rows: minmax(0, 1fr) auto; min-height: calc(100dvh - 54px); }
.drawing { grid-area: drawing; display: flex; flex-direction: column; min-width: 0; }
.toolbar { flex-wrap: wrap; padding: .6rem .8rem; border-bottom: 1px solid var(--line); }
fieldset { border: 0; padding: 0; margin: 0; min-width: 0; }
fieldset label { display: flex; align-items: center; gap: .3rem; }
#color { width: 30px; height: 26px; padding: 0; }
#scale { min-width: 3.2rem; text-align: center; font-variant-numeric: tabular-nums; }
.viewport { position: relative; overflow: hidden; flex: 1; min-height: 360px; touch-action: none; background: #e9ebf3; }
.canvas-stack {
  position: absolute; top: 50%; left: 50%;
  background: white; box-shadow: 0 4px 24px #20233729; cursor: crosshair;
}
.viewport[data-locked="true"] .canvas-stack { cursor: wait; }
.canvas-stack canvas { position: absolute; inset: 0; pointer-events: none; }
.canvas-stack[data-rotating="true"] { cursor: grab; }
.sidebar { grid-area: sidebar; border-left: 1px solid var(--line); display: flex; flex-direction: column; gap: 1rem; padding: 1rem; }
.layers { display: grid; gap: .25rem; margin-top: .6rem; }
.chat { grid-area: chat; display: flex; flex-direction: column; padding: .75rem 1rem; border-top: 1px solid var(--line); min-width: 0; }
#messages { overflow: auto; height: clamp(90px, 16dvh, 180px); padding: 0; list-style: none; overflow-wrap: anywhere; }
#messages li { padding: .4rem 0; border-bottom: 1px solid var(--line); white-space: pre-wrap; }
#chat-form { display: flex; gap: .4rem; }
#chat-text { min-width: 0; flex: 1; border: 1px solid var(--line); border-radius: 7px; padding: .4rem; }
.cursor { position: absolute; width: 9px; height: 9px; border-radius: 50%; transform: translate(-50%, -50%); background: #493abb; outline: 1px solid white; pointer-events: none; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
@media (max-width: 750px) {
  .workspace { grid-template-columns: minmax(0, 1fr); grid-template-areas: "drawing" "chat" "sidebar"; grid-template-rows: auto; }
  .sidebar { border-left: 0; }
  .viewport { min-height: 55dvh; }
  .view-tools { flex-wrap: wrap; }
}
.room-header { flex-wrap: wrap; }
body[data-archive="true"] .canvas-stack { cursor: default; }
body[data-archive="true"] .canvas-stack[data-rotating="true"] { cursor: grab; }

.layer-row { display: grid; grid-template-columns: auto 1fr; align-items: center; gap: .5rem; }
.layer-row button { text-align: left; }
.viewport[data-panning="true"], .viewport[data-panning="true"] .canvas-stack { cursor: grab; }
.viewport[data-panning="true"]:active, .viewport[data-panning="true"]:active .canvas-stack { cursor: grabbing; }

#color-tools { display: grid; gap: .4rem; margin-top: .5rem; }
#color-palette { display: block; width: 100%; max-width: 240px; height: auto; aspect-ratio: 1; touch-action: none; border-radius: 6px; cursor: crosshair; }
#color-tools:disabled #color-palette { cursor: default; }
.color-actions { display: flex; align-items: center; justify-content: space-between; gap: .5rem; }
#color-tools .slider-row { display: grid; grid-template-columns: 1rem minmax(0, 1fr) 2.2rem; gap: .4rem; }
.slider-row input { min-width: 0; width: 100%; margin: 0; accent-color: var(--accent); }
.slider-row output { font-variant-numeric: tabular-nums; text-align: right; }
.canvas-stack[data-eyedropper="true"] { cursor: copy; }
.leave-room {
  display: inline-block; border: 1px solid var(--line); border-radius: 7px;
  padding: .42rem .7rem; color: inherit; text-decoration: none; white-space: nowrap;
}
.leave-room:hover { background: #f2f3f8; }

#color-tools .width-row { grid-template-columns: 2.2rem minmax(0, 1fr) 2.2rem; margin-top: .3rem; }
#drawing-tools { display: grid; gap: .25rem; margin-top: .85rem; }
#drawing-tools legend { font-weight: 600; margin-bottom: .4rem; padding: 0; }
#drawing-tools button { text-align: left; }

#shortcuts-dialog {
  width: min(440px, calc(100% - 2rem)); max-height: calc(100dvh - 2rem);
  border: 1px solid var(--line); border-radius: 12px; padding: 1rem; color: inherit;
}
#shortcuts-dialog::backdrop { background: #1b193b80; }
#shortcut-list { display: grid; gap: .4rem; margin-top: .7rem; }
.shortcut-row { display: grid; grid-template-columns: minmax(0, 1fr) 5rem; align-items: center; gap: .5rem; }
.shortcut-row select { font: inherit; padding: .25rem; border: 1px solid var(--line); border-radius: 5px; }
.shortcut-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: .4rem; }
#shortcut-error { color: #a52036; margin: .5rem 0; }
