:root {
  --bg: #f4f5f7;
  --panel: #ffffff;
  --panel-2: #f8f9fb;
  --line: #e3e6eb;
  --line-strong: #cfd4dc;
  --text: #1b1f27;
  --muted: #68707d;
  --accent: #1f4fd1;
  --accent-soft: #e8eefc;
  --ai: #6b45e0;
  --ai-soft: #f0ebff;
  --danger: #c62828;
  --ok: #1b7f4b;
  --warn-bg: #fff6e0;
  --add-bg: #e6f6ec;
  --add-fg: #145c34;
  --del-bg: #fdecec;
  --del-fg: #9b1c1c;
  --mark: #fff1a8;
  --corr: #1f4e9a;
  --radius: 10px;
  --shadow: 0 6px 24px rgba(16, 24, 40, 0.12);
  --font: 'Pretendard', 'Apple SD Gothic Neo', 'Malgun Gothic', '맑은 고딕', system-ui, sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #14161a;
    --panel: #1c1f25;
    --panel-2: #22262d;
    --line: #2f343d;
    --line-strong: #3d434e;
    --text: #e8eaee;
    --muted: #9aa2ae;
    --accent: #6f95ff;
    --accent-soft: #1f2a45;
    --ai: #a78bff;
    --ai-soft: #2a2343;
    --danger: #ff7a7a;
    --ok: #5fd39a;
    --warn-bg: #3a3218;
    --add-bg: #173323;
    --add-fg: #8fe0b1;
    --del-bg: #3a1c1c;
    --del-fg: #ffadad;
    --mark: #5b4f12;
    --corr: #8fb3ff;
    --shadow: 0 6px 24px rgba(0, 0, 0, 0.5);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { background: var(--bg); color: var(--text); font: 14px/1.55 var(--font); -webkit-font-smoothing: antialiased; }
button, input, select, textarea { font: inherit; color: inherit; }
h1, h2, h3 { margin: 0; line-height: 1.3; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.error { color: var(--danger); }
.center { text-align: center; }
.pad { padding: 8px 12px; }
.spacer { flex: 1; }
.row { display: flex; align-items: center; }
.gap { gap: 8px; }
.wrap { flex-wrap: wrap; }
.stack { display: flex; flex-direction: column; gap: 14px; }

/* 버튼 */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: 34px; padding: 0 14px; border-radius: 8px; border: 1px solid var(--line-strong); background: var(--panel); cursor: pointer; text-decoration: none; white-space: nowrap; transition: background .15s, border-color .15s; }
.btn:hover { background: var(--panel-2); }
.btn:disabled { opacity: .55; cursor: default; }
.btn.small { height: 30px; padding: 0 10px; font-size: 13px; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { filter: brightness(1.06); }
.btn.ai { color: var(--ai); border-color: color-mix(in srgb, var(--ai) 40%, transparent); background: var(--ai-soft); }
.btn.primary.ai { background: var(--ai); border-color: var(--ai); color: #fff; }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.ghost:hover { background: var(--panel-2); }
.btn.danger, .btn.ghost.danger { color: var(--danger); }
.btn.link { border: 0; background: none; color: var(--accent); font-weight: 600; cursor: pointer; padding: 0 4px; }
.btn.block { width: 100%; }
.icon-btn { width: 32px; height: 32px; border-radius: 8px; border: 0; background: transparent; cursor: pointer; color: var(--muted); display: inline-grid; place-items: center; flex: none; }
.icon-btn:hover { background: var(--panel-2); color: var(--text); }
.icon-btn:disabled { opacity: .3; cursor: default; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* 입력 */
.input { width: 100%; min-height: 34px; padding: 6px 10px; border: 1px solid var(--line-strong); border-radius: 8px; background: var(--panel); }
.input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
textarea.input { resize: vertical; line-height: 1.6; }
.input.narrow { width: 90px; }
select.input { width: auto; }
.field { display: flex; flex-direction: column; gap: 4px; margin: 10px 0; }
.field > span { font-weight: 600; font-size: 13px; }
.toggle { display: inline-flex; align-items: center; gap: 4px; cursor: pointer; color: var(--muted); }

/* 상단 바 */
#app { height: 100%; display: flex; flex-direction: column; }
.topbar { display: flex; align-items: center; gap: 8px; padding: 8px 12px; background: var(--panel); border-bottom: 1px solid var(--line); padding-top: max(8px, env(safe-area-inset-top)); }
.brand { display: flex; align-items: center; gap: 8px; min-width: 0; font-weight: 700; }
.brand #doc-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 36vw; }
.logo { width: 28px; height: 28px; border-radius: 8px; background: var(--accent); color: #fff; display: inline-grid; place-items: center; font-size: 14px; font-weight: 800; flex: none; }
.logo.big { width: 52px; height: 52px; font-size: 24px; border-radius: 14px; margin: 0 auto 8px; }
.save-status { font-size: 12px; color: var(--muted); white-space: nowrap; }
.save-status.ok { color: var(--ok); }
.save-status.error { color: var(--danger); }

/* 3단 화면 */
.panes { flex: 1; min-height: 0; display: grid; grid-template-columns: minmax(300px, 1fr) minmax(360px, 1.15fr) minmax(360px, 1.1fr); gap: 1px; background: var(--line); }
.pane { display: flex; flex-direction: column; min-height: 0; min-width: 0; background: var(--bg); }
.pane-head { display: flex; align-items: center; gap: 6px; padding: 8px 14px; background: var(--panel); border-bottom: 1px solid var(--line); min-height: 46px; }
.pane-head h2 { font-size: 14px; }
.pane-body { flex: 1; min-height: 0; overflow: auto; padding: 14px; }
.tabbar { display: none; }

@media (max-width: 1099px) {
  .panes { grid-template-columns: 1fr; }
  .pane { display: none; }
  body[data-tab="transcript"] .pane-transcript, body[data-tab="editor"] .pane-editor, body[data-tab="preview"] .pane-preview { display: flex; }
  .tabbar { display: flex; background: var(--panel); border-bottom: 1px solid var(--line); }
  .tabbar button { flex: 1; height: 42px; border: 0; background: none; cursor: pointer; color: var(--muted); font-weight: 600; border-bottom: 2px solid transparent; }
  .tabbar button[aria-selected="true"] { color: var(--accent); border-bottom-color: var(--accent); }
  .pane-head { display: none; }
  .pane-preview .pane-head { display: flex; }
}
@media (max-width: 640px) {
  .topbar { flex-wrap: wrap; }
  .topbar .spacer { flex-basis: 100%; height: 0; }
  .topbar .hide-sm { display: none; }
  .topbar .btn.small { padding: 0 9px; }
  .brand #doc-name { max-width: 55vw; }
  .pane-body { padding: 10px; }
}

/* 카드 (작성) */
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); margin-bottom: 12px; }
.card-head { display: flex; align-items: center; justify-content: space-between; padding: 10px 14px 0; }
.card-head h3 { font-size: 13px; color: var(--muted); font-weight: 700; letter-spacing: .02em; }
.card-body { padding: 8px 14px 14px; }
.att-list, .agenda-list, .act-list { display: flex; flex-direction: column; gap: 8px; margin-bottom: 8px; }
.att-group { display: grid; grid-template-columns: 150px 1fr auto 32px; gap: 6px; align-items: start; }
.att-names { min-height: 34px; }
.att-others { display: inline-flex; align-items: center; gap: 4px; color: var(--muted); font-size: 13px; white-space: nowrap; }
.att-others .input { width: 58px; }
.att-count { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 16px; margin-top: 10px; padding: 8px 10px; background: var(--panel-2); border-radius: 8px; font-size: 13px; }
.att-count select.input { min-height: 30px; padding: 2px 6px; font-size: 13px; }
.act-row textarea.input { min-height: 34px; }
.act-row.no-note { grid-template-areas: "no task owner due del"; }
.act-opts { margin-bottom: 8px; }
.agenda { border: 1px solid var(--line); border-radius: 8px; padding: 8px; background: var(--panel-2); }
.agenda-head { display: flex; align-items: center; gap: 4px; margin-bottom: 6px; }
.agenda-no { font-weight: 700; width: 22px; text-align: right; flex: none; }
.agenda .title { font-weight: 600; }
.agenda .points { min-height: 70px; }
.act-row { display: grid; grid-template-columns: 22px 1fr 100px 100px 32px; grid-template-areas: "no task owner due del" "no note note note del"; gap: 6px; align-items: start; padding-bottom: 8px; border-bottom: 1px dashed var(--line); }
.act-no { grid-area: no; font-weight: 700; padding-top: 7px; text-align: right; }
.act-task { grid-area: task; }
.act-owner { grid-area: owner; }
.act-due { grid-area: due; }
.act-note { grid-area: note; }
.act-row .icon-btn { grid-area: del; }
@media (max-width: 640px) {
  .act-row { grid-template-columns: 22px 1fr 1fr 32px; grid-template-areas: "no task task del" "no owner due del" "no note note del"; }
  .act-row.no-note { grid-template-areas: "no task task del" "no owner due del"; }
  .att-group { grid-template-columns: 1fr auto 32px; grid-template-areas: "co others del" "names names names"; }
  .att-company { grid-area: co; } .att-names { grid-area: names; } .att-others { grid-area: others; } .att-group .icon-btn { grid-area: del; }
}

/* AI 패널 */
.ai-panel { background: var(--panel); border: 1px solid color-mix(in srgb, var(--ai) 35%, var(--line)); border-radius: var(--radius); padding: 12px 14px; margin-bottom: 14px; box-shadow: 0 1px 0 var(--ai-soft); }
.ai-row { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.ai-label { font-weight: 700; color: var(--ai); }
.preset { height: 30px; min-height: 30px; padding: 2px 8px; font-size: 13px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 8px; }
.chip { height: 28px; padding: 0 10px; border-radius: 999px; border: 1px solid var(--line-strong); background: var(--panel); cursor: pointer; font-size: 13px; }
.chip.on { background: var(--ai); border-color: var(--ai); color: #fff; }
.ai-input { display: flex; gap: 8px; align-items: stretch; }
.ai-input textarea { min-height: 54px; }
.ai-input .btn { height: auto; min-width: 74px; }
.ai-status { margin-top: 6px; min-height: 18px; }

/* 원문 */
.tr-meta { display: flex; align-items: center; gap: 4px; flex-wrap: wrap; font-size: 12px; color: var(--muted); margin-bottom: 10px; }
.tr-tools { display: flex; gap: 8px; align-items: center; position: sticky; top: -14px; background: var(--bg); padding: 8px 0; z-index: 2; }
.tr-audio { width: 100%; margin: 4px 0 6px; }
.seg-list { display: flex; flex-direction: column; gap: 2px; }
.seg { padding: 8px 10px; border-radius: 8px; }
.seg:hover { background: var(--panel); }
.seg.playing { background: var(--accent-soft); }
.seg-head { display: flex; align-items: center; gap: 8px; margin-bottom: 2px; }
.spk-chip { --c: #2563eb; border: 0; background: color-mix(in srgb, var(--c) 14%, transparent); color: var(--c); font-weight: 700; font-size: 12px; padding: 1px 8px; border-radius: 6px; cursor: pointer; }
@media (prefers-color-scheme: dark) { .spk-chip { color: color-mix(in srgb, var(--c) 60%, white); } }
.seg-time { border: 0; background: none; color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; cursor: pointer; padding: 0; }
.seg-time:disabled { cursor: default; }
.seg-text { white-space: pre-wrap; word-break: keep-all; overflow-wrap: anywhere; }
.seg-text mark { background: var(--mark); color: inherit; }
.spk-panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 8px 12px; margin-bottom: 10px; }
.spk-panel > summary { cursor: pointer; font-weight: 700; padding: 4px 0; }
.spk-rows { display: flex; flex-direction: column; gap: 8px; margin-top: 10px; }
.spk-row { border-top: 1px solid var(--line); padding-top: 8px; }
.spk-main { display: grid; grid-template-columns: auto auto 1fr auto auto; align-items: center; gap: 4px 6px; }
.spk-main .input { min-height: 30px; padding: 3px 8px; }
.spk-main input.input { grid-column: 1 / -1; order: 5; }
.spk-main .merge { width: 96px; font-size: 12px; justify-self: end; }
.spk-label { font-weight: 600; white-space: nowrap; font-size: 13px; }
.spk-main .muted { white-space: nowrap; }
.dot { width: 10px; height: 10px; border-radius: 50%; flex: none; display: inline-block; background: var(--c, #999); }
.spk-sugg { margin: 6px 0 0 16px; padding: 6px 10px; border-radius: 8px; background: var(--ai-soft); font-size: 13px; display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.spk-sugg details { flex-basis: 100%; }
.spk-sugg summary { cursor: pointer; font-size: 12px; color: var(--ai); }
.spk-sugg.conf-low { background: var(--panel-2); }
.popover { position: fixed; z-index: 50; background: var(--panel); border: 1px solid var(--line); border-radius: 10px; box-shadow: var(--shadow); padding: 4px; min-width: 180px; max-height: 60vh; overflow: auto; }
.menu-item { display: flex; align-items: center; gap: 8px; width: 100%; text-align: left; border: 0; background: none; padding: 7px 10px; border-radius: 6px; cursor: pointer; }
.menu-item:hover, .menu-item.active { background: var(--panel-2); }
.menu-item .dot { background: var(--c); }

.empty { text-align: center; padding: 48px 16px; }
.empty-icon { font-size: 36px; margin-bottom: 8px; }
.empty h3 { margin-bottom: 6px; }
.empty .btn { margin-top: 12px; }
.choice { border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; }
.choice h3 { font-size: 15px; margin-bottom: 4px; }
.choice .btn { margin-top: 6px; }
.job-card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; margin-bottom: 12px; display: flex; flex-direction: column; gap: 8px; }
.progress { height: 6px; background: var(--panel-2); border-radius: 99px; overflow: hidden; }
.progress > div { height: 100%; background: var(--accent); transition: width .4s; }
.spinner { width: 16px; height: 16px; border: 2px solid var(--accent-soft); border-top-color: var(--accent); border-radius: 50%; animation: spin 0.9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.notice { padding: 10px 12px; border-radius: 8px; background: var(--accent-soft); }
.notice.error { background: var(--del-bg); color: var(--del-fg); margin-bottom: 10px; }
.notice.warn { background: var(--warn-bg); }
.badge { font-size: 11px; background: var(--accent-soft); color: var(--accent); padding: 1px 6px; border-radius: 4px; }

/* 미리보기 (종이) */
.preview-wrap { background: color-mix(in srgb, var(--bg) 85%, #888); }
.pv-page { background: #fff; color: #111; width: 100%; max-width: 794px; margin: 0 auto; padding: clamp(20px, 7%, 56px) clamp(14px, 6.5%, 52px); box-shadow: 0 2px 12px rgba(0,0,0,.18); font-family: 'Malgun Gothic', '맑은 고딕', 'Apple SD Gothic Neo', sans-serif; font-size: 13.3px; line-height: 1.55; }
@media (max-width: 640px) { .pv-page { font-size: 12.5px; } }
.pv-title { text-align: center; font-size: 29px; font-weight: 700; margin-bottom: 26px; letter-spacing: .3em; padding-left: .3em; }
.pv-table { width: 100%; border-collapse: collapse; table-layout: fixed; }
.pv-table + .pv-table { margin-top: -1px; }
.pv-table th, .pv-table td { border: 1px solid #808080; padding: 6px 9px; vertical-align: middle; word-break: keep-all; overflow-wrap: anywhere; white-space: pre-line; }
.pv-table th { background: #dce6f1; font-weight: 700; text-align: center; }
.pv-table td.c { text-align: center; }
.pv-content { vertical-align: top !important; }
.pv-agenda + .pv-agenda { margin-top: 10px; }
.pv-agenda-title { font-weight: 700; margin-bottom: 2px; }
.pv-pt { display: flex; gap: 6px; }
.pv-l1 { padding-left: 12px; }
.pv-l2 { padding-left: 34px; }
.pv-bullet { flex: none; }
.pv-appendix { margin-top: 26px; }
.pv-appendix-title { font-weight: 700; font-size: 12px; margin-bottom: 6px; }
.pv-small th, .pv-small td { font-size: 12px; }
mark.corr { background: transparent; color: var(--corr); text-decoration: underline dotted; text-underline-offset: 3px; cursor: help; }
.pv-page mark.corr { color: #1f4e9a; }

/* 비교 화면 */
.diff-block { border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.diff-head { display: flex; align-items: center; gap: 8px; padding: 8px 12px; background: var(--panel-2); border-bottom: 1px solid var(--line); cursor: pointer; }
.diff { font-size: 13px; max-height: 340px; overflow: auto; padding: 6px 0; }
.dl { display: flex; gap: 8px; padding: 1px 12px; white-space: pre-wrap; word-break: keep-all; overflow-wrap: anywhere; }
.dl .sign { width: 10px; flex: none; color: var(--muted); }
.dl.add { background: var(--add-bg); color: var(--add-fg); }
.dl.del { background: var(--del-bg); color: var(--del-fg); text-decoration: line-through; text-decoration-thickness: 1px; }
.corr-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.corr-table th, .corr-table td { border-bottom: 1px solid var(--line); padding: 6px 8px; text-align: left; vertical-align: top; }
.corr-table th { color: var(--muted); font-weight: 600; font-size: 12px; }

/* 모달 */
.overlay { position: fixed; inset: 0; background: rgba(10, 14, 22, .45); display: grid; place-items: center; z-index: 40; padding: 16px; }
.dialog { background: var(--panel); border-radius: 14px; box-shadow: var(--shadow); width: min(520px, 100%); max-height: calc(100vh - 32px); display: flex; flex-direction: column; }
.dialog.wide { width: min(860px, 100%); }
.dialog-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 18px; border-bottom: 1px solid var(--line); }
.dialog-head h2 { font-size: 16px; }
.dialog-body { padding: 16px 18px; overflow: auto; }
.dialog-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 12px 18px; border-top: 1px solid var(--line); }
.settings section { margin-bottom: 22px; }
.settings h3 { font-size: 15px; margin-bottom: 4px; }
.settings details { border: 1px solid var(--line); border-radius: 8px; padding: 6px 12px; margin: 8px 0; }
.settings summary { cursor: pointer; font-weight: 600; padding: 4px 0; }
.task-row { border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; margin: 8px 0; display: flex; flex-direction: column; gap: 8px; }
.task-label { display: flex; flex-direction: column; }
.task-row .input:not(select) { flex: 1; min-width: 180px; }

/* 목록 서랍 */
.drawer { position: fixed; top: 0; bottom: 0; left: 0; width: min(340px, 88vw); background: var(--panel); border-right: 1px solid var(--line); transform: translateX(-102%); transition: transform .2s; z-index: 30; display: flex; flex-direction: column; padding: 12px; gap: 10px; padding-top: max(12px, env(safe-area-inset-top)); }
.drawer-open .drawer { transform: none; box-shadow: var(--shadow); }
.drawer-head { display: flex; align-items: center; }
.drawer-head h2 { font-size: 16px; }
#meeting-list { flex: 1; overflow: auto; display: flex; flex-direction: column; gap: 4px; }
.drawer-foot { border-top: 1px solid var(--line); padding-top: 8px; }
.mt-item { display: flex; align-items: center; border-radius: 8px; }
.mt-item.active { background: var(--accent-soft); }
.mt-item:hover { background: var(--panel-2); }
.mt-open { flex: 1; min-width: 0; text-align: left; border: 0; background: none; cursor: pointer; padding: 8px 10px; display: flex; flex-direction: column; }
.mt-open strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.scrim { position: fixed; inset: 0; background: rgba(0,0,0,.3); z-index: 25; display: none; }
.drawer-open .scrim { display: block; }

/* 로그인 */
.login { flex: 1; display: grid; place-items: center; padding: 16px; }
.login-box { width: min(340px, 100%); background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 28px; display: flex; flex-direction: column; gap: 12px; text-align: center; }
.login-box h1 { font-size: 20px; margin-bottom: 6px; }

/* 알림 */
.toast { position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 20px); background: #222831; color: #fff; padding: 10px 16px; border-radius: 10px; box-shadow: var(--shadow); opacity: 0; pointer-events: none; transition: all .2s; z-index: 60; display: flex; align-items: center; gap: 10px; max-width: calc(100vw - 32px); font-size: 13px; padding-bottom: calc(10px + env(safe-area-inset-bottom) * 0); }
.toast.show { opacity: 1; transform: translate(-50%, 0); pointer-events: auto; }
.toast.error { background: #8e1e1e; }
.toast.success { background: #145c34; }
.toast .btn.link { color: #9cc1ff; }

/* 인쇄: 미리보기 종이만 출력 */
@media print {
  @page { size: A4; margin: 20mm; }
  body { background: #fff; }
  .topbar, .tabbar, .pane-transcript, .pane-editor, .pane-head, .drawer, .scrim, .toast, #modal-root { display: none !important; }
  #app, .panes, .pane-preview, .pane-body { display: block !important; height: auto !important; overflow: visible !important; background: #fff !important; padding: 0 !important; }
  .pv-page { box-shadow: none; padding: 0 2px; max-width: none; }
  /* 표 머리칸의 파란 배경이 인쇄/PDF에서도 나오도록 */
  .pv-page, .pv-page * { -webkit-print-color-adjust: exact !important; print-color-adjust: exact !important; }
  .pv-table th { background: #dce6f1 !important; }
  .pv-table tr:not([data-key="content"]) { break-inside: avoid; }
  mark.corr { color: #1f4e9a !important; }
}

/* 여러 파일 */
.file-order { margin: 8px 0; padding-left: 22px; display: flex; flex-direction: column; gap: 2px; }
.file-order li { display: flex; align-items: center; gap: 6px; }
.file-order .fo-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.part-divider { margin: 10px 0 4px; padding: 4px 10px; font-size: 12px; font-weight: 700; color: var(--accent); background: var(--accent-soft); border-radius: 6px; }

.warn-text { color: #b45309; }
@media (prefers-color-scheme: dark) { .warn-text { color: #fbbf24; } }
