:root {
  color-scheme: dark;
  --bg: #11120f;
  --panel: #191a16;
  --panel-2: #20211d;
  --line: #34362e;
  --text: #f2f1e8;
  --muted: #9b9d91;
  --accent: #ffb84d;
  --accent-2: #ffd28c;
  --target: #6fe7a5;
  --danger: #ff7369;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, Pretendard, "Noto Sans KR", system-ui, sans-serif;
}
button, input { font: inherit; }
button { color: inherit; }

.app-shell { display: grid; grid-template-columns: 292px 1fr; height: 100vh; }
.sidebar { border-right: 1px solid var(--line); background: #151612; min-height: 0; display: flex; flex-direction: column; }
.brand { padding: 25px 20px 17px; border-bottom: 1px solid var(--line); }
.brand h1 { margin: 2px 0 18px; font-size: 25px; letter-spacing: -.03em; }
.eyebrow { color: var(--accent); font-size: 11px; font-weight: 800; letter-spacing: .13em; margin: 0; }
.progress-row { display: flex; justify-content: space-between; color: var(--muted); font-size: 12px; }
.save-state { color: var(--muted); }
.save-state.saving { color: var(--accent-2); }
.save-state.saved { color: var(--target); }
.save-state.error { color: var(--danger); }
.progress-track { height: 3px; background: #2b2c27; margin: 8px 0 15px; border-radius: 10px; overflow: hidden; }
.progress-track div { height: 100%; width: 0; background: var(--accent); transition: width .2s; }
.search { width: 100%; border: 1px solid var(--line); border-radius: 8px; background: #10110e; color: var(--text); padding: 10px 11px; outline: none; }
.search:focus { border-color: #696b5f; }
.item-list { overflow-y: auto; min-height: 0; padding: 8px; }
.item { width: 100%; border: 0; border-radius: 8px; background: transparent; padding: 11px 12px; text-align: left; display: grid; grid-template-columns: 10px 1fr; gap: 10px; cursor: pointer; }
.item:hover { background: #20211c; }
.item.active { background: #2b291f; outline: 1px solid #5d4a2e; }
.status-dot { width: 8px; height: 8px; border: 1px solid #686a60; border-radius: 50%; margin-top: 4px; }
.item.reviewed .status-dot { background: var(--target); border-color: var(--target); box-shadow: 0 0 0 3px #6fe7a51c; }
.item-main { min-width: 0; }
.item-id { display: block; font-size: 13px; font-weight: 750; }
.item-text { display: block; margin-top: 4px; color: var(--muted); font-size: 11px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.workspace { min-width: 0; height: 100vh; display: flex; flex-direction: column; }
.topbar { min-height: 91px; display: flex; align-items: center; justify-content: space-between; gap: 20px; padding: 17px 25px; border-bottom: 1px solid var(--line); }
.topbar h2 { font-size: 21px; margin: 4px 0 1px; }
.muted { color: var(--muted); margin: 0; font-size: 12px; }
.top-actions { display: flex; gap: 8px; }
.button, .zoom-actions button { border: 1px solid var(--line); border-radius: 8px; background: var(--panel-2); padding: 9px 13px; cursor: pointer; }
.button:hover, .zoom-actions button:hover { border-color: #64665b; }
.button.primary { border-color: #ca8731; background: var(--accent); color: #21170a; font-weight: 800; }
.button.secondary { background: transparent; }
.button.compact { padding: 7px 11px; }
.button:disabled { opacity: .35; cursor: default; }

.content-grid { flex: 1; min-height: 0; display: grid; grid-template-columns: minmax(460px, 1fr) 310px; gap: 15px; padding: 15px; }
.stage-card { min-height: 0; background: var(--panel); border: 1px solid var(--line); border-radius: 12px; overflow: hidden; display: flex; flex-direction: column; }
.stage-toolbar, .stage-footer { min-height: 47px; padding: 0 14px; display: flex; align-items: center; justify-content: space-between; gap: 12px; border-bottom: 1px solid var(--line); }
.stage-footer { min-height: 36px; border-bottom: 0; border-top: 1px solid var(--line); color: var(--muted); font-size: 11px; }
.legend { display: flex; gap: 18px; color: var(--muted); font-size: 12px; }
.legend span { display: flex; align-items: center; gap: 7px; }
.legend-box { width: 15px; height: 10px; border: 2px solid; display: inline-block; }
.legend-box.target { border-color: var(--target); }
.legend-box.crop { border-color: var(--accent); }
.zoom-actions { display: flex; gap: 5px; }
.zoom-actions button { padding: 5px 9px; background: transparent; font-size: 12px; }
.canvas-wrap { position: relative; flex: 1; min-height: 260px; overflow: hidden; background-color: #0b0c0a; background-image: radial-gradient(#292b25 1px, transparent 1px); background-size: 18px 18px; }
#editorCanvas { display: block; width: 100%; height: 100%; touch-action: none; }
.loading-overlay { position: absolute; inset: 0; display: grid; place-items: center; background: #0d0e0bdd; color: var(--muted); font-size: 13px; }
.loading-overlay.hidden { display: none; }
.canvas-help { position: absolute; bottom: 10px; left: 50%; transform: translateX(-50%); background: #11130fdd; border: 1px solid #3c3e35; border-radius: 20px; color: #b8baaf; padding: 6px 12px; font-size: 11px; white-space: nowrap; pointer-events: none; }

.inspector { min-height: 0; overflow-y: auto; display: flex; flex-direction: column; gap: 12px; }
.panel { border: 1px solid var(--line); border-radius: 11px; background: var(--panel); padding: 15px; }
.panel-label { color: var(--muted); font-size: 10px; font-weight: 800; letter-spacing: .12em; margin: 0 0 8px; }
.change-panel { border-left: 3px solid var(--target); }
.text-change p { font-size: 13px; line-height: 1.5; margin: 0; word-break: break-all; }
.text-change span { display: block; color: var(--target); margin: 5px 0; }
#textAfter { color: #b8ffd4; }
.panel-heading { display: flex; justify-content: space-between; align-items: flex-start; }
.panel-heading h3 { margin: 0; font-size: 16px; }
.text-button { border: 0; background: transparent; color: var(--accent-2); cursor: pointer; font-size: 11px; padding: 2px; }
.padding-grid { margin: 18px auto; width: 250px; display: grid; grid-template-columns: 72px 86px 72px; grid-template-rows: 62px 70px 62px; align-items: center; justify-items: center; }
.padding-grid label { color: var(--muted); text-align: center; font-size: 10px; }
.padding-grid input, .uniform-row input { width: 68px; display: block; margin-top: 4px; border: 1px solid var(--line); border-radius: 7px; background: #0f100d; color: var(--text); padding: 7px; text-align: center; outline: none; }
.padding-grid input:focus, .uniform-row input:focus { border-color: var(--accent); }
.top-field { grid-column: 2; grid-row: 1; }
.left-field { grid-column: 1; grid-row: 2; }
.right-field { grid-column: 3; grid-row: 2; }
.bottom-field { grid-column: 2; grid-row: 3; }
.mini-box { grid-column: 2; grid-row: 2; width: 78px; height: 54px; border: 2px solid var(--accent); display: grid; place-items: center; color: var(--target); font-size: 10px; }
.mini-box span { border: 1px solid var(--target); padding: 5px 8px; }
.uniform-row { display: grid; grid-template-columns: 1fr 72px auto; align-items: end; gap: 8px; border-top: 1px solid var(--line); padding-top: 13px; }
.uniform-row label { color: var(--muted); font-size: 11px; padding-bottom: 8px; }
.uniform-row input { width: 72px; margin: 0; }
.metrics { padding: 4px 15px; }
.metrics div { display: flex; justify-content: space-between; gap: 12px; padding: 11px 0; border-bottom: 1px solid #2b2d27; font-size: 12px; }
.metrics div:last-child { border: 0; }
.metrics span { color: var(--muted); }
.metrics strong { font-variant-numeric: tabular-nums; }
.hint { color: var(--muted); font-size: 11px; line-height: 1.55; margin: 0 3px; }
.hint b { color: var(--text); }
.toast { position: fixed; right: 22px; bottom: 22px; max-width: 420px; background: #292b24; border: 1px solid #55584c; border-radius: 9px; padding: 11px 14px; opacity: 0; transform: translateY(8px); pointer-events: none; transition: .18s; font-size: 12px; box-shadow: 0 12px 30px #0008; }
.toast.show { opacity: 1; transform: none; }
.toast.error { border-color: #944943; color: #ffc0ba; }

@media (max-width: 1050px) {
  .app-shell { grid-template-columns: 235px 1fr; }
  .content-grid { grid-template-columns: 1fr 270px; }
  .padding-grid { transform: scale(.9); margin-left: -5px; }
}
