:root {
  --bg-0: #04050a;
  --glass: rgba(255, 255, 255, 0.055);
  --glass-strong: rgba(255, 255, 255, 0.09);
  --panel: rgba(20, 22, 32, 0.74);
  --panel-strong: rgba(24, 26, 38, 0.9);
  --stroke: rgba(255, 255, 255, 0.09);
  --stroke-strong: rgba(255, 255, 255, 0.16);
  --text-1: rgba(255, 255, 255, 0.92);
  --text-2: rgba(255, 255, 255, 0.58);
  --text-3: rgba(255, 255, 255, 0.36);
  --blue: #0a84ff;
  --cyan: #64d2ff;
  --indigo: #8e8cff;
  --purple: #bf5af2;
  --green: #30d158;
  --amber: #ffd60a;
  --red: #ff6961;
  --radius-l: 22px;
  --radius-m: 14px;
  --radius-s: 10px;
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Display", "SF Pro Text",
          "Apple SD Gothic Neo", "Pretendard", "Malgun Gothic", sans-serif;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0; overflow: hidden;
  font: 14px/1.5 var(--font); letter-spacing: 0;
  background: var(--bg-0); color: var(--text-1);
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3, p, dl, dd { margin: 0; }
h2 { font-size: 18px; font-weight: 700; letter-spacing: -0.02em; line-height: 1.4; }
h3 { font-size: 14px; font-weight: 600; letter-spacing: -0.01em; }
small { font-size: 11.5px; color: var(--text-3); }
a { color: inherit; text-decoration: none; }
[hidden] { display: none !important; }
.muted { color: var(--text-3); }
:focus-visible { outline: 2px solid rgba(100, 210, 255, 0.75); outline-offset: 2px; }
::selection { background: rgba(100, 210, 255, 0.3); }

svg {
  width: 17px; height: 17px; flex-shrink: 0;
  fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round;
}

button, input, select, textarea { font: inherit; letter-spacing: 0; color: inherit; }
button, a, input, select, textarea { -webkit-tap-highlight-color: transparent; }
button {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  min-height: 32px; padding: 7px 14px;
  font-size: 12.5px; font-weight: 500; line-height: 1.3; color: var(--text-1);
  background: rgba(255, 255, 255, 0.07); border: 1px solid var(--stroke); border-radius: 100px;
  cursor: pointer; touch-action: manipulation;
  transition: background 0.15s, border-color 0.15s, box-shadow 0.2s, transform 0.15s, color 0.15s;
}
button svg { width: 15px; height: 15px; }
button:hover { background: rgba(255, 255, 255, 0.12); border-color: var(--stroke-strong); }
button:active { transform: scale(0.97); }
button:disabled { opacity: 0.45; cursor: default; transform: none; }
button.primary, .mini-btn.primary {
  color: #fff; border-color: transparent;
  background: linear-gradient(135deg, var(--blue), #5e5ce6);
  box-shadow: 0 3px 14px rgba(10, 132, 255, 0.35);
}
button.primary:hover { box-shadow: 0 5px 20px rgba(10, 132, 255, 0.5); }
button.danger { color: var(--red); border-color: rgba(255, 105, 97, 0.28); background: rgba(255, 105, 97, 0.08); }
button.danger:hover { background: rgba(255, 105, 97, 0.16); }
.icon-button { width: 32px; height: 32px; padding: 0; border-color: transparent; background: rgba(255, 255, 255, 0.06); }
.mini-btn { font-size: 12px; font-weight: 600; }

input, select, textarea {
  min-width: 0; max-width: 100%; padding: 9px 12px;
  background: rgba(255, 255, 255, 0.05); border: 1px solid var(--stroke); border-radius: var(--radius-s);
  outline: none; transition: border-color 0.15s, box-shadow 0.15s;
}
input:focus, select:focus, textarea:focus { border-color: rgba(100, 210, 255, 0.5); box-shadow: 0 0 0 3px rgba(100, 210, 255, 0.1); }
input::placeholder, textarea::placeholder { color: var(--text-3); }
select { appearance: none; -webkit-appearance: none; cursor: pointer; }
select option { background: #181a26; color: var(--text-1); }
textarea { resize: vertical; line-height: 1.7; }
dialog label, .gmail-form label { display: flex; flex-direction: column; gap: 7px; font-size: 12px; color: var(--text-2); }

.badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 9px; border-radius: 100px;
  font-size: 10.5px; font-weight: 600; line-height: 1.35; white-space: nowrap;
}
.badge.neutral { background: rgba(255, 255, 255, 0.08); color: var(--text-2); }
.badge.good { background: rgba(48, 209, 88, 0.14); color: var(--green); }
.badge.warning { background: rgba(255, 214, 10, 0.13); color: var(--amber); }
.badge.bad { background: rgba(255, 105, 97, 0.14); color: var(--red); }

/* ── 배경 레이어 ─────────────────────────────────
   캔버스가 맨 아래, 유리 UI가 위다. 빈 영역(.app·.hero 등)은 포인터를 그대로 흘려보내야
   화면 가운데의 노드도 클릭된다 — 실제 조작 요소만 포인터를 다시 받는다. */
#graph { position: fixed; inset: 0; width: 100%; height: 100%; z-index: 0; display: block; }
#dustfx { position: fixed; inset: 0; width: 100%; height: 100%; z-index: 3; pointer-events: none; }
.vignette {
  position: fixed; inset: 0; z-index: 1; pointer-events: none;
  background:
    radial-gradient(ellipse 80% 60% at 50% 42%, transparent 40%, rgba(4, 5, 10, 0.55) 100%),
    linear-gradient(to bottom, rgba(4, 5, 10, 0.7) 0%, transparent 12%, transparent 78%, rgba(4, 5, 10, 0.85) 100%);
}
/* jaegukang.com ↔ brain ↔ claw 순환 이동 — .app보다 위(z:4)라 어떤 화면에서도 가려지지 않는다.
   좁은 화면은 topbar·ask-wrap과 겹쳐서 620px 아래 반응형 규칙에서 감춘다. */
.portal-nav { position: fixed; inset: 0; z-index: 4; pointer-events: none; }
.portal-arrow {
  position: absolute; top: 50%; transform: translateY(-50%);
  width: 40px; height: 40px; border-radius: 999px; pointer-events: auto;
  display: flex; align-items: center; justify-content: center;
  background: var(--glass); border: 1px solid var(--stroke); color: var(--text-2);
  backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px);
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}
.portal-arrow svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; }
.portal-arrow:hover { background: var(--glass-strong); border-color: var(--stroke-strong); color: var(--text-1); }
.portal-arrow.left { left: 14px; }
.portal-arrow.right { right: 14px; }

.app { position: relative; z-index: 2; height: 100vh; height: 100dvh; display: flex; flex-direction: column; }
.app, .topbar, .workspace, .hero, .hero-pad, .ask-wrap, .ask-hints, .answer { pointer-events: none; }
.brand, .top-right, .collect, .hero-title, .hero-sub, .mode-switch, .askbar, .ask-hints > *, .answer.show { pointer-events: auto; }
.workspace { flex: 1; min-height: 0; display: flex; align-items: stretch; }

/* ── 상단 바 ─────────────────────────────────── */
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 20px 32px; flex-shrink: 0; }
.brand { display: flex; align-items: center; gap: 12px; }
.brand-mark {
  width: 34px; height: 34px; border-radius: 9px; display: grid; place-items: center;
  background: linear-gradient(135deg, var(--blue), #5e5ce6);
  box-shadow: 0 0 24px rgba(10, 132, 255, 0.45);
}
.brand-mark svg { width: 18px; height: 18px; stroke: #fff; }
.brand-name { font-size: 16px; font-weight: 600; letter-spacing: -0.02em; }
.brand-name em { font-style: normal; color: var(--cyan); }
.brand-sub { font-size: 11px; color: var(--text-3); letter-spacing: 0.02em; margin-top: 1px; }
.top-right { display: flex; align-items: center; gap: 12px; min-width: 0; }
.db-status, .pill-btn {
  display: flex; align-items: center; gap: 8px;
  background: var(--glass); border: 1px solid var(--stroke); border-radius: 100px;
  -webkit-backdrop-filter: blur(24px) saturate(160%); backdrop-filter: blur(24px) saturate(160%);
}
.db-status { font-size: 12px; color: var(--text-2); padding: 8px 14px; min-width: 0; white-space: nowrap; }
.db-status #model-status { overflow: hidden; text-overflow: ellipsis; max-width: 220px; }
.db-dot {
  width: 7px; height: 7px; border-radius: 50%; flex-shrink: 0;
  background: var(--green); box-shadow: 0 0 8px rgba(48, 209, 88, 0.8);
  animation: breathe 2.4s ease-in-out infinite;
}
.db-dot.idle { background: var(--amber); box-shadow: 0 0 8px rgba(255, 214, 10, 0.8); }
@keyframes breathe { 50% { opacity: 0.45; } }
.pill-btn { padding: 9px 16px; min-height: 38px; font-size: 13px; color: var(--text-1); }
.pill-btn:hover { background: var(--glass-strong); border-color: var(--stroke-strong); }
.pill-btn svg { width: 14px; height: 14px; opacity: 0.65; }
.icon-btn { width: 38px; height: 38px; padding: 0; justify-content: center; }
.icon-btn svg { width: 17px; height: 17px; opacity: 0.75; }

.dropdown { position: relative; }
.dropdown .chev { transition: transform 0.25s cubic-bezier(0.3, 0.9, 0.4, 1); }
.dropdown.open .chev { transform: rotate(180deg); }
.dropdown-menu {
  position: absolute; top: calc(100% + 10px); right: 0; z-index: 30;
  min-width: 220px; padding: 6px;
  background: rgba(22, 24, 34, 0.86); border: 1px solid var(--stroke-strong); border-radius: var(--radius-m);
  -webkit-backdrop-filter: blur(40px) saturate(180%); backdrop-filter: blur(40px) saturate(180%);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.55);
  opacity: 0; transform: translateY(-6px) scale(0.98); transform-origin: top right; pointer-events: none;
  transition: opacity 0.22s, transform 0.22s cubic-bezier(0.3, 0.9, 0.4, 1);
}
.dropdown.open .dropdown-menu { opacity: 1; transform: none; pointer-events: auto; }
.menu-item {
  width: 100%; justify-content: space-between; padding: 10px 12px; min-height: 0;
  font-size: 13px; border: 0; border-radius: var(--radius-s); background: none;
}
.menu-item:hover { background: rgba(255, 255, 255, 0.08); }
.menu-item .count { font-size: 11px; color: var(--text-3); }
.menu-item.active, .menu-item.active .count { color: var(--cyan); }
.menu-note { margin: 4px 0 0; padding: 9px 12px 6px; border-top: 1px solid var(--stroke); font-size: 11px; line-height: 1.5; color: var(--text-3); }

/* ── 히어로 ──────────────────────────────────────
   처음엔 제목·질문창이 세로 가운데, 답변 카드를 열면 한 번에 맨 위로 올라간다.
   위·아래 빈 스페이서가 둘 다 flex-grow:1이면 가운데, 위쪽만 0이면 맨 위다 —
   justify-content는 전이가 안 되지만 flex-grow는 숫자라 전이가 걸린다. */
.hero {
  flex: 1; min-width: 0; min-height: 0; overflow: hidden;
  display: flex; flex-direction: column; align-items: center; padding: 24px;
}
.hero-title, .hero-sub, .ask-wrap { flex-shrink: 0; }
.hero-pad { flex: 1 1 0; min-height: 0; transition: flex-grow 0.55s cubic-bezier(0.3, 0.8, 0.3, 1); }
.hero.answering .hero-pad-top { flex-grow: 0; }
.hero-title {
  font-size: clamp(26px, 3.4vw, 40px); font-weight: 700; letter-spacing: -0.03em; line-height: 1.25; text-align: center;
  background: linear-gradient(180deg, #fff 30%, rgba(255, 255, 255, 0.6));
  -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent;
  animation: rise 0.8s cubic-bezier(0.2, 0.8, 0.3, 1) backwards;
}
.hero-sub { margin-top: 10px; font-size: 14px; color: var(--text-2); letter-spacing: -0.01em; text-align: center; animation: rise 0.8s 0.08s cubic-bezier(0.2, 0.8, 0.3, 1) backwards; }
/* backwards, never both: a lingering fill keeps the element a backdrop root, so the
   backdrop-filter glass inside it stops blurring the graph canvas behind. */
@keyframes rise { from { opacity: 0; transform: translateY(14px); } }

.ask-wrap { width: min(760px, 100%); margin-top: 32px; animation: rise 0.8s 0.16s cubic-bezier(0.2, 0.8, 0.3, 1) backwards; }
.mode-switch {
  display: flex; gap: 4px; padding: 4px; margin: 0 auto 14px; width: max-content; max-width: 100%;
  background: var(--glass); border: 1px solid var(--stroke); border-radius: 100px;
  -webkit-backdrop-filter: blur(24px) saturate(160%); backdrop-filter: blur(24px) saturate(160%);
}
.mode-btn {
  min-height: 0; padding: 7px 16px; gap: 6px;
  font-size: 12.5px; font-weight: 500; color: var(--text-2);
  background: none; border: 0; border-radius: 100px;
}
.mode-btn:hover { color: var(--text-1); background: none; }
.mode-btn.active { background: rgba(255, 255, 255, 0.12); color: var(--text-1); box-shadow: 0 2px 10px rgba(0, 0, 0, 0.3); }
.mode-count {
  min-width: 17px; padding: 1px 5px; border-radius: 100px;
  font-size: 10px; font-weight: 700; color: #fff; background: rgba(191, 90, 242, 0.55);
}
.askbar {
  display: flex; align-items: center; gap: 12px;
  padding: 8px 8px 8px 22px;
  background: rgba(255, 255, 255, 0.07); border: 1px solid var(--stroke-strong); border-radius: 100px;
  -webkit-backdrop-filter: blur(30px) saturate(170%); backdrop-filter: blur(30px) saturate(170%);
  box-shadow: 0 12px 48px rgba(0, 0, 0, 0.4), inset 0 1px 0 rgba(255, 255, 255, 0.08);
  transition: border-color 0.25s, box-shadow 0.25s;
}
.askbar:focus-within {
  border-color: rgba(100, 210, 255, 0.5);
  box-shadow: 0 12px 48px rgba(0, 0, 0, 0.4), 0 0 0 4px rgba(100, 210, 255, 0.12), inset 0 1px 0 rgba(255, 255, 255, 0.08);
}
.askbar .glyph { opacity: 0.5; }
.askbar input { flex: 1; padding: 0; background: none; border: 0; border-radius: 0; box-shadow: none; font-size: 15px; letter-spacing: -0.01em; }
.askbar input:focus { box-shadow: none; }
.ask-send {
  width: 40px; height: 40px; padding: 0; flex-shrink: 0; border: 0; border-radius: 50%;
  background: linear-gradient(135deg, var(--blue), #5e5ce6);
  box-shadow: 0 4px 16px rgba(10, 132, 255, 0.4);
}
.ask-send svg { width: 16px; height: 16px; stroke: #fff; stroke-width: 2.2; }
.ask-send:hover { transform: scale(1.06); box-shadow: 0 6px 22px rgba(10, 132, 255, 0.55); }
.ask-hints { display: flex; justify-content: center; flex-wrap: wrap; gap: 8px; margin-top: 14px; min-height: 31px; }
.hint {
  min-height: 0; padding: 7px 14px; max-width: 100%;
  font-size: 12px; font-weight: 400; color: var(--text-2);
  background: var(--glass); border-color: var(--stroke);
  -webkit-backdrop-filter: blur(20px); backdrop-filter: blur(20px);
}
.hint:hover { background: var(--glass-strong); color: var(--text-1); }
.hint svg { width: 13px; height: 13px; opacity: 0.7; }

/* ── 답변 카드 ───────────────────────────────── */
.answer {
  width: min(760px, 100%); margin-top: 20px;
  flex: 0 1 auto; min-height: 0; display: flex; flex-direction: column;
  max-height: 0; opacity: 0; overflow: hidden;
  transition: max-height 0.5s cubic-bezier(0.3, 0.8, 0.3, 1), opacity 0.4s;
}
.answer.show { max-height: 60vh; opacity: 1; }
.answer-card {
  flex: 1 1 auto; min-height: 0; overflow-y: auto;
  padding: 22px 26px;
  background: var(--panel); border: 1px solid var(--stroke-strong); border-radius: var(--radius-l);
  -webkit-backdrop-filter: blur(40px) saturate(180%); backdrop-filter: blur(40px) saturate(180%);
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.5);
}
.answer-card::-webkit-scrollbar, dialog::-webkit-scrollbar, .import-results::-webkit-scrollbar { width: 8px; }
.answer-card::-webkit-scrollbar-thumb, dialog::-webkit-scrollbar-thumb, .import-results::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, 0.12); border-radius: 4px; }
.answer-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.answer-tag {
  display: inline-flex; align-items: center; gap: 7px; min-width: 0;
  font-size: 11px; font-weight: 600; letter-spacing: 0.04em; text-transform: uppercase; color: var(--cyan);
}
.answer-tag #answer-scope { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pulse-dot { width: 6px; height: 6px; border-radius: 50%; flex-shrink: 0; background: var(--cyan); box-shadow: 0 0 8px var(--cyan); }
.answer-close { min-height: 0; padding: 4px 10px; font-size: 12.5px; color: var(--text-3); background: none; border: 0; border-radius: 6px; }
.answer-close:hover { color: var(--text-1); background: rgba(255, 255, 255, 0.08); }
.composing { font-size: 13px; color: var(--text-2); }
.caret { display: inline-block; width: 2px; height: 1em; background: var(--cyan); vertical-align: text-bottom; animation: blink 0.9s step-end infinite; }
@keyframes blink { 50% { opacity: 0; } }

.answer-header { display: flex; align-items: baseline; justify-content: space-between; gap: 14px; margin-bottom: 12px; }
.answer-header h3 { font-size: 15px; line-height: 1.6; overflow-wrap: anywhere; }
.answer-header small { white-space: nowrap; }
.claims { font-size: 14px; line-height: 1.8; }
.claim { margin-bottom: 8px; overflow-wrap: anywhere; }
.outcome { margin: 4px 0 2px; }
.cite-tag {
  min-height: 0; padding: 0 6px; margin: 0 3px; vertical-align: 1px;
  font-size: 11px; font-weight: 600; color: var(--cyan);
  background: rgba(100, 210, 255, 0.1); border: 1px solid rgba(100, 210, 255, 0.25); border-radius: 6px;
}
.cite-tag:hover { background: rgba(100, 210, 255, 0.22); border-color: rgba(100, 210, 255, 0.4); }
.applied-note { margin-top: 10px; }
.sources-label {
  margin: 18px 0 10px; font-size: 11px; font-weight: 600; letter-spacing: 0.05em;
  text-transform: uppercase; color: var(--text-3);
}
#answer-body > .sources-label:first-child { margin-top: 0; }
.source-chips { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 8px; }
.source-chip {
  justify-content: flex-start; align-items: flex-start; gap: 10px; min-height: 0; padding: 10px 12px;
  text-align: left; background: rgba(255, 255, 255, 0.05); border-color: var(--stroke); border-radius: var(--radius-s);
}
.source-chip:hover { background: rgba(100, 210, 255, 0.08); border-color: rgba(100, 210, 255, 0.3); transform: translateY(-1px); }
.source-icon { width: 26px; height: 26px; border-radius: 7px; display: grid; place-items: center; flex-shrink: 0; }
.source-icon svg { width: 13px; height: 13px; }
.t-mail { background: rgba(191, 90, 242, 0.15); color: var(--purple); }
.t-wiki { background: rgba(100, 210, 255, 0.15); color: var(--cyan); }
.source-text { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.source-title { font-size: 12px; font-weight: 600; line-height: 1.35; color: var(--text-1); overflow-wrap: anywhere; }
.snippet {
  font-size: 11.5px; line-height: 1.5; color: var(--text-2); overflow-wrap: anywhere;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.source-detail { font-size: 10.5px; color: var(--text-3); overflow-wrap: anywhere; }
.wiki-related { margin-top: 4px; display: flex; flex-wrap: wrap; gap: 8px; }
.wiki-related .sources-label { width: 100%; margin-bottom: 2px; }
.wiki-link { justify-content: flex-start; text-align: left; color: var(--text-1); background: rgba(142, 140, 255, 0.1); border-color: rgba(142, 140, 255, 0.3); overflow-wrap: anywhere; }
.wiki-link:hover { background: rgba(142, 140, 255, 0.2); }
.wiki-link svg { color: var(--indigo); }
.answer-footer {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  margin-top: 18px; padding-top: 12px; border-top: 1px solid var(--stroke);
  font-size: 11px; color: var(--text-3);
}
.inline-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.history { margin-top: 22px; }
.history-item { border-top: 1px solid var(--stroke); }
.history-item > summary {
  display: flex; align-items: baseline; justify-content: space-between; gap: 12px;
  padding: 11px 2px; cursor: pointer; list-style: none; font-size: 13px; color: var(--text-2);
}
.history-item > summary::-webkit-details-marker { display: none; }
.history-item > summary span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.history-item > summary:hover { color: var(--text-1); }
.history-item[open] > summary { color: var(--text-1); }
.history-item > .answer-item { padding: 4px 0 16px; }

.empty { display: grid; place-items: center; align-content: center; gap: 12px; min-height: 200px; text-align: center; color: var(--text-3); padding: 20px; }
.empty > svg { width: 34px; height: 34px; stroke-width: 1.2; color: var(--text-3); }
.empty h2 { font-size: 14px; font-weight: 600; color: var(--text-2); }
.empty-line { padding: 26px 0; text-align: center; font-size: 12.5px; color: var(--text-3); }
.progress { margin-top: 12px; font-size: 12px; color: var(--cyan); }
.warning-text { margin: 10px 0; font-size: 12px; line-height: 1.7; color: var(--amber); overflow-wrap: anywhere; }

/* ── 메일함 ─────────────────────────────────── */
.table-wrap { overflow-x: auto; }
.mail-table { width: 100%; border-collapse: collapse; table-layout: fixed; font-size: 13px; }
.mail-table th {
  padding: 8px 10px; text-align: left; font-size: 10.5px; font-weight: 600; letter-spacing: 0.05em;
  color: var(--text-3); border-bottom: 1px solid var(--stroke);
}
.mail-table td { padding: 12px 10px; border-bottom: 1px solid var(--stroke); vertical-align: middle; overflow-wrap: anywhere; color: var(--text-2); font-size: 12px; }
.mail-table th:first-child, .mail-table td:first-child { width: 52%; padding-left: 2px; }
.mail-table th:nth-child(2) { width: 22%; }
.mail-table th:nth-child(3) { width: 13%; }
.mail-table th:nth-child(4) { width: 13%; }
.mail-table tr:hover td { background: rgba(255, 255, 255, 0.03); }
.mail-table button {
  display: flex; flex-direction: column; align-items: flex-start; gap: 3px; width: 100%;
  min-height: 0; padding: 0; text-align: left; background: none; border: 0; border-radius: 0;
}
.mail-table button:hover .mail-subject { color: var(--cyan); }
.mail-table button:active { transform: none; }
.mail-subject { font-size: 13px; font-weight: 600; line-height: 1.5; color: var(--text-1); overflow-wrap: anywhere; }
.mail-meta { display: flex; align-items: center; gap: 6px; font-size: 11px; color: var(--text-3); }
.mail-meta svg { width: 11px; height: 11px; }
.pagination { display: flex; align-items: center; justify-content: flex-end; gap: 10px; margin-top: 14px; font-size: 12px; color: var(--text-3); }

/* ── 수집함 (우측) ───────────────────────────────
   order:2 — DOM에선 본문보다 먼저 읽히지만 화면에선 오른쪽 끝에 둔다. */
.collect {
  order: 2; flex-shrink: 0; width: 262px; padding: 4px 28px 24px 6px;
  display: flex; flex-direction: column; justify-content: center; justify-content: safe center; gap: 10px; min-height: 0;
  overflow-y: auto; overflow-x: hidden;   /* safe center: on a short screen overflow from the top stays scrollable */
  animation: rise 0.8s 0.24s cubic-bezier(0.2, 0.8, 0.3, 1) backwards;
}
.collect.flash .collect-card { border-color: rgba(100, 210, 255, 0.55); box-shadow: 0 0 0 4px rgba(100, 210, 255, 0.14); }
.collect-title { font-size: 13px; font-weight: 600; letter-spacing: -0.01em; color: var(--text-2); margin-bottom: 2px; }
.drop, .collect-card, .collect-stats {
  position: relative; overflow: hidden; flex-shrink: 0;
  background: var(--glass); border: 1px solid var(--stroke); border-radius: var(--radius-m);
  -webkit-backdrop-filter: blur(30px) saturate(160%); backdrop-filter: blur(30px) saturate(160%);
}
.drop {
  display: flex; align-items: center; gap: 12px; padding: 14px 15px; cursor: pointer;
  transition: background 0.2s, border-color 0.2s, transform 0.25s cubic-bezier(0.3, 0.9, 0.4, 1), box-shadow 0.25s;
}
.drop:hover { background: var(--glass-strong); border-color: var(--stroke-strong); transform: translateX(-3px); }
.drop.dragging {
  border-color: var(--purple); background: rgba(191, 90, 242, 0.08);
  box-shadow: 0 0 0 4px rgba(191, 90, 242, 0.12), 0 12px 40px rgba(0, 0, 0, 0.4); transform: translateX(-4px) scale(1.02);
}
.drop:focus-within { outline: 2px solid rgba(100, 210, 255, 0.75); outline-offset: 2px; }
.drop.processing { pointer-events: none; }
.drop input { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer; }
.drop-icon { width: 34px; height: 34px; border-radius: 9px; display: grid; place-items: center; flex-shrink: 0; background: rgba(191, 90, 242, 0.15); color: var(--purple); }
.drop-text { display: flex; flex-direction: column; min-width: 0; }
.drop-name { font-size: 13px; font-weight: 600; letter-spacing: -0.01em; }
.drop-desc { font-size: 10.5px; line-height: 1.45; color: var(--text-3); margin-top: 2px; }
.drop-progress {
  position: absolute; left: 0; bottom: 0; height: 2.5px; width: 0%; opacity: 0;
  background: linear-gradient(90deg, var(--blue), var(--cyan)); transition: width 0.3s ease;
}
.drop.processing .drop-progress { opacity: 1; }
.import-results { display: flex; flex-direction: column; gap: 6px; max-height: 132px; overflow-y: auto; flex-shrink: 0; }
.import-results:empty { display: none; }
.file-report {
  display: flex; flex-direction: column; gap: 2px; padding: 8px 11px; flex-shrink: 0;
  font-size: 11px; color: var(--text-2);
  background: rgba(255, 255, 255, 0.04); border: 1px solid var(--stroke); border-radius: var(--radius-s);
  animation: rise 0.35s backwards;
}
.file-report .file-name { color: var(--text-1); font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-report .warning-text { margin: 2px 0 0; font-size: 10.5px; }
.collect-card > summary {
  display: flex; align-items: center; gap: 10px; padding: 11px 13px; cursor: pointer; list-style: none;
}
.collect-card > summary::-webkit-details-marker { display: none; }
.collect-card-title { flex: 1; font-size: 13px; font-weight: 600; }
.gmail-body { display: flex; flex-direction: column; gap: 10px; padding: 0 13px 13px; }
.gmail-body > .mini-btn { align-self: flex-start; }
.gmail-form { display: grid; gap: 9px; }
.gmail-form input { width: 100%; font-size: 12px; padding: 7px 10px; }
.gmail-form .mini-btn { justify-self: start; }
.gmail-body .progress { margin: 0; font-size: 11px; }
.gmail-body .progress:empty { display: none; }
.collect-stats { display: grid; grid-template-columns: 1fr 1fr; gap: 1px; padding: 0; background: var(--stroke); }
.collect-stats > div { padding: 10px 13px; background: rgba(12, 14, 22, 0.72); }
.collect-stats dt { font-size: 10.5px; color: var(--text-3); }
.collect-stats dd { font-size: 17px; font-weight: 700; letter-spacing: -0.03em; font-variant-numeric: tabular-nums; }
.collect-stats .warn dd { color: var(--amber); }
.collect-stats .purple dd { color: var(--purple); }
.collect-note { font-size: 11px; line-height: 1.55; color: var(--text-3); }

/* ── 노드 정보 카드 ─────────────────────────────── */
.node-card {
  position: fixed; z-index: 40; width: 268px; padding: 14px 16px;
  background: rgba(24, 26, 38, 0.9); border: 1px solid var(--stroke-strong); border-radius: var(--radius-m);
  -webkit-backdrop-filter: blur(36px) saturate(180%); backdrop-filter: blur(36px) saturate(180%);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.6);
  opacity: 0; pointer-events: none; transform: translateY(6px) scale(0.97);
  transition: opacity 0.2s, transform 0.2s cubic-bezier(0.3, 0.9, 0.4, 1);
}
.node-card.show { opacity: 1; pointer-events: auto; transform: none; }
.node-card-head { display: flex; align-items: center; gap: 9px; margin-bottom: 8px; }
.node-card-title { font-size: 13px; font-weight: 600; letter-spacing: -0.01em; line-height: 1.35; overflow-wrap: anywhere; }
.node-card-meta { font-size: 11px; line-height: 1.7; color: var(--text-3); overflow-wrap: anywhere; }
.node-card-links { margin-top: 8px; padding-top: 8px; border-top: 1px solid var(--stroke); font-size: 11px; color: var(--text-2); }
.node-card-links b { color: var(--cyan); font-weight: 600; }
.node-card-actions { display: flex; gap: 8px; margin-top: 10px; }
.node-card-open { flex: 1; border-radius: var(--radius-s); color: #fff; background: rgba(10, 132, 255, 0.28); border-color: rgba(10, 132, 255, 0.4); }
.node-card-open:hover { background: rgba(10, 132, 255, 0.42); border-color: rgba(10, 132, 255, 0.5); }
.node-card-link {
  display: inline-flex; align-items: center; gap: 5px; padding: 0 12px;
  font-size: 12px; color: var(--text-2); border: 1px solid var(--stroke); border-radius: var(--radius-s);
}
.node-card-link:hover { color: var(--text-1); background: rgba(255, 255, 255, 0.06); }
.node-card-link svg { width: 13px; height: 13px; }

/* ── 대화상자 ───────────────────────────────── */
dialog {
  width: min(520px, calc(100vw - 32px)); max-height: 86dvh; padding: 26px 28px;
  color: var(--text-1); background: var(--panel-strong);
  border: 1px solid var(--stroke-strong); border-radius: var(--radius-l);
  -webkit-backdrop-filter: blur(50px) saturate(180%); backdrop-filter: blur(50px) saturate(180%);
  box-shadow: 0 40px 120px rgba(0, 0, 0, 0.7);
}
dialog[open] { animation: modal-in 0.3s cubic-bezier(0.3, 0.9, 0.4, 1); }
@keyframes modal-in { from { opacity: 0; transform: translateY(16px) scale(0.97); } }
dialog::backdrop { background: rgba(4, 5, 10, 0.55); -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px); }
dialog form { display: grid; gap: 18px; }
.source-dialog { width: min(760px, calc(100vw - 32px)); }
.dialog-heading { display: flex; justify-content: space-between; align-items: center; gap: 15px; }
.dialog-actions { display: flex; justify-content: flex-end; }
.modal-sub { margin: 4px 0 6px; font-size: 12.5px; color: var(--text-3); }
.source-subject { margin: 14px 0 18px; line-height: 1.45; overflow-wrap: anywhere; }
.source-metadata { display: grid; grid-template-columns: 72px 1fr; gap: 9px; margin-bottom: 18px; font-size: 12px; }
.source-metadata dt, .settings-grid dt { color: var(--text-3); }
.source-metadata dd, .settings-grid dd { overflow-wrap: anywhere; }
.source-body {
  max-height: 45dvh; overflow: auto; padding: 16px 18px; margin-bottom: 18px;
  background: rgba(255, 255, 255, 0.035); border: 1px solid var(--stroke); border-radius: var(--radius-m);
}
.source-block { padding: 4px 0; font-size: 13px; line-height: 1.85; white-space: pre-wrap; overflow-wrap: anywhere; }
.source-block.quoted_text, .source-block.signature { padding-left: 13px; font-size: 12px; color: var(--text-3); border-left: 2px solid var(--stroke-strong); }
.section-heading { display: flex; align-items: baseline; justify-content: space-between; gap: 14px; margin: 18px 0 10px; }
.attachments { display: grid; gap: 8px; }
.download { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--cyan); }
.download:hover { text-decoration: underline; }
.download svg { width: 14px; height: 14px; }
.source-actions { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-top: 20px; }
.settings-section { margin-top: 18px; }
.settings-section .sources-label { margin: 0 0 10px; }
.settings-grid {
  display: grid; grid-template-columns: 110px 1fr; gap: 10px 16px; padding: 13px 15px;
  font-size: 12.5px; line-height: 1.6;
  background: rgba(255, 255, 255, 0.04); border: 1px solid var(--stroke); border-radius: var(--radius-m);
}

/* ── 토스트 ─────────────────────────────────── */
.toasts { position: fixed; right: 28px; bottom: 28px; z-index: 70; display: flex; flex-direction: column; align-items: flex-end; gap: 10px; pointer-events: none; }
.toast {
  display: flex; align-items: center; gap: 12px; max-width: 360px; padding: 13px 18px;
  font-size: 13px; pointer-events: auto;
  background: rgba(24, 26, 38, 0.88); border: 1px solid var(--stroke-strong); border-radius: var(--radius-m);
  -webkit-backdrop-filter: blur(30px) saturate(180%); backdrop-filter: blur(30px) saturate(180%);
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.5);
  animation: toast-in 0.35s cubic-bezier(0.2, 0.9, 0.3, 1.2) backwards;
}
.toast.out { animation: toast-out 0.3s ease both; }
@keyframes toast-in { from { opacity: 0; transform: translateX(24px); } }
@keyframes toast-out { to { opacity: 0; transform: translateX(24px); } }
.toast-text { display: flex; flex-direction: column; min-width: 0; overflow-wrap: anywhere; }
.toast-sub { font-size: 11px; color: var(--text-3); margin-top: 1px; }
.toast .check, .toast .warn { width: 18px; height: 18px; border-radius: 50%; flex-shrink: 0; display: grid; place-items: center; font-size: 11px; font-weight: 700; }
.toast .check { background: rgba(48, 209, 88, 0.18); color: var(--green); }
.toast .check svg { width: 11px; height: 11px; stroke-width: 3; }
.toast .warn { background: rgba(255, 214, 10, 0.15); color: var(--amber); }
.toast .spinner, .spin { animation: spin 0.8s linear infinite; }
.toast .spinner { width: 16px; height: 16px; flex-shrink: 0; border: 2px solid rgba(100, 210, 255, 0.25); border-top-color: var(--cyan); border-radius: 50%; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ── 좁은 화면 ───────────────────────────────────
   수집함을 본문 아래로 내리고 문서 전체 스크롤을 연다(그래프 캔버스는 고정 배경). */
@media (max-width: 900px) {
  body { overflow: auto; }
  .app { height: auto; min-height: 100dvh; }
  .workspace { flex-direction: column; }
  .hero { overflow: visible; min-height: calc(100dvh - 90px); }
  .answer.show { max-height: 68vh; }
  .collect { order: 2; width: auto; padding: 0 20px 28px; justify-content: flex-start; overflow: visible; }
  .collect-note { display: none; }
  .drop:hover, .drop.dragging { transform: none; }
  .topbar { padding: 16px 20px; }
  .brand-sub, .db-status { display: none; }
  .toasts { left: 16px; right: 16px; bottom: 16px; align-items: stretch; }
  .toast { max-width: none; }
  .portal-nav { display: none; }
}
@media (max-width: 620px) {
  .hero { padding: 16px; }
  .ask-wrap { margin-top: 22px; }
  .answer-card { padding: 18px 16px; }
  .mode-btn { padding: 7px 12px; }
  .askbar { padding-left: 16px; }
  .pill-btn #filter-label { display: none; }
  .mail-table th:nth-child(2), .mail-table td:nth-child(2), .mail-table th:nth-child(3), .mail-table td:nth-child(3) { display: none; }
  .mail-table th:first-child, .mail-table td:first-child { width: 72%; }
  .mail-table th:nth-child(4) { width: 28%; }
  .source-chips { grid-template-columns: 1fr; }
  .answer-footer { flex-wrap: wrap; }
  .settings-grid { grid-template-columns: 88px 1fr; }
  .source-metadata { grid-template-columns: 58px 1fr; }
  .source-actions { flex-wrap: wrap; }
  dialog { padding: 20px 18px; }
}
/* 세로가 짧으면 가운데 정렬을 포기한다 — 고정 블록이 화면보다 커지면 제목이 위로 잘린다. */
@media (max-height: 860px) and (min-width: 901px) {
  .ask-wrap { margin-top: 22px; }
  .answer.show { max-height: 58vh; }
}
@media (max-height: 560px) and (min-width: 901px) {
  .hero-pad { flex-grow: 0; }
  .hero-sub { display: none; }
  .ask-wrap { margin-top: 14px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}
