:root {
  --paper: #eef2f5;
  --panel: #ffffff;
  --ink: #152033;
  --muted: #5b6779;
  --line: #d3dae2;
  --lox: #1f5bd8;
  --fuel: #b45309;
  --danger: #b42318;
  --ok: #18794e;
  --r: 8px;
  --hot: linear-gradient(90deg, #1b0c41, #5c1a6e, #a5304f, #e4572e, #f8a325, #fcf1a1);
  --isp: linear-gradient(90deg, #f3f6fa, #b9cdf2, #6c94e6, #1f5bd8, #0c2d7a);
  font-family: "IBM Plex Sans KR", system-ui, sans-serif;
  font-variant-numeric: tabular-nums;
  color: var(--ink);
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; background: var(--paper); }
body { font-size: 15px; line-height: 1.5; min-height: 100vh; }
button, input, select { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--lox); outline-offset: 2px; }

/* ---------- top ---------- */
.top {
  display: flex; align-items: center; gap: 24px;
  padding: 12px 24px; background: var(--panel); border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 10;
}
.brand { display: flex; align-items: center; gap: 12px; }
.brand svg { width: 28px; height: 28px; fill: var(--ink); }
.brand h1 { font-size: 19px; margin: 0; letter-spacing: -0.01em; }
.brand p { margin: 0; font-size: 12.5px; color: var(--muted); }
.tabs { display: flex; gap: 4px; margin-left: 16px; }
.tabs button {
  border: 0; background: none; padding: 8px 14px; border-radius: 6px; cursor: pointer; color: var(--muted); font-weight: 500;
}
.tabs button[aria-selected="true"] { background: var(--ink); color: #fff; }
.tabs button:hover:not([aria-selected="true"]) { background: var(--paper); color: var(--ink); }
.live { margin-left: auto; display: flex; align-items: center; gap: 10px; font-size: 14px; white-space: nowrap; }
.dot { width: 9px; height: 9px; border-radius: 50%; background: var(--line); }
.dot.on { background: var(--ok); box-shadow: 0 0 0 4px #18794e22; }

button {
  border: 1px solid var(--ink); background: var(--ink); color: #fff;
  padding: 8px 14px; border-radius: 6px; cursor: pointer; font-weight: 500; white-space: nowrap;
}
button.ghost { background: transparent; color: var(--ink); border-color: var(--line); }
button.ghost:hover { border-color: var(--ink); }
button:disabled { opacity: .5; cursor: progress; }

main { padding: 20px 28px 48px; max-width: 2400px; margin: 0 auto; }
.tab-panel { display: none; }
.tab-panel.active { display: block; }
#tab-design.active { display: grid; grid-template-columns: 300px 1fr; gap: 20px; align-items: start; }

/* ---------- inputs ---------- */
.inputs {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--r);
  padding: 18px; display: flex; flex-direction: column; gap: 14px; position: sticky; top: 84px;
}
.field { display: flex; flex-direction: column; gap: 5px; font-size: 13px; color: var(--muted); }
.field > span { display: flex; justify-content: space-between; align-items: baseline; }
.field em { font-style: normal; opacity: .75; margin-left: 4px; }
.field output { color: var(--ink); font-weight: 700; font-size: 17px; }
.field input, .field select {
  border: 1px solid var(--line); border-radius: 6px; padding: 8px 10px; background: #fff; font-size: 15px; width: 100%;
}
.field input:focus, .field select:focus { border-color: var(--lox); outline: none; }
input[type=range] { accent-color: var(--lox); padding: 0 !important; border: 0 !important; height: 26px; }
.pair { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.adv { border-top: 1px solid var(--line); padding-top: 12px; }
.adv summary { cursor: pointer; font-size: 13px; color: var(--muted); margin-bottom: 10px; }
.adv[open] { display: flex; flex-direction: column; gap: 12px; }
.actions { display: flex; gap: 8px; }
.actions button { flex: 1; font-size: 13.5px; }
.hint { font-size: 12.5px; color: var(--muted); margin: 0; }
.hint.err { color: var(--danger); }

/* ---------- stage ---------- */
.stage { display: flex; flex-direction: column; gap: 20px; min-width: 0; }
.viewport {
  position: relative; height: min(58vh, 560px); min-height: 360px;
  border-radius: var(--r); overflow: hidden;
  background:
    linear-gradient(#e3e9ef 1px, transparent 1px) 0 0 / 24px 24px,
    linear-gradient(90deg, #e3e9ef 1px, transparent 1px) 0 0 / 24px 24px,
    #f7f9fb;
  border: 1px solid var(--line);
  cursor: grab;
}
.viewport:active { cursor: grabbing; }
.viewport canvas { display: block; }
.overlay-top {
  position: absolute; inset: 18px 20px auto 20px; display: flex; justify-content: space-between; align-items: flex-start;
  pointer-events: none;
}
.big { line-height: 1; }
.big span { font-size: clamp(56px, 7vw, 92px); font-weight: 700; letter-spacing: -0.035em; }
.big small { font-size: 22px; font-weight: 600; margin-left: 6px; color: var(--muted); }
.big p { margin: 8px 0 0; font-size: 14px; color: var(--muted); }
.legend { display: grid; grid-template-columns: auto auto; gap: 2px 10px; font-size: 12px; color: var(--muted); align-items: center; background: #ffffffcc; padding: 8px 10px; border-radius: 6px; }
.legend > span:first-child { grid-column: 1 / -1; }
.legend .ramp { grid-column: 1 / -1; }
#legHi { text-align: right; }
.ramp { display: block; width: 160px; height: 8px; border-radius: 4px; background: var(--hot); }
.ramp-isp { background: var(--isp); width: 220px; }
.warn { position: absolute; left: 20px; bottom: 16px; display: flex; flex-direction: column; gap: 6px; max-width: 60%; pointer-events: none; }
.warn p { margin: 0; background: #fff8eb; border: 1px solid #f2d39b; color: #7a4a00; font-size: 13px; padding: 6px 10px; border-radius: 6px; }
.drag-hint { position: absolute; right: 18px; bottom: 12px; margin: 0; font-size: 12px; color: var(--muted); pointer-events: none; }

.sheet { display: grid; grid-template-columns: minmax(280px, 380px) 1fr; gap: 20px; align-items: start; }
.spec { width: 100%; border-collapse: collapse; background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); overflow: hidden; font-size: 14px; }
.spec caption { text-align: left; font-weight: 700; padding: 0 0 8px; font-size: 15px; }
.spec th { text-align: left; font-weight: 400; color: var(--muted); padding: 7px 12px; border-top: 1px solid var(--line); white-space: nowrap; }
.spec td { text-align: right; padding: 7px 12px; border-top: 1px solid var(--line); font-weight: 600; white-space: nowrap; }
.spec td small { font-weight: 400; color: var(--muted); margin-left: 3px; }
.spec tr.group th { color: var(--ink); font-weight: 700; background: var(--paper); font-size: 12.5px; padding: 5px 12px; }
.spec .ox { color: var(--lox); } .spec .fu { color: var(--fuel); }

.charts { display: flex; flex-direction: column; gap: 20px; min-width: 0; }
figure { margin: 0; background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); padding: 14px 16px; min-width: 0; }
figcaption { font-weight: 700; font-size: 15px; margin-bottom: 10px; }
figcaption .sub { font-weight: 400; color: var(--muted); font-size: 13px; }
.chart-box { position: relative; height: 240px; }
.chart-box.tall { height: 340px; }

#species { display: flex; flex-direction: column; gap: 6px; font-size: 13px; }
.sp { display: grid; grid-template-columns: 54px 1fr 1fr; gap: 10px; align-items: center; }
.sp b { font-weight: 600; }
.sp .bar { position: relative; height: 16px; background: var(--paper); border-radius: 3px; }
.sp .bar i { position: absolute; inset: 0 auto 0 0; background: var(--ink); border-radius: 3px; }
.sp .bar.ex i { background: var(--lox); }
.sp .bar span { position: absolute; right: 4px; top: -1px; font-size: 11.5px; color: var(--muted); }
.sp-head { grid-template-columns: 54px 1fr 1fr; color: var(--muted); font-size: 12px; }

/* ---------- analysis ---------- */
.analysis-head { display: flex; justify-content: space-between; align-items: center; gap: 20px; margin-bottom: 16px; }
.analysis-head p { margin: 0; max-width: 70ch; color: var(--muted); }
.wide { margin-bottom: 20px; }
.carpet-wrap { position: relative; }
#carpet { width: 100%; height: auto; display: block; }
.carpet-legend { display: flex; align-items: center; gap: 10px; font-size: 12.5px; color: var(--muted); margin-top: 8px; }

/* ---------- challenge ---------- */
.challenge { display: grid; grid-template-columns: minmax(280px, 420px) 1fr; gap: 28px; align-items: start; }
.rules h2 { margin: 0 0 10px; font-size: 26px; letter-spacing: -0.02em; }
.rules p { color: var(--muted); max-width: 60ch; }
.ch-form { display: flex; gap: 8px; margin: 18px 0 8px; }
.ch-form input { flex: 1; border: 1px solid var(--line); border-radius: 6px; padding: 9px 12px; font-size: 15px; }
.board { list-style: none; padding: 0; margin: 0; background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); counter-reset: r; }
.board li { display: grid; grid-template-columns: 44px 1fr auto; gap: 12px; align-items: center; padding: 12px 16px; border-top: 1px solid var(--line); counter-increment: r; }
.board li:first-child { border-top: 0; }
.board li::before { content: counter(r); font-size: 20px; font-weight: 700; color: var(--muted); text-align: center; }
.board li:nth-child(1)::before { color: var(--ink); font-size: 26px; }
.board .who b { display: block; font-size: 16px; }
.board .who span { font-size: 12.5px; color: var(--muted); }
.board .score { font-size: 22px; font-weight: 700; }
.board .score small { font-size: 13px; color: var(--muted); font-weight: 500; margin-left: 2px; }
.board li.new { animation: flash 1.6s ease-out; }
.board .empty { display: block; padding: 28px; color: var(--muted); text-align: center; }
.board .empty::before { content: none; }
@keyframes flash { from { background: #dfe8fb; } to { background: transparent; } }

/* ---------- system (실시간 모니터) ---------- */
.mon-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; margin-bottom: 16px; }
.mon-head h2 { margin: 0; font-size: 22px; letter-spacing: -0.01em; }
.mon-head p { margin: 4px 0 0; }
.mon-live { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); margin: 0; }
.mon-tiles { display: grid; grid-template-columns: repeat(4, 1fr); gap: 1px; background: var(--line); border: 1px solid var(--line); border-radius: var(--r); overflow: hidden; margin-bottom: 20px; }
.tile { background: var(--panel); padding: 12px 14px; }
.tile dt { font-size: 12.5px; color: var(--muted); }
.tile dd { margin: 2px 0 0; font-size: 22px; font-weight: 700; }
.tile dd small { font-size: 13px; font-weight: 500; color: var(--muted); margin-left: 3px; }
.tile .meter { height: 5px; background: var(--paper); border-radius: 3px; margin-top: 8px; overflow: hidden; }
.tile .meter i { display: block; height: 100%; background: var(--lox); transition: width .4s; }
.tile .meter i.warn { background: #d97706; } .tile .meter i.crit { background: var(--danger); }
.mon-charts { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; margin-bottom: 20px; }
.mon-charts .chart-box { height: 190px; }
.mon-bottom { display: grid; grid-template-columns: 1.2fr 1fr; gap: 28px; }
.mon-bottom h3 { font-size: 15px; margin: 0 0 10px; }
.mon-bottom h3 + .stats, .bars + h3 { margin-top: 18px; }
.bars { display: flex; flex-direction: column; gap: 10px; }
.bar-row { display: grid; grid-template-columns: 90px 1fr 150px; gap: 12px; align-items: center; font-size: 13.5px; }
.bar-row .track { height: 12px; background: var(--paper); border: 1px solid var(--line); border-radius: 6px; overflow: hidden; }
.bar-row .track i { display: block; height: 100%; background: var(--ink); }
.bar-row span:last-child { text-align: right; color: var(--muted); }
.stats { display: grid; grid-template-columns: repeat(2, 1fr); gap: 1px; background: var(--line); border: 1px solid var(--line); border-radius: var(--r); overflow: hidden; margin: 0; }
.stats div { background: var(--panel); padding: 10px 14px; }
.stats dt { font-size: 12.5px; color: var(--muted); }
.stats dd { margin: 2px 0 0; font-size: 18px; font-weight: 700; }
.feed { list-style: none; padding: 0; margin: 0; font-size: 13.5px; }
.feed li { padding: 7px 0; border-top: 1px solid var(--line); display: flex; justify-content: space-between; gap: 10px; }
.feed li span { color: var(--muted); }

/* ---------- CEA 상세 ---------- */
#tab-cea.active { display: grid; grid-template-columns: 430px 1fr; gap: 20px; align-items: start; }
.cea-form { background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); padding: 14px 18px 18px; display: flex; flex-direction: column; gap: 4px; position: sticky; top: 84px; max-height: calc(100vh - 100px); overflow-y: auto; }
.form-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; }
.form-head h2 { margin: 0; font-size: 17px; }
.form-tools { display: flex; gap: 6px; }
.reac-tools { display: flex; flex-direction: column; gap: 8px; }
/* 넓게: 계산 전 / 사용자가 펼쳤을 때 — 설정을 가로로 크게 */
#tab-cea.active.wide { display: flex; flex-direction: column; }
#tab-cea.wide .cea-form { position: static; max-height: none; overflow: visible; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); column-gap: 28px; padding: 18px 24px 22px; }
#tab-cea.wide .form-head, #tab-cea.wide #fsReac, #tab-cea.wide .cea-actions, #tab-cea.wide #ceaMeta { grid-column: 1 / -1; }
#tab-cea.wide .form-head h2 { font-size: 20px; }
#tab-cea.wide .fs-col { border-bottom: 0; }
#tab-cea.wide #fsReac { padding-bottom: 16px; }
#tab-cea.wide .reac-tools { flex-direction: row; align-items: flex-start; }
#tab-cea.wide .reac-tools > button { flex: none; }
#tab-cea.wide .reac { max-width: 1100px; font-size: 14px; }
#tab-cea.wide .reac input, #tab-cea.wide .reac select { font-size: 15px; padding: 8px 9px; }
#tab-cea.wide .reac td:nth-child(1) { width: 40%; }
#tab-cea.wide .cea-actions { justify-content: flex-start; padding-top: 8px; border-top: 1px solid var(--line); margin-top: 8px; }
#tab-cea.wide .cea-actions button { flex: none; min-width: 140px; }
#tab-cea.wide .cea-actions #ceaRun { min-width: 220px; font-size: 16px; }
.cea-form fieldset { border: 0; border-bottom: 1px solid var(--line); margin: 0; padding: 12px 0; display: flex; flex-direction: column; gap: 10px; }
.cea-form legend { font-weight: 700; font-size: 14px; padding: 0; float: left; width: 100%; margin-bottom: 2px; }
.cea-form legend em { font-style: normal; font-weight: 400; color: var(--muted); font-size: 12.5px; }
.cea-form legend + * { clear: both; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.checks { display: flex; flex-direction: column; gap: 6px; font-size: 14px; }
.checks input { accent-color: var(--lox); margin-right: 6px; }
.cea-presets { display: flex; flex-wrap: wrap; gap: 6px; }
.cea-presets button { font-size: 12.5px; padding: 4px 9px; background: var(--paper); color: var(--ink); border-color: var(--line); }
.cea-presets button:hover { border-color: var(--ink); }
button.small { font-size: 13px; padding: 5px 10px; align-self: flex-start; }
.reac { width: 100%; border-collapse: collapse; font-size: 13px; }
.reac th { text-align: left; font-weight: 500; color: var(--muted); padding: 0 4px 4px 0; font-size: 12px; }
.reac td { padding: 3px 4px 3px 0; vertical-align: top; }
.reac input, .reac select { width: 100%; border: 1px solid var(--line); border-radius: 5px; padding: 6px 7px; font-size: 13.5px; background: #fff; }
.reac td:nth-child(1) { width: 36%; }
.reac .meta-chip { display: inline-block; font-size: 11px; color: var(--muted); } .reac td:nth-child(2) { width: 21%; } .reac td:nth-child(3) { width: 16%; } .reac td:nth-child(4) { width: 22%; }
.reac input[type=number] { padding: 6px 5px; }
.reac .sp-ok { border-color: #8ac2a4; } .reac .sp-bad { border-color: var(--danger); background: #fff5f4; }
.reac small { display: block; color: var(--muted); font-size: 11px; margin-top: 2px; }
.reac small.err { color: var(--danger); }
.reac .del { background: none; border: 0; color: var(--muted); padding: 6px 4px; font-size: 16px; line-height: 1; }
.reac .del:hover { color: var(--danger); }

.cea-result { min-width: 0; display: flex; flex-direction: column; gap: 16px; }
.empty-state { background: var(--panel); border: 1px dashed var(--line); border-radius: var(--r); padding: 40px; color: var(--muted); text-align: center; }
.case-pick { display: flex; flex-wrap: wrap; gap: 6px; }
.case-pick button { font-size: 13px; padding: 5px 10px; background: var(--panel); color: var(--ink); border-color: var(--line); }
.case-pick button[aria-pressed="true"] { background: var(--ink); color: #fff; border-color: var(--ink); }
.case-pick button.err { color: var(--danger); }
.out-table { width: 100%; border-collapse: collapse; background: var(--panel); font-size: 13.5px; }
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--r); background: var(--panel); }
.out-table th, .out-table td { padding: 6px 12px; border-top: 1px solid var(--line); white-space: nowrap; }
.out-table thead th { border-top: 0; background: var(--paper); font-weight: 600; text-align: right; position: sticky; top: 0; }
.out-table thead th:first-child { text-align: left; }
.out-table tbody th { text-align: left; font-weight: 400; color: var(--muted); }
.out-table tbody th em { font-style: normal; font-size: 12px; margin-left: 4px; opacity: .8; }
.out-table td { text-align: right; font-weight: 600; }
.out-table tr.group th { color: var(--ink); font-weight: 700; background: var(--paper); font-size: 12.5px; padding: 5px 12px; }
.out-table td.minor { color: var(--muted); font-weight: 400; }
.out-table tr.hl td { color: var(--lox); }
.summary-table td.err { color: var(--danger); text-align: left; font-weight: 400; white-space: normal; }
.summary-table tbody tr { cursor: pointer; }
.summary-table tbody tr:hover td, .summary-table tbody tr:hover th { background: #f4f7fb; }
.summary-table tbody tr.sel td, .summary-table tbody tr.sel th { background: #e6edfb; }
.result-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; flex-wrap: wrap; }
.result-head h2 { margin: 0; font-size: 19px; }
.result-head p { margin: 0; color: var(--muted); font-size: 13px; }
.note { margin: 0; background: #fff8eb; border: 1px solid #f2d39b; color: #7a4a00; font-size: 13.5px; padding: 8px 12px; border-radius: 6px; }

/* ---------- 주기율표 · 저장 ---------- */
dialog.big-dialog { max-width: 1280px; width: calc(100% - 32px); max-height: calc(100vh - 32px); padding: 22px 24px; }
.dlg-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.dlg-head h2, .dlg-form h2 { margin: 0; font-size: 20px; }
.pt-tools { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin: 10px 0; }
.pt-sel { font-size: 13.5px; color: var(--muted); }
.pt-grid { display: grid; grid-template-columns: repeat(18, minmax(0, 1fr)); gap: 3px; }
.pt-grid .el { aspect-ratio: 1 / 0.92; border: 1px solid var(--line); border-radius: 5px; background: #fff; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 0; color: var(--ink); line-height: 1.05; cursor: pointer; font-weight: 600; }
.pt-grid .el small { font-size: 9.5px; font-weight: 400; color: var(--muted); }
.pt-grid .el b { font-size: clamp(11px, 1.25vw, 17px); }
.pt-grid .el:disabled { background: transparent; color: #b6bfca; border-style: dashed; cursor: default; }
.pt-grid .el:disabled small { color: #c8cfd8; }
.pt-grid .el:not(:disabled):hover { border-color: var(--ink); }
.pt-grid .el[aria-pressed="true"] { background: var(--ink); color: #fff; border-color: var(--ink); }
.pt-grid .el[aria-pressed="true"] small { color: #c9d3e0; }
.pt-grid .el.k-alkali:not(:disabled):not([aria-pressed="true"]) { background: #fdf1e7; }
.pt-grid .el.k-alkaline:not(:disabled):not([aria-pressed="true"]) { background: #fbf6e1; }
.pt-grid .el.k-transition:not(:disabled):not([aria-pressed="true"]) { background: #eef3fb; }
.pt-grid .el.k-post:not(:disabled):not([aria-pressed="true"]) { background: #f1eff8; }
.pt-grid .el.k-metalloid:not(:disabled):not([aria-pressed="true"]) { background: #eef6ef; }
.pt-grid .el.k-nonmetal:not(:disabled):not([aria-pressed="true"]) { background: #e6f2ee; }
.pt-grid .el.k-halogen:not(:disabled):not([aria-pressed="true"]) { background: #e9f3f7; }
.pt-grid .el.k-noble:not(:disabled):not([aria-pressed="true"]) { background: #f3f4f6; }
.pt-grid .el.k-actinide:not(:disabled):not([aria-pressed="true"]) { background: #f7eef1; }
.pt-grid .gap { grid-column: span 1; }
.pt-grid .label { font-size: 11px; color: var(--muted); display: flex; align-items: center; justify-content: center; text-align: center; border: 1px dashed var(--line); border-radius: 5px; }
.pt-filters { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin: 14px 0 8px; font-size: 13.5px; }
.pt-filters input#ptSearch { flex: 1; min-width: 220px; border: 1px solid var(--line); border-radius: 6px; padding: 8px 10px; }
.pt-filters select { border: 1px solid var(--line); border-radius: 6px; padding: 8px; }
.pt-filters input[type=checkbox] { accent-color: var(--lox); }
.pt-results { max-height: 38vh; overflow: auto; border: 1px solid var(--line); border-radius: var(--r); }
.pt-table { font-size: 13px; }
.pt-table td, .pt-table th { padding: 5px 10px; }
.pt-table tbody th { color: var(--ink); font-weight: 600; }
.pt-table td.desc { text-align: left; font-weight: 400; color: var(--muted); max-width: 320px; overflow: hidden; text-overflow: ellipsis; }
.pt-table td.btns { white-space: nowrap; }
.pt-table td.btns button { font-size: 12px; padding: 3px 8px; margin-left: 4px; }
.pt-table td.btns button.ox { background: var(--lox); border-color: var(--lox); }
.pt-table .tag { display: inline-block; font-size: 11px; padding: 1px 6px; border-radius: 9px; background: #e6edfb; color: var(--lox); font-weight: 500; margin-left: 6px; }
#ptMsg { min-height: 1.4em; margin-top: 8px; color: var(--ok); }
.dlg-form { display: flex; flex-direction: column; gap: 12px; min-width: min(460px, 80vw); }
.share { display: flex; gap: 8px; }
.share input { flex: 1; border: 1px solid var(--line); border-radius: 6px; padding: 8px; font-size: 13.5px; }
#loadSearch { width: 100%; border: 1px solid var(--line); border-radius: 6px; padding: 9px 11px; margin: 12px 0; font-size: 15px; }
.preset-list { list-style: none; padding: 0; margin: 0; max-height: 60vh; overflow: auto; border: 1px solid var(--line); border-radius: var(--r); }
.preset-list li { display: grid; grid-template-columns: 1fr auto; gap: 4px 16px; padding: 12px 16px; border-top: 1px solid var(--line); }
.preset-list li:first-child { border-top: 0; }
.preset-list b { font-size: 15.5px; }
.preset-list .meta { font-size: 12.5px; color: var(--muted); }
.preset-list .sum { grid-column: 1; font-size: 13px; color: var(--ink); }
.preset-list .btns { grid-row: 1 / span 3; grid-column: 2; display: flex; gap: 6px; align-items: center; }
.preset-list .btns button { font-size: 13px; padding: 5px 10px; }
.preset-list .empty { display: block; color: var(--muted); text-align: center; padding: 30px; }

.cea-recent { display: flex; flex-direction: column; gap: 12px; }
.recent-head { display: flex; justify-content: space-between; align-items: center; }
.recent-head h3 { margin: 0; font-size: 16px; }
.recent-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 12px; }
.recent-card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); padding: 14px 16px; display: flex; flex-direction: column; gap: 6px; text-align: left; color: var(--ink); font-weight: 400; cursor: pointer; }
.recent-card:hover { border-color: var(--ink); }
.recent-card b { font-size: 15px; }
.recent-card .meta { font-size: 12px; color: var(--muted); }
.recent-card .sum { font-size: 13px; line-height: 1.45; }
.recent-card .go { margin-top: auto; font-size: 12.5px; color: var(--lox); font-weight: 600; }
#tab-cea:not(.wide) .cea-recent { display: none; }

/* ---------- 넓은 화면: 설계 탭 3열 (여백 채우기) ---------- */
@media (min-width: 1680px) {
  #tab-design.active { grid-template-columns: 300px minmax(0, 1fr) 400px; }
  #tab-design .stage, #tab-design .sheet { display: contents; }
  #tab-design .inputs { grid-column: 1; grid-row: 1 / span 2; }
  #tab-design .viewport { grid-column: 2; grid-row: 1; height: min(62vh, 640px); }
  #tab-design .charts { grid-column: 2; grid-row: 2; display: grid; grid-template-columns: 1.35fr 1fr; align-items: start; }
  #tab-design .spec { grid-column: 3; grid-row: 1 / span 2; align-self: start; position: sticky; top: 84px; }
  .mon-tiles { grid-template-columns: repeat(8, 1fr); }
  .challenge { grid-template-columns: minmax(320px, 520px) 1fr; }
}

/* ---------- QR ---------- */
dialog { border: 0; border-radius: 12px; padding: 32px; max-width: 860px; width: calc(100% - 32px); }
dialog::backdrop { background: #152033cc; }
.qr-inner { display: grid; grid-template-columns: auto 1fr; gap: 32px; align-items: center; }
#qr img, #qr svg { width: 300px; height: 300px; display: block; image-rendering: pixelated; }
.qr-url { font-size: 30px; font-weight: 700; margin: 0 0 8px; letter-spacing: -0.02em; word-break: break-all; }

/* ---------- responsive ---------- */
@media (max-width: 1100px) {
  .sheet { grid-template-columns: 1fr; }
  .mon-charts { grid-template-columns: 1fr 1fr; }
  #tab-cea.active { grid-template-columns: 380px 1fr; }
  #tab-cea.wide .cea-form { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 860px) {
  .top { flex-wrap: wrap; gap: 10px; padding: 10px 16px; }
  .tabs { order: 3; margin: 0; width: 100%; overflow-x: auto; }
  .brand p { display: none; }
  .live button { display: none; }
  main { padding: 16px; }
  #tab-design.active { grid-template-columns: 1fr; }
  #tab-design .stage { display: contents; }
  #tab-design .viewport { order: -2; }
  #tab-design .inputs { order: -1; }
  .legend { display: none; }
  .big span { font-size: 52px; }
  .inputs { position: static; }
  .viewport { height: 46vh; min-height: 300px; }
  .challenge, .qr-inner, .mon-bottom { grid-template-columns: 1fr; }
  #tab-cea.active { grid-template-columns: 1fr; }
  #tab-cea.wide .cea-form { grid-template-columns: 1fr; padding: 14px 16px; }
  #tab-cea.wide .reac-tools { flex-direction: column; }
  .pt-grid { gap: 2px; }
  .pt-grid .el small { display: none; }
  .pt-grid .label { font-size: 8px; line-height: 1.1; }
  .pt-table td.desc { display: none; }
  .pt-table td, .pt-table th { padding: 5px 6px; }
  .preset-list li { grid-template-columns: 1fr; }
  .preset-list .btns { grid-row: auto; grid-column: 1; }
  .cea-form { position: static; max-height: none; }
  .mon-charts { grid-template-columns: 1fr; }
  .mon-tiles { grid-template-columns: repeat(2, 1fr); }
  .bar-row { grid-template-columns: 70px 1fr; }
  .bar-row span:last-child { grid-column: 1 / -1; text-align: left; }
  .analysis-head { flex-direction: column; align-items: flex-start; }
  .warn { max-width: calc(100% - 40px); }
  .drag-hint { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  .board li.new { animation: none; }
  .tile .meter i { transition: none; }
}
