@charset "UTF-8";

:root {
  color-scheme: light;
  --paper: #f5f3ee;
  --surface: #fffefa;
  --surface-raised: #ffffff;
  --ink: #283634;
  --muted: #78817a;
  --faint: #a5aaa2;
  --line: #e5e7de;
  --line-strong: #d5dbcf;
  --accent: #bd5c42;
  --accent-hover: #a94d36;
  --accent-soft: #f7e8df;
  --sage: #e8eee4;
  --green: #607a64;
  --shadow: 0 5px 20px rgb(44 56 47 / 4%);
  font-family: "Yu Gothic UI", "Hiragino Kaku Gothic ProN", "Noto Sans JP", Meiryo, sans-serif;
  font-synthesis: none;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-size: 13px;
  line-height: 1.7;
}

button, input, select, textarea { font: inherit; }
button, input, select { accent-color: var(--accent); }
button, select, input[type="range"], input[type="color"] { cursor: pointer; }
button { -webkit-tap-highlight-color: transparent; }
button, input, select, textarea { color: inherit; }
button { line-height: 1.45; }
svg { flex-shrink: 0; vertical-align: middle; }
a { color: var(--accent); text-underline-offset: 3px; }

button:focus-visible, input:focus-visible, select:focus-visible,
textarea:focus-visible, a:focus-visible, summary:focus-visible,
[tabindex]:focus-visible {
  outline: 3px solid #d39b70;
  outline-offset: 3px;
}

button:disabled, input:disabled, select:disabled {
  cursor: not-allowed;
  opacity: .43;
}

button:disabled:hover { transform: none; box-shadow: none; }

.app-shell {
  display: grid;
  grid-template-columns: 270px minmax(360px, 1fr) 266px;
  grid-template-rows: auto minmax(0, 1fr) auto;
  min-height: 100vh;
  max-width: 1920px;
  margin: 0 auto;
}

.workspace {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: 270px minmax(360px, 1fr) 266px;
  min-width: 0;
  align-items: stretch;
}

.topbar {
  grid-column: 1 / -1;
  min-height: 79px;
  padding: 17px 28px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 20px;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
  position: relative;
  z-index: 2;
}

.brand { display: flex; align-items: center; gap: 12px; min-width: 0; }
.brand-mark {
  display: grid;
  place-items: center;
  width: 39px;
  height: 39px;
  flex: 0 0 auto;
  background: var(--accent-soft);
  color: var(--accent);
  border-radius: 12px 12px 12px 4px;
}
.brand-mark svg { width: 22px; height: 22px; }
.brand h1, .brand-title, .brand strong { display: block; margin: 0; font-size: 18px; font-weight: 700; letter-spacing: .09em; line-height: 1.4; }
.brand p, .brand-subtitle, .brand-sub { display: block; margin: 2px 0 0; font-size: 9px; letter-spacing: .12em; color: var(--muted); }
.brand-mark { font-size: 28px; line-height: 1; }
.top-actions { display: flex; align-items: center; gap: 9px; }
.local-badge { font-size: 11px; color: var(--muted); margin-right: 10px; display: inline-flex; align-items: center; gap: 6px; }
.local-badge::before { content: ""; width: 6px; height: 6px; background: #8d9d83; border-radius: 50%; }

.sidebar {
  min-width: 0;
  background: var(--surface);
  padding: 26px 21px 24px;
}
.settings-panel { border-right: 1px solid var(--line); }
.process-panel { border-left: 1px solid var(--line); }
.sidebar > section + section, .sidebar > .panel-section + .panel-section { margin-top: 27px; padding-top: 25px; border-top: 1px solid var(--line); }
.section-title { display: flex; flex-direction: column; align-items: flex-start; gap: 4px; margin: 0 0 14px; font-size: 12px; font-weight: 700; letter-spacing: .055em; }
.section-title:not(:first-child) { margin-top: 25px; }
.section-title h2 { margin: 0; font-size: 14px; line-height: 1.6; font-weight: 600; letter-spacing: .02em; }
.section-title > span:first-child { display: inline-flex; align-items: center; gap: 8px; }
.section-title .count { font-size: 10px; color: var(--muted); font-weight: 500; }
.section-kicker, .eyebrow { display: block; margin-bottom: 2px; color: #8c9684; font-size: 9px; letter-spacing: .14em; font-weight: 600; }
.sidebar h2 { margin-top: 0; }
.sidebar h3 { font-size: 12px; }

.dropzone {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 160px;
  padding: 20px 13px;
  text-align: center;
  border: 1.5px dashed #cbd3c3;
  border-radius: 11px;
  background: #f9faf5;
  transition: border-color .18s, background .18s;
  cursor: pointer;
  overflow: hidden;
}
.dropzone:hover, .dropzone.drag-over, .dropzone.dragover { border-color: var(--accent); background: #fbf0e9; }
.dropzone > svg { color: #86967c; width: 28px; height: 28px; margin-bottom: 4px; }
.dropzone strong { font-size: 12px; font-weight: 600; }
.dropzone .muted, .dropzone small { font-size: 10px; color: var(--muted); }
.dropzone input[type="file"] { position: absolute; width: 1px; height: 1px; opacity: 0; }
.dropzone .upload-icon { display: grid; place-items: center; width: 34px; height: 34px; border-radius: 50%; background: #edf1e5; color: #91a17f; font-size: 25px; font-weight: 300; line-height: 1; }
.dropzone > span:not(.upload-icon) { font-size: 10px; color: var(--muted); }
#sourceInfo { margin-top: 9px; font-size: 10px; overflow-wrap: anywhere; }
.dropzone:focus-within { outline: 3px solid #d39b70; outline-offset: 3px; }
.dropzone img, .source-preview { display: block; max-width: 100%; max-height: 125px; border-radius: 5px; object-fit: contain; }
.file-name { display: block; max-width: 100%; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; font-size: 11px; }
.source-meta { margin-top: 9px; color: var(--muted); font-size: 10px; overflow-wrap: anywhere; }

.field { display: flex; flex-direction: column; gap: 7px; margin: 0 0 17px; min-width: 0; }
.field:last-child { margin-bottom: 0; }
.field > label, .field-row > label, .field-label { font-size: 11px; font-weight: 600; }
.field-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.field-row output, .field output { font-size: 10px; color: var(--muted); font-variant-numeric: tabular-nums; }
.field > span { display: flex; justify-content: space-between; font-size: 11px; font-weight: 600; }
.settings-panel > label.field-row { justify-content: flex-start; align-items: flex-start; gap: 8px; margin-top: 14px; color: var(--muted); font-size: 10px; }
.settings-panel > label.field-row input { margin-top: 3px; flex-shrink: 0; }
.field small { color: var(--muted); font-size: 10px; }
select, input[type="number"], input[type="text"], textarea {
  width: 100%;
  min-height: 36px;
  border: 1px solid var(--line-strong);
  border-radius: 7px;
  background: #fffefa;
  padding: 7px 10px;
  font-size: 12px;
}
select:hover, input[type="number"]:hover, input[type="text"]:hover { border-color: #b4c0ad; }
input[type="range"] { display: block; width: 100%; height: 20px; margin: 0; background: transparent; }
input[type="checkbox"] { width: 14px; height: 14px; margin: 0; vertical-align: -2px; }
input[type="color"] { width: 31px; height: 31px; border: 1px solid var(--line); padding: 3px; border-radius: 6px; background: var(--surface-raised); }
.checkbox-label { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 11px; cursor: pointer; }

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 10px 14px;
  min-height: 38px;
  font-size: 11px;
  font-weight: 600;
  border: 1px solid transparent;
  border-radius: 7px;
  background: transparent;
  text-decoration: none;
  white-space: nowrap;
  transition: background .15s, border-color .15s, box-shadow .15s, transform .15s;
}
.button svg { width: 15px; height: 15px; }
.button.primary, .button-primary { background: var(--accent); color: #fff; border-color: var(--accent); }
.button.primary:hover:not(:disabled), .button-primary:hover:not(:disabled) { background: var(--accent-hover); border-color: var(--accent-hover); box-shadow: 0 3px 7px rgb(140 68 43 / 13%); }
.button.secondary, .button-secondary { background: #fffefa; border-color: var(--line-strong); color: var(--ink); }
.button.secondary:hover:not(:disabled), .button-secondary:hover:not(:disabled) { background: #f0f3eb; border-color: #b5c0ae; }
.button.ghost, .button-ghost { color: var(--muted); }
.button.ghost:hover:not(:disabled), .button-ghost:hover:not(:disabled) { color: var(--ink); background: var(--sage); }
.button.small { min-height: 30px; padding: 6px 9px; font-size: 10px; }
.button.full, .full-width { width: 100%; }
.button.icon-only, .icon-button { min-width: 35px; min-height: 35px; padding: 8px; }
.button.active, .button[aria-pressed="true"] { background: var(--accent-soft); color: var(--accent); border-color: #e6c3b2; }
.button-row { display: flex; gap: 7px; }
.button-row > .button { flex: 1; }
.region-tools { display: flex; flex-wrap: wrap; gap: 6px; margin: 12px 0; }
.region-tools .button { padding: 7px 9px; min-height: 31px; font-size: 10px; flex: 1; }
.region-tools select { flex: 1 1 83px; width: 83px; min-width: 0; padding-left: 7px; font-size: 11px; }
.region-tools .button { flex: 1 1 100px; }
.region-list { display: grid; gap: 6px; margin-top: 11px; max-height: 190px; overflow-y: auto; }
.region-item { display: flex; align-items: center; gap: 7px; border: 1px solid var(--line); border-radius: 7px; background: #fff; padding: 7px 9px; min-width: 0; font-size: 11px; }
.region-item.active { background: #f2f5ed; border-color: #aab99f; }
.region-item > span { overflow: hidden; text-overflow: ellipsis; }
.region-item .remove-region, .region-item .remove { margin-left: auto; padding: 0 4px; border: 0; background: transparent; color: var(--muted); }
.region-dot { width: 9px; height: 9px; border-radius: 3px; flex: 0 0 auto; background: var(--accent); }
.region-hint { font-size: 10px; color: var(--muted); line-height: 1.75; }
.parts-details { border: 1px solid var(--line); border-radius: 8px; padding: 11px; margin-top: 10px; background: #fafbf6; }
.parts-details summary { cursor: pointer; color: var(--ink); font-size: 11px; font-weight: 600; line-height: 1.6; }
.parts-details > p { line-height: 1.85; margin: 10px 0; }
.parts-details > .field-row { justify-content: flex-start; align-items: flex-start; font-size: 10px; gap: 7px; line-height: 1.7; }
.parts-details > .field-row input { flex: 0 0 auto; margin-top: 3px; }

.studio { display: flex; flex-direction: column; min-width: 0; padding: 23px 28px 25px; gap: 16px; }
.studio-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 30px; }
.studio-toolbar h2 { margin: 0; font-size: 12px; font-weight: 600; letter-spacing: .04em; }
.studio-toolbar > div:first-child { min-width: 0; }
.studio-toolbar strong { font-size: 12px; font-weight: 500; line-height: 1.7; }
.studio-toolbar .row { flex-shrink: 0; }
.studio-toolbar .row .field-row { gap: 5px; font-size: 10px; white-space: nowrap; }
.studio-toolbar .row .button { padding: 6px 8px; min-height: 32px; font-size: 10px; }
.studio-toolbar .toolbar-right { display: flex; align-items: center; gap: 8px; }
.canvas-tools { display: flex; align-items: center; justify-content: space-between; gap: 10px; min-width: 0; flex-wrap: wrap; }
.current-brush { display: flex; align-items: center; gap: 8px; min-width: 106px; }
.current-brush small { display: block; font-size: 9px; color: var(--muted); line-height: 1.5; }
.current-brush output { display: block; font-size: 12px; font-weight: 600; line-height: 1.5; font-variant-numeric: tabular-nums; }
.active-color-swatch { display: block; width: 28px; height: 28px; border-radius: 7px; box-shadow: inset 0 0 0 1px rgb(0 0 0 / 13%); flex: 0 0 auto; }
.active-color-swatch.is-empty { background: repeating-conic-gradient(#edf0e8 0 25%, #fafbf7 0 50%) 50% / 10px 10px !important; }
.view-tools { display: flex; align-items: center; gap: 5px; margin-left: auto; }
.view-tools .button { min-height: 30px; padding: 5px 8px; font-size: 11px; }
#zoomIn, #zoomOut { min-width: 29px; font-size: 15px; padding: 2px 6px; }
#zoomValue { min-width: 39px; text-align: center; font-size: 11px; font-variant-numeric: tabular-nums; color: var(--muted); }
.swatch.current-color { outline: 2px solid var(--accent); outline-offset: 2px; box-shadow: 0 0 0 4px var(--accent-soft); }
.status-pill { display: inline-flex; align-items: center; gap: 6px; border: 1px solid #dfe6d8; border-radius: 20px; background: #eef2e8; color: #6b7a60; padding: 3px 9px; font-size: 10px; white-space: nowrap; }
.status-pill::before { content: ""; width: 5px; height: 5px; border-radius: 50%; background: currentColor; }
.status-pill.working { background: var(--accent-soft); border-color: #e9d1bf; color: var(--accent); }
.status-pill.error { color: #aa4439; background: #fae8e3; border-color: #e8c4ba; }
.canvas-wrap {
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  min-height: 330px;
  height: clamp(360px, 58vh, 690px);
  width: 100%;
  padding: 22px;
  border: 1px solid #dfe3d8;
  border-radius: 12px;
  background-color: #ebece4;
  background-image: radial-gradient(#d4d9cb .65px, transparent .65px);
  background-size: 8px 8px;
  overflow: hidden;
  container-type: size;
  touch-action: none;
  user-select: none;
  cursor: grab;
}
.canvas-wrap.editing { outline: 2px solid #b5bf9e; outline-offset: -2px; }
.canvas-wrap.is-panning, .canvas-wrap.view-panning { cursor: grabbing; }
.canvas-wrap.editing { cursor: crosshair; }
.canvas-frame {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 100%;
  height: 100%;
  max-width: none;
  max-height: none;
  transform-origin: center;
  transform: translate(-50%, -50%);
  line-height: 0;
  box-shadow: 0 6px 24px rgb(50 59 40 / 10%), 0 1px 2px rgb(50 59 40 / 6%);
  background: white;
  overflow: hidden;
}
#drawingCanvas {
  display: block;
  max-width: none;
  max-height: none;
  width: 100%;
  height: 100%;
  background: #fff;
}
#regionCanvas { position: absolute; inset: 0; width: 100%; height: 100%; z-index: 2; touch-action: none; cursor: crosshair; }
#regionCanvas:not(.active) { pointer-events: none; }
#regionCanvas.active { pointer-events: auto; }
.canvas-frame.editing #regionCanvas, .canvas-wrap.editing #regionCanvas { pointer-events: auto; }
.canvas-note { position: absolute; left: 12px; bottom: 10px; font-size: 9px; color: #909987; pointer-events: none; }
.canvas-gesture-hint { position: absolute; left: 10px; bottom: 8px; padding: 3px 6px; background: rgb(248 249 244 / 86%); border-radius: 4px; color: #77836f; font-size: 9px; line-height: 1.4; pointer-events: none; z-index: 3; }
.magnifier-target { position: absolute; width: 13px; height: 13px; transform: translate(-50%, -50%); border: 2px solid #fff; border-radius: 50%; box-shadow: 0 0 0 1px #34423c; z-index: 7; pointer-events: none; }
.magnifier-target::before, .magnifier-target::after { content: ''; position: absolute; background: #34423c; }
.magnifier-target::before { width: 17px; height: 1px; top: 4px; left: -4px; }
.magnifier-target::after { width: 1px; height: 17px; top: -4px; left: 4px; }
.magnifier { position: absolute; z-index: 8; display: flex; flex-direction: column; width: 260px; max-width: calc(100% - 12px); border: 1px solid #b4bdac; border-radius: 10px; overflow: hidden; box-shadow: 0 6px 25px rgb(36 48 33 / 30%); background: #fff; pointer-events: none; }
.magnifier-controls { display: inline-flex; align-items: center; gap: 5px; }
.magnifier-controls select { width: 63px; min-height: 30px; padding: 3px 5px; font-size: 11px; background: #fff; }
.magnifier-controls .button { min-height: 30px; padding: 1px 7px; font-size: 17px; }
#magnifierCanvas { display: block; width: 100%; height: 0; flex: 1 1 0; min-height: 0; background: #fff; pointer-events: none; }
.empty-state { position: absolute; inset: 0; max-width: none; padding: 28px; text-align: center; color: var(--muted); display: flex; flex-direction: column; align-items: center; justify-content: center; line-height: 1.7; background: #fffefa; }
.empty-state > span { color: #9fae92; font-size: 50px; margin-bottom: 8px; line-height: 1.3; }
.empty-state h1 { margin: 0 0 12px; color: #5d6c55; font-size: clamp(19px, 2vw, 28px); line-height: 1.6; letter-spacing: .06em; font-weight: 500; }
.empty-state > svg, .empty-icon { width: 54px; height: 54px; color: #9fae92; margin: 0 auto 20px; }
.empty-state h2, .empty-state h3 { margin: 0 0 9px; font-size: 17px; line-height: 1.6; font-weight: 500; color: #63715c; letter-spacing: .04em; }
.empty-state p { margin: 0; font-size: 11px; line-height: 1.9; }
.empty-state .button { margin-top: 20px; }
.empty-state .empty-steps { display: flex; justify-content: center; gap: 13px; margin-top: 23px; color: #8f9a86; font-size: 10px; }
.empty-state .empty-steps span + span::before { content: "→"; margin-right: 13px; color: #aeb6a8; }

.transport { display: flex; align-items: center; gap: 12px; min-width: 0; }
.transport .play-button { flex: 0 0 auto; width: 89px; min-width: 82px; height: 38px; padding: 8px 12px; border-radius: 7px; }
.transport .icon-button { border: 0; background: transparent; color: #66745e; }
.transport .icon-button:hover:not(:disabled) { background: var(--sage); border-radius: 50%; }
.timeline { flex: 1 1 0; min-width: 40px; width: auto !important; }
.timeline input[type="range"], input.timeline { width: 100%; }
.timeline-labels { display: flex; justify-content: space-between; color: var(--muted); font-size: 9px; margin-top: 2px; font-variant-numeric: tabular-nums; }
.time-display { font-size: 10px; color: var(--muted); white-space: nowrap; font-variant-numeric: tabular-nums; }
.transport .speed-select { max-width: 65px; min-height: 30px; padding: 3px 5px; background: transparent; font-size: 10px; }
#speed { width: 76px; flex: 0 0 76px; min-height: 31px; padding: 4px 6px; font-size: 11px; }
.transport #restartButton { min-width: 28px; padding: 4px; font-size: 21px; }
.stage-strip { display: flex; gap: 8px; overflow-x: auto; padding: 1px 1px 8px; scrollbar-width: thin; scrollbar-color: #c6cdbf transparent; }
.stage-card { flex: 0 0 176px; display: block; min-width: 0; max-width: calc(100vw - 48px); min-height: 50px; padding: 10px 11px; border: 1px solid var(--line-strong); border-radius: 8px; background: rgb(255 254 250 / 65%); color: var(--muted); text-align: left; font-size: 10px; line-height: 1.55; white-space: normal; overflow-wrap: anywhere; }
.stage-card .stage-index, .stage-card > small { font-size: 9px; color: #919b88; letter-spacing: .08em; }
.stage-card strong, .stage-card .stage-name { display: block; font-size: 11px; margin-top: 4px; font-weight: 600; }
.stage-card .stage-time { font-size: 9px; color: var(--faint); margin-top: 3px; }
.stage-card.active { border-color: #cf9f7e; background: #fcf0e5; color: #9f5b3d; }
.stage-card.active .stage-index { color: #ba8968; }
.stage-card.complete { border-color: #d3dcc9; background: #edf2e7; color: #6f7f62; }
.stage-card:hover:not(:disabled) { border-color: #aebda3; }

.process-list { display: grid; gap: 4px; max-height: min(55vh, 520px); overflow-y: auto; scrollbar-width: thin; scrollbar-color: #cad2c1 transparent; padding-right: 4px; }
.process-item { display: flex; align-items: flex-start; gap: 11px; width: 100%; position: relative; border: 1px solid transparent; border-radius: 8px; padding: 12px 10px; background: transparent; text-align: left; }
.process-item:hover:not(:disabled) { background: #f4f6ef; }
.step-num { display: grid; place-items: center; flex-shrink: 0; width: 25px; height: 25px; border-radius: 50%; background: #eef1e8; border: 1px solid #e4e9db; color: #8f9a84; font-size: 10px; font-variant-numeric: tabular-nums; }
.step-copy { flex: 1; min-width: 0; padding-top: 2px; }
.step-copy strong { display: block; font-size: 11px; font-weight: 600; color: #75816b; }
.step-copy p { margin: 5px 0 0; font-size: 10px; color: #9aa28f; line-height: 1.65; }
.step-copy > span { display: block; margin-top: 4px; font-size: 10px; color: #929c87; line-height: 1.65; }
.stage-meta { display: block; color: #929c87; font-size: 9px; margin-top: 4px; }
.process-item.active { background: #faf0e7; border-color: #ecd6c4; }
.process-item.active .step-num { color: #fff; background: var(--accent); border-color: var(--accent); }
.process-item.active .step-copy strong { color: #9c593c; }
.process-item.active .step-copy p, .process-item.active .stage-meta { color: #ab8b70; }
.process-item.complete .step-num { background: #e5eddf; border-color: #d8e2d1; color: #6b825f; }
.process-item.complete .step-copy strong { color: #6b7d60; }
.process-item.complete::after { content: "✓"; color: #829572; font-size: 12px; margin-top: 5px; }
.palette { display: flex; flex-wrap: wrap; gap: 7px; max-height: 138px; overflow-y: auto; padding: 2px; scrollbar-width: thin; }
.swatch { width: 25px; height: 25px; border-radius: 50%; border: 2px solid var(--surface); box-shadow: 0 0 0 1px #dfe4d8; padding: 0; }
.swatch.active { box-shadow: 0 0 0 2px var(--accent); }
.palette-label { margin: 9px 0 0; font-size: 10px; color: var(--muted); }
#planStats { font-size: 10px; margin: 12px 0; }
.process-panel > .notice { margin-top: 17px; font-size: 10px; }
.process-panel details { border-top: 1px solid var(--line); padding-top: 15px; margin-top: 22px; font-size: 10px; color: var(--muted); }
.process-panel summary { cursor: pointer; font-weight: 600; color: #74816b; }
.process-panel details p { line-height: 1.9; margin-bottom: 0; }
.process-panel .mini-info { border-radius: 8px; background: #f3f5ed; padding: 12px; font-size: 10px; color: #88957c; margin-top: 18px; }

.banner, .notice { border: 1px solid #e4dcc8; background: #faf5e8; color: #8b7952; padding: 10px 13px; border-radius: 7px; font-size: 11px; line-height: 1.8; }
.banner.error, .notice.error { border-color: #e4c5b8; background: #fbede6; color: #a9543d; }
.banner.success, .notice.success { border-color: #d4e0c7; background: #eff4e8; color: #6e845e; }
.progress-track { width: 100%; height: 4px; border-radius: 4px; overflow: hidden; background: #e8ecdf; margin: 10px 0 4px; }
.progress-fill { width: 0; height: 100%; border-radius: inherit; background: var(--accent); transition: width .2s ease; }
.bottom-note { grid-column: 1 / -1; border-top: 1px solid var(--line); padding: 12px 28px; font-size: 10px; color: #909a86; background: var(--surface); display: flex; justify-content: space-between; gap: 15px; }
.bottom-note p { margin: 0; }
.bottom-note .version { font-size: 9px; letter-spacing: .06em; white-space: nowrap; }

.row { display: flex; align-items: center; gap: 8px; }
.row.between { justify-content: space-between; }
.muted { color: var(--muted); }
.small { font-size: 11px; }
.hidden, [hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }
.segmented { display: flex; gap: 3px; padding: 3px; border: 1px solid var(--line); border-radius: 7px; background: #f0f3e9; }
.segmented button { flex: 1; border: 0; border-radius: 4px; padding: 5px 8px; background: transparent; color: var(--muted); font-size: 10px; }
.segmented button.active, .segmented button[aria-pressed="true"] { background: #fff; color: var(--ink); box-shadow: 0 1px 3px rgb(40 55 32 / 8%); }

dialog.modal { width: min(500px, calc(100vw - 36px)); border: 1px solid var(--line-strong); border-radius: 14px; padding: 26px; background: var(--surface); color: var(--ink); box-shadow: 0 20px 80px rgb(35 48 29 / 20%); }
dialog.modal::backdrop { background: rgb(39 49 34 / 32%); backdrop-filter: blur(3px); }
.modal h2 { margin: 0 0 12px; font-size: 17px; }
.modal p { font-size: 12px; color: var(--muted); }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 23px; }

dialog.sample-modal { width: min(900px, calc(100vw - 36px)); max-height: calc(100dvh - 36px); overflow-y: auto; }
.sample-dialog-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; }
.sample-dialog-header h2 { margin: 0; }
.sample-dialog-header .button { padding: 4px 10px; min-height: 32px; font-size: 12px; }
.sample-intro { margin: 10px 0 20px; line-height: 1.7; }
.sample-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; }
.sample-card { display: flex; flex-direction: column; min-width: 0; padding: 0; border: 1px solid var(--line-strong); border-radius: 10px; background: #fffefa; color: var(--ink); overflow: hidden; text-align: left; transition: border-color .15s, box-shadow .15s; }
.sample-card:hover:not(:disabled) { border-color: var(--accent); box-shadow: 0 3px 14px rgb(77 90 61 / 12%); }
.sample-card:focus-visible { outline: 3px solid var(--accent); outline-offset: 3px; }
.sample-thumb { display: block; width: 100%; height: auto; aspect-ratio: 4 / 3; object-fit: contain; background: #edece5; }
.sample-copy { display: flex; flex: 1; flex-direction: column; gap: 5px; padding: 13px 14px 15px; min-width: 0; overflow-wrap: anywhere; }
.sample-style { color: var(--accent); font-size: 10px; letter-spacing: .06em; }
.sample-title { font-size: 13px; font-weight: 600; line-height: 1.6; }
.sample-description { font-size: 11px; line-height: 1.7; color: var(--muted); }
@media (max-width: 600px) {
  dialog.sample-modal { padding: 20px; }
  .sample-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .sample-copy { padding: 10px; }
}
@media (max-width: 380px) {
  .sample-grid { grid-template-columns: minmax(0, 1fr); }
}

@media (min-width: 1550px) {
  .app-shell, .workspace { grid-template-columns: 285px minmax(360px, 1fr) 285px; }
  .studio { padding-left: 38px; padding-right: 38px; }
  .sidebar { padding-left: 26px; padding-right: 26px; }
}

@media (min-width: 1150px) {
  html, body { height: 100%; overflow: hidden; }
  .app-shell { height: 100dvh; min-height: 0; grid-template-rows: 79px minmax(0, 1fr) 40px; }
  .sidebar { min-height: 0; overflow-y: auto; scrollbar-width: thin; scrollbar-color: #cad2c1 transparent; }
  .studio { display: grid; grid-template-rows: auto auto minmax(130px, 1fr) auto auto auto; min-height: 0; overflow: hidden; gap: 12px; padding-top: 20px; padding-bottom: 20px; }
  .studio-toolbar { min-height: 36px; }
  .canvas-wrap { min-height: 0; height: 100%; max-height: calc(100dvh - 270px); padding: 18px; }
  #drawingCanvas { max-height: none; max-width: none; }
  .stage-strip { min-height: 0; margin-bottom: -4px; }
  .stage-strip > .notice { width: 100%; }
  .studio > .notice { font-size: 10px; padding: 8px 11px; line-height: 1.75; }
  .process-panel { display: flex; flex-direction: column; }
  .process-panel .process-list { flex: 1 0 210px; min-height: 210px; max-height: min(55vh, 520px); }
  .process-panel > .section-title, .process-panel > .palette, .process-panel > .notice, .process-panel > #planStats { flex-shrink: 0; }
  .bottom-note { padding-top: 10px; padding-bottom: 10px; align-items: center; }
}

@media (max-width: 1149px) {
  .app-shell, .workspace { grid-template-columns: 248px minmax(360px, 1fr); }
  .sidebar { padding: 22px 18px; }
  .studio { padding: 21px; }
  .process-panel { grid-column: 2; border-left: 0; border-top: 1px solid var(--line); padding-top: 20px; }
  .process-panel .process-list { grid-template-columns: repeat(3, 1fr); gap: 5px; }
  .process-panel .process-item { padding: 9px 7px; gap: 7px; }
  .process-panel .step-copy p { display: none; }
  .process-panel > section + section { padding-top: 17px; margin-top: 17px; }
  .settings-panel { grid-row: span 2; }
  .canvas-wrap { height: clamp(360px, 56vh, 650px); }
  #drawingCanvas { max-height: 100cqh; }
  .topbar { padding-left: 22px; padding-right: 22px; }
}

@media (max-width: 760px) {
  html, body { overflow: auto; height: auto; }
  .app-shell, .workspace { display: flex; flex-direction: column; min-width: 0; }
  .topbar { order: 0; padding: 14px 17px; min-height: 72px; flex-wrap: wrap; gap: 13px; }
  .brand h1, .brand-title, .brand strong { font-size: 16px; }
  .brand-mark { width: 34px; height: 34px; }
  .brand p { font-size: 9px; }
  .top-actions { margin-left: auto; }
  .top-actions .local-badge { display: none; }
  .top-actions .button { padding: 8px 10px; min-height: 34px; }
  .workspace { order: 1; }
  .settings-panel { order: 1; border-right: 0; border-bottom: 1px solid var(--line); }
  .studio { order: 2; padding: 20px 16px; gap: 14px; }
  .process-panel { order: 3; }
  .bottom-note { order: 4; padding: 12px 17px; flex-direction: column; gap: 3px; }
  .sidebar { padding: 21px 18px; }
  .settings-panel { display: block; }
  .settings-panel > section + section, .settings-panel > .panel-section + .panel-section { padding: 0; margin: 0; border-top: 0; }
  .settings-panel > :first-child { grid-column: 1 / -1; }
  .dropzone { min-height: 118px; padding: 15px; }
  .dropzone > svg { width: 23px; height: 23px; margin-bottom: 0; }
  .canvas-wrap { padding: 16px; height: min(63vh, 570px); min-height: 300px; border-radius: 9px; }
  #drawingCanvas { max-height: 100cqh; }
  .empty-state { padding: 18px; }
  .empty-state h2, .empty-state h3 { font-size: 15px; }
  .transport { gap: 8px; }
  .transport .play-button { min-width: 70px; width: 70px; padding: 7px; }
  .time-display { font-size: 9px; }
  .stage-card { flex-basis: 99px; }
  .process-panel .process-list { grid-template-columns: repeat(3, 1fr); }
}

@media (max-width: 440px) {
  .topbar { gap: 10px; }
  .top-actions .button { font-size: 10px; gap: 5px; }
  .top-actions .button svg { width: 13px; height: 13px; }
  .settings-panel { grid-template-columns: 1fr; gap: 22px; }
  .settings-panel > section + section { border-top: 1px solid var(--line); padding-top: 19px; }
  .settings-panel .dropzone { min-height: 130px; }
  .process-panel .process-list { grid-template-columns: repeat(2, 1fr); }
  .canvas-wrap { min-height: 270px; }
  .studio-toolbar h2 { font-size: 11px; }
  .status-pill { font-size: 9px; }
  .transport .speed-select { max-width: 55px; }
  #speed { width: 70px; flex-basis: 70px; }
  .transport { flex-wrap: wrap; }
  .transport .timeline { order: 5; flex-basis: calc(100% - 15px); }
  .transport .time-display { margin-left: auto; }
  .top-actions { width: 100%; justify-content: flex-end; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; scroll-behavior: auto !important; }
}
