/* ========================================================
   HEAL7 AI DOCUMENT CONSOLE - DASHBOARD & GOOGLE DOCS STUDIO
   ======================================================== */

.card {
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow);
  backdrop-filter: blur(16px);
}
.chip {
  display: inline-flex; align-items: center; gap: 0.35rem;
  padding: 0.25rem 0.65rem; border-radius: 999px;
  background: rgba(148, 163, 184, 0.12); color: var(--muted-light);
  font-size: 0.75rem; font-weight: 600;
}
.chip.ok { color: #064e3b; background: var(--green); }
.chip.pending { color: #451a03; background: var(--amber); }
.chip.error { color: white; background: var(--red); }

/* 관리자 로그인 모달 — 인증 전에는 이 창 말고 아무것도 만질 수 없다 */
.auth-dialog { width: min(420px, calc(100vw - 32px)); border-color: rgba(34, 211, 238, 0.35); }
.auth-body { display: grid; gap: 0.55rem; padding: 1.8rem 1.75rem 1.6rem; }
.auth-lock { font-size: 1.9rem; line-height: 1; }
.auth-body h2 { margin: 0; font-size: 1.15rem; }
.auth-copy { margin: 0 0 0.4rem; color: var(--muted-light); font-size: 0.78rem; line-height: 1.5; }
.auth-field { display: grid; gap: 0.28rem; color: var(--muted-light); font-size: 0.74rem; font-weight: 700; }
.auth-field input {
  min-width: 0; border: 1px solid var(--line-strong); border-radius: var(--radius-sm);
  background: var(--surface); color: var(--text); padding: 0.62rem 0.75rem;
  font-size: 0.92rem; font-weight: 500;
}
.auth-field input:focus-visible { outline: 3px solid rgba(34, 211, 238, 0.35); outline-offset: 1px; border-color: var(--cyan); }
.auth-status { margin: 0.15rem 0 0; color: var(--muted); font-size: 0.76rem; line-height: 1.45; min-height: 1.1rem; }
.auth-status.error { color: #fecdd3; }
.auth-status.ok { color: #6ee7b7; }
.auth-submit { margin-top: 0.35rem; justify-content: center; width: 100%; }

/* AI 모델 센터 — 왼쪽 메뉴의 운영 버튼이 실제 서버 설정을 보여주는 모달 */
.ai-model-dialog {
  width: min(720px, calc(100vw - 2rem)); max-height: min(86vh, 760px); padding: 0;
  border-color: rgba(34, 211, 238, 0.38); background: var(--surface-raised);
}
.ai-model-dialog-body { display: grid; gap: 0.9rem; padding: 1.35rem; overflow: auto; }
.ai-model-dialog-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem; }
.ai-model-dialog-head h2 { margin: 0.18rem 0 0; }
.ai-model-dialog-intro { margin: 0; color: var(--muted-light); font-size: 0.82rem; line-height: 1.5; }
.ai-model-dialog-content { min-height: 6rem; }
.ai-model-dialog-status { min-height: 1.15rem; margin: 0; color: var(--muted); font-size: 0.74rem; line-height: 1.4; }
.ai-model-dialog-status[data-kind="error"] { color: #fda4af; }
.ai-model-dialog-status[data-kind="ok"] { color: #6ee7b7; }
.ai-dialog-loading { display: flex; align-items: center; justify-content: center; gap: 0.5rem; min-height: 8rem; color: var(--cyan); font-size: 0.82rem; }
.ai-dialog-loading span { display: inline-block; animation: ai-dialog-spin 0.9s linear infinite; font-size: 1.2rem; }
@keyframes ai-dialog-spin { to { transform: rotate(360deg); } }
.ai-model-list, .ai-health-list, .ai-model-choice-list { display: grid; gap: 0.55rem; max-height: 48vh; overflow: auto; }
.ai-model-row, .ai-health-row {
  display: grid; grid-template-columns: minmax(0, 1fr) auto minmax(4.2rem, auto); align-items: center;
  gap: 0.65rem; padding: 0.72rem 0.8rem; border: 1px solid var(--line); border-radius: var(--radius-sm);
  background: rgba(148, 163, 184, 0.05);
}
.ai-model-copy, .ai-health-row > div { display: grid; gap: 0.18rem; min-width: 0; }
.ai-model-copy strong, .ai-health-row strong { overflow: hidden; color: var(--text); font-size: 0.82rem; text-overflow: ellipsis; white-space: nowrap; }
.ai-model-copy small, .ai-health-row small { overflow-wrap: anywhere; color: var(--muted); font-size: 0.7rem; line-height: 1.35; }
.ai-model-state, .ai-model-marker, .ai-health-label { font-size: 0.68rem; font-weight: 750; white-space: nowrap; }
.ai-model-state.ok, .ai-health-label { color: #6ee7b7; }
.ai-model-state.pending { color: #fbbf24; }
.ai-model-marker { min-width: 4.2rem; color: var(--cyan); text-align: right; }
.ai-health-summary {
  display: grid; gap: 0.2rem; padding: 0.8rem; border: 1px solid var(--line); border-radius: var(--radius-sm);
  font-size: 0.78rem; line-height: 1.4;
}
.ai-health-summary.ok { border-color: rgba(16, 185, 129, 0.36); background: rgba(16, 185, 129, 0.08); }
.ai-health-summary.pending { border-color: rgba(245, 158, 11, 0.36); background: rgba(245, 158, 11, 0.08); }
.ai-health-summary span { color: var(--muted-light); font-size: 0.72rem; }
.ai-health-row { grid-template-columns: auto minmax(0, 1fr) auto; }
.ai-health-dot { width: 0.55rem; height: 0.55rem; border-radius: 50%; background: var(--muted); box-shadow: 0 0 0 3px rgba(148, 163, 184, 0.1); }
.ai-health-dot.ok { background: #34d399; box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.13); }
.ai-health-dot.pending { background: #f59e0b; box-shadow: 0 0 0 3px rgba(245, 158, 11, 0.13); }
.ai-dialog-refresh { margin-top: 0.6rem; }
.ai-setting-form { display: grid; gap: 0.7rem; }
.ai-setting-field { display: grid; gap: 0.35rem; color: var(--muted-light); font-size: 0.76rem; font-weight: 700; }
.ai-setting-field select { width: 100%; }
.ai-setting-help { margin: 0; color: var(--muted); font-size: 0.74rem; line-height: 1.45; }
.ai-model-choice {
  display: flex; align-items: center; gap: 0.65rem; min-width: 0; padding: 0.72rem 0.8rem;
  border: 1px solid var(--line); border-radius: var(--radius-sm); background: rgba(148, 163, 184, 0.05); cursor: pointer;
}
.ai-model-choice:hover, .ai-model-choice.selected { border-color: var(--cyan); background: rgba(34, 211, 238, 0.08); }
.ai-model-choice.disabled { opacity: 0.52; cursor: not-allowed; }
.ai-model-choice input { flex: 0 0 auto; accent-color: var(--cyan); }
.ai-model-choice span { display: grid; gap: 0.18rem; min-width: 0; }
.ai-model-choice strong { color: var(--text); font-size: 0.8rem; }
.ai-model-choice small { color: var(--muted); font-size: 0.7rem; line-height: 1.35; }
.ai-model-choice em { margin-left: auto; color: var(--cyan); font-size: 0.68rem; font-style: normal; font-weight: 750; }
.ai-model-dialog-content .primary-button { justify-self: end; }

/* --- Metrics Grid --- */
.metric-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 0.9rem; }
.metric, .panel { padding: 1.25rem; }
.metric span { color: var(--muted); font-size: 0.82rem; font-weight: 500; }
.metric strong { display: block; font-size: 2.2rem; font-weight: 800; margin-top: 0.25rem; letter-spacing: -0.03em; color: var(--text); }
.metric.warn strong { color: var(--red); }

/* --- Dashboard Grid --- */
.dashboard-grid { display: grid; grid-template-columns: minmax(340px, 0.85fr) 1.15fr; gap: 1.25rem; }
.panel p { color: var(--muted); font-size: 0.9rem; margin-bottom: 1.1rem; line-height: 1.5; }
.upload-form { display: grid; gap: 0.9rem; }
.dropzone {
  position: relative; display: grid; place-items: center;
  min-height: 180px; padding: 1.5rem;
  border: 2px dashed rgba(34, 211, 238, 0.35); border-radius: var(--radius);
  text-align: center; background: rgba(34, 211, 238, 0.03);
  transition: all 0.2s ease;
}
.dropzone.dragging, .dropzone:hover {
  border-color: var(--cyan); background: rgba(34, 211, 238, 0.08);
  box-shadow: 0 0 25px rgba(34, 211, 238, 0.15);
}
.dropzone:focus-within { outline: 3px solid rgba(34, 211, 238, 0.35); outline-offset: 2px; }
.dropzone input[type="file"] { position: absolute; inset: 0; z-index: 1; opacity: 0; cursor: pointer; }
.dropzone strong { font-size: 1.05rem; color: var(--text); margin-bottom: 0.25rem; }
.dropzone span { color: var(--cyan); font-weight: 600; font-size: 0.9rem; }
.dropzone small { margin-top: 0.5rem; color: var(--muted); font-size: 0.78rem; }
.processing-settings {
  display: grid; gap: 0.8rem; padding: 1rem; border: 1px solid var(--line-strong);
  border-radius: var(--radius); background: rgba(15, 23, 42, 0.5);
}
.processing-settings-head {
  display: grid; gap: 0.35rem;
}
.settings-kicker { color: var(--cyan); font-size: 0.66rem; font-weight: 800; letter-spacing: 0.08em; }
.processing-settings h3 { margin-top: 0.18rem; font-size: 1rem; }
.processing-settings-head p { margin: 0; color: var(--muted); font-size: 0.76rem; line-height: 1.45; }
.processing-settings .ai-consent-option {
  display: inline-flex; align-items: center; gap: 0.45rem; color: var(--text); font-size: 0.82rem; font-weight: 700; cursor: pointer;
}
.processing-settings .ai-consent-option input { width: 16px; height: 16px; cursor: pointer; accent-color: var(--cyan); }
.processing-settings .ai-consent-option span { color: var(--text); font-size: 0.82rem; }
.processing-settings .ai-consent-option:has(input:disabled) { cursor: not-allowed; opacity: 0.62; }
.processing-settings-help { display: block; max-width: 620px; margin-top: 0.55rem; color: var(--muted); font-size: 0.76rem; line-height: 1.45; }
.table-recheck-setting { padding-top: 0.75rem; border-top: 1px solid var(--line); }
.progress-dialog {
  width: min(540px, calc(100vw - 2rem)); max-height: min(86vh, 760px); padding: 0;
  border: 1px solid rgba(34, 211, 238, 0.42); border-radius: 20px;
  color: var(--text); background: rgba(7, 11, 20, 0.98); box-shadow: var(--shadow-lg);
}
.progress-modal { display: grid; gap: 0.8rem; padding: 1.35rem; }
.progress-modal-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem; }
.progress-kicker { display: block; margin-bottom: 0.25rem; color: var(--cyan); font-size: 0.68rem; font-weight: 800; letter-spacing: 0.08em; text-transform: uppercase; }
.progress-title { margin: 0; font-size: 1.04rem; font-weight: 750; color: var(--text); display: flex; align-items: center; gap: 0.4rem; }
.progress-source { flex: 0 0 auto; padding: 0.3rem 0.55rem; border: 1px solid rgba(34, 211, 238, 0.28); border-radius: 999px; color: var(--cyan); background: rgba(34, 211, 238, 0.08); font-size: 0.68rem; font-weight: 750; white-space: nowrap; }
.progress-document { margin: 0; overflow: hidden; color: var(--muted-light); font-size: 0.78rem; text-overflow: ellipsis; white-space: nowrap; }
.progress-stage-row { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: 0.65rem; color: var(--muted); font-size: 0.75rem; }
.progress-stage-row strong { overflow: hidden; color: var(--text); font-size: 0.86rem; text-overflow: ellipsis; white-space: nowrap; }
.progress-percent { min-width: 5.5rem; color: var(--cyan); font-size: 0.84rem; font-weight: 800; font-variant-numeric: tabular-nums; text-align: right; }
.progress-track { width: 100%; height: 9px; border-radius: 999px; background: rgba(148, 163, 184, 0.15); overflow: hidden; }
.progress-fill { height: 100%; width: 0; border-radius: 999px; background: linear-gradient(90deg, var(--blue), var(--cyan), #38bdf8); box-shadow: 0 0 12px rgba(34, 211, 238, 0.5); transition: width 0.28s ease; }
.progress-track.is-determinate .progress-fill { animation: none; }
.progress-track.is-indeterminate .progress-fill { width: 38%; animation: progress-indeterminate 1.25s ease-in-out infinite; }
.progress-track.is-error .progress-fill { width: 100%; animation: none; background: var(--red) !important; box-shadow: none; }
.progress-track.is-terminal .progress-fill { width: 100%; animation: none; background: var(--amber) !important; box-shadow: none; }
.progress-observation { display: flex; align-items: center; justify-content: space-between; gap: 0.75rem; min-height: 1.15rem; color: var(--muted); font-size: 0.72rem; line-height: 1.35; }
.progress-observation > span:first-child { min-width: 0; }
.progress-detail { margin: 0; color: var(--muted-light); font-size: 0.78rem; line-height: 1.45; }
.progress-elapsed { margin-left: auto; margin-right: 0; color: var(--cyan); font-size: 0.76rem; font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; }
.progress-mascot {
  min-height: 3.7rem; margin: 0; padding: 0.45rem 0.65rem;
  border: 1px solid rgba(34, 211, 238, 0.18); border-radius: var(--radius-sm);
  background: rgba(2, 6, 23, 0.45); color: var(--cyan);
  font: 0.68rem/1.25 ui-monospace, SFMono-Regular, Consolas, monospace;
  white-space: pre-wrap; font-variant-numeric: tabular-nums;
}
.progress-modal-actions { display: flex; justify-content: flex-end; gap: 0.5rem; min-height: 2.2rem; }
.progress-modal-actions .ghost-button,
.progress-modal-actions .primary-button { margin: 0; }
body.processing-locked { cursor: progress; }
body.processing-locked #uploadDropzone { opacity: 0.62; }
body.processing-locked #progressBox { border-color: rgba(34, 211, 238, 0.55); }
body.processing-locked #main { position: relative; }
body.processing-locked #main[aria-busy="true"]::before {
  content: "처리 중 · 취소 버튼을 제외한 화면 조작이 잠겼습니다";
  display: block; margin: 0 0 0.65rem; padding: 0.42rem 0.65rem;
  border: 1px solid rgba(34, 211, 238, 0.22); border-radius: var(--radius-sm);
  color: var(--cyan); background: rgba(34, 211, 238, 0.08);
  font-size: 0.72rem; line-height: 1.35;
}
@keyframes progress-indeterminate {
  0% { transform: translateX(-120%); }
  55%, 100% { transform: translateX(280%); }
}
.card-progress-bar { width: 100%; height: 4px; border-radius: 999px; background: rgba(148, 163, 184, 0.15); overflow: hidden; margin-top: 0.4rem; }
.card-progress-note { margin: 0.3rem 0 0; font-size: 0.72rem; color: var(--cyan); line-height: 1.35; }
.card-progress-fill { height: 100%; width: 38%; border-radius: 999px; background: linear-gradient(90deg, var(--blue), var(--cyan)); }
.card-progress-bar.is-indeterminate .card-progress-fill { animation: progress-indeterminate 1.25s ease-in-out infinite; }
.card-progress-bar.is-determinate .card-progress-fill { animation: none; }
.preflight-card {
  display: grid; gap: 0.35rem; padding: 0.75rem 0.85rem;
  border: 1px solid rgba(245, 158, 11, 0.42); border-radius: var(--radius-sm);
  background: rgba(245, 158, 11, 0.08); color: var(--text); font-size: 0.76rem; line-height: 1.4;
}
.preflight-card > strong { color: var(--amber); font-size: 0.8rem; }
.preflight-card > span { color: var(--muted-light); }
.conversion-mode-options { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0.55rem; margin-top: 0.35rem; }
.conversion-mode-card {
  display: flex; align-items: flex-start; gap: 0.5rem; min-width: 0; padding: 0.65rem 0.7rem;
  border: 1px solid var(--line); border-radius: var(--radius-sm); background: rgba(15, 23, 42, 0.28);
  color: var(--text); cursor: pointer; transition: border-color 0.18s ease, background 0.18s ease;
}
.conversion-mode-card:hover { border-color: var(--line-strong); background: rgba(34, 211, 238, 0.06); }
.conversion-mode-card.selected { border-color: var(--cyan); background: rgba(34, 211, 238, 0.1); box-shadow: inset 0 0 0 1px rgba(34, 211, 238, 0.12); }
.conversion-mode-card.disabled { opacity: 0.55; cursor: not-allowed; }
.conversion-mode-card input { flex: 0 0 auto; width: 16px; height: 16px; margin: 0.1rem 0 0; accent-color: var(--cyan); }
.conversion-mode-card span { display: grid; gap: 0.18rem; min-width: 0; }
.conversion-mode-card strong { font-size: 0.78rem; }
.conversion-mode-card small { color: var(--muted); font-size: 0.7rem; line-height: 1.35; }
.preflight-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 0.45rem; margin-top: 0.35rem; }
.preflight-actions button { padding: 0.35rem 0.6rem; font-size: 0.74rem; }
.preflight-table-option { display: inline-flex; align-items: center; gap: 0.25rem; color: var(--muted-light); font-size: 0.74rem; }
.preflight-ai-limit input[type="number"] { width: 4.4rem; min-height: 30px; padding: 0 0.35rem; border: 1px solid var(--line-strong); border-radius: var(--radius-sm); background: var(--surface); color: var(--text); }
.preflight-ai-limit small { color: var(--muted); font-size: 0.7rem; white-space: nowrap; }
.preflight-table-option input { accent-color: var(--cyan); }
.upload-preflight-panel {
  display: grid; gap: 0.65rem; margin-top: 1rem; padding-top: 1rem;
  border-top: 1px solid var(--line);
}
.upload-preflight-panel.hidden { display: none; }
.upload-preflight-head { display: flex; align-items: center; justify-content: space-between; gap: 0.5rem; }
.upload-preflight-head h3 { margin: 0; font-size: 0.92rem; }
.doc-workflow-status { display: flex; flex-wrap: wrap; align-items: center; gap: 0.35rem; }
.mode-chip, .review-chip { display: inline-flex; align-items: center; min-height: 22px; padding: 0.16rem 0.45rem; border: 1px solid var(--line); border-radius: 999px; color: var(--muted-light); font-size: 0.68rem; font-weight: 700; }
.mode-chip { color: var(--cyan); border-color: rgba(34, 211, 238, 0.28); background: rgba(34, 211, 238, 0.08); }
.review-chip { color: var(--muted-light); background: rgba(148, 163, 184, 0.08); }

/* --- Document Grid & Cards --- */
.list { display: grid; gap: 0.8rem; }
.recent-list { gap: 0; border-top: 1px solid var(--line); }
.recent-document-row {
  display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(8rem, 0.9fr) auto;
  align-items: center; gap: 0.8rem; min-width: 0; padding: 0.7rem 0.15rem;
  border-bottom: 1px solid var(--line); transition: background 0.18s ease;
}
.recent-document-row:hover { background: rgba(148, 163, 184, 0.06); }
.recent-document-row.parsed { border-left: 3px solid var(--green); padding-left: 0.55rem; }
.recent-document-row.partial { border-left: 3px solid var(--amber); padding-left: 0.55rem; }
.recent-document-row.error { border-left: 3px solid var(--red); padding-left: 0.55rem; }
.recent-document-row.processing, .recent-document-row.queued { border-left: 3px solid var(--cyan); padding-left: 0.55rem; }
.recent-document-primary { display: flex; align-items: center; gap: 0.55rem; min-width: 0; }
.recent-document-primary .ext { flex: 0 0 auto; }
.recent-document-copy { display: grid; gap: 0.18rem; min-width: 0; }
.recent-document-copy strong,
.recent-document-copy span,
.recent-document-facts { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.recent-document-copy strong { font-size: 0.86rem; line-height: 1.3; }
.recent-document-copy span, .recent-document-facts { color: var(--muted); font-size: 0.72rem; }
.recent-document-facts { text-align: right; }
.recent-document-actions { display: inline-flex; align-items: center; justify-content: flex-end; gap: 0.35rem; flex-wrap: wrap; }
.recent-document-actions > * { white-space: nowrap; }
.empty { color: var(--muted); padding: 1.5rem; text-align: center; font-size: 0.9rem; }
.doc-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 1rem; }
/* auto-fill 그리드에 항목이 "조건과 일치하는 문서가 없습니다" 한 줄뿐이면 첫 칸(280px)에만 놓여
   글자는 그 안에서 가운데지만 오른쪽에 빈 칸들이 남아 패널 전체 기준으로는 왼쪽에 쏠려 보인다.
   전체 폭을 차지하게 해야 text-align:center가 패널 전체 기준으로 먹는다. */
.doc-grid .empty { grid-column: 1 / -1; }
.doc-card {
  display: flex; flex-direction: column; gap: 0.65rem; padding: 1.2rem;
  transition: all 0.2s ease; position: relative; overflow: hidden;
}
.doc-card:hover { transform: translateY(-2px); border-color: var(--line-strong); box-shadow: var(--shadow-lg); }
.doc-card.parsed { border-left: 4px solid var(--green); }
.doc-card.partial { border-left: 4px solid var(--amber); }
.doc-card.error { border-left: 4px solid var(--red); }
.doc-card.processing { border-left: 4px solid var(--cyan); }
.doc-card.awaiting-confirmation { border-left: 4px solid var(--amber); }
.doc-top .ext {
  font-size: 0.72rem; font-weight: 800; padding: 0.22rem 0.55rem;
  border-radius: 6px; background: rgba(34, 211, 238, 0.12); color: var(--cyan);
  border: 1px solid rgba(34, 211, 238, 0.25);
}
.doc-card h3 {
  font-size: 1.02rem; font-weight: 700; line-height: 1.35;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.doc-card p {
  font-size: 0.84rem; color: var(--muted); line-height: 1.5;
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden;
}
.tag, .keyword-row em {
  font-size: 0.72rem; color: var(--cyan); background: rgba(34, 211, 238, 0.1);
  padding: 0.22rem 0.5rem; border-radius: 999px; font-style: normal;
  border: 1px solid rgba(34, 211, 238, 0.18);
}
.keyword-row { display: flex; flex-wrap: wrap; gap: 0.3rem; margin-top: 0.2rem; }
.doc-card footer { margin-top: auto; padding-top: 0.75rem; border-top: 1px solid var(--line); font-size: 0.8rem; color: var(--muted); }
.card-footer-actions { display: inline-flex; align-items: center; gap: 0.4rem; flex-wrap: wrap; justify-content: flex-end; }
.card-footer-actions > * { white-space: nowrap; }
.btn-compact { padding: 0.24rem 0.62rem; font-size: 0.77rem; }
.chip-compact { padding: 0.15rem 0.5rem; font-size: 0.72rem; }
.bookmark-heal-row { margin-top: 0.35rem; display: flex; justify-content: flex-end; }
.bookmark-empty { padding: 1rem 0; }
.filters { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem; }
.filter.active { background: var(--blue); color: white; border-color: var(--blue); }
select {
  min-height: 38px; padding: 0 0.8rem; border-radius: var(--radius-sm);
  border: 1px solid var(--line); color: var(--text); background: var(--surface);
  font-size: 0.85rem;
}

/* --- Library Tabs & Batch Toolbar --- */
.library-header-row {
  display: flex; align-items: center; justify-content: space-between;
  gap: 1rem; flex-wrap: wrap; margin-bottom: 1rem;
}
.library-tabs {
  display: flex; gap: 0.35rem; background: rgba(15, 23, 42, 0.65);
  padding: 0.25rem; border-radius: var(--radius); border: 1px solid var(--line);
}
.lib-tab {
  padding: 0.45rem 0.9rem; border-radius: calc(var(--radius) - 2px);
  border: 0; background: transparent; color: var(--muted); font-weight: 600;
  font-size: 0.86rem; cursor: pointer; transition: all 0.15s ease;
}
.lib-tab:hover { color: var(--text); background: rgba(148, 163, 184, 0.08); }
.lib-tab.active { color: white; background: var(--blue); box-shadow: 0 2px 8px rgba(79, 70, 229, 0.4); }

.batch-bar {
  display: flex; align-items: center; justify-content: space-between;
  gap: 1rem; padding: 0.7rem 1.2rem; margin-bottom: 1rem;
  background: rgba(15, 23, 42, 0.85); border: 1px solid var(--line-strong);
  border-radius: var(--radius); backdrop-filter: blur(12px);
}
.batch-left { display: flex; align-items: center; gap: 1.2rem; }
.select-all-label {
  display: flex; align-items: center; gap: 0.5rem; cursor: pointer;
  font-size: 0.88rem; font-weight: 600; color: var(--text);
}
.batch-selected-count {
  font-size: 0.82rem; font-weight: 700; color: var(--cyan);
  background: rgba(34, 211, 238, 0.12); padding: 0.2rem 0.6rem; border-radius: 999px;
}
.batch-actions { display: flex; align-items: center; gap: 0.5rem; flex-wrap: wrap; }
.batch-btn {
  padding: 0.38rem 0.85rem; border-radius: 6px; font-size: 0.82rem;
  font-weight: 600; cursor: pointer; border: 0; transition: all 0.15s ease;
}
.batch-btn.primary { background: var(--blue); color: white; }
.batch-btn.primary:hover { filter: brightness(1.15); }
.batch-btn.danger { background: rgba(239, 68, 68, 0.18); color: #f87171; border: 1px solid rgba(239, 68, 68, 0.35); }
.batch-btn.danger:hover { background: #ef4444; color: white; }
.batch-btn.ghost { background: rgba(148, 163, 184, 0.12); color: var(--muted-light); }
.batch-btn.ghost:hover { background: rgba(148, 163, 184, 0.2); color: white; }

/* Document Card Select Checkbox & Action Buttons */
.doc-card .card-select {
  position: absolute; top: 12px; left: 12px; z-index: 5;
  width: 17px; height: 17px; cursor: pointer; accent-color: var(--cyan);
}
.doc-card.selected {
  border-color: var(--cyan); box-shadow: 0 0 0 2px rgba(34, 211, 238, 0.35);
  background: rgba(34, 211, 238, 0.03);
}
.doc-card.trashed {
  opacity: 0.82; border-left: 4px solid var(--muted);
}
.doc-card.has-select .doc-top {
  padding-left: 1.6rem;
}
.card-action-btn {
  padding: 0.25rem 0.55rem; font-size: 0.76rem; border-radius: 5px;
  cursor: pointer; border: 0; font-weight: 600; transition: all 0.15s;
}
.card-action-btn.delete { background: rgba(239, 68, 68, 0.12); color: #f87171; border: 1px solid rgba(239, 68, 68, 0.25); }
.card-action-btn.delete:hover { background: #ef4444; color: white; }
.card-action-btn.restore { background: rgba(16, 185, 129, 0.12); color: #34d399; border: 1px solid rgba(16, 185, 129, 0.25); }
.card-action-btn.restore:hover { background: #10b981; color: white; }
.card-action-btn.permanent { background: rgba(239, 68, 68, 0.18); color: #fca5a5; border: 1px solid rgba(239, 68, 68, 0.4); }
.card-action-btn.permanent:hover { background: #dc2626; color: white; }
.card-action-btn.cancel { background: rgba(245, 158, 11, 0.14); color: #fbbf24; border: 1px solid rgba(245, 158, 11, 0.3); }
.card-action-btn.cancel:hover { background: #f59e0b; color: #1f1300; }
.card-action-btn.reparse { background: rgba(56, 189, 248, 0.14); color: #7dd3fc; border: 1px solid rgba(56, 189, 248, 0.3); }
.card-action-btn.reparse:hover { background: #0ea5e9; color: white; }
.card-action-btn:disabled { opacity: 0.45; cursor: not-allowed; }
.card-action-btn:disabled:hover { background: inherit; color: inherit; }

/* ========================================================
   GOOGLE DOCS STYLE EDITING STUDIO
   ======================================================== */

.studio-container {
  display: flex; flex-direction: column; gap: 0.85rem; min-height: 82vh;
}

/* --- Top Header & Ribbon Bar --- */
.studio-header-card {
  display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center;
  gap: 0.35rem 0.75rem; padding: 0.35rem 0.75rem; flex: 0 0 auto;
}
.studio-doc-info {
  display: flex; align-items: center; gap: 0.55rem; min-width: 0;
}
.studio-doc-info select {
  min-width: 0; width: min(100%, 520px); min-height: 32px; padding: 0 0.55rem;
  font-size: 0.86rem; font-weight: 600; flex: 1;
}
.studio-workflow-status { display: flex; flex-wrap: wrap; align-items: center; gap: 0.3rem; min-width: max-content; }
.studio-header-card .toolbar-actions {
  display: flex; align-items: center; justify-content: flex-end; gap: 0.35rem;
  min-width: 0; flex-wrap: wrap;
}
.studio-header-card .toolbar-actions button {
  min-height: 30px; padding: 0.3rem 0.62rem; font-size: 0.76rem;
}

/* --- Google Docs Ribbon Toolbar --- */
.gdocs-toolbar {
  display: flex; align-items: center; gap: 0.4rem; padding: 0.5rem 0.8rem;
  background: var(--surface-raised); border: 1px solid var(--line);
  border-radius: var(--radius) var(--radius) 0 0; flex-wrap: wrap; flex: 0 0 auto;
  position: sticky; top: 0; z-index: 40;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.25);
}
.toolbar-group {
  display: inline-flex; align-items: center; gap: 0.2rem;
  padding: 0 0.4rem; border-right: 1px solid var(--line);
}
.toolbar-group:last-child { border-right: none; }
.toolbar-group-caption {
  color: var(--muted-light); font-size: 0.7rem; font-weight: 800; white-space: nowrap;
}
.manual-insert-group { gap: 0.3rem; }
.manual-insert-position { display: inline-flex; align-items: center; }
.manual-insert-position .tool-select { height: 30px; font-size: 0.74rem; }
.manual-insert-slot {
  position: relative; z-index: 10; height: 0; margin: 0; padding: 0;
  pointer-events: none;
}
.manual-insert-slot::before {
  content: ""; position: absolute; top: 0; left: 0; right: 0;
  height: 20px; transform: translateY(-50%); pointer-events: auto;
}
.manual-insert-boundary {
  position: absolute; top: 0; left: 50%; transform: translate(-50%, -50%);
  min-height: 24px; padding: 0.08rem 0.65rem;
  border: 1px solid #cbd5e1; border-radius: 999px; background: #f8fafc;
  color: #334155; font: inherit; font-size: 0.7rem; font-weight: 700;
  cursor: pointer; opacity: 0; pointer-events: none;
  transition: opacity 0.15s, border-color 0.15s, background 0.15s;
}
.manual-insert-slot:hover .manual-insert-boundary,
.manual-insert-slot:focus-within .manual-insert-boundary,
.manual-insert-boundary:hover, .manual-insert-boundary:focus-visible {
  border-color: #4f46e5; background: #eef2ff; opacity: 1;
  pointer-events: auto;
}
.manual-insert-boundary:focus-visible { outline: 3px solid rgba(79, 70, 229, 0.32); outline-offset: 2px; }
.manual-insert-boundary:disabled { cursor: not-allowed; opacity: 0.4; }
.tool-btn {
  width: 32px; height: 32px; border-radius: 6px; border: 1px solid transparent;
  background: transparent; color: var(--text); display: grid; place-items: center;
  font-size: 0.88rem; font-weight: 600; cursor: pointer; transition: all 0.15s;
}
.align-icon { width: 15px; height: 15px; fill: currentColor; display: block; }
.tool-btn-labeled {
  width: auto; padding: 0 0.6rem; gap: 0.3rem; font-size: 0.76rem; white-space: nowrap;
  border-color: var(--line);
}
.tool-btn:hover { background: rgba(148, 163, 184, 0.15); color: var(--cyan); }
.tool-btn.active { background: rgba(79, 70, 229, 0.3); border-color: var(--blue); color: #fff; }
.tool-btn:disabled { opacity: 0.35; cursor: not-allowed; }
.tool-select {
  height: 32px; padding: 0 0.5rem; border-radius: 6px; border: 1px solid var(--line);
  background: var(--surface); color: var(--text); font-size: 0.82rem;
}
.tool-color-wrap {
  width: 32px; height: 32px; border-radius: 6px; border: 1px solid var(--line);
  display: grid; place-items: center; cursor: pointer; position: relative; overflow: hidden;
}
.tool-color-wrap:hover { border-color: var(--cyan); }
.tool-color-swatch {
  width: 16px; height: 16px; border-radius: 3px; border: 1px solid rgba(0, 0, 0, 0.25);
  background: var(--tool-color-current, #202124); pointer-events: none;
}
.tool-color-input {
  position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer; border: none; padding: 0;
}
.save-indicator {
  font-size: 0.78rem; color: var(--muted); display: inline-flex; align-items: center;
  gap: 0.35rem; margin-left: auto; padding: 0 0.5rem;
}
.save-indicator.dirty { color: var(--amber); }
.save-indicator.saved { color: var(--green); }
.save-indicator.error { color: #fda4af; }

/* Studio fills the viewport so the paper scrolls and the AI bar stays on-screen. */
.shell:has(#studio:not(.hidden)) {
  height: 100vh; max-height: 100vh; overflow: hidden;
}
.shell:has(#studio:not(.hidden)) main {
  display: flex; flex-direction: column; min-height: 0; height: 100%; max-height: 100%; overflow: hidden;
}
#studio:not(.hidden) {
  flex: 1; min-height: 0; overflow: hidden;
}

/* --- Studio Main Layout (full-width toolbar + paper, compact AI dock inside editor) --- */
.gdocs-layout {
  display: grid; grid-template-columns: minmax(0, 1fr);
  grid-template-areas: "editor";
  align-items: stretch; flex: 1; min-height: 0;
  container: studio-layout / inline-size;
}
.studio-editor-column {
  grid-area: editor; display: flex; flex-direction: column;
  min-width: 0; min-height: 0; overflow: hidden;
}
.toolbar-scroll-hint { display: none; }
.source-validation-message {
  flex: 0 0 auto; margin: 0; padding: 0.55rem 0.8rem;
  color: #fecdd3; background: rgba(244, 63, 94, 0.12); border: 1px solid rgba(244, 63, 94, 0.38);
  font-size: 0.78rem; line-height: 1.4;
}

/* --- Left Panel: Bookmarks / Outline --- */
.gdocs-bookmarks-panel {
  padding: 1rem; display: flex; flex-direction: column; gap: 0.75rem;
  height: 100%; min-height: 0; overflow: hidden;
}
.bookmarks-head {
  display: flex; align-items: center; justify-content: space-between; gap: 0.5rem;
}
.bookmarks-head h2 { font-size: 1.05rem; margin: 0; display: flex; align-items: center; gap: 0.45rem; }
.search-input-wrap { position: relative; }
.search-input-wrap input {
  width: 100%; min-height: 34px; padding: 0 0.8rem; border-radius: var(--radius-sm);
  border: 1px solid var(--line); background: var(--surface); color: var(--text);
  font-size: 0.82rem;
}
.bookmark-tab-filters {
  display: flex; flex-wrap: wrap; gap: 0.3rem; margin-top: -0.2rem;
}
.bookmark-tab-filters .filter {
  font-size: 0.75rem; padding: 0.3rem 0.55rem; border-radius: 6px;
}
.bookmark-tree {
  display: flex; flex-direction: column; gap: 0.4rem; overflow-y: auto;
  padding-right: 4px; flex: 1; min-height: 0;
}
.bookmark-item {
  display: flex; flex-direction: column; gap: 0.25rem; padding: 0.65rem 0.8rem;
  border-radius: var(--radius-sm); border: 1px solid transparent;
  background: rgba(148, 163, 184, 0.05); color: var(--text); text-align: left;
  cursor: pointer; transition: all 0.18s ease; text-decoration: none;
}
.bookmark-item:hover {
  background: rgba(79, 70, 229, 0.15); border-color: rgba(79, 70, 229, 0.3);
  transform: translateX(2px);
}
.bookmark-item.active {
  background: rgba(34, 211, 238, 0.12); border-color: var(--cyan);
  box-shadow: 0 0 12px rgba(34, 211, 238, 0.2);
}
.bookmark-item.unmarked { opacity: 0.45; }
.bookmark-meta {
  display: flex; align-items: center; justify-content: space-between; gap: 0.4rem;
}
.bookmark-badge {
  font-size: 0.68rem; font-weight: 700; padding: 0.12rem 0.45rem;
  border-radius: 4px; text-transform: uppercase; letter-spacing: 0.02em;
}
.bookmark-badge.table { background: rgba(16, 185, 129, 0.18); color: #34d399; }
.bookmark-badge.figure { background: rgba(245, 158, 11, 0.18); color: #fbbf24; }
.bookmark-badge.chart { background: rgba(244, 63, 94, 0.18); color: #fda4af; }
.bookmark-badge.equation { background: rgba(168, 85, 247, 0.18); color: #d8b4fe; }
.bookmark-badge.text { background: rgba(34, 211, 238, 0.15); color: var(--cyan); }
.bookmark-page { font-size: 0.72rem; color: var(--muted); }
.bookmark-item strong {
  font-size: 0.84rem; font-weight: 600; line-height: 1.35;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}

/* --- Right Canvas: Google Docs Paper Canvas --- */
.gdocs-canvas-wrap {
  display: flex; flex-direction: column; align-items: center; gap: 1.1rem;
  padding: 1.1rem 1rem 1.2rem; background: rgba(0, 0, 0, 0.25);
  border-radius: 0 0 var(--radius) var(--radius); border: 1px solid var(--line);
  border-top: 0; flex: 1; min-height: 0; overflow: auto; position: relative;
}
.studio-editing-overlay {
  position: absolute; top: 0.9rem; right: 0.9rem; z-index: 20;
  display: grid; gap: 0.42rem; width: min(390px, calc(100% - 1.8rem));
  padding: 0.75rem 0.85rem; border: 1px solid rgba(34, 211, 238, 0.55);
  border-radius: 10px; background: color-mix(in srgb, var(--surface-raised) 94%, transparent);
  color: var(--text); box-shadow: 0 12px 30px rgba(2, 6, 23, 0.28);
  pointer-events: auto; backdrop-filter: blur(8px);
}
.studio-editing-overlay.hidden { display: none !important; }
.studio-editing-overlay[data-state="done"] { border-color: rgba(34, 197, 94, 0.6); }
.studio-editing-overlay[data-state="error"] { border-color: rgba(248, 113, 113, 0.68); }
.studio-editing-overlay-head { display: flex; align-items: center; gap: 0.45rem; min-width: 0; }
.studio-editing-overlay-head > span { font-size: 1rem; line-height: 1; }
.studio-editing-overlay-head strong { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 0.78rem; }
.studio-editing-overlay-skip { margin-left: auto; min-height: 25px; padding: 0 0.5rem; font-size: 0.68rem; white-space: nowrap; }
.studio-editing-overlay p { margin: 0; color: var(--muted-light); font-size: 0.72rem; line-height: 1.45; overflow-wrap: anywhere; }
.studio-editing-overlay-track { width: 100%; height: 7px; overflow: hidden; border-radius: 999px; background: rgba(148, 163, 184, 0.18); }
.studio-editing-overlay-fill { height: 100%; width: 42%; border-radius: inherit; background: linear-gradient(90deg, var(--cyan), var(--blue)); }
.studio-editing-overlay-track.is-indeterminate .studio-editing-overlay-fill { animation: studio-ai-slide 1.15s ease-in-out infinite; }
.studio-editing-overlay-track.is-determinate .studio-editing-overlay-fill { animation: none; }
.studio-editing-overlay[data-state="done"] .studio-editing-overlay-fill { width: 100%; background: var(--green); animation: none; }
.studio-editing-overlay[data-state="error"] .studio-editing-overlay-fill { width: 100%; background: var(--red); animation: none; }
.studio-editing-overlay-meta { color: var(--muted); font-size: 0.66rem; line-height: 1.35; }
.gdocs-paper {
  /* 세로 flex 컨테이너 안에서 줄어들면 긴 쪽의 내용이 종이 밖으로 흘러나온다. */
  flex: 0 0 auto;
  width: 100%; max-width: 860px; min-height: 1050px;
  background: var(--doc-paper-bg); color: var(--doc-paper-text);
  padding: 65px 75px; border-radius: 4px; box-shadow: var(--doc-paper-shadow);
  border: 1px solid rgba(0, 0, 0, 0.08); font-family: "Pretendard", "Segoe UI", system-ui, sans-serif;
  font-size: 15px; line-height: 1.75; outline: none; transition: box-shadow 0.2s;
}
.gdocs-paper:focus-within {
  box-shadow: var(--doc-paper-shadow), 0 0 0 2px var(--cyan);
}
.studio-pending-card {
  display: grid; gap: 0.65rem; width: min(100%, 860px); margin: auto 0;
  padding: 1.25rem 1.35rem; border: 1px solid rgba(34, 211, 238, 0.35);
  border-radius: var(--radius); background: var(--surface-raised);
  box-shadow: 0 12px 30px rgba(2, 6, 23, 0.2);
}
.studio-pending-card.hidden { display: none; }
.studio-pending-head { display: flex; align-items: center; gap: 0.55rem; min-width: 0; }
.studio-pending-head strong { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.studio-pending-card p { margin: 0; color: var(--muted-light); font-size: 0.82rem; line-height: 1.5; }
.studio-pending-track {
  width: 100%; height: 8px; overflow: hidden; border-radius: 999px;
  background: rgba(148, 163, 184, 0.16);
}
.studio-pending-fill { height: 100%; width: 38%; border-radius: inherit; background: linear-gradient(90deg, var(--blue), var(--cyan)); }
.studio-pending-track.is-indeterminate .studio-pending-fill { animation: progress-indeterminate 1.25s ease-in-out infinite; }
.studio-pending-track.is-determinate .studio-pending-fill { animation: none; background: linear-gradient(90deg, var(--blue), var(--cyan)); }
.studio-pending-track[aria-valuenow="100"] .studio-pending-fill { background: var(--green); }
.studio-pending-foot { display: flex; align-items: center; justify-content: space-between; gap: 0.6rem; color: var(--muted); font-size: 0.74rem; }
.studio-pending-foot button { padding: 0.32rem 0.6rem; font-size: 0.74rem; }
.gdocs-source {
  font-family: ui-monospace, SFMono-Regular, monospace; font-size: 13px;
  color: #cbd5e1; background: #0b1120;
}
.gdocs-paper table { width: auto; border-collapse: separate; margin: 0; color: inherit; empty-cells: show; }
.gdocs-paper th, .gdocs-paper td {
  padding: 0; vertical-align: inherit; color: inherit;
}
.gdocs-paper th { font-weight: inherit; }
.gdocs-paper .doc-block table table {
  display: table; visibility: visible; opacity: 1;
}
.gdocs-paper table.nested-table {
  display: table !important; visibility: visible !important; opacity: 1 !important;
}
.gdocs-paper .doc-block td > table, .gdocs-paper .doc-block th > table {
  vertical-align: inherit;
}
.table-edit-toolbar {
  display: flex; align-items: center; gap: 0.35rem; flex-wrap: wrap;
  min-height: 38px; padding: 0.35rem 0.55rem;
  background: rgba(15, 23, 42, 0.72); border: 1px solid var(--line);
  border-top: 0; color: var(--muted-light); font-size: 0.72rem;
}
/* 선택 시작 순간에도 캔버스 위치가 움직이지 않아야 드래그 끝 셀을 잃지 않는다. */
.table-edit-toolbar[hidden] {
  display: flex !important; visibility: hidden; pointer-events: none;
}
.table-edit-count { color: var(--cyan); font-weight: 700; white-space: nowrap; }
.table-edit-help { min-width: 15rem; flex: 1 1 15rem; line-height: 1.35; }
.table-cell-dragging, .table-cell-dragging * { cursor: crosshair !important; user-select: none !important; }
.gdocs-paper table.table-selection-active { outline: 2px solid rgba(79, 70, 229, 0.62); outline-offset: 2px; }
.gdocs-paper table td.table-cell-selected,
.gdocs-paper table th.table-cell-selected {
  background-color: rgba(34, 211, 238, 0.2) !important;
  outline: 2px solid rgba(34, 211, 238, 0.72); outline-offset: -2px;
}
.studio-ai-dock {
  display: grid; gap: 0.4rem; padding: 0.45rem 0.65rem 0.55rem;
  flex: 0 0 auto; z-index: 46; min-width: 0; margin-top: 0.45rem;
  background: var(--surface-raised); box-shadow: 0 -10px 28px rgba(0, 0, 0, 0.28);
}
.studio-ai-dock[hidden] { display: none !important; }
.studio-ai-controls {
  display: flex; align-items: center; gap: 0.45rem; flex-wrap: wrap;
  padding-top: 0.1rem; border-top: 1px solid var(--line); color: var(--muted-light); font-size: 0.72rem;
}
.studio-ai-control { display: inline-flex; align-items: center; gap: 0.3rem; white-space: nowrap; }
.studio-ai-control select {
  max-width: 13rem; padding: 0.25rem 0.4rem; border: 1px solid var(--line-strong); border-radius: 5px;
  background: var(--surface); color: var(--text); font: inherit;
}
.studio-ai-context-label { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--cyan); }
.studio-resource-summary { min-height: 1.1rem; color: var(--muted); font-size: 0.7rem; overflow-wrap: anywhere; }
.studio-ai-status {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) minmax(72px, 1fr) auto;
  grid-template-areas: "emoji text track close";
  align-items: center; gap: 0.45rem; min-height: 28px;
}
.studio-ai-status #studioAiEmoji { grid-area: emoji; font-size: 1rem; line-height: 1; }
.studio-ai-status #studioAiText {
  grid-area: text; min-width: 0; color: var(--text); font-size: 0.76rem; font-weight: 600;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.studio-ai-track {
  grid-area: track; height: 7px; border-radius: 999px;
  background: rgba(148, 163, 184, 0.18); overflow: hidden;
}
.studio-ai-fill {
  height: 100%; width: 8%; border-radius: inherit;
  background: linear-gradient(90deg, var(--cyan), var(--blue));
  transition: width 0.28s ease;
}
.studio-ai-status[data-state="busy"] .studio-ai-fill {
  width: 42%; animation: studio-ai-slide 1.15s ease-in-out infinite;
}
.studio-ai-status[data-state="done"] .studio-ai-fill { width: 100%; background: var(--green); animation: none; }
.studio-ai-status[data-state="error"] .studio-ai-fill { width: 100%; background: var(--red); animation: none; }
/* 재생 중에는 확정 진행률을 그대로 보여준다. */
.studio-ai-status[data-state="replay"] .studio-ai-fill {
  background: linear-gradient(90deg, var(--cyan), var(--green)); animation: none;
}
.studio-ai-skip {
  grid-area: close; min-height: 24px; padding: 0 0.5rem; font-size: 0.68rem; white-space: nowrap;
}
.studio-ai-status:not([data-state="replay"]) .studio-ai-skip { display: none; }
.studio-ai-status[data-state="replay"] .studio-ai-close { display: none; }

/* AI 편집 재생 표현 */
.doc-block.replay-active {
  outline: 2px solid var(--cyan); outline-offset: 2px; border-radius: 6px;
  background: color-mix(in srgb, var(--cyan) 7%, transparent);
}
.doc-block.replay-active::after {
  content: ""; display: inline-block; width: 2px; height: 1em; margin-left: 1px;
  vertical-align: -0.15em; background: var(--cyan); animation: replay-caret 0.85s step-end infinite;
}
/* class가 아닌 data 속성으로 표시한다. sanitizer가 class는 보존해 저장 상태로 새어 들어간다. */
.doc-block td, .doc-block th { transition: background 0.6s ease; }
.doc-block td[data-replay="pending"], .doc-block th[data-replay="pending"] {
  background: color-mix(in srgb, var(--muted-light) 12%, transparent);
}
.doc-block td[data-replay="filled"], .doc-block th[data-replay="filled"] {
  background: color-mix(in srgb, var(--cyan) 18%, transparent);
}
@keyframes replay-caret { 0%, 60% { opacity: 1; } 61%, 100% { opacity: 0; } }
@media (prefers-reduced-motion: reduce) {
  .doc-block.replay-active::after { animation: none; }
}
.studio-ai-close { grid-area: close; width: 28px; height: 28px; padding: 0; }
.studio-ai-form { display: flex; align-items: center; gap: 0.45rem; }
.studio-ai-form input {
  flex: 1; min-width: 0; min-height: 36px; padding: 0.35rem 0.7rem;
  border: 1px solid var(--line-strong); border-radius: var(--radius-sm);
  background: var(--surface); color: var(--text); font-size: 0.84rem;
}
.studio-ai-form input:disabled { opacity: 0.72; }
.studio-direct-edit { padding: 0.4rem 0.65rem; font-size: 0.78rem; white-space: nowrap; }
.studio-ai-form .primary-button { padding: 0.4rem 0.85rem; font-size: 0.8rem; white-space: nowrap; }
@keyframes studio-ai-slide {
  0% { transform: translateX(-130%); }
  100% { transform: translateX(280%); }
}
.preflight-note {
  margin: 0.15rem 0 0; color: var(--muted-light); font-size: 0.72rem; line-height: 1.4;
}
.editor-page-divider {
  display: flex; align-items: center; gap: 0.7rem; margin: -0.4rem 0 1.5rem;
  color: #64748b; font-size: 0.72rem; font-weight: 800; letter-spacing: 0.08em;
  text-transform: uppercase; user-select: none;
}
.editor-page-divider::before, .editor-page-divider::after {
  content: ""; height: 1px; flex: 1; background: #cbd5e1;
}
.editor-page-divider span { padding: 0 0.45rem; white-space: nowrap; }
.page-diagnostic-badges { display: inline-flex; gap: 0.35rem; flex-wrap: wrap; text-transform: none; letter-spacing: normal; }
.page-diagnostic-badge {
  display: inline-flex; align-items: center; gap: 0.25rem; padding: 0.15rem 0.55rem; border-radius: 999px;
  font-size: 0.68rem; font-weight: 700; white-space: nowrap;
}
.page-diagnostic-badge.warn { background: rgba(217, 119, 6, 0.14); color: #b45309; border: 1px solid rgba(217, 119, 6, 0.35); }
.page-diagnostic-badge.muted { background: rgba(100, 116, 139, 0.14); color: #475569; border: 1px solid rgba(100, 116, 139, 0.32); }
.preflight-diagnostic-summary { display: flex; flex-wrap: wrap; gap: 0.35rem; margin: 0.35rem 0 0; }
.page-empty { padding: 2rem 0; color: #64748b; text-align: center; }
.editor-pagination {
  display: flex; align-items: center; justify-content: center; flex-wrap: wrap; gap: 0.35rem;
  width: min(100%, 860px); padding: 0.55rem; border: 1px solid var(--line);
  border-radius: var(--radius-sm); background: var(--surface-raised);
  /* 긴 쪽에서도 쪽 이동 막대는 항상 닿을 수 있게 스크롤 영역 하단에 고정한다. */
  flex: 0 0 auto; position: sticky; bottom: 0; z-index: 35;
  box-shadow: 0 -6px 18px rgba(0, 0, 0, 0.35);
}
.page-number-list { display: inline-flex; flex-wrap: wrap; gap: 0.25rem; justify-content: center; }
.page-button {
  min-width: 34px; min-height: 34px; padding: 0 0.45rem; border-radius: 6px;
  border: 1px solid var(--line); background: var(--surface); color: var(--text);
  font-size: 0.78rem; font-weight: 700; cursor: pointer;
}
.page-button:hover, .page-button.active { border-color: var(--cyan); background: var(--blue); color: white; }
.page-button:disabled { opacity: 0.35; cursor: not-allowed; }
.page-status { margin-left: 0.45rem; color: var(--muted); font-size: 0.76rem; font-weight: 700; white-space: nowrap; }

/* Document Elements Inside Google Docs Paper */
.doc-block {
  position: relative; margin: 0.8em 0; padding: 0.35em 0.5em;
  border-radius: 6px; border: 1px dashed transparent;
  transition: all 0.18s ease; outline: none;
}
.doc-block:hover {
  border-color: rgba(79, 70, 229, 0.35); background: rgba(79, 70, 229, 0.02);
}
.doc-block.focused {
  border-color: var(--blue); background: rgba(79, 70, 229, 0.04);
  box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.18);
}
.gdocs-paper .doc-block .ai-point-target {
  outline: 2px solid var(--cyan); outline-offset: 2px;
  background-color: rgba(34, 211, 238, 0.12);
}
.doc-block.scope-locked {
  cursor: wait; opacity: 0.82;
}
.doc-block.scope-locked::after {
  content: "처리 중"; position: absolute; right: 0.45rem; bottom: 0.25rem;
  color: #475569; font-size: 0.68rem; font-weight: 700; pointer-events: none;
}
.doc-block.highlight-pulse {
  animation: block-pulse 2s ease-out;
}
/* 원문의 빈 문단은 세로 여백 그 자체다. 편집 블록의 기본 margin/padding까지 얹으면
   원문 한 줄보다 훨씬 넓게 벌어져 오히려 원문과 다른 간격이 된다. 딱 한 줄 높이로 둔다. */
.doc-block:has(> .empty-line) {
  margin: 0; padding: 0;
}
.doc-block > .empty-line {
  margin: 0; min-height: 1.15em; line-height: 1.15;
}
@keyframes block-pulse {
  0% { background: rgba(34, 211, 238, 0.35); box-shadow: 0 0 0 6px var(--cyan); }
  100% { background: transparent; box-shadow: none; }
}

/* Floating Block Tag / Controls */
.doc-block-chrome {
  position: absolute; right: 8px; top: -11px; z-index: 10;
  display: inline-flex; align-items: center; gap: 0.3rem;
  opacity: 0; pointer-events: none; transition: opacity 0.15s;
}
.doc-block:hover .doc-block-chrome, .doc-block.focused .doc-block-chrome {
  opacity: 1; pointer-events: auto;
}
.doc-block-badge {
  display: inline-flex; align-items: center; gap: 0.3rem;
  padding: 0.12rem 0.5rem; border-radius: 999px;
  font-size: 0.68rem; font-weight: 700; color: white;
  background: var(--blue); box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}
.doc-block-comment {
  width: 22px; height: 22px; padding: 0; border-radius: 999px; cursor: pointer;
  border: 1px solid var(--cyan); background: var(--surface-raised); color: var(--cyan);
  font-size: 0.7rem; line-height: 1; display: grid; place-items: center;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.25);
}
.doc-block-comment:hover { background: var(--cyan); color: #04121a; }

.doc-block-badge.table { background: #059669; }
.doc-block-badge.figure { background: #d97706; }
.doc-block-badge.chart { background: #e11d48; }
.doc-block-badge.equation { background: #7c3aed; }

.tool-btn[aria-pressed="true"], .tool-btn.mode-active { background: rgba(34, 211, 238, 0.16); border-color: var(--cyan); color: var(--cyan); }

/* Block Content Elements Styling inside White Canvas */
.doc-block h1 { font-size: 1.85rem; font-weight: 800; color: #0f172a; margin: 0.6em 0 0.3em; line-height: 1.3; }
.doc-block h2 { font-size: 1.45rem; font-weight: 700; color: #1e293b; margin: 0.5em 0 0.25em; line-height: 1.35; }
.doc-block h3 { font-size: 1.2rem; font-weight: 600; color: #334155; margin: 0.4em 0 0.2em; }
.doc-block p { color: #334155; margin: 0.4em 0; line-height: 1.7; word-break: break-word; }
.doc-block ul, .doc-block ol { padding-left: 1.6em; margin: 0.4em 0; color: #334155; }
.doc-block li { margin: 0.25em 0; }

/* Table Styling in Google Docs Paper */
.doc-block table {
  width: auto; border-collapse: separate; margin: 0;
  font-size: inherit; color: inherit; empty-cells: show;
}
.gdocs-paper.native-layout > .doc-block.group-table {
  width: 100%; box-sizing: border-box;
  padding-inline: 0; border-inline-width: 0;
}
.gdocs-paper.native-layout > .doc-block.group-table > table {
  max-width: 100%; box-sizing: border-box;
}
.doc-block th, .doc-block td {
  padding: 0; text-align: inherit; vertical-align: inherit;
  min-height: 0; min-width: 0; color: inherit;
}
.doc-block th {
  font-weight: inherit;
}

/* Figure / Image Styling */
.doc-block figure {
  display: flex; flex-direction: column; align-items: center; gap: 0.6rem;
  margin: 1.2em 0; padding: 1rem; background: #f8fafc; border: 1px solid #e2e8f0;
  border-radius: 8px;
}
.doc-block figure img {
  max-width: 100%; height: auto; border-radius: 6px; box-shadow: 0 4px 14px rgba(0, 0, 0, 0.08);
}
.doc-block figcaption {
  font-size: 0.82rem; color: #64748b; text-align: center; max-width: 90%;
}
.doc-block figcaption .figure-type {
  font-weight: 700; color: #4f46e5; text-transform: uppercase; font-size: 0.75rem;
}
.doc-block .docx-tree-diagram {
  width: 100%; max-width: 100%; box-sizing: border-box; min-height: 0;
  max-height: none; overflow-x: auto; overflow-y: hidden; white-space: pre;
  word-break: normal; overflow-wrap: normal; text-align: left;
  padding: 0.85rem; color: #1e293b; background: #f8fafc; border: 1px solid #e2e8f0;
}
.doc-block .visual-placeholder {
  width: 100%; box-sizing: border-box; color: #92400e;
  background: #fffbeb; border: 1px dashed #f59e0b;
}
.doc-block td figure, .doc-block th figure {
  max-width: 100%; box-sizing: border-box; margin: 0.35rem 0; padding: 0.45rem;
}
.doc-block td img, .doc-block th img { max-width: 100%; box-sizing: border-box; }

/* Footer / Export Bar */
.export-bar {
  display: flex; align-items: center; justify-content: space-between;
  gap: 1rem; padding: 0.7rem 1.25rem; flex-wrap: wrap; flex: 0 0 auto;
}
.export-title { display: inline; margin: 0; font-size: 1rem; }
a.ghost-button { text-decoration: none; display: inline-flex; align-items: center; }
a.ghost-button.disabled { opacity: 0.4; pointer-events: none; }

/* Dialog & Toasts */
dialog {
  width: min(920px, calc(100vw - 24px)); max-height: min(86vh, 860px);
  border: 0; border-radius: 20px; color: var(--text); background: var(--surface);
  box-shadow: var(--shadow-lg); border: 1px solid var(--line);
  /* tokens.css의 `* { margin: 0 }`이 dialog 기본 auto 마진을 덮어 좌상단에 붙는다 */
  margin: auto;
}
dialog::backdrop { background: rgba(2, 6, 16, 0.8); backdrop-filter: blur(4px); }
.detail-body { padding: 1.5rem; overflow: auto; }
.detail-body header { display: flex; justify-content: space-between; gap: 1rem; align-items: flex-start; margin-bottom: 1.2rem; }
.summary-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 0.8rem; margin-bottom: 1.2rem; }
.summary-grid div { padding: 0.8rem 1rem; border-radius: var(--radius-sm); background: rgba(148, 163, 184, 0.08); border: 1px solid var(--line); }
.summary-grid dt { font-size: 0.75rem; color: var(--muted); }
.summary-grid dd { font-weight: 700; font-size: 1.05rem; margin-top: 0.2rem; color: var(--text); }
pre {
  min-height: 220px; max-height: 44vh; overflow: auto; padding: 1rem;
  white-space: pre-wrap; word-break: break-word; border-radius: var(--radius-sm);
  background: rgba(2, 6, 17, 0.85); border: 1px solid var(--line);
  font-size: 0.84rem; line-height: 1.6; color: #cbd5e1;
}

/* ========================================================
   AI TABLE HEALING & MULTI-MODEL RECONSTRUCTION BADGES
======================================================== */
.btn-heal-action {
  background: linear-gradient(135deg, rgba(124, 58, 237, 0.25), rgba(37, 99, 235, 0.25)) !important;
  border: 1px solid rgba(139, 92, 246, 0.45) !important;
  color: #c4b5fd !important;
  font-weight: 500;
}
.btn-heal-action:hover {
  background: linear-gradient(135deg, rgba(124, 58, 237, 0.45), rgba(37, 99, 235, 0.45)) !important;
  border-color: #a78bfa !important;
  color: #ffffff !important;
  box-shadow: 0 0 12px rgba(139, 92, 246, 0.3);
}
.mini-heal-btn {
  background: rgba(124, 58, 237, 0.2);
  border: 1px solid rgba(139, 92, 246, 0.35);
  color: #c4b5fd;
  font-size: 0.7rem;
  padding: 0.18rem 0.45rem;
  border-radius: 4px;
  cursor: pointer;
  margin-top: 0.3rem;
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  transition: all 0.18s ease;
}
.mini-heal-btn:hover {
  background: #7c3aed;
  color: #ffffff;
  border-color: #a78bfa;
}
.badge-ai-healed {
  background: rgba(16, 185, 129, 0.2);
  border: 1px solid rgba(16, 185, 129, 0.45);
  color: #6ee7b7;
  font-size: 0.66rem;
  padding: 0.1rem 0.35rem;
  border-radius: 4px;
  font-weight: 500;
}
.badge-needs-review {
  background: rgba(245, 158, 11, 0.16);
  border: 1px solid rgba(245, 158, 11, 0.48);
  color: #fbbf24;
  font-size: 0.66rem;
  padding: 0.1rem 0.35rem;
  border-radius: 4px;
  font-weight: 600;
}
.bookmark-item-card {
  display: flex;
  flex-direction: column;
  border-radius: 6px;
  transition: background 0.15s ease;
}
.bookmark-item-card.active {
  background: rgba(99, 102, 241, 0.1);
}
.resource-hero, .review-hero {
  display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem;
  padding: 1.25rem;
}
.resource-hero p, .review-hero p { max-width: 58rem; color: var(--muted-light); margin: 0.4rem 0 0; line-height: 1.55; }
.resource-hero > button, .review-hero > button { flex: 0 0 auto; margin-top: 0.1rem; }
.resource-hero-actions { display: flex; flex-wrap: wrap; align-items: center; justify-content: flex-end; gap: 0.45rem; flex: 0 0 auto; }
.resource-upload-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 1rem; }
.resource-selection-panel { min-height: 100%; }
.resource-selected-list { display: flex; flex-wrap: wrap; gap: 0.35rem; min-height: 2rem; align-items: center; }
.resource-chip {
  display: inline-flex; align-items: center; gap: 0.25rem; max-width: 100%; padding: 0.25rem 0.45rem;
  border: 1px solid rgba(34, 211, 238, 0.45); border-radius: 999px; color: var(--cyan); background: rgba(34, 211, 238, 0.08); font-size: 0.72rem;
}
.resource-chip button { border: 0; background: transparent; color: inherit; cursor: pointer; padding: 0 0.1rem; font-size: 0.9rem; }
.resource-list { display: grid; gap: 0.45rem; }
.resource-item {
  display: flex; align-items: center; justify-content: space-between; gap: 0.75rem; padding: 0.65rem 0.75rem;
  border: 1px solid var(--line); border-radius: var(--radius-sm); background: rgba(148, 163, 184, 0.04);
}
.resource-item.is-processing { opacity: 0.68; }
.resource-check { display: flex; align-items: center; gap: 0.55rem; min-width: 0; cursor: pointer; }
.resource-file-icon { display: grid; place-items: center; width: 2rem; height: 2rem; border-radius: 6px; background: rgba(79, 70, 229, 0.22); color: var(--cyan); font-weight: 800; }
.resource-file-copy { display: grid; gap: 0.15rem; min-width: 0; }
.resource-file-copy strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.resource-file-copy small, .resource-item-actions { color: var(--muted); font-size: 0.7rem; }
.resource-item-actions { display: flex; align-items: center; gap: 0.5rem; flex: 0 0 auto; }
.resource-status.ready { color: #6ee7b7; }
.resource-status.processing { color: #fbbf24; }
.mybox-panel { display: grid; gap: 0.85rem; }
.mybox-head { align-items: flex-start; }
.mybox-head h3 { display: flex; align-items: center; gap: 0.45rem; }
.mybox-view-toggle { display: flex; flex-wrap: wrap; gap: 0.35rem; }
.mybox-view-toggle .filter { white-space: nowrap; }
.mybox-toolbar { display: flex; align-items: center; flex-wrap: wrap; gap: 0.55rem; padding: 0.65rem 0.75rem; border: 1px solid var(--line); border-radius: var(--radius-sm); background: rgba(148, 163, 184, 0.04); }
.mybox-folder-filter { display: inline-flex; align-items: center; gap: 0.4rem; color: var(--muted-light); font-size: 0.78rem; font-weight: 700; }
.mybox-folder-filter select, .mybox-document-folder select, .folder-dialog-field select {
  min-height: 32px; max-width: 20rem; padding: 0.25rem 0.45rem; border: 1px solid var(--line-strong);
  border-radius: 6px; background: var(--surface); color: var(--text); font: inherit; font-size: 0.76rem;
}
.mybox-summary { flex: 1 1 auto; min-width: 12rem; color: var(--muted); font-size: 0.76rem; }
.mybox-document-list { display: grid; gap: 0; border-top: 1px solid var(--line); }
.mybox-document-row {
  display: grid; grid-template-columns: auto minmax(0, 1fr) minmax(9rem, 0.75fr) auto; align-items: center;
  gap: 0.75rem; min-width: 0; padding: 0.7rem 0.25rem; border-bottom: 1px solid var(--line);
}
.mybox-document-row:hover { background: rgba(148, 163, 184, 0.06); }
.mybox-file-icon { display: grid; place-items: center; width: 2rem; height: 2rem; border-radius: 6px; background: rgba(79, 70, 229, 0.22); color: var(--cyan); font-size: 0.74rem; font-weight: 800; }
.mybox-document-copy { display: grid; gap: 0.15rem; min-width: 0; }
.mybox-document-copy strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mybox-document-copy small, .mybox-folder-path { color: var(--muted); font-size: 0.7rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mybox-folder-path { color: var(--cyan); }
.mybox-document-folder { display: inline-flex; align-items: center; gap: 0.25rem; min-width: 0; color: var(--muted); }
.mybox-document-folder select { width: 100%; min-width: 0; }
.mybox-document-actions { display: inline-flex; align-items: center; justify-content: flex-end; gap: 0.3rem; flex-wrap: wrap; }
.mybox-pagination { display: flex; align-items: center; justify-content: center; flex-wrap: wrap; gap: 0.3rem; padding-top: 0.55rem; }
.mybox-page-status { color: var(--muted); font-size: 0.74rem; font-weight: 700; }
.mybox-tree { min-height: 6rem; padding: 0.55rem 0.25rem; border: 1px solid var(--line); border-radius: var(--radius-sm); background: rgba(148, 163, 184, 0.03); overflow: auto; }
.mybox-tree-list { display: grid; gap: 0.25rem; margin: 0; padding: 0 0 0 1rem; list-style: none; }
.mybox-tree-list.is-root { padding-left: 0; }
.mybox-tree-folder { position: relative; }
.mybox-tree-folder::before { content: ""; position: absolute; left: -0.65rem; top: 1.25rem; bottom: 0.1rem; border-left: 1px dashed var(--line-strong); }
.mybox-tree-node { display: flex; align-items: center; flex-wrap: wrap; gap: 0.45rem; min-height: 2.1rem; padding: 0.35rem 0.45rem; border-radius: 6px; }
.mybox-tree-node:hover { background: rgba(34, 211, 238, 0.07); }
.mybox-tree-name { display: inline-flex; align-items: center; gap: 0.25rem; min-width: 10rem; }
.mybox-tree-count { color: var(--muted); font-size: 0.7rem; }
.mybox-tree-actions { display: inline-flex; align-items: center; gap: 0.15rem; margin-left: auto; }
.mybox-tree-document { display: flex; align-items: center; gap: 0.35rem; min-height: 1.8rem; padding-left: 1.4rem; color: var(--muted-light); font-size: 0.76rem; }
.mybox-tree-document .link-button { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; text-align: left; }
.mybox-tree-document small { color: var(--muted); white-space: nowrap; }
.folder-dialog { width: min(92vw, 430px); padding: 0; border: 1px solid var(--line-strong); border-radius: var(--radius); background: var(--surface-raised); color: var(--text); box-shadow: 0 24px 80px rgba(2, 6, 23, 0.5); }
.folder-dialog::backdrop { background: rgba(2, 6, 23, 0.68); backdrop-filter: blur(3px); }
.folder-dialog-body { display: grid; gap: 0.75rem; padding: 1.35rem; }
.folder-dialog-icon { font-size: 1.8rem; }
.folder-dialog-body h2 { margin: 0; }
.folder-dialog-body p { margin: 0; }
.folder-dialog-field { display: grid; gap: 0.3rem; color: var(--muted-light); font-size: 0.78rem; font-weight: 700; }
.folder-dialog-field input, .folder-dialog-field select { width: 100%; box-sizing: border-box; min-height: 38px; padding: 0.45rem 0.6rem; }
.folder-dialog-field input { border: 1px solid var(--line-strong); border-radius: 6px; background: var(--surface); color: var(--text); font: inherit; }
.folder-dialog-actions { display: flex; justify-content: flex-end; gap: 0.45rem; padding-top: 0.35rem; }
.manual-table-dialog { width: min(92vw, 430px); padding: 0; border: 1px solid var(--line-strong); border-radius: var(--radius); background: var(--surface-raised); color: var(--text); box-shadow: 0 24px 80px rgba(2, 6, 23, 0.5); }
.manual-table-dialog::backdrop { background: rgba(2, 6, 23, 0.68); backdrop-filter: blur(3px); }
.manual-table-dialog-body { display: grid; gap: 0.7rem; padding: 1.25rem; }
.manual-table-dialog-body h2, .manual-table-dialog-body p { margin: 0; }
.manual-table-dialog-icon { font-size: 1.7rem; color: var(--cyan); }
.manual-table-fields { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0.65rem; }
.manual-table-field { display: grid; gap: 0.28rem; color: var(--muted-light); font-size: 0.78rem; font-weight: 800; }
.manual-table-field input { width: 100%; box-sizing: border-box; min-height: 38px; padding: 0.45rem 0.6rem; border: 1px solid var(--line-strong); border-radius: 6px; background: var(--surface); color: var(--text); font: inherit; }
.manual-table-field small { color: var(--muted); font-size: 0.68rem; font-weight: 600; }
.manual-table-error { min-height: 1.1rem; color: #fda4af; font-size: 0.76rem; }
.manual-table-dialog-actions { display: flex; justify-content: flex-end; gap: 0.45rem; padding-top: 0.2rem; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }
.review-status-card { display: grid; gap: 0.8rem; padding: 1.25rem; }
.review-status-card .panel-head { align-items: flex-start; }
.review-action-row { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding-top: 0.75rem; border-top: 1px solid var(--line); }
.review-action-row > div { min-width: 0; }
.review-action-row > button { flex: 0 0 auto; }
.review-action-row p { margin: 0.25rem 0 0; color: var(--muted); font-size: 0.78rem; }
.review-summary { color: var(--cyan); font-size: 0.78rem; font-weight: 700; text-align: right; }
.review-target-list { display: grid; gap: 0.45rem; }
.review-target-item { display: flex; align-items: center; justify-content: space-between; gap: 0.75rem; padding: 0.6rem 0.7rem; border: 1px solid var(--line); border-radius: var(--radius-sm); }
.review-target-item > div { display: grid; gap: 0.2rem; min-width: 0; }
.review-target-item strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.review-target-item span { color: var(--muted); font-size: 0.7rem; }
#toast {
  position: fixed; left: 50%; bottom: 24px; z-index: 2000;
  transform: translate(-50%, 150%); width: min(420px, 90vw);
  padding: 0.9rem 1.2rem; border-radius: var(--radius);
  background: var(--surface-raised); border: 1px solid var(--line);
  box-shadow: var(--shadow-lg); font-size: 0.88rem; font-weight: 500;
  display: flex; align-items: center; gap: 0.6rem; transition: transform 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}
body:has(.studio-ai-dock:not([hidden])) #toast { bottom: 6.25rem; }
#toast:empty { display: none; }
#toast.show { transform: translate(-50%, 0); }
#toast.ok { border-color: var(--green); color: #34d399; }
#toast.error { border-color: var(--red); color: #fda4af; }

/* Responsive adjustments */
@media (min-width: 1081px) {
  @container studio-layout (min-width: 920px) {
    .gdocs-layout.chat-open .studio-editor-column {
      display: grid;
      grid-template-columns: minmax(0, 1fr) minmax(280px, 320px);
      grid-template-rows: auto minmax(0, 1fr);
      grid-template-areas:
        "toolbar chat"
        "canvas chat";
    }
    .gdocs-layout.chat-open .gdocs-toolbar { grid-area: toolbar; }
    .gdocs-layout.chat-open .gdocs-canvas-wrap { grid-area: canvas; }
    .gdocs-layout.chat-open .studio-ai-dock {
      grid-area: chat; align-self: start; margin-top: 0; box-shadow: none;
    }
  }
  .studio-ai-status {
    grid-template-columns: auto minmax(0, 1fr) auto;
    grid-template-areas:
      "emoji text close"
      "track track track";
  }
}
@media (max-width: 1080px) {
  .dashboard-grid { grid-template-columns: 1fr; }
  .gdocs-layout, .gdocs-layout.chat-open {
    grid-template-columns: 1fr;
    grid-template-rows: minmax(0, 1fr);
    grid-template-areas: "editor";
  }
  .gdocs-paper { padding: 40px 30px; }
}
@media (max-width: 900px) {
  .shell:has(#studio:not(.hidden)) {
    display: flex; flex-direction: column;
    height: 100dvh; max-height: 100dvh; overflow: hidden;
  }
  /* 스튜디오 모바일 레이아웃은 메뉴와 본문을 세로로 쌓아 본문이
     사이드 메뉴의 가로 intrinsic width 뒤로 밀리지 않게 한다. */
  .shell:has(#studio:not(.hidden)) .workspace-row {
    flex-direction: column; min-width: 0;
  }
  .shell:has(#studio:not(.hidden)) .sidebar {
    position: relative; height: auto; width: auto; flex: 0 0 auto;
    flex-direction: row; flex-wrap: nowrap; align-items: center;
    gap: 0.45rem; padding: 0.45rem 0.7rem; overflow: hidden;
  }
  .shell:has(#studio:not(.hidden)) .sidebar nav {
    flex-direction: row; flex: 1; min-width: 0; overflow-x: auto;
  }
  .shell:has(#studio:not(.hidden)) .nav-item { padding: 0.4rem 0.55rem; font-size: 0.78rem; }
  .shell:has(#studio:not(.hidden)) .brand small { display: none; }
  .shell:has(#studio:not(.hidden)) main {
    display: flex; flex-direction: column; flex: 1; min-height: 0;
    height: auto; max-height: none; overflow: hidden; padding: 0.65rem;
  }
  #studio:not(.hidden) { overflow: hidden; flex: 1; min-height: 0; }
  .studio-editor-column { overflow: hidden; }
  .gdocs-canvas-wrap { min-height: 0; }
  .gdocs-layout.chat-open .studio-ai-dock {
    position: static; left: auto; right: auto; bottom: auto; margin-top: 0.35rem;
  }
  .gdocs-layout.chat-open .studio-editor-column { padding-bottom: 0; }
  .studio-header-card { grid-template-columns: 1fr; padding: 0.35rem 0.65rem; }
  .studio-doc-info { min-width: 0; }
  .studio-doc-info select { min-width: 0; }
  .studio-header-card .toolbar-actions { justify-content: flex-start; }
  .toolbar-scroll-hint {
    display: block; margin: 0; padding: 0.2rem 0.55rem; color: var(--muted-light);
    background: rgba(34, 211, 238, 0.07); font-size: 0.68rem; text-align: right;
  }
  .gdocs-toolbar { flex-wrap: nowrap; overflow-x: auto; scrollbar-gutter: stable; }
  .gdocs-toolbar .save-indicator {
    display: inline-flex; flex: 0 0 auto; margin-left: 0; max-width: 9rem;
    padding: 0 0.35rem; white-space: nowrap;
  }
  .gdocs-toolbar .save-indicator #saveStatusText {
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  }
  .manual-insert-group { padding-right: 0.35rem; }
  .toolbar-group-caption { font-size: 0.68rem; }
  /* 표는 컬럼을 욱여넣어 글자를 깨지 않는다. 폭을 그대로 유지한 채 표만 좌우로 훑어보게 하고,
     본문 글은 (표와 달리) 이미 가변 폭이라 화면 너비에 맞춰 그대로 줄바꿈된다.
     스튜디오 레이아웃 자체가 이 900px 기준으로 모바일 전환되므로 표 스크롤도 같은 기준을 쓴다 —
     720px에만 걸면 721~900px 구간에서 표가 좁아진 화면 폭 밖으로 그냥 넘쳐 아무 스크롤 수단이 없다. */
  .doc-block:has(> table) { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  /* max-content는 안 된다: 셀 안 긴 문장이 줄바꿈 없이 한 줄로 늘어나 표 하나가 수천 px가 된다
     (실측: "핵심 내용" 셀 93자 문장). 대신 칸마다 최소 폭만 보장해 글은 여전히 줄바꿈되게 하고,
     칸 수가 많아 그 합이 화면보다 넓을 때만 좌우로 스크롤되게 한다. */
  .doc-block:has(> table) > table { width: auto; min-width: 0; }
  .gdocs-paper.native-layout .doc-block:has(> table) > table {
    max-width: 100%; min-width: 0;
  }
  .doc-block:has(> table) th, .doc-block:has(> table) td { min-width: 0; }
}
@media (max-width: 720px) {
  .metric-grid { grid-template-columns: repeat(2, 1fr); }
  .summary-grid { grid-template-columns: repeat(2, 1fr); }
  .recent-document-row { grid-template-columns: minmax(0, 1fr) auto; gap: 0.35rem 0.55rem; }
  .recent-document-facts { grid-column: 1; grid-row: 2; text-align: left; }
  .recent-document-actions { grid-column: 2; grid-row: 1 / span 2; }
  .conversion-mode-options { grid-template-columns: 1fr; }
  .resource-upload-grid { grid-template-columns: 1fr; }
  .resource-hero, .review-hero, .review-action-row { flex-direction: column; }
  .resource-hero-actions { width: 100%; justify-content: flex-start; }
  .review-summary { text-align: left; }
  .resource-item { align-items: flex-start; flex-direction: column; }
  .resource-item-actions { width: 100%; justify-content: space-between; }
  .studio-header-card { grid-template-columns: 1fr; }
  .manual-table-fields { grid-template-columns: 1fr 1fr; }
  .mybox-head { display: grid; }
  .mybox-view-toggle { width: 100%; }
  .mybox-document-row { grid-template-columns: auto minmax(0, 1fr) auto; gap: 0.45rem; }
  .mybox-document-folder, .mybox-document-actions { grid-column: 2 / -1; }
  .mybox-document-actions { justify-content: flex-start; }
  .processing-settings-head { display: grid; gap: 0.45rem; }
  .processing-settings-head p { max-width: none; text-align: left; }
  .studio-ai-status {
    grid-template-columns: auto minmax(0, 1fr) auto;
    grid-template-areas:
      "emoji text close"
      "track track track";
  }
  #studio:not(.hidden) .export-bar {
    display: block; padding: 0.55rem 0.65rem; overflow-x: auto;
  }
  #studio:not(.hidden) .export-bar > div:first-child { display: none; }
  #studio:not(.hidden) .export-bar .toolbar-actions { display: flex; flex-wrap: nowrap; width: max-content; }
  .gdocs-layout, .gdocs-layout.chat-open {
    grid-template-areas: "editor";
    grid-template-rows: minmax(0, 1fr);
  }
}
