:root {
  color-scheme: light;
  --ink: #3b332d;
  --muted: #7a6d62;
  --line: #e6ddd2;
  --paper: #f3eee6;
  --card: #fffdf9;
  --accent: #e8893a;
  --board: #efe8dc;
}

* { box-sizing: border-box; }

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

body {
  display: flex;
  flex-direction: column;
  height: 100dvh;
  overflow: hidden;
  background: var(--paper);
  color: var(--ink);
  font-family: "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  user-select: none;
  -webkit-user-select: none;
}

button, input, select, textarea { font-size: 16px; font-family: inherit; }
input, select { user-select: text; -webkit-user-select: text; }
button, label { touch-action: manipulation; }

.top {
  flex: none;
  padding: calc(8px + env(safe-area-inset-top)) 12px 8px;
  background: var(--card);
  border-bottom: 1px solid var(--line);
}

.title-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
}

h1 {
  margin: 0;
  font-size: 16px;
  font-weight: 700;
}

.title-row p {
  margin: 0;
  font-size: 12px;
  color: var(--muted);
}

.idline, .more {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 8px;
}

label {
  display: flex;
  flex-direction: column;
  gap: 2px;
  font-size: 12px;
  color: var(--muted);
}

label.grow { flex: 1; min-width: 140px; }
label.wide { flex: 1 1 180px; }

input, select {
  height: 36px;
  padding: 0 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
}

input[type="color"] {
  padding: 2px;
  width: 72px;
}

.diffs {
  display: flex;
  gap: 6px;
  margin-top: 8px;
}

.diffs button, .tools button, .actions button {
  min-height: 40px;
  padding: 0 12px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
}

.diffs button { flex: 1; }

.diffs button.on, .tools button.on {
  background: var(--ink);
  color: #fff;
  border-color: var(--ink);
}

details summary {
  margin-top: 6px;
  font-size: 13px;
  color: var(--muted);
  cursor: pointer;
}

.stage {
  flex: 1;
  min-height: 0;
  position: relative;
  background: var(--board);
}

canvas {
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
}

.hint {
  flex: none;
  margin: 0;
  padding: 6px 12px 0;
  font-size: 12px;
  line-height: 1.35;
  color: var(--muted);
  background: var(--card);
}

.dock {
  flex: none;
  background: var(--card);
  border-top: 1px solid var(--line);
  padding-bottom: calc(6px + env(safe-area-inset-bottom));
}

.stats {
  padding: 6px 12px 0;
  font-size: 12px;
  color: var(--ink);
}

.palette {
  display: flex;
  gap: 2px;
  overflow-x: auto;
  padding: 6px 8px 0;
}

.swatch {
  flex: 0 0 auto;
  width: 44px;
  height: 52px;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--ink);
}

.swatch .bead {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  margin: 0 auto;
  border-radius: 50%;
  border: 2px solid transparent;
  font-style: normal;
  font-size: 13px;
  font-weight: 700;
}

.swatch.on .bead {
  border-color: #fff;
  box-shadow: 0 0 0 2px var(--accent);
}

.swatch .cnt {
  display: block;
  height: 14px;
  font-size: 10px;
  line-height: 14px;
  text-align: center;
  font-style: normal;
}

.tools, .actions {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  padding: 6px 8px 0;
}

.tools button:disabled {
  opacity: 0.4;
}

.check {
  flex-direction: row;
  align-items: center;
  gap: 6px;
  min-height: 40px;
  padding: 0 4px;
  white-space: nowrap;
  color: var(--ink);
  font-size: 14px;
}

.actions .primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  font-weight: 700;
}

.crop-note {
  margin: 4px 12px 0;
  font-size: 11px;
  line-height: 1.35;
  color: var(--muted);
}

.toast {
  position: fixed;
  left: 50%;
  top: 28%;
  transform: translateX(-50%) translateY(12px);
  padding: 8px 14px;
  border-radius: 999px;
  background: var(--ink);
  color: #fff;
  font-size: 14px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s, transform 0.2s;
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}
