/* CellNova 스타일 */
:root {
  --bg: #ffffff; --bg2: #f6f7f9; --bg3: #eef0f3; --panel: #ffffff;
  --fg: #1f2937; --fg2: #4b5563; --fg3: #6b7280; --line: #dfe3e8; --line2: #c9ced6;
  --accent: #0f766e; --accent2: #115e59; --accent-bg: #e6f4f2; --accent-fg: #ffffff;
  --hover: #eef2f5; --active: #d9ece9; --danger: #dc2626; --warn: #d97706; --ok: #15803d;
  --shadow: 0 8px 28px rgba(15, 23, 42, .16), 0 2px 6px rgba(15, 23, 42, .08);
  --radius: 8px; --font: "Malgun Gothic", "맑은 고딕", "Apple SD Gothic Neo", "Noto Sans KR", system-ui, -apple-system, "Segoe UI", sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #16191d; --bg2: #1d2126; --bg3: #262b31; --panel: #1f2328; --fg: #e5e7eb; --fg2: #c2c7ce; --fg3: #9aa1aa; --line: #2f353c; --line2: #3c434b;
    --accent: #2dd4bf; --accent2: #5eead4; --accent-bg: #133a37; --accent-fg: #062b28; --hover: #2a3037; --active: #17423e; color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #16191d; --bg2: #1d2126; --bg3: #262b31; --panel: #1f2328; --fg: #e5e7eb; --fg2: #c2c7ce; --fg3: #9aa1aa; --line: #2f353c; --line2: #3c434b;
  --accent: #2dd4bf; --accent2: #5eead4; --accent-bg: #133a37; --accent-fg: #062b28; --hover: #2a3037; --active: #17423e; color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: var(--bg); color: var(--fg); font: 13px/1.4 var(--font); -webkit-font-smoothing: antialiased; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: 0; padding: 0; }
[hidden] { display: none !important; }
.ic { display: inline-flex; align-items: center; justify-content: center; flex: none; line-height: 0; }
kbd { font: 11px/1 var(--font); padding: 2px 5px; border: 1px solid var(--line2); border-bottom-width: 2px; border-radius: 4px; background: var(--bg2); color: var(--fg2); white-space: nowrap; }
.spacer { flex: 1; }
.boot { display: grid; place-items: center; height: 100vh; color: var(--fg3); }
.boot-in { max-width: 560px; padding: 24px; text-align: center; line-height: 1.7; }
.boot-in h1 { font-size: 22px; margin: 0 0 8px; color: var(--accent); }
.boot-in p { margin: 0 0 10px; color: var(--fg2); }
.boot-in .boot-load { color: var(--fg3); }
.boot-in a { color: var(--accent); }

.app { display: flex; flex-direction: column; height: 100vh; height: 100dvh; }
.app > * { flex: none; }
.app > .grid-area { flex: 1 1 0; }
.app.ribbon-collapsed .ribbon { display: none; }
.app.no-fbar .formula-bar { display: none; }

/* 상단 */
.topbar { display: flex; align-items: center; gap: 10px; padding: 0 10px; height: 44px; background: var(--accent); color: #fff; }
:root[data-theme="dark"] .topbar { background: #0b3b37; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .topbar { background: #0b3b37; } }
.brand { display: flex; align-items: center; gap: 7px; font-size: 15px; letter-spacing: .2px; }
.brand .logo svg rect { fill: rgba(255, 255, 255, .16); }
.qa { display: flex; gap: 2px; }
.topbar .icon-btn { color: #fff; }
.topbar .icon-btn:hover { background: rgba(255, 255, 255, .16); }
.title-wrap { display: flex; align-items: center; gap: 8px; min-width: 0; }
.book-title { background: transparent; border: 1px solid transparent; color: #fff; border-radius: 6px; padding: 4px 8px; width: 200px; font-weight: 600; }
.book-title:hover { border-color: rgba(255, 255, 255, .35); }
.book-title:focus { background: #fff; color: #111; outline: none; }
.save-state { font-size: 11.5px; opacity: .8; white-space: nowrap; }
.search-box { flex: 0 1 420px; margin-left: auto; display: flex; align-items: center; gap: 8px; height: 30px; padding: 0 10px; border-radius: 8px; background: rgba(255, 255, 255, .15); color: rgba(255, 255, 255, .9); text-align: left; }
.search-box:hover { background: rgba(255, 255, 255, .24); }
.search-box span { flex: 1; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.search-box kbd { background: rgba(255, 255, 255, .15); border-color: rgba(255, 255, 255, .25); color: #fff; }
.top-right { display: flex; gap: 2px; margin-left: auto; }
.icon-btn { display: inline-flex; align-items: center; justify-content: center; width: 30px; height: 30px; border-radius: 6px; color: var(--fg2); }
.icon-btn:hover { background: var(--hover); }

/* 리본 */
.ribbon-tabs { display: flex; align-items: flex-end; gap: 2px; padding: 0 8px; background: var(--bg2); border-bottom: 1px solid var(--line); overflow-x: auto; scrollbar-width: none; }
.rtab { padding: 7px 14px 6px; border-bottom: 3px solid transparent; color: var(--fg2); white-space: nowrap; font-weight: 500; }
.rtab:hover { color: var(--fg); background: var(--hover); }
.rtab.active { color: var(--accent); border-bottom-color: var(--accent); font-weight: 700; }
.rtab.file-tab { color: var(--accent); font-weight: 700; }
.rtab-spacer { flex: 1; }
.rtab.collapse { padding: 6px 8px; }
.ribbon { display: flex; align-items: stretch; gap: 0; padding: 4px 6px 0; background: var(--bg); border-bottom: 1px solid var(--line); overflow-x: auto; overflow-y: hidden; min-height: 96px; scrollbar-width: thin; }
.rgroup { display: flex; flex-direction: column; padding: 0 6px; border-right: 1px solid var(--line); flex: none; }
.rgroup:last-child { border-right: 0; }
.rgroup-items { display: flex; align-items: flex-start; gap: 2px; flex: 1; }
.rgroup-name { text-align: center; font-size: 11px; color: var(--fg3); padding: 1px 0 3px; white-space: nowrap; }
.rbtn { display: inline-flex; align-items: center; justify-content: center; gap: 4px; min-width: 26px; height: 26px; padding: 0 4px; border-radius: 4px; color: var(--fg); border: 1px solid transparent; white-space: nowrap; }
.rbtn:hover { background: var(--hover); border-color: var(--line); }
.rbtn:active, .rbtn.on { background: var(--active); border-color: var(--line2); }
.rbtn.big { flex-direction: column; height: 70px; min-width: 52px; max-width: 76px; padding: 4px 4px 2px; gap: 3px; }
.rbtn.big .lbl { font-size: 11.5px; line-height: 1.2; white-space: pre-line; text-align: center; }
.rbtn.big .ic:last-child:not(:first-child) { display: none; }
.rbtn.wide { justify-content: flex-start; padding: 0 6px; }
.rbtn.wide .lbl { font-size: 12px; }
.rcol { display: flex; flex-direction: column; gap: 1px; padding-top: 1px; }
.rcol .rbtn { justify-content: flex-start; padding: 0 6px; height: 23px; }
.rcol .rbtn .lbl { font-size: 12px; }
.rrows { display: flex; flex-direction: column; gap: 3px; padding-top: 2px; }
.rrow { display: flex; align-items: center; gap: 1px; }
.split { display: inline-flex; align-items: stretch; border-radius: 4px; }
.split:hover { box-shadow: inset 0 0 0 1px var(--line); }
.split > .rbtn { border-radius: 4px 0 0 4px; }
.split > .rbtn.arrow { min-width: 14px; width: 14px; padding: 0; border-radius: 0 4px 4px 0; }
.split.big { flex-direction: column; }
.split.big > .rbtn.big { height: 52px; border-radius: 4px 4px 0 0; }
.split.big > .rbtn.arrow { width: 100%; height: 16px; border-radius: 0 0 4px 4px; }
.split.wide > .rbtn:first-child { padding: 0 6px; }
.color-main { flex-direction: column; gap: 0; }
.color-bar { display: block; width: 16px; height: 4px; margin-top: -2px; border-radius: 1px; }
.font-sel { width: 118px; height: 24px; border: 1px solid var(--line2); border-radius: 4px; background: var(--bg); padding: 0 4px; }
.size-wrap { display: inline-flex; align-items: center; margin-left: 2px; border: 1px solid var(--line2); border-radius: 4px; height: 24px; }
.size-sel { width: 34px; height: 22px; border: 0; background: var(--bg); padding: 0 4px; outline: none; }
.size-wrap .size-drop { height: 22px; min-width: 14px; width: 14px; border: 0; }
.numfmt-sel { width: 150px; height: 24px; border: 1px solid var(--line2); border-radius: 4px; background: var(--bg); padding: 0 4px; }
.rcheck { display: flex; align-items: center; gap: 6px; padding: 2px 4px; font-size: 12px; cursor: pointer; white-space: nowrap; }
.rcheck input { accent-color: var(--accent); }

/* 수식 입력줄 */
.formula-bar { display: flex; align-items: center; gap: 4px; padding: 4px 6px; background: var(--bg); border-bottom: 1px solid var(--line); }
.name-wrap { display: flex; align-items: center; border: 1px solid var(--line2); border-radius: 4px; height: 26px; }
.name-box { width: 96px; border: 0; background: transparent; padding: 0 6px; height: 24px; outline: none; }
.name-drop { width: 18px; height: 24px; display: flex; align-items: center; justify-content: center; border-left: 1px solid var(--line); color: var(--fg3); }
.fx-btns { display: flex; align-items: center; padding: 0 2px; border-right: 1px solid var(--line); }
.fx-btn { width: 26px; height: 26px; border-radius: 4px; display: inline-flex; align-items: center; justify-content: center; color: var(--fg3); }
.fx-btn:hover { background: var(--hover); color: var(--fg); }
.fx-fn i { font: italic 600 14px Georgia, serif; }
.fx-input { flex: 1; height: 26px; border: 1px solid transparent; border-radius: 4px; padding: 0 8px; background: transparent; outline: none; font-family: Consolas, "D2Coding", var(--font); }
.fx-input:focus { border-color: var(--accent); background: var(--bg); }
.fx-input.ghost::placeholder { color: var(--fg3); }
.app.fbar-tall .fx-input { height: 70px; }

/* 그리드 */
.grid-area { position: relative; overflow: hidden; min-height: 0; background: var(--bg); }
.grid-canvas { position: absolute; inset: 0; display: block; }
.grid-scroller { position: absolute; inset: 0; overflow: scroll; outline: none; }
.grid-spacer { pointer-events: none; }
.grid-overlay { position: absolute; inset: 0; pointer-events: none; overflow: hidden; }
.cell-editor { position: absolute; z-index: 5; margin: 0; padding: 1px 3px; border: 0; outline: none; resize: none; overflow: hidden; white-space: pre; opacity: 0; width: 1px; height: 1px; pointer-events: none; background: #fff; color: #111; box-shadow: none; }
.cell-editor.editing { opacity: 1; pointer-events: auto; outline: 2px solid #217346; outline-offset: 0; box-shadow: 0 2px 8px rgba(0, 0, 0, .15); }
.grid-tip { position: absolute; z-index: 8; max-width: 280px; padding: 6px 9px; background: #fffbe6; color: #333; border: 1px solid #e5c76b; border-radius: 4px; box-shadow: var(--shadow); font-size: 12px; pointer-events: none; white-space: pre-wrap; }
.grid-tip .tip-err { color: #b91c1c; }
.grid-tip .tip-link { color: #1d4ed8; }
.autocomplete { position: absolute; z-index: 9; min-width: 280px; max-width: 420px; max-height: 260px; overflow: auto; background: var(--panel); border: 1px solid var(--line2); border-radius: 6px; box-shadow: var(--shadow); padding: 3px; }
.ac-item { display: flex; flex-direction: column; padding: 4px 8px; border-radius: 4px; cursor: pointer; }
.ac-item b { font-family: Consolas, var(--font); font-size: 12.5px; }
.ac-item span { font-size: 11.5px; color: var(--fg3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ac-item.active, .ac-item:hover { background: var(--accent-bg); }
.arg-tip { position: absolute; z-index: 9; pointer-events: none; padding: 5px 9px; background: var(--panel); border: 1px solid var(--line2); border-radius: 5px; box-shadow: var(--shadow); font-size: 12px; white-space: nowrap; max-width: 560px; overflow: hidden; text-overflow: ellipsis; }
.arg-tip b { color: var(--accent); }
.arg-tip .arg-desc { display: block; color: var(--fg3); font-size: 11.5px; white-space: normal; }
.chart-box { position: absolute; pointer-events: auto; background: #fff; border: 1px solid #d1d5db; border-radius: 4px; padding: 8px; box-shadow: 0 1px 3px rgba(0, 0, 0, .08); cursor: move; }
.chart-box canvas { width: 100% !important; height: 100% !important; }
.chart-box.selected { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-bg), 0 4px 14px rgba(0, 0, 0, .12); }
.chart-handle.se { position: absolute; right: -5px; bottom: -5px; width: 11px; height: 11px; background: #fff; border: 2px solid var(--accent); border-radius: 2px; cursor: nwse-resize; display: none; }
.chart-box.selected .chart-handle { display: block; }
.chart-tools { position: absolute; top: 4px; right: 4px; display: none; gap: 2px; }
.chart-box:hover .chart-tools, .chart-box.selected .chart-tools { display: flex; }
.chart-tools button { width: 24px; height: 24px; border-radius: 4px; background: #fff; border: 1px solid #d1d5db; color: #374151; font-size: 13px; }
.chart-tools button:hover { background: #f3f4f6; }
.fill-opt { position: absolute; z-index: 6; display: flex; align-items: center; height: 20px; padding: 0 2px; background: var(--panel); border: 1px solid var(--line2); border-radius: 3px; box-shadow: 0 1px 3px rgba(0, 0, 0, .15); transition: opacity .6s; }
.fill-opt.fade { opacity: .45; }
.app.painting .grid-scroller { cursor: copy; }
body.dropping::after { content: "파일을 놓으면 엽니다 (xlsx, csv)"; position: fixed; inset: 12px; display: grid; place-items: center; border: 3px dashed var(--accent); border-radius: 16px; background: rgba(15, 118, 110, .08); color: var(--accent); font-size: 20px; font-weight: 700; z-index: 100; pointer-events: none; }

/* 시트 탭 / 상태 표시줄 */
.sheetbar { display: flex; align-items: stretch; height: 32px; background: var(--bg2); border-top: 1px solid var(--line); }
.tab-nav, .tab-add { width: 30px; display: flex; align-items: center; justify-content: center; color: var(--fg3); }
.tab-nav:hover, .tab-add:hover { background: var(--hover); color: var(--fg); }
.sheet-tabs { display: flex; overflow-x: auto; scrollbar-width: none; max-width: calc(100% - 100px); }
.stab { position: relative; display: flex; align-items: center; gap: 4px; padding: 0 16px; border-right: 1px solid var(--line); cursor: pointer; white-space: nowrap; color: var(--fg2); user-select: none; }
.stab:hover { background: var(--hover); }
.stab.active { background: var(--bg); color: var(--accent); font-weight: 700; box-shadow: inset 0 -3px 0 var(--accent); }
.stab::after { content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 3px; background: var(--tabc, transparent); }
.stab.active::after { height: 0; }
.stab.active { --tabcolor: var(--tabc); }
.statusbar { display: flex; align-items: center; gap: 10px; height: 26px; padding: 0 10px; background: var(--bg2); border-top: 1px solid var(--line); font-size: 12px; color: var(--fg2); }
.st-mode { min-width: 40px; font-weight: 600; }
.st-msg { color: var(--fg3); overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.st-stats { display: flex; gap: 14px; cursor: pointer; white-space: nowrap; overflow: hidden; }
.st-stats b { font-weight: 600; color: var(--fg); }
.zoom-btn { width: 20px; height: 20px; display: inline-flex; align-items: center; justify-content: center; border-radius: 3px; }
.zoom-btn:hover { background: var(--hover); }
.zoom-range { width: 110px; accent-color: var(--accent); }
.zoom-label { min-width: 40px; text-align: right; }

/* 메뉴 */
.menu { position: fixed; z-index: 60; min-width: 200px; max-width: 360px; max-height: calc(100vh - 16px); overflow-y: auto; padding: 4px; background: var(--panel); border: 1px solid var(--line2); border-radius: 8px; box-shadow: var(--shadow); }
.menu.scroll { max-height: 420px; }
.mi { display: flex; align-items: center; gap: 8px; width: 100%; padding: 5px 10px 5px 8px; border-radius: 5px; text-align: left; color: var(--fg); min-height: 28px; }
.mi:hover, .mi:focus { background: var(--accent-bg); outline: none; }
.mi.disabled { color: var(--fg3); pointer-events: none; }
.mi .ic { color: var(--fg2); width: 16px; }
.ml { flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mk { font-size: 11px; color: var(--fg3); margin-left: 16px; }
.msep { height: 1px; margin: 4px 6px; background: var(--line); }
.mtitle { padding: 6px 8px 3px; font-size: 11.5px; color: var(--fg3); font-weight: 600; }
.sw { display: inline-block; width: 14px; height: 14px; border-radius: 3px; border: 1px solid rgba(0, 0, 0, .15); flex: none; }
.sws { display: inline-flex; gap: 1px; }
.sws .sw { width: 10px; border-radius: 2px; }
.color-menu { width: 248px; }
.cgrid { display: grid; grid-template-columns: repeat(10, 1fr); gap: 3px; padding: 4px 8px; }
.cgrid.big { gap: 4px; padding: 4px 0; max-width: 340px; }
.cell-sw { width: 100%; aspect-ratio: 1; border: 1px solid rgba(0, 0, 0, .15); border-radius: 2px; }
.cell-sw:hover, .cell-sw.active { outline: 2px solid var(--accent); outline-offset: 1px; }
.color-menu input[type=color] { width: 28px; height: 20px; border: 0; padding: 0; background: none; }
.filter-menu { width: 260px; }
.fsearch { padding: 4px 6px; }
.fvals { max-height: 220px; overflow: auto; border: 1px solid var(--line); border-radius: 5px; margin: 2px 6px; padding: 3px 4px; }
.fvals .chk { display: flex; padding: 2px 2px; }
.fvals .chk span { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fvals small { color: var(--fg3); }
.btnrow { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin: 6px 0; }
.btnrow.end { justify-content: flex-end; padding: 2px 6px 4px; }
.dv-menu .mi { min-height: 24px; padding: 3px 8px; }

/* 토스트 */
.toasts { position: fixed; left: 50%; bottom: 46px; transform: translateX(-50%); display: flex; flex-direction: column; align-items: center; gap: 6px; z-index: 90; pointer-events: none; }
.toast { display: flex; align-items: center; gap: 8px; max-width: min(560px, calc(100vw - 32px)); padding: 9px 14px; border-radius: 8px; background: #1f2937; color: #fff; box-shadow: var(--shadow); font-size: 13px; animation: tin .18s ease-out; pointer-events: auto; }
.toast.ok .ic { color: #4ade80; } .toast.error { background: #7f1d1d; } .toast.warn .ic { color: #fbbf24; } .toast.info .ic { color: #93c5fd; }
.toast.out { opacity: 0; transform: translateY(6px); transition: .3s; }
@keyframes tin { from { opacity: 0; transform: translateY(8px); } }

/* 모달 */
.modal { position: fixed; inset: 0; z-index: 70; display: flex; align-items: center; justify-content: center; background: rgba(15, 23, 42, .32); padding: 16px; }
.modal.modeless { background: transparent; pointer-events: none; justify-content: flex-end; align-items: flex-start; padding-top: 150px; }
.modal.modeless .dlg { pointer-events: auto; }
.dlg { display: flex; flex-direction: column; width: min(460px, 100%); max-height: calc(100vh - 32px); background: var(--panel); border-radius: 12px; box-shadow: var(--shadow); border: 1px solid var(--line); animation: din .15s ease-out; }
.dlg.wide { width: min(760px, 100%); }
.dlg.xwide { width: min(980px, 100%); }
@keyframes din { from { opacity: 0; transform: scale(.98) translateY(6px); } }
.dlg-head { display: flex; align-items: center; padding: 12px 12px 8px 18px; cursor: move; user-select: none; }
.dlg-head h2 { flex: 1; margin: 0; font-size: 15px; }
.dlg-body { padding: 4px 18px 10px; overflow: auto; }
.dlg-foot { display: flex; align-items: center; gap: 8px; padding: 10px 18px 14px; border-top: 1px solid var(--line); }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: 32px; padding: 0 14px; border-radius: 6px; border: 1px solid var(--line2); background: var(--bg); color: var(--fg); font-weight: 500; white-space: nowrap; }
.btn:hover { background: var(--hover); }
.btn:focus-visible, .inp:focus, .mi:focus-visible, .rbtn:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-fg); }
.btn.primary:hover { background: var(--accent2); }
.btn.danger { color: var(--danger); }
.btn.sm { height: 28px; padding: 0 10px; font-size: 12.5px; }
.btn.xs { height: 22px; padding: 0 6px; font-size: 11px; }
.btn.block { width: 100%; justify-content: flex-start; height: 38px; margin: 4px 0; }
.inp { width: 100%; height: 32px; padding: 0 9px; border: 1px solid var(--line2); border-radius: 6px; background: var(--bg); outline: none; }
.inp.sm { height: 28px; } .inp.xs { height: 22px; width: auto; padding: 0 4px; font-size: 11.5px; }
textarea.inp { height: auto; padding: 7px 9px; resize: vertical; }
input[type=color].inp { padding: 2px; height: 32px; }
.inp.mono, .mono { font-family: Consolas, "D2Coding", monospace; }
.field { display: flex; flex-direction: column; gap: 4px; margin: 8px 0; }
.field > span { font-size: 12px; font-weight: 600; color: var(--fg2); }
.field small, .hint { color: var(--fg3); font-size: 11.5px; }
.hint { display: block; margin: 6px 0; }
.lab { font-size: 12px; font-weight: 600; color: var(--fg2); margin: 10px 0 4px; }
.chk { display: inline-flex; align-items: center; gap: 6px; margin: 3px 12px 3px 0; cursor: pointer; }
.chk input { accent-color: var(--accent); width: 15px; height: 15px; }
.radios { display: flex; flex-direction: column; }
.opts { display: flex; flex-wrap: wrap; margin: 6px 0; }
.msg { white-space: pre-wrap; line-height: 1.6; padding: 4px 0 8px; }
.cols2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 18px; }
.cols3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0 12px; align-items: end; }
.row2 { display: grid; grid-template-columns: 1fr 160px; gap: 8px; }
.row3 { display: flex; gap: 8px; margin: 6px 0; }
.dlg h4 { margin: 12px 0 6px; font-size: 12.5px; color: var(--fg2); }
.dtabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line); margin-bottom: 8px; overflow-x: auto; }
.dtab { padding: 7px 12px; border-bottom: 2px solid transparent; color: var(--fg2); white-space: nowrap; }
.dtab.active { color: var(--accent); border-bottom-color: var(--accent); font-weight: 700; }
.list { border: 1px solid var(--line); border-radius: 6px; max-height: 240px; overflow: auto; padding: 3px; }
.li { display: flex; align-items: center; gap: 10px; padding: 5px 8px; border-radius: 4px; cursor: pointer; }
.li:hover { background: var(--hover); }
.li.active { background: var(--accent-bg); }
.li small { color: var(--fg3); margin-left: auto; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 55%; }
.list.checks { display: flex; flex-direction: column; padding: 6px 8px; }
.empty { padding: 18px; text-align: center; color: var(--fg3); }
.fmt-grid { display: grid; grid-template-columns: 150px 1fr; gap: 14px; }
.cat-list { height: 330px; max-height: none; }
.code-list { height: 228px; max-height: none; margin-top: 6px; }
.code-list .li small { max-width: 45%; }
.fmt-preview { min-height: 34px; padding: 7px 10px; border: 1px solid var(--line); border-radius: 6px; background: var(--bg2); font-size: 15px; margin-bottom: 4px; }
.font-preview { display: grid; place-items: center; height: 90px; border: 1px solid var(--line); border-radius: 6px; background: #fff; color: #111; }
.border-preview { position: relative; display: grid; grid-template-columns: 1fr 1fr; width: 220px; height: 110px; margin: 6px 0; background: #fff; color: #555; }
.border-preview .bp-cell { display: grid; place-items: center; font-size: 12px; }
.border-preview .bp-cell:nth-child(1), .border-preview .bp-cell:nth-child(3) { border-right: var(--bv); }
.border-preview .bp-cell:nth-child(1), .border-preview .bp-cell:nth-child(2) { border-bottom: var(--bh); }
.bstyles { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; }
.bstyle { height: 26px; padding: 0 8px; border: 1px solid var(--line); border-radius: 4px; display: flex; align-items: center; }
.bstyle span { display: block; width: 100%; height: 0; }
.bstyle.active { border-color: var(--accent); background: var(--accent-bg); }
.fill-preview { height: 50px; border: 1px solid var(--line); border-radius: 6px; }
.find-dlg .opts { margin: 4px 0; }
.find-status { font-size: 12px; color: var(--fg3); min-height: 18px; }
.find-results { max-height: 220px; overflow: auto; }
.find-results .li b { font-family: Consolas, monospace; font-size: 12px; min-width: 100px; }
.find-results .li span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sort-rows { display: flex; flex-direction: column; gap: 6px; }
.sort-row { display: grid; grid-template-columns: 70px 1fr 110px 1fr 30px; gap: 6px; align-items: center; }
.lvl { font-size: 12px; color: var(--fg2); }
.cf-list { display: flex; flex-direction: column; gap: 4px; max-height: 340px; overflow: auto; margin-top: 6px; }
.cf-item { display: grid; grid-template-columns: 64px 1fr 110px 30px 30px 30px; align-items: center; gap: 8px; padding: 5px 6px; border: 1px solid var(--line); border-radius: 6px; }
.cf-sw { display: grid; place-items: center; height: 24px; border-radius: 4px; font-size: 11px; border: 1px solid rgba(0, 0, 0, .1); }
.cf-desc { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cf-rg { font-family: Consolas, monospace; font-size: 12px; color: var(--fg3); }
.ref-wrap { display: flex; gap: 4px; }
.ref-wrap .inp { font-family: Consolas, monospace; }
.chart-dlg { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.chart-types { display: grid; grid-template-columns: repeat(5, 1fr); gap: 4px; }
.ctype { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 6px 2px; border: 1px solid var(--line); border-radius: 6px; font-size: 10.5px; color: var(--fg2); }
.ctype:hover { background: var(--hover); }
.ctype.active { border-color: var(--accent); background: var(--accent-bg); color: var(--accent); }
.chart-prev { position: relative; min-height: 300px; border: 1px solid var(--line); border-radius: 8px; background: #fff; padding: 8px; }
.chart-prev canvas { position: absolute; inset: 8px; width: calc(100% - 16px) !important; height: calc(100% - 16px) !important; }
.pv-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.pv-fields { border: 1px solid var(--line); border-radius: 6px; max-height: 300px; overflow: auto; padding: 4px; }
.pv-field { display: flex; align-items: center; justify-content: space-between; padding: 2px 4px; border-radius: 4px; }
.pv-field:hover { background: var(--hover); }
.pv-add { display: flex; gap: 2px; opacity: .55; }
.pv-field:hover .pv-add { opacity: 1; }
.pv-zone { min-height: 40px; border: 1px dashed var(--line2); border-radius: 6px; padding: 4px; display: flex; flex-wrap: wrap; gap: 4px; align-items: center; }
.pv-zone .empty { padding: 4px 6px; font-size: 11.5px; }
.chip { display: inline-flex; align-items: center; gap: 4px; padding: 2px 4px 2px 8px; background: var(--accent-bg); border-radius: 14px; font-size: 12px; }
.chip .icon-btn { width: 20px; height: 20px; }
.symbols { display: grid; grid-template-columns: repeat(auto-fill, minmax(32px, 1fr)); gap: 3px; max-height: 260px; overflow: auto; }
.sym { height: 32px; border: 1px solid var(--line); border-radius: 4px; font-size: 16px; }
.sym:hover { background: var(--accent-bg); border-color: var(--accent); }
.fn-dlg .fn-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 8px; }
.fn-list { height: 320px; max-height: none; }
.fn-list .li b { font-family: Consolas, monospace; font-size: 12.5px; min-width: 120px; }
.fn-info { padding: 4px 8px; }
.fn-info h3 { font-family: Consolas, monospace; font-size: 14px; margin: 4px 0 10px; color: var(--accent); word-break: break-all; }
.fn-info p { line-height: 1.6; }
.fn-info .ex { background: var(--bg2); padding: 8px; border-radius: 6px; margin: 10px 0; }
.names-list .name-row { display: grid; grid-template-columns: 120px 1fr 90px 96px; }
.names-list code { font-size: 12px; color: var(--fg2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.names-list .acts { display: flex; }
.eval-steps { border: 1px solid var(--line); border-radius: 6px; max-height: 320px; overflow: auto; padding: 6px; }
.eval-row { display: flex; gap: 8px; align-items: baseline; padding: 2px 0; font-size: 12.5px; }
.eval-row code { color: var(--fg2); word-break: break-all; }
code.block { display: block; padding: 8px; background: var(--bg2); border-radius: 6px; word-break: break-all; }
.ttc-prev { border: 1px solid var(--line); border-radius: 6px; max-height: 150px; overflow: auto; }
.ttc-prev table { border-collapse: collapse; font-size: 12px; }
.ttc-prev td { border: 1px solid var(--line); padding: 2px 8px; white-space: nowrap; }
table.kv { border-collapse: collapse; width: 100%; }
table.kv th { text-align: left; font-weight: 500; color: var(--fg2); padding: 6px 4px; border-bottom: 1px solid var(--line); }
table.kv td { text-align: right; padding: 6px 4px; border-bottom: 1px solid var(--line); font-weight: 600; }
.about { text-align: center; padding: 10px; }
.about h3 { margin: 10px 0 4px; } .about p { color: var(--fg2); }
.shortcuts { display: grid; grid-template-columns: repeat(auto-fit, minmax(290px, 1fr)); gap: 6px 22px; }
.shortcuts h4 { margin: 8px 0 4px; color: var(--accent); }
.shortcuts table { width: 100%; border-collapse: collapse; font-size: 12.5px; }
.shortcuts td { padding: 3px 0; border-bottom: 1px solid var(--line); vertical-align: top; }
.shortcuts td:first-child { white-space: nowrap; padding-right: 10px; }

/* 명령 검색 */
.pal-overlay { align-items: flex-start; padding-top: 70px; }
.palette { width: min(620px, 100%); background: var(--panel); border-radius: 12px; box-shadow: var(--shadow); border: 1px solid var(--line); overflow: hidden; }
.pal-head { display: flex; align-items: center; gap: 10px; padding: 10px 14px; border-bottom: 1px solid var(--line); }
.pal-input { flex: 1; border: 0; outline: none; background: transparent; font-size: 15px; height: 30px; }
.pal-list { max-height: 420px; overflow: auto; padding: 4px; }
.pal-item { display: flex; align-items: center; gap: 10px; padding: 7px 10px; border-radius: 6px; cursor: pointer; }
.pal-item.active { background: var(--accent-bg); }
.pal-item .pl { white-space: nowrap; }
.pal-item .pd { flex: 1; color: var(--fg3); font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pal-item kbd { margin-left: auto; }
.pal-empty { padding: 20px; text-align: center; color: var(--fg3); }

/* 시작 화면 */
.start-dlg { width: min(900px, 100%) !important; }
.start { display: grid; grid-template-columns: 240px 1fr; gap: 24px; padding-bottom: 8px; }
.start-side h1 { margin: 8px 0 2px; font-size: 24px; color: var(--accent); }
.start-side p { color: var(--fg2); margin: 0 0 16px; }
.start-links { display: flex; flex-wrap: wrap; gap: 4px 12px; margin-top: 14px; font-size: 12.5px; }
.start-links a { color: var(--accent); text-decoration: none; }
.start-links a:hover { text-decoration: underline; }
.start-main h3 { margin: 4px 0 10px; font-size: 14px; }
.tpl-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 12px; }
.tpl { display: flex; flex-direction: column; align-items: flex-start; gap: 3px; padding: 8px; border: 1px solid var(--line); border-radius: 10px; text-align: left; background: var(--bg); }
.tpl:hover { border-color: var(--accent); box-shadow: 0 2px 10px rgba(0, 0, 0, .08); }
.tpl small { color: var(--fg3); font-size: 11.5px; }
.tpl-thumb { display: grid; place-items: center; width: 100%; height: 86px; border-radius: 7px; margin-bottom: 4px; color: #fff; background: linear-gradient(135deg, var(--tc, #0f766e), color-mix(in srgb, var(--tc, #0f766e) 60%, #000)); }
.tpl-thumb.blank { background: var(--bg2); color: var(--fg3); border: 1px dashed var(--line2); }

/* 빠른 안내 */
.tour-ov { position: fixed; inset: 0; z-index: 80; }
.tour-hl { position: fixed; border-radius: 8px; box-shadow: 0 0 0 9999px rgba(15, 23, 42, .45); border: 2px solid #fbbf24; pointer-events: none; transition: all .25s; }
.tour-card { position: fixed; z-index: 1; width: 360px; background: var(--panel); border-radius: 12px; padding: 16px 18px; box-shadow: var(--shadow); }
.tour-card h3 { margin: 4px 0 6px; font-size: 16px; }
.tour-card p { margin: 0 0 8px; color: var(--fg2); line-height: 1.6; }
.tour-step { font-size: 11.5px; color: var(--accent); font-weight: 700; }

/* 반응형 */
@media (max-width: 760px) {
  .brand b, .save-state, .search-box span, .search-box kbd, .top-right { display: none; }
  .search-box { flex: 0 0 auto; }
  .book-title { width: 120px; }
  .ribbon { min-height: 0; }
  .rgroup-name { display: none; }
  .zoom-range { display: none; }
  .st-stats span:not(:last-child) { display: none; }
  .cols2, .cols3, .chart-dlg, .pv-grid, .fn-dlg .fn-grid, .fmt-grid, .start { grid-template-columns: 1fr; }
  .cat-list { height: 120px; }
  .sort-row { grid-template-columns: 1fr 1fr; }
  .dlg { max-height: calc(100dvh - 20px); }
}
@media print { .topbar, .ribbon-tabs, .ribbon, .formula-bar, .sheetbar, .statusbar { display: none; } }
