:root {
  /* 베이지 라이트 테마 · 포인트 #008c4e · 그라디언트 최소 (토스풍 미니멀) */
  --bg: #f4efe3;          /* 페이지 베이지 */
  --surface: #ffffff;     /* 카드/패널 */
  --surface-2: #f6f2e8;   /* 인풋/인셋 */
  --line: #e8e2d3;        /* 경계선 (따뜻한 톤) */
  --line-2: #ddd6c4;
  --text: #1f2329;        /* 본문 */
  --muted: #8a9099;       /* 보조 텍스트 */
  --accent: #008c4e;      /* 포인트 그린 */
  --accent-strong: #00733f;
  --accent-soft: #e6f3ec; /* 연한 그린 배경 */
  --amber: #e8920c;
  --red: #e0413a;
  --shadow-sm: 0 1px 2px rgba(20,30,40,.04), 0 1px 3px rgba(20,30,40,.05);
  --shadow: 0 6px 22px rgba(20,30,40,.07);
  --r-card: 16px;
  --r-btn: 12px;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; }
body {
  font-family: "Pretendard", -apple-system, BlinkMacSystemFont, "Apple SD Gothic Neo", sans-serif;
  background: var(--bg); color: var(--text); font-size: 14px;
  -webkit-font-smoothing: antialiased;
}
h1, h2 { margin: 0; }
button { font-family: inherit; cursor: pointer; }
.muted { color: var(--muted); font-weight: 400; }
.hint { font-size: .74rem; color: var(--muted); margin: .35rem 0 0; line-height: 1.5; }
.spacer { flex: 1; }

/* ── 로그인 ── */
.login-overlay { position: fixed; inset: 0; display: flex; align-items: center; justify-content: center;
  background: var(--bg); z-index: 500; padding: 1.5rem; }
.login-card { background: var(--surface); border: 1px solid var(--line); border-radius: 22px; padding: 2.4rem 2rem;
  width: 350px; max-width: 100%; text-align: center; display: flex; flex-direction: column; gap: .9rem; box-shadow: var(--shadow); }
.login-logo { width: 56px; height: 56px; margin: 0 auto; object-fit: contain; }
.login-card h1 { font-size: 1.2rem; letter-spacing: -.02em; }
.login-card input { background: var(--surface-2); border: 1px solid var(--line); color: var(--text);
  padding: .8rem 1rem; border-radius: var(--r-btn); font-size: .95rem; text-align: center; }
.login-card button { background: var(--accent); color: #fff; border: 0; padding: .8rem; border-radius: var(--r-btn); font-weight: 700; font-size: .95rem; }
.login-card button:hover { background: var(--accent-strong); }
.login-error { color: var(--red); font-size: .8rem; }

/* ── 헤더 ── */
header { display: flex; align-items: center; gap: 1.2rem; padding: .75rem 1.6rem;
  background: var(--surface); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 50; }
.brand { display: flex; align-items: center; gap: .7rem; }
.brand .logo { width: 32px; height: 32px; object-fit: contain; }
.brand h1 { font-size: 1.05rem; letter-spacing: -.02em; }
.brand .sub { font-size: .72rem; color: var(--muted); }
.modes { display: flex; gap: .3rem; margin-left: .5rem; background: var(--surface-2); padding: .25rem; border-radius: 999px; }
.mode-tab { background: transparent; border: 0; color: var(--muted); padding: .45rem 1rem; border-radius: 999px; font-size: .85rem; font-weight: 700; }
.mode-tab:hover { color: var(--text); }
.mode-tab.active { background: var(--accent); color: #fff; box-shadow: var(--shadow-sm); }
.header-right { margin-left: auto; display: flex; align-items: center; gap: .7rem; }
.usage { font-size: .76rem; color: var(--muted); font-variant-numeric: tabular-nums; }

/* ── 진행 바 (그라디언트 없음) ── */
.progress-bar { position: sticky; top: 53px; z-index: 40; height: 22px; background: #e9efe9;
  border-bottom: 1px solid var(--line); display: flex; align-items: center; overflow: hidden; }
.progress-fill { position: absolute; left: 0; top: 0; bottom: 0; width: 0%; background: var(--accent); transition: width .3s ease; }
.progress-text { position: relative; z-index: 1; margin-left: auto; padding-right: 1rem; font-size: .72rem; font-weight: 600; color: var(--text); font-variant-numeric: tabular-nums; }

/* ── 레이아웃 ── */
main { display: grid; grid-template-columns: 300px 1fr; gap: 1.2rem; padding: 1.2rem 1.6rem; max-width: 1480px; margin: 0 auto; }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-card); box-shadow: var(--shadow-sm); }
.settings { padding: 1.1rem 1.2rem; position: sticky; top: 92px; align-self: start; max-height: calc(100vh - 112px); overflow-y: auto; }
.settings h2 { font-size: .72rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 1.4rem 0 .65rem; font-weight: 700; }
.settings h2:first-child { margin-top: 0; }

/* 세그먼트(모델) */
.seg { display: flex; gap: .3rem; background: var(--surface-2); padding: .25rem; border-radius: var(--r-btn); }
.seg button { flex: 1; background: transparent; border: 0; color: var(--muted); padding: .5rem; border-radius: 9px; font-size: .82rem; font-weight: 700; }
.seg button.active { background: var(--surface); color: var(--accent); box-shadow: var(--shadow-sm); }
.seg button:disabled { opacity: .4; cursor: not-allowed; }

/* 프리셋 */
.presets { display: grid; gap: .45rem; }
.preset { display: flex; align-items: center; gap: .65rem; text-align: left; width: 100%; background: var(--surface);
  border: 1px solid var(--line); color: var(--text); padding: .6rem .7rem; border-radius: var(--r-btn); transition: border-color .12s, background .12s; }
.preset:hover { border-color: var(--line-2); background: var(--surface-2); }
.preset.active { border-color: var(--accent); background: var(--accent-soft); }
.preset .dot { width: 11px; height: 11px; border-radius: 50%; flex: none; }
.preset .pt { font-weight: 700; font-size: .86rem; }
.preset .pd { font-size: .7rem; color: var(--muted); }

/* 참조 라이브러리 */
.ref-strip { display: flex; gap: .45rem; overflow-x: auto; padding-bottom: .35rem; }
.ref-item { flex: none; width: 58px; cursor: pointer; text-align: center; }
.ref-item .rimg { width: 58px; height: 58px; border-radius: 11px; border: 2px solid var(--line);
  object-fit: cover; background: var(--surface-2); display: flex; align-items: center; justify-content: center; font-size: .8rem; color: var(--muted); overflow: hidden; }
.ref-item .rimg img { width: 100%; height: 100%; object-fit: cover; }
.ref-item.active .rimg { border-color: var(--accent); }
.ref-item .rlbl { font-size: .58rem; color: var(--muted); margin-top: .22rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mini-upload { display: block; text-align: center; margin-top: .5rem; background: var(--surface-2);
  border: 1px dashed var(--line-2); color: var(--muted); padding: .5rem; border-radius: var(--r-btn); font-size: .76rem; cursor: pointer; }
.mini-upload:hover { border-color: var(--accent); color: var(--accent); }

textarea, select { width: 100%; background: var(--surface-2); color: var(--text); border: 1px solid var(--line);
  border-radius: var(--r-btn); padding: .55rem .7rem; font-size: .85rem; font-family: inherit; resize: vertical; }
textarea:focus, select:focus, .login-card input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }

/* 버튼 */
.primary { background: var(--accent); color: #fff; border: 0; border-radius: var(--r-btn); padding: .6rem 1rem; font-weight: 700; font-size: .86rem; }
.primary:hover:not(:disabled) { background: var(--accent-strong); }
.primary:disabled { opacity: .45; cursor: not-allowed; }
.warn { background: #fff4e6; color: #b5670a; border: 1px solid #f3d09a; border-radius: var(--r-btn); padding: .6rem 1rem; font-weight: 700; font-size: .86rem; }
.warn:hover { background: #ffe9cc; }
.ghost { background: var(--surface); border: 1px solid var(--line-2); color: var(--text); border-radius: var(--r-btn); padding: .45rem .85rem; font-size: .82rem; font-weight: 600; }
.ghost:hover { background: var(--surface-2); }
.ghost.tiny { padding: .35rem .7rem; font-size: .76rem; }

/* ── 작업 영역 ── */
.work { min-width: 0; }
.dropzone { border: 2px dashed var(--line-2); border-radius: var(--r-card); padding: 2.2rem 1rem; text-align: center;
  cursor: pointer; transition: border-color .12s, background .12s; background: var(--surface); }
.dropzone:hover, .dropzone.drag, .dropzone.paste:focus { border-color: var(--accent); background: var(--accent-soft); outline: none; }
.dz-icon { font-size: 1.8rem; }
.dropzone p { margin: .3rem 0; }
.dropzone b { font-weight: 700; }

.toolbar { display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; margin: 1rem 0; }
.filters { display: flex; gap: .3rem; flex-wrap: wrap; }
.chip { background: var(--surface); border: 1px solid var(--line); color: var(--muted); padding: .32rem .7rem;
  border-radius: 999px; font-size: .76rem; cursor: pointer; user-select: none; font-weight: 600; }
.chip:hover { border-color: var(--line-2); }
.chip.active { background: var(--accent); border-color: var(--accent); color: #fff; }
.chip .c { font-weight: 800; }
.menu { display: flex; gap: .3rem; }

/* ── 카드 ── */
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 1rem; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-card); overflow: hidden;
  display: flex; flex-direction: column; box-shadow: var(--shadow-sm); }
.card.verdict-pass { border-color: var(--accent); }
.card.verdict-hold { border-color: var(--amber); }
.card.verdict-reject { border-color: var(--red); }
.pair { display: grid; grid-template-columns: 1fr 1fr; gap: 1px; background: var(--line); }
.pair .side { background: var(--surface-2); aspect-ratio: 1; display: flex; align-items: center; justify-content: center; position: relative; overflow: hidden; }
.pair .side img { max-width: 100%; max-height: 100%; object-fit: contain; cursor: zoom-in; }
.pair .side .tag { position: absolute; top: 5px; left: 5px; font-size: .6rem; background: rgba(31,35,41,.62); padding: .12rem .45rem; border-radius: 5px; color: #fff; font-weight: 600; }
.pair .side.placeholder { color: var(--muted); font-size: .74rem; flex-direction: column; gap: .4rem; }
.spinner { width: 24px; height: 24px; border: 3px solid var(--line); border-top-color: var(--accent); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.card .body { padding: .6rem .7rem; display: flex; flex-direction: column; gap: .45rem; }
.card .fname { font-size: .74rem; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.card .status { font-size: .68rem; color: var(--muted); }
.card .status.err { color: var(--red); }
.card .status.ok { color: var(--accent); }
.card .status.run, .card .status.queued { color: var(--amber); }

/* 판정 버튼 (일괄) */
.verdicts { display: flex; gap: .25rem; }
.verdicts button { flex: 1; border: 1px solid var(--line); background: var(--surface-2); color: var(--muted);
  border-radius: 9px; padding: .35rem; font-size: .72rem; font-weight: 700; }
.verdicts button:hover { border-color: var(--line-2); }
.verdicts button.pass.on { background: var(--accent); border-color: var(--accent); color: #fff; }
.verdicts button.hold.on { background: var(--amber); border-color: var(--amber); color: #fff; }
.verdicts button.reject.on { background: var(--red); border-color: var(--red); color: #fff; }
.card .memo { width: 100%; background: var(--surface-2); border: 1px solid var(--line); color: var(--text);
  border-radius: 9px; padding: .4rem .55rem; font-size: .74rem; font-family: inherit; resize: vertical; min-height: 32px; display: none; }
.card.verdict-reject .memo, .card.show-memo .memo { display: block; }

.card .row { display: flex; gap: .3rem; }
.card .row button { flex: 1; border-radius: 9px; padding: .42rem; font-size: .74rem; font-weight: 700; border: 0; }
.btn-dl { background: var(--accent); color: #fff; }
.btn-edit { background: var(--surface-2); color: var(--text); border: 1px solid var(--line) !important; }
.btn-redo { background: #fff4e6; color: #b5670a; border: 1px solid #f3d09a !important; }
.btn-dl:hover { background: var(--accent-strong); }
.btn-edit:hover { background: var(--bg); }
.btn-redo:hover { background: #ffe9cc; }
.btn-x { background: var(--surface); border: 1px solid var(--line-2) !important; color: var(--muted); flex: 0 0 auto !important; padding: .42rem .55rem; }
.btn-x:hover { background: var(--surface-2); }

/* ── 비교 모달 ── */
.modal { position: fixed; inset: 0; background: rgba(31,35,41,.55); display: flex; align-items: center; justify-content: center; padding: 2rem; z-index: 300; }
.modal-box { background: var(--surface); border-radius: var(--r-card); max-width: 1100px; width: 100%; max-height: 92vh; overflow: auto; padding: 1.3rem; box-shadow: var(--shadow); }
.modal-head { display: flex; align-items: center; gap: .5rem; margin-bottom: .9rem; }
.modal-head span { font-weight: 700; font-size: .92rem; word-break: break-all; margin-right: auto; }
.modal-compare { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.modal-compare figure { margin: 0; background: var(--surface-2); border-radius: var(--r-btn); padding: .8rem; text-align: center; }
.modal-compare figcaption { font-size: .72rem; color: var(--muted); text-transform: uppercase; letter-spacing: .08em; margin-bottom: .5rem; font-weight: 700; }
.modal-compare img { max-width: 100%; max-height: 70vh; }
.modal-foot { margin-top: 1rem; display: flex; flex-direction: column; gap: .6rem; }
.modal-foot .verdicts button { padding: .55rem; font-size: .82rem; }
.modal-hint { text-align: center; font-size: .7rem; color: var(--muted); }
.modal-hint kbd { background: var(--surface-2); border: 1px solid var(--line); border-radius: 5px;
  padding: .05rem .35rem; font-size: .68rem; font-family: inherit; }

/* ── 토스트 ── */
.toast { position: fixed; bottom: 1.4rem; left: 50%; transform: translateX(-50%); background: var(--text);
  border: 0; color: #fff; padding: .75rem 1.2rem; border-radius: var(--r-btn); font-size: .84rem; font-weight: 600;
  z-index: 600; box-shadow: var(--shadow); max-width: 90vw; }
.toast.err { background: var(--red); }

/* ── 텍스트 편집기 ── */
.editor-overlay { position: fixed; inset: 0; background: var(--bg); z-index: 700; display: flex; flex-direction: column; }
.editor-top { display: flex; align-items: center; gap: .6rem; padding: .65rem 1.1rem; background: var(--surface); border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.editor-top .etitle { font-weight: 700; font-size: .9rem; margin-right: auto; }
.editor-main { flex: 1; display: flex; min-height: 0; }
.editor-stage-wrap { flex: 1; display: flex; align-items: center; justify-content: center; overflow: auto; padding: 1.5rem; }
.editor-stage { position: relative; display: inline-block; box-shadow: var(--shadow); border-radius: 4px; }
.editor-stage img { display: block; max-width: 100%; max-height: 78vh; user-select: none; -webkit-user-drag: none; border-radius: 4px; }
.txt-box { position: absolute; cursor: move; padding: 2px 4px; white-space: pre-wrap; line-height: 1.2;
  border: 1px dashed transparent; min-width: 12px; outline: none; }
.txt-box { z-index: 2; }
.txt-box.sel { border-color: var(--accent); }
/* 가리개(영역 지우기) */
.editor-stage.masking { cursor: crosshair; }
.editor-stage.masking .txt-box, .editor-stage.masking .mask-box { pointer-events: none; }
.mask-box { position: absolute; z-index: 1; box-sizing: border-box; }
.mask-box:hover { outline: 1px dashed var(--line-2); }
.mask-box .mask-x { position: absolute; top: -9px; right: -9px; width: 18px; height: 18px; padding: 0;
  border: 0; border-radius: 50%; background: #e0413a; color: #fff; font-size: 10px; line-height: 18px;
  cursor: pointer; display: none; box-shadow: var(--shadow-sm); }
.mask-box:hover .mask-x { display: block; }
.ed-rubber { position: absolute; z-index: 3; pointer-events: none;
  border: 1.5px dashed var(--accent); background: rgba(0,140,78,.14); }
#ed-mask.active { background: var(--accent); color: #fff; }
/* 텍스트 상자 리사이즈 핸들 (모퉁이 변형) */
.rz-handle { position: absolute; z-index: 4; width: 14px; height: 14px; margin: -7px 0 0 -7px;
  background: #fff; border: 2px solid var(--accent); border-radius: 3px; cursor: nwse-resize;
  box-shadow: var(--shadow-sm); touch-action: none; }
.editor-side { width: 268px; background: var(--surface); border-left: 1px solid var(--line); padding: 1.1rem; overflow-y: auto; }
.editor-side h3 { font-size: .72rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 1.2rem 0 .55rem; font-weight: 700; }
.editor-side h3:first-child { margin-top: 0; }
.editor-side label { font-size: .74rem; color: var(--muted); display: block; margin: .55rem 0 .28rem; }
.editor-side select, .editor-side input[type=text] { width: 100%; }
.editor-side .rowf { display: flex; gap: .5rem; align-items: center; }
.editor-side input[type=range] { width: 100%; accent-color: var(--accent); }
.editor-side input[type=color] { width: 44px; height: 34px; padding: 0; border: 1px solid var(--line); border-radius: 9px; background: var(--surface-2); }
.editor-side input[type=checkbox] { accent-color: var(--accent); }
.editor-side .val { font-size: .74rem; color: var(--text); font-variant-numeric: tabular-nums; min-width: 38px; text-align: right; font-weight: 600; }
.editor-empty { color: var(--muted); font-size: .78rem; line-height: 1.6; }

/* ── 반응형 ── */
@media (max-width: 880px) {
  header { flex-wrap: wrap; }
  .modes { order: 3; width: 100%; margin: .4rem 0 0; justify-content: center; }
  main { grid-template-columns: 1fr; }
  .settings { position: static; max-height: none; }
  .modal-compare { grid-template-columns: 1fr; }
  .editor-main { flex-direction: column; }
  .editor-side { width: auto; border-left: 0; border-top: 1px solid var(--line); }
}

/* ── 글자 빼기 토글 ─────────────────────────────────────────────────────── */
.toggle { display: flex; align-items: flex-start; gap: .7rem; margin-top: 1.4rem; cursor: pointer;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-btn);
  padding: .75rem .8rem; transition: border-color .12s, background .12s; }
.toggle:hover { border-color: var(--line-2); background: var(--surface-2); }
.toggle.on { border-color: var(--accent); background: var(--accent-soft); }
.toggle input { position: absolute; opacity: 0; width: 0; height: 0; }
.tg-track { flex: none; width: 38px; height: 22px; border-radius: 999px; background: var(--line-2);
  position: relative; margin-top: .1rem; transition: background .15s; }
.tg-thumb { position: absolute; top: 2px; left: 2px; width: 18px; height: 18px; border-radius: 50%;
  background: #fff; box-shadow: var(--shadow-sm); transition: transform .15s; }
.toggle.on .tg-track { background: var(--accent); }
.toggle.on .tg-thumb { transform: translateX(16px); }
.tg-body { display: flex; flex-direction: column; gap: .15rem; }
.tg-title { font-size: .82rem; font-weight: 700; color: var(--text); }
.tg-desc { font-size: .7rem; color: var(--muted); line-height: 1.45; }
.toggle.on .tg-title { color: var(--accent-strong); }
