/* Atorts autosync — 반응형 관리자 화면 */
:root {
  --bg: #f5f7fb; --bg-grad: radial-gradient(1200px 500px at 85% -10%, #e7eeff 0%, rgba(231,238,255,0) 60%);
  --panel: #ffffff; --panel-2: #f8fafd; --line: #e4e9f2; --line-2: #eef2f8;
  --text: #0f172a; --text-2: #334155; --muted: #64748b;
  --accent: #3b6cf6; --accent-2: #6d5cf6; --accent-soft: #eaf0ff; --accent-ink: #2a52c7;
  --ok: #12a150; --ok-soft: #e4f7ec; --test: #0891b2; --test-soft: #e2f5fa; --warn: #c27803; --warn-soft: #fff4dd;
  --danger: #dc2f45; --danger-soft: #fde9ec; --off: #94a3b8; --off-soft: #eff3f8;
  --heat0: #f4f7fc; --heat1: #e1eafe; --heat2: #c2d4fd; --heat3: #8eaefa; --heat4: #5585f4; --heat5: #2c5ce0;
  --shadow-sm: 0 1px 2px rgba(15,23,42,.05); --shadow: 0 1px 2px rgba(15,23,42,.04), 0 6px 22px rgba(15,23,42,.06);
  --radius: 14px; --radius-sm: 9px; --nav-h: 64px;
  --safe-b: env(safe-area-inset-bottom, 0px);
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0b1020; --bg-grad: radial-gradient(1200px 500px at 85% -10%, #17223f 0%, rgba(23,34,63,0) 60%);
    --panel: #121a2b; --panel-2: #0f1626; --line: #23304a; --line-2: #1b2539;
    --text: #e8edf7; --text-2: #c3cde0; --muted: #8b98b3;
    --accent: #7c9cff; --accent-2: #a594ff; --accent-soft: #1b2950; --accent-ink: #a9bcff;
    --ok: #3fd07f; --ok-soft: #12301f; --test: #3cc4e0; --test-soft: #0f2c35; --warn: #f2b84b; --warn-soft: #33270f;
    --danger: #ff6b7d; --danger-soft: #3a1820; --off: #64748b; --off-soft: #1a2335;
    --heat0: #141d30; --heat1: #18284d; --heat2: #1f3a78; --heat3: #2c55ad; --heat4: #4a78e8; --heat5: #8aa9ff;
    --shadow-sm: 0 1px 2px rgba(0,0,0,.35); --shadow: 0 1px 2px rgba(0,0,0,.3), 0 8px 26px rgba(0,0,0,.3);
  }
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }
html, body { margin: 0; }
body { background: var(--bg-grad), var(--bg); background-attachment: fixed; color: var(--text);
  font: 14px/1.5 "Pretendard Variable", Pretendard, "SUIT", "Malgun Gothic", "Apple SD Gothic Neo", system-ui, -apple-system, sans-serif;
  -webkit-font-smoothing: antialiased; letter-spacing: -.005em; }
button, input, select { font: inherit; color: inherit; }
button { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 38px; padding: 0 14px; border: 0; border-radius: var(--radius-sm);
  background: linear-gradient(180deg, var(--accent), var(--accent-ink)); color: #fff; font-weight: 600; cursor: pointer; white-space: nowrap;
  box-shadow: var(--shadow-sm); transition: transform .08s ease, filter .15s ease, background .15s ease; }
button:hover { filter: brightness(1.06); } button:active { transform: translateY(1px); }
button:disabled { opacity: .45; cursor: not-allowed; }
button.ghost { background: var(--panel); color: var(--text-2); border: 1px solid var(--line); box-shadow: none; font-weight: 500; }
button.ghost:hover { background: var(--panel-2); }
button.warn { background: linear-gradient(180deg, #e39b1f, var(--warn)); }
button.danger { background: linear-gradient(180deg, #ef5466, var(--danger)); }
.icon-btn { background: transparent; color: var(--text-2); border: 1px solid var(--line); box-shadow: none; padding: 0 10px; font-weight: 500; }
.icon-btn svg { width: 18px; height: 18px; fill: currentColor; }
input, select { min-height: 38px; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 0 11px; min-width: 0; transition: border-color .15s, box-shadow .15s; }
input[type=checkbox] { min-height: 0; width: 18px; height: 18px; accent-color: var(--accent); }
input:focus, select:focus, button:focus-visible { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
a { color: var(--accent); text-decoration: none; } a:hover { text-decoration: underline; }
.muted { color: var(--muted); } .hint { color: var(--muted); font-size: 12.5px; margin: 10px 0 0; } .mt { margin-top: 18px !important; }
.grow { flex: 1; }

/* 상단 */
.topbar { position: sticky; top: 0; z-index: 30; display: flex; align-items: center; gap: 14px; padding: 10px 20px; flex-wrap: wrap;
  background: color-mix(in srgb, var(--panel) 82%, transparent); backdrop-filter: saturate(160%) blur(12px); -webkit-backdrop-filter: saturate(160%) blur(12px);
  border-bottom: 1px solid var(--line); }
@supports not (background: color-mix(in srgb, red 50%, blue)) { .topbar { background: var(--panel); } }
.brand { display: flex; align-items: center; gap: 10px; }
.brand-text b { display: block; font-size: 15px; letter-spacing: -.01em; } .brand-text small { color: var(--muted); font-size: 12px; }
.logo { width: 34px; height: 34px; border-radius: 11px; display: grid; place-items: center; color: #fff; font-weight: 800; font-size: 17px;
  background: linear-gradient(135deg, var(--accent) 0%, var(--accent-2) 100%); box-shadow: 0 6px 16px rgba(59,108,246,.35); }
.chips { display: flex; gap: 6px; flex: 1; min-width: 0; overflow-x: auto; scrollbar-width: none; padding: 2px 0; }
.chips::-webkit-scrollbar { display: none; }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 4px 11px; border-radius: 999px; background: var(--off-soft); color: var(--text-2); font-size: 12.5px; font-weight: 500; white-space: nowrap; }
.chip::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: var(--off); }
.chip.ok { background: var(--ok-soft); color: var(--ok); } .chip.ok::before { background: var(--ok); }
.chip.bad { background: var(--danger-soft); color: var(--danger); } .chip.bad::before { background: var(--danger); }
.chip.test { background: var(--test-soft); color: var(--test); } .chip.test::before { background: var(--test); }
.chip.warn { background: var(--warn-soft); color: var(--warn); } .chip.warn::before { background: var(--warn); }
.usermenu { display: flex; align-items: center; gap: 8px; margin-left: auto; }
.userchip { display: flex; flex-direction: column; align-items: flex-end; line-height: 1.2; }
.userchip b { font-size: 13px; } .userchip small { color: var(--muted); font-size: 11.5px; }
form.inline { display: inline; margin: 0; }
.form-col { display: flex; flex-direction: column; gap: 12px; }
.form-col label:not(.check) { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--text-2); }
.form-col input, .form-col select { width: 100%; }
.viewer-note { margin-bottom: 14px; }
/* 조회 전용 계정: 변경 컨트롤 숨김·비활성(서버도 거부한다) */
.role-viewer .w, .role-viewer [data-save-set], .role-viewer [data-tcmd], .role-viewer #saveSite, .role-viewer #saveCycle, .role-viewer #saveNote,
.role-viewer #invOne, .role-viewer #planRun, .role-viewer [data-plan-from] { display: none !important; }
.role-viewer #modeBar, .role-viewer #scopeBar, .role-viewer #hookOk, .role-viewer input[data-set], .role-viewer #siteCode, .role-viewer #cycleMs, .role-viewer #noteIn { pointer-events: none; opacity: .55; }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.clones { display: flex; flex-wrap: wrap; gap: 6px; }
/* 로그인 */
.login-page { min-height: 100vh; }
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; }
.login-card { width: min(380px, 100%); background: var(--panel); border: 1px solid var(--line); border-radius: 18px; box-shadow: var(--shadow); padding: 26px 24px; display: flex; flex-direction: column; gap: 14px; }
.login-card .brand { margin-bottom: 6px; }
.login-card label { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--text-2); }
.login-card input { width: 100%; min-height: 44px; }
.login-card button[type=submit] { min-height: 46px; font-size: 15px; }
.login-card .note.bad { background: var(--danger-soft); color: var(--danger); }
.login-card code { font-size: 12px; }

/* 탭 */
.tabs { display: flex; gap: 4px; padding: 6px 20px 0; border-bottom: 1px solid var(--line); background: var(--panel); overflow-x: auto; }
.tabs button { background: transparent; color: var(--muted); box-shadow: none; border-radius: 10px 10px 0 0; padding: 0 14px; min-height: 42px; font-weight: 500; border-bottom: 2px solid transparent; }
.tabs button svg { width: 17px; height: 17px; fill: currentColor; }
.tabs button.active { color: var(--accent); border-bottom-color: var(--accent); font-weight: 650; }
.tabs button:hover { filter: none; background: var(--panel-2); }
main { padding: 18px 20px 40px; max-width: 1680px; margin: 0 auto; }
.tab { display: none; animation: fade .18s ease; } .tab.active { display: block; }
@keyframes fade { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }
.page-head { margin: 4px 0 14px; } .page-head h1 { font-size: 21px; margin: 0 0 3px; letter-spacing: -.02em; } .page-head p { margin: 0; color: var(--muted); }

.toolbar { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 12px; }
.toolbar .wide { min-width: 280px; flex: 1 1 320px; max-width: 560px; }
.seg { display: inline-flex; padding: 3px; background: var(--off-soft); border-radius: 11px; gap: 2px; }
.seg button { background: transparent; color: var(--muted); box-shadow: none; min-height: 32px; border-radius: 8px; padding: 0 12px; font-weight: 500; }
.seg button.on { background: var(--panel); color: var(--text); box-shadow: var(--shadow-sm); font-weight: 650; }
.seg button:hover { filter: none; }
.check { display: inline-flex; align-items: center; gap: 7px; color: var(--text-2); font-size: 13px; cursor: pointer; }
.legend { display: flex; gap: 12px; align-items: center; color: var(--muted); font-size: 12.5px; margin: 0 0 10px; flex-wrap: wrap; }
.dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-right: 5px; vertical-align: -1px; }
.dot.off { background: var(--off); } .dot.test { background: var(--test); } .dot.live { background: var(--ok); }
.badge { display: inline-flex; align-items: center; padding: 1px 8px; border-radius: 7px; font-size: 11.5px; font-weight: 600; border: 1px solid transparent; white-space: nowrap; }
.badge.auto { background: var(--accent-soft); color: var(--accent); } .badge.other { background: var(--off-soft); color: var(--muted); }
.badge.mode-off { background: var(--off-soft); color: var(--muted); } .badge.mode-test { background: var(--test-soft); color: var(--test); } .badge.mode-live { background: var(--ok-soft); color: var(--ok); }
.empty { padding: 48px 20px; text-align: center; color: var(--muted); background: var(--panel); border: 1px dashed var(--line); border-radius: var(--radius); }

/* 연동 지도: 행렬 */
.matrix-wrap { overflow: auto; max-height: calc(100vh - 290px); background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
table.matrix { border-collapse: separate; border-spacing: 0; font-size: 12.5px; }
table.matrix th, table.matrix td { border-bottom: 1px solid var(--line-2); border-right: 1px solid var(--line-2); padding: 0; }
table.matrix thead th { position: sticky; top: 0; background: var(--panel); z-index: 3; vertical-align: bottom; }
table.matrix thead th.colhead { height: 136px; width: 60px; min-width: 60px; cursor: pointer; }
table.matrix thead th.colhead:hover { background: var(--panel-2); }
.colhead .vert { writing-mode: vertical-rl; transform: rotate(180deg); padding: 10px 4px; white-space: nowrap; font-weight: 500; }
.colhead .vert small { color: var(--muted); }
table.matrix thead th.tot-h { cursor: default; padding: 10px 6px; font-size: 12.5px; color: var(--text-2); } table.matrix thead th.tot-h:hover { background: var(--panel); }
table.matrix tbody th { position: sticky; left: 0; background: var(--panel); z-index: 2; text-align: left; padding: 6px 12px; white-space: nowrap; font-weight: 500; cursor: pointer; }
table.matrix tbody th:hover { background: var(--panel-2); }
table.matrix thead th.corner { left: 0; z-index: 4; text-align: left; padding: 10px 12px; color: var(--muted); font-weight: 500; }
.rowhead { display: flex; align-items: center; gap: 8px; } .rowhead small { color: var(--muted); }
td.cell { width: 60px; min-width: 60px; height: 34px; text-align: center; cursor: pointer; font-variant-numeric: tabular-nums; position: relative; transition: box-shadow .12s; }
td.cell:hover { box-shadow: inset 0 0 0 2px var(--accent); }
td.cell.h0 { background: var(--heat0); color: transparent; cursor: default; } td.cell.h0:hover { box-shadow: none; }
td.cell.h1 { background: var(--heat1); } td.cell.h2 { background: var(--heat2); }
td.cell.h3 { background: var(--heat3); color: #fff; } td.cell.h4 { background: var(--heat4); color: #fff; } td.cell.h5 { background: var(--heat5); color: #fff; }
td.cell.tot { background: var(--panel-2); color: var(--text); font-weight: 700; cursor: default; }
td.cell .rt { position: absolute; top: 3px; right: 4px; width: 7px; height: 7px; border-radius: 50%; box-shadow: 0 0 0 2px var(--panel); }
td.cell .rt.ok { background: var(--ok); } td.cell .rt.err { background: var(--danger); } td.cell .rt.test { background: var(--test); }
tr.total th, tr.total td { font-weight: 700; background: var(--panel-2) !important; color: var(--text) !important; }

/* 연동 지도: 카드 */
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 12px; }
.mcard { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.mcard-head { display: flex; align-items: center; gap: 10px; padding: 12px 14px; cursor: pointer; border-bottom: 1px solid var(--line-2); }
.mcard-head:hover { background: var(--panel-2); }
.mcard-head .t { display: flex; flex-direction: column; min-width: 0; } .mcard-head .t b { font-size: 14.5px; } .mcard-head .t small { color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mcard-head .total { margin-left: auto; text-align: right; font-variant-numeric: tabular-nums; } .mcard-head .total b { font-size: 16px; display: block; } .mcard-head .total small { color: var(--muted); }
.links { display: flex; flex-direction: column; }
.link { display: grid; grid-template-columns: 1fr auto; gap: 4px 10px; align-items: center; padding: 9px 14px; cursor: pointer; border-bottom: 1px solid var(--line-2); }
.link:last-child { border-bottom: 0; } .link:hover { background: var(--panel-2); }
.link .name { display: flex; align-items: center; gap: 7px; font-weight: 550; min-width: 0; }
.link .name span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.link .v { font-variant-numeric: tabular-nums; font-weight: 650; }
.link .meter { grid-column: 1 / -1; height: 5px; border-radius: 3px; background: var(--off-soft); overflow: hidden; }
.link .meter i { display: block; height: 100%; border-radius: 3px; background: linear-gradient(90deg, var(--accent), var(--accent-2)); }
.link .sports { grid-column: 1 / -1; color: var(--muted); font-size: 12px; }

/* 카드·목록 */
.stack { display: flex; flex-direction: column; gap: 14px; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px 18px; }
.card.flat { box-shadow: none; background: var(--panel-2); }
.card h3 { margin: 0 0 12px; font-size: 15.5px; letter-spacing: -.01em; } .card h3 small { font-weight: 500; }
.card h4 { margin: 16px 0 8px; font-size: 13px; color: var(--muted); font-weight: 600; text-transform: none; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-bottom: 14px; }
.kv { display: grid; grid-template-columns: 130px 1fr; gap: 10px 16px; align-items: center; }
.kv > label { color: var(--muted); font-size: 13px; }
.btnrow { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; } .btnrow.right { justify-content: flex-end; }
.inline { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.modebar { display: inline-flex; padding: 3px; gap: 3px; background: var(--off-soft); border-radius: 12px; flex-wrap: wrap; }
.modebar button { background: transparent; color: var(--muted); box-shadow: none; min-height: 36px; border-radius: 9px; font-weight: 600; padding: 0 16px; }
.modebar button:hover { filter: none; background: var(--panel); }
.modebar button.on.off { background: var(--off); color: #fff; } .modebar button.on.test { background: var(--test); color: #fff; } .modebar button.on.live { background: var(--ok); color: #fff; }
.note { padding: 11px 13px; border-radius: 10px; background: var(--warn-soft); color: var(--warn); font-size: 13px; line-height: 1.55; }
.note.info { background: var(--accent-soft); color: var(--accent-ink); }
.src-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.src-head .stat { margin-left: auto; color: var(--text-2); font-variant-numeric: tabular-nums; }
details { margin-top: 8px; } summary { cursor: pointer; color: var(--muted); font-size: 13px; padding: 6px 0; }

.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; border-radius: 10px; }
table.list { width: 100%; border-collapse: collapse; font-size: 13px; }
table.list th { text-align: left; color: var(--muted); font-weight: 600; font-size: 12px; border-bottom: 1px solid var(--line); padding: 8px 10px; white-space: nowrap; background: var(--panel-2); }
table.list td { border-bottom: 1px solid var(--line-2); padding: 8px 10px; vertical-align: top; }
table.list tr:hover td { background: var(--panel-2); }
table.list td.num { text-align: right; font-variant-numeric: tabular-nums; }
table.list td { word-break: keep-all; } table.list td.nw { white-space: nowrap; }
.drawer table.list th, .drawer table.list td { padding: 8px 6px; } .drawer .bar { min-width: 40px; }
table.list tr.hl td { background: var(--warn-soft); }
.sport { display: inline-flex; align-items: center; gap: 5px; margin: 2px 5px 2px 0; padding: 2px 9px; border-radius: 999px; background: var(--accent-soft); color: var(--accent-ink); font-size: 12px; }
.sport b { font-weight: 700; }
.bar { height: 6px; border-radius: 3px; background: var(--off-soft); overflow: hidden; min-width: 70px; }
.bar > i { display: block; height: 100%; border-radius: 3px; background: linear-gradient(90deg, var(--accent), var(--accent-2)); }
code.rule { display: block; white-space: pre-wrap; word-break: break-all; background: var(--panel-2); border: 1px solid var(--line); border-radius: 9px; padding: 8px 10px; font: 12px/1.55 "JetBrains Mono", Consolas, "D2Coding", monospace; margin: 5px 0; color: var(--text-2); }
.ruleflag { display: inline-block; font: 11.5px "JetBrains Mono", Consolas, monospace; background: var(--off-soft); border-radius: 6px; padding: 2px 7px; margin: 2px 5px 2px 0; color: var(--text-2); }
.diffcell { font-variant-numeric: tabular-nums; white-space: nowrap; } .diffcell .chg { color: var(--danger); font-weight: 700; }
.state { font-size: 11.5px; font-weight: 600; padding: 2px 8px; border-radius: 7px; white-space: nowrap; }
.state.same { background: var(--ok-soft); color: var(--ok); } .state.diff { background: var(--danger-soft); color: var(--danger); }
.state.legacy_pending { background: var(--warn-soft); color: var(--warn); } .state.error, .state.policy_skipped { background: var(--off-soft); color: var(--muted); }
.statgrid { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 10px; }
.stat-tile { background: var(--panel-2); border: 1px solid var(--line-2); border-radius: 12px; padding: 10px 12px; }
.stat-tile small { color: var(--muted); display: block; } .stat-tile b { font-size: 19px; font-variant-numeric: tabular-nums; }

/* 패널·모달·토스트 */
.scrim { position: fixed; inset: 0; background: rgba(8,12,24,.38); z-index: 39; backdrop-filter: blur(2px); }
.drawer { position: fixed; top: 0; right: 0; width: min(640px, 100vw); height: 100%; background: var(--panel); border-left: 1px solid var(--line);
  box-shadow: -10px 0 40px rgba(0,0,0,.18); z-index: 40; display: flex; flex-direction: column; animation: slide .2s ease; }
@keyframes slide { from { transform: translateX(30px); opacity: 0; } to { transform: none; opacity: 1; } }
.drawer-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 14px 18px; border-bottom: 1px solid var(--line); }
.drawer-head b { font-size: 15px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.drawer-body { padding: 16px 18px calc(24px + var(--safe-b)); overflow: auto; display: flex; flex-direction: column; gap: 14px; }
.modal { position: fixed; inset: 0; background: rgba(8,12,24,.45); display: grid; place-items: center; z-index: 60; padding: 16px; backdrop-filter: blur(3px); }
.modal-box { background: var(--panel); border: 1px solid var(--line); border-radius: 16px; padding: 20px; width: min(460px, 100%); box-shadow: var(--shadow); display: flex; flex-direction: column; gap: 16px; animation: fade .15s ease; }
.toast { position: fixed; bottom: calc(22px + var(--safe-b)); left: 50%; transform: translateX(-50%); background: var(--text); color: var(--bg); padding: 10px 18px; border-radius: 12px; z-index: 70; max-width: 92vw; box-shadow: var(--shadow); font-weight: 500; }
.toast.err { background: var(--danger); color: #fff; }

/* 태블릿 */
@media (max-width: 1080px) {
  .grid2 { grid-template-columns: 1fr; }
  .kv { grid-template-columns: 110px 1fr; }
}

/* 모바일 */
@media (max-width: 760px) {
  body { font-size: 14.5px; }
  .topbar { padding: 8px 12px; gap: 8px; top: 0; }
  .brand-text small { display: none; }
  .chips { order: 3; flex-basis: 100%; }
  .userchip small { display: none; }
  .usermenu .ghost { padding: 0 10px; }
  .tabs { position: fixed; top: auto; bottom: 0; left: 0; right: 0; z-index: 35; padding: 4px 4px calc(4px + var(--safe-b)); border-top: 1px solid var(--line); border-bottom: 0;
    justify-content: space-around; gap: 0; background: color-mix(in srgb, var(--panel) 92%, transparent); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); }
  .tabs button { flex: 1; flex-direction: column; gap: 2px; min-height: 52px; padding: 4px 2px; border-radius: 12px; border-bottom: 0; font-size: 11px; }
  .tabs button svg { width: 21px; height: 21px; }
  .tabs button.active { background: var(--accent-soft); }
  main { padding: 12px 12px calc(var(--nav-h) + 30px + var(--safe-b)); }
  .page-head h1 { font-size: 19px; } .page-head p { font-size: 13px; }
  .toolbar > * { flex: 1 1 auto; }
  .toolbar .wide { min-width: 0; max-width: none; flex-basis: 100%; }
  .seg { flex: 1 1 100%; } .seg button { flex: 1; }
  .cards { grid-template-columns: 1fr; }
  .kv { grid-template-columns: 1fr; gap: 4px; } .kv > label { margin-top: 8px; }
  .modebar { width: 100%; } .modebar button { flex: 1; padding: 0 8px; }
  .card { padding: 14px; border-radius: 13px; }
  .btnrow > button { flex: 1 1 auto; }
  .drawer { width: 100vw; border-left: 0; border-radius: 0; animation: up .2s ease; }
  @keyframes up { from { transform: translateY(24px); opacity: 0; } to { transform: none; opacity: 1; } }
  .src-head .stat { margin-left: 0; width: 100%; }
  /* 목록 표 → 카드 */
  table.list.stack-sm thead { display: none; }
  table.list.stack-sm, table.list.stack-sm tbody, table.list.stack-sm tr, table.list.stack-sm td { display: block; width: 100%; }
  table.list.stack-sm tr { border: 1px solid var(--line); border-radius: 12px; margin-bottom: 10px; padding: 6px 2px; background: var(--panel); }
  table.list.stack-sm tr:hover td { background: transparent; }
  table.list.stack-sm td { display: flex; justify-content: space-between; gap: 12px; border-bottom: 1px dashed var(--line-2); padding: 7px 12px; text-align: right; }
  table.list.stack-sm td:last-child { border-bottom: 0; }
  table.list.stack-sm td::before { content: attr(data-label); color: var(--muted); font-size: 12px; text-align: left; flex: 0 0 auto; max-width: 42%; }
  table.list.stack-sm td.num { text-align: right; }
  table.list.stack-sm td > * { max-width: 100%; }
  table.list.stack-sm td code.rule { text-align: left; }
  .matrix-wrap { max-height: calc(100vh - 330px); }
}
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }
