:root {
  color-scheme: light;

  --bg: #f5f7fb;
  --panel: #fff;
  --ink: #1a1f2c;
  --muted: #667085;
  --line: #d9e0ea;
  --accent: #0f766e;
  --accent-2: #b42318;
  --eraser-fill: #f04438;
  --eraser-border: #b42318;
  --eraser-background: rgb(240 68 56 / 16%);
  --surface: #fffdf8;
  --shadow: 0 16px 42px rgb(28 39 57 / 13%);
}

* {
  box-sizing: border-box;
}

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

body {
  background: var(--bg);
  color: var(--ink);
  font-family:
    Inter,
    ui-sans-serif,
    system-ui,
    -apple-system,
    BlinkMacSystemFont,
    "Segoe UI",
    sans-serif;
}

button,
input {
  font: inherit;
}

.app-shell {
  display: grid;
  grid-template-columns: minmax(288px, 360px) 1fr;
  height: 100vh;
  min-height: 0;
  overflow: hidden;
}

.panel {
  display: flex;
  flex-direction: column;
  gap: 18px;
  height: 100vh;
  min-height: 0;
  overflow-y: auto;
  padding: 20px;
  background: var(--panel);
  border-right: 1px solid var(--line);
  box-shadow: var(--shadow);
  z-index: 2;
}

.brand {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 24px;
  line-height: 1.15;
}

.brand p {
  margin-top: 6px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.4;
}

.status {
  flex: 0 0 auto;
  padding: 5px 9px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--accent);
  font-size: 12px;
  font-weight: 700;
}

.controls {
  display: grid;
  gap: 14px;
}

.control-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px 12px;
  align-items: center;
  color: #344054;
  font-size: 13px;
  font-weight: 700;
}

.control-row output {
  color: var(--muted);
  font-weight: 700;
}

input[type="range"] {
  grid-column: 1 / -1;
  width: 100%;
  accent-color: var(--accent);
}

input[type="color"] {
  width: 44px;
  height: 32px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: transparent;
}

.readout {
  display: grid;
  gap: 8px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f9fbfd;
}

.readout div {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  min-width: 0;
  color: var(--muted);
  font-size: 13px;
}

.readout strong {
  overflow: hidden;
  max-width: 155px;
  color: var(--ink);
  text-align: right;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.actions,
.board-actions,
.tool-actions {
  display: grid;
  grid-template-columns: repeat(3, 48px);
  gap: 10px;
}

.actions button,
.board-actions button,
.tool-actions button,
.dialog-header button {
  width: 48px;
  height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  cursor: pointer;
  font-size: 21px;
  font-weight: 800;
  line-height: 1;
}

.eraser-icon {
  position: relative;
  display: inline-block;
  width: 21px;
  height: 14px;
  border: 2px solid var(--eraser-border);
  border-radius: 3px;
  background: var(--eraser-background);
  color: var(--eraser-border);
  transform: rotate(-38deg);
  vertical-align: middle;
}

.eraser-icon::after {
  position: absolute;
  top: -2px;
  bottom: -2px;
  left: 7px;
  width: 2px;
  background: currentcolor;
  content: "";
}

.stroke-eraser-icon {
  position: relative;
  display: inline-block;
  width: 27px;
  height: 24px;
  vertical-align: middle;
}

.stroke-eraser-icon .eraser-icon {
  position: absolute;
  top: 0;
  left: 3px;
  transform: rotate(-38deg) scale(0.82);
}

.stroke-eraser-line {
  position: absolute;
  right: 1px;
  bottom: 2px;
  left: 1px;
  height: 2px;
  border-radius: 1px;
  background: var(--eraser-border);
}

.actions button:hover,
.board-actions button:hover,
.tool-actions button:hover,
.dialog-header button:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.tool-actions {
  grid-column: 1 / -1;
  grid-template-columns: repeat(3, 48px);
}

.tool-actions button[aria-pressed="true"] {
  border-color: var(--accent);
  background: #e8f5f2;
  color: var(--accent);
}

#eraseToolButton[aria-pressed="true"],
#eraseStrokeToolButton[aria-pressed="true"] {
  border-color: var(--eraser-border);
  background: var(--eraser-background);
  color: var(--eraser-border);
}

#eraseToolButton:hover,
#eraseStrokeToolButton:hover {
  border-color: var(--eraser-border);
  color: var(--eraser-border);
}

button:disabled {
  cursor: default;
  opacity: 0.4;
}

dialog {
  width: min(720px, calc(100vw - 32px));
  max-height: min(720px, calc(100vh - 32px));
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  box-shadow: var(--shadow);
}

dialog::backdrop {
  background: rgb(26 31 44 / 42%);
}

.dialog-header,
.dialog-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 18px 20px;
}

.dialog-header {
  border-bottom: 1px solid var(--line);
}

.dialog-header p {
  margin-top: 4px;
  color: var(--muted);
  font-size: 13px;
}

.dialog-header button {
  flex: 0 0 auto;
  font-size: 22px;
}

.dialog-footer {
  border-top: 1px solid var(--line);
}

.dialog-footer button {
  min-height: 40px;
  padding: 0 16px;
  border: 1px solid var(--accent);
  border-radius: 6px;
  background: var(--accent);
  color: #fff;
  cursor: pointer;
  font-weight: 700;
}

.boards-list {
  display: grid;
  max-height: 520px;
  overflow: auto;
}

.board-row {
  display: grid;
  grid-template-columns: minmax(160px, 2fr) minmax(210px, 1.2fr) auto;
  gap: 16px;
  align-items: center;
  min-height: 64px;
  padding: 10px 20px;
  border-bottom: 1px solid var(--line);
}

.board-row:last-child {
  border-bottom: 0;
}

.board-row code {
  overflow: hidden;
  color: var(--ink);
  font-size: 13px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.board-row span {
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
}

.board-id {
  font-size: 12px;
}

.board-meta {
  display: grid;
  gap: 4px;
  min-width: 0;
}

.board-meta__time,
.board-meta__count {
  overflow: hidden;
  color: var(--muted);
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.board-row button {
  width: 40px;
  height: 36px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  cursor: pointer;
  font-size: 18px;
}

.boards-empty {
  padding: 32px 20px;
  color: var(--muted);
  text-align: center;
}

.event-log {
  min-height: 0;
}

.event-log h2 {
  margin-bottom: 8px;
  font-size: 15px;
}

.event-log ol {
  display: grid;
  gap: 6px;
  max-height: 220px;
  margin: 0;
  padding: 0;
  overflow: auto;
  list-style: none;
}

.event-log li {
  padding: 7px 9px;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: #344054;
  font-family: "Cascadia Mono", SFMono-Regular, Consolas, monospace;
  font-size: 12px;
  line-height: 1.35;
  background: #fff;
}

.svg-stage {
  position: relative;
  height: 100vh;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  background:
    linear-gradient(rgb(26 31 44 / 4.5%) 1px, transparent 1px),
    linear-gradient(90deg, rgb(26 31 44 / 4.5%) 1px, transparent 1px),
    var(--surface);
  background-size: 28px 28px;
}

#vectorLayer {
  position: absolute;
  inset: 0;
  z-index: 1;
  width: 100%;
  height: 100%;
  min-height: 0;
  overflow: visible;
  touch-action: none;
  cursor: crosshair;
  pointer-events: auto;
}

#vectorLayer .stroke-path {
  stroke-linecap: round;
  stroke-linejoin: round;
}

#vectorLayer .eraser-preview-path {
  fill: var(--eraser-fill);
  fill-opacity: 0.16;
  stroke: var(--eraser-border);
  stroke-width: 1.25px;
  stroke-opacity: 0.82;
  vector-effect: non-scaling-stroke;
  pointer-events: none;
}

#vectorLayer .eraser-live-head {
  stroke-width: 1.5px;
}

.gesture-hint {
  position: absolute;
  right: 18px;
  bottom: 18px;
  z-index: 3;
  max-width: min(360px, calc(100% - 36px));
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgb(255 255 255 / 92%);
  color: var(--muted);
  font-size: 13px;
  line-height: 1.35;
  pointer-events: none;
}

@media (width <= 820px) {
  .app-shell {
    grid-template-columns: 1fr;
    height: auto;
    min-height: 100%;
    overflow: visible;
  }

  .panel {
    height: auto;
    min-height: auto;
    overflow-y: visible;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .svg-stage,
  #vectorLayer {
    height: 64vh;
    min-height: 64vh;
  }
}
