/* Channel 16 — 다크 단일 테마 (차 안 야간 기준) */
:root {
  --bg: #08090C;
  --bg-glow: radial-gradient(1200px 600px at 50% -20%, rgba(255, 106, 26, .07), transparent 60%);
  --panel: #0C0D11;
  --card: #121419;
  --card-hi: #171A20;
  --fg: #EDEEF1;
  --fg2: #9A9DA6;
  --fg3: #5F626B;
  --line: rgba(255, 255, 255, .09);
  --line2: rgba(255, 255, 255, .06);
  --fill: rgba(255, 255, 255, .05);
  --fill2: rgba(255, 255, 255, .09);
  --accent: #FF6A1A;
  --accent-press: #FF7F3A;
  --accent-soft: rgba(255, 106, 26, .14);
  --accent-ring: rgba(255, 106, 26, .30);
  --ok: #34D399;
  --err: #F87171;
  --err-soft: rgba(248, 113, 113, .12);
  --info: #60A5FA;
  --info-soft: rgba(96, 165, 250, .14);
  --hl: inset 0 1px 0 rgba(255, 255, 255, .04);
  --shadow: var(--hl), 0 1px 2px rgba(0, 0, 0, .5), 0 8px 24px rgba(0, 0, 0, .35);
  --shadow-sm: var(--hl), 0 1px 2px rgba(0, 0, 0, .4);
  --shadow-lg: 0 2px 6px rgba(0, 0, 0, .5), 0 24px 60px rgba(0, 0, 0, .6);
  --glass: rgba(8, 9, 12, .72);
  --r-card: 16px;
  --r-btn: 12px;
  --ease: cubic-bezier(.22, .8, .24, 1);
  --t: 200ms;
  --topbar: 56px;
  --tabbar: 58px;
  --orb: 176px;
  --font: "Pretendard Variable", Pretendard, -apple-system, BlinkMacSystemFont, "Apple SD Gothic Neo", "Noto Sans KR", system-ui, sans-serif;
  --mono: ui-monospace, "SF Mono", "JetBrains Mono", Menlo, Consolas, monospace;
  color-scheme: dark;
}

/* ---------- 기본 */
*, *::before, *::after { box-sizing: border-box; }
* { -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg); color: var(--fg);
  font: 400 15px/1.55 var(--font); letter-spacing: -0.01em;
  -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility; overflow: hidden;
  font-variant-numeric: tabular-nums;
}
[hidden] { display: none !important; }
button { font: inherit; color: inherit; letter-spacing: inherit; background: none; border: 0; padding: 0; margin: 0; cursor: pointer; }
input { font: inherit; letter-spacing: inherit; color: inherit; }
h1, h2, h3, p { margin: 0; }
a { color: var(--info); text-decoration: none; }
a:hover { text-decoration: underline; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 6px; }
::selection { background: var(--accent-ring); }

.i, .orb-mic {
  width: 20px; height: 20px; flex: none;
  fill: none; stroke: currentColor; stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round;
}
.logo { width: 28px; height: 28px; flex: none; border-radius: 7px; }

/* ---------- 버튼 */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 48px; padding: 0 18px; border-radius: var(--r-btn);
  font-size: 16px; font-weight: 600; letter-spacing: -0.015em; white-space: nowrap;
  transition: background-color var(--t) var(--ease), transform 120ms var(--ease), box-shadow var(--t) var(--ease), opacity var(--t);
  user-select: none;
}
.btn:active { transform: scale(.98); }
.btn:disabled { opacity: .55; cursor: default; transform: none; }
.btn-block { width: 100%; }
.btn-primary { background: var(--accent); color: #fff; box-shadow: 0 1px 2px rgba(255, 106, 26, .25), 0 4px 12px rgba(255, 106, 26, .22); }
.btn-primary:hover { background: var(--accent-press); }
.btn-secondary { background: var(--fill); color: var(--fg); }
.btn-secondary:hover { background: var(--fill2); }
.btn-ghost { color: var(--fg2); }
.btn-ghost:hover { background: var(--fill); color: var(--fg); }
.btn-sm { min-height: 36px; padding: 0 12px; font-size: 13px; border-radius: 10px; gap: 6px; }
.btn-sm .i { width: 16px; height: 16px; }
.icon-btn {
  width: 36px; height: 36px; border-radius: 10px; display: inline-grid; place-items: center; color: var(--fg2);
  transition: background-color var(--t) var(--ease), color var(--t);
}
.icon-btn:hover { background: var(--fill); color: var(--fg); }
.icon-btn:active { background: var(--fill2); }

/* ---------- 로그인 */
.login {
  min-height: 100%; height: 100%; overflow: auto; display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: max(24px, env(safe-area-inset-top)) 20px max(20px, env(safe-area-inset-bottom));
  background:
    radial-gradient(700px 380px at 50% -5%, rgba(255, 106, 26, .16), transparent 70%),
    var(--bg);
}
.login-card {
  width: 100%; max-width: 380px; margin: auto 0 0;
  background: var(--card); border: 1px solid var(--line2); border-radius: var(--r-card); box-shadow: var(--shadow);
  padding: 32px 24px 24px;
  animation: rise 360ms var(--ease) both;
}
.login-brand { display: flex; flex-direction: column; align-items: center; text-align: center; margin-bottom: 28px; }
.logo-lg { width: 56px; height: 56px; border-radius: 14px; box-shadow: 0 6px 18px rgba(255, 106, 26, .28); margin-bottom: 16px; }
.login-brand h1 { font-size: 24px; font-weight: 700; letter-spacing: -0.03em; line-height: 1.2; }
.login-brand p { margin-top: 6px; font-size: 14px; color: var(--fg2); }
#login-form { display: flex; flex-direction: column; gap: 16px; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field-label { font-size: 13px; font-weight: 600; color: var(--fg2); padding-left: 2px; }
.field input {
  height: 48px; padding: 0 14px; border-radius: var(--r-btn); width: 100%;
  background: var(--card); border: 1px solid var(--line); font-size: 16px; outline: none;
  transition: border-color var(--t) var(--ease), box-shadow var(--t) var(--ease);
}
.field input:hover { border-color: var(--fg3); }
.field input:focus { border-color: var(--accent); box-shadow: 0 0 0 4px var(--accent-ring); }
.login.has-err .field input { border-color: var(--err); }
.login.has-err .field input:focus { box-shadow: 0 0 0 4px var(--err-soft); }
.field-err { font-size: 13px; color: var(--err); margin: -8px 0 0 2px; }
.field-err:empty { display: none; }
.switch-row {
  display: flex; align-items: center; justify-content: space-between; min-height: 44px;
  font-size: 15px; color: var(--fg); cursor: pointer; position: relative; user-select: none;
}
.switch-row input { position: absolute; opacity: 0; width: 1px; height: 1px; pointer-events: none; }
.switch {
  width: 44px; height: 26px; border-radius: 999px; background: var(--fill2); position: relative; flex: none;
  transition: background-color var(--t) var(--ease);
}
.switch::after {
  content: ""; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%;
  background: #fff; box-shadow: 0 1px 3px rgba(0, 0, 0, .2);
  transition: transform var(--t) var(--ease);
}
.switch-row input:checked + .switch { background: var(--accent); }
.switch-row input:checked + .switch::after { transform: translateX(18px); }
.switch-row input:focus-visible + .switch { outline: 2px solid var(--accent); outline-offset: 2px; }
#login-btn { margin-top: 4px; }
.login-foot { margin: auto 0 0; padding-top: 32px; font-size: 12px; color: var(--fg3); font-weight: 500; letter-spacing: 0; }

/* ---------- 앱 셸 */
.app {
  height: 100%; height: 100dvh; display: grid; grid-template-columns: minmax(0, 1fr); grid-template-rows: auto minmax(0, 1fr) auto;
  background: var(--bg-glow), var(--bg);
}
.topbar {
  position: relative; z-index: 20;
  height: calc(var(--topbar) + env(safe-area-inset-top));
  padding: env(safe-area-inset-top) max(16px, env(safe-area-inset-right)) 0 max(16px, env(safe-area-inset-left));
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  background: var(--glass); border-bottom: 1px solid var(--line);
  -webkit-backdrop-filter: saturate(180%) blur(16px); backdrop-filter: saturate(180%) blur(16px);
  transition: box-shadow var(--t) var(--ease);
}
.topbar.scrolled { box-shadow: 0 1px 12px rgba(0, 0, 0, .05); }
.brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.wordmark { font-size: 17px; font-weight: 700; letter-spacing: -0.03em; white-space: nowrap; }
.by { font-size: 12px; color: var(--fg3); font-weight: 500; white-space: nowrap; letter-spacing: 0; padding-top: 2px; }
@media (max-width: 380px) { .by { display: none; } }

.me { position: relative; }
.avatar {
  width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center;
  background: var(--fill); color: var(--fg); border: 1px solid var(--line);
  font-size: 13px; font-weight: 700; letter-spacing: 0; text-transform: uppercase;
  transition: box-shadow var(--t) var(--ease), background-color var(--t);
}
button.avatar { position: relative; }
button.avatar::before { content: ""; position: absolute; inset: -5px; }   /* 44px 터치 타깃 */
button.avatar:hover { background: var(--fill2); }
button.avatar[aria-expanded="true"] { box-shadow: 0 0 0 4px var(--accent-ring); }
.avatar-sm { width: 36px; height: 36px; }
.menu {
  position: absolute; right: 0; top: calc(100% + 10px); width: 232px; z-index: 30;
  background: var(--card); border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow-lg);
  padding: 6px; transform-origin: top right; animation: pop 160ms var(--ease) both;
}
.menu-user { display: flex; align-items: center; gap: 10px; padding: 10px 10px 12px; border-bottom: 1px solid var(--line2); margin-bottom: 6px; }
.menu-user-text { display: flex; flex-direction: column; min-width: 0; line-height: 1.3; }
.menu-user-text strong { font-size: 15px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.menu-user-text small { font-size: 12px; color: var(--fg2); }
.menu-item {
  display: flex; align-items: center; gap: 10px; width: 100%; min-height: 44px; padding: 0 10px;
  border-radius: 10px; font-size: 15px; color: var(--fg); text-align: left;
  transition: background-color var(--t);
}
.menu-item .i { color: var(--fg2); width: 18px; height: 18px; }
.menu-item:hover { background: var(--fill); }

.panes { position: relative; min-height: 0; }
.pane { height: 100%; min-height: 0; display: none; flex-direction: column; }
.panes[data-tab="voice"] .voice, .panes[data-tab="explore"] .explore { display: flex; }

.tabbar {
  display: flex; z-index: 20;
  padding: 0 max(8px, env(safe-area-inset-right)) env(safe-area-inset-bottom) max(8px, env(safe-area-inset-left));
  background: var(--glass); border-top: 1px solid var(--line);
  -webkit-backdrop-filter: saturate(180%) blur(16px); backdrop-filter: saturate(180%) blur(16px);
}
.tab {
  flex: 1; height: var(--tabbar); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  color: var(--fg3); font-size: 11px; font-weight: 600; letter-spacing: 0;
  transition: color var(--t) var(--ease);
}
.tab .i { width: 24px; height: 24px; transition: transform var(--t) var(--ease); }
.tab:active .i { transform: scale(.9); }
.tab.on { color: var(--accent); }

@media (min-width: 900px) {
  .panes { display: grid; grid-template-columns: 380px minmax(0, 1fr); }
  .pane { display: flex !important; }
  .explore { background: rgba(12, 13, 17, .7); border-right: 1px solid var(--line2); }
  .tabbar { display: none; }
  :root { --orb: 196px; }
}

/* ---------- 토스트 */
.toast {
  position: fixed; left: 50%; top: calc(env(safe-area-inset-top) + var(--topbar) + 10px); z-index: 40;
  max-width: min(92vw, 480px); display: flex; align-items: center; gap: 8px;
  padding: 8px 14px 8px 12px; border-radius: 999px;
  background: var(--fg); color: var(--bg); font-size: 13px; font-weight: 500; line-height: 1.35;
  box-shadow: var(--shadow-lg);
  transform: translate(-50%, -8px); opacity: 0; pointer-events: none; visibility: hidden;
  transition: transform 220ms var(--ease), opacity 220ms var(--ease), visibility 0s 220ms;
}
.toast.show { transform: translate(-50%, 0); opacity: 1; visibility: visible; pointer-events: auto; transition-delay: 0s; }
.toast .i { width: 16px; height: 16px; }
.toast.err .i { color: var(--err); }
.toast.info .i { color: var(--info); }
.toast span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- 음성 */
.voice-inner {
  flex: 1; min-height: 0; width: 100%; max-width: 680px; margin: 0 auto;
  display: flex; flex-direction: column; padding: 16px 16px 0;
}
.target {
  align-self: center; max-width: 100%; min-height: 44px; display: flex; align-items: center; gap: 10px;
  padding: 0 12px 0 6px; border-radius: 999px;
  background: var(--card); border: 1px solid var(--line2); box-shadow: var(--shadow-sm);
  font-size: 14px; font-weight: 500; text-align: left;
  transition: background-color var(--t), box-shadow var(--t) var(--ease), transform 120ms var(--ease);
}
.target:hover { box-shadow: var(--shadow); }
.target:active { transform: scale(.985); }
.target-ic {
  width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center; flex: none;
  background: var(--accent-soft); color: var(--accent);
}
.target-ic .i { width: 16px; height: 16px; }
.target-text { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.target-text .sep { color: var(--fg3); margin: 0 5px; }
.target-text .dim { color: var(--fg2); }
.target-chev { width: 16px; height: 16px; color: var(--fg3); }
.target.is-empty { background: transparent; border: 1px dashed var(--line); box-shadow: none; color: var(--fg2); font-weight: 400; padding-left: 14px; }
.target.is-empty .target-ic { display: none; }
.target.is-empty:hover { background: var(--card); border-color: var(--fg3); }

.stage { flex: none; display: flex; flex-direction: column; align-items: center; padding: 40px 0 20px; }
.orb-wrap { --lv: 0; position: relative; width: var(--orb); height: var(--orb); }
.orb {
  position: absolute; inset: 0; border-radius: 50%; display: grid; place-items: center; z-index: 2;
  background: radial-gradient(circle at 50% 30%, #1E2129 0%, #121419 62%, #0E1014 100%);
  color: var(--accent);
  border: 1px solid rgba(255, 255, 255, .07);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, .06),
    inset 0 -10px 24px rgba(0, 0, 0, .35),
    0 0 0 10px var(--bg),
    0 0 0 11px rgba(255, 106, 26, .22),
    0 20px 50px rgba(0, 0, 0, .55),
    0 0 90px rgba(255, 106, 26, .08);
  transition: background 250ms var(--ease), color 250ms var(--ease), box-shadow 250ms var(--ease), transform 160ms var(--ease), border-color 250ms;
}
.orb:hover { box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, .07), inset 0 -10px 24px rgba(0, 0, 0, .35),
    0 0 0 10px var(--bg), 0 0 0 11px rgba(255, 106, 26, .4),
    0 20px 50px rgba(0, 0, 0, .55), 0 0 100px rgba(255, 106, 26, .16); }
.orb:active { transform: scale(.965); }
.orb:focus-visible { outline-offset: 6px; border-radius: 50%; }
.orb-mic { width: 30%; height: 30%; stroke-width: 1.6; transition: opacity var(--t), transform 250ms var(--ease); }
.bars {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; gap: 7%;
  opacity: 0; transition: opacity var(--t);
}
.bars i {
  display: block; width: 5.5%; height: 34%; border-radius: 99px; background: currentColor;
  transform: scaleY(.18); transition: transform 90ms linear;
}
body[data-state="listening"] .orb, body[data-state="speaking"] .orb {
  background: radial-gradient(circle at 50% 28%, #FF8A47 0%, #FF6A1A 55%, #E2550A 100%); color: #fff; border-color: transparent;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .25), inset 0 -10px 24px rgba(120, 30, 0, .25),
    0 14px 40px rgba(255, 106, 26, .35), 0 0 120px rgba(255, 106, 26, .30);
}
body[data-state="speaking"] .orb-mic { opacity: 0; transform: scale(.8); }
body[data-state="speaking"] .bars { opacity: 1; }
body[data-state="connecting"] .orb { color: var(--fg3); }

.ripple {
  position: absolute; inset: 0; border-radius: 50%; background: var(--accent); z-index: 1;
  opacity: 0; transform: scale(1);
  transition: transform 140ms linear, opacity 300ms var(--ease);
}
body[data-state="listening"] .ripple {
  opacity: var(--o);
  transform: scale(calc(1 + var(--k) * .22 + var(--lv) * var(--k)));
}
.ring { position: absolute; border-radius: 50%; pointer-events: none; opacity: 0; transition: opacity 250ms var(--ease); }
.ring-connect { inset: -12px; border: 2px solid var(--line); border-top-color: var(--accent); }
.ring-work { inset: -20px; border: 2.5px solid var(--info-soft); border-top-color: var(--info); border-right-color: var(--info); }
body[data-state="connecting"] .ring-connect { opacity: 1; animation: spin 900ms linear infinite; }
body[data-work] .ring-work { opacity: 1; animation: spin 1.6s linear infinite; }
body[data-work][data-state="listening"] .ring-work { inset: -26px; }

.talk-label { margin-top: 32px; font-size: 17px; font-weight: 600; letter-spacing: -0.02em; }
.status { margin-top: 2px; font-size: 14px; color: var(--fg2); max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.work {
  margin-top: 10px; display: inline-flex; align-items: center; gap: 7px; max-width: 100%;
  padding: 3px 10px 3px 9px; border-radius: 999px; background: var(--info-soft); color: var(--info);
  font-size: 12px; font-weight: 600; letter-spacing: 0;
}
.work span:last-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.work-dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; flex: none; animation: blink 1.4s ease-in-out infinite; }

@media (max-height: 700px) {
  :root { --orb: 136px; }
  .stage { padding: 28px 0 12px; }
  .talk-label { margin-top: 22px; }
}

/* 대화가 쌓이면 버튼을 줄여 자막 공간 확보 */
.voice-inner:has(.transcript:not(:empty)) .stage { padding: 34px 0 8px; }
.voice-inner:has(.transcript:not(:empty)) { --orb: 112px; }
.voice-inner:has(.transcript:not(:empty)) .talk-label { margin-top: 22px; font-size: 15px; }
@media (min-width: 900px) and (min-height: 760px) { .voice-inner:has(.transcript:not(:empty)) { --orb: 150px; } }

/* 스크롤바 */
* { scrollbar-width: thin; scrollbar-color: rgba(255, 255, 255, .12) transparent; }
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, .10); border-radius: 8px; border: 2px solid transparent; background-clip: padding-box; }
::-webkit-scrollbar-thumb:hover { background-color: rgba(255, 255, 255, .18); }
::-webkit-scrollbar-button { display: none; height: 0; }

/* 자막 */
.transcript {
  flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain;
  display: flex; flex-direction: column; gap: 8px; padding: 16px 2px 20px;
  -webkit-mask-image: linear-gradient(to bottom, transparent 0, #000 20px);
          mask-image: linear-gradient(to bottom, transparent 0, #000 20px);
}
.transcript:empty::before {
  content: "버튼을 누르고 말해 보세요. 대화와 작업 결과가 여기에 쌓입니다.";
  margin: 12px auto auto; max-width: 240px; text-align: center; font-size: 13px; color: var(--fg3); line-height: 1.6;
}
.bubble {
  max-width: 84%; padding: 9px 14px; border-radius: 18px; font-size: 15px; line-height: 1.5;
  white-space: pre-wrap; word-break: break-word; animation: rise 220ms var(--ease) both;
  transition: opacity var(--t);
}
.bubble.user { align-self: flex-end; background: #23262E; border-bottom-right-radius: 6px; }
.bubble.ai { align-self: flex-start; background: var(--card); border: 1px solid var(--line2); box-shadow: var(--shadow-sm); border-bottom-left-radius: 6px; }
.bubble.partial { opacity: .5; }
.sys {
  align-self: center; display: inline-flex; align-items: center; gap: 6px; max-width: 92%;
  font-size: 12px; color: var(--fg2); padding: 2px 0; text-align: center; animation: rise 220ms var(--ease) both;
}
.sys .i { width: 14px; height: 14px; color: var(--fg3); }

/* Hermes 작업 카드 */
.job {
  align-self: stretch; margin: 4px 0; padding: 14px 16px;
  background: var(--card); border: 1px solid var(--line2); border-radius: var(--r-card); box-shadow: var(--shadow);
  animation: rise 240ms var(--ease) both;
}
.job-head { display: flex; align-items: center; gap: 8px; min-height: 28px; }
.dot { width: 8px; height: 8px; border-radius: 50%; flex: none; background: var(--fg3); }
.job.is-running .dot { background: var(--info); box-shadow: 0 0 0 4px var(--info-soft); animation: blink 1.4s ease-in-out infinite; }
.job.is-done .dot { background: var(--ok); }
.job.is-failed .dot { background: var(--err); }
.job-title { font-size: 13px; font-weight: 700; letter-spacing: -0.01em; }
.job-status { font-size: 13px; color: var(--fg2); }
.job.is-running .job-status { color: var(--info); }
.job.is-failed .job-status { color: var(--err); }
.job-where { margin-left: auto; font-size: 12px; color: var(--fg3); max-width: 40%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.job-stop { margin: -4px -8px -4px 4px; }
.job-req {
  margin-top: 6px; font-size: 15px; font-weight: 500; line-height: 1.5; word-break: break-word;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.chip {
  display: inline-flex; align-items: center; gap: 5px; height: 24px; padding: 0 9px; border-radius: 999px;
  background: var(--fill); color: var(--fg2); font: 500 12px/1 var(--mono); letter-spacing: 0;
}
.chip .i { width: 12px; height: 12px; }
.chip.now { background: var(--info-soft); color: var(--info); }
.job-result { margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--line2); }
.job-result .md { font-size: 14px; color: var(--fg); }
.job-result.clamped .md {
  max-height: calc(1.6em * 3); overflow: hidden;
  -webkit-mask-image: linear-gradient(to bottom, #000 55%, transparent);
          mask-image: linear-gradient(to bottom, #000 55%, transparent);
}
.more-toggle { margin: 8px 0 -4px -8px; }
.more-toggle .i { transition: transform var(--t) var(--ease); }
.job-result:not(.clamped) .more-toggle .i { transform: rotate(180deg); }
.job-err { margin-top: 10px; padding: 8px 10px; border-radius: 10px; background: var(--err-soft); color: var(--err); font-size: 13px; word-break: break-word; }

/* 마크다운 */
.md { line-height: 1.6; word-break: break-word; }
.md p { margin: 0; }
.md .gap { height: .55em; }
.md .h { font-weight: 700; margin-top: .3em; }
.md ul, .md ol { margin: .2em 0; padding-left: 1.3em; }
.md li { margin: .1em 0; }
.md li::marker { color: var(--fg3); }
.md strong { font-weight: 650; }
.md blockquote { margin: .2em 0; padding-left: 10px; border-left: 3px solid var(--line); color: var(--fg2); }
.md code { font: 500 .88em/1.4 var(--mono); background: var(--fill); padding: .12em .38em; border-radius: 6px; letter-spacing: 0; }
.md pre {
  margin: .5em 0; padding: 12px 14px; border-radius: 12px; background: var(--fill); overflow-x: auto;
  font: 12.5px/1.6 var(--mono); letter-spacing: 0; white-space: pre;
}
.md pre code { background: none; padding: 0; font: inherit; }
.md a { word-break: break-all; }

/* 승인 시트 */
.sheet {
  position: fixed; z-index: 50; left: 0; right: 0; bottom: 0; margin: 0 auto; width: 100%; max-width: 520px;
  background: var(--card); border-radius: 20px 20px 0 0; box-shadow: 0 -2px 6px rgba(0, 0, 0, .04), 0 -16px 48px rgba(0, 0, 0, .14);
  border: 1px solid var(--line2); border-bottom: 0;
  padding: 8px 20px calc(20px + env(safe-area-inset-bottom));
  transform: translateY(105%); visibility: hidden;
  transition: transform 280ms var(--ease), visibility 0s 280ms;
}
.sheet.open { transform: none; visibility: visible; transition-delay: 0s; }
@media (min-width: 900px) {
  .sheet { bottom: 24px; border-radius: 20px; border-bottom: 1px solid var(--line2); padding-bottom: 20px; transform: translateY(calc(100% + 32px)); }
}
.sheet-grab { width: 36px; height: 5px; border-radius: 99px; background: var(--line); margin: 0 auto 14px; }
.sheet-head { display: flex; align-items: center; gap: 12px; }
.sheet-ic { width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; background: var(--accent-soft); color: var(--accent); flex: none; }
.sheet-head h3 { font-size: 18px; font-weight: 700; letter-spacing: -0.02em; line-height: 1.3; }
.sheet-sub { font-size: 13px; color: var(--fg2); }
.sheet-text { margin-top: 16px; font-size: 15px; line-height: 1.55; white-space: pre-wrap; word-break: break-word; max-height: 30vh; overflow: auto; }
.sheet-text:empty { display: none; }
.sheet-cmd {
  margin: 12px 0 0; padding: 12px 14px; border-radius: 12px; background: var(--fill); max-height: 24vh; overflow: auto;
  font: 12.5px/1.6 var(--mono); white-space: pre-wrap; word-break: break-all;
}
.sheet-actions { display: flex; flex-direction: column; gap: 8px; margin-top: 20px; }
.sheet-actions .btn { min-height: 52px; }

/* ---------- 탐색 */
.ex-top { flex: none; padding: 12px 16px 4px; display: flex; flex-direction: column; gap: 8px; }
.search { position: relative; display: flex; align-items: center; }
.search-ic { position: absolute; left: 12px; width: 18px; height: 18px; color: var(--fg3); pointer-events: none; }
.search input {
  width: 100%; height: 44px; padding: 0 40px 0 38px; border-radius: var(--r-btn);
  background: var(--fill); border: 1px solid transparent; font-size: 16px; outline: none; -webkit-appearance: none; appearance: none;
  transition: background-color var(--t), border-color var(--t), box-shadow var(--t) var(--ease);
}
.search input::placeholder { color: var(--fg3); }
.search input::-webkit-search-cancel-button { display: none; }
.search input:focus { background: var(--card); border-color: var(--accent); box-shadow: 0 0 0 4px var(--accent-ring); }
.search-clear {
  position: absolute; right: 4px; width: 36px; height: 36px; display: grid; place-items: center; border-radius: 10px; color: var(--fg3);
}
.search-clear .i { width: 16px; height: 16px; padding: 2px; border-radius: 50%; background: var(--fill2); color: var(--fg2); stroke-width: 2.5; }
.ex-nav { display: flex; align-items: center; gap: 2px; min-height: 36px; margin-left: -8px; }
.crumbs {
  display: flex; align-items: center; gap: 2px; min-width: 0; overflow-x: auto; scrollbar-width: none;
  font-size: 13px; color: var(--fg2); white-space: nowrap;
}
.crumbs::-webkit-scrollbar { display: none; }
.crumbs button { padding: 4px 6px; border-radius: 8px; max-width: 160px; overflow: hidden; text-overflow: ellipsis; transition: background-color var(--t), color var(--t); }
.crumbs button:hover { background: var(--fill); color: var(--fg); }
.crumbs button:last-child { color: var(--fg); font-weight: 600; }
.crumbs .i { width: 12px; height: 12px; color: var(--fg3); }

.steps { flex: 1; min-height: 0; position: relative; }
.ex-scroll { height: 100%; overflow-y: auto; overscroll-behavior: contain; padding: 4px 16px 24px; }
#search-results { flex: 1; min-height: 0; height: auto; }
.step { display: none; animation: fade 200ms var(--ease) both; }
.steps[data-step="guilds"] #step-guilds, .steps[data-step="channels"] #step-channels,
.steps[data-step="threads"] #step-threads, .steps[data-step="messages"] #step-messages { display: block; }
.ex-title { font-size: 22px; font-weight: 700; letter-spacing: -0.03em; line-height: 1.25; margin: 8px 4px 14px; word-break: break-word; }

.group {
  background: var(--card); border: 1px solid var(--line2); border-radius: var(--r-card); box-shadow: var(--shadow-sm); overflow: hidden;
}
.group + .group { margin-top: 12px; }
.section-label {
  display: flex; align-items: baseline; justify-content: space-between; gap: 8px;
  margin: 22px 6px 8px; font-size: 12px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; color: var(--fg2);
}
.section-label:first-child { margin-top: 8px; }
.section-label small { font-size: 11px; font-weight: 500; letter-spacing: 0; text-transform: none; color: var(--fg3); }
.row {
  position: relative; display: flex; align-items: center; gap: 12px; width: 100%; min-height: 52px; padding: 8px 14px;
  text-align: left; transition: background-color 120ms;
}
.row + .row::before { content: ""; position: absolute; top: 0; right: 0; left: var(--div, 14px); border-top: 1px solid var(--line2); }
.row:hover { background: color-mix(in srgb, var(--fill) 60%, transparent); }
.row:active { background: var(--fill); }
.row.sel { background: var(--accent-soft); }
.row.compact { min-height: 46px; }
.row-ic {
  width: 36px; height: 36px; border-radius: 10px; flex: none; display: grid; place-items: center; overflow: hidden;
  background: hsl(var(--h, 220) 28% 18%); color: hsl(var(--h, 220) 70% 78%);
  font-size: 14px; font-weight: 700; letter-spacing: 0;
}
.row-ic img { width: 100%; height: 100%; object-fit: cover; }
.row-ic.plain { width: 20px; height: 20px; background: none; color: var(--fg3); border-radius: 0; }
.row-ic.plain .i { width: 18px; height: 18px; }
.row-ic.soft { background: var(--fill); color: var(--fg2); }
.row-ic.soft .i { width: 18px; height: 18px; }
.row-main { flex: 1; min-width: 0; display: flex; flex-direction: column; line-height: 1.35; }
.row-title { font-size: 15px; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row-title.wrap { white-space: normal; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.row-sub { font-size: 13px; color: var(--fg2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; margin-top: 1px; }
.row-meta { flex: none; font-size: 12px; color: var(--fg3); display: flex; align-items: center; gap: 6px; }
.row-chev { width: 16px; height: 16px; color: var(--fg3); flex: none; margin-right: -4px; }
.badge {
  display: inline-flex; align-items: center; height: 20px; padding: 0 7px; border-radius: 999px;
  background: var(--info-soft); color: var(--info); font-size: 11px; font-weight: 700; letter-spacing: 0;
}
.badge.muted { background: var(--fill); color: var(--fg2); }

/* 메시지 */
.more { display: flex; margin: 0 auto 12px; }
.loading-row { display: flex; justify-content: center; padding: 8px 0 14px; }
.spinner { width: 18px; height: 18px; border-radius: 50%; border: 2px solid var(--line); border-top-color: var(--fg2); animation: spin 800ms linear infinite; }
.msg { position: relative; padding: 12px 16px; }
.msg + .msg::before { content: ""; position: absolute; top: 0; left: 16px; right: 0; border-top: 1px solid var(--line2); }
.msg-head { display: flex; align-items: baseline; gap: 8px; min-width: 0; }
.msg-author { font-size: 14px; font-weight: 700; color: #F3C9A8; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.msg-bot { font-size: 10px; font-weight: 700; color: var(--fg2); background: var(--fill); padding: 1px 5px; border-radius: 5px; letter-spacing: .02em; flex: none; }
.msg-time { font-size: 12px; color: var(--fg3); white-space: nowrap; margin-left: auto; flex: none; }
.msg .md { margin-top: 2px; font-size: 15px; }
.msg.mark-hermes, .msg.mark-voice, .msg.mark-warn { padding-left: 20px; }
.msg.mark-hermes::after, .msg.mark-voice::after, .msg.mark-warn::after {
  content: ""; position: absolute; left: 8px; top: 12px; bottom: 12px; width: 3px; border-radius: 3px;
}
.msg.mark-hermes::after { background: var(--info); }
.msg.mark-voice::after { background: var(--accent); }
.msg.mark-warn::after { background: var(--err); }
.attach { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.attach .chip { font-family: var(--font); }

.dock {
  flex: none; padding: 28px 16px 12px; margin-top: -24px; position: relative; z-index: 2;
  background: linear-gradient(to bottom, transparent, var(--bg) 40%);
}
@media (min-width: 900px) { .dock { background: linear-gradient(to bottom, transparent, var(--panel) 40%); padding-bottom: 16px; } }
#step-messages { padding-bottom: 40px; }

/* 빈 상태·스켈레톤 */
.empty { display: flex; flex-direction: column; align-items: center; gap: 12px; padding: 44px 16px; text-align: center; color: var(--fg2); font-size: 14px; }
.empty-ic { width: 48px; height: 48px; border-radius: 14px; background: var(--fill); color: var(--fg3); display: grid; place-items: center; }
.empty-ic .i { width: 22px; height: 22px; }
.empty.err { color: var(--err); }
.empty.err .empty-ic { background: var(--err-soft); color: var(--err); }
.skel-row { display: flex; align-items: center; gap: 12px; padding: 12px 14px; }
.skel-row + .skel-row { border-top: 1px solid var(--line2); }
.sk { background: var(--fill); border-radius: 6px; position: relative; overflow: hidden; }
.sk::after {
  content: ""; position: absolute; inset: 0; transform: translateX(-100%);
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, .05), transparent);
  animation: shimmer 1.3s infinite;
}
.sk-ic { width: 36px; height: 36px; border-radius: 10px; flex: none; }
.sk-lines { flex: 1; display: flex; flex-direction: column; gap: 8px; }
.sk-l1 { height: 12px; width: 62%; }
.sk-l2 { height: 10px; width: 38%; }

/* ---------- 모션 */
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes blink { 50% { opacity: .35; } }
@keyframes rise { from { opacity: 0; transform: translateY(6px); } }
@keyframes fade { from { opacity: 0; } }
@keyframes pop { from { opacity: 0; transform: scale(.96) translateY(-4px); } }
@keyframes shimmer { to { transform: translateX(100%); } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 1ms !important; animation-iteration-count: 1 !important; transition-duration: 1ms !important; }
  body[data-state="connecting"] .ring-connect, body[data-work] .ring-work { animation: none; border-color: var(--line); }
  body[data-work] .ring-work { border-color: var(--info); opacity: .5; }
  .ripple { display: none; }
}
