:root {
  --paper: #f3efe6;
  --ink: #f3efe6;
  --field: #000000;
  --outside: #3d2918;
  --bar: #241f1a;
  color-scheme: light;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  height: 100%;
  background: var(--outside);
  color: var(--ink);
  overflow: hidden;
  overscroll-behavior: none;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}

body.painter {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  touch-action: none;
}

body.display {
  position: fixed;
  inset: 0;
  cursor: none;
}

canvas {
  display: block;
  width: 100%;
  background: var(--outside);
  touch-action: none;
}

body.painter canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

body.display canvas {
  height: 100%;
  cursor: none;
}

.version {
  position: absolute;
  z-index: 40;
  top: calc(10px + env(safe-area-inset-top));
  left: calc(12px + env(safe-area-inset-left));
  margin: 0;
  pointer-events: none;
  color: rgba(243, 239, 230, 0.62);
  font-family: "Avenir Next", "Gill Sans", "Trebuchet MS", sans-serif;
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.08em;
  line-height: 1;
}

body.display .version {
  cursor: none;
}

.dock {
  position: absolute;
  right: 0;
  bottom: 0;
  left: 0;
  z-index: 2;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 0;
  pointer-events: none;
  padding-bottom: env(safe-area-inset-bottom);
}

.dock.open {
  gap: 10px;
}

.tray {
  width: 100%;
  display: grid;
  grid-template-rows: 0fr;
  transition: grid-template-rows 0.28s ease;
  pointer-events: none;
}

.dock.open .tray {
  grid-template-rows: 1fr;
  pointer-events: auto;
}

.tray-clip {
  overflow: hidden;
  min-height: 0;
}

.dock-bar {
  display: flex;
  align-items: center;
  align-self: flex-end;
  gap: 10px;
  margin: 0 14px 14px;
  pointer-events: auto;
}

.dock.open .dock-bar {
  margin-bottom: 0;
}

.tools {
  display: flex;
  align-items: flex-start;
  flex-wrap: nowrap;
  gap: 16px;
  width: 100%;
  padding: 12px 18px;
  background: rgba(36, 31, 26, 0.78);
  border-radius: 0;
  overflow-x: auto;
  touch-action: manipulation;
}

#tools-toggle svg {
  transition: transform 0.25s ease;
}

.dock.open #tools-toggle svg {
  transform: rotate(180deg);
}

.swatches {
  display: grid;
  grid-template-columns: repeat(3, 40px);
  grid-template-rows: repeat(3, 40px);
  gap: 12px;
  flex: 0 0 auto;
  padding: 8px;
}

.swatch {
  width: 40px;
  height: 40px;
  border: 0;
  border-radius: 50%;
  padding: 0;
  cursor: pointer;
  box-shadow: inset 0 0 0 1px rgba(243, 239, 230, 0.45);
}

.swatch[aria-pressed="true"] {
  box-shadow: 0 0 0 3px var(--bar), 0 0 0 6px var(--paper);
}

.divider {
  width: 1px;
  align-self: stretch;
  flex: 0 0 auto;
  background: rgba(243, 239, 230, 0.4);
}

.section {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 8px;
  flex: 0 0 auto;
}

.section-label {
  min-height: 14px;
  color: rgba(243, 239, 230, 0.92);
  font-family: "Avenir Next", "Gill Sans", "Trebuchet MS", sans-serif;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.16em;
  line-height: 14px;
  text-transform: uppercase;
}

.section-controls {
  display: flex;
  align-items: flex-start;
  gap: 16px;
}

.section-note {
  min-height: 14px;
  color: rgba(243, 239, 230, 0.48);
  font-family: "Avenir Next", "Gill Sans", "Trebuchet MS", sans-serif;
  font-size: 9px;
  font-weight: 500;
  letter-spacing: 0.04em;
  line-height: 14px;
  text-align: center;
  white-space: nowrap;
}

.color-picker {
  position: fixed;
  left: 0;
  top: 0;
  width: 1px;
  height: 1px;
  margin: 0;
  padding: 0;
  border: 0;
  opacity: 0;
}

.sizes {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
  box-sizing: border-box;
  width: 52px;
  height: 150px;
  padding: 6px 0;
  flex: 0 0 auto;
}

.sizes::before {
  content: "";
  position: absolute;
  left: 50%;
  top: 6px;
  bottom: 6px;
  width: 3px;
  margin-left: -1.5px;
  border-radius: 999px;
  background: rgba(243, 239, 230, 0.28);
}

.size {
  position: relative;
  z-index: 1;
  flex: 0 0 auto;
  border: 0;
  border-radius: 50%;
  padding: 0;
  background: var(--paper);
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
  box-shadow: inset 0 0 0 1px rgba(243, 239, 230, 0.45);
}

.size[aria-pressed="true"] {
  box-shadow: 0 0 0 3px var(--bar), 0 0 0 6px var(--paper);
}

.brush {
  width: 42px;
  height: 42px;
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 50%;
  padding: 0;
  background: transparent;
  color: var(--paper);
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
}

.brush svg {
  width: 24px;
  height: 24px;
  display: block;
}

.brush[aria-pressed="true"] {
  box-shadow: 0 0 0 3px var(--bar), 0 0 0 6px var(--paper);
}

.tune {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  flex: 0 0 auto;
}

.tune-label {
  min-height: 14px;
  color: rgba(243, 239, 230, 0.72);
  font-family: "Avenir Next", "Gill Sans", "Trebuchet MS", sans-serif;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.14em;
  line-height: 14px;
  text-transform: uppercase;
  white-space: nowrap;
}

.effects {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 0 0 auto;
}

.slider {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  width: 52px;
  touch-action: none;
}

.slider-track {
  position: relative;
  width: 36px;
  height: 128px;
  touch-action: none;
  cursor: pointer;
}

.slider-line {
  position: absolute;
  left: 50%;
  top: 8px;
  bottom: 8px;
  width: 3px;
  margin-left: -1.5px;
  border-radius: 999px;
  background: rgba(243, 239, 230, 0.28);
}

.slider-fill {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  width: 100%;
  border-radius: inherit;
  background: #ffe24a;
}

.slider-thumb {
  position: absolute;
  left: 50%;
  width: 18px;
  height: 18px;
  margin: -9px 0 0 -9px;
  border-radius: 50%;
  background: #f3efe6;
  box-shadow: 0 0 0 2px rgba(36, 31, 26, 0.4);
}

.slider-value {
  flex: 0 0 auto;
  height: 16px;
  line-height: 16px;
  color: var(--paper);
  font-family: "Avenir Next", "Gill Sans", "Trebuchet MS", sans-serif;
  font-size: 12px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  text-align: center;
}

.switch {
  display: flex;
  align-items: flex-start;
  justify-content: center;
  width: 52px;
  height: 150px;
  padding: 8px 0 0;
  border: 0;
  background: transparent;
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
}

.switch-track {
  position: relative;
  width: 48px;
  height: 28px;
  border-radius: 999px;
  background: rgba(243, 239, 230, 0.16);
  box-shadow: inset 0 0 0 1px rgba(243, 239, 230, 0.45);
}

.switch-thumb {
  position: absolute;
  top: 4px;
  left: 4px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: rgba(243, 239, 230, 0.72);
  transition: transform 0.18s ease, background 0.18s ease;
}

.switch[aria-pressed="true"] .switch-track {
  background: #ffe24a;
  box-shadow: none;
}

.switch[aria-pressed="true"] .switch-thumb {
  transform: translateX(20px);
  background: #241f1a;
}

.tune.is-off .slider {
  opacity: 0.38;
}

.dock-bar .step {
  background: rgba(36, 31, 26, 0.92);
}

.step {
  flex: 0 0 auto;
  width: 46px;
  height: 46px;
  display: grid;
  place-items: center;
  border: 1px solid rgba(243, 239, 230, 0.55);
  border-radius: 50%;
  padding: 0;
  background: transparent;
  color: var(--paper);
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
}

.step svg {
  width: 22px;
  height: 22px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.step:disabled {
  opacity: 0.28;
  cursor: default;
}

.erase {
  flex: 0 0 auto;
  height: 46px;
  padding: 0 16px;
  border: 1px solid rgba(243, 239, 230, 0.55);
  border-radius: 999px;
  background: rgba(36, 31, 26, 0.92);
  color: var(--paper);
  font-family: "Avenir Next", "Gill Sans", "Trebuchet MS", sans-serif;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.04em;
  white-space: nowrap;
  cursor: pointer;
}

.erase:active {
  background: rgba(243, 239, 230, 0.12);
}

.status {
  position: absolute;
  left: 18px;
  bottom: calc(78px + env(safe-area-inset-bottom));
  margin: 0;
  color: var(--ink);
  font-family: "Avenir Next", "Gill Sans", "Trebuchet MS", sans-serif;
  font-size: 13px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.status[hidden] {
  display: none;
}

.turn {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 30;
  margin: 0;
  align-items: center;
  justify-content: center;
  background: #3d2918;
  color: var(--paper);
  font-family: "Avenir Next", "Gill Sans", "Trebuchet MS", sans-serif;
  font-size: 22px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-align: center;
}

@media (orientation: portrait) and (max-width: 1100px) {
  .turn {
    display: flex;
  }
}
