:root {
  color-scheme: light;
  --surface: #fffdfa;
  --white: #fff;
  --ink: #27231f;
  --muted: #6d625b;
  --subtle: #85776d;
  --line: #eae2d9;
  --line-strong: #ded3c8;
  --accent: #c94d35;
  --accent-fill: #cf5037;
  --accent-hover: #b8402a;
  --accent-soft: #fff0e9;
  --accent-edge: #f3c6b8;
  --paper-shadow: 0 24px 52px -20px #4a39204a, 0 3px 10px #3c2a190f;
  --sans: Inter, -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", "Noto Sans CJK SC", sans-serif;
  --mono: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  font-family: var(--sans);
  color: var(--ink);
  background: var(--surface);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  font-synthesis: none;
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }

body {
  margin: 0;
  min-width: 320px;
  min-height: 100dvh;
  font-size: 14px;
  display: flex;
  flex-direction: column;
}

button, input, textarea, select { font: inherit; }
button, select, input[type="range"], input[type="color"] { cursor: pointer; }
button { color: inherit; }
button:disabled { cursor: default; opacity: .52; }
:where(button, input, textarea, select, a, [tabindex]):focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}
button[aria-disabled="true"] { cursor: default; }
h1, h2, h3, p { margin: 0; }
a { color: var(--accent); }

.app-header, .site-header, body > header {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  flex: none;
  gap: 20px;
  min-height: 70px;
  padding: 0 28px;
  background: var(--white);
  border-bottom: 1px solid var(--line);
}

.brand {
  display: inline-flex;
  align-items: center;
  justify-self: start;
  gap: 11px;
  color: var(--ink);
  text-decoration: none;
  font-size: 19px;
  font-weight: 750;
  letter-spacing: -.035em;
  white-space: nowrap;
}
.brand > span:last-child {
  display: grid;
  gap: 2px;
}
.brand small {
  color: var(--subtle);
  font-family: var(--mono);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: .15em;
  line-height: 1;
}

.brand-mark {
  position: relative;
  display: inline-grid;
  grid-template-columns: repeat(2, 7px);
  grid-template-rows: repeat(2, 7px);
  place-content: center;
  gap: 2px;
  flex: 0 0 36px;
  width: 36px;
  height: 36px;
  place-items: center;
  color: #fff;
  background: var(--accent-fill);
  border-radius: 11px;
  box-shadow: 0 3px 7px #c94d3530;
}
.brand-mark i {
  width: 7px;
  height: 7px;
  border-radius: 1.5px;
  background: #fff;
}
.brand-mark i:nth-child(4) { opacity: .55; }

.brand-mark:empty::before {
  content: "";
  width: 16px;
  height: 16px;
  border-radius: 3px;
  background:
    linear-gradient(#fff 0 0) 0 0 / 7px 7px,
    linear-gradient(#fff 0 0) 100% 0 / 7px 7px,
    linear-gradient(#fff 0 0) 0 100% / 7px 7px,
    linear-gradient(#ffffff93 0 0) 100% 100% / 7px 7px;
  background-repeat: no-repeat;
  transform: rotate(-8deg);
}

.header-note {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  justify-self: center;
  color: var(--muted);
  font-size: 13px;
  white-space: nowrap;
}
.header-note .icon { color: var(--accent); }

.header-actions {
  display: inline-flex;
  align-items: center;
  justify-self: end;
  gap: 9px;
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-height: 38px;
  padding: 8px 14px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: var(--white);
  color: var(--ink);
  line-height: 1.25;
  font-size: 14px;
  font-weight: 640;
  white-space: nowrap;
  text-decoration: none;
  transition: background .15s ease, color .15s ease, border-color .15s ease, box-shadow .15s ease;
}
.button:hover:not(:disabled) { background: #f8f4ef; border-color: #d6c6b9; }
.button.outline:hover:not(:disabled) { color: var(--accent); border-color: var(--accent-edge); }
.button.primary {
  border-color: var(--accent-fill);
  background: var(--accent-fill);
  color: var(--white);
  box-shadow: 0 2px 4px #a5382424;
}
.button.primary:hover:not(:disabled) { background: var(--accent-hover); border-color: var(--accent-hover); }
.button.danger { color: #a73e30; }

.quiet {
  border: 0;
  padding: 5px 7px;
  border-radius: 6px;
  color: var(--muted);
  background: transparent;
  font-size: 13px;
}
.quiet:hover:not(:disabled) { color: var(--ink); background: #eae2d8; }

.icon {
  position: relative;
  display: inline-flex;
  flex: none;
  justify-content: center;
  align-items: center;
  width: 1em;
  height: 1em;
  font-size: 1.1em;
  line-height: 1;
}
.icon-lock::before {
  content: "";
  width: .72em;
  height: .55em;
  position: absolute;
  inset: .44em auto auto;
  border: 1.25px solid currentColor;
  border-radius: .14em;
}
.icon-lock::after {
  content: "";
  position: absolute;
  width: .42em;
  height: .37em;
  inset: .13em auto auto;
  border: 1.25px solid currentColor;
  border-bottom: 0;
  border-radius: .2em .2em 0 0;
}
.icon-download::before {
  content: "";
  width: .82em;
  height: .39em;
  position: absolute;
  inset: auto auto .01em;
  border: 1.4px solid currentColor;
  border-top: 0;
  border-radius: 0 0 .15em .15em;
}
.icon-download::after {
  content: "↓";
  position: absolute;
  inset: -.2em auto auto;
  font-size: .98em;
  font-weight: 750;
}

.workspace-bar {
  position: relative;
  z-index: 1;
  display: flex;
  flex: none;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 72px;
  padding: 12px 28px;
  background: var(--white);
  border-bottom: 1px solid var(--line);
}

.project-title {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px 15px;
}
.project-title h1 {
  font-size: clamp(20px, 2.1vw, 26px);
  font-weight: 720;
  line-height: 1.2;
  letter-spacing: -.045em;
}
.project-meta { color: var(--muted); line-height: 1.35; font-size: 13px; }
.project-meta:empty { display: none; }

.steps {
  display: flex;
  list-style: none;
  align-items: center;
  gap: 12px;
  padding: 0;
  margin: 0;
  color: var(--subtle);
  font-size: 13px;
  white-space: nowrap;
}
.steps > * {
  display: inline-flex;
  align-items: center;
  gap: 7px;
}
.steps > * + *::before {
  content: "";
  width: 22px;
  margin-right: 5px;
  border-top: 1px solid var(--line-strong);
}
.steps > li > span:first-child {
  display: inline-grid;
  flex: none;
  place-items: center;
  width: 22px;
  height: 22px;
  border-radius: 99px;
  background: #f3ede5;
  font-size: 11px;
  font-weight: 700;
  color: var(--muted);
}
.steps :is(.active, .current, [aria-current="step"]) {
  color: var(--accent);
  font-weight: 700;
}
.steps :is(.active, .current, [aria-current="step"]) > span:first-child {
  background: var(--accent-fill);
  color: var(--white);
}
.steps :is(.done, .complete) > span:first-child {
  background: var(--accent-soft);
  color: var(--accent);
}

.editor {
  flex: 1;
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr) 312px;
  align-items: stretch;
  min-height: 500px;
  height: calc(100dvh - 142px);
}

.library, .inspector {
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  background: var(--surface);
  overflow: auto;
  scrollbar-width: thin;
  scrollbar-color: #d8ccbf transparent;
}
.library { border-right: 1px solid var(--line); }
.inspector { border-left: 1px solid var(--line); }

.panel-title {
  min-height: 52px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 15px 20px 11px;
  color: var(--ink);
  font-size: 16px;
  font-weight: 710;
  letter-spacing: -.018em;
}
.panel-title h2 { font-size: inherit; font-weight: inherit; }
.panel-title small { color: var(--subtle); font-size: 12px; font-weight: 500; letter-spacing: 0; }
.panel-title .icon { color: var(--accent); }

.panel-tabs {
  display: flex;
  flex: none;
  gap: 4px;
  margin: 0 20px 18px;
  padding: 4px;
  border: 1px solid #f0e9e1;
  background: #f5f0ea;
  border-radius: 9px;
}
.panel-tabs button {
  min-width: 0;
  flex: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 7px 4px;
  background: transparent;
  color: var(--muted);
  border: 1px solid transparent;
  border-radius: 6px;
  font-size: 14px;
  line-height: 1.25;
}
.panel-tabs button:hover { color: var(--ink); }
.panel-tabs button:is(.active, [aria-selected="true"], [aria-pressed="true"]) {
  background: var(--white);
  color: var(--ink);
  border-color: #eae2d9;
  box-shadow: 0 1px 2px #4333200f;
  font-weight: 700;
}

.tab-panel {
  padding: 0 20px 20px;
}
.tab-panel > h3 { margin: 0 0 12px; font-size: 14px; line-height: 1.45; }
.tab-panel > p {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.65;
  margin-bottom: 12px;
}

.template-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}
.template-card {
  position: relative;
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 4px;
  padding: 5px 5px 8px;
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: 10px;
  text-align: left;
  transition: border-color .15s ease, background .15s ease;
}
.template-card:hover { border-color: var(--accent-edge); background: #fff7f2; }
.template-card:is(.active, .selected, [aria-selected="true"], [aria-pressed="true"]) {
  background: #fff6f0;
  border-color: var(--accent-fill);
  box-shadow: 0 0 0 1px var(--accent-fill);
}
.template-check {
  display: none;
  position: absolute;
  z-index: 1;
  right: 8px;
  top: 8px;
  place-items: center;
  width: 18px;
  height: 18px;
  border: 1px solid var(--white);
  border-radius: 50%;
  color: var(--white);
  background: var(--accent-fill);
  font: 700 11px / 1 var(--sans);
}
.template-card:is(.active, .selected, [aria-selected="true"], [aria-pressed="true"]) .template-check { display: grid; }
.template-preview {
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 84px;
  aspect-ratio: 1 / 1;
  padding: 7px;
  border-radius: 6px;
  overflow: hidden;
  background: #eee4d8;
}
.template-card[data-template^="grid"] .template-preview { background: #e2d5c8; }
.template-preview canvas, .template-preview img {
  display: block;
  max-width: 100%;
  max-height: 100%;
  width: auto;
  height: 100%;
  object-fit: contain;
  box-shadow: 0 2px 5px #4a392035;
}
.template-name, .template-count {
  display: block;
  width: 100%;
  padding: 0 3px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.template-name { margin-top: 4px; font-weight: 700; font-size: 13px; }
.template-count { color: var(--muted); font-size: 12px; }

.panel-divider {
  height: 1px;
  margin: 20px 0 16px;
  background: var(--line);
  border: none;
}
.tab-panel:has(> .panel-divider:last-child) { padding-bottom: 0; }
.library > .panel-divider { flex: none; margin-left: 20px; margin-right: 20px; }
.upload-heading {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  color: var(--ink);
  font-size: 14px;
  font-weight: 700;
  line-height: 1.4;
}
.upload-heading h2, .upload-heading h3 { font-size: inherit; font-weight: inherit; }
.upload-heading :is(small, output, #upload-count) {
  color: var(--muted);
  font-weight: 550;
  font-family: var(--mono);
  font-size: 12px;
}
.progress-track {
  height: 5px;
  border-radius: 99px;
  overflow: hidden;
  background: #efe5dc;
  margin: 10px 0 12px;
}
.progress-track > span {
  display: block;
  height: 100%;
  background: var(--accent-fill);
  border-radius: inherit;
  transition: width .16s ease;
}
.drop-zone {
  min-height: 117px;
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 11px 8px;
  border: 1px dashed #dfa992;
  border-radius: 9px;
  background: #fdf5ef;
  color: var(--ink);
  text-align: center;
  cursor: pointer;
  transition: border-color .15s ease, background .15s ease;
}
.drop-zone:is(:hover, .drag-over) {
  border-color: var(--accent-fill);
  background: var(--accent-soft);
}
.drop-zone .icon {
  width: 29px;
  height: 29px;
  margin-bottom: 3px;
  border-radius: 7px;
  color: var(--accent);
  background: #f8e1d6;
  font-size: 17px;
}
.drop-zone strong { font-size: 14px; font-weight: 680; }
.drop-zone small { color: var(--muted); font-size: 12px; line-height: 1.4; }
.sample-action {
  width: 100%;
  margin-top: 8px;
  min-height: 33px;
  padding: 5px 10px;
  border: 1px solid transparent;
  border-radius: 6px;
  background: transparent;
  color: var(--accent);
  font-size: 13px;
  font-weight: 630;
}
.sample-action:hover { background: var(--accent-soft); }
.photo-list {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin-top: 11px;
}
.photo-tile {
  min-width: 0;
  display: grid;
  gap: 4px;
  justify-items: stretch;
  align-content: start;
  background: transparent;
  padding: 4px;
  border: 1px solid transparent;
  border-radius: 8px;
}
.photo-tile:hover { background: #f5efe8; }
.photo-tile:is(.active, .selected, [aria-selected="true"], [aria-pressed="true"]) {
  border-color: var(--accent-fill);
  background: var(--accent-soft);
}
.photo-thumb {
  display: grid;
  place-items: center;
  width: 100%;
  aspect-ratio: 1;
  border-radius: 4px;
  overflow: hidden;
  color: #8b6556;
  background: #f1e8dd;
}
.photo-thumb :is(img, canvas) { display: block; width: 100%; height: 100%; object-fit: cover; }
.slot-name {
  text-align: center;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.library-footer {
  display: flex;
  align-items: flex-start;
  gap: 6px;
  margin-top: auto;
  padding: 13px 20px 16px;
  border-top: 1px solid var(--line);
  color: var(--subtle);
  font-size: 12px;
  line-height: 1.55;
}
.library-footer .icon { color: var(--accent); margin-top: 2px; }

.workspace {
  min-height: 0;
  min-width: 0;
  display: flex;
  flex-direction: column;
  background-color: #f2ede6;
  background-image: radial-gradient(circle, #c9bdb080 .75px, transparent 1px);
  background-size: 16px 16px;
  background-position: center;
}
.workspace-top, .workspace-bottom {
  position: relative;
  z-index: 1;
  display: flex;
  flex: none;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-height: 50px;
  padding: 8px 16px;
}
.workspace-top {
  background: linear-gradient(#f2ede6 32%, #f2ede600);
}
.workspace-bottom {
  margin-top: auto;
  background: linear-gradient(0deg, #f2ede6 25%, #f2ede600);
}
.view-label, .view-control, .canvas-dimensions {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  color: var(--muted);
  font-weight: 590;
  font-size: 13px;
  white-space: nowrap;
}
.view-label {
  min-height: 30px;
  padding: 4px 9px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fffcf8e8;
}
.view-label > :is(.status-dot, .view-dot, .dot, span:empty) {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #6e8671;
}
.view-control .quiet {
  color: var(--muted);
  border: 1px solid var(--line);
  background: #fffcf8e8;
}
.view-control .quiet:hover { background: var(--white); }
.view-control :is(.active, [aria-pressed="true"]) {
  color: var(--accent);
  background: var(--accent-soft);
}

.stage-shell {
  flex: 1;
  min-width: 0;
  min-height: 0;
  overflow: auto;
  scrollbar-color: #bfb0a0 transparent;
  scrollbar-width: thin;
  overscroll-behavior: contain;
}
.stage {
  display: flex;
  flex: none;
  align-items: center;
  justify-content: center;
  width: max-content;
  min-width: 100%;
  min-height: 100%;
  padding: 12px 24px;
}
.artboard {
  position: relative;
  flex: none;
  background: #fffdf6;
  box-shadow: var(--paper-shadow);
  isolation: isolate;
  touch-action: none;
}
.artboard canvas {
  display: block;
  width: 100%;
  height: 100%;
  outline-offset: 4px;
  user-select: none;
  -webkit-user-select: none;
}
.artboard canvas:has(+ .selection-box:not([hidden])) { cursor: default; }
.selection-box {
  position: absolute;
  z-index: 2;
  border: 1.5px solid var(--accent-fill);
  box-shadow: 0 0 0 1px #fff8;
  pointer-events: none;
}
.selection-box::before, .selection-box::after {
  position: absolute;
  width: 6px;
  height: 6px;
  content: "";
  border: 1px solid var(--accent-fill);
  border-radius: 1px;
  background: #fff;
}
.selection-box::before { left: -3px; top: -3px; }
.selection-box::after { right: -3px; bottom: -3px; }

.zoom-bar {
  display: inline-flex;
  min-height: 33px;
  align-items: center;
  gap: 2px;
  padding: 2px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fffdf9f2;
  box-shadow: 0 1px 3px #5b423215;
}
.zoom-bar button {
  min-width: 28px;
  min-height: 27px;
  padding: 3px 7px;
  border: 0;
  border-radius: 5px;
  color: var(--ink);
  background: transparent;
  font-weight: 650;
}
.zoom-bar button:hover:not(:disabled) { background: #f3ebe3; }
.zoom-bar :is(output, #zoom-value) {
  min-width: 45px;
  padding-inline: 4px;
  color: var(--muted);
  text-align: center;
  font-family: var(--mono);
  font-size: 12px;
}
.canvas-dimensions {
  font-family: var(--mono);
  font-size: 12px;
}

.inspector-content {
  padding: 0 20px 20px;
}
.inspector-content .tab-panel { padding: 0; }
.inspector-content .panel-divider { margin: 18px 0; }
.inspector-content h3 { font-size: 14px; margin: 0; }
.inspector-content .button { min-height: 34px; }

.field {
  display: grid;
  gap: 7px;
  margin: 0 0 15px;
}
.field-label {
  color: var(--ink);
  font-size: 14px;
  font-weight: 650;
  line-height: 1.35;
}
.field-label:has(output) {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 5px;
}
.field-label output { color: var(--muted); font: 500 12px / 1 var(--mono); }
.field-row {
  display: flex;
  align-items: center;
  gap: 8px;
}
.field-row > .field {
  flex: 1;
  min-width: 0;
}
.field-row input { min-width: 0; }
.field small { color: var(--muted); font-size: 12px; line-height: 1.5; }
.photo-actions { margin: -3px 0 15px; }
.photo-actions .button { flex: 1; }
.size-readout {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 5px;
  min-height: 36px;
  padding: 6px 9px;
  border: 1px solid var(--line);
  border-radius: 7px;
  color: var(--muted);
  background: #f8f4ef;
  font: 600 12px / 1.35 var(--mono);
}
.size-readout > :last-child {
  border-radius: 4px;
  padding: 2px 6px;
  color: var(--accent);
  background: var(--accent-soft);
}

:where(input:not([type]), input[type="text"], input[type="number"], textarea, select) {
  width: 100%;
  min-height: 37px;
  border: 1px solid var(--line-strong);
  border-radius: 7px;
  background: var(--white);
  color: var(--ink);
  padding: 7px 9px;
}
:where(input:not([type]), input[type="text"], input[type="number"], textarea, select):hover {
  border-color: #cabbad;
}
textarea {
  min-height: 70px;
  resize: vertical;
  line-height: 1.45;
}
select {
  appearance: none;
  padding-right: 29px;
  background-image: linear-gradient(45deg, transparent 50%, #7c6f64 51%), linear-gradient(135deg, #7c6f64 50%, transparent 51%);
  background-position: right 15px center, right 10px center;
  background-size: 5px 5px;
  background-repeat: no-repeat;
}
input[type="range"] { width: 100%; margin: 0; accent-color: var(--accent-fill); }
input:is([type="checkbox"], [type="radio"]) { accent-color: var(--accent-fill); }
input[type="color"] {
  min-width: 31px;
  width: 33px;
  height: 33px;
  padding: 4px;
  border: 1px solid var(--line-strong);
  border-radius: 7px;
  background: var(--white);
}
input[type="color"]::-webkit-color-swatch-wrapper { padding: 0; }
input[type="color"]::-webkit-color-swatch { border: 0; border-radius: 4px; }
input[type="color"]::-moz-color-swatch { border: 0; border-radius: 4px; }

.segmented {
  display: flex;
  gap: 4px;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f5f0ea;
}
.segmented button {
  flex: 1;
  min-width: 0;
  min-height: 30px;
  padding: 4px;
  border: 1px solid transparent;
  border-radius: 5px;
  color: var(--muted);
  background: transparent;
  line-height: 1.2;
}
.segmented button:hover { color: var(--ink); }
.segmented button:is(.active, [aria-selected="true"], [aria-pressed="true"]) {
  color: var(--accent);
  background: var(--white);
  border-color: var(--line);
  font-weight: 630;
}

.toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-height: 32px;
}
.toggle-row input[type="checkbox"] { width: 17px; height: 17px; }
.color-options {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 7px;
}
.swatch {
  position: relative;
  width: 30px;
  height: 30px;
  padding: 0;
  background: var(--swatch, var(--white));
  border: 1px solid #0003;
  border-radius: 50%;
}
.swatch:hover { outline: 1px solid var(--line-strong); outline-offset: 2px; }
.swatch:is(.active, .selected, [aria-pressed="true"]) { outline: 2px solid var(--accent-fill); outline-offset: 2px; }
.text-layer-list, .tool-list {
  display: grid;
  gap: 6px;
  margin: 0 0 14px;
  padding: 0;
  list-style: none;
}
.text-layer-list {
  max-height: 225px;
  overflow: auto;
  padding: 1px;
  scrollbar-width: thin;
}
.layer-button {
  width: 100%;
  min-height: 35px;
  min-width: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 7px;
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 6px 9px;
  color: var(--ink);
  text-align: left;
}
.layer-button > span:last-child {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.layer-button:hover { border-color: var(--accent-edge); }
.layer-button:is(.active, .selected, [aria-selected="true"], [aria-pressed="true"]) {
  border-color: var(--accent-edge);
  color: var(--accent);
  background: var(--accent-soft);
}
.inspector-note {
  display: flex;
  align-items: flex-start;
  gap: 7px;
  margin: 0 0 14px;
  padding: 10px 11px;
  border: 1px solid #ece2d8;
  border-radius: 7px;
  background: #f8f2ec;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.6;
}
.inspector-note .icon { color: var(--accent); margin-top: 3px; }
.inspector-content > .button + .inspector-note { margin-top: 12px; }
.tool-list .button { width: 100%; }
.tool-card {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 9px;
  align-items: center;
  width: 100%;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--white);
  text-align: left;
}
.tool-card:hover { border-color: var(--accent-edge); background: #fff8f3; }
.tool-card strong { display: block; font-size: 14px; line-height: 1.45; font-weight: 665; }
.tool-card small { display: block; color: var(--muted); line-height: 1.45; }
.tool-icon {
  display: grid;
  width: 31px;
  height: 31px;
  place-items: center;
  border-radius: 7px;
  font-size: 15px;
  font-weight: 700;
}
.tool-icon.peach { color: #aa4739; background: #fae6db; }
.tool-icon.lilac { color: #735696; background: #efe7f9; }
.tool-chevron { color: var(--subtle); font-size: 16px; }

.modal {
  width: min(460px, calc(100% - 26px));
  max-height: calc(100dvh - 26px);
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface);
  color: var(--ink);
  overflow: auto;
  box-shadow: 0 20px 90px #2f221d50;
}
.modal::backdrop, .modal-backdrop {
  background: #30282064;
  backdrop-filter: blur(3px);
}
.modal-head, .modal-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 15px 20px;
}
.modal-head { justify-content: space-between; border-bottom: 1px solid var(--line); }
.modal-head h2 { font-size: 19px; letter-spacing: -.02em; }
.icon-button {
  display: grid;
  place-items: center;
  width: 33px;
  height: 33px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--white);
  color: var(--muted);
  font-size: 20px;
  line-height: 1;
}
.icon-button:hover { background: #f4eee6; }
.modal-body { padding: 17px 20px; }
.modal-body p { color: var(--muted); line-height: 1.55; }
.export-detail { margin-top: 12px; font-size: 13px; }
.modal-actions { justify-content: flex-end; border-top: 1px solid var(--line); }
.export-options {
  display: grid;
  gap: 10px;
}
.export-options .field:last-child { margin-bottom: 0; }
.toast {
  position: fixed;
  z-index: 10;
  left: 50%;
  bottom: max(env(safe-area-inset-bottom), 20px);
  transform: translateX(-50%);
  max-width: min(480px, calc(100% - 24px));
  padding: 10px 14px;
  border-radius: 8px;
  background: #332923;
  color: #fff;
  font-size: 14px;
  line-height: 1.4;
  text-align: center;
  box-shadow: 0 8px 24px #33292345;
}

@media (max-width: 1140px) {
  .editor { grid-template-columns: 240px minmax(0, 1fr) 266px; }
  .tab-panel, .inspector-content { padding-inline: 15px; }
  .panel-title, .library-footer { padding-inline: 15px; }
  .panel-tabs { margin-inline: 15px; }
  .library > .panel-divider { margin-inline: 15px; }
}

@media (max-width: 860px) {
  .app-header, .site-header, body > header { grid-template-columns: 1fr auto; min-height: 62px; padding: 0 17px; }
  .header-note { display: none; }
  .workspace-bar { min-height: 62px; padding-inline: 17px; }
  .project-title { gap: 3px 10px; }
  .steps { gap: 7px; }
  .steps > * + *::before { width: 10px; margin-right: 1px; }
  .editor {
    grid-template-columns: minmax(0, 1fr);
    height: auto;
  }
  .library, .inspector {
    overflow: visible;
    border: 0;
  }
  .template-grid { grid-template-columns: repeat(2, minmax(0, 135px)); }
  .photo-list { grid-template-columns: repeat(auto-fill, minmax(56px, 1fr)); }
  .photo-thumb { max-width: 100%; }
  .workspace {
    height: clamp(440px, 78svh, 670px);
    border-block: 1px solid var(--line);
  }
  .stage { padding: 12px 15px; }
  .workspace-top, .workspace-bottom { padding: 7px 14px; }
  .inspector-content .tab-panel { padding-inline: 0; }
  .layer-button { min-height: 39px; }
}

@media (min-width: 620px) and (max-width: 860px) {
  .editor { grid-template-columns: 225px minmax(0, 1fr); }
  .library { max-height: clamp(440px, 78svh, 670px); overflow: auto; border-right: 1px solid var(--line); }
  .workspace { min-width: 0; border-top: 0; }
  .inspector { grid-column: 1 / -1; }
}

@media (max-width: 560px) {
  .app-header, .site-header, body > header { position: sticky; top: 0; z-index: 5; padding-inline: 12px; gap: 8px; }
  .brand { font-size: 17px; gap: 7px; }
  .brand-mark { flex-basis: 30px; width: 30px; height: 30px; border-radius: 8px; }
  .header-actions { gap: 6px; }
  .header-actions .button { min-height: 34px; padding: 6px 8px; font-size: 13px; gap: 4px; }
  .header-actions .icon { display: none; }
  .workspace-bar { padding-inline: 13px; min-height: 56px; gap: 8px; }
  .steps { display: none; }
  .template-preview { min-height: 72px; }
  .drop-zone { min-height: 97px; }
  .workspace { height: clamp(385px, 73svh, 560px); }
  .modal-head, .modal-body, .modal-actions { padding-inline: 14px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::after, *::before { scroll-behavior: auto !important; transition: none !important; }
}
