:root{
  --bg:#f5f4f0; --surface:#fbfbf9; --panel:#ffffff; --panel-soft:#f7f6f2;
  --ink:#1c1c1a; --ink-hover:#3a3935; --ink-2:#55534d; --sub:#7a776f; --muted:#8a877f;
  --line:#e3e1db; --line-2:#dcdad3; --line-3:#efeee9; --hover:#efeee9; --soft:#f3f2ee; --track:#ebe9e3;
  --accent:#e0532f; --accent-soft:#fcebe5;
  --font:"IBM Plex Sans KR",sans-serif; --mono:"JetBrains Mono",monospace;
}
*{box-sizing:border-box}
[hidden]{display:none !important}
body{margin:0;background:var(--bg);color:var(--ink);font-family:var(--font);-webkit-font-smoothing:antialiased}
button{font:inherit;color:inherit}
.mono-label{font-family:var(--mono);font-size:11px;letter-spacing:.12em;color:var(--muted)}
.app{min-height:calc(100vh - 48px);display:flex;flex-direction:column}
.topbar{display:flex;align-items:center;justify-content:space-between;gap:16px;padding:16px 28px;border-bottom:1px solid var(--line);background:var(--surface);flex-wrap:wrap}
.brand{display:flex;align-items:baseline;gap:14px;min-width:0;flex-wrap:wrap}
.home{font-size:13px;color:var(--ink-2);text-decoration:none}
.home:hover{color:var(--ink)}
.brand-title{font-size:17px;font-weight:700;letter-spacing:-.01em}
.btn{height:36px;padding:0 14px;background:transparent;border:1px solid var(--line-2);border-radius:999px;font-size:13px;cursor:pointer}
.btn:hover{background:var(--hover)}
.btn--solid{background:var(--ink);color:#fff;border:none;font-weight:500}
.btn--solid:hover{background:var(--ink-hover)}
.text-input{height:40px;padding:0 12px;background:var(--surface);border:1px solid var(--line-2);border-radius:8px;font:inherit;font-size:14px;color:var(--ink)}
@media (max-width:640px){ .topbar{padding:14px 16px} }

/* ---------- 공통 ---------- */
.sr-only{position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0,0,0,0);border:0}
.mono{font-family:var(--mono)}
.note{margin:0;font-size:12px;line-height:1.6;color:var(--muted)}
.num{font-family:var(--mono);font-size:13px;color:var(--ink-2)}
.actions{display:flex;gap:8px;flex-wrap:wrap}
.btn--file{display:inline-flex;align-items:center;position:relative}
.btn--file:focus-within{outline:2px solid var(--accent);outline-offset:2px}
.btn--wide{width:100%;height:44px;font-weight:500;border-color:var(--ink)}
input[type=range]{width:100%;accent-color:var(--accent)}
:focus-visible{outline:2px solid var(--accent);outline-offset:2px}

.layout{flex:1;display:flex;flex-wrap:wrap;align-items:flex-start}

/* ---------- 스테이지 ---------- */
.stage{flex:999 1 440px;min-width:0;padding:32px 28px 40px;display:flex;flex-direction:column;gap:16px}
.photo-wrap{position:relative;display:flex;align-items:center;justify-content:center;height:min(52vh,480px);min-height:240px;padding:16px;background:#2a2926;border-radius:20px;overflow:hidden}
.photo-wrap canvas#photo{display:block;max-width:100%;max-height:100%;border-radius:6px;cursor:crosshair;touch-action:manipulation;box-shadow:0 10px 30px rgba(0,0,0,.35)}
.loupe{position:absolute;left:0;top:0;width:132px;height:132px;border-radius:50%;border:3px solid #fff;box-shadow:0 6px 20px rgba(0,0,0,.35);pointer-events:none;opacity:0;transition:opacity .12s;image-rendering:pixelated;z-index:2}
.loupe.is-on{opacity:1}
.marker{position:absolute;width:22px;height:22px;margin:-11px 0 0 -11px;border-radius:50%;border:3px solid #fff;box-shadow:0 0 0 1px rgba(0,0,0,.4),0 3px 8px rgba(0,0,0,.4);pointer-events:none;animation:ping .35s ease}
.photo-tip{position:absolute;left:50%;bottom:12px;transform:translateX(-50%);padding:6px 12px;border-radius:999px;background:rgba(20,19,17,.72);color:#f2efe6;font-size:12px;white-space:nowrap;pointer-events:none}
.drop-hint{position:absolute;inset:10px;display:flex;align-items:center;justify-content:center;border:2px dashed #fff;border-radius:14px;background:rgba(42,41,38,.85);color:#fff;font-size:15px;opacity:0;pointer-events:none;transition:opacity .2s;z-index:3}
.stage.is-over .drop-hint{opacity:1}

.source-row{display:flex;align-items:center;gap:12px;flex-wrap:wrap}
.samples{display:flex;gap:8px;flex-wrap:wrap}
.sample{display:flex;align-items:center;gap:8px;height:40px;padding:0 12px 0 4px;background:var(--panel);border:1px solid var(--line-2);border-radius:999px;font-size:13px;cursor:pointer}
.sample canvas{width:32px;height:32px;border-radius:50%;display:block}
.sample.is-active{border-color:var(--ink);box-shadow:inset 0 0 0 1px var(--ink)}
.privacy{margin-left:auto;display:flex;align-items:center;gap:8px;font-size:12px;color:var(--ink-2)}
.privacy::before{content:"";width:8px;height:8px;border-radius:50%;background:var(--accent);flex:0 0 auto}

.palette-head{display:flex;justify-content:space-between;align-items:baseline;gap:12px;flex-wrap:wrap;margin-top:8px}
.chips{display:flex;gap:6px;height:168px}
.chip{position:relative;flex:1 1 0;min-width:0;display:flex;flex-direction:column;justify-content:space-between;padding:12px 10px;border:none;border-radius:14px;cursor:pointer;text-align:left;transition:flex-grow .35s ease,transform .2s;animation:rise .4s ease both}
.chip:hover{flex-grow:1.6;transform:translateY(-3px)}
.chip.is-light{color:#1c1c1a}
.chip.is-dark{color:#fff}
.chip-pct{font-family:var(--mono);font-size:12px;opacity:.85}
.chip-hex{font-family:var(--mono);font-size:14px;font-weight:500;letter-spacing:.02em;white-space:nowrap}
.chip-copied{position:absolute;inset:0;display:flex;align-items:center;justify-content:center;border-radius:14px;font-size:13px;font-weight:500;opacity:0;transition:opacity .2s;background:inherit}
.chip.is-copied .chip-copied{opacity:1}
.ratio{display:flex;height:14px;border-radius:999px;overflow:hidden;box-shadow:inset 0 0 0 1px rgba(0,0,0,.05)}
.ratio i{display:block;height:100%;transition:width .4s ease}

/* ---------- 패널 ---------- */
.panel{flex:1 1 320px;min-width:280px;align-self:stretch;border-left:1px solid var(--line);background:var(--panel);padding:28px 24px 40px;display:flex;flex-direction:column;gap:24px}
.group{display:flex;flex-direction:column;gap:12px}
.group--line{border-top:1px solid var(--line-3);padding-top:22px}
.field{display:flex;flex-direction:column;gap:6px}
.field .text-input{width:100%}
.field-label{font-size:12px;color:var(--ink-2)}
.field-head{display:flex;justify-content:space-between;align-items:center;font-size:13px;color:var(--ink-2)}
.seg{display:flex;background:var(--soft);border-radius:999px;padding:3px;gap:2px}
.seg-btn{flex:1;height:32px;padding:0 8px;background:transparent;color:var(--sub);border:none;border-radius:999px;font-size:13px;cursor:pointer;white-space:nowrap}
.seg-btn.is-active{background:#fff;color:var(--ink);font-weight:500;box-shadow:0 1px 3px rgba(0,0,0,.12)}
.seg--sm .seg-btn{height:26px;font-size:11px;font-family:var(--mono)}
.export-head{display:flex;justify-content:space-between;align-items:center;gap:12px}

.picked{display:flex;gap:12px;align-items:stretch}
.picked-sw{flex:0 0 auto;width:92px;border-radius:14px;background:repeating-conic-gradient(#ecebe6 0 25%,#fff 0 50%) 0 0/12px 12px;box-shadow:inset 0 0 0 1px rgba(0,0,0,.08);transition:background-color .2s}
.picked-vals{flex:1;min-width:0;display:flex;flex-direction:column;gap:4px}
.val-row{display:flex;justify-content:space-between;align-items:center;gap:8px;height:32px;padding:0 10px;border:1px solid var(--line);border-radius:8px;background:var(--surface);cursor:pointer;min-width:0}
.val-row:hover{border-color:var(--ink-2)}
.val-k{font-family:var(--mono);font-size:10px;letter-spacing:.12em;color:var(--muted)}
.val-v{font-size:12px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.history{display:flex;flex-wrap:wrap;gap:6px;min-height:28px}
.history button{width:28px;height:28px;border-radius:8px;border:none;cursor:pointer;box-shadow:inset 0 0 0 1px rgba(0,0,0,.1);padding:0;animation:rise .25s ease both}
.history:empty::before{content:"아직 찍은 색이 없어요";font-size:12px;color:var(--muted);line-height:28px}
html[lang="en"] .history:empty::before{content:"No colors picked yet"}

.code{margin:0;padding:12px 14px;max-height:240px;overflow:auto;border-radius:10px;background:#211f1c;color:#f3e9de;font-family:var(--mono);font-size:12px;line-height:1.65;white-space:pre}

.toast{position:fixed;left:50%;bottom:28px;transform:translate(-50%,20px);padding:10px 18px;background:var(--ink);color:#fff;border-radius:999px;font-size:13px;opacity:0;pointer-events:none;transition:opacity .2s,transform .2s;z-index:10;max-width:calc(100% - 32px);text-align:center}
.toast.is-show{opacity:1;transform:translate(-50%,0)}

@keyframes rise{from{opacity:0;transform:translateY(10px)}to{opacity:1;transform:none}}
@keyframes ping{from{transform:scale(1.8);opacity:0}to{transform:none;opacity:1}}

@media (max-width:760px){
  .panel{border-left:none;border-top:1px solid var(--line);padding:24px 16px 40px}
  .stage{padding:16px 16px 24px}
  .photo-wrap{height:auto;min-height:0;aspect-ratio:4/3;padding:10px;border-radius:16px}
  .privacy{margin-left:0}
  .chips{display:grid;grid-template-columns:repeat(var(--cols,5),minmax(0,1fr));height:auto}
  .chip{height:92px;padding:8px 6px;border-radius:10px}
  .chip:hover{transform:none}
  .chip-hex{font-size:10px;letter-spacing:0}
  .chip-pct{font-size:10px}
  .photo-tip{font-size:11px}
}
@media (prefers-reduced-motion:reduce){
  *,*::before,*::after{animation:none !important;transition-duration:.01ms !important}
}

/* 다크 모드 (인쇄는 라이트 그대로) · 사진 · 추출한 색 견본 · 복사되는 코드는 그대로 */
@media screen{
  :root[data-theme="dark"]{
    color-scheme:dark;
    --bg:#151412; --surface:#1b1a17; --panel:#201f1c; --panel-soft:#262521;
    --ink:#edebe6; --ink-hover:#ffffff; --ink-2:#cac7bf; --sub:#a29f96; --muted:#8c897f;
    --line:#302e2a; --line-2:#3b3934; --line-3:#2a2925; --hover:#2c2b27; --soft:#282723; --track:#36342f;
    --accent:#f27c5e; --accent-soft:rgba(242,124,94,.16);
  }
  :root[data-theme="dark"] .btn--solid,:root[data-theme="dark"] .toast{color:var(--bg)}
  :root[data-theme="dark"] .seg-btn.is-active{background:var(--line-2);box-shadow:0 1px 3px rgba(0,0,0,.4)}
  /* 원래 어두운 사진 판 · 코드 상자: 배경과 구분되게 테두리 */
  :root[data-theme="dark"] .photo-wrap{background:#1f1e1b;border:1px solid var(--line-2)}
  :root[data-theme="dark"] .code{background:#181715;border:1px solid var(--line-2)}
  :root[data-theme="dark"] .picked-sw,:root[data-theme="dark"] .history button{box-shadow:inset 0 0 0 1px rgba(255,255,255,.14)}
  /* 아직 안 찍었을 때의 빈 견본 체커만 어둡게 (찍으면 JS가 그 색으로 덮음) */
  :root[data-theme="dark"] .picked-sw{background:repeating-conic-gradient(#2a2925 0 25%,#201f1c 0 50%) 0 0/12px 12px}
  :root[data-theme="dark"] .ratio{box-shadow:inset 0 0 0 1px rgba(255,255,255,.08)}
}
