:root {
  --bg: #0E0E10;
  --bar: #121214;
  --card: #161618;
  --term: #0A0A0B;
  --border: #26262A;
  --border-soft: rgba(255, 255, 255, 0.08);
  --border-med: rgba(255, 255, 255, 0.12);
  --border-input: #303035;
  --text: #E6E3DC;
  --text-2: #B5B1A8;
  --text-3: #9A968D;
  --text-4: #8A867E;
  --text-dim: #7D7A73;
  --term-text: #CFCBC2;
  --sage: #8FB58A;
  --amber: #D9A441;
  --rose: #D96B6B;
  --stone: #A8A39A;
  --bubble-user: #2A2A2E;
  --bubble-ai: rgba(255, 255, 255, 0.04);
  --font-sans: 'Pretendard', 'Noto Sans KR', 'Malgun Gothic', system-ui, -apple-system, sans-serif;
  --font-mono: 'JetBrains Mono', 'Cascadia Code', ui-monospace, Consolas, monospace;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
}

button,
input,
textarea,
select {
  font-family: inherit;
}

a {
  color: inherit;
  text-decoration: none;
}

.hidden {
  display: none !important;
}

.mono {
  font-family: var(--font-mono);
}

.hs {
  scrollbar-width: none;
}

.hs::-webkit-scrollbar {
  display: none;
}

::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.12);
  border-radius: 999px;
}

/* Buttons */
.btn {
  height: 32px;
  padding: 0 12px;
  border-radius: 6px;
  border: 1px solid var(--border-input);
  background: var(--card);
  color: var(--text);
  font-size: 13px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

.btn:hover {
  background: #1E1E21;
  border-color: rgba(255, 255, 255, 0.22);
}

.btn-primary {
  border: 1px solid var(--text);
  background: var(--text);
  color: var(--term);
  font-weight: 600;
}

.btn-primary:hover {
  background: #F4F2EC;
}

.btn-ghost {
  height: 28px;
  padding: 0 10px;
  border-radius: 7px;
  background: transparent;
  border: 1px solid var(--border-med);
  color: var(--text-2);
  font-size: 12px;
  cursor: pointer;
}

.btn-ghost:hover {
  background: rgba(255, 255, 255, 0.06);
  color: var(--text);
}

.btn-soft {
  height: 28px;
  padding: 0 10px;
  border-radius: 7px;
  background: rgba(230, 227, 220, 0.10);
  border: 1px solid rgba(230, 227, 220, 0.30);
  color: var(--text);
  font-size: 12px;
  cursor: pointer;
}

/* Login View */
.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.login-box {
  width: 100%;
  max-width: 340px;
  padding: 24px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 10px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.login-box h2 {
  margin: 0;
  font-size: 16px;
  font-weight: 600;
}

.login-box label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 12px;
  color: var(--text-3);
}

.login-box input {
  height: 38px;
  padding: 0 12px;
  border-radius: 8px;
  border: 1px solid var(--border-input);
  background: var(--term);
  color: var(--text);
  font-size: 14px;
  outline: 0;
}

.error-text {
  color: var(--rose);
  font-size: 12px;
  margin: 0;
}

/* ================= VIEW 1: INDEX (프로젝트 현황) ================= */
.index-shell {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.idx-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 16px;
  padding: 0 32px;
  min-height: 52px;
  border-bottom: 1px solid var(--border);
  background: var(--bg);
}

.idx-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-right: auto;
}

.idx-brand-agy {
  font-family: var(--font-mono);
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
}

.idx-brand-sep {
  color: #4A4A50;
}

.idx-brand-sub {
  color: var(--text-3);
}

.search-box {
  display: flex;
  align-items: center;
  gap: 8px;
  height: 32px;
  padding: 0 10px;
  min-width: 220px;
  border: 1px solid var(--border-input);
  border-radius: 6px;
  color: var(--text-4);
}

.search-box input {
  flex: 1;
  min-width: 0;
  background: none;
  border: 0;
  outline: 0;
  color: var(--text);
  font-size: 13px;
}

.search-hint {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-dim);
}

.otp-pill {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--text-3);
}

.idx-main {
  flex: 1;
  width: 100%;
  max-width: 1120px;
  margin: 0 auto;
  padding: 40px 32px 64px;
  display: flex;
  flex-direction: column;
  gap: 44px;
}

.sec-head {
  display: flex;
  align-items: baseline;
  gap: 10px;
  margin-bottom: 14px;
}

.sec-head h1,
.sec-head h2 {
  margin: 0;
  font-size: 15px;
  font-weight: 600;
}

.sec-count {
  font-size: 12px;
  color: var(--text-4);
}

.card-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.proj-card {
  display: flex;
  flex-direction: column;
  gap: 18px;
  padding: 16px 16px 14px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 8px;
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease;
}

.proj-card:hover {
  background: #1B1B1E;
  border-color: #38383E;
}

.proj-card-top {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

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

.proj-card-name {
  font-size: 14px;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.proj-card-status {
  flex: none;
  font-size: 12px;
  color: var(--text);
}

.proj-card-status.is-review {
  color: var(--amber);
}

.proj-card-status.is-done {
  color: var(--sage);
}

.proj-card-status.is-error {
  color: var(--rose);
}

.proj-card-path {
  font-family: var(--font-mono);
  font-size: 11.5px;
  color: var(--text-4);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.prog-row {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 12px;
  color: var(--text-4);
}

.prog-track {
  flex: 1;
  height: 3px;
  border-radius: 2px;
  background: var(--border);
  position: relative;
  overflow: hidden;
}

.prog-fill {
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  border-radius: 2px;
  background: var(--text);
}

.prog-fill.is-review {
  background: var(--amber);
}

.prog-fill.is-done {
  background: var(--sage);
}

.proj-card-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 12px;
  color: var(--text-4);
}

.proj-agents {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.02em;
  color: var(--text-4);
}

.inbox-card {
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--card);
  overflow: hidden;
}

.inbox-row {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px 16px;
  border-top: 1px solid var(--border);
}

.inbox-row:first-child {
  border-top: none;
}

.inbox-proj {
  width: 108px;
  flex: none;
  font-size: 12px;
  color: var(--text-4);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.inbox-title {
  flex: 1;
  min-width: 0;
  font-size: 13.5px;
}

.inbox-empty {
  padding: 18px 16px;
  font-size: 13px;
  color: var(--text-4);
}

/* ================= VIEW 2: WORKSPACE (상세) ================= */
.ws-shell {
  width: 100%;
  height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  overflow: hidden;
}

.ws-header {
  flex: none;
  min-height: 52px;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  padding: 0 20px;
  border-bottom: 1px solid var(--border-soft);
  background: var(--bar);
  gap: 12px;
}

.ws-h-left {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 14px;
  min-width: 0;
}

.back-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--text-3);
  background: none;
  border: 0;
  cursor: pointer;
  height: 36px;
  padding: 0 4px;
  font-size: 13px;
}

.back-btn:hover {
  color: var(--text);
}

.v-sep {
  width: 1px;
  height: 16px;
  background: var(--border-med);
  flex: none;
}

.ws-title {
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.pid-chip {
  font-family: var(--font-mono);
  font-size: 11px;
  padding: 3px 8px;
  border-radius: 6px;
  background: var(--card);
  border: 1px solid var(--border-soft);
  color: var(--text-3);
  flex: none;
}

.stepper {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
  font-size: 12px;
}

.step-item {
  display: flex;
  align-items: center;
  gap: 8px;
}

.step-label {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--text-3);
}

.step-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.14);
}

.step-line {
  width: 24px;
  height: 2px;
  border-radius: 2px;
  background: rgba(255, 255, 255, 0.14);
}

.step-item.done .step-dot,
.step-item.done .step-line {
  background: var(--sage);
}

.step-item.active .step-label {
  color: var(--text);
  font-weight: 600;
}

.step-item.active .step-dot {
  background: var(--text);
}

.ws-h-right {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 14px;
  font-size: 12px;
}

.guard-pill {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--card);
  border: 1px solid rgba(255, 255, 255, 0.10);
  color: var(--text-2);
}

.sse-status {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--sage);
}

.sse-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--sage);
}

.sse-status.err {
  color: var(--rose);
}

.sse-status.err .sse-dot {
  background: var(--rose);
}

/* Mobile sub-tabs (hidden on desktop) */
.mob-tabs {
  display: none;
  border-bottom: 1px solid var(--border-soft);
  background: var(--bar);
  padding: 0 12px;
}

.mob-tab {
  flex: 1;
  height: 40px;
  background: none;
  border: 0;
  border-bottom: 2px solid transparent;
  color: var(--text-3);
  font-size: 14px;
  cursor: pointer;
}

.mob-tab.active {
  border-bottom-color: var(--text);
  color: var(--text);
  font-weight: 600;
}

/* Center 2-column split */
.ws-body {
  flex: 1;
  min-height: 0;
  display: flex;
}

.term-pane {
  flex: 55;
  min-width: 0;
  display: flex;
  flex-direction: column;
  background: var(--card);
  border-right: 1px solid var(--border-soft);
}

.pane-bar {
  flex: none;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 12px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.07);
}

.tab-group {
  display: flex;
  gap: 4px;
  height: 100%;
  align-items: flex-end;
}

.term-tab {
  height: 34px;
  padding: 0 14px;
  background: transparent;
  color: var(--text-2);
  border: 0;
  border-radius: 8px 8px 0 0;
  font-size: 13px;
  display: flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
}

.term-tab.active {
  background: var(--term);
  color: var(--text);
  border: 1px solid var(--border-soft);
  border-bottom: 0;
  font-weight: 600;
}

.dot-sm {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--stone);
}

.dot-sm.sage {
  background: var(--sage);
}

.pane-actions {
  display: flex;
  gap: 6px;
  align-items: center;
}

.term-screen-wrap {
  flex: 1;
  min-height: 0;
  position: relative;
  background: var(--term);
  display: flex;
  flex-direction: column;
  padding: 8px 10px;
  overflow: hidden;
}
.term-screen-wrap.zweb-wrap { padding: 0; }
.zellij-frame {
  flex: 1;
  width: 100%;
  height: 100%;
  border: 0;
  background: #0A0A0B;
}

.term-mode-toggle {
  position: absolute;
  top: 10px;
  right: 12px;
  display: flex;
  padding: 2px;
  border-radius: 8px;
  background: var(--card);
  border: 1px solid var(--border-med);
  z-index: 5;
}

.mode-btn {
  height: 24px;
  padding: 0 9px;
  border-radius: 6px;
  border: 0;
  background: transparent;
  color: var(--text-3);
  font-size: 11px;
  cursor: pointer;
}

.mode-btn.active {
  background: var(--text);
  color: var(--bg);
  font-weight: 600;
}

.term-screen {
  flex: 1;
  min-height: 0;
  padding: 0;
  background: var(--term);
  overflow: hidden;
}

.term-screen .xterm {
  height: 100%;
}

.term-screen.select-mode {
  touch-action: none;
}

.term-screen.scroll-mode {
  touch-action: pan-y;
}

.aux-keys {
  flex: none;
  flex-shrink: 0;
  position: relative;
  z-index: 6;
  display: none;
  gap: 6px;
  overflow-x: auto;
  padding: 6px 12px;
  background: var(--bar);
  border-top: 1px solid var(--border-soft);
}

.aux-keys.open {
  display: flex;
}

.aux-key {
  flex: none;
  min-width: 40px;
  height: 30px;
  padding: 0 10px;
  border-radius: 7px;
  background: var(--card);
  border: 1px solid var(--border-med);
  color: var(--text);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
}

.aux-key:hover,
.aux-key.active {
  background: rgba(230, 227, 220, 0.14);
  border-color: var(--text);
}

.aux-key.aux-danger {
  color: var(--rose);
  border-color: rgba(217, 107, 107, 0.35);
}

/* Chat Pane */
.chat-pane {
  flex: 45;
  min-width: 0;
  display: flex;
  flex-direction: column;
  background: var(--card);
  position: relative;
}

.filter-bar {
  flex: none;
  height: 44px;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 0 16px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.07);
  overflow-x: auto;
}

.filter-chip {
  flex: none;
  height: 28px;
  padding: 0 12px;
  border-radius: 999px;
  background: transparent;
  color: var(--text-2);
  border: 1px solid var(--border-med);
  font-size: 12px;
  cursor: pointer;
}

.filter-chip.active {
  background: var(--text);
  color: var(--term);
  border-color: var(--text);
  font-weight: 600;
}

.readonly-tag {
  margin-left: auto;
  font-size: 11px;
  color: var(--text-3);
  flex: none;
}

.chat-feed {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 20px 20px 72px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.msg-wrap {
  display: flex;
  flex-direction: column;
  gap: 4px;
  align-items: flex-start;
}

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

.msg-meta {
  font-size: 11px;
  color: var(--text-3);
  display: flex;
  align-items: center;
  gap: 6px;
}

.msg-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--stone);
}

.msg-dot.agy,
.msg-dot.user {
  background: var(--text);
}

.msg-dot.codex {
  background: var(--sage);
}

.msg-dot.error {
  background: var(--rose);
}

.msg-bubble {
  max-width: 86%;
  padding: 10px 14px;
  border-radius: 14px;
  font-size: 13.5px;
  line-height: 1.55;
  background: var(--bubble-ai);
  border: 1px solid var(--bubble-ai);
  color: var(--text);
  white-space: pre-wrap;
  word-break: break-word;
  margin: 0;
}

.msg-wrap.from-user .msg-bubble {
  background: var(--bubble-user);
  border-color: var(--bubble-user);
}

.msg-wrap.kind-error .msg-bubble {
  border-color: rgba(217, 107, 107, 0.45);
  background: rgba(217, 107, 107, 0.08);
}

.msg-wrap.from-system {
  align-items: center;
}

.msg-wrap.from-system .msg-bubble {
  font-size: 12px;
  color: var(--text-4);
  padding: 4px 12px;
  border-radius: 999px;
}

/* Board Drawer Pill */
.board-float {
  position: absolute;
  right: 16px;
  bottom: 14px;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 8px;
  z-index: 10;
  max-width: calc(100% - 32px);
}

.board-drawer {
  width: 340px;
  max-width: 100%;
  max-height: 260px;
  overflow-y: auto;
  background: var(--bar);
  border: 1px solid var(--border-med);
  border-radius: 12px;
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.5);
}

.board-task {
  padding: 8px 10px;
  border-radius: 8px;
  background: var(--card);
  border: 1px solid var(--border-soft);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-size: 12.5px;
}

.board-toggle-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  height: 40px;
  padding: 0 14px;
  border-radius: 12px;
  background: var(--bar);
  border: 1px solid var(--border-med);
  color: var(--text);
  font-size: 13px;
  cursor: pointer;
}

.amber-txt {
  color: var(--amber);
}

/* Bottom Fixed Prefix Bar */
.ws-footer {
  flex: none;
  padding: 10px 20px 14px;
  background: var(--bar);
  border-top: 1px solid var(--border-soft);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.prefix-row {
  display: flex;
  align-items: center;
  gap: 6px;
  overflow-x: auto;
}

.ai-btn {
  flex: none;
  height: 32px;
  padding: 0 12px;
  border-radius: 8px;
  background: transparent;
  border: 1px solid var(--border-med);
  color: var(--stone);
  font-size: 13px;
  cursor: pointer;
}

.ai-btn.codex {
  color: var(--sage);
}

.ai-btn.active {
  background: rgba(230, 227, 220, 0.10);
  border-color: var(--text);
  color: var(--text);
  font-weight: 600;
}

.session-chip {
  flex: none;
  height: 32px;
  padding: 0 10px;
  display: inline-flex;
  align-items: center;
  line-height: 1;
  border-radius: 8px;
  background: var(--card);
  border: 1px solid var(--border-med);
  color: var(--text);
  font-size: 12px;
  font-family: var(--font-mono);
}

.opt-group {
  margin-left: auto;
  display: flex;
  gap: 6px;
  flex: none;
}

.opt-chip {
  height: 26px;
  padding: 0 10px;
  display: inline-flex;
  align-items: center;
  border-radius: 6px;
  background: var(--card);
  border: 1px solid rgba(255, 255, 255, 0.10);
  color: var(--text-2);
  font-size: 12px;
  font-family: var(--font-mono);
  cursor: pointer;
}

.opt-chip.active {
  background: rgba(230, 227, 220, 0.10);
  border-color: rgba(230, 227, 220, 0.30);
  color: var(--text);
}

.input-row {
  display: flex;
  gap: 10px;
  align-items: center;
}

.cmd-input {
  flex: 1;
  min-width: 0;
  height: 44px;
  padding: 0 16px;
  border-radius: 10px;
  background: var(--card);
  border: 1px solid rgba(255, 255, 255, 0.10);
  color: var(--text);
  font-size: 14px;
  outline: 0;
}

.cmd-input:focus {
  border-color: rgba(230, 227, 220, 0.35);
}

.send-btn {
  flex: none;
  height: 44px;
  padding: 0 24px;
  border-radius: 10px;
  border: 0;
  background: var(--text);
  color: var(--bg);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}

.send-btn:hover {
  background: #F4F2EC;
}

.cmd-preview {
  font-family: var(--font-mono);
  font-size: 11.5px;
  color: var(--text-4);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ================= UNIFIED 3-TAB SHELL ================= */
.app-shell {
  width: 100%;
  height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  overflow: hidden;
}

.main-topbar {
  flex: none;
  min-height: 52px;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 0 20px;
  background: var(--bar);
  border-bottom: 1px solid var(--border-soft);
}

.main-tabs {
  display: flex;
  align-items: center;
  gap: 4px;
  height: 52px;
}

.main-tab {
  height: 52px;
  padding: 0 16px;
  background: none;
  border: 0;
  border-bottom: 2px solid transparent;
  color: var(--text-3);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
}

.main-tab:hover {
  color: var(--text);
}

.main-tab.active {
  color: var(--text);
  font-weight: 600;
  border-bottom-color: var(--text);
}

.topbar-right {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 12px;
}

.tab-panel {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.tab-panel.scroll-y {
  overflow-y: auto;
}

.session-name-input {
  height: 28px;
  width: 130px;
  padding: 0 8px;
  border-radius: 6px;
  border: 1px solid var(--border-input);
  background: var(--term);
  color: var(--text);
  font-family: var(--font-mono);
  font-size: 12px;
  outline: 0;
}

.session-name-input:focus {
  border-color: rgba(230, 227, 220, 0.35);
}

.chat-proj-select {
  height: 28px;
  padding: 0 8px;
  border-radius: 6px;
  border: 1px solid var(--border-input);
  background: var(--term);
  color: var(--text);
  font-size: 12px;
  margin-left: 8px;
}

/* Project Detail View (Memory MCP) */
.detail-topbar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 18px;
}

.detail-title {
  margin: 0;
  font-size: 17px;
  font-weight: 600;
  font-family: var(--font-mono);
}

.detail-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 14px;
}

.detail-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 16px;
  margin-bottom: 14px;
}

.detail-grid .detail-card {
  margin-bottom: 0;
}

.detail-card-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 12px;
}

.detail-card-head h2 {
  margin: 0;
  font-size: 14px;
  font-weight: 600;
}

.session-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.session-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border-radius: 8px;
  background: var(--term);
  border: 1px solid var(--border-soft);
  font-size: 12px;
}

.session-row-label {
  width: 92px;
  flex: none;
  color: var(--text-3);
  font-weight: 600;
}

.session-row-val {
  flex: 1;
  min-width: 0;
  font-family: var(--font-mono);
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.detail-prose {
  font-size: 13px;
  line-height: 1.6;
  color: var(--text-2);
  white-space: pre-wrap;
  word-break: break-word;
  padding: 10px 12px;
  border-radius: 8px;
  background: var(--term);
  border: 1px solid var(--border-soft);
  margin-bottom: 10px;
}

.steps-wrap {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 12.5px;
}

.step-row {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 8px 10px;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.03);
  min-width: 0;
  overflow: hidden;
}

.step-row > span:last-child {
  flex: 1;
  min-width: 0;
  overflow-wrap: anywhere;
  word-break: break-word;
  line-height: 1.5;
}

.step-tag {
  font-family: var(--font-mono);
  font-size: 11px;
  flex: none;
  padding: 2px 6px;
  border-radius: 4px;
}

.step-tag.done {
  background: rgba(143, 181, 138, 0.16);
  color: var(--sage);
}

.step-tag.pending {
  background: rgba(217, 164, 65, 0.16);
  color: var(--amber);
}

.event-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.event-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 7px;
  background: var(--term);
  border: 1px solid var(--border-soft);
  font-size: 12px;
}

.event-ts {
  font-family: var(--font-mono);
  color: var(--text-4);
  flex: none;
}

.event-type {
  font-family: var(--font-mono);
  color: var(--sage);
  flex: none;
}

.event-sum {
  flex: 1;
  min-width: 0;
  color: var(--text-2);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chat-empty-state {
  margin: auto;
  text-align: center;
  max-width: 420px;
  color: var(--text-3);
  line-height: 1.6;
  padding: 32px 16px;
}

.chat-empty-state h3 {
  margin: 0 0 8px;
  font-size: 15px;
  color: var(--text);
}

.opt-group-inline {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  flex: none;
}

.cmd-input-wrap {
  flex: 1;
  min-width: 0;
  height: 42px;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 12px;
  border-radius: 10px;
  background: var(--card);
  border: 1px solid rgba(255, 255, 255, 0.12);
}

.cmd-input-wrap:focus-within {
  border-color: rgba(230, 227, 220, 0.40);
}

.cmd-prefix-badge {
  flex: none;
  padding: 3px 8px;
  border-radius: 6px;
  background: rgba(230, 227, 220, 0.09);
  border: 1px solid rgba(230, 227, 220, 0.18);
  color: var(--text-2);
  font-family: var(--font-mono);
  font-size: 12px;
  white-space: nowrap;
  cursor: pointer;
}
.cmd-clear-btn {
  flex: none;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  border: 0;
  background: rgba(255, 255, 255, 0.10);
  color: var(--text-2);
  font-size: 15px;
  line-height: 1;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.cmd-clear-btn:hover { background: rgba(255, 255, 255, 0.20); color: var(--text); }
.cancel-btn {
  flex: none;
  height: 42px;
  padding: 0 14px;
  border-radius: 10px;
  border: 1px solid rgba(217, 107, 107, 0.45);
  background: rgba(217, 107, 107, 0.10);
  color: var(--rose);
  font-size: 14px;
  font-weight: 600;
  white-space: nowrap;
  cursor: pointer;
}
.cancel-btn:hover { background: rgba(217, 107, 107, 0.22); }

.cmd-prefix-badge.raw-mode {
  background: rgba(143, 181, 138, 0.12);
  border-color: rgba(143, 181, 138, 0.30);
  color: var(--sage);
}

.cmd-input-bare {
  flex: 1;
  min-width: 0;
  height: 100%;
  background: transparent;
  border: 0;
  outline: 0;
  color: var(--text);
  font-size: 14px;
}

/* Global nowrap guards so Korean buttons/tabs never break vertically */
.btn,
.btn-ghost,
.btn-soft,
.opt-chip,
.ai-btn,
.main-tab,
.filter-chip,
.aux-key,
.sec-count,
.sec-head h1,
.sec-head h2 {
  white-space: nowrap;
  flex-shrink: 0;
}

.sec-head {
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 10px;
}

/* Responsive (Mobile <= 900px) */
@media (max-width: 900px) {
  .main-topbar {
    padding: 0 10px;
    gap: 6px;
    flex-wrap: nowrap;
  }

  .idx-brand {
    margin-right: 4px;
    flex: none;
  }

  .main-tabs {
    flex: 1;
    min-width: 0;
    overflow-x: auto;
    scrollbar-width: none;
    gap: 2px;
  }
  .main-tabs::-webkit-scrollbar { display: none; }

  .main-tab {
    padding: 0 9px;
    font-size: 12.5px;
    height: 48px;
  }

  .topbar-right {
    gap: 6px;
    flex: none;
  }

  .guard-pill,
  .pid-chip,
  .idx-brand-sub,
  .idx-brand-sep,
  #sse-text,
  #btn-notify,
  #otp-badge {
    display: none;
  }

  .idx-main {
    padding: 16px 12px 28px;
    gap: 20px;
  }

  .sec-head {
    gap: 8px;
  }

  .search-box {
    flex: 1 1 180px;
    min-width: 0;
    margin-left: 0 !important;
  }

  .detail-topbar {
    gap: 8px;
  }
  .detail-title {
    width: 100%;
    font-size: 14px;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .card-grid,
  .detail-grid {
    grid-template-columns: 1fr;
  }

  .pane-bar {
    padding: 0 8px;
    gap: 6px;
    overflow-x: auto;
    scrollbar-width: none;
  }
  .pane-bar::-webkit-scrollbar { display: none; }

  .session-name-input {
    width: 88px;
  }

  .aux-keys {
    display: flex;
  }

  .ws-footer {
    padding: 8px 10px 10px;
    gap: 6px;
  }

  .cmd-input-wrap {
    padding: 0 8px;
    gap: 6px;
  }

  .cmd-prefix-badge {
    max-width: 104px;
    overflow: hidden;
    text-overflow: ellipsis;
    font-size: 11px;
    padding: 2px 6px;
  }

  .send-btn {
    padding: 0 16px;
  }
}

.pw-modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.72);
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.pw-modal-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}
