/* 간편 이미지 편집기 - 스타일
   1) 사이트 공통(헤더/푸터/본문)은 시스템 라이트/다크 테마를 따르고,
   2) 편집기(.app, 메뉴, 대화상자)는 항상 어두운 작업 화면 색(--ed-*)을 씁니다.
   색은 :root 변수로만 관리합니다. */

:root {
  /* 사이트 */
  --bg: #f4f5f7;
  --card: #ffffff;
  --text: #1c2230;
  --muted: #5b6474;
  --line: #dde1e8;
  --primary: #2563eb;
  --primary-text: #ffffff;
  --radius: 8px;

  /* 편집기 (항상 어둡게) */
  --ed-bg: #26272b;
  --ed-panel: #2f3035;
  --ed-panel-2: #383a40;
  --ed-stage: #1c1d20;
  --ed-line: #45474e;
  --ed-text: #e8e9ec;
  --ed-muted: #a3a6ae;
  --ed-accent: #4d8dff;
  --ed-accent-bg: rgb(77 141 255 / 0.22);
  --ed-hover: #3d3f46;
  --checker-a: #4a4c52;
  --checker-b: #3a3c41;
  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1218;
    --card: #171c25;
    --text: #e7eaf0;
    --muted: #9aa3b2;
    --line: #2a3240;
    --primary: #4c8dff;
  }
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", "Malgun Gothic", "Apple SD Gothic Neo", sans-serif;
  line-height: 1.6;
}

a {
  color: var(--primary);
}

:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 16px;
}

.skip-link {
  position: absolute;
  left: -9999px;
}

.skip-link:focus {
  left: 16px;
  top: 8px;
  background: var(--card);
  padding: 6px 10px;
  z-index: 100;
}

/* ================= 사이트 헤더 / 푸터 ================= */

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

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
  min-height: 44px;
}

.brand {
  font-weight: 700;
  color: var(--text);
  text-decoration: none;
}

.site-nav {
  display: flex;
  gap: 16px;
}

.site-nav a {
  color: var(--muted);
  text-decoration: none;
}

.site-nav a:hover {
  color: var(--text);
}

.site-footer {
  margin-top: 48px;
  padding: 24px 0;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 14px;
}

.site-footer nav {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 8px;
}

.site-footer p {
  margin: 0;
}

/* ================= 본문 / 공통 요소 ================= */

main {
  padding-bottom: 24px;
}

h1 {
  font-size: 26px;
  margin: 24px 0 4px;
}

h2 {
  font-size: 20px;
}

.lead {
  margin: 0 0 20px;
  color: var(--muted);
}

.hint {
  font-size: 13px;
  color: var(--muted);
  margin: 8px 0;
}

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
}

.content {
  max-width: 800px;
  margin: 40px auto 0;
}

.content.flush {
  margin-top: 0;
}

.content.narrow-center {
  margin-top: 48px;
  text-align: center;
}

.content h2 {
  margin-top: 36px;
}

.content h3 {
  font-size: 17px;
  margin-bottom: 4px;
}

.content p,
.content li {
  color: var(--muted);
}

.btn {
  font: inherit;
  padding: 7px 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--card);
  color: var(--text);
  cursor: pointer;
  text-decoration: none;
  display: inline-block;
}

.btn:hover:not(:disabled) {
  border-color: var(--primary);
}

.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.btn.primary {
  background: var(--primary);
  border-color: var(--primary);
  color: var(--primary-text);
}

.btn.sm {
  padding: 3px 9px;
  font-size: 13px;
}

.btn.wide {
  width: 100%;
}

/* ================= 편집기 레이아웃 ================= */

#app {
  display: grid;
  grid-template-columns: 46px minmax(0, 1fr) 280px;
  grid-template-rows: auto auto minmax(0, 1fr) auto;
  grid-template-areas:
    "menubar menubar menubar"
    "options options options"
    "toolbox workspace panels"
    "status status status";
  height: calc(100vh - 45px);
  min-height: 540px;
  background: var(--ed-bg);
  color: var(--ed-text);
  font-size: 13px;
  line-height: 1.4;
  user-select: none;
}

#app .btn,
.dlg .btn,
.menu-panel {
  --card: var(--ed-panel-2);
  --text: var(--ed-text);
  --line: var(--ed-line);
  --primary: var(--ed-accent);
}

.menubar {
  grid-area: menubar;
  display: flex;
  background: var(--ed-panel);
  border-bottom: 1px solid var(--ed-line);
  padding: 0 4px;
}

.menu-btn {
  font: inherit;
  padding: 6px 10px;
  border: 0;
  background: none;
  color: var(--ed-text);
  cursor: pointer;
}

.menu-btn:hover,
.menu-btn[aria-expanded="true"] {
  background: var(--ed-hover);
}

.optionsbar {
  grid-area: options;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 4px 12px;
  min-height: 40px;
  padding: 4px 10px;
  background: var(--ed-panel-2);
  border-bottom: 1px solid var(--ed-line);
}

.opt-tool {
  display: flex;
  align-items: center;
  gap: 6px;
  padding-right: 10px;
  border-right: 1px solid var(--ed-line);
  font-weight: 600;
  white-space: nowrap;
}

.opt-sep {
  width: 1px;
  height: 20px;
  background: var(--ed-line);
}

.opt-readout {
  color: var(--ed-muted);
  white-space: nowrap;
}

.toolbox {
  grid-area: toolbox;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 6px 0;
  background: var(--ed-panel);
  border-right: 1px solid var(--ed-line);
  overflow-y: auto;
}

.tool-btn {
  width: 34px;
  height: 32px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 5px;
  background: none;
  color: var(--ed-text);
  cursor: pointer;
}

.tool-btn:hover {
  background: var(--ed-hover);
}

.tool-btn[aria-pressed="true"] {
  background: var(--ed-accent);
  color: #fff;
}

.tool-sep {
  width: 24px;
  height: 1px;
  margin: 4px 0;
  background: var(--ed-line);
}

.workspace {
  grid-area: workspace;
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
}

.doc-tab {
  display: flex;
  gap: 12px;
  align-items: baseline;
  padding: 4px 12px;
  background: var(--ed-panel);
  border-bottom: 1px solid var(--ed-line);
}

.doc-name {
  font-weight: 600;
}

.doc-info {
  color: var(--ed-muted);
}

.stage-frame {
  --rw: 0px;
  flex: 1;
  min-height: 0;
  position: relative;
  display: grid;
  grid-template-columns: var(--rw) minmax(0, 1fr);
  grid-template-rows: var(--rw) minmax(0, 1fr);
}

.ruler,
.ruler-corner {
  background: var(--ed-panel);
  color: var(--ed-muted, #9aa0a6);
  display: block;
}

.ruler[hidden] {
  display: none;
}

.ruler-corner {
  grid-area: 1 / 1;
  border-right: 1px solid var(--ed-line);
  border-bottom: 1px solid var(--ed-line);
}

.ruler-top {
  grid-area: 1 / 2;
  width: 100%;
  height: var(--rw);
  cursor: ns-resize;
  border-bottom: 1px solid var(--ed-line);
}

.ruler-left {
  grid-area: 2 / 1;
  width: var(--rw);
  height: 100%;
  cursor: ew-resize;
  border-right: 1px solid var(--ed-line);
}

.guide-layer {
  position: absolute;
  left: var(--rw);
  top: var(--rw);
  right: 0;
  bottom: 0;
  overflow: hidden;
  pointer-events: none;
}

.guide {
  position: absolute;
  background: #29b6f6;
  opacity: 0.85;
}

.guide-v {
  top: 0;
  bottom: 0;
  width: 1px;
}

.guide-h {
  left: 0;
  right: 0;
  height: 1px;
}

.stage-body {
  grid-area: 2 / 2;
  flex: 1;
  min-height: 0;
  display: flex;
  overflow: auto;
  padding: 16px;
  background: var(--ed-stage);
  touch-action: none;
}

.empty,
.canvas-wrap {
  margin: auto; /* flex 컨테이너에서 가운데 정렬하되 확대 시 왼쪽/위쪽이 잘리지 않게 함 */
  flex: none;
}

.empty {
  text-align: center;
  max-width: 440px;
  padding: 28px;
  background: var(--ed-panel);
  border: 1px solid var(--ed-line);
  border-radius: var(--radius);
  user-select: text;
}

.empty-title {
  font-weight: 700;
  font-size: 18px;
  margin: 0 0 8px;
}

.empty p {
  margin: 0 0 14px;
  color: var(--ed-muted);
}

.empty-actions {
  display: flex;
  gap: 8px;
  justify-content: center;
  margin-bottom: 12px;
}

.is-dragover .stage-body {
  outline: 2px dashed var(--ed-accent);
  outline-offset: -8px;
}

.canvas-wrap {
  position: relative;
  line-height: 0;
  background: repeating-conic-gradient(var(--checker-a) 0% 25%, var(--checker-b) 0% 50%) 50% / 16px 16px;
  box-shadow: 0 2px 14px rgb(0 0 0 / 0.5);
}

#canvas {
  display: block;
  max-width: none;
  height: auto;
  image-rendering: auto;
}

.canvas-wrap.zoomed #canvas {
  image-rendering: pixelated;
}

#overlay,
#selection,
.tool-layer {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

.tool-layer {
  overflow: hidden;
}

/* 캔버스 위에 얹는 도구 UI */
.brush-ring {
  position: absolute;
  left: 0;
  top: 0;
  border: 1px solid #fff;
  border-radius: 50%;
  box-shadow: 0 0 0 1px rgb(0 0 0 / 0.7);
  pointer-events: none;
}

.clone-source {
  position: absolute;
  left: 0;
  top: 0;
  width: 16px;
  height: 16px;
  border: 1px solid #fff;
  border-radius: 50%;
  box-shadow: 0 0 0 1px #000;
  pointer-events: none;
}

.crop-box,
.xf-box {
  position: absolute;
  border: 2px dashed #fff;
  pointer-events: none;
  transform-origin: center;
}

.crop-box {
  box-shadow: 0 0 0 9999px rgb(0 0 0 / 0.55);
}

.xf-box {
  border-style: solid;
  border-width: 1px;
  outline: 1px solid #000;
}

.crop-handle {
  position: absolute;
  width: 12px;
  height: 12px;
  background: #fff;
  border: 1px solid #000;
}

.h-nw { left: 0; top: 0; }
.h-n { left: calc(50% - 6px); top: 0; }
.h-ne { right: 0; top: 0; }
.h-e { right: 0; top: calc(50% - 6px); }
.h-se { right: 0; bottom: 0; }
.h-s { left: calc(50% - 6px); bottom: 0; }
.h-sw { left: 0; bottom: 0; }
.h-w { left: 0; top: calc(50% - 6px); }

.zoom-rect {
  position: absolute;
  border: 1px dashed #fff;
  background: rgb(77 141 255 / 0.15);
  pointer-events: none;
}

.grid-overlay {
  position: absolute;
  inset: 0;
  background-image: linear-gradient(to right, rgb(120 160 255 / 0.5) 1px, transparent 1px), linear-gradient(to bottom, rgb(120 160 255 / 0.5) 1px, transparent 1px);
  pointer-events: none;
}

.text-edit {
  position: absolute;
  margin: 0;
  padding: 0;
  border: 1px dashed var(--ed-accent);
  background: transparent;
  color: transparent; /* 글자는 레이어에 그려진 것을 보여주고, 입력 상자는 캐럿/선택만 표시 */
  resize: none;
  overflow: hidden;
  outline: none;
  white-space: pre;
  pointer-events: auto;
  user-select: text;
}

.text-edit::selection {
  background: rgb(77 141 255 / 0.45);
}

/* ================= 패널 ================= */

.panels {
  grid-area: panels;
  display: flex;
  flex-direction: column;
  min-height: 0;
  background: var(--ed-panel);
  border-left: 1px solid var(--ed-line);
  overflow-y: auto;
}

.panel {
  display: flex;
  flex-direction: column;
  border-bottom: 1px solid var(--ed-line);
  min-height: 0;
}

.panel.grow {
  flex: 1 1 260px;
  min-height: 200px;
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 5px 10px;
  background: var(--ed-panel-2);
  border-bottom: 1px solid var(--ed-line);
  cursor: pointer;
}

.panel-head::after {
  content: "▾";
  color: var(--ed-muted);
}

.panel.collapsed > .panel-head::after {
  content: "▸";
}

.panel.collapsed > :not(.panel-head) {
  display: none;
}

.panel.collapsed.grow {
  flex: 0 0 auto;
  min-height: 0;
}

.panel-title {
  font-weight: 600;
  text-transform: uppercase;
  font-size: 11px;
  letter-spacing: 0.04em;
  color: var(--ed-muted);
}

.panel-body {
  padding: 8px;
  min-height: 0;
  overflow: auto;
}

/* 색상 패널 */
.chips {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  margin-bottom: 8px;
}

.chip-stack {
  position: relative;
  width: 48px;
  height: 44px;
  flex: none;
}

.chip {
  position: absolute;
  width: 28px;
  height: 28px;
  border: 2px solid var(--ed-line);
  border-radius: 3px;
  cursor: pointer;
  padding: 0;
}

.chip-fg { left: 0; top: 0; z-index: 2; }
.chip-bg { left: 16px; top: 14px; }
.chip.active { border-color: var(--ed-accent); }
.chip-tools { display: flex; flex-direction: column; gap: 2px; }
.color-values { display: flex; flex-direction: column; gap: 4px; flex: 1; min-width: 0; }

.hex-input,
.rgb-input,
.ctl-text,
.ctl-num,
.ctl-select,
.zoom-input {
  font: inherit;
  padding: 3px 6px;
  border: 1px solid var(--ed-line);
  border-radius: 4px;
  background: var(--ed-stage);
  color: var(--ed-text);
  min-width: 0;
}

.hex-input { width: 100%; }
.rgb-row { display: flex; gap: 4px; }
.rgb-input { width: 100%; }

.color-sv,
.color-hue {
  display: block;
  width: 100%;
  border-radius: 3px;
  cursor: crosshair;
  touch-action: none;
}

.color-sv { height: 90px; }
.color-hue { height: 14px; margin: 6px 0; }

.swatch-grid {
  display: grid;
  grid-template-columns: repeat(12, 1fr);
  gap: 2px;
}

.swatch {
  aspect-ratio: 1;
  border: 1px solid var(--ed-line);
  border-radius: 2px;
  padding: 0;
  cursor: pointer;
}

/* 레이어 패널 */
.layers-body {
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex: 1;
  min-height: 0;
}

.layer-props {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.layer-locks {
  display: flex;
  align-items: center;
  gap: 4px;
}

.layer-list {
  list-style: none;
  margin: 0;
  padding: 0;
  flex: 1;
  min-height: 80px;
  overflow-y: auto;
  border: 1px solid var(--ed-line);
  background: var(--ed-stage);
}

.layer {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 3px 6px;
  border-bottom: 1px solid var(--ed-line);
  cursor: pointer;
}

.layer.is-active { background: var(--ed-accent-bg); }
.layer.is-hidden .layer-name { opacity: 0.5; }
.layer.is-clipped { padding-left: 22px; }
.layer { padding-left: calc(6px + var(--depth, 0) * 14px); }
.layer.is-clipped { padding-left: calc(22px + var(--depth, 0) * 14px); }
.layer.drop-above { box-shadow: inset 0 2px 0 var(--ed-accent); }
.layer.drop-below { box-shadow: inset 0 -2px 0 var(--ed-accent); }
.layer.drop-into { box-shadow: inset 0 0 0 2px var(--ed-accent); }
.layer.is-group .layer-name { font-weight: 600; }

.layer-twist {
  flex: none;
  width: 14px;
  padding: 0;
  border: 0;
  background: none;
  color: var(--ed-muted);
  cursor: pointer;
  font-size: 11px;
  line-height: 1;
}

.layer-twist.spacer { cursor: default; }

.kind-thumb {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--ed-muted);
  background: var(--ed-panel-2);
}

.adjust-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
}

.layer-thumbs { display: flex; gap: 4px; }

.layer-thumb {
  flex: none;
  width: 34px;
  height: 26px;
  border: 1px solid var(--ed-line);
  background: repeating-conic-gradient(var(--checker-a) 0% 25%, var(--checker-b) 0% 50%) 50% / 8px 8px;
}

.layer-thumb.mask-thumb { background: #000; }
.layer-thumb.editing { outline: 2px solid var(--ed-accent); }
.layer-thumb.disabled { opacity: 0.4; }

.layer-name {
  flex: 1;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.layer-badges {
  display: flex;
  gap: 3px;
  align-items: center;
  color: var(--ed-muted);
}

.badge {
  font-size: 10px;
  font-weight: 700;
  border: 1px solid var(--ed-muted);
  border-radius: 3px;
  padding: 0 3px;
}

.layer-actions {
  display: flex;
  gap: 2px;
  justify-content: space-between;
}

.icon-btn {
  display: inline-grid;
  place-items: center;
  width: 28px;
  height: 26px;
  padding: 0;
  border: 0;
  border-radius: 4px;
  background: none;
  color: var(--ed-text);
  cursor: pointer;
}

.icon-btn:hover:not(:disabled) { background: var(--ed-hover); }
.icon-btn[aria-pressed="true"] { background: var(--ed-accent-bg); color: var(--ed-accent); }
.icon-btn:disabled { opacity: 0.4; cursor: default; }
.icon-btn.eye { width: 22px; }

/* 히스토리 패널 */
.history-body { max-height: 140px; padding: 0; }
.history-list { list-style: none; margin: 0; padding: 0; }

.history-item {
  padding: 3px 10px;
  cursor: pointer;
}

.history-item:hover { background: var(--ed-hover); }
.history-item.is-current { background: var(--ed-accent-bg); font-weight: 600; }
.history-item.is-future { opacity: 0.45; }

/* 상태바 */
.statusbar {
  grid-area: status;
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 3px 10px;
  background: var(--ed-panel);
  border-top: 1px solid var(--ed-line);
  color: var(--ed-muted);
}

.status { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; user-select: text; }
.cursor-info { font-variant-numeric: tabular-nums; white-space: pre; }
.zoom-controls { display: flex; gap: 4px; align-items: center; }
.zoom-input { width: 60px; text-align: center; }

.status-btn {
  font: inherit;
  padding: 1px 7px;
  border: 1px solid var(--ed-line);
  border-radius: 4px;
  background: var(--ed-panel-2);
  color: var(--ed-text);
  cursor: pointer;
}

.status-btn:hover { border-color: var(--ed-accent); }

/* ================= 컨트롤 (옵션바 / 대화상자 공용) ================= */

.ctl {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
}

.ctl-label { white-space: nowrap; color: var(--ed-muted); }
.ctl-unit { color: var(--ed-muted); }
.ctl-range input[type="range"] { width: 110px; accent-color: var(--ed-accent); }
.ctl-num { width: 56px; }
.ctl-num.wide { width: 80px; }
.ctl-select { max-width: 170px; }
.ctl-text { width: 160px; }
.ctl-color { width: 34px; height: 26px; padding: 0; border: 1px solid var(--ed-line); background: none; cursor: pointer; }
.ctl-check { cursor: pointer; }
.ctl input[type="checkbox"] { accent-color: var(--ed-accent); }

.segmented {
  display: inline-flex;
  border: 1px solid var(--ed-line);
  border-radius: 5px;
  overflow: hidden;
}

.seg-btn {
  font: inherit;
  padding: 3px 9px;
  border: 0;
  border-right: 1px solid var(--ed-line);
  background: var(--ed-panel-2);
  color: var(--ed-text);
  cursor: pointer;
  display: inline-grid;
  place-items: center;
}

.seg-btn:last-child { border-right: 0; }
.seg-btn:hover { background: var(--ed-hover); }
.seg-btn[aria-pressed="true"] { background: var(--ed-accent); color: #fff; }

/* ================= 메뉴 ================= */

#menu-host { position: fixed; z-index: 2000; left: 0; top: 0; }

.menu-panel {
  position: fixed;
  min-width: 230px;
  max-height: calc(100vh - 16px);
  padding: 4px 0;
  background: var(--ed-panel);
  border: 1px solid var(--ed-line);
  border-radius: 6px;
  box-shadow: 0 8px 24px rgb(0 0 0 / 0.5);
  color: var(--ed-text);
  font-size: 13px;
  z-index: 2001;
}

.menu-panel.submenu { position: absolute; left: 100%; top: -5px; }
.menu-panel.submenu.flip { left: auto; right: 100%; }

.menu-item {
  position: relative;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 5px 12px 5px 6px;
  cursor: pointer;
  white-space: nowrap;
}

.menu-item:hover:not(.disabled),
.menu-item:focus { background: var(--ed-accent); color: #fff; outline: none; }
.menu-item.disabled { opacity: 0.4; cursor: default; }
.menu-check { width: 14px; text-align: center; }
.menu-label { flex: 1; }
.menu-shortcut { margin-left: 24px; color: var(--ed-muted); font-size: 12px; }
.menu-item:hover:not(.disabled) .menu-shortcut { color: #e5eeff; }
.menu-arrow { margin-left: 16px; }
.menu-sep { height: 1px; margin: 4px 0; background: var(--ed-line); }

/* ================= 대화상자 ================= */

dialog.dlg {
  width: min(420px, calc(100vw - 24px));
  padding: 0;
  border: 1px solid var(--ed-line);
  border-radius: 8px;
  background: var(--ed-panel);
  color: var(--ed-text);
  box-shadow: 0 12px 40px rgb(0 0 0 / 0.55);
  font-size: 13px;
  --card: var(--ed-panel-2);
  --text: var(--ed-text);
  --line: var(--ed-line);
  --primary: var(--ed-accent);
}

dialog.dlg::backdrop { background: rgb(0 0 0 / 0.5); }

dialog.dlg-side {
  position: fixed;
  margin: 0;
  right: 300px;
  top: 100px;
  left: auto;
  max-height: calc(100vh - 140px);
}

dialog.dlg-side::backdrop { background: transparent; }

.dlg-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 8px 8px 14px;
  border-bottom: 1px solid var(--ed-line);
  background: var(--ed-panel-2);
  border-radius: 8px 8px 0 0;
}

.dlg-head h2 { margin: 0; font-size: 14px; }
.dlg-body { padding: 14px; max-height: 70vh; overflow-y: auto; }

.dlg-footer {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 10px 14px;
  border-top: 1px solid var(--ed-line);
}

.param-form { display: flex; flex-direction: column; gap: 10px; }
.param-form .ctl { justify-content: space-between; }
.param-form .ctl-range { display: grid; grid-template-columns: 120px minmax(0, 1fr) 60px auto; }
.param-form .ctl-range input[type="range"] { width: 100%; }
.param-form .ctl-select { max-width: 200px; }
.param-form .ctl-text.wide, .ctl-text.wide { width: 100%; }

.style-section { border: 1px solid var(--ed-line); border-radius: 6px; padding: 8px 10px 10px; display: flex; flex-direction: column; gap: 8px; }
.style-section legend { padding: 0 4px; font-weight: 600; }

.histogram { width: 100%; height: 80px; border: 1px solid var(--ed-line); }
.curves { display: flex; flex-direction: column; gap: 8px; align-items: flex-start; }
.curves-canvas { width: 256px; height: 256px; border: 1px solid var(--ed-line); cursor: crosshair; touch-action: none; }

.anchor-grid { display: grid; grid-template-columns: repeat(3, 24px); gap: 3px; }
.anchor-cell { width: 24px; height: 24px; border: 1px solid var(--ed-line); background: var(--ed-panel-2); cursor: pointer; border-radius: 3px; padding: 0; }
.anchor-cell[aria-pressed="true"] { background: var(--ed-accent); border-color: var(--ed-accent); }

.psd-ask ul { margin: 6px 0; padding-left: 18px; }
.export-size { margin: 0; min-height: 1.4em; }
.shortcut-scroll { max-height: 60vh; overflow: auto; }
.shortcut-table { width: 100%; border-collapse: collapse; }
.shortcut-table td, .shortcut-table th { padding: 3px 6px; text-align: left; border-bottom: 1px solid var(--ed-line); }
.shortcut-table .keys { text-align: right; color: var(--ed-muted); font-variant-numeric: tabular-nums; white-space: nowrap; }
.shortcut-table .group th { padding-top: 12px; color: var(--ed-accent); font-size: 12px; text-transform: uppercase; }

/* ================= 반응형 ================= */

@media (max-width: 900px) {
  #app {
    grid-template-columns: 46px minmax(0, 1fr);
    grid-template-rows: auto auto minmax(380px, 65vh) auto auto;
    grid-template-areas:
      "menubar menubar"
      "options options"
      "toolbox workspace"
      "panels panels"
      "status status";
    height: auto;
  }

  .menubar { overflow-x: auto; }
  .panels {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    align-items: start;
    border-left: 0;
    border-top: 1px solid var(--ed-line);
  }

  .panel { border-right: 1px solid var(--ed-line); }
  .optionsbar { overflow-x: auto; flex-wrap: nowrap; }
  .statusbar { flex-wrap: wrap; }
  dialog.dlg-side { right: 12px; top: 60px; }
}

@media (max-width: 480px) {
  h1 { font-size: 22px; }
  .site-nav { gap: 12px; }
}
