: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:#1c1c1a;
  --font:"IBM Plex Sans KR",sans-serif; --mono:"JetBrains Mono",monospace;
}
*{box-sizing:border-box}
[hidden]{display:none !important}
html,body{height:100%}
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)}
.sr{position:absolute;width:1px;height:1px;overflow:hidden;clip:rect(0 0 0 0);white-space:nowrap}
.app{min-height:100vh;height:100vh;height:100dvh;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}
.actions{display:flex;align-items:center;gap:8px;flex-wrap:wrap}
.btn{height:36px;padding:0 14px;background:transparent;border:1px solid var(--line-2);border-radius:999px;font-size:13px;cursor:pointer;white-space:nowrap}
.btn:hover{background:var(--hover)}
.btn:disabled{opacity:.35;cursor:default}
.btn:disabled:hover{background:transparent}
.btn--icon{width:36px;padding:0;display:inline-flex;align-items:center;justify-content:center}
.btn--icon svg{width:18px;height:18px}
.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)}

/* ---------- 툴바 ---------- */
.toolbar{display:flex;align-items:center;justify-content:space-between;gap:12px;padding:10px 28px;background:var(--surface);border-bottom:1px solid var(--line);flex-wrap:wrap}
.toolbar-right{display:flex;align-items:center;gap:14px}
.seg{display:flex;background:var(--soft);border-radius:999px;padding:3px;gap:2px}
.seg-btn{height:30px;padding:0 14px;background:transparent;color:var(--sub);border:none;border-radius:999px;font-size:13px;cursor:pointer;white-space:nowrap}
.seg-btn:hover{color:var(--ink)}
.seg-btn.is-active{background:#fff;color:var(--ink);box-shadow:0 1px 3px rgba(0,0,0,.12);font-weight:500}
.hint{font-size:12px;color:var(--muted)}
kbd{font-family:var(--mono);font-size:11px;padding:1px 6px;border:1px solid var(--line-2);border-bottom-width:2px;border-radius:5px;background:#fff;color:var(--ink-2)}
.gen{display:inline-flex;align-items:center;gap:8px;height:38px;padding:0 18px 0 14px;background:var(--ink);color:#fff;border:none;border-radius:999px;font-size:14px;font-weight:500;cursor:pointer}
.gen:hover{background:var(--ink-hover)}
.gen svg{width:18px;height:18px}
.gen.spin svg{animation:spin .45s ease}
@keyframes spin{to{transform:rotate(180deg)}}

/* ---------- 팔레트 ---------- */
.palette{flex:1;min-height:420px;display:flex}
.col{--fg:#fff;position:relative;flex:1 1 0;min-width:0;display:flex;flex-direction:column;align-items:center;justify-content:flex-end;gap:16px;padding:28px 12px 44px;color:var(--fg);transition:background-color .4s ease,flex-grow .25s ease}
.col:hover{flex-grow:1.12}
.tools{display:flex;flex-direction:column;align-items:center;gap:6px;opacity:0;transform:translateY(6px);transition:opacity .2s,transform .2s}
.col:hover .tools,.col:focus-within .tools,.col.is-locked .tools{opacity:1;transform:none}
.col.is-locked .tools .tool:not(.tool--lock){opacity:0}
.col.is-locked:hover .tools .tool,.col.is-locked:focus-within .tools .tool{opacity:1}
.tool{position:relative;width:44px;height:44px;display:inline-flex;align-items:center;justify-content:center;background:transparent;border:none;border-radius:12px;color:inherit;cursor:pointer;opacity:.82;transition:background .15s,opacity .15s}
.tool:hover,.tool:focus-visible{background:color-mix(in srgb,currentColor 14%,transparent);opacity:1}
.tool svg{width:22px;height:22px}
.tool input{position:absolute;inset:0;width:100%;height:100%;opacity:0;cursor:pointer;border:0;padding:0}
.tool--lock[aria-pressed="true"]{opacity:1;background:color-mix(in srgb,currentColor 18%,transparent)}
.hex{background:none;border:none;color:inherit;padding:4px 8px;border-radius:8px;font-family:var(--mono);font-size:clamp(18px,2.2vw,30px);font-weight:700;letter-spacing:-.02em;cursor:pointer;white-space:nowrap}
.hex:hover{background:color-mix(in srgb,currentColor 12%,transparent)}
.meta{font-family:var(--mono);font-size:11px;letter-spacing:.04em;opacity:.7;text-align:center;white-space:nowrap;margin-top:-10px}
.col.flash .hex{animation:rise .35s ease}
@keyframes rise{from{opacity:0;transform:translateY(8px)}to{opacity:1;transform:none}}
.lock-tag{position:absolute;top:16px;left:50%;transform:translateX(-50%);font-family:var(--mono);font-size:10px;letter-spacing:.14em;opacity:0;transition:opacity .2s}
.col.is-locked .lock-tag{opacity:.75}

@media (hover:none){
  .tools{opacity:1;transform:none}
  .col.is-locked .tools .tool:not(.tool--lock){opacity:.82}
  .col:hover{flex-grow:1}
}

/* ---------- 내보내기 시트 ---------- */
.sheet{position:fixed;inset:0;z-index:40;display:flex;align-items:center;justify-content:center;padding:16px}
.sheet-back{position:absolute;inset:0;background:rgba(28,28,26,.45);animation:fade .2s ease}
.sheet-card{position:relative;width:100%;max-width:560px;max-height:calc(100vh - 32px);overflow:auto;background:var(--panel);border-radius:20px;padding:22px 22px 20px;display:flex;flex-direction:column;gap:14px;box-shadow:0 30px 80px rgba(0,0,0,.25);animation:up .25s ease}
@keyframes fade{from{opacity:0}}
@keyframes up{from{opacity:0;transform:translateY(16px)}}
.sheet-head{display:flex;justify-content:space-between;align-items:flex-start;gap:12px}
.sheet-head h2{margin:6px 0 0;font-size:19px}
.close{width:36px;height:36px;border:none;background:var(--soft);border-radius:999px;cursor:pointer;font-size:14px}
.close:hover{background:var(--hover)}
.sheet-strip{display:flex;height:56px;border-radius:12px;overflow:hidden}
.sheet-strip span{flex:1}
.seg--fit{align-self:flex-start;max-width:100%;overflow-x:auto}
.code{width:100%;min-height:190px;padding:14px 16px;background:#1c1c1a;color:#efeee9;border:none;border-radius:12px;font-family:var(--mono);font-size:13px;line-height:1.65;resize:vertical}
.code:focus{outline:2px solid var(--line-2);outline-offset:2px}
.sheet-foot{display:flex;align-items:flex-end;justify-content:space-between;gap:12px;flex-wrap:wrap}
.prefix{display:flex;flex-direction:column;gap:4px;font-size:12px;color:var(--ink-2)}
.prefix .text-input{width:160px;height:36px;font-family:var(--mono);font-size:13px}

/* ---------- 토스트 ---------- */
.toast{position:fixed;left:50%;bottom:28px;transform:translate(-50%,20px);background:var(--ink);color:#fff;padding:10px 18px;border-radius:999px;font-size:13px;opacity:0;pointer-events:none;transition:opacity .2s,transform .2s;z-index:60;max-width:calc(100% - 32px);white-space:nowrap;overflow:hidden;text-overflow:ellipsis;box-shadow:0 8px 24px rgba(0,0,0,.2)}
.toast.is-on{opacity:1;transform:translate(-50%,0)}
.toast b{font-family:var(--mono);font-weight:500}

@media (max-width:860px){
  .hint{display:none}
}
@media (max-width:640px){
  .app{height:auto;min-height:100vh;min-height:100dvh}
  .topbar{padding:14px 16px}
  .toolbar{padding:10px 16px}
  .toolbar .seg{width:100%}
  .toolbar .seg-btn{flex:1;padding:0 4px}
  .toolbar-right{width:100%}
  .gen{width:100%;justify-content:center;height:44px}
  .palette{flex-direction:column;min-height:0}
  .col{flex:1 1 auto;min-height:96px;flex-direction:row;justify-content:space-between;align-items:center;padding:14px 12px 14px 16px;gap:8px}
  .col:hover{flex-grow:1}
  .col-text{display:flex;flex-direction:column;align-items:flex-start;gap:2px;min-width:0}
  .hex{font-size:22px;padding:2px 4px;margin-left:-4px}
  .meta{margin:0;text-align:left}
  .tools{flex-direction:row;opacity:1;transform:none;gap:2px}
  .col.is-locked .tools .tool:not(.tool--lock){opacity:.82}
  .tool{width:40px;height:40px}
  .lock-tag{display:none}
}
@media (min-width:641px){
  .col-text{display:flex;flex-direction:column;align-items:center;gap:16px}
  .tools{order:-1}
  .col{justify-content:flex-end}
}
@media (prefers-reduced-motion:reduce){
  *,*::before,*::after{transition:none !important;animation:none !important}
}

/* 다크 모드 (인쇄는 라이트 그대로) — 팔레트 색 기둥 · 견본 띠는 고른 색 그대로 */
@media screen{
  :root[data-theme="dark"]{
    color-scheme:dark;
    --bg:#141318; --surface:#1a1920; --panel:#1f1e26; --panel-soft:#24232c;
    --ink:#ecebf0; --ink-hover:#ffffff; --ink-2:#c9c7d1; --sub:#a09eab; --muted:#8a8895;
    --line:#2e2d36; --line-2:#393843; --line-3:#26252d; --hover:#2a2932; --soft:#26252d; --track:#34333d;
    --accent:#ecebf0;
  }
  :root[data-theme="dark"] .btn--solid,:root[data-theme="dark"] .gen,:root[data-theme="dark"] .toast,
  :root[data-theme="dark"] .tb-presets button[aria-pressed="true"]{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"] kbd{background:var(--panel)}
  :root[data-theme="dark"] .sheet-back{background:rgba(0,0,0,.6)}
  :root[data-theme="dark"] .sheet-card{border:1px solid var(--line-2);box-shadow:0 30px 80px rgba(0,0,0,.5)}
  :root[data-theme="dark"] .code{background:#111015;border:1px solid var(--line-2)}
}
