:root {
  color-scheme: light;
  --ink: #20232a;
  --muted: #626a76;
  --line: #d9dee7;
  --panel: #f8fafc;
  --surface: #ffffff;
  --accent: #1f6feb;
  --accent-dark: #174ea6;
  --danger: #b42318;
  --shadow: 0 18px 42px rgba(15, 23, 42, 0.14);
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
}

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

.app-shell {
  display: grid;
  grid-template-columns: minmax(280px, 1fr) minmax(280px, 1fr) minmax(280px, 1fr);
  min-width: 840px;
  min-height: 100vh;
}

.control-panel {
  display: flex;
  flex-direction: column;
  gap: 18px;
  height: 100vh;
  padding: 22px;
  overflow-y: auto;
  background: var(--surface);
  border-right: 1px solid var(--line);
}

.control-panel h1 {
  margin: 0;
  font-size: 25px;
  font-weight: 760;
  letter-spacing: 0;
}

.control-section,
.export-section,
.advanced-body {
  display: grid;
  gap: 14px;
}

.color-picker {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 650;
}

.color-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
}

.color-tile {
  display: grid;
  place-items: center;
  gap: 4px;
  min-height: 58px;
  padding: 8px 4px;
  border: 2px solid var(--line);
  color: var(--ink);
  background: #fff;
  font-size: 13px;
  font-weight: 760;
}

.color-tile:hover {
  color: var(--ink);
  background: #f8fafc;
  border-color: var(--tile-color);
}

.color-tile.is-selected {
  border-color: var(--tile-color);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--tile-color) 24%, transparent);
}

.color-tile.is-complete::after {
  content: "已完成";
  color: var(--muted);
  font-size: 10px;
  font-weight: 700;
  line-height: 1;
}

.swatch {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--tile-color);
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.14);
}

label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 650;
}

input,
select,
button {
  min-height: 40px;
  border-radius: 7px;
  font: inherit;
}

input,
select {
  width: 100%;
  border: 1px solid var(--line);
  color: var(--ink);
  background: #fff;
  padding: 0 11px;
}

input[type="color"] {
  height: 40px;
  padding: 4px;
}

input[type="file"] {
  min-height: 42px;
  padding: 8px;
}

button {
  border: 1px solid var(--accent);
  color: #fff;
  background: var(--accent);
  padding: 0 14px;
  font-weight: 760;
  cursor: pointer;
}

button:hover {
  background: var(--accent-dark);
  border-color: var(--accent-dark);
}

button.secondary {
  color: var(--ink);
  background: #fff;
  border-color: var(--line);
}

button.secondary:hover {
  background: #f3f6fa;
  border-color: #c7d0dd;
}

.button-row,
.popover-actions,
.path-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.path-actions {
  grid-template-columns: 1fr;
}

.advanced-controls {
  margin-top: auto;
  border-top: 1px solid var(--line);
  padding-top: 14px;
}

.advanced-controls summary {
  cursor: pointer;
  color: var(--ink);
  font-weight: 760;
  list-style-position: inside;
}

.advanced-body {
  padding-top: 14px;
}

.checkbox-row {
  display: flex;
  align-items: center;
  gap: 9px;
}

.checkbox-row input {
  width: 18px;
  min-height: 18px;
  height: 18px;
  margin: 0;
}

.export-section {
  padding-top: 4px;
}

.status-text {
  min-height: 38px;
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.status-text.error {
  color: var(--danger);
}

.preview-pane {
  display: grid;
  grid-template-rows: auto 1fr;
  min-width: 0;
  height: 100vh;
  overflow: hidden;
  border-right: 1px solid var(--line);
  background: var(--panel);
}

.preview-pane header {
  padding: 16px 18px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.68);
  font-size: 15px;
  font-weight: 760;
}

.canvas-wrap {
  display: grid;
  place-items: center;
  min-height: 0;
  padding: 22px;
  overflow: auto;
}

canvas {
  display: block;
  max-width: min(100%, 430px);
  max-height: calc(100vh - 92px);
  width: auto;
  height: auto;
  background: #fff;
  box-shadow: var(--shadow);
}

.cell-popover {
  position: fixed;
  z-index: 20;
  display: grid;
  gap: 10px;
  width: 190px;
  padding: 13px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  box-shadow: var(--shadow);
}

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

.cell-popover strong {
  font-size: 14px;
}
