:root {
  --ink: #242424;
  --muted: #6e6a63;
  --paper: #fffdf8;
  --wash: #f4f5f0;
  --line: #dedbd2;
  --teal: #0f7b78;
  --coral: #df5b48;
  --gold: #c99728;
  --green: #4d8b57;
  --violet: #7963a7;
  --shadow: 0 18px 50px rgba(48, 43, 34, 0.12);
  color-scheme: light;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

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

body {
  margin: 0;
  background:
    linear-gradient(120deg, rgba(15, 123, 120, 0.06), transparent 38%),
    linear-gradient(300deg, rgba(223, 91, 72, 0.07), transparent 34%),
    var(--wash);
  color: var(--ink);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
}

button,
input {
  font: inherit;
}

button {
  cursor: pointer;
}

button:focus-visible,
input:focus-visible,
canvas:focus-visible {
  outline: 3px solid rgba(15, 123, 120, 0.42);
  outline-offset: 2px;
}

.app {
  display: block;
  position: relative;
  height: 100svh;
  min-height: 100svh;
  overflow: hidden;
}

.left-rail {
  position: fixed;
  top: 0;
  bottom: 0;
  z-index: 50;
  display: flex;
  flex-direction: column;
  gap: 18px;
  width: min(360px, calc(100vw - 52px));
  min-width: 0;
  min-height: 0;
  max-height: 100svh;
  overflow: auto;
  padding: max(18px, env(safe-area-inset-top)) 18px max(18px, env(safe-area-inset-bottom));
  border: 0;
  background: rgba(255, 253, 248, 0.98);
  box-shadow: var(--shadow);
  transition: transform 180ms ease;
}

.left-rail {
  left: 0;
  transform: translateX(-105%);
}

body.drawer-setup-open .left-rail {
  transform: translateX(0);
}

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

.brand-mark {
  display: grid;
  width: 44px;
  height: 44px;
  place-items: center;
  border: 2px solid var(--ink);
  border-radius: 12px;
  background:
    linear-gradient(135deg, rgba(15, 123, 120, 0.18), transparent 55%),
    linear-gradient(315deg, rgba(223, 91, 72, 0.2), transparent 48%),
    var(--paper);
  font-weight: 900;
  letter-spacing: 0;
}

.brand h1,
.studio-header h2,
.section-heading h2 {
  margin: 0;
  letter-spacing: 0;
}

.brand h1 {
  font-size: 1.3rem;
  line-height: 1.1;
}

.brand p,
.eyebrow,
.section-heading span,
.room-code {
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.brand p {
  margin: 4px 0 0;
}

.control-section {
  display: grid;
  gap: 12px;
}

.identity-control {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  gap: 10px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
}

.identity-control input {
  min-width: 0;
  height: 38px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--paper);
  color: var(--ink);
  font-weight: 750;
}

.session-status,
.empty-hosts {
  margin: 0;
  color: var(--muted);
  font-size: 0.78rem;
  line-height: 1.35;
}

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

.section-heading h2 {
  font-size: 0.92rem;
}

.section-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 6px;
}

.room-code {
  white-space: nowrap;
}

.segmented {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 4px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(222, 219, 210, 0.38);
}

.segment {
  min-height: 38px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  font-weight: 800;
}

.control-section[aria-labelledby="session-heading"] .segmented {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.segment.active {
  background: var(--paper);
  color: var(--ink);
  box-shadow: 0 6px 16px rgba(36, 36, 36, 0.09);
}

.small-button {
  min-height: 30px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--paper);
  color: var(--ink);
  font-size: 0.78rem;
  font-weight: 800;
}

.small-button[hidden],
.file-input {
  display: none;
}

.host-panel[hidden] {
  display: none;
}

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

.host-card {
  display: grid;
  grid-template-columns: 32px minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-height: 52px;
  padding: 9px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 253, 248, 0.78);
  color: var(--ink);
  text-align: left;
}

.host-card.active {
  border-color: rgba(15, 123, 120, 0.62);
  background: #e8f4f1;
  box-shadow: inset 3px 0 0 var(--teal);
}

.host-card:disabled {
  cursor: default;
  opacity: 0.72;
}

.host-card strong,
.host-card span {
  display: block;
  min-width: 0;
}

.host-card strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.host-card span {
  color: var(--muted);
  font-size: 0.75rem;
}

.host-card em {
  color: var(--teal);
  font-size: 0.7rem;
  font-style: normal;
  font-weight: 900;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.preset-list {
  display: grid;
  gap: 10px;
}

.preset-card {
  display: grid;
  grid-template-columns: 58px minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  width: 100%;
  min-height: 70px;
  padding: 9px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 253, 248, 0.78);
  color: var(--ink);
  text-align: left;
}

.preset-card.active {
  border-color: rgba(15, 123, 120, 0.6);
  box-shadow: inset 3px 0 0 var(--teal), 0 10px 24px rgba(15, 123, 120, 0.1);
}

.preset-card canvas {
  width: 58px;
  height: 48px;
  border-radius: 6px;
  background: #fbfaf5;
  border: 1px solid rgba(222, 219, 210, 0.8);
}

.preset-card img {
  width: 58px;
  height: 48px;
  border: 1px solid rgba(222, 219, 210, 0.8);
  border-radius: 6px;
  background: #fbfaf5;
  object-fit: cover;
}

.preset-card strong,
.preset-card span {
  display: block;
}

.preset-card strong {
  overflow-wrap: anywhere;
  font-size: 0.9rem;
}

.preset-card span {
  margin-top: 3px;
  color: var(--muted);
  font-size: 0.75rem;
  line-height: 1.25;
}

.preset-card em {
  color: var(--gold);
  font-style: normal;
  font-size: 0.74rem;
  font-weight: 900;
}

.studio {
  display: grid;
  position: relative;
  grid-template-rows: minmax(0, 1fr);
  height: 100svh;
  min-width: 0;
  min-height: 0;
  padding: 0;
}

.studio-header {
  position: absolute;
  top: max(10px, env(safe-area-inset-top));
  right: max(10px, env(safe-area-inset-right));
  left: max(10px, env(safe-area-inset-left));
  z-index: 35;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  min-width: 0;
  padding: 0;
  pointer-events: none;
  transition:
    opacity 160ms ease,
    transform 160ms ease;
}

.studio-header > div:first-child {
  min-width: 0;
}

.studio-header > * {
  pointer-events: auto;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--teal);
}

.studio-header h2 {
  overflow: hidden;
  font-size: clamp(1.45rem, 2.6vw, 2.4rem);
  line-height: 1.05;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.timer-block {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 0 0 auto;
  min-height: 48px;
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 253, 248, 0.94);
  box-shadow: 0 10px 24px rgba(36, 36, 36, 0.12);
}

.save-status {
  display: grid;
  width: 24px;
  height: 40px;
  place-items: center;
  color: var(--teal);
}

.save-status.saving {
  color: var(--gold);
}

.save-status.unavailable {
  color: var(--coral);
}

.save-status svg {
  width: 18px;
  height: 18px;
}

.timer-block > div {
  display: grid;
  justify-items: end;
}

.drawer-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

body.fullscreen-active {
  overflow: hidden;
  background: var(--paper);
}

body.fullscreen-active .app,
body.fullscreen-active .studio,
body.fullscreen-active .canvas-zone {
  width: 100vw;
  height: 100dvh;
  min-height: 100dvh;
}

body.fullscreen-active .canvas-zone {
  position: fixed;
  inset: 0;
  z-index: 20;
}

body.fullscreen-active .canvas-wrap {
  width: 100vw;
  height: 100dvh;
}

.drawer-scrim {
  display: none;
}

.drawer-scrim[hidden] {
  display: none;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(132px + env(safe-area-inset-bottom));
  z-index: 80;
  max-width: min(420px, calc(100vw - 32px));
  padding: 10px 14px;
  border: 1px solid rgba(36, 36, 36, 0.18);
  border-radius: 8px;
  background: rgba(36, 36, 36, 0.92);
  color: var(--paper);
  box-shadow: 0 16px 38px rgba(36, 36, 36, 0.18);
  font-size: 0.86rem;
  font-weight: 850;
  line-height: 1.25;
  opacity: 0;
  pointer-events: none;
  text-align: center;
  transform: translate(-50%, 10px);
  transition:
    opacity 160ms ease,
    transform 160ms ease;
}

.toast.warning {
  background: rgba(223, 91, 72, 0.96);
}

.toast.visible {
  opacity: 1;
  transform: translate(-50%, 0);
}

.toast[hidden] {
  display: none;
}

#timerValue {
  font-variant-numeric: tabular-nums;
  font-size: 1.25rem;
  font-weight: 900;
}

.studio-title {
  display: none;
}

.canvas-zone {
  display: grid;
  height: 100svh;
  place-items: stretch;
  min-width: 0;
  min-height: 0;
}

.canvas-wrap {
  position: relative;
  --canvas-pan-x: 0px;
  --canvas-pan-y: 0px;
  --canvas-scale: 1;
  width: 100%;
  height: 100%;
  max-height: none;
  aspect-ratio: auto;
  overflow: hidden;
  border: 0;
  border-radius: 0;
  background:
    linear-gradient(90deg, rgba(222, 219, 210, 0.42) 1px, transparent 1px),
    linear-gradient(rgba(222, 219, 210, 0.42) 1px, transparent 1px),
    var(--paper);
  background-position:
    var(--canvas-pan-x) var(--canvas-pan-y),
    var(--canvas-pan-x) var(--canvas-pan-y),
    0 0;
  background-size:
    calc(36px * var(--canvas-scale)) calc(36px * var(--canvas-scale)),
    calc(36px * var(--canvas-scale)) calc(36px * var(--canvas-scale)),
    auto;
  box-shadow: none;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}

.canvas-wrap.grid-hidden {
  background: var(--paper);
}

.canvas-surface {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  contain: layout paint size;
}

.canvas-surface canvas,
.peer-cursors {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
}

#paintCanvas {
  cursor: crosshair;
}

#strokeCanvas {
  pointer-events: none;
}

.peer-cursor {
  position: absolute;
  width: 14px;
  height: 14px;
  border: 2px solid currentColor;
  border-radius: 999px;
  transform: translate(-50%, -50%);
  opacity: 0;
  transition:
    left 650ms ease,
    top 650ms ease,
    opacity 220ms ease;
}

.peer-cursor::after {
  position: absolute;
  top: 12px;
  left: 7px;
  padding: 3px 6px;
  border-radius: 999px;
  background: rgba(36, 36, 36, 0.86);
  color: white;
  content: attr(data-name);
  font-size: 0.66rem;
  font-weight: 800;
  white-space: nowrap;
}

.tool-dock {
  position: absolute;
  right: max(10px, env(safe-area-inset-right));
  bottom: max(10px, env(safe-area-inset-bottom));
  left: max(10px, env(safe-area-inset-left));
  z-index: 35;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  min-width: 0;
  max-height: min(32svh, 220px);
  overflow: visible;
  padding: 8px;
  flex-wrap: wrap;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 253, 248, 0.94);
  box-shadow: 0 12px 30px rgba(36, 36, 36, 0.14);
  transition:
    opacity 160ms ease,
    transform 160ms ease;
  -webkit-overflow-scrolling: touch;
}

.confirm-dialog {
  width: min(360px, calc(100vw - 32px));
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--paper);
  color: var(--ink);
  box-shadow: var(--shadow);
}

.confirm-dialog::backdrop {
  background: rgba(36, 36, 36, 0.34);
}

.confirm-dialog h2 {
  margin: 0;
  font-size: 1.15rem;
}

.confirm-dialog p {
  margin: 10px 0 18px;
  color: var(--muted);
}

.confirm-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.small-button.danger {
  border-color: rgba(223, 91, 72, 0.5);
  color: var(--coral);
}

.tool-group,
.palette {
  display: flex;
  align-items: center;
  gap: 8px;
}

.icon-button {
  display: grid;
  width: 44px;
  height: 44px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--paper);
  color: var(--ink);
  box-shadow: 0 8px 18px rgba(36, 36, 36, 0.06);
}

.icon-button svg {
  width: 20px;
  height: 20px;
  stroke-width: 2.2;
}

.icon-fallback {
  display: none;
  font-size: 0.78rem;
  font-weight: 900;
}

.no-lucide .icon-button i {
  display: none;
}

.no-lucide .icon-fallback {
  display: block;
}

.icon-button i:empty + .icon-fallback {
  display: block;
}

.icon-button.active {
  border-color: rgba(15, 123, 120, 0.65);
  background: #e8f4f1;
  color: var(--teal);
}

.icon-button.danger {
  color: var(--coral);
}

.icon-button:disabled {
  cursor: default;
  opacity: 0.42;
}

.brush-menu {
  position: relative;
  display: grid;
  place-items: center;
}

.brush-styles-popover {
  position: absolute;
  bottom: calc(100% + 12px);
  left: 0;
  z-index: 30;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  width: min(384px, calc(100vw - 20px));
  max-height: min(440px, calc(100svh - 120px));
  overflow: hidden;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 253, 248, 0.98);
  box-shadow: var(--shadow);
}

.brush-popover-heading {
  display: flex;
  min-height: 42px;
  align-items: center;
  justify-content: space-between;
  padding: 0 2px 8px 6px;
}

.brush-popover-heading strong {
  font-size: 0.88rem;
}

.brush-close {
  width: 36px;
  height: 36px;
  box-shadow: none;
}

.brush-styles {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  width: 100%;
  min-height: 0;
  overflow-y: auto;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(222, 219, 210, 0.28);
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}

.brush-style-button {
  grid-template-columns: 20px minmax(0, 1fr);
  grid-template-rows: 20px 24px;
  gap: 4px 7px;
  width: 100%;
  height: 58px;
  padding: 6px 8px;
  border-radius: 6px;
  box-shadow: none;
  align-items: center;
  justify-items: stretch;
  text-align: left;
}

.brush-style-button > svg {
  grid-column: 1;
  grid-row: 1;
  width: 17px;
  height: 17px;
  justify-self: center;
}

.brush-style-button .icon-fallback {
  grid-column: 1;
  grid-row: 1;
}

.brush-name {
  grid-column: 2;
  grid-row: 1;
  min-width: 0;
  overflow: hidden;
  color: var(--ink);
  font-size: 0.72rem;
  font-weight: 850;
  line-height: 1.1;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.brush-preview {
  display: block;
  grid-column: 1 / -1;
  grid-row: 2;
  width: 100%;
  height: 24px;
}

.brush-styles-popover[hidden] {
  display: none;
}

.canvas-controls {
  display: flex;
  align-items: center;
  gap: 8px;
}

.layers-menu,
.actions-menu {
  position: relative;
  display: grid;
  place-items: center;
}

.layers-popover,
.actions-popover {
  position: absolute;
  bottom: calc(100% + 12px);
  left: 50%;
  z-index: 30;
  overflow: auto;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 253, 248, 0.98);
  box-shadow: var(--shadow);
  transform: translateX(-50%);
}

.layers-popover {
  width: min(330px, calc(100vw - 32px));
  max-height: min(440px, calc(100vh - 160px));
}

.actions-popover {
  display: grid;
  gap: 6px;
  width: min(210px, calc(100vw - 32px));
}

.layers-popover[hidden],
.actions-popover[hidden] {
  display: none;
}

.action-item {
  display: grid;
  grid-template-columns: 20px minmax(0, 1fr);
  align-items: center;
  gap: 10px;
  min-height: 40px;
  width: 100%;
  padding: 9px 10px;
  border: 1px solid transparent;
  border-radius: 6px;
  background: transparent;
  color: var(--ink);
  font-size: 0.82rem;
  font-weight: 850;
  text-align: left;
}

.action-item:hover {
  border-color: var(--line);
  background: rgba(222, 219, 210, 0.24);
}

.action-item svg {
  width: 17px;
  height: 17px;
  stroke-width: 2.3;
}

.action-item.danger {
  color: var(--coral);
}

.layers-popover-heading {
  display: grid;
  grid-template-columns: 38px minmax(0, 1fr) 38px;
  align-items: stretch;
  gap: 8px;
  margin-bottom: 10px;
}

.layer-header-button {
  width: 38px;
  height: 38px;
  min-height: 38px;
  border-radius: 8px;
  color: var(--teal);
  box-shadow: 0 8px 18px rgba(36, 36, 36, 0.04);
}

.layer-header-button svg {
  width: 16px;
  height: 16px;
  stroke-width: 2.3;
}

.layer-header-button:disabled {
  cursor: default;
  opacity: 0.38;
}

.swatch {
  width: 38px;
  height: 38px;
  border: 2px solid var(--paper);
  border-radius: 999px;
  background: var(--swatch-color);
  box-shadow: 0 0 0 1px var(--line), 0 7px 14px rgba(36, 36, 36, 0.1);
}

.swatch.active {
  box-shadow: 0 0 0 3px var(--ink), 0 7px 14px rgba(36, 36, 36, 0.12);
}

.color-control {
  display: grid;
  grid-template-columns: 38px 88px;
  align-items: center;
  min-height: 44px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--paper);
  box-shadow: 0 8px 18px rgba(36, 36, 36, 0.06);
}

.color-control input[type="color"] {
  width: 38px;
  height: 44px;
  padding: 0;
  border: 0;
  background: transparent;
  cursor: pointer;
}

.color-control input[type="color"]::-webkit-color-swatch-wrapper {
  padding: 5px;
}

.color-control input[type="color"]::-webkit-color-swatch {
  border: 1px solid var(--line);
  border-radius: 6px;
}

.color-control input[type="text"] {
  width: 88px;
  min-width: 0;
  height: 44px;
  padding: 0 9px;
  border: 0;
  border-left: 1px solid var(--line);
  background: transparent;
  color: var(--ink);
  font-size: 0.82rem;
  font-weight: 850;
  letter-spacing: 0;
  text-transform: uppercase;
}

.color-control input[type="text"]:focus {
  outline: 2px solid rgba(15, 123, 120, 0.32);
  outline-offset: -2px;
}

.color-control.invalid {
  border-color: rgba(223, 91, 72, 0.7);
  box-shadow: 0 0 0 3px rgba(223, 91, 72, 0.12);
}

.range-control {
  display: grid;
  grid-template-columns: auto minmax(96px, 136px);
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
}

.range-control input {
  accent-color: var(--teal);
}

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

.layer-row {
  display: grid;
  grid-template-columns: 38px minmax(0, 1fr) 38px;
  align-items: stretch;
  gap: 8px;
}

.layer-item {
  display: grid;
  grid-template-columns: 12px minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-height: 48px;
  padding: 9px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 253, 248, 0.72);
  color: var(--ink);
  text-align: left;
}

.layer-visibility,
.layer-delete {
  display: grid;
  width: 38px;
  min-height: 48px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--paper);
  box-shadow: 0 8px 18px rgba(36, 36, 36, 0.04);
}

.layer-visibility {
  color: var(--teal);
}

.layer-delete {
  color: var(--coral);
}

.layer-visibility svg,
.layer-delete svg {
  width: 16px;
  height: 16px;
  stroke-width: 2.3;
}

.layer-visibility:disabled,
.layer-delete:disabled {
  cursor: default;
  opacity: 0.38;
}

.layer-row.hidden-layer .layer-item {
  opacity: 0.58;
}

.layer-row.hidden-layer .layer-color {
  background: repeating-linear-gradient(
    45deg,
    var(--layer-color),
    var(--layer-color) 4px,
    rgba(255, 253, 248, 0.92) 4px,
    rgba(255, 253, 248, 0.92) 8px
  );
}

.layer-item.active {
  border-color: rgba(15, 123, 120, 0.62);
  background: #e8f4f1;
  box-shadow: inset 3px 0 0 var(--teal);
}

.layer-color {
  width: 10px;
  height: 30px;
  border-radius: 999px;
  background: var(--layer-color);
}

.layer-item strong,
.layer-item span {
  display: block;
}

.layer-item strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.layer-item span {
  color: var(--muted);
  font-size: 0.75rem;
}

.layer-item em {
  color: var(--teal);
  font-size: 0.7rem;
  font-style: normal;
  font-weight: 900;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.avatar {
  display: grid;
  width: 32px;
  height: 32px;
  place-items: center;
  border-radius: 999px;
  background: var(--avatar-color);
  color: white;
  font-size: 0.76rem;
  font-weight: 900;
}

.drawer-scrim:not([hidden]) {
  position: fixed;
  inset: 0;
  z-index: 45;
  display: block;
  border: 0;
  background: rgba(36, 36, 36, 0.28);
}

@media (max-width: 820px) {
  .studio-header {
    gap: 10px;
  }

  .timer-block {
    min-height: 42px;
  }

  .tool-dock {
    justify-content: flex-start;
    max-height: min(36svh, 260px);
  }

  .toast {
    bottom: calc(min(30svh, 180px) + 28px + env(safe-area-inset-bottom));
  }

  .left-rail {
    width: min(340px, calc(100vw - 44px));
  }

}

@media (max-width: 560px) {
  .preset-card {
    grid-template-columns: 52px minmax(0, 1fr);
  }

  .preset-card em {
    display: none;
  }

  .tool-dock {
    display: grid;
    grid-template-columns: minmax(112px, 0.8fr) minmax(0, 1.2fr);
    grid-template-areas:
      "tools tools"
      "controls controls"
      "palette palette"
      "color size"
      "guide guide";
    align-items: center;
    gap: 8px;
    max-height: min(42svh, 300px);
    overflow-y: auto;
    padding: 8px;
  }

  .tool-group {
    grid-area: tools;
    justify-content: center;
  }

  .canvas-controls {
    grid-area: controls;
    justify-content: center;
    gap: 6px;
  }

  .palette {
    grid-area: palette;
    justify-content: center;
  }

  .color-control {
    grid-area: color;
  }

  .range-control:not(.guide-range) {
    grid-area: size;
  }

  .guide-range {
    grid-area: guide;
  }

  .range-control {
    width: 100%;
    grid-template-columns: 42px minmax(0, 1fr);
  }

  .brush-styles-popover,
  .layers-popover,
  .actions-popover {
    position: fixed;
    right: 10px;
    bottom: calc(min(42svh, 300px) + 20px);
    left: 10px;
    width: auto;
    transform: none;
  }

  .brush-styles-popover {
    max-height: calc(58svh - 24px);
  }

  .brush-styles {
    width: 100%;
  }

  .color-control {
    grid-template-columns: 38px minmax(76px, 1fr);
    flex: 1 1 136px;
  }

  .color-control input[type="text"] {
    width: 100%;
  }

  .tool-dock {
    gap: 10px;
  }

  .tool-dock .icon-button {
    width: 44px;
    height: 44px;
  }

  .tool-dock .brush-style-button {
    width: 100%;
    height: 58px;
  }

  .timer-block > div {
    display: grid;
  }

  #timerValue {
    font-size: 1rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
  }
}
