/* ==========================================================================
   Ho 에이전트 AI — styles.css
   다크 단일 테마 · 반응형(모바일 드로어) · 의존성 없는 정적 CSS
   ========================================================================== */

/* ------------------------------------------------------------------- 토큰 */
:root {
  --bg: #070a11;
  --bg-soft: #0b1018;
  --panel: rgba(17, 23, 35, 0.72);
  --panel-solid: #10161f;
  --panel-2: rgba(24, 31, 46, 0.6);
  --line: rgba(255, 255, 255, 0.075);
  --line-strong: rgba(255, 255, 255, 0.14);
  --text: #e9eef8;
  --text-soft: #c3cddf;
  --muted: #8794a9;
  --muted-2: #64718a;
  --accent: #8b7bff;
  --accent-2: #38c6ff;
  --accent-soft: rgba(139, 123, 255, 0.14);
  --ok: #43d39e;
  --warn: #ffb454;
  --danger: #ff6b81;
  --radius-lg: 20px;
  --radius: 14px;
  --radius-sm: 10px;
  --shadow: 0 24px 60px -30px rgba(0, 0, 0, 0.9);
  --font: "Pretendard Variable", Pretendard, -apple-system, BlinkMacSystemFont, "Apple SD Gothic Neo",
    "Segoe UI", "Malgun Gothic", system-ui, sans-serif;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow: hidden;
}

button,
input,
textarea {
  font: inherit;
  color: inherit;
}

code {
  font-family: var(--mono);
  font-size: 0.86em;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--line);
  padding: 1px 6px;
  border-radius: 6px;
  color: #cfe0ff;
  white-space: nowrap;
}

.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;
}

[hidden] {
  display: none !important;
}

::selection {
  background: rgba(139, 123, 255, 0.35);
}

/* ---------------------------------------------------------------- 배경 효과 */
.aurora {
  position: fixed;
  inset: 0;
  z-index: 0;
  overflow: hidden;
  pointer-events: none;
  background:
    radial-gradient(1100px 620px at 78% -10%, rgba(56, 198, 255, 0.13), transparent 62%),
    radial-gradient(900px 560px at 8% 6%, rgba(139, 123, 255, 0.16), transparent 60%),
    linear-gradient(180deg, #080c14 0%, #070a11 48%, #05070c 100%);
}

.aurora__blob {
  position: absolute;
  border-radius: 50%;
  filter: blur(90px);
  opacity: 0.55;
  animation: drift 26s ease-in-out infinite alternate;
}

.aurora__blob--a {
  width: 520px;
  height: 520px;
  top: -180px;
  right: -60px;
  background: radial-gradient(circle, rgba(56, 198, 255, 0.34), transparent 68%);
}

.aurora__blob--b {
  width: 460px;
  height: 460px;
  bottom: -160px;
  left: 18%;
  background: radial-gradient(circle, rgba(139, 123, 255, 0.3), transparent 68%);
  animation-delay: -8s;
}

.aurora__blob--c {
  width: 300px;
  height: 300px;
  top: 34%;
  left: -120px;
  background: radial-gradient(circle, rgba(67, 211, 158, 0.16), transparent 70%);
  animation-delay: -15s;
}

.aurora__grid {
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.028) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.028) 1px, transparent 1px);
  background-size: 56px 56px;
  mask-image: radial-gradient(900px 620px at 50% 0%, #000 0%, transparent 78%);
  -webkit-mask-image: radial-gradient(900px 620px at 50% 0%, #000 0%, transparent 78%);
}

@keyframes drift {
  0% { transform: translate3d(0, 0, 0) scale(1); }
  50% { transform: translate3d(-26px, 22px, 0) scale(1.06); }
  100% { transform: translate3d(18px, -18px, 0) scale(0.98); }
}

/* ------------------------------------------------------------------ 앱 골격 */
.app {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: 316px minmax(0, 1fr);
  height: 100dvh;
}

/* ------------------------------------------------------------------ 사이드바 */
.sidebar {
  display: flex;
  flex-direction: column;
  gap: 16px;
  min-height: 0;
  padding: 20px 16px 14px;
  background: linear-gradient(180deg, rgba(13, 18, 27, 0.92), rgba(9, 13, 20, 0.86));
  border-right: 1px solid var(--line);
  backdrop-filter: blur(18px);
}

.sidebar__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 11px;
}

.brand__mark {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border-radius: 12px;
  font-weight: 800;
  font-size: 19px;
  color: #0a0e15;
  background: linear-gradient(140deg, #b6aaff, #7ee0ff);
  box-shadow: 0 8px 22px -10px rgba(139, 123, 255, 0.9);
}

.brand__text {
  display: flex;
  flex-direction: column;
  line-height: 1.15;
}

.brand__text strong {
  font-size: 15px;
  letter-spacing: -0.01em;
}

.brand__text small {
  font-size: 11px;
  color: var(--muted);
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.icon-btn.sidebar__close {
  display: none;
}

.conn {
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
}

.conn__top {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  font-weight: 600;
}

.conn__label {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--muted-2);
  box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.04);
  flex: none;
}

.dot[data-state="ok"] {
  background: var(--ok);
  box-shadow: 0 0 0 3px rgba(67, 211, 158, 0.16);
}

.dot[data-state="warn"] {
  background: var(--warn);
  box-shadow: 0 0 0 3px rgba(255, 180, 84, 0.16);
}

.dot[data-state="err"] {
  background: var(--danger);
  box-shadow: 0 0 0 3px rgba(255, 107, 129, 0.16);
}

.dot[data-state="idle"] {
  animation: pulse 1.6s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 0.4; }
  50% { opacity: 1; }
}

.conn__provider {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin: 9px 0 0;
  padding: 3px 8px;
  border: 1px solid rgba(56, 198, 255, 0.26);
  border-radius: 999px;
  background: rgba(56, 198, 255, 0.08);
  font-size: 10.5px;
  font-weight: 600;
  color: #9fd9f7;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.app[data-provider="gemini"] .conn__provider {
  border-color: rgba(139, 123, 255, 0.34);
  background: rgba(139, 123, 255, 0.14);
  color: #c5bcff;
}

.conn__host {
  margin: 8px 0 10px;
  font-family: var(--mono);
  font-size: 11px;
  color: var(--muted-2);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.conn__meta {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin: 0 0 12px;
}

.conn__meta div {
  padding: 7px 9px;
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.035);
  border: 1px solid var(--line);
  min-width: 0;
}

.conn__meta dt {
  font-size: 10px;
  color: var(--muted-2);
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.conn__meta dd {
  margin: 2px 0 0;
  font-size: 11.5px;
  color: var(--text-soft);
  font-family: var(--mono);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ------------------------------------------------------------- 오늘 사용량 */
.usage {
  padding: 13px 14px 11px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: linear-gradient(180deg, rgba(139, 123, 255, 0.12), rgba(56, 198, 255, 0.04)), var(--panel);
}

.usage__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.usage__title {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.03em;
  color: var(--muted);
}

.usage__pct {
  font-size: 11px;
  font-weight: 700;
  color: var(--ok);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.usage__remaining {
  display: flex;
  align-items: baseline;
  gap: 5px;
  margin: 6px 0 9px;
  min-width: 0;
}

.usage__remaining strong {
  font-size: 23px;
  font-weight: 800;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
  background: linear-gradient(135deg, #cec6ff, #8ee4ff);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.usage__unit {
  flex: none;
  font-size: 11px;
  color: var(--muted);
}

.usage__bar {
  position: relative;
  height: 6px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.09);
  overflow: hidden;
}

.usage__fill {
  display: block;
  height: 100%;
  width: 0;
  border-radius: inherit;
  background: linear-gradient(90deg, #6d5efc, #38c6ff);
  transition: width 0.45s ease;
}

.usage[data-level="warn"] .usage__fill {
  background: linear-gradient(90deg, #d0a04a, #ffb454);
}

.usage[data-level="danger"] .usage__fill {
  background: linear-gradient(90deg, #ff6b81, #ff4757);
}

.usage[data-level="warn"] .usage__pct {
  color: var(--warn);
}

.usage[data-level="danger"] .usage__pct {
  color: var(--danger);
}

.usage[data-level="idle"] .usage__fill {
  background: rgba(255, 255, 255, 0.18);
}

.usage__sub {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px;
  margin: 8px 0 0;
  font-size: 10.5px;
  color: var(--text-soft);
  font-variant-numeric: tabular-nums;
}

.usage__dot {
  color: var(--muted-2);
}

.usage__sub #usageUsed,
.usage__sub #usageLimit {
  font-family: var(--mono);
  color: var(--text-soft);
}

.usage__note {
  margin: 4px 0 0;
  font-size: 10px;
  line-height: 1.45;
  color: var(--muted-2);
}

.memos {
  display: flex;
  flex-direction: column;
  min-height: 0;
  flex: 1;
}

.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 4px 8px;
}

.section-head h2 {
  margin: 0;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
  display: flex;
  align-items: center;
  gap: 7px;
}

.count {
  display: inline-grid;
  place-items: center;
  min-width: 20px;
  height: 18px;
  padding: 0 6px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: #c9c1ff;
  font-size: 10.5px;
  letter-spacing: 0;
}

.memo-list {
  list-style: none;
  margin: 0;
  padding: 2px 2px 6px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 7px;
  flex: 0 1 auto;
  min-height: 0;
  max-height: 100%;
}

.memo {
  position: relative;
  padding: 10px 11px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.028);
  transition: border-color 0.16s ease, background 0.16s ease, transform 0.16s ease;
  animation: memoIn 0.24s ease both;
}

.memo:hover {
  border-color: var(--line-strong);
  background: rgba(255, 255, 255, 0.05);
}

@keyframes memoIn {
  from { opacity: 0; transform: translateY(-4px); }
  to { opacity: 1; transform: none; }
}

.memo__top {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 5px;
}

.tag {
  font-size: 10px;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: 999px;
  background: rgba(56, 198, 255, 0.12);
  color: #9bdcff;
  border: 1px solid rgba(56, 198, 255, 0.18);
  flex: none;
}

.tag[data-cat="회의"] { background: rgba(139, 123, 255, 0.14); color: #c3b8ff; border-color: rgba(139, 123, 255, 0.22); }
.tag[data-cat="할일"] { background: rgba(255, 180, 84, 0.14); color: #ffcf90; border-color: rgba(255, 180, 84, 0.22); }
.tag[data-cat="약속"] { background: rgba(67, 211, 158, 0.14); color: #8ff0c8; border-color: rgba(67, 211, 158, 0.22); }
.tag[data-cat="아이디어"] { background: rgba(255, 107, 129, 0.14); color: #ffb3bf; border-color: rgba(255, 107, 129, 0.22); }

.memo__time {
  margin-left: auto;
  font-size: 10px;
  color: var(--muted-2);
  font-family: var(--mono);
}

.memo__title {
  margin: 0;
  font-size: 13px;
  font-weight: 600;
  line-height: 1.4;
  color: var(--text);
  word-break: break-word;
}

.memo__body {
  margin: 3px 0 0;
  font-size: 11.5px;
  line-height: 1.5;
  color: var(--muted);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  word-break: break-word;
}

.memo__del {
  position: absolute;
  top: 7px;
  right: 7px;
  width: 22px;
  height: 22px;
  display: grid;
  place-items: center;
  border: 1px solid transparent;
  border-radius: 7px;
  background: transparent;
  color: var(--muted-2);
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.15s ease, color 0.15s ease, background 0.15s ease;
}

.memo:hover .memo__del,
.memo__del:focus-visible {
  opacity: 1;
}

.memo__del:hover {
  color: var(--danger);
  background: rgba(255, 107, 129, 0.12);
}

.memo__del[data-confirm="1"] {
  opacity: 1;
  width: auto;
  padding: 0 7px;
  font-size: 10.5px;
  font-weight: 700;
  color: #ffd7dd;
  background: rgba(255, 107, 129, 0.24);
  border-color: rgba(255, 107, 129, 0.5);
}

.memo-empty {
  margin: 6px 4px 0;
  font-size: 11.5px;
  line-height: 1.65;
  color: var(--muted-2);
}

.memo-empty span {
  color: var(--muted);
}

.sidebar__foot {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding-top: 10px;
  border-top: 1px solid var(--line);
  font-size: 11px;
  color: var(--muted-2);
}

.sidebar__foot a {
  color: var(--muted);
  text-decoration: none;
}

.sidebar__foot a:hover {
  color: var(--text);
}

/* ---------------------------------------------------------------------- 메인 */
.main {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
}

.topbar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 22px;
  border-bottom: 1px solid var(--line);
  background: rgba(8, 12, 19, 0.55);
  backdrop-filter: blur(14px);
}

.icon-btn.topbar__menu {
  display: none;
}

.topbar__title {
  display: flex;
  flex-direction: column;
  line-height: 1.25;
  min-width: 0;
}

.topbar__title strong {
  font-size: 15px;
  letter-spacing: -0.01em;
}

.topbar__title span {
  font-size: 11px;
  color: var(--muted-2);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.topbar__actions {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-left: auto;
}

.status {
  display: inline-flex;
  max-width: 42vw;
  align-items: center;
  gap: 7px;
  height: 28px;
  padding: 0 11px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.03);
  font-size: 11.5px;
  color: var(--text-soft);
  white-space: nowrap;
}

.status .dot {
  width: 6px;
  height: 6px;
}

.status #statusText {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ------------------------------------------------------------------- 버튼 */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 36px;
  padding: 0 14px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.04);
  color: var(--text-soft);
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease, transform 0.12s ease;
  white-space: nowrap;
}

.btn:hover {
  background: rgba(255, 255, 255, 0.08);
  border-color: var(--line-strong);
  color: var(--text);
}

.btn:active {
  transform: translateY(1px);
}

.btn--sm {
  height: 30px;
  padding: 0 11px;
  font-size: 11.5px;
  border-radius: 8px;
}

.btn--block {
  width: 100%;
}

.btn--primary {
  border-color: transparent;
  background: linear-gradient(135deg, #8b7bff, #4f8dff);
  color: #0a0d14;
  font-weight: 700;
  box-shadow: 0 10px 24px -14px rgba(110, 120, 255, 0.9);
}

.btn--primary:hover {
  background: linear-gradient(135deg, #9a8cff, #62a0ff);
  color: #05070c;
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.icon-btn {
  display: inline-grid;
  place-items: center;
  width: 32px;
  height: 32px;
  padding: 0;
  border-radius: 9px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.03);
  color: var(--muted);
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
  flex: none;
}

.icon-btn:hover {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text);
  border-color: var(--line-strong);
}

.icon-btn svg {
  width: 15px;
  height: 15px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.9;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* ------------------------------------------------------------------- 채팅 */
.chat {
  flex: 1;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-gutter: stable;
}

.chat__inner {
  display: flex;
  flex-direction: column;
  gap: 22px;
  width: 100%;
  max-width: 860px;
  margin: 0 auto;
  padding: 34px 24px 8px;
  min-height: 100%;
}

/* 히어로 */
.app[data-empty="true"] .hero {
  margin-block: auto;
}

.hero {
  display: flex;
  flex-direction: column;
  gap: 18px;
  padding: 10px 0 4px;
  animation: rise 0.5s ease both;
}

@keyframes rise {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: none; }
}

.hero__eyebrow {
  font-family: var(--mono);
  font-size: 10.5px;
  letter-spacing: 0.18em;
  color: rgba(139, 123, 255, 0.9);
}

.hero h1 {
  margin: 0;
  font-size: clamp(26px, 4vw, 38px);
  line-height: 1.15;
  letter-spacing: -0.03em;
  font-weight: 800;
  background: linear-gradient(120deg, #ffffff 8%, #cfd8ff 46%, #8fd6ff 92%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.hero__lead {
  margin: 0;
  font-size: 14px;
  line-height: 1.75;
  color: var(--muted);
  max-width: 620px;
}

.cards {
  list-style: none;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin: 4px 0 0;
  padding: 0;
}

.card {
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  transition: border-color 0.18s ease, transform 0.18s ease, background 0.18s ease;
}

.card:hover {
  border-color: rgba(139, 123, 255, 0.34);
  background: rgba(24, 30, 45, 0.8);
  transform: translateY(-2px);
}

.card__icon {
  display: inline-grid;
  place-items: center;
  width: 30px;
  height: 30px;
  margin-bottom: 9px;
  border-radius: 9px;
  background: rgba(255, 255, 255, 0.045);
  border: 1px solid var(--line);
  font-size: 14px;
}

.card strong {
  display: block;
  font-size: 13px;
  margin-bottom: 4px;
}

.card p {
  margin: 0;
  font-size: 11.5px;
  line-height: 1.6;
  color: var(--muted-2);
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 2px;
}

.chip {
  padding: 8px 13px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.03);
  color: var(--text-soft);
  font-size: 12px;
  cursor: pointer;
  transition: all 0.15s ease;
  text-align: left;
}

.chip:hover {
  border-color: rgba(139, 123, 255, 0.45);
  background: rgba(139, 123, 255, 0.12);
  color: #fff;
}

.chip::before {
  content: "↗";
  margin-right: 6px;
  color: var(--muted-2);
  font-size: 11px;
}

.notice {
  margin-top: 4px;
  padding: 15px 16px;
  border: 1px solid rgba(255, 180, 84, 0.28);
  border-radius: var(--radius);
  background: linear-gradient(180deg, rgba(255, 180, 84, 0.1), rgba(255, 180, 84, 0.03));
}

.notice__head {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  margin-bottom: 7px;
}

.notice__icon {
  font-size: 14px;
}

.notice p {
  margin: 0 0 9px;
  font-size: 12px;
  line-height: 1.65;
  color: #e7d6bb;
}

.notice p em {
  font-style: normal;
  color: #ffd9a3;
  font-weight: 600;
}

.notice ol {
  margin: 0 0 12px;
  padding-left: 18px;
  font-size: 11.5px;
  line-height: 1.9;
  color: #d9c6a9;
}

.notice__actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

/* 메시지 */
.messages {
  display: flex;
  flex-direction: column;
  gap: 20px;
  padding-bottom: 6px;
}

.msg {
  display: flex;
  gap: 10px;
  max-width: 100%;
  animation: msgIn 0.26s ease both;
}

@keyframes msgIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: none; }
}

.msg--user {
  justify-content: flex-end;
}

.msg__avatar {
  flex: none;
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  margin-top: 2px;
  border-radius: 10px;
  background: linear-gradient(140deg, rgba(139, 123, 255, 0.9), rgba(56, 198, 255, 0.85));
  color: #080b12;
  font-size: 13px;
  font-weight: 800;
  box-shadow: 0 8px 20px -12px rgba(139, 123, 255, 0.9);
}

.msg__avatar--user {
  background: rgba(255, 255, 255, 0.1);
  color: var(--text-soft);
  font-weight: 700;
  border: 1px solid var(--line);
  box-shadow: none;
}

.msg__body {
  display: flex;
  flex-direction: column;
  gap: 7px;
  min-width: 0;
  max-width: min(680px, 88%);
}

.msg--user .msg__body {
  align-items: flex-end;
}

.bubble {
  padding: 12px 15px;
  border-radius: 16px;
  font-size: 13.5px;
  line-height: 1.75;
  word-break: break-word;
  white-space: pre-wrap;
}

.msg--ai .bubble {
  border: 1px solid var(--line);
  border-top-left-radius: 6px;
  background: var(--panel);
  color: var(--text-soft);
}

.msg--user .bubble {
  border-top-right-radius: 6px;
  background: linear-gradient(135deg, rgba(139, 123, 255, 0.92), rgba(79, 141, 255, 0.92));
  color: #0a0d15;
  font-weight: 550;
  box-shadow: 0 14px 30px -20px rgba(120, 120, 255, 0.9);
}

.bubble a {
  color: #a9d8ff;
  text-underline-offset: 2px;
}

.msg--user .bubble a {
  color: #10131c;
  text-decoration-color: rgba(10, 13, 21, 0.45);
}

.bubble--error {
  border-color: rgba(255, 107, 129, 0.34) !important;
  background: linear-gradient(180deg, rgba(255, 107, 129, 0.12), rgba(255, 107, 129, 0.04)) !important;
  color: #ffdde2 !important;
}

.bubble--error strong {
  display: block;
  margin-bottom: 4px;
  color: #ffe7ea;
}

.bubble--error .err-hint {
  display: block;
  margin-top: 6px;
  font-size: 12px;
  color: #f3bcc5;
  line-height: 1.7;
}

.bubble--error button {
  margin-top: 10px;
  display: inline-flex;
}

.bubble--error .err-hint + button {
  margin-left: 0;
}

.msg__meta {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 10.5px;
  color: var(--muted-2);
  font-family: var(--mono);
  flex-wrap: wrap;
}

.msg__meta .sep {
  width: 3px;
  height: 3px;
  border-radius: 50%;
  background: currentColor;
  opacity: 0.5;
}

.msg__meta .msg__cost {
  padding: 1px 7px;
  border-radius: 999px;
  border: 1px solid rgba(139, 123, 255, 0.24);
  background: rgba(139, 123, 255, 0.12);
  color: #b7aeff;
  font-size: 10px;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.msg__meta .msg__cost--external {
  border-color: rgba(56, 198, 255, 0.26);
  background: rgba(56, 198, 255, 0.1);
  color: #9fd9f7;
}

.tools {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.tool-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  max-width: 100%;
  padding: 4px 9px;
  border: 1px solid rgba(139, 123, 255, 0.28);
  border-radius: 999px;
  background: rgba(139, 123, 255, 0.1);
  color: #d6d0ff;
  font-size: 11px;
  font-weight: 600;
  animation: badgeIn 0.3s ease both;
}

@keyframes badgeIn {
  from { opacity: 0; transform: scale(0.94); }
  to { opacity: 1; transform: none; }
}

.tool-badge small {
  font-weight: 500;
  color: rgba(214, 208, 255, 0.72);
  font-size: 10.5px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 260px;
}

.tool-badge[data-ok="false"] {
  border-color: rgba(255, 107, 129, 0.32);
  background: rgba(255, 107, 129, 0.1);
  color: #ffc3cd;
}

/* 타이핑 인디케이터 */
.typing {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 14px 16px;
}

.typing span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--muted);
  animation: blink 1.3s infinite ease-in-out;
}

.typing span:nth-child(2) { animation-delay: 0.16s; }
.typing span:nth-child(3) { animation-delay: 0.32s; }

@keyframes blink {
  0%, 80%, 100% { opacity: 0.25; transform: translateY(0); }
  40% { opacity: 1; transform: translateY(-2px); }
}

/* ------------------------------------------------------------------ 입력창 */
.composer {
  padding: 10px 24px calc(16px + env(safe-area-inset-bottom));
  background: linear-gradient(180deg, rgba(7, 10, 17, 0), rgba(7, 10, 17, 0.9) 34%);
}

.composer__inner {
  width: 100%;
  max-width: 860px;
  margin: 0 auto;
}

.composer__box {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 8px 8px 8px 16px;
  border: 1px solid var(--line-strong);
  border-radius: 16px;
  background: rgba(16, 22, 32, 0.92);
  box-shadow: var(--shadow);
  transition: border-color 0.16s ease, box-shadow 0.16s ease;
}

.composer__box:focus-within {
  border-color: rgba(139, 123, 255, 0.55);
  box-shadow: 0 0 0 3px rgba(139, 123, 255, 0.12), var(--shadow);
}

.composer textarea {
  flex: 1;
  min-height: 26px;
  max-height: 168px;
  padding: 7px 0;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--text);
  font-size: 13.5px;
  line-height: 1.6;
  resize: none;
}

.composer textarea::placeholder {
  color: var(--muted-2);
}

.send {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border: 0;
  border-radius: 12px;
  background: linear-gradient(140deg, #8b7bff, #42a5ff);
  color: #0a0d14;
  cursor: pointer;
  transition: transform 0.14s ease, filter 0.14s ease, opacity 0.14s ease;
  flex: none;
}

.send svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.4;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.send:hover:not(:disabled) {
  filter: brightness(1.08);
  transform: translateY(-1px);
}

.send:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.composer__foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 7px 4px 0;
  font-size: 10.5px;
  color: var(--muted-2);
  font-family: var(--mono);
}

.composer__count[data-warn="1"] {
  color: var(--warn);
}

/* --------------------------------------------------------------------- 모달 */
.modal {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: grid;
  place-items: center;
  padding: 20px;
}

.modal__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(3, 5, 9, 0.68);
  backdrop-filter: blur(6px);
  animation: fade 0.2s ease both;
}

@keyframes fade {
  from { opacity: 0; }
  to { opacity: 1; }
}

.modal__panel {
  position: relative;
  width: min(520px, 100%);
  max-height: min(86dvh, 720px);
  display: flex;
  flex-direction: column;
  border: 1px solid var(--line-strong);
  border-radius: 18px;
  background: #0c1119;
  box-shadow: 0 40px 90px -40px #000;
  animation: pop 0.22s cubic-bezier(0.2, 0.9, 0.3, 1) both;
  overflow: hidden;
}

@keyframes pop {
  from { opacity: 0; transform: translateY(12px) scale(0.98); }
  to { opacity: 1; transform: none; }
}

.modal__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 18px;
  border-bottom: 1px solid var(--line);
}

.modal__head h2 {
  margin: 0;
  font-size: 15px;
}

.modal__body {
  padding: 18px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 7px;
}

.field__label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-soft);
  display: flex;
  align-items: baseline;
  gap: 7px;
}

.field__label small {
  font-size: 10.5px;
  font-weight: 400;
  color: var(--muted-2);
}

.field input {
  width: 100%;
  height: 40px;
  padding: 0 12px;
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.03);
  font-size: 12.5px;
  font-family: var(--mono);
  outline: 0;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.field input:focus {
  border-color: rgba(139, 123, 255, 0.6);
  box-shadow: 0 0 0 3px rgba(139, 123, 255, 0.12);
}

.field input[readonly] {
  color: var(--muted);
  background: rgba(255, 255, 255, 0.015);
}

.field__row {
  display: flex;
  gap: 8px;
}

.field__hint {
  font-size: 11px;
  color: var(--muted-2);
  line-height: 1.6;
}

/* ------------------------------------------------------------ AI 공급자 */
.provider {
  display: flex;
  flex-direction: column;
  gap: 7px;
}

.provider__option {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px 12px;
  border: 1px solid var(--line-strong);
  border-radius: 11px;
  background: rgba(255, 255, 255, 0.02);
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease;
}

.provider__option:hover {
  border-color: rgba(139, 123, 255, 0.45);
}

.provider__option:has(input:checked) {
  border-color: rgba(139, 123, 255, 0.7);
  background: rgba(139, 123, 255, 0.12);
}

.provider__option input {
  width: 15px;
  height: 15px;
  margin: 3px 0 0;
  accent-color: #8b7bff;
  flex: none;
}

.provider__body {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.provider__body strong {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text);
}

.provider__body small {
  font-size: 10.5px;
  color: var(--muted);
  line-height: 1.5;
}

.gemini-fields {
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 13px;
  border: 1px dashed rgba(139, 123, 255, 0.4);
  border-radius: 12px;
  background: rgba(139, 123, 255, 0.06);
}

.gemini-fields[hidden] {
  display: none;
}

.gemini-fields .field__hint a {
  color: #9fb6ff;
}

.gemini-fields__clear {
  align-self: flex-start;
}

.field select {
  width: 100%;
  height: 40px;
  padding: 0 10px;
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.03);
  color: var(--text);
  font-size: 12.5px;
  font-family: var(--font);
  outline: 0;
}

.field select:focus {
  border-color: rgba(139, 123, 255, 0.6);
  box-shadow: 0 0 0 3px rgba(139, 123, 255, 0.12);
}

.probe {
  padding: 12px 13px;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: rgba(255, 255, 255, 0.02);
  font-size: 11.5px;
  line-height: 1.7;
  color: var(--muted);
}

.probe__idle {
  margin: 0;
  color: var(--muted-2);
}

.probe[data-state="ok"] {
  border-color: rgba(67, 211, 158, 0.32);
  background: rgba(67, 211, 158, 0.07);
  color: #b9f0d8;
}

.probe[data-state="err"] {
  border-color: rgba(255, 107, 129, 0.32);
  background: rgba(255, 107, 129, 0.07);
  color: #ffcfd6;
}

.probe dl {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 4px 12px;
  margin: 8px 0 0;
  font-family: var(--mono);
  font-size: 11px;
}

.probe dt {
  color: var(--muted-2);
}

.probe dd {
  margin: 0;
  word-break: break-all;
}

.modal__foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 14px 18px;
  border-top: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.015);
}

.modal__foot-right {
  display: flex;
  gap: 8px;
}

/* -------------------------------------------------------------------- 토스트 */
.toast {
  position: fixed;
  left: 50%;
  bottom: 26px;
  transform: translate(-50%, 16px);
  z-index: 80;
  max-width: min(420px, calc(100vw - 32px));
  padding: 10px 16px;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  background: rgba(16, 22, 33, 0.96);
  color: var(--text);
  font-size: 12px;
  box-shadow: var(--shadow);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
  text-align: center;
}

.toast[data-show="1"] {
  opacity: 1;
  transform: translate(-50%, 0);
}

/* ------------------------------------------------------------------ 스크림 */
.scrim {
  position: fixed;
  inset: 0;
  z-index: 40;
  background: rgba(3, 5, 9, 0.6);
  backdrop-filter: blur(3px);
}

/* --------------------------------------------------------------- 스크롤바 */
.chat::-webkit-scrollbar,
.memo-list::-webkit-scrollbar,
.modal__body::-webkit-scrollbar {
  width: 9px;
}

.chat::-webkit-scrollbar-thumb,
.memo-list::-webkit-scrollbar-thumb,
.modal__body::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.1);
  border-radius: 999px;
  border: 2px solid transparent;
  background-clip: content-box;
}

.chat::-webkit-scrollbar-thumb:hover,
.memo-list::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.2);
  background-clip: content-box;
}

/* ------------------------------------------------------------------ 반응형 */
@media (max-width: 980px) {
  .app {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: fixed;
    z-index: 50;
    inset: 0 auto 0 0;
    width: min(320px, 86vw);
    transform: translateX(-102%);
    transition: transform 0.26s cubic-bezier(0.3, 0.9, 0.3, 1);
    box-shadow: 40px 0 80px -40px #000;
  }

  .app[data-drawer="open"] .sidebar {
    transform: none;
  }

  .icon-btn.sidebar__close {
    display: inline-grid;
  }

  .topbar {
    padding: 11px 14px;
    gap: 9px;
  }

  .icon-btn.topbar__menu {
    display: inline-grid;
  }

  .topbar__title span {
    display: none;
  }

  .topbar__new {
    display: none;
  }

  .status {
    height: 26px;
    padding: 0 9px;
    font-size: 10.5px;
  }

  .chat__inner {
    padding: 22px 16px 6px;
  }

  .composer {
    padding: 8px 12px calc(12px + env(safe-area-inset-bottom));
  }

  .cards {
    grid-template-columns: 1fr;
  }

  .card {
    display: grid;
    grid-template-columns: 34px 1fr;
    column-gap: 10px;
    padding: 11px 12px;
  }

  .card__icon {
    grid-row: span 2;
    margin: 0;
  }

  .card strong {
    margin-bottom: 2px;
  }

  .msg__body {
    max-width: 84%;
  }

  .hero h1 {
    font-size: 26px;
  }
}

@media (max-width: 520px) {
  .chips .chip {
    font-size: 11.5px;
    padding: 7px 11px;
  }

  .msg__avatar {
    display: none;
  }

  .msg__body {
    max-width: 92%;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
}
