/* AI Crew — 모바일 우선. 색은 모두 토큰으로, 다크 모드는 시스템을 따른다. */
:root {
  --bg: #f6f7fb;
  --bg-elev: #ffffff;
  --bg-sunk: #eceef4;
  --line: rgba(20, 24, 40, .08);
  --line-strong: rgba(20, 24, 40, .14);
  --text: #141824;
  --text-2: #4a5165;
  --text-3: #8a90a2;
  --accent: #4f46e5;
  --accent-2: #7c3aed;
  --accent-soft: rgba(79, 70, 229, .10);
  --on-accent: #ffffff;
  --me-bubble: linear-gradient(135deg, #4f46e5, #6d4aea);
  --grad: linear-gradient(135deg, #4f46e5, #7c3aed);
  --bubble: #ffffff;
  --danger: #e5484d;
  --danger-soft: rgba(229, 72, 77, .12);
  --ok: #16a34a;
  --warn: #d97706;

  --cost-low: #e9f8ef;  --cost-low-line: #b6e6c8;  --cost-low-ink: #15803d;
  --cost-mid: #fff7df;  --cost-mid-line: #f3dc95;  --cost-mid-ink: #a16207;
  --cost-high: #fdecec; --cost-high-line: #f5bcbc; --cost-high-ink: #c2410c;
  --cost-none: #ffffff;
  --codex: #10b981;   --codex-2: #059669;
  --claude: #f97316;  --claude-2: #ea580c;
  --muse: #8b5cf6;    --muse-2: #7c3aed;
  --gemini: #3b82f6;  --gemini-2: #2563eb;
  --system: #8a90a2;

  --radius: 18px;
  --radius-s: 12px;
  --shadow-1: 0 1px 2px rgba(16, 20, 36, .05), 0 1px 1px rgba(16, 20, 36, .03);
  --shadow-2: 0 10px 30px -10px rgba(16, 20, 36, .25), 0 2px 6px rgba(16, 20, 36, .06);
  --shadow-3: 0 24px 60px -12px rgba(16, 20, 36, .35);
  --ease: cubic-bezier(.2, .8, .2, 1);
  --sat: env(safe-area-inset-top, 0px);
  --sab: env(safe-area-inset-bottom, 0px);
  --font: "Pretendard Variable", Pretendard, -apple-system, BlinkMacSystemFont, "Apple SD Gothic Neo", "Noto Sans KR", "Malgun Gothic", system-ui, sans-serif;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0e1016;
    --bg-elev: #171a23;
    --bg-sunk: #0a0c11;
    --line: rgba(255, 255, 255, .07);
    --line-strong: rgba(255, 255, 255, .13);
    --text: #eef0f6;
    --text-2: #b4b9c8;
    --text-3: #7a8094;
    --accent: #8b85ff;
    --accent-2: #a78bfa;
    --accent-soft: rgba(139, 133, 255, .14);
    --me-bubble: linear-gradient(135deg, #5b54f0, #7a4fe8);
    --bubble: #1b1f2a;
    --danger: #ff6369;
    --danger-soft: rgba(255, 99, 105, .14);
    --codex: #34d399; --codex-2: #10b981;
    --cost-low: rgba(34, 197, 94, .10);  --cost-low-line: rgba(34, 197, 94, .30);  --cost-low-ink: #6ee7a0;
    --cost-mid: rgba(234, 179, 8, .10);  --cost-mid-line: rgba(234, 179, 8, .30);  --cost-mid-ink: #facc6b;
    --cost-high: rgba(239, 68, 68, .11); --cost-high-line: rgba(239, 68, 68, .32); --cost-high-ink: #fca5a5;
    --cost-none: #1f2330;
    --claude: #fb923c; --claude-2: #f97316;
    --muse: #a78bfa; --muse-2: #8b5cf6;
    --gemini: #60a5fa; --gemini-2: #3b82f6;
    --shadow-1: 0 1px 0 rgba(255, 255, 255, .03) inset;
    --shadow-2: 0 10px 30px -10px rgba(0, 0, 0, .6);
    --shadow-3: 0 24px 60px -12px rgba(0, 0, 0, .7);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0e1016; --bg-elev: #171a23; --bg-sunk: #0a0c11;
  --line: rgba(255, 255, 255, .07); --line-strong: rgba(255, 255, 255, .13);
  --text: #eef0f6; --text-2: #b4b9c8; --text-3: #7a8094;
  --accent: #8b85ff; --accent-2: #a78bfa; --accent-soft: rgba(139, 133, 255, .14);
  --me-bubble: linear-gradient(135deg, #5b54f0, #7a4fe8); --bubble: #1b1f2a;
  --danger: #ff6369; --danger-soft: rgba(255, 99, 105, .14);
--cost-low: rgba(34, 197, 94, .10);  --cost-low-line: rgba(34, 197, 94, .30);  --cost-low-ink: #6ee7a0;
    --cost-mid: rgba(234, 179, 8, .10);  --cost-mid-line: rgba(234, 179, 8, .30);  --cost-mid-ink: #facc6b;
    --cost-high: rgba(239, 68, 68, .11); --cost-high-line: rgba(239, 68, 68, .32); --cost-high-ink: #fca5a5;
    --cost-none: #1f2330;
  --codex: #34d399; --codex-2: #10b981; --claude: #fb923c; --claude-2: #f97316; --muse: #a78bfa; --muse-2: #8b5cf6; --gemini: #60a5fa; --gemini-2: #3b82f6;
  --shadow-1: 0 1px 0 rgba(255, 255, 255, .03) inset; --shadow-2: 0 10px 30px -10px rgba(0, 0, 0, .6); --shadow-3: 0 24px 60px -12px rgba(0, 0, 0, .7);
  color-scheme: dark;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 15.5px;
  line-height: 1.55;
  letter-spacing: -0.01em;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: none;
  word-break: keep-all;
  overflow-wrap: anywhere;
}
button, input, textarea, select { font: inherit; color: inherit; letter-spacing: inherit; }
button { cursor: pointer; border: 0; background: none; padding: 0; }
a { color: var(--accent); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 8px; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

.app {
  height: 100dvh;
  max-width: 780px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  position: relative;
  background: var(--bg);
}
@media (min-width: 800px) {
  .app { border-left: 1px solid var(--line); border-right: 1px solid var(--line); }
}

/* ---------- 상단 바 ---------- */
.topbar {
  position: sticky; top: 0; z-index: 10;
  padding: calc(var(--sat) + 10px) 16px 10px;
  display: flex; align-items: center; gap: 10px;
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: saturate(1.6) blur(18px);
  -webkit-backdrop-filter: saturate(1.6) blur(18px);
  border-bottom: 1px solid transparent;
  transition: border-color .2s;
}
.topbar.scrolled { border-bottom-color: var(--line); }
.brand { display: flex; align-items: center; gap: 10px; min-width: 0; flex: 1; }
.brand-mark { width: 30px; height: 30px; border-radius: 9px; flex: none; }
.brand h1 { font-size: 21px; font-weight: 800; margin: 0; letter-spacing: -0.03em; }
.icon-btn {
  width: 40px; height: 40px; border-radius: 12px;
  display: grid; place-items: center; flex: none;
  color: var(--text-2);
  transition: background .15s, transform .1s;
}
.icon-btn:hover { background: var(--bg-sunk); }
.icon-btn:active { transform: scale(.94); }
.icon-btn svg { width: 22px; height: 22px; }

.thread-head { flex: 1; min-width: 0; }
.thread-head .t { font-weight: 700; font-size: 16px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.thread-head .s { font-size: 12.5px; color: var(--text-3); display: flex; align-items: center; gap: 6px; }

/* ---------- 크루(참가 AI) 줄 ---------- */
.crew {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(0, 1fr)); gap: 8px; padding: 4px 16px 14px;
}
.crew::-webkit-scrollbar { display: none; }
.crew-chip {
  min-width: 0;
  display: flex; align-items: center; gap: 8px;
  padding: 7px 10px 7px 7px;
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: 999px;
  box-shadow: var(--shadow-1);
  transition: transform .12s var(--ease), border-color .2s;
  text-align: left;
}
.crew-chip:active { transform: scale(.97); }
.crew-chip > span:last-child { min-width: 0; }
.crew-chip .nm { font-weight: 700; font-size: 14px; line-height: 1.2; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.crew-chip .av { width: 32px; height: 32px; font-size: 12px; }
.crew-chip .st { font-size: 12px; color: var(--text-3); line-height: 1.2; display: flex; align-items: center; gap: 5px; white-space: nowrap; }
.dot { width: 7px; height: 7px; border-radius: 50%; background: var(--text-3); flex: none; }
.dot.online { background: var(--ok); box-shadow: 0 0 0 3px color-mix(in srgb, var(--ok) 20%, transparent); }
.dot.working { background: var(--warn); animation: pulse 1.2s infinite; }
.dot.error { background: var(--danger); }
.dot.offline { background: var(--text-3); opacity: .6; }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: .35; } }

/* ---------- 아바타 ---------- */
.av {
  --c: var(--accent); --c2: var(--accent-2);
  width: 36px; height: 36px; border-radius: 50%; flex: none;
  display: grid; place-items: center;
  font-weight: 800; font-size: 13px; letter-spacing: -0.02em;
  color: #fff;
  background: linear-gradient(140deg, var(--c), var(--c2));
  position: relative;
  user-select: none;
}
.av.sm { width: 22px; height: 22px; font-size: 9.5px; }
.av.lg { width: 56px; height: 56px; font-size: 19px; }
.av.codex { --c: var(--codex); --c2: var(--codex-2); }
.av.claude { --c: var(--claude); --c2: var(--claude-2); }
.av.muse { --c: var(--muse); --c2: var(--muse-2); }
.av.gemini { --c: var(--gemini); --c2: var(--gemini-2); }
.av.user { --c: #64748b; --c2: #475569; }
.av.working::after {
  content: ""; position: absolute; inset: -4px; border-radius: 50%;
  border: 2px solid var(--c);
  border-right-color: transparent; border-bottom-color: transparent;
  animation: spin 1s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.av-stack { display: flex; }
.av-stack .av { box-shadow: 0 0 0 2px var(--bg-elev); }
.av-stack .av + .av { margin-left: -4px; }

/* ---------- 목록 ---------- */
.scroll { flex: 1; overflow-y: auto; overscroll-behavior: contain; -webkit-overflow-scrolling: touch; }
.section-label {
  padding: 6px 20px 8px; font-size: 13px; font-weight: 700; color: var(--text-3);
  display: flex; justify-content: space-between; align-items: center;
}
.list { padding: 0 12px calc(110px + var(--sab)); display: flex; flex-direction: column; gap: 10px; }
.card {
  display: block; width: 100%; text-align: left;
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 15px 16px 14px;
  box-shadow: var(--shadow-1);
  transition: transform .15s var(--ease), box-shadow .2s, border-color .2s;
  position: relative;
  animation: rise .35s var(--ease) both;
}
.card:hover { border-color: var(--line-strong); }
.card:active { transform: scale(.985); }
.card .row1 { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; }
.card .title { font-weight: 700; font-size: 16.5px; line-height: 1.4; letter-spacing: -0.02em; flex: 1; min-width: 0;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.card .time { font-size: 12px; color: var(--text-3); flex: none; align-self: flex-start; margin-top: 3px; }
.card .preview { display: flex; align-items: flex-start; gap: 8px; color: var(--text-2); font-size: 14px; }
.card .preview .who { font-weight: 700; flex: none; }
.card .preview .txt { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.card .meta { display: flex; align-items: center; gap: 10px; margin-top: 10px; color: var(--text-3); font-size: 12.5px; }
.card .meta .grow { flex: 1; }
.badge {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 11.5px; font-weight: 700;
  padding: 3px 9px; border-radius: 999px;
  background: var(--accent-soft); color: var(--accent);
}
.badge.live { background: color-mix(in srgb, var(--warn) 14%, transparent); color: var(--warn); }
.badge.live .dot { background: var(--warn); animation: pulse 1.2s infinite; }
.badge.post { background: color-mix(in srgb, var(--muse) 14%, transparent); color: var(--muse); }
@keyframes rise { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

/* 빈 화면 */
.empty { padding: 36px 24px 140px; text-align: center; }
.empty .art { display: flex; justify-content: center; margin: 10px 0 22px; }
.empty .art .av { width: 64px; height: 64px; font-size: 21px; box-shadow: 0 0 0 5px var(--bg); animation: bob 3s ease-in-out infinite; }
.empty .art .av + .av { margin-left: -10px; }
.empty .art .av:nth-child(2) { animation-delay: .3s; }
.empty .art .av:nth-child(3) { animation-delay: .6s; }
@keyframes bob { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-6px); } }
.empty h2 { font-size: 22px; margin: 0 0 6px; letter-spacing: -0.03em; }
.empty p { color: var(--text-2); margin: 0 0 22px; }
.suggest { display: flex; flex-direction: column; gap: 8px; max-width: 420px; margin: 0 auto; }
.suggest button {
  text-align: left; padding: 13px 16px; border-radius: 14px;
  background: var(--bg-elev); border: 1px solid var(--line); color: var(--text);
  font-size: 14.5px; display: flex; gap: 10px; align-items: center;
  transition: transform .12s, border-color .2s;
}
.suggest button:hover { border-color: var(--accent); }
.suggest button:active { transform: scale(.98); }
.suggest .q { color: var(--accent); font-weight: 800; }

/* 떠 있는 새 글 버튼 */
.fab {
  position: absolute; right: 18px; bottom: calc(22px + var(--sab)); z-index: 20;
  height: 56px; padding: 0 22px 0 18px; border-radius: 20px;
  display: flex; align-items: center; gap: 8px;
  background: var(--grad);
  color: var(--on-accent); font-weight: 800; font-size: 15.5px;
  box-shadow: 0 12px 28px -8px color-mix(in srgb, var(--accent) 70%, transparent);
  transition: transform .15s var(--ease), box-shadow .2s;
}
.fab:active { transform: scale(.95); }
.fab svg { width: 22px; height: 22px; }

/* ---------- 글 화면 ---------- */
.thread { padding: 6px 14px 18px; display: flex; flex-direction: column; transition: padding .2s; }
.topic {
  background: var(--bg-elev); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 16px 16px 14px; margin: 4px 0 18px; box-shadow: var(--shadow-1);
}
.topic .by { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--text-3); margin-bottom: 8px; }
.topic h2 { font-size: 19px; line-height: 1.4; margin: 0 0 6px; letter-spacing: -0.03em; }
.topic .body { color: var(--text-2); font-size: 15px; }
.topic .body:empty { display: none; }

.day { align-self: center; font-size: 12px; color: var(--text-3); padding: 4px 12px; border-radius: 999px; background: var(--bg-sunk); margin: 10px 0; font-weight: 600; }

.msg { display: flex; gap: 10px; margin-top: 14px; animation: rise .3s var(--ease) both; }
.msg.cont { margin-top: 4px; }
.msg.cont .av { visibility: hidden; height: 0; }
.msg .col { min-width: 0; max-width: min(88%, 620px); display: flex; flex-direction: column; align-items: flex-start; }
.msg .name { font-size: 13px; font-weight: 800; margin: 0 0 4px 4px; display: flex; gap: 6px; align-items: baseline; }
.msg .name .model { font-weight: 600; color: var(--text-3); font-size: 11.5px; }
.msg.codex .name { color: var(--codex); }
.msg.claude .name { color: var(--claude); }
.msg.muse .name { color: var(--muse); }
.msg.gemini .name { color: var(--gemini); }
.bubble {
  background: var(--bubble);
  border: 1px solid var(--line);
  padding: 10px 14px;
  border-radius: 6px 20px 20px 20px;
  box-shadow: var(--shadow-1);
  font-size: 15px;
  position: relative;
}
.msg.cont .bubble { border-top-left-radius: 20px; }
.msg .stamp { font-size: 11px; color: var(--text-3); margin: 3px 6px 0; }
.msg.me { flex-direction: row-reverse; }
.msg.me .col { align-items: flex-end; }
.msg.me .bubble {
  background: var(--me-bubble); color: #fff; border: 0;
  border-radius: 20px 6px 20px 20px;
}
.msg.me.cont .bubble { border-top-right-radius: 20px; }
.msg.me .bubble a { color: #fff; }
.msg.me .bubble code { background: rgba(255, 255, 255, .18); }
.msg.flash .bubble { animation: flash 2.2s var(--ease); }
@keyframes flash { 0%, 40% { box-shadow: 0 0 0 3px var(--accent); } 100% { box-shadow: var(--shadow-1); } }

.sys {
  align-self: center; margin: 16px 0 4px; max-width: 92%;
  font-size: 12.5px; color: var(--text-3); text-align: center;
  padding: 6px 14px; border-radius: 999px; background: var(--bg-sunk);
}
.sys.err { color: var(--danger); background: var(--danger-soft); border-radius: 14px; }

/* 말풍선 안 서식 */
.md > :first-child { margin-top: 0; }
.md > :last-child { margin-bottom: 0; }
.md p { margin: 0 0 .55em; }
.md ul, .md ol { margin: .2em 0 .6em; padding-left: 1.3em; }
.md li { margin: .15em 0; }
.md strong { font-weight: 750; }
.md code { font-family: ui-monospace, "Cascadia Code", Consolas, monospace; font-size: .88em; background: var(--bg-sunk); padding: .1em .38em; border-radius: 6px; }
.md pre { background: var(--bg-sunk); padding: 10px 12px; border-radius: 12px; overflow-x: auto; margin: .4em 0 .6em; font-size: 13px; line-height: 1.5; }
.md pre code { background: none; padding: 0; font-size: inherit; }
.md blockquote { margin: .4em 0; padding-left: 10px; border-left: 3px solid var(--line-strong); color: var(--text-2); }
.mention { font-weight: 750; }
.mention.all { color: var(--accent); }
.mention.codex { color: var(--codex); } .mention.claude { color: var(--claude); } .mention.muse { color: var(--muse); } .mention.gemini { color: var(--gemini); }
.msg.me .mention { color: #fff; text-decoration: underline; text-underline-offset: 3px; }

/* 작성 중 */
.typing + .typing { margin-top: 8px; }
.typing { display: flex; gap: 10px; margin-top: 14px; align-items: flex-end; animation: rise .3s var(--ease) both; }
.typing .bubble { display: flex; align-items: center; gap: 10px; padding: 12px 14px; }
.typing .dots { display: flex; gap: 4px; }
.typing .dots i { width: 7px; height: 7px; border-radius: 50%; background: var(--text-3); animation: blink 1.2s infinite; }
.typing .dots i:nth-child(2) { animation-delay: .15s; }
.typing .dots i:nth-child(3) { animation-delay: .3s; }
.typing .lbl { font-size: 13px; color: var(--text-3); }
@keyframes blink { 0%, 60%, 100% { opacity: .25; transform: translateY(0); } 30% { opacity: 1; transform: translateY(-3px); } }

/* ---------- 입력창 ---------- */
.composer {
  padding: 8px 12px calc(10px + var(--sab));
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(18px); -webkit-backdrop-filter: blur(18px);
  border-top: 1px solid var(--line);
  position: relative;
}
.stopbar { display: flex; justify-content: center; }
.stopbar:empty { display: none; }
.stopbar .stop-btn { margin: 2px 0 10px; }
.stop-btn {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 9px 18px; border-radius: 999px;
  background: var(--bg-elev); color: var(--danger); font-weight: 800; font-size: 14px;
  border: 1px solid color-mix(in srgb, var(--danger) 35%, transparent);
  box-shadow: var(--shadow-2);
  animation: rise .25s var(--ease) both;
}
.stop-btn:active { transform: scale(.96); }
.stop-btn .sq { width: 10px; height: 10px; border-radius: 2px; background: currentColor; }
.chips[hidden] { display: none; }
.chips { display: flex; gap: 6px; overflow-x: auto; padding: 2px 2px 8px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex: none; display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 12px 6px 6px; border-radius: 999px;
  background: var(--bg-elev); border: 1px solid var(--line);
  font-size: 13.5px; font-weight: 700; color: var(--text-2);
  transition: border-color .15s, background .15s, transform .1s;
}
.chip.plain { padding-left: 12px; }
.chip:active { transform: scale(.95); }
.chip.on { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); }
.inputrow { display: flex; align-items: flex-end; gap: 8px; }
.field {
  flex: 1; min-width: 0;
  background: var(--bg-elev); border: 1px solid var(--line-strong);
  border-radius: 22px; padding: 4px 4px 4px 6px;
  display: flex; align-items: flex-end;
  transition: border-color .15s, box-shadow .15s;
}
.field:focus-within { border-color: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft); }
.field textarea {
  flex: 1; border: 0; outline: 0; resize: none; background: transparent;
  padding: 8px 6px; max-height: 160px; min-height: 38px; line-height: 1.45; font-size: 15.5px;
}
.at-btn { width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center; color: var(--text-3); font-weight: 800; font-size: 17px; flex: none; }
.at-btn.on { color: var(--accent); background: var(--accent-soft); }
.send {
  width: 46px; height: 46px; border-radius: 50%; flex: none;
  display: grid; place-items: center;
  background: var(--grad); color: #fff;
  transition: transform .12s, opacity .2s, filter .2s;
}
.send:disabled { opacity: .35; filter: grayscale(.6); }
.send:not(:disabled):active { transform: scale(.9); }
.send svg { width: 21px; height: 21px; }

/* ---------- 아래에서 올라오는 패널 ---------- */
.scrim { position: fixed; inset: 0; background: rgba(8, 10, 18, .45); z-index: 50; animation: fade .2s both; }
.scrim.out { animation: fade .18s reverse both; }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
.sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 51;
  max-width: 640px; margin: 0 auto;
  background: var(--bg-elev);
  border-radius: 26px 26px 0 0;
  padding: 8px 20px calc(20px + var(--sab));
  box-shadow: var(--shadow-3);
  animation: up .32s var(--ease) both;
  max-height: 92dvh; overflow-y: auto;
}
.sheet.out { animation: up .2s reverse both; }
@keyframes up { from { transform: translateY(100%); } to { transform: none; } }
@media (min-width: 700px) {
  .sheet { bottom: auto; top: 50%; border-radius: 26px; width: min(560px, 92vw); left: 50%; right: auto; transform: translate(-50%, -50%); animation: pop .25s var(--ease) both; padding-bottom: 22px; }
  .sheet.out { animation: pop .18s reverse both; }
  @keyframes pop { from { opacity: 0; transform: translate(-50%, -46%) scale(.97); } to { opacity: 1; transform: translate(-50%, -50%); } }
  .grab { display: none; }
}
.grab { width: 40px; height: 5px; border-radius: 3px; background: var(--line-strong); margin: 4px auto 14px; }
.sheet h3 { margin: 0 0 4px; font-size: 20px; letter-spacing: -0.03em; }
.sheet .sub { margin: 0 0 18px; color: var(--text-3); font-size: 14px; }
.label { display: block; font-size: 13px; font-weight: 700; color: var(--text-2); margin: 14px 0 7px; }
.input, .textarea, .select {
  width: 100%; border: 1px solid var(--line-strong); background: var(--bg);
  border-radius: 14px; padding: 12px 14px; outline: 0; font-size: 15.5px;
  transition: border-color .15s, box-shadow .15s;
}
.input:focus, .textarea:focus, .select:focus { border-color: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft); }
.textarea { min-height: 110px; resize: vertical; line-height: 1.5; }
.title-input { font-size: 18px; font-weight: 700; }
.btn {
  width: 100%; height: 52px; border-radius: 16px; margin-top: 20px;
  background: var(--grad); color: #fff;
  font-weight: 800; font-size: 16px; display: flex; align-items: center; justify-content: center; gap: 8px;
  transition: transform .12s, opacity .2s;
}
.btn:disabled { opacity: .45; }
.btn:not(:disabled):active { transform: scale(.98); }
.btn.ghost { background: var(--bg-sunk); color: var(--text); }
.btn.danger { background: var(--danger-soft); color: var(--danger); }
.btn-row { display: flex; gap: 10px; }
.btn-row .btn { margin-top: 12px; }
.pick { display: flex; gap: 8px; flex-wrap: wrap; }

.agent-head { display: flex; align-items: center; gap: 14px; margin: 4px 0 6px; }
.agent-head .nm { font-size: 21px; font-weight: 800; letter-spacing: -0.03em; }
.agent-head .st { font-size: 13.5px; color: var(--text-3); display: flex; align-items: center; gap: 6px; }
.role-input { min-height: 96px; font-size: 14.5px; }
.role-foot { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: 8px; font-size: 12.5px; color: var(--text-3); }
.mini-btn { flex: none; padding: 8px 16px; border-radius: 10px; background: var(--grad); color: #fff; font-weight: 800; font-size: 13.5px; transition: opacity .2s, transform .1s; }
.mini-btn:disabled { opacity: .35; }
.mini-btn:not(:disabled):active { transform: scale(.95); }
.role { background: var(--bg); border-radius: 14px; padding: 12px 14px; color: var(--text-2); font-size: 14px; margin-top: 12px; }
.err-detail { color: var(--danger); font-size: 13px; margin-top: 8px; }
.seg { display: flex; background: var(--bg); border: 1px solid var(--line); border-radius: 14px; padding: 4px; gap: 2px; }
.seg button { flex: 1; min-width: 0; white-space: nowrap; padding: 9px 2px; border-radius: 10px; font-weight: 700; font-size: 13.5px; color: var(--text-2); transition: background .15s, color .15s; }
.seg button.on { background: var(--bg-elev); color: var(--text); box-shadow: var(--shadow-2); }

/* ---------- 로그인 ---------- */
.login { flex: 1; display: flex; flex-direction: column; justify-content: center; padding: 24px 24px calc(40px + var(--sab)); max-width: 420px; width: 100%; margin: 0 auto; }
.login .hero { text-align: center; margin-bottom: 34px; }
.login .hero .brand-mark { width: 76px; height: 76px; border-radius: 22px; box-shadow: 0 18px 40px -12px rgba(79, 70, 229, .6); margin-bottom: 18px; }
.login h1 { margin: 0 0 6px; font-size: 30px; letter-spacing: -0.04em; }
.login p { margin: 0; color: var(--text-2); }
.login .crewline { display: flex; justify-content: center; gap: 6px; margin-top: 16px; font-size: 13px; color: var(--text-3); align-items: center; }
.login .msg-err { color: var(--danger); font-size: 14px; margin-top: 10px; min-height: 20px; text-align: center; }
.shake { animation: shake .4s; }
@keyframes shake { 20%, 60% { transform: translateX(-6px); } 40%, 80% { transform: translateX(6px); } }

/* ---------- 알림 ---------- */
.toast {
  position: fixed; left: 50%; bottom: calc(96px + var(--sab)); z-index: 80;
  transform: translate(-50%, 20px); opacity: 0; pointer-events: none;
  background: var(--text); color: var(--bg); padding: 11px 18px; border-radius: 14px;
  font-size: 14px; font-weight: 600; box-shadow: var(--shadow-2);
  transition: opacity .2s, transform .25s var(--ease);
  max-width: calc(100vw - 32px);
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

.conn {
  margin: 0 16px 10px; padding: 9px 14px; border-radius: 12px; font-size: 13px; font-weight: 600;
  background: var(--danger-soft); color: var(--danger); display: flex; gap: 8px; align-items: center;
}

.jump {
  position: absolute; right: 16px; bottom: calc(100% + 12px); z-index: 5;
  width: 42px; height: 42px; border-radius: 50%; display: grid; place-items: center;
  background: var(--bg-elev); border: 1px solid var(--line-strong); box-shadow: var(--shadow-2); color: var(--text-2);
}
.jump .n { position: absolute; top: -5px; right: -5px; min-width: 20px; height: 20px; border-radius: 10px; background: var(--accent); color: #fff; font-size: 11px; font-weight: 800; display: grid; place-items: center; padding: 0 5px; }

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

.av-btn { flex: none; align-self: flex-start; border-radius: 50%; }
.msg.cont .av-btn { visibility: hidden; height: 0; }

/* ---------- 턴 구분선 ---------- */
.round-div { display: flex; align-items: center; gap: 12px; margin: 22px 4px 4px; color: var(--accent); font-size: 12.5px; font-weight: 800; letter-spacing: .02em; }
.round-div::before, .round-div::after { content: ""; flex: 1; height: 1px; background: linear-gradient(90deg, transparent, color-mix(in srgb, var(--accent) 40%, transparent)); }
.round-div::after { transform: scaleX(-1); }
.round-div span { padding: 4px 12px; border-radius: 999px; background: var(--accent-soft); }
.rule-pill { margin-left: 6px; padding: 1px 8px; border-radius: 999px; background: var(--bg-sunk); color: var(--text-3); font-size: 11.5px; font-weight: 600; white-space: nowrap; }

/* ---------- 토론 규칙 편집기 ---------- */
.rule-line { display: flex; align-items: center; justify-content: space-between; margin: 16px 0 8px; }
.link-btn { color: var(--accent); font-weight: 700; font-size: 14px; padding: 4px 0; }
#nt-rule { margin-bottom: 4px; }
.rule-desc { margin: 10px 2px 4px; font-size: 13.5px; color: var(--text-2); min-height: 2.9em; }
.stepper-row { display: flex; align-items: center; justify-content: space-between; margin-top: 10px; font-weight: 700; font-size: 14px; color: var(--text-2); }
.stepper { display: flex; align-items: center; gap: 4px; background: var(--bg); border: 1px solid var(--line); border-radius: 14px; padding: 4px; }
.stepper button { width: 38px; height: 36px; border-radius: 10px; font-size: 20px; font-weight: 700; color: var(--text); }
.stepper button:not(:disabled):active { background: var(--bg-sunk); }
.stepper button:disabled { opacity: .3; }
.stepper b { min-width: 30px; text-align: center; font-size: 17px; }
.order { margin-top: 12px; display: flex; flex-direction: column; gap: 6px; }
.order-row { display: flex; align-items: center; gap: 10px; padding: 8px 8px 8px 12px; border-radius: 14px; background: var(--bg); border: 1px solid var(--line); font-weight: 700; }
.order-row .grow { flex: 1; }
.order-n { width: 18px; color: var(--text-3); font-size: 13px; }
.order-row button { width: 34px; height: 34px; border-radius: 10px; color: var(--text-2); font-size: 16px; }
.order-row button:disabled { opacity: .25; }
.order-row button:not(:disabled):active { background: var(--bg-sunk); }

/* ---------- 잔여량 ---------- */
.label-row { display: flex; align-items: center; justify-content: space-between; margin: 4px 0 8px; }
#usage-list { display: flex; flex-direction: column; gap: 8px; margin-bottom: 18px; }
.usage-card { background: var(--bg); border: 1px solid var(--line); border-radius: 16px; padding: 12px 14px; }
.usage-head { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.usage-head b { font-size: 15px; }
.usage-today { margin-left: auto; font-size: 12px; color: var(--text-3); white-space: nowrap; }
.usage-note { margin: 2px 0 0; font-size: 12.5px; color: var(--text-3); }
.usage-mini { margin-top: 12px; background: var(--bg); border-radius: 14px; padding: 10px 12px; }
.limit + .limit { margin-top: 8px; }
.limit-top { display: flex; justify-content: space-between; font-size: 13px; font-weight: 600; color: var(--text-2); }
.limit-top b { font-weight: 800; }
.limit-top b.ok { color: var(--ok); } .limit-top b.warn { color: var(--warn); } .limit-top b.low { color: var(--danger); }
.bar { height: 7px; border-radius: 4px; background: var(--bg-sunk); margin-top: 5px; overflow: hidden; }
.limit.compact .bar { height: 5px; }
.bar i { display: block; height: 100%; border-radius: 4px; transition: width .4s var(--ease); }
.bar i.ok { background: var(--ok); } .bar i.warn { background: var(--warn); } .bar i.low { background: var(--danger); }
.limit-sub { font-size: 11.5px; color: var(--text-3); margin-top: 4px; }

/* ---------- 모델 고르기(토큰 소모 등급 색) ---------- */
.cost-legend { display: inline-flex; align-items: center; gap: 4px; font-size: 11.5px; color: var(--text-3); }
.cost-legend i { width: 9px; height: 9px; border-radius: 3px; margin-left: 6px; border: 1px solid; }
.cost-legend i.low { background: var(--cost-low); border-color: var(--cost-low-line); }
.cost-legend i.mid { background: var(--cost-mid); border-color: var(--cost-mid-line); }
.cost-legend i.high { background: var(--cost-high); border-color: var(--cost-high-line); }
.model-list { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.model-opt {
  position: relative; text-align: left; min-height: 52px;
  display: flex; flex-direction: column; justify-content: center; gap: 1px;
  padding: 9px 30px 9px 12px; border-radius: 14px;
  background: var(--cost-none); border: 1.5px solid var(--line-strong);
  transition: transform .12s var(--ease), border-color .15s, box-shadow .15s;
}
.model-opt:active { transform: scale(.97); }
.model-opt .mn { font-weight: 750; font-size: 14px; line-height: 1.25; color: var(--text); }
.model-opt .mc { font-size: 11.5px; font-weight: 700; }
.model-opt.cost-low { background: var(--cost-low); border-color: var(--cost-low-line); }
.model-opt.cost-low .mc { color: var(--cost-low-ink); }
.model-opt.cost-mid { background: var(--cost-mid); border-color: var(--cost-mid-line); }
.model-opt.cost-mid .mc { color: var(--cost-mid-ink); }
.model-opt.cost-high { background: var(--cost-high); border-color: var(--cost-high-line); }
.model-opt.cost-high .mc { color: var(--cost-high-ink); }
.model-opt .ck {
  position: absolute; right: 9px; top: 50%; transform: translateY(-50%) scale(.6); opacity: 0;
  width: 20px; height: 20px; border-radius: 50%; display: grid; place-items: center;
  background: var(--grad); color: #fff; font-size: 11px; font-weight: 900;
  transition: opacity .15s, transform .2s var(--ease);
}
.model-opt.on { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.model-opt.on .ck { opacity: 1; transform: translateY(-50%) scale(1); }

a.btn { text-decoration: none; }

/* ---------- 프로젝트 ---------- */
.badge.proj { background: color-mix(in srgb, var(--codex) 14%, transparent); color: var(--codex-2); }
.rule-pill.proj { color: var(--codex-2); background: color-mix(in srgb, var(--codex) 12%, transparent); }
.proj-note { margin: 8px 2px 0; font-size: 12.5px; color: var(--text-3); }

/* 꾹 누르는 중: 살짝 눌려 들어가며 삭제할 수 있음을 알린다 */
.card { -webkit-touch-callout: none; user-select: none; }
.card.pressing { transform: scale(.97); border-color: color-mix(in srgb, var(--danger) 45%, transparent); transition: transform .45s var(--ease), border-color .45s; }

/* ---------- 그림 첨부 ---------- */
.img-btn svg { width: 20px; height: 20px; }
.att-strip { display: flex; gap: 8px; overflow-x: auto; padding: 2px 2px 10px; scrollbar-width: none; }
.att-strip[hidden] { display: none; }
.att { position: relative; flex: none; width: 64px; height: 64px; border-radius: 12px; overflow: hidden; background: var(--bg-sunk); border: 1px solid var(--line); }
.att img { width: 100%; height: 100%; object-fit: cover; display: block; }
.att.loading img { opacity: .45; }
.att-spin { position: absolute; inset: 0; margin: auto; width: 22px; height: 22px; border-radius: 50%; border: 2.5px solid var(--accent); border-right-color: transparent; animation: spin .8s linear infinite; }
.att-x { position: absolute; top: 3px; right: 3px; width: 20px; height: 20px; border-radius: 50%; background: rgba(0,0,0,.6); color: #fff; font-size: 14px; line-height: 20px; text-align: center; }
.composer.drop { outline: 2px dashed var(--accent); outline-offset: -6px; }
.att-grid { display: grid; gap: 4px; margin-top: 4px; max-width: min(320px, 100%); border-radius: 16px; overflow: hidden; }
.att-grid.n1 { grid-template-columns: 1fr; }
.att-grid.n2, .att-grid.n4 { grid-template-columns: 1fr 1fr; }
.att-grid.n3 { grid-template-columns: 1fr 1fr 1fr; }
.att-img { width: 100%; display: block; background: var(--bg-sunk); cursor: zoom-in; }
.att-grid:not(.n1) .att-img { aspect-ratio: 1; object-fit: cover; }
.att-grid.n1 .att-img { max-height: 360px; object-fit: contain; }
.lightbox { position: fixed; inset: 0; z-index: 90; background: rgba(4,6,12,.92); display: grid; place-items: center; animation: fade .15s both; }
.lightbox img { max-width: 96vw; max-height: 90dvh; object-fit: contain; }
.lb-x { position: absolute; top: calc(10px + var(--sat)); right: 12px; width: 42px; height: 42px; border-radius: 50%; background: rgba(255,255,255,.14); color: #fff; font-size: 24px; }
