/* ============================================
   webcoding — MotherDuck Neo-Brutalist Design System
   ============================================ */

:root {
  /* --- MotherDuck Palette --- */
  --bg-primary: #f4efea;
  --bg-secondary: #ede9df;
  --bg-tertiary: #e1d6cb;
  --bg-bubble-user: #383838;
  --bg-bubble-assistant: #f8f8f7;
  --text-primary: #383838;
  --text-secondary: #5f5f5f;
  --text-muted: #737373;
  --border-color: #383838;
  --accent: #6fc2ff;
  --accent-hover: #2ba5ff;
  --accent-light: rgba(111, 194, 255, 0.18);
  --success: #2e8a61;
  --danger: #d44;
  --info: #2ba5ff;
  --scrollbar-thumb: rgba(56, 56, 56, 0.25);
  --scrollbar-track: transparent;
  --sidebar-width: 280px;
  --header-height: 52px;
  --input-max-height: 200px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --font-ui: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Hiragino Sans', 'Noto Sans CJK SC', sans-serif;
  --font-mono: 'Space Mono', 'Courier New', 'Noto Sans Mono CJK SC', 'PingFang SC', 'Microsoft YaHei', monospace;

  /* --- Semantic tokens --- */
  --line: #383838;
  --blue: #6fc2ff;
  --yellow: #ffde00;
  --blue-strong: #2ba5ff;
  --surface: #f8f8f7;
  --page-background: var(--bg-primary);
  --login-background: var(--bg-primary);
  --surface-strong: #ffffff;
  --chat-title-edit-bg: var(--surface-strong);
  --shadow-strong: 4px 4px 0 var(--line);
  --accent-fallback: #4a90d9;
  --success-strong: #4caf50;
  --code-header-bg: #2b2b2b;
  --code-header-text: #999;
  --code-action-border: #555;
  --code-action-hover-bg: #444;
  --code-action-hover-text: #fff;

  /* --- Session loading --- */
  --loading-overlay-layer-a: rgba(244, 239, 234, 0.88);
  --loading-overlay-layer-b: rgba(225, 214, 203, 0.9);
  --loading-overlay-scrim: rgba(56, 56, 56, 0.12);
  --loading-card-bg: #ffffff;
  --loading-card-border: var(--line);
  --loading-card-shadow: 4px 4px 0 var(--line);
  --loading-badge-bg: rgba(111, 194, 255, 0.15);
  --loading-badge-text: var(--text-primary);
  --loading-bar-bg: var(--bg-tertiary);
  --loading-bar-fill: linear-gradient(90deg, #6fc2ff, #ffde00, #6fc2ff);
}

/* === Reset === */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html {
  height: 100%;
  height: -webkit-fill-available;
}

body {
  height: 100%;
  height: 100dvh;
  min-height: -webkit-fill-available;
  font-family: var(--font-ui);
  font-size: 16px;
  line-height: 1.5;
  letter-spacing: 0.01em;
  color: var(--text-primary);
  background: var(--page-background);
  overflow: hidden;
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
}

/* Native scrollbar hiding is scoped to message containers only (see .messages below). */

/* === Login === */
.login-overlay {
  position: fixed; inset: 0;
  display: flex; align-items: center; justify-content: center;
  background: var(--login-background);
  z-index: 1000;
}
.login-box {
  text-align: center;
  padding: 48px 36px;
  background: var(--surface-strong);
  border: 2px solid var(--line);
  border-radius: 0;
  width: 90%;
  max-width: 360px;
  box-shadow: 6px 6px 0 var(--line);
}
.login-kicker {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 16px;
}
.login-brand-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  margin-bottom: 20px;
}
.login-brand-copy {
  text-align: left;
}
.login-brand-copy strong {
  font-family: var(--font-mono);
  font-size: 18px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  display: block;
}
.login-brand-copy span {
  font-size: 12px;
  color: var(--text-muted);
}
.login-logo {
  width: 56px; height: 56px;
  background: var(--line);
  color: var(--surface-strong);
  border: 2px solid var(--line);
  border-radius: 0;
  display: flex; align-items: center; justify-content: center;
  font-family: var(--font-mono);
  font-size: 22px; font-weight: 700;
  letter-spacing: -1px;
  flex-shrink: 0;
}
.login-box h2 {
  font-family: var(--font-mono);
  font-size: 22px;
  margin-bottom: 4px;
  color: var(--text-primary);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.login-box p {
  color: var(--text-secondary);
  margin-bottom: 28px;
  font-size: 14px;
}
.login-field {
  display: block;
  text-align: left;
  margin-bottom: 12px;
}
.login-field span {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 6px;
  font-family: var(--font-mono);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.login-box input {
  width: 100%;
  padding: 10px 12px;
  margin-bottom: 12px;
}
.login-box button {
  --nb-btn-bg: var(--blue);
  --nb-btn-font-size: 14px;
  --nb-btn-shadow: 3px 3px 0 var(--line);
  --nb-btn-hover-shift: 2px;

  width: 100%;
  padding: 12px;
  letter-spacing: 0.06em;
}
.login-box button:hover {
  /* keep explicit block for readability with shared button base */
}
.login-box button:active {
  background: var(--blue-strong);
  transform: none;
  box-shadow: 3px 3px 0 var(--line);
}
.remember-label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--text-secondary);
  margin-bottom: 12px;
  cursor: pointer;
  user-select: none;
}
.remember-label input[type="checkbox"] {
  width: 16px;
  height: 16px;
  accent-color: var(--blue);
  cursor: pointer;
}
.login-error {
  color: var(--danger);
  margin-top: 12px;
  font-size: 14px;
  font-weight: 600;
}

/* === App Layout === */
.app {
  display: flex;
  flex-direction: column;
  height: 100%;
  height: 100dvh;
  min-height: -webkit-fill-available;
  width: 100%;
  overflow: hidden;
}

.app-workspace {
  display: flex;
  flex: 1;
  overflow: hidden;
}

.workspace-main {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
}

/* === Topbar === */
.app-topbar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 16px;
  height: var(--header-height);
  min-height: var(--header-height);
  background: var(--surface);
  border-bottom: 2px solid var(--line);
  flex-shrink: 0;
  z-index: 50;
}
.app-topbar-brand {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}
.app-topbar-brand strong {
  font-family: var(--font-mono);
  font-size: 16px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-primary);
}
.app-topbar-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-left: auto;
  flex-shrink: 0;
}

/* Agent tabs in topbar */
.agent-tabs {
  display: flex;
  border: 2px solid var(--line);
  border-radius: 2px;
  overflow: hidden;
}
.agent-tab {
  appearance: none;
  border: none;
  border-right: 2px solid var(--line);
  background: var(--surface);
  color: var(--text-secondary);
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 5px 14px;
  cursor: pointer;
  transition: background 120ms ease, color 120ms ease;
}
.agent-tab:last-child { border-right: none; }
.agent-tab:hover {
  background: var(--bg-secondary);
  color: var(--text-primary);
}
.agent-tab.active {
  background: var(--blue);
  color: var(--text-primary);
}

/* Mode tabs in topbar */
.mode-tabs {
  display: flex;
  border: 2px solid var(--line);
  border-radius: 2px;
  overflow: hidden;
}
.mode-tab {
  appearance: none;
  border: none;
  border-right: 2px solid var(--line);
  background: var(--surface);
  color: var(--text-muted);
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 4px 10px;
  cursor: pointer;
  transition: background 120ms ease, color 120ms ease;
}
.mode-tab:last-child { border-right: none; }
.mode-tab:hover {
  background: var(--bg-secondary);
  color: var(--text-primary);
}
.mode-tab.active {
  background: var(--yellow);
  color: var(--text-primary);
}

/* Shared compact control base (close/back/icon/small controls) */
:where(
  .topbar-icon-btn,
  .settings-back,
  .settings-panel h3 .settings-close,
  .settings-header .settings-close,
  .modal-close-btn,
  .attachment-chip-remove
) {
  appearance: none;
  border: var(--compact-btn-border, 2px solid var(--line));
  border-radius: 2px;
  background: var(--compact-btn-bg, transparent);
  color: var(--compact-btn-color, var(--text-muted));
  cursor: pointer;
  line-height: 1;
  transition: background 120ms, color 120ms, transform 120ms, box-shadow 120ms;
}

:where(
  .topbar-icon-btn,
  .settings-back,
  .settings-panel h3 .settings-close,
  .settings-header .settings-close,
  .modal-close-btn,
  .attachment-chip-remove
):hover {
  background: var(--compact-btn-hover-bg, var(--yellow));
  color: var(--compact-btn-hover-color, var(--text-primary));
  transform: translate(var(--compact-btn-hover-shift, 0), var(--compact-btn-hover-shift, 0));
  box-shadow: var(--compact-btn-hover-shadow, var(--compact-btn-shadow, none));
}

/* Topbar icon buttons */
.topbar-icon-btn {
  --compact-btn-bg: var(--surface);
  --compact-btn-color: var(--text-primary);
  --compact-btn-shadow: 2px 2px 0 var(--line);
  --compact-btn-hover-shift: 1px;
  --compact-btn-hover-shadow: 1px 1px 0 var(--line);

  width: 36px;
  height: 36px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--compact-btn-shadow);
  padding: 0;
  flex-shrink: 0;
}
.topbar-icon-btn:hover {
  /* keep explicit block for readability with shared compact control base */
}
.topbar-icon-btn:active {
  transform: translate(2px, 2px);
  box-shadow: none;
}

body.session-loading-active {
  cursor: progress;
}

.session-loading-overlay {
  position: fixed;
  inset: 0;
  z-index: 900;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: var(--loading-overlay-scrim);
}

.session-loading-card {
  width: min(440px, 100%);
  padding: 24px 24px 20px;
  border: 2px solid var(--loading-card-border);
  border-radius: 0;
  background: var(--loading-card-bg);
  box-shadow: var(--loading-card-shadow);
}

.session-loading-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 74px;
  margin-bottom: 12px;
  padding: 5px 10px;
  border: 2px solid var(--line);
  border-radius: 2px;
  background: var(--loading-badge-bg);
  color: var(--loading-badge-text);
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.session-loading-title {
  font-family: var(--font-mono);
  font-size: 22px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-primary);
}

.session-loading-label {
  margin-top: 8px;
  color: var(--text-secondary);
  font-size: 14px;
  line-height: 1.7;
}

.session-loading-bar {
  margin-top: 18px;
  height: 8px;
  overflow: hidden;
  border: 2px solid var(--line);
  border-radius: 0;
  background: var(--loading-bar-bg);
}

.session-loading-bar-fill {
  display: block;
  width: 44%;
  height: 100%;
  background: var(--loading-bar-fill);
  animation: session-loading-pulse 1.2s ease-in-out infinite;
  transform-origin: left center;
}

@keyframes session-loading-pulse {
  0% {
    transform: translateX(-55%) scaleX(0.82);
    opacity: 0.72;
  }
  50% {
    transform: translateX(120%) scaleX(1.08);
    opacity: 1;
  }
  100% {
    transform: translateX(250%) scaleX(0.88);
    opacity: 0.72;
  }
}

/* === Sidebar === */
.sidebar {
  width: var(--sidebar-width);
  min-width: var(--sidebar-width);
  background: var(--bg-secondary);
  border-right: 2px solid var(--line);
  display: flex;
  flex-direction: column;
  transition: transform 200ms ease;
  overflow: hidden;
}
.sidebar-header {
  padding: 12px;
  border-bottom: 2px solid var(--line);
  flex-shrink: 0;
  position: relative;
}

/* === Neo-Brutalist Shared Button Base === */
:where(
  .login-box button,
  .new-chat-btn,
  .new-chat-arrow,
  .settings-actions button,
  .modal-btn-primary,
  .modal-btn-secondary,
  .project-picker-action-btn,
  .fc-submit-btn,
  .import-item-btn,
  #tunnel-copy-btn
) {
  --nb-btn-bg: var(--blue);
  --nb-btn-hover-bg: var(--yellow);
  --nb-btn-font-size: 13px;
  --nb-btn-shadow: 2px 2px 0 var(--line);
  --nb-btn-hover-shadow: 1px 1px 0 var(--line);
  --nb-btn-hover-shift: 1px;

  background: var(--nb-btn-bg);
  color: var(--text-primary);
  border: 2px solid var(--line);
  border-radius: 2px;
  font-family: var(--font-mono);
  font-size: var(--nb-btn-font-size);
  font-weight: 700;
  text-transform: uppercase;
  cursor: pointer;
  box-shadow: var(--nb-btn-shadow);
  transition: transform 120ms ease, box-shadow 120ms ease, background 120ms ease;
}

:where(
  .login-box button,
  .new-chat-btn,
  .new-chat-arrow,
  .settings-actions .btn-test,
  .settings-actions .btn-save,
  .modal-btn-primary,
  .modal-btn-secondary,
  .project-picker-action-btn,
  .import-item-btn,
  #tunnel-copy-btn
):hover {
  background: var(--nb-btn-hover-bg);
  transform: translate(var(--nb-btn-hover-shift), var(--nb-btn-hover-shift));
  box-shadow: var(--nb-btn-hover-shadow);
}

.new-chat-btn {
  --nb-btn-bg: var(--blue);
  --nb-btn-shadow: 3px 3px 0 var(--line);
  --nb-btn-hover-shift: 2px;

  width: 100%;
  min-height: 48px;
  padding: 10px;
  letter-spacing: 0.04em;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.new-chat-btn:hover {
  /* keep explicit block for readability with shared button base */
}
.new-chat-btn:active {
  background: var(--blue-strong);
  transform: translate(3px, 3px);
  box-shadow: none;
}
.session-list {
  flex: 1;
  overflow-y: auto;
  padding: 8px;
  -webkit-overflow-scrolling: touch;
}
.session-list-empty {
  margin: 12px 6px;
  padding: 16px 14px;
  border: 2px dashed var(--line);
  border-radius: 0;
  color: var(--text-secondary);
  font-size: 13px;
  line-height: 1.6;
  background: transparent;
}

/* --- Session Item (single-row layout) --- */
.session-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 10px;
  border: 2px solid transparent;
  border-radius: 2px;
  cursor: pointer;
  margin-bottom: 1px;
  transition: background 120ms ease, border-color 120ms ease, box-shadow 120ms ease;
  position: relative;
}
.session-item:hover {
  border-color: var(--line);
  background: var(--bg-tertiary);
}
.session-item.active {
  border-color: var(--line);
  background: var(--yellow);
  box-shadow: 2px 2px 0 var(--line);
}
.session-item:focus-visible {
  outline: 2px solid var(--blue);
  outline-offset: 2px;
  border-color: var(--blue);
}
.session-item-title {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 13px;
  color: var(--text-primary);
  line-height: 1.4;
}
.session-item.active .session-item-title { font-weight: 600; }
.session-item-right {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
}
.session-item-agent {
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  background: var(--bg-secondary);
  border: 1px solid var(--line);
  border-radius: 2px;
  padding: 1px 5px;
  line-height: 1.3;
}
.session-item.active .session-item-agent {
  background: rgba(255, 255, 255, 0.5);
}
.session-item-status {
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-primary);
  background: var(--yellow);
  border: 1px solid var(--line);
  border-radius: 2px;
  padding: 1px 5px;
  line-height: 1.3;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.session-item-status::before {
  content: '';
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: currentColor;
  animation: pulse 1.1s infinite;
}
.session-item-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 1px 4px;
  font-size: 13px;
  border-radius: 2px;
  line-height: 1;
  opacity: 0;
  transition: opacity 120ms, color 120ms, background 120ms;
}
.session-item:hover .session-item-btn { opacity: 1; }
.session-item-btn:hover { color: var(--text-primary); background: var(--bg-tertiary); }
.session-item-btn.delete:hover { color: var(--danger); background: rgba(221, 68, 68, 0.1); }
/* Inline edit in sidebar */
.session-item-edit-input {
  flex: 1;
  padding: 2px 6px;
  border: 2px solid var(--blue);
  border-radius: 2px;
  background: #fff;
  color: var(--text-primary);
  font-size: 13px;
  outline: none;
  min-width: 0;
}
.sidebar-footer {
  padding: 12px;
  border-top: 2px solid var(--line);
  text-align: center;
  flex-shrink: 0;
}
.brand {
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
}

/* === Project Groups === */
.project-group {
  margin-bottom: 6px;
  border: 1px solid var(--line);
  border-radius: 2px;
  overflow: hidden;
}
.project-group-header {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 10px;
  cursor: pointer;
  transition: background 120ms;
  border-bottom: 1px solid var(--line);
  background: var(--bg-secondary);
  user-select: none;
}
.project-group-header:hover {
  background: var(--bg-tertiary);
}
.project-group.active-project > .project-group-header {
  border-left: 3px solid var(--blue);
  background: var(--bg-tertiary);
}
.project-group-chevron {
  font-size: 10px;
  color: var(--text-muted);
  transition: transform 150ms;
  flex-shrink: 0;
  width: 12px;
  text-align: center;
}
.project-group-header:not(.collapsed) .project-group-chevron {
  transform: rotate(90deg);
}
.project-group-main {
  display: flex;
  align-items: center;
  gap: 6px;
  flex: 1;
  min-width: 0;
}
.project-group-copy {
  flex: 1;
  min-width: 0;
}
.project-group-name {
  display: block;
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-primary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  line-height: 1.3;
}
.project-group-path {
  font-size: 11px;
  color: var(--text-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  line-height: 1.3;
  margin-top: 1px;
}
.project-group-actions {
  display: flex;
  align-items: center;
  gap: 3px;
  flex-shrink: 0;
  opacity: 0;
  transition: opacity 120ms;
}
.project-group-header:hover .project-group-actions {
  opacity: 1;
}
.project-group-create-btn {
  appearance: none;
  background: var(--blue);
  color: var(--text-primary);
  border: 1px solid var(--line);
  border-radius: 2px;
  font-family: var(--font-mono);
  font-size: 14px;
  font-weight: 700;
  width: 22px;
  height: 22px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  padding: 0;
  line-height: 1;
  transition: background 120ms;
}
.project-group-create-btn:hover {
  background: var(--yellow);
}
.project-group-btn {
  appearance: none;
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 12px;
  padding: 2px 4px;
  border-radius: 2px;
  line-height: 1;
}
.project-group-btn:hover {
  color: var(--text-primary);
  background: var(--bg-tertiary);
}
.project-group-body {
  padding: 4px 4px 4px 0;
  border-left: 2px solid var(--line);
  margin-left: 10px;
}
.project-group-body.collapsed {
  display: none;
}
.project-group-empty {
  padding: 8px 10px;
  color: var(--text-muted);
  font-size: 12px;
}

/* === Chat Main === */
.chat-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  position: relative;
  background: var(--bg-primary);
}
.chat-stage-shell {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
}
.chat-header {
  height: 40px;
  min-height: 40px;
  display: flex;
  align-items: center;
  padding: 0 16px;
  border-bottom: 2px solid var(--line);
  background: var(--bg-secondary);
  gap: 10px;
  flex-shrink: 0;
  position: relative;
}
.chat-header-copy {
  flex: 1;
  min-width: 0;
}
.chat-agent-context {
  margin-top: 2px;
  padding: 0 4px;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-muted);
  letter-spacing: 0.03em;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.menu-btn {
  display: none;
  background: none;
  border: 2px solid var(--line);
  border-radius: 2px;
  color: var(--text-primary);
  font-size: 20px;
  cursor: pointer;
  padding: 4px 8px;
}
.menu-btn:hover { background: var(--bg-tertiary); }
.chat-title {
  flex: 1;
  min-width: 0;
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 14px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--text-primary);
  cursor: pointer;
  padding: 2px 4px;
  border-radius: 2px;
  transition: background 120ms;
}
.chat-title:hover { background: var(--bg-tertiary); }
.chat-toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}
.chat-agent-btn {
  appearance: none;
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--text-primary);
  background: var(--surface);
  border: 2px solid var(--line);
  padding: 2px 22px 2px 10px;
  border-radius: 2px;
  box-shadow: 2px 2px 0 var(--line);
  flex-shrink: 0;
  cursor: pointer;
  position: relative;
  transition: transform 120ms ease, box-shadow 120ms ease, background 120ms ease;
}
.chat-agent-btn::after {
  content: '\25BE';
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-48%);
  font-size: 10px;
  color: var(--text-secondary);
}
.chat-agent-btn:hover {
  background: var(--blue);
  transform: translate(1px, 1px);
  box-shadow: 1px 1px 0 var(--line);
}
.chat-agent-menu {
  position: absolute;
  top: calc(100% - 6px);
  right: 16px;
  min-width: 148px;
  padding: 6px;
  border: 2px solid var(--line);
  border-radius: 0;
  background: var(--surface-strong);
  box-shadow: 4px 4px 0 var(--line);
  z-index: 80;
}
.chat-agent-option {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 9px 11px;
  border: none;
  border-radius: 2px;
  background: transparent;
  color: var(--text-primary);
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  cursor: pointer;
}
.chat-agent-option:hover {
  background: var(--bg-tertiary);
}
.chat-agent-option.active {
  background: var(--accent-light);
  color: var(--blue-strong);
}
.chat-agent-option.active::after {
  content: '\5F53\524D';
  font-size: 10px;
  letter-spacing: 0.04em;
}
.chat-runtime-state {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 10px;
  border: 2px solid var(--line);
  border-radius: 2px;
  background: var(--yellow);
  color: var(--text-primary);
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.04em;
  flex-shrink: 0;
}
.chat-runtime-state::before {
  content: '';
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: currentColor;
  animation: pulse 1.1s infinite;
}
.cost-display {
  display: none !important;
}
.cost-display:empty { display: none; }

/* Shared text control base (fields/selects/small text controls) */
:where(
  .login-box input,
  .force-change-form input,
  .settings-field input,
  .settings-select,
  .modal-select,
  .modal-text-input
) {
  background: #fff;
  border: 2px solid var(--line);
  border-radius: 2px;
  color: var(--text-primary);
  font-size: 14px;
  font-family: var(--font-ui);
  outline: none;
  transition: border-color 120ms ease, background 120ms ease, box-shadow 120ms ease;
}

:where(
  .login-box input,
  .force-change-form input,
  .settings-field input,
  .settings-select,
  .modal-select,
  .modal-text-input
):focus {
  border-color: var(--blue);
}

:where(
  .mode-select,
  .mobile-topbar-select,
  .new-chat-dropdown button
) {
  color: var(--compact-text-control-color, var(--text-primary));
  font-family: var(--compact-text-control-font, var(--font-mono));
  font-size: var(--compact-text-control-size, 12px);
  font-weight: var(--compact-text-control-weight, 700);
  letter-spacing: var(--compact-text-control-spacing, 0.04em);
  cursor: pointer;
  transition: background 120ms ease, color 120ms ease, border-color 120ms ease, box-shadow 120ms ease, transform 120ms ease;
}

/* Mode selector */
.mode-select {
  -webkit-appearance: none;
  appearance: none;
  background: var(--surface);
  border: 2px solid var(--line);
  padding: 4px 24px 4px 10px;
  text-transform: uppercase;
  flex-shrink: 0;
  box-shadow: 2px 2px 0 var(--line);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M0 0l5 6 5-6z' fill='%23383838'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 8px center;
}
.mode-select:hover {
  background-color: var(--blue);
  transform: translate(1px, 1px);
  box-shadow: 1px 1px 0 var(--line);
}
.mode-select:focus {
  border-color: var(--blue);
}
.mode-select option {
  background: var(--surface);
  color: var(--text-primary);
}

/* === Messages === */
.messages-wrap {
  flex: 1;
  position: relative;
  overflow: hidden;
  min-height: 0;
}
.messages {
  height: 100%;
  overflow-y: scroll;
  overflow-x: hidden;
  padding: 16px 20px;
  padding-right: 24px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  -ms-overflow-style: none;
  scrollbar-width: none;
  transition: opacity 80ms ease;
}
.messages.messages-switching {
  opacity: 0;
  pointer-events: none;
}
.messages::-webkit-scrollbar { display: none; }
/* Custom scrollbar */
.custom-scrollbar {
  position: absolute;
  right: 2px;
  top: 0;
  bottom: 0;
  width: 6px;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.2s;
}
.messages-wrap:hover .custom-scrollbar,
.custom-scrollbar.active {
  opacity: 1;
}
@media (pointer: coarse) {
  .messages-wrap:hover .custom-scrollbar {
    opacity: 0;
  }
  .custom-scrollbar.scrolling {
    opacity: 1;
  }
}
.custom-scrollbar-thumb {
  position: absolute;
  right: 0;
  width: 6px;
  min-height: 30px;
  border-radius: 2px;
  background: var(--scrollbar-thumb);
  cursor: grab;
  transition: width 0.15s, right 0.15s, background 0.15s;
  pointer-events: all;
}
.custom-scrollbar-thumb:hover,
.custom-scrollbar-thumb.dragging {
  width: 12px;
  right: -3px;
  background: var(--text-muted);
  cursor: grab;
}
.custom-scrollbar-thumb.dragging { cursor: grabbing; }
@media (pointer: coarse) {
  .custom-scrollbar {
    width: 18px;
    right: 0;
    opacity: 0;
  }
  .custom-scrollbar.active {
    opacity: 1;
  }
  .custom-scrollbar-thumb {
    width: 8px;
    right: 5px;
    min-height: 40px;
    border-radius: 2px;
  }
  .custom-scrollbar-thumb:hover,
  .custom-scrollbar-thumb.dragging {
    width: 14px;
    right: 2px;
  }
}
.welcome-msg {
  text-align: center;
  margin: auto;
  padding: 40px 20px;
  color: var(--text-secondary);
  max-width: 480px;
  width: 100%;
}
.welcome-header {
  margin-bottom: 24px;
}
.welcome-icon {
  font-size: 32px;
  margin-bottom: 8px;
  opacity: 0.5;
}
.welcome-msg h3 {
  font-family: var(--font-mono);
  font-size: 16px;
  text-transform: uppercase;
  color: var(--text-primary);
  font-weight: 700;
  letter-spacing: 0.06em;
}
.welcome-stats {
  display: flex;
  border: 2px solid var(--line);
  border-radius: 2px;
  overflow: hidden;
  margin-bottom: 16px;
}
.welcome-stat {
  flex: 1;
  padding: 10px 8px;
  border-right: 2px solid var(--line);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
}
.welcome-stat:last-child { border-right: none; }
.welcome-stat strong {
  font-family: var(--font-mono);
  font-size: 18px;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1;
}
.welcome-stat span {
  font-size: 11px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.welcome-actions {
  margin-bottom: 24px;
}
.welcome-panels {
  display: flex;
  flex-direction: column;
  gap: 12px;
  text-align: left;
}
.welcome-panel {
  border: 2px solid var(--line);
  border-radius: 2px;
  padding: 12px 14px;
  background: var(--bg-secondary);
}
.welcome-panel-kicker {
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  margin-bottom: 8px;
}
.welcome-list {
  margin: 0;
  padding-left: 16px;
  font-size: 13px;
  line-height: 1.7;
  color: var(--text-secondary);
}
.welcome-list code {
  font-family: var(--font-mono);
  font-size: 12px;
  background: var(--bg-tertiary);
  border: 1px solid var(--line);
  padding: 1px 4px;
  border-radius: 2px;
}

/* Message Bubbles */
.msg {
  display: flex;
  gap: 10px;
  max-width: 90%;
  min-width: 0;
  animation: fadeIn 0.25s ease;
}
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}
.msg.user { align-self: flex-end; flex-direction: row-reverse; }
.msg.assistant { align-self: flex-start; }

.msg-avatar {
  width: 32px;
  height: 32px;
  border: 2px solid var(--line);
  border-radius: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 700;
  flex-shrink: 0;
}
.msg.user .msg-avatar { background: var(--bg-bubble-user); color: var(--surface-strong); }
.msg.assistant .msg-avatar { background: var(--blue); color: var(--text-primary); }

.msg-bubble {
  padding: 12px 16px;
  border: 2px solid var(--line);
  border-radius: 0;
  line-height: 1.65;
  word-break: break-word;
  min-width: 0;
  max-width: 100%;
}
.msg-attachments {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}
.msg-attachment-label {
  display: inline-flex;
  align-items: center;
  max-width: 100%;
  padding: 4px 8px;
  border: 2px solid var(--line);
  border-radius: 2px;
  background: var(--accent-light);
  color: var(--text-secondary);
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 600;
  line-height: 1.35;
}
.msg.user .msg-bubble {
  background: var(--bg-bubble-user);
  color: var(--surface-strong);
  box-shadow: 3px 3px 0 rgba(56, 56, 56, 0.3);
}
.msg.user .msg-attachment-label {
  background: rgba(255, 255, 255, 0.16);
  color: rgba(255, 255, 255, 0.92);
  border-color: rgba(255, 255, 255, 0.3);
}
.msg.assistant .msg-bubble {
  background: var(--surface-strong);
  color: var(--text-primary);
  box-shadow: 3px 3px 0 rgba(56, 56, 56, 0.15);
}
.msg-bubble > .msg-segment {
  margin: 0;
}
.msg-bubble > .msg-segment + .msg-segment {
  margin-top: 10px;
}
.msg-segment-text {
  min-width: 0;
  font-size: 15px;
  line-height: 1.75;
  color: var(--text-primary);
  opacity: 1;
}
.msg-segment-text.msg-segment-process {
  font-size: 13px;
  line-height: 1.7;
  color: var(--text-secondary);
  opacity: 0.88;
}
.msg-segment-text.msg-segment-final {
  font-size: 15px;
  line-height: 1.75;
  color: var(--text-primary);
  opacity: 1;
}
.msg-segment-pending {
  min-height: 24px;
}

/* System messages */
.msg.system {
  align-self: center;
  max-width: 90%;
}
.msg.system .msg-bubble {
  background: var(--bg-tertiary);
  border: 2px dashed var(--line);
  border-radius: 0;
  color: var(--text-secondary);
  font-size: 13px;
  padding: 10px 16px;
  text-align: center;
  white-space: pre-line;
  box-shadow: none;
}

/* Error messages */
.msg.system.error-msg {
  animation: errorShake 0.4s ease;
}
.msg.system.error-msg .msg-bubble {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  text-align: left;
}
.error-dismiss-btn {
  background: none;
  border: none;
  color: inherit;
  font-size: 18px;
  cursor: pointer;
  padding: 0 4px;
  opacity: 0.6;
  transition: opacity 120ms;
  flex-shrink: 0;
  margin-left: auto;
}
.error-dismiss-btn:hover {
  opacity: 1;
}
@keyframes errorShake {
  0%, 100% { transform: translateX(0); }
  20%, 60% { transform: translateX(-4px); }
  40%, 80% { transform: translateX(4px); }
}

/* Markdown content */
.msg-bubble p { margin: 0 0 8px 0; }
.msg-bubble p:last-child { margin-bottom: 0; }
.msg-bubble ul, .msg-bubble ol { margin: 4px 0 8px 20px; }
.msg-bubble li { margin-bottom: 2px; }
.msg-bubble h1, .msg-bubble h2, .msg-bubble h3, .msg-bubble h4 {
  margin: 12px 0 6px 0;
  font-family: var(--font-mono);
  text-transform: uppercase;
  letter-spacing: 0.02em;
}
.msg-bubble h1 { font-size: 1.3em; }
.msg-bubble h2 { font-size: 1.15em; }
.msg-bubble h3 { font-size: 1.05em; }
.msg-bubble a { color: var(--blue-strong); text-decoration: none; text-underline-offset: 0.22em; }
.msg-bubble a:hover { text-decoration: underline; border-bottom: 2px solid var(--blue); }
.msg-bubble blockquote {
  border-left: 3px solid var(--line);
  padding-left: 12px;
  color: var(--text-secondary);
  margin: 8px 0;
}
.msg-bubble table {
  border-collapse: collapse;
  margin: 8px 0;
  font-size: 13px;
  width: 100%;
  display: block;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}
.msg-bubble th, .msg-bubble td {
  border: 2px solid var(--line);
  padding: 6px 10px;
  text-align: left;
  white-space: nowrap;
}
.msg-bubble th { background: var(--bg-secondary); font-family: var(--font-mono); font-size: 12px; text-transform: uppercase; }

/* Inline code */
.msg-bubble code:not(pre code) {
  background: var(--bg-tertiary);
  padding: 2px 6px;
  border: 1px solid var(--line);
  border-radius: 2px;
  font-size: 0.88em;
  font-family: var(--font-mono);
  color: var(--text-primary);
}
.msg.user .msg-bubble code:not(pre code) {
  background: rgba(255,255,255,0.2);
  border-color: rgba(255,255,255,0.3);
  color: #fff;
}

/* Code blocks */
.code-block-wrapper {
  position: relative;
  margin: 8px 0;
  border: 2px solid var(--line);
  border-radius: 0;
  overflow: hidden;
  max-width: 100%;
}
.code-block-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 6px 12px;
  background: var(--code-header-bg);
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--code-header-text);
  border-bottom: 2px solid var(--line);
}
.code-block-actions {
  display: flex;
  gap: 4px;
  align-items: center;
}
.code-copy-btn, .code-preview-btn {
  background: none;
  border: 1px solid var(--code-action-border);
  color: var(--code-header-text);
  cursor: pointer;
  font-family: var(--font-mono);
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 2px;
}
.code-copy-btn:hover, .code-preview-btn:hover { color: var(--code-action-hover-text); background: var(--code-action-hover-bg); }
.code-block-wrapper pre {
  margin: 0;
  padding: 12px;
  overflow-x: auto;
  overflow-y: hidden;
  max-width: 100%;
  -webkit-overflow-scrolling: touch;
}
.code-block-wrapper pre code {
  font-family: var(--font-mono);
  font-size: 13px;
  line-height: 1.5;
  white-space: pre;
  word-break: normal;
  display: block;
  min-width: max-content;
}
/* HTML/SVG preview pane */
.code-preview-pane {
  display: none;
  background: #fff;
  border-top: 2px solid var(--line);
}
.code-preview-iframe {
  width: 100%;
  min-height: 120px;
  max-height: 600px;
  border: none;
  display: block;
}
.code-render-pane {
  background: var(--bg);
}
.json-render-pre {
  margin: 0;
  padding: 12px;
  font-family: var(--font-mono);
  font-size: 13px;
  line-height: 1.5;
  white-space: pre;
  overflow-x: auto;
  color: var(--text);
  max-height: 600px;
  overflow-y: auto;
}
.code-block-wrapper.preview-mode .code-preview-pane { display: block; }
.code-block-wrapper.preview-mode pre { display: none; }

/* Tool calls */
.tool-call {
  margin: 4px 0;
  border: 1px solid var(--line);
  border-radius: 0;
  overflow: hidden;
  font-size: 11px;
  opacity: 0.6;
}
.tool-call.codex-command {
  border-color: var(--line);
}
.tool-call.codex-reasoning {
  border-color: var(--text-muted);
  border-style: dashed;
  opacity: 0.88;
}
.tool-call.codex-reasoning summary {
  opacity: 0.72;
}
.tool-call.codex-reasoning .tool-call-label {
  font-weight: 400;
  color: var(--text-muted);
  text-transform: none;
  letter-spacing: 0;
}
.tool-call.codex-file-change {
  border-color: var(--line);
}
.tool-call summary {
  padding: 8px 12px;
  cursor: pointer;
  font-size: 11px;
  color: var(--text-secondary);
  background: var(--bg-secondary);
  display: flex;
  align-items: flex-start;
  gap: 8px;
  user-select: none;
  list-style: none;
}
.tool-call-summary-main {
  min-width: 0;
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
}
.tool-call-label {
  display: block;
  width: 100%;
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 12px;
  text-transform: uppercase;
  color: var(--text-primary);
  line-height: 1.25;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.tool-call-subtitle {
  display: block;
  width: 100%;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--text-muted);
  font-size: 12px;
}
.tool-call-state {
  flex-shrink: 0;
  padding: 2px 8px;
  border: 2px solid var(--line);
  border-radius: 2px;
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  background: var(--bg-tertiary);
  color: var(--text-secondary);
}
.tool-call-state.running {
  background: var(--yellow);
  color: var(--text-primary);
}
.tool-call-state.done {
  background: rgba(46, 138, 97, 0.14);
  color: var(--success);
}
.tool-call-state.error {
  background: rgba(221, 68, 68, 0.14);
  color: var(--danger);
}
.tool-call summary::-webkit-details-marker { display: none; }
.tool-call summary::before {
  content: '\25B8';
  font-size: 11px;
  transition: transform 0.2s;
}
.tool-call[open] summary::before { transform: rotate(90deg); }
.tool-call summary:hover { background: var(--bg-tertiary); }
.tool-call summary:focus-visible {
  outline: 2px solid var(--blue);
  outline-offset: 2px;
  background: var(--accent-light);
}
.tool-call-icon {
  display: inline-block;
  width: 8px; height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}
.tool-call-icon.done { background: var(--success); }
.tool-call-icon.running { background: var(--yellow); animation: pulse 1s infinite; }
@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.3; }
}
.tool-call-content {
  padding: 8px 12px;
  font-size: 11px;
  color: var(--text-secondary);
  background: var(--bg-primary);
  border-top: 2px solid var(--line);
  max-height: 250px;
  overflow-y: auto;
  overflow-x: auto;
  white-space: pre-wrap;
  word-break: break-word;
  font-family: var(--font-mono);
  -webkit-overflow-scrolling: touch;
}
.tool-call-content.reasoning {
  font-family: var(--font-ui);
  line-height: 1.7;
  color: var(--text-muted);
  background: var(--bg-primary);
  font-style: italic;
  font-size: 11px;
  opacity: 0.9;
}
.tool-call-content.command,
.tool-call-content.file-change {
  background: var(--surface-strong);
}
.tool-call-structured {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.tool-call-section {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.tool-call-section-label {
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
}
.tool-call-code {
  margin: 0;
  padding: 10px 12px;
  border: 2px solid var(--line);
  border-radius: 0;
  background: var(--bg-secondary);
  color: var(--text-primary);
  white-space: pre-wrap;
  word-break: break-word;
  font-family: var(--font-mono);
  font-size: 12px;
  line-height: 1.6;
}
.tool-call-empty {
  color: var(--text-muted);
  font-style: italic;
}

/* Tool group (auto-fold) */
.tool-group {
  margin: 8px 0;
  border: 2px solid var(--line);
  border-radius: 0;
  overflow: hidden;
}
.tool-group-summary {
  padding: 8px 12px;
  cursor: pointer;
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-muted);
  background: var(--bg-secondary);
  list-style: none;
  user-select: none;
  text-transform: uppercase;
}
.tool-group-summary::-webkit-details-marker { display: none; }
.tool-group-summary::before {
  content: '\25B8 ';
  font-size: 11px;
  transition: transform 0.2s;
  display: inline-block;
}
.tool-group[open] > .tool-group-summary::before { transform: rotate(90deg); }
.tool-group-summary:hover { background: var(--bg-tertiary); }
.tool-group-inner {
  padding: 4px 8px;
  background: var(--bg-primary);
}
.tool-group-inner .tool-call {
  margin: 4px 0;
}

/* AskUserQuestion preview */
.ask-user-question {
  padding: 10px 12px;
  background: var(--bg-primary);
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.ask-question-card {
  border: 2px solid var(--line);
  border-radius: 0;
  background: var(--surface-strong);
  padding: 10px;
}
.ask-question-header {
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 700;
  color: var(--blue-strong);
  text-transform: uppercase;
  margin-bottom: 6px;
}
.ask-question-text {
  font-size: 13px;
  line-height: 1.5;
  color: var(--text-primary);
  margin-bottom: 8px;
}
.ask-options-layout {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.ask-options-layout.has-preview {
  display: grid;
  grid-template-columns: 1fr 1fr;
  grid-template-rows: auto auto;
  gap: 8px;
  align-items: start;
}
.ask-question-options {
  display: flex;
  flex-direction: column;
  gap: 6px;
  grid-row: 1;
  grid-column: 1;
}
.ask-option-preview {
  grid-row: 1;
  grid-column: 2;
  background: var(--bg-secondary);
  border: 2px solid var(--line);
  border-radius: 0;
  padding: 10px 12px;
  font-family: var(--font-mono);
  font-size: 12px;
  line-height: 1.6;
  color: var(--text-secondary);
  min-height: 60px;
  transition: background 0.15s;
  white-space: pre-wrap;
  word-break: break-word;
}
.ask-confirm-btn {
  display: none;
  grid-row: 2;
  grid-column: 1 / -1;
  width: 100%;
  padding: 9px 0;
  border: 2px solid var(--line);
  border-radius: 2px;
  background: transparent;
  color: var(--text-primary);
  font-family: var(--font-mono);
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
  cursor: pointer;
  transition: background 120ms;
}
.ask-confirm-btn:active {
  background: var(--blue);
}
@media (pointer: coarse) {
  .ask-confirm-btn { display: block; }
}
.ask-option-item {
  border: 2px solid var(--line);
  border-radius: 2px;
  padding: 8px;
  background: var(--bg-secondary);
  width: 100%;
  text-align: left;
  cursor: pointer;
  transition: background 120ms, transform 120ms, box-shadow 120ms;
}
.ask-option-item:hover {
  background: var(--accent-light);
  transform: translate(1px, 1px);
}
.ask-option-item.ask-option-selected {
  background: var(--blue);
  border-color: var(--line);
  box-shadow: 2px 2px 0 var(--line);
}
.ask-option-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-primary);
}
.ask-option-desc {
  font-size: 12px;
  color: var(--text-secondary);
  line-height: 1.45;
  margin-top: 4px;
}

/* Typing indicator */
.typing-indicator {
  display: inline-flex;
  gap: 5px;
  padding: 8px 4px;
}
.typing-indicator span {
  width: 7px; height: 7px;
  background: var(--line);
  border-radius: 50%;
  opacity: 0.5;
  animation: bounce 1.4s infinite;
}
.typing-indicator span:nth-child(2) { animation-delay: 0.2s; }
.typing-indicator span:nth-child(3) { animation-delay: 0.4s; }
@keyframes bounce {
  0%, 60%, 100% { transform: translateY(0); }
  30% { transform: translateY(-7px); }
}

/* === Slash Command Menu === */
.cmd-menu {
  position: absolute;
  bottom: 80px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--surface-strong);
  border: 2px solid var(--line);
  border-radius: 0;
  box-shadow: 4px 4px 0 var(--line);
  padding: 6px;
  min-width: 240px;
  max-width: 320px;
  z-index: 50;
}
.cmd-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border-radius: 2px;
  cursor: pointer;
  transition: background 120ms;
}
.cmd-item:hover, .cmd-item.active { background: var(--accent-light); }
.cmd-item-cmd {
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 14px;
  color: var(--blue-strong);
  white-space: nowrap;
}
.cmd-item-desc {
  font-size: 13px;
  color: var(--text-secondary);
}

/* === Input Area === */
.input-area {
  padding: 8px 16px;
  padding-bottom: max(12px, var(--safe-bottom));
  background: var(--bg-secondary);
  border-top: 2px solid var(--line);
  flex-shrink: 0;
}
.attachment-tray {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  max-width: min(920px, 100%);
  margin: 0 auto 10px;
}
.attachment-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  max-width: 100%;
  padding: 7px 10px;
  border: 2px solid var(--line);
  border-radius: 0;
  background: var(--surface-strong);
  color: var(--text-primary);
  font-size: 12px;
  line-height: 1.4;
}
.attachment-chip.uploading {
  border-style: dashed;
  background: var(--surface);
}
.attachment-chip-meta {
  display: flex;
  flex-direction: column;
  min-width: 0;
}
.attachment-chip-name {
  font-weight: 700;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.attachment-chip-note {
  color: var(--text-muted);
  font-size: 11px;
  white-space: nowrap;
}
.attachment-chip-remove {
  --compact-btn-border: none;
  --compact-btn-bg: transparent;
  --compact-btn-color: var(--text-muted);
  --compact-btn-hover-bg: rgba(221, 68, 68, 0.1);
  --compact-btn-hover-color: var(--danger);

  font-size: 13px;
  padding: 2px;
}
.attachment-chip-remove:hover {
  /* keep explicit block for readability with shared compact control base */
}
.attachment-tray-note {
  width: 100%;
  padding: 8px 10px;
  border: 2px solid var(--line);
  border-radius: 0;
  background: var(--yellow);
  color: var(--text-primary);
  font-size: 12px;
  line-height: 1.55;
}
.input-wrapper {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  background: var(--surface-strong);
  border: 2px solid var(--line);
  border-radius: 2px;
  padding: 8px 12px;
  max-width: min(920px, 100%);
  margin: 0 auto;
  box-shadow: 4px 4px 0 var(--line);
  transition: box-shadow 120ms ease;
}
.input-wrapper.drag-active {
  border-color: var(--blue);
  box-shadow: 4px 4px 0 var(--blue);
}
.attach-btn {
  appearance: none;
  width: 40px;
  height: 40px;
  background: var(--surface);
  color: var(--text-primary);
  border: 2px solid var(--line);
  border-radius: 2px;
  cursor: pointer;
  padding: 0;
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-shadow: 2px 2px 0 var(--line);
  transition: transform 120ms ease, box-shadow 120ms ease, background 120ms ease;
}
.attach-btn:hover {
  background: var(--yellow);
  transform: translate(1px, 1px);
  box-shadow: 1px 1px 0 var(--line);
}
.attach-btn:disabled {
  opacity: 0.45;
  cursor: default;
}
.input-wrapper:focus-within {
  box-shadow: 4px 4px 0 var(--blue);
}
#msg-input {
  flex: 1;
  background: transparent;
  border: none;
  color: var(--text-primary);
  font-size: 15px;
  font-family: var(--font-ui);
  line-height: 1.5;
  resize: none;
  outline: none;
  max-height: var(--input-max-height);
  min-height: 24px;
  overflow-y: auto;
}
#msg-input::placeholder { color: var(--text-muted); }
.send-btn, .abort-btn {
  width: 36px; height: 36px;
  border: 2px solid var(--line);
  border-radius: 2px;
  cursor: pointer;
  display: flex;
  align-items: center; justify-content: center;
  flex-shrink: 0;
  box-shadow: 2px 2px 0 var(--line);
  transition: transform 120ms ease, box-shadow 120ms ease, background 120ms ease;
}
.send-btn:active, .abort-btn:active {
  transform: translate(2px, 2px);
  box-shadow: none;
}
.send-btn {
  background: var(--blue);
  color: var(--text-primary);
}
.send-btn:hover {
  background: var(--yellow);
  transform: translate(1px, 1px);
  box-shadow: 1px 1px 0 var(--line);
}
.send-btn:disabled { opacity: 0.4; cursor: not-allowed; }
.abort-btn {
  background: var(--danger);
  color: #fff;
}
.abort-btn:hover {
  background: #c33;
  transform: translate(1px, 1px);
  box-shadow: 1px 1px 0 var(--line);
}

/* === Option Picker === */
.option-picker {
  position: absolute;
  bottom: 80px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--surface-strong);
  border: 2px solid var(--line);
  border-radius: 0;
  box-shadow: 6px 6px 0 var(--line);
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 12px;
  min-width: 260px;
  width: min(360px, calc(100vw - 32px));
  max-width: calc(100vw - 32px);
  max-height: min(70vh, 540px);
  z-index: 50;
  animation: fadeIn 0.2s ease;
}
.option-picker-title {
  font-family: var(--font-mono);
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--text-primary);
  margin-bottom: 0;
  padding: 0 2px;
}
.option-picker-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
  max-height: min(42vh, 320px);
  overflow-y: auto;
  overflow-x: hidden;
  padding-right: 2px;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  touch-action: pan-y;
}
.option-picker-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border: 2px solid transparent;
  border-radius: 2px;
  cursor: pointer;
  transition: background 120ms, border-color 120ms;
  margin-bottom: 0;
}
.option-picker-item:last-child { margin-bottom: 0; }
.option-picker-item:hover {
  background: var(--accent-light);
  border-color: var(--line);
}
.option-picker-item.active {
  background: var(--blue);
  border-color: var(--line);
}
.option-picker-item-info { flex: 1; min-width: 0; }
.option-picker-item-label {
  font-weight: 600;
  font-size: 14px;
  line-height: 1.35;
  color: var(--text-primary);
}
.option-picker-item-desc {
  font-size: 12px;
  color: var(--text-secondary);
  line-height: 1.4;
  margin-top: 1px;
}
.option-picker-item-check {
  color: var(--text-primary);
  font-size: 14px;
  font-weight: 700;
  flex-shrink: 0;
}

/* === Model Picker (Claude Code style) === */
.model-picker-claude {
  width: min(420px, calc(100vw - 32px));
  max-width: calc(100vw - 32px);
  max-height: min(76vh, 600px);
}
.mp-header {
  margin-bottom: 8px;
  padding: 0 2px;
}
.mp-subtitle {
  font-size: 11px;
  color: var(--text-secondary);
  margin-top: 3px;
  line-height: 1.4;
}
.mp-cursor {
  font-size: 13px;
  color: var(--accent, var(--accent-fallback));
  width: 14px;
  flex-shrink: 0;
  text-align: center;
}
.mp-num {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-secondary);
  min-width: 18px;
  text-align: right;
  flex-shrink: 0;
}
.mp-check {
  color: var(--success-strong);
  font-weight: 700;
  margin-left: 4px;
}
.option-picker-item.focused {
  background: var(--accent-light);
}
.mp-items {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-bottom: 2px;
  max-height: min(38vh, 280px);
  overflow-y: auto;
  overflow-x: hidden;
  padding-right: 2px;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  touch-action: pan-y;
}
.mp-custom {
  padding: 6px 2px 0;
  margin-top: 2px;
  border-top: 1px solid var(--border-color);
}
.mp-custom-input {
  width: 100%;
  box-sizing: border-box;
  padding: 6px 8px;
  border: 1px solid var(--border-color, #ccc);
  border-radius: 4px;
  font-size: 12px;
  line-height: 1.4;
  font-family: var(--font-mono);
  background: var(--input-bg, #fff);
  color: var(--text-primary, #333);
  outline: none;
}
.mp-custom-input:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 1px var(--blue);
}
.option-picker-list::-webkit-scrollbar,
.mp-items::-webkit-scrollbar {
  width: 8px;
}
.option-picker-list::-webkit-scrollbar-thumb,
.mp-items::-webkit-scrollbar-thumb {
  background: var(--scrollbar-thumb);
  border-radius: 999px;
}
.option-picker-list::-webkit-scrollbar-track,
.mp-items::-webkit-scrollbar-track {
  background: transparent;
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}
.mp-hint {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--text-secondary);
  text-align: center;
  padding: 4px 0 0;
  opacity: 0.7;
}

/* Mobile topbar bar — hidden on desktop */
.mobile-topbar-bar {
  display: none;
  flex-shrink: 0;
}
.mobile-topbar-select {
  --compact-text-control-size: 11px;

  display: none;
  appearance: auto;
  background: var(--surface);
  border: 2px solid var(--line);
  box-shadow: 2px 2px 0 var(--line);
  height: 36px;
  padding: 0 6px;
  flex-shrink: 0;
  vertical-align: middle;
}

/* === Mobile === */
@media (max-width: 728px) {
  .sidebar {
    position: fixed;
    left: 0; top: 0; bottom: 0;
    z-index: 100;
    transform: translateX(-100%);
  }
  .sidebar.open { transform: translateX(0); }
  .sidebar-overlay {
    position: fixed; inset: 0;
    background: rgba(56, 56, 56, 0.3);
    z-index: 99;
  }
  .menu-btn { display: block; }
  .msg { max-width: 95%; }
  .input-area { padding: 8px 10px; padding-bottom: max(10px, var(--safe-bottom)); }
  .messages { padding: 12px 8px; gap: 10px; }
  .session-item-actions { display: flex; }
  .session-item-btn { opacity: 1; }
  .project-group-actions { opacity: 1; }
  .app-topbar {
    padding: 0 10px;
    gap: 6px;
  }
  .app-topbar-brand {
    flex-shrink: 1;
    min-width: 0;
  }
  .app-topbar-brand strong {
    font-size: 13px;
  }
  .app-topbar-actions {
    gap: 4px;
    flex-shrink: 0;
  }
  .agent-tabs, .mode-tabs {
    display: none;
  }
  .mobile-topbar-bar {
    display: none;
  }
  .mobile-topbar-select {
    display: block;
    width: auto;
  }
  .cmd-menu { left: 10px; right: 10px; transform: none; min-width: auto; bottom: 72px; }
  .option-picker { left: 10px; right: 10px; transform: none; min-width: auto; max-width: none; bottom: 72px; }
  .chat-title {
    font-size: 12px;
  }
  .chat-agent-context {
    font-size: 10px;
  }
  .chat-agent-menu {
    right: 10px;
    min-width: 138px;
  }
  .chat-cwd {
    display: none;
  }
}

@media (max-width: 480px) {
  .msg-avatar { width: 28px; height: 28px; font-size: 11px; }
  .msg-bubble { padding: 10px 12px; font-size: 14px; }
  .msg-segment-text.msg-segment-process { font-size: 12px; }
  .msg-segment-text.msg-segment-final { font-size: 14px; }
  .code-block-wrapper pre code { font-size: 12px; }
  .input-wrapper { padding: 6px 10px; box-shadow: 3px 3px 0 var(--line); }
  .attach-btn { width: 38px; height: 38px; }
  .send-btn, .abort-btn { width: 34px; height: 34px; }
  .new-chat-btn,
  .new-chat-arrow { min-height: 44px; }
  .new-chat-arrow { width: 48px; }
  /* Mobile tool content overflow fix */
  .tool-call-content {
    max-height: 180px;
    font-size: 11px;
    padding: 6px 8px;
  }
  .tool-call-code {
    font-size: 11px;
    padding: 8px 10px;
  }
  .code-block-wrapper {
    margin: 6px 0;
  }
  .code-block-wrapper pre {
    padding: 8px 10px;
  }
}

/* === Utility === */
[hidden] { display: none !important; }

/* === Toast Notification === */
.toast-notification {
  position: fixed;
  top: calc(var(--header-height) + 10px);
  left: 50%;
  transform: translateX(-50%) translateY(-6px);
  background: var(--success);
  color: #fff;
  padding: 12px 20px;
  border: 2px solid var(--line);
  border-radius: 0;
  font-family: var(--font-mono);
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
  box-shadow: 4px 4px 0 var(--line);
  z-index: 200;
  opacity: 0;
  transition: opacity 0.3s, transform 0.3s;
  white-space: nowrap;
}
.toast-notification.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* === Connection Status Indicator === */
body.ws-reconnecting::before {
  content: '⟳ 重连中';
  position: fixed;
  top: 0;
  left: 50%;
  transform: translateX(-50%);
  background: var(--yellow);
  color: var(--text-primary);
  padding: 6px 16px;
  border: 2px solid var(--line);
  border-top: none;
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  z-index: 1000;
  animation: pulse 1.5s ease-in-out infinite;
}

/* === Session Unread Dot === */
.session-unread-dot {
  width: 8px;
  height: 8px;
  background: var(--blue);
  border-radius: 50%;
  flex-shrink: 0;
  margin-left: 4px;
}

/* === Settings Button (topbar) === */
.settings-btn {
  background: none;
  border: none;
  font-size: 18px;
  cursor: pointer;
  color: var(--text-muted);
  padding: 4px 8px;
  border-radius: 2px;
  transition: color 120ms, background 120ms;
  vertical-align: middle;
}
.settings-btn:hover { color: var(--text-primary); background: var(--bg-tertiary); }

/* === Settings Overlay & Panel === */
.settings-overlay {
  position: fixed; inset: 0;
  display: flex; align-items: center; justify-content: center;
  background: rgba(56, 56, 56, 0.35);
  z-index: 1000;
  animation: fadeIn 0.2s ease;
}
.settings-panel {
  background: var(--surface-strong);
  border: 2px solid var(--line);
  border-radius: 0;
  width: 90%;
  max-width: 420px;
  max-height: 85vh;
  overflow-y: auto;
  box-shadow: 6px 6px 0 var(--line);
  padding: 32px 28px;
  animation: fadeIn 0.25s ease;
}
.settings-panel h3 {
  font-family: var(--font-mono);
  font-size: 18px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-primary);
  margin-bottom: 20px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.settings-panel h3 .settings-close {
  --compact-btn-bg: transparent;
  --compact-btn-color: var(--text-muted);

  margin-left: auto;
  font-size: 18px;
  padding: 2px 8px;
}
.settings-panel h3 .settings-close:hover { /* keep explicit block for readability */ }
/* Local file viewer */
.localfile-body {
  overflow: auto;
  max-height: calc(80vh - 80px);
}
.localfile-iframe {
  width: 100%;
  height: calc(80vh - 80px);
  border: none;
  display: block;
}
.localfile-pre {
  margin: 0;
  padding: 16px;
  font-family: var(--font-mono);
  font-size: 13px;
  line-height: 1.6;
  white-space: pre-wrap;
  word-break: break-all;
  color: var(--text);
  background: var(--bg);
}
.local-file-link {
  color: var(--accent);
  text-decoration: underline;
  cursor: pointer;
}
.settings-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 20px;
}
.settings-back {
  --compact-btn-bg: var(--surface);
  --compact-btn-color: var(--text-primary);
  --compact-btn-shadow: 2px 2px 0 var(--line);
  --compact-btn-hover-shift: 1px;
  --compact-btn-hover-shadow: 1px 1px 0 var(--line);

  width: 34px;
  height: 34px;
  font-size: 22px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  box-shadow: var(--compact-btn-shadow);
}
.settings-back:hover {
  /* keep explicit block for readability with shared compact control base */
}
.settings-header h3 {
  margin-bottom: 0;
  flex: 1;
}
.settings-subpage-header {
  align-items: flex-start;
}
.settings-subpage-copy {
  flex: 1;
  min-width: 0;
}
.settings-subpage-copy h3 {
  margin-bottom: 0;
}
.settings-subpage-kicker {
  display: inline-flex;
  align-items: center;
  min-height: 20px;
  margin-bottom: 4px;
  color: var(--text-muted);
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}
.settings-header .settings-close {
  --compact-btn-bg: transparent;
  --compact-btn-color: var(--text-muted);

  margin-left: auto;
  font-size: 18px;
  padding: 2px 8px;
}
.settings-header .settings-close:hover { /* keep explicit block for readability */ }
.settings-field {
  margin-bottom: 16px;
}
.agent-context-card {
  margin: -6px 0 18px;
  padding: 14px 16px 15px;
  border: 2px solid var(--line);
  border-radius: 0;
  background: var(--accent-light);
}
.agent-context-kicker {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--blue-strong);
  margin-bottom: 6px;
}
.agent-context-title {
  font-family: var(--font-mono);
  font-size: 15px;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--text-primary);
  margin-bottom: 4px;
}
.agent-context-copy {
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.65;
}
.settings-field label {
  display: block;
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-secondary);
  margin-bottom: 6px;
}
.tpl-fetch-toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
}
.tpl-fetch-toolbar-title {
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-secondary);
  white-space: nowrap;
}
.tpl-fetch-toolbar-btn {
  flex: 0 0 auto;
  padding: 6px 12px;
  border: 2px solid var(--line);
  border-radius: 2px;
  background: var(--bg-secondary);
  color: var(--text-primary);
  font-family: var(--font-mono);
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
  cursor: pointer;
  box-shadow: 2px 2px 0 var(--line);
  transition: transform 120ms ease, box-shadow 120ms ease, background 120ms ease;
  white-space: nowrap;
}
.tpl-fetch-toolbar-btn:hover {
  background: var(--yellow);
  transform: translate(1px, 1px);
  box-shadow: 1px 1px 0 var(--line);
}
.tpl-fetch-toolbar-btn:active {
  transform: translate(2px, 2px);
  box-shadow: none;
}
.tpl-fetch-toolbar-status {
  display: block;
  margin-top: 4px;
  font-size: 12px;
  color: var(--text-secondary);
}
.tpl-fetch-toolbar-status:empty {
  display: none;
}
.settings-inline-note {
  margin: -6px 0 16px;
  padding: 7px 10px;
  border: 1px dashed rgba(56, 56, 56, 0.28);
  border-radius: 0;
  font-size: 11px;
  line-height: 1.55;
  color: var(--text-muted);
  background: rgba(248, 248, 247, 0.68);
}
.settings-inline-note.warning {
  color: var(--text-primary);
  background: var(--yellow);
  border-color: var(--line);
}
.settings-inline-note code {
  font-family: var(--font-mono);
  font-size: 10px;
  padding: 1px 4px;
  border: 1px solid var(--line);
  border-radius: 2px;
  background: rgba(56, 56, 56, 0.08);
  color: var(--text-primary);
}
.settings-nav-card {
  appearance: none;
  width: 100%;
  padding: 14px 16px;
  border: 2px solid var(--line);
  border-radius: 0;
  background: var(--surface-strong);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  text-align: left;
  cursor: pointer;
  box-shadow: 3px 3px 0 var(--line);
  transition: transform 120ms ease, box-shadow 120ms ease, background 120ms ease;
}
.settings-nav-card:hover {
  transform: translate(2px, 2px);
  box-shadow: 1px 1px 0 var(--line);
  background: var(--accent-light);
}
.settings-nav-card:active {
  transform: translate(3px, 3px);
  box-shadow: none;
}
.settings-nav-card-main {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}
.settings-nav-card-title {
  font-family: var(--font-mono);
  font-size: 14px;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--text-primary);
}
.settings-nav-card-meta {
  font-size: 12px;
  color: var(--text-secondary);
}
.settings-nav-card-arrow {
  color: var(--text-muted);
  font-size: 22px;
  line-height: 1;
  flex-shrink: 0;
}
.settings-subpage-panel {
  max-width: 460px;
}
.settings-field input,
.settings-select {
  width: 100%;
  padding: 10px 12px;
}
.settings-select {
  -webkit-appearance: none;
  appearance: none;
  cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M0 0l5 6 5-6z' fill='%23383838'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 32px;
}
.settings-actions {
  display: flex;
  gap: 10px;
  margin-top: 24px;
}
.settings-actions button {
  --nb-btn-shadow: 2px 2px 0 var(--line);
  --nb-btn-hover-shift: 1px;

  flex: 1;
  padding: 10px;
}
.settings-actions .btn-test {
  --nb-btn-bg: var(--bg-secondary);
}
.settings-actions .btn-test:hover {
  /* keep explicit block for readability with shared button base */
}
.settings-actions .btn-save {
  --nb-btn-bg: var(--blue);
}
.settings-actions .btn-save:hover {
  /* keep explicit block for readability with shared button base */
}
.settings-actions .btn-save:active,
.settings-actions .btn-test:active {
  transform: translate(2px, 2px);
  box-shadow: none;
}
.settings-status {
  margin-top: 12px;
  font-family: var(--font-mono);
  font-size: 13px;
  text-align: center;
  min-height: 20px;
  text-transform: uppercase;
}
.settings-status.success { color: var(--success); }
.settings-status.error { color: var(--danger); }

@media (max-width: 728px) {
  .settings-panel { padding: 24px 20px; }
}
@media (max-width: 480px) {
  .settings-panel { width: 95%; padding: 20px 16px; }
  .settings-nav-card { padding: 13px 14px; }
  .settings-back { width: 32px; height: 32px; }
}

/* === Force Change Password Overlay === */
.force-change-overlay {
  position: fixed; inset: 0;
  display: flex; align-items: center; justify-content: center;
  background: rgba(56, 56, 56, 0.5);
  z-index: 2000;
  animation: fadeIn 0.25s ease;
}
.force-change-panel {
  text-align: center;
  padding: 48px 36px;
  background: var(--surface-strong);
  border: 2px solid var(--line);
  border-radius: 0;
  width: 90%;
  max-width: 400px;
  box-shadow: 6px 6px 0 var(--line);
  animation: fadeIn 0.25s ease;
}
.force-change-panel .login-logo {
  width: 56px; height: 56px;
  margin: 0 auto 12px;
  background: var(--line);
  color: var(--surface-strong);
  border: 2px solid var(--line);
  border-radius: 0;
  display: flex; align-items: center; justify-content: center;
  font-family: var(--font-mono);
  font-size: 20px; font-weight: 700;
}
.force-change-panel h2 {
  font-family: var(--font-mono);
  font-size: 22px;
  margin-bottom: 4px;
  color: var(--text-primary);
  font-weight: 700;
  text-transform: uppercase;
}
.force-change-panel p {
  color: var(--text-secondary);
  margin-bottom: 24px;
  font-size: 14px;
}
.force-change-form input {
  width: 100%;
  padding: 10px 12px;
  margin-bottom: 10px;
}
.fc-submit-btn {
  --nb-btn-bg: var(--blue);
  --nb-btn-font-size: 14px;
  --nb-btn-shadow: 3px 3px 0 var(--line);

  width: 100%;
  padding: 12px;
  margin-top: 6px;
}
.fc-submit-btn:hover:not(:disabled) {
  background: var(--yellow);
  transform: translate(2px, 2px);
  box-shadow: 1px 1px 0 var(--line);
}
.fc-submit-btn:disabled { opacity: 0.4; cursor: not-allowed; }
.fc-status {
  margin-top: 10px;
  font-size: 13px;
  min-height: 18px;
  color: var(--text-secondary);
}
.fc-status.error { color: var(--danger); }
.fc-status.success { color: var(--success); }

/* === Password Hint === */
.password-hint {
  font-size: 12px;
  color: var(--text-muted);
  margin: -4px 0 10px 2px;
  text-align: left;
}
.password-hint.error { color: var(--danger); }
.password-hint.success { color: var(--success); }

/* === Settings Divider === */
.settings-divider {
  height: 2px;
  background: var(--line);
  margin: 24px 0;
}

/* === Settings Section Title === */
.settings-section-title {
  font-family: var(--font-mono);
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-secondary);
  margin-bottom: 14px;
}

/* === New Chat Split Button === */
.new-chat-split {
  display: flex;
  align-items: stretch;
  gap: 0;
}
.new-chat-split.single .new-chat-btn {
  border-radius: 2px;
}
.new-chat-split.single .new-chat-arrow {
  display: none;
}
.new-chat-split .new-chat-btn {
  flex: 1;
  min-height: 48px;
  border-radius: 2px 0 0 2px;
  border-right: none;
}
.new-chat-arrow {
  --nb-btn-bg: var(--blue);
  --nb-btn-shadow: 3px 3px 0 var(--line);
  --nb-btn-hover-shift: 0px;
  --nb-btn-hover-shadow: var(--nb-btn-shadow);

  width: 52px;
  min-height: 48px;
  padding: 0;
  border-left: 2px solid rgba(56, 56, 56, 0.4);
  border-radius: 0 2px 2px 0;
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.new-chat-arrow:hover {
  background: var(--yellow);
}
.new-chat-dropdown {
  position: absolute;
  top: 54px;
  left: 12px;
  right: 12px;
  background: var(--surface-strong);
  border: 2px solid var(--line);
  border-radius: 0;
  box-shadow: 4px 4px 0 var(--line);
  z-index: 200;
  overflow: hidden;
}
.new-chat-dropdown button {
  --compact-text-control-font: var(--font-ui);
  --compact-text-control-size: 13px;
  --compact-text-control-weight: 600;
  --compact-text-control-spacing: 0.02em;

  display: block;
  width: 100%;
  min-height: 46px;
  padding: 12px 16px;
  background: none;
  border: none;
  border-bottom: 2px solid var(--line);
  text-align: left;
  line-height: 1.45;
  touch-action: manipulation;
}
.new-chat-dropdown button:last-child { border-bottom: none; }
.new-chat-dropdown button:hover { background: var(--accent-light); }

.dropdown-divider {
  border: none;
  border-top: 2px solid var(--line);
  margin: 0;
}

#import-session-btn {
  color: var(--text-secondary);
  font-size: 12px;
  border-top: 3px solid var(--line) !important;
}
#import-session-btn::before {
  content: '↓ ';
  opacity: 0.5;
}
#import-session-btn:hover {
  color: var(--text-primary);
  border-top-color: var(--blue) !important;
}

.new-chat-dropdown button:focus-visible {
  position: relative;
  z-index: 1;
  background: var(--accent-light);
  box-shadow: inset 0 0 0 2px var(--blue);
  outline: none;
}

/* === Chat CWD label === */
.chat-cwd {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-muted);
  background: var(--bg-tertiary);
  border: 2px solid var(--line);
  border-radius: 2px;
  padding: 2px 8px;
  flex-shrink: 0;
  max-width: 220px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  cursor: default;
}

/* === Modal Overlay === */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(56, 56, 56, 0.35);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 500;
  padding: 16px;
}
.modal-panel {
  background: var(--surface-strong);
  border: 2px solid var(--line);
  border-radius: 0;
  width: 100%;
  max-width: 420px;
  box-shadow: 6px 6px 0 var(--line);
  display: flex;
  flex-direction: column;
  max-height: 90vh;
}
.modal-panel-wide {
  max-width: 600px;
}
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px 12px;
  border-bottom: 2px solid var(--line);
  flex-shrink: 0;
}
.modal-title {
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 16px;
  text-transform: uppercase;
  color: var(--text-primary);
}
.modal-close-btn {
  --compact-btn-bg: transparent;
  --compact-btn-color: var(--text-muted);

  font-size: 16px;
  padding: 4px 8px;
}
.modal-close-btn:hover { /* keep explicit block for readability */ }
.modal-body {
  padding: 20px;
  overflow-y: auto;
  flex: 1;
}
.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: 12px 20px 16px;
  border-top: 2px solid var(--line);
  flex-shrink: 0;
}
.modal-field-label {
  display: block;
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-secondary);
  margin-bottom: 8px;
}
.modal-field-row {
  display: flex;
  gap: 8px;
}
.modal-select {
  width: 100%;
  padding: 10px 12px;
}
.modal-stack {
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.modal-text-input {
  flex: 1;
  padding: 10px 12px;
}
.modal-btn-primary {
  --nb-btn-bg: var(--blue);

  padding: 9px 20px;
}
.modal-btn-primary:hover {
  /* keep explicit block for readability with shared button base */
}
.modal-btn-secondary {
  --nb-btn-bg: var(--bg-secondary);

  padding: 9px 20px;
}
.modal-btn-secondary:hover {
  /* keep explicit block for readability with shared button base */
}
.modal-btn-primary:disabled,
.modal-btn-secondary:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  transform: none;
  box-shadow: 2px 2px 0 var(--line);
}
.modal-loading, .modal-empty {
  text-align: center;
  color: var(--text-muted);
  padding: 32px 0;
  font-size: 14px;
}

/* === New Session Project Picker === */
.modal-panel-project {
  max-width: 720px;
}
.modal-body-project {
  display: flex;
  flex-direction: column;
  gap: 18px;
}
.project-flow-shell {
  gap: 18px;
}
.project-picker-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px;
}
.project-picker-head-copy {
  min-width: 0;
}
.project-picker-summary {
  font-size: 13px;
  line-height: 1.6;
  color: var(--text-secondary);
}
.project-picker-total {
  flex-shrink: 0;
  padding: 5px 10px;
  border: 2px solid var(--line);
  border-radius: 2px;
  background: var(--bg-secondary);
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-primary);
}
.project-picker-list {
  display: grid;
  gap: 10px;
}
.project-picker-item {
  position: relative;
  width: 100%;
  padding: 15px 48px 15px 16px;
  border: 2px solid var(--line);
  border-radius: 2px;
  background: var(--surface);
  color: var(--text-primary);
  text-align: left;
  cursor: pointer;
  box-shadow: 3px 3px 0 var(--line);
  transition: transform 150ms ease, box-shadow 150ms ease, background 150ms ease;
  touch-action: manipulation;
}
.project-picker-item:hover {
  background: var(--accent-light);
  transform: translate(2px, 2px);
  box-shadow: 1px 1px 0 var(--line);
}
.project-picker-item-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}
.project-picker-item-tag,
.project-picker-item-count {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 3px 8px;
  border: 1px solid var(--line);
  border-radius: 2px;
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
.project-picker-item-tag {
  background: var(--yellow);
  color: var(--text-primary);
}
.project-picker-item-count {
  background: var(--bg-secondary);
  color: var(--text-secondary);
}
.project-picker-item-name {
  display: block;
  padding-right: 8px;
  font-family: var(--font-mono);
  font-size: 15px;
  font-weight: 700;
  line-height: 1.35;
  text-transform: uppercase;
  color: var(--text-primary);
  word-break: break-word;
}
.project-picker-item-path {
  display: block;
  margin-top: 7px;
  font-size: 13px;
  line-height: 1.6;
  color: var(--text-secondary);
  word-break: break-all;
}
.project-picker-item-note {
  display: block;
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px dashed rgba(56, 56, 56, 0.22);
  font-size: 12px;
  line-height: 1.6;
  color: var(--text-secondary);
}
.project-picker-item-arrow {
  position: absolute;
  right: 14px;
  top: 50%;
  font-size: 24px;
  line-height: 1;
  color: var(--text-muted);
  transform: translateY(-50%);
  transition: transform 150ms ease, color 150ms ease;
}
.project-picker-item:hover .project-picker-item-arrow {
  color: var(--text-primary);
  transform: translate(2px, -50%);
}
.project-picker-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}
.project-picker-action-btn {
  --nb-btn-bg: var(--blue);
  --nb-btn-font-size: 12px;
  --nb-btn-shadow: 3px 3px 0 var(--line);
  --nb-btn-hover-shift: 2px;

  min-height: 46px;
  padding: 10px 14px;
  letter-spacing: 0.05em;
  transition: transform 150ms ease, box-shadow 150ms ease, background 150ms ease;
  touch-action: manipulation;
}
.project-picker-action-btn.primary {
  --nb-btn-bg: var(--blue);
  color: var(--text-primary);
}
.project-picker-action-btn.secondary {
  --nb-btn-bg: var(--bg-secondary);
  color: var(--text-primary);
}
.project-picker-action-btn:hover {
  /* keep explicit block for readability with shared button base */
}
.project-picker-action-btn:active {
  transform: translate(3px, 3px);
  box-shadow: none;
}
.project-picker-helper {
  padding: 12px 14px;
  border: 2px solid var(--line);
  border-radius: 0;
  background: var(--accent-light);
  color: var(--text-secondary);
  font-size: 12px;
  line-height: 1.7;
}

/* === Directory Browser === */
.dir-browser-shell {
  gap: 14px;
}
.dir-browser-current {
  padding: 14px 16px;
  border: 2px solid var(--line);
  border-radius: 0;
  background: var(--surface);
  box-shadow: 3px 3px 0 var(--line);
}
.dir-browser-current-label {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
}
.dir-browser-current-name {
  margin-top: 6px;
  font-family: var(--font-mono);
  font-size: 16px;
  font-weight: 700;
  line-height: 1.35;
  text-transform: uppercase;
  color: var(--text-primary);
  word-break: break-word;
}
.dir-browser-current-path {
  margin-top: 4px;
  font-size: 12px;
  line-height: 1.65;
  color: var(--text-secondary);
  word-break: break-all;
}
.dir-browser-pathbar {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 48px;
  padding: 8px 10px;
  border: 2px solid var(--line);
  border-radius: 2px;
  background: var(--surface-strong);
  box-shadow: 2px 2px 0 var(--line);
}
.dir-browser-crumbs {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 6px;
  overflow-x: auto;
  white-space: nowrap;
}
.dir-browser-crumb,
.dir-browser-crumb-current {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 28px;
  padding: 0 9px;
  border-radius: 2px;
  font-family: var(--font-mono);
  font-size: 12px;
  line-height: 1;
  white-space: nowrap;
}
.dir-browser-crumb {
  appearance: none;
  border: 1px solid var(--line);
  background: var(--bg-secondary);
  color: var(--text-primary);
  cursor: pointer;
  transition: background 150ms ease, transform 150ms ease;
  touch-action: manipulation;
}
.dir-browser-crumb:hover {
  background: var(--accent-light);
  transform: translateY(-1px);
}
.dir-browser-crumb-current {
  border: 1px solid var(--line);
  background: var(--blue);
  color: var(--text-primary);
  font-weight: 700;
}
.dir-browser-crumb-sep {
  color: var(--text-muted);
  font-size: 12px;
}
.dir-browser-edit-btn,
.dir-browser-go-btn {
  appearance: none;
  min-width: 42px;
  min-height: 42px;
  padding: 0 12px;
  border: 2px solid var(--line);
  border-radius: 2px;
  background: var(--bg-secondary);
  color: var(--text-primary);
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 2px 2px 0 var(--line);
  transition: transform 150ms ease, box-shadow 150ms ease, background 150ms ease;
  touch-action: manipulation;
}
.dir-browser-edit-btn:hover,
.dir-browser-go-btn:hover {
  background: var(--yellow);
  transform: translate(1px, 1px);
  box-shadow: 1px 1px 0 var(--line);
}
.dir-browser-manual {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 10px;
}
.dir-browser-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-height: 300px;
  max-height: 360px;
  margin-top: 10px;
  padding: 10px;
  overflow-y: auto;
  border: 2px solid var(--line);
  border-radius: 0;
  background: var(--surface);
  box-shadow: 3px 3px 0 var(--line);
}
.dir-browser-item {
  appearance: none;
  width: 100%;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border: 2px solid var(--line);
  border-radius: 2px;
  background: var(--surface-strong);
  color: var(--text-primary);
  text-align: left;
  cursor: pointer;
  transition: transform 150ms ease, background 150ms ease, box-shadow 150ms ease;
  touch-action: manipulation;
}
.dir-browser-item:hover {
  background: var(--accent-light);
  transform: translate(1px, 1px);
  box-shadow: 1px 1px 0 rgba(56, 56, 56, 0.18);
}
.dir-browser-item.is-parent {
  background: var(--bg-secondary);
}
.dir-browser-item-copy {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 3px;
}
.dir-browser-item-icon {
  position: relative;
  width: 20px;
  height: 16px;
  flex-shrink: 0;
}
.dir-browser-item-icon::before,
.dir-browser-item-icon::after {
  content: '';
  position: absolute;
  border: 2px solid var(--line);
  border-radius: 2px 2px 0 0;
}
.dir-browser-item-icon::before {
  left: 0;
  top: 4px;
  width: 20px;
  height: 12px;
  border-radius: 2px;
  background: var(--yellow);
}
.dir-browser-item-icon::after {
  left: 2px;
  top: 0;
  width: 10px;
  height: 7px;
  border-bottom: none;
  background: var(--blue);
}
.dir-browser-item.is-parent .dir-browser-item-icon::before {
  background: var(--accent-light);
}
.dir-browser-item.is-parent .dir-browser-item-icon::after {
  background: var(--surface);
}
.dir-browser-item-name {
  font-family: var(--font-mono);
  font-size: 13px;
  font-weight: 700;
  line-height: 1.4;
  color: var(--text-primary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.dir-browser-item-note {
  font-size: 12px;
  line-height: 1.5;
  color: var(--text-secondary);
}
.dir-browser-item-arrow {
  flex-shrink: 0;
  font-size: 18px;
  line-height: 1;
  color: var(--text-muted);
  transition: transform 150ms ease, color 150ms ease;
}
.dir-browser-item:hover .dir-browser-item-arrow {
  color: var(--text-primary);
  transform: translateX(2px);
}
.dir-browser-empty,
.dir-browser-error {
  padding: 22px 16px;
  border: 2px dashed var(--line);
  border-radius: 0;
  background: var(--bg-secondary);
  color: var(--text-secondary);
  font-size: 13px;
  line-height: 1.65;
  text-align: center;
}
.dir-browser-error-back {
  margin-top: 12px;
  padding: 8px 12px;
  border: 2px solid var(--line);
  border-radius: 2px;
  background: var(--surface-strong);
  color: var(--text-primary);
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 2px 2px 0 var(--line);
  transition: transform 150ms ease, box-shadow 150ms ease, background 150ms ease;
}
.dir-browser-error-back:hover {
  background: var(--yellow);
  transform: translate(1px, 1px);
  box-shadow: 1px 1px 0 var(--line);
}
.dir-browser-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-top: 10px;
}
.dir-browser-toggle {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  line-height: 1.5;
  color: var(--text-secondary);
  cursor: pointer;
}
.dir-browser-toggle input {
  width: 16px;
  height: 16px;
  accent-color: var(--blue-strong);
}
.dir-browser-selection-hint {
  max-width: 320px;
  padding: 6px 10px;
  border: 1px solid var(--line);
  border-radius: 2px;
  background: var(--surface-strong);
  font-family: var(--font-mono);
  font-size: 11px;
  line-height: 1.5;
  color: var(--text-muted);
}
.project-picker-item:focus-visible,
.project-picker-action-btn:focus-visible,
.dir-browser-item:focus-visible,
.dir-browser-edit-btn:focus-visible,
.dir-browser-go-btn:focus-visible,
.dir-browser-crumb:focus-visible,
.dir-browser-error-back:focus-visible {
  outline: 3px solid var(--blue-strong);
  outline-offset: 2px;
}

@media (max-width: 728px) {
  .modal-panel-project {
    max-width: none;
  }
  .project-picker-head {
    align-items: flex-start;
    flex-direction: column;
  }
  .project-picker-actions {
    grid-template-columns: 1fr;
  }
  .dir-browser-manual {
    flex-direction: column;
  }
  .dir-browser-manual .modal-text-input,
  .dir-browser-go-btn {
    width: 100%;
  }
  .dir-browser-list {
    min-height: 240px;
    max-height: 44vh;
  }
  .dir-browser-toolbar {
    align-items: flex-start;
    flex-direction: column;
  }
  .dir-browser-selection-hint {
    max-width: none;
    width: 100%;
  }
}

@media (max-width: 480px) {
  .modal-body-project {
    gap: 16px;
  }
  .project-picker-item {
    padding: 14px 42px 14px 14px;
  }
  .project-picker-item-name,
  .dir-browser-current-name {
    font-size: 14px;
  }
  .dir-browser-pathbar {
    padding: 8px;
  }
}

/* === Import Session List === */
.import-group {
  margin-bottom: 20px;
}
.import-group:last-child { margin-bottom: 0; }
.import-group-title {
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--text-muted);
  padding: 4px 0 8px;
  border-bottom: 2px solid var(--line);
  margin-bottom: 8px;
  word-break: break-all;
}
.import-group-title-toggle {
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  user-select: none;
}
.import-group-title-toggle:hover {
  color: var(--text-primary);
}
.import-group-arrow {
  font-size: 10px;
  flex-shrink: 0;
  transition: none;
}
.import-group-sessions {
  overflow: hidden;
}
.import-group-collapsed .import-group-sessions {
  display: none;
}
.import-group-collapsed .import-group-title {
  margin-bottom: 0;
  border-bottom-color: var(--bg-tertiary);
}
.import-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 4px;
  border-bottom: 2px solid var(--bg-tertiary);
}
.import-item:last-child { border-bottom: none; }
.import-item-info {
  flex: 1;
  min-width: 0;
}
.import-item-title {
  font-size: 14px;
  color: var(--text-primary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  margin-bottom: 2px;
}
.import-item-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 6px;
}
.import-item-tag {
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  color: var(--blue-strong);
  background: var(--accent-light);
  border: 2px solid var(--line);
  border-radius: 2px;
  padding: 2px 7px;
}
.import-item-meta {
  font-size: 12px;
  color: var(--text-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.import-item-btn {
  --nb-btn-bg: var(--blue);

  flex-shrink: 0;
  padding: 6px 14px;
  font-size: 12px;
}
.import-item-btn:hover {
  /* keep explicit block for readability with shared button base */
}

/* === Sidebar Resizer === */
.sidebar-resizer {
  width: 4px;
  cursor: col-resize;
  background: transparent;
  flex-shrink: 0;
  transition: background 120ms;
}
.sidebar-resizer:hover {
  background: var(--line);
}

/* === Workspace Insights === */
.workspace-insights {
  display: none;
  width: 320px;
  border-left: 2px solid var(--line);
  background: var(--surface);
  flex-shrink: 0;
  overflow: hidden;
}
.workspace-insights.visible {
  display: flex;
  flex-direction: column;
}
.workspace-insights-scroll {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
}
.workspace-insights-content {
  font-size: 14px;
  color: var(--text-secondary);
  line-height: 1.6;
}

/* === Workspace Insights Components === */
.insights-shell {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.insights-hero {
  padding: 16px;
  border: 2px solid var(--line);
  border-radius: 0;
  background: var(--surface-strong);
  box-shadow: 3px 3px 0 var(--line);
}

.insights-hero-stats {
  display: flex;
  gap: 0;
}

.insights-hero-stat {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 8px;
  border-right: 2px solid var(--line);
}

.insights-hero-stat:last-child {
  border-right: none;
}

.insights-hero-stat span {
  font-size: 11px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.insights-hero-stat strong {
  font-family: var(--font-mono);
  font-size: 16px;
  font-weight: 700;
  color: var(--text-primary);
}

.insights-card {
  padding: 14px 16px;
  border: 2px solid var(--line);
  border-radius: 0;
  background: var(--surface-strong);
  box-shadow: 3px 3px 0 var(--line);
}

.insights-card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 12px;
}

.insights-card-header h3 {
  margin: 0;
  font-family: var(--font-mono);
  font-size: 14px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-primary);
}

.insights-card-kicker {
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 4px;
}

.insights-status-pill {
  padding: 3px 10px;
  border: 2px solid var(--line);
  border-radius: 2px;
  background: var(--bg-tertiary);
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-secondary);
  flex-shrink: 0;
}

.insights-status-pill.running {
  background: var(--yellow);
  color: var(--text-primary);
}

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

.insights-detail-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  font-size: 12px;
}

.insights-detail-item span {
  color: var(--text-muted);
}

.insights-detail-item strong {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-primary);
}

.insights-note {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px dashed var(--line);
  font-size: 12px;
  color: var(--text-muted);
}

.insights-shell .workspace-action-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.insights-shell .workspace-action-btn {
  flex: 1;
  min-width: 100px;
  padding: 8px 12px;
  border: 2px solid var(--line);
  border-radius: 2px;
  background: var(--bg-secondary);
  color: var(--text-primary);
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  cursor: pointer;
  transition: transform 120ms, box-shadow 120ms, background 120ms;
  box-shadow: 2px 2px 0 var(--line);
}

.insights-shell .workspace-action-btn:hover {
  background: var(--blue);
  transform: translate(1px, 1px);
  box-shadow: 1px 1px 0 var(--line);
}

.insights-shell .workspace-action-btn.primary {
  background: var(--blue);
}

.insights-shell .workspace-action-btn.primary:hover {
  background: var(--yellow);
}

#tunnel-copy-btn {
  --nb-btn-bg: var(--bg-secondary);
  border-left: 2px solid var(--line) !important;
  border-top: none !important;
  border-right: none !important;
  border-bottom: none !important;
  border-radius: 0;
  padding: 6px 12px;
}
