:root {
  --bg-main: #07090e;
  --bg-sidebar: #0b0f19;
  --bg-card: rgba(255, 255, 255, 0.035);
  --bg-card-hover: rgba(255, 255, 255, 0.06);
  --bg-input: rgba(16, 23, 38, 0.85);
  --border: rgba(255, 255, 255, 0.08);
  --border-subtle: rgba(255, 255, 255, 0.05);
  --border-focus: #38bdf8;
  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --text-dim: #64748b;
  --accent: #0284c7;
  --accent-cyan: #38bdf8;
  --accent-glow: rgba(56, 189, 248, 0.25);
  --user-bubble: #172235;
  --assistant-bubble: #0d1422;
  --danger: #ef4444;
  --success: #10b981;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Inter", Helvetica, Arial, sans-serif;
  letter-spacing: -0.015em;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.12) transparent;
}

/* Minimalist Dark Scrollbars (Taste Skill) */
::-webkit-scrollbar {
  width: 5px;
  height: 5px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.12);
  border-radius: 999px;
}
::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.25);
}

html, body {
  background-color: var(--bg-main);
  color: var(--text-main);
  height: 100%;
  height: 100dvh;
  width: 100%;
  max-width: 100vw;
  overflow: hidden;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
}

.app-container {
  display: flex;
  height: 100%;
  height: 100dvh;
  width: 100vw;
  max-width: 100vw;
  overflow: hidden;
  position: relative;
}

/* SIDEBAR */
.sidebar {
  width: 280px;
  max-width: 85vw;
  background-color: var(--bg-sidebar);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  transition: margin-left 0.22s cubic-bezier(0.16, 1, 0.3, 1), transform 0.22s cubic-bezier(0.16, 1, 0.3, 1);
  z-index: 100;
  height: 100%;
  flex-shrink: 0;
}

/* Collapsible state on desktop */
.sidebar.collapsed {
  margin-left: -280px;
}

.sidebar-header {
  padding: 14px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border-subtle);
}

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

.brand-icon {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  background: linear-gradient(135deg, #0284c7, #38bdf8);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  box-shadow: 0 2px 14px rgba(56, 189, 248, 0.35), inset 0 1px 0 rgba(255, 255, 255, 0.3);
}

.brand-title {
  font-size: 14px;
  font-weight: 700;
  color: #fff;
  letter-spacing: -0.025em;
}

.brand-subtitle {
  font-size: 10px;
  color: var(--accent-cyan);
  display: block;
  font-weight: 500;
  letter-spacing: 0.2px;
}

/* 9ROUTER PANEL */
.router-panel {
  background: var(--bg-card);
  margin: 12px;
  padding: 12px;
  border-radius: 12px;
  border: 1px solid var(--border);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.05);
}

.router-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}

.router-title {
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.8px;
  color: var(--text-dim);
}

.status-indicator {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 999px;
  background: rgba(16, 185, 129, 0.12);
  color: var(--success);
  border: 1px solid rgba(16, 185, 129, 0.25);
  font-weight: 500;
}

.status-indicator.offline {
  background: rgba(239, 68, 68, 0.12);
  color: var(--danger);
  border-color: rgba(239, 68, 68, 0.25);
}

.status-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
}

.form-group label {
  display: block;
  font-size: 11px;
  color: #cbd5e1;
  margin-bottom: 4px;
}

.custom-select {
  width: 100%;
  background: var(--bg-input);
  border: 1px solid var(--border);
  color: var(--text-main);
  padding: 7px 8px;
  border-radius: 8px;
  font-size: 12px;
  outline: none;
  cursor: pointer;
}

.router-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 8px;
  font-size: 11px;
  color: var(--text-muted);
}

.btn-link {
  background: none;
  border: none;
  color: var(--accent-cyan);
  cursor: pointer;
  font-size: 11px;
}

/* SESSIONS */
.sessions-section {
  flex: 1;
  overflow-y: auto;
  padding: 0 12px;
}

.section-label {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.5px;
  color: #64748b;
  margin: 10px 4px 6px 4px;
}

.sessions-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.session-item {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  border-radius: 10px;
  cursor: pointer;
  color: var(--text-muted);
  font-size: 13px;
  transition: all 0.16s cubic-bezier(0.16, 1, 0.3, 1);
  background: transparent;
  border: 1px solid transparent;
}

.session-item:hover {
  background: var(--bg-card-hover);
  color: #fff;
}

.session-item.active {
  background: rgba(56, 189, 248, 0.08);
  border-color: rgba(56, 189, 248, 0.22);
  color: #fff;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.05);
}

.session-item.active::before {
  content: "";
  position: absolute;
  left: 0;
  top: 8px;
  bottom: 8px;
  width: 3px;
  background: var(--accent-cyan);
  border-radius: 0 3px 3px 0;
  box-shadow: 0 0 8px var(--accent-cyan);
}

.session-info {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  flex: 1;
  padding-right: 6px;
}

.session-title {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-main);
}

.session-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 10.5px;
  color: var(--text-dim);
  margin-top: 2px;
}

.session-del {
  background: none;
  border: none;
  color: var(--text-dim);
  cursor: pointer;
  padding: 5px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0.6;
  transition: all 0.15s;
}

.session-del:hover {
  opacity: 1;
  color: var(--danger);
  background: rgba(239, 68, 68, 0.15);
}

/* Badge count on mobile sidebar toggle */
.sessions-badge {
  position: absolute;
  top: -4px;
  right: -4px;
  background: #0284c7;
  color: #fff;
  font-size: 9.5px;
  font-weight: 700;
  border-radius: 10px;
  padding: 1px 5px;
  min-width: 15px;
  line-height: 14px;
  text-align: center;
  box-shadow: 0 2px 5px rgba(0,0,0,0.4);
}

/* Header Action Buttons */
.btn-action-primary {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: linear-gradient(135deg, #0284c7, #0369a1);
  color: #fff;
  border: 1px solid rgba(56, 189, 248, 0.35);
  padding: 6px 13px;
  border-radius: 9px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.16s cubic-bezier(0.16, 1, 0.3, 1);
  white-space: nowrap;
  box-shadow: 0 2px 8px rgba(2, 132, 199, 0.25), inset 0 1px 0 rgba(255, 255, 255, 0.2);
}

.btn-action-primary:hover {
  background: linear-gradient(135deg, #0369a1, #075985);
  box-shadow: 0 3px 12px rgba(2, 132, 199, 0.4);
}

.btn-action-primary:active {
  transform: scale(0.97);
}

.btn-action-danger {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: rgba(239, 68, 68, 0.08);
  color: #ef4444;
  border: 1px solid rgba(239, 68, 68, 0.2);
  padding: 6px 9px;
  border-radius: 9px;
  font-size: 12px;
  cursor: pointer;
  transition: all 0.16s cubic-bezier(0.16, 1, 0.3, 1);
}

.btn-action-danger:hover {
  background: rgba(239, 68, 68, 0.16);
  color: #f87171;
  border-color: rgba(239, 68, 68, 0.35);
}

.btn-action-danger:active {
  transform: scale(0.97);
}

/* Toast notice popup */
.toast-notice {
  position: fixed;
  bottom: 85px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: #0f172a;
  color: #38bdf8;
  border: 1px solid #0284c7;
  padding: 10px 18px;
  border-radius: 20px;
  font-size: 12.5px;
  font-weight: 500;
  box-shadow: 0 10px 25px rgba(0,0,0,0.6);
  z-index: 9999;
  opacity: 0;
  pointer-events: none;
  transition: all 0.25s ease;
  max-width: 90vw;
  text-align: center;
}

.toast-notice.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.sidebar-bottom {
  padding: 12px;
  border-top: 1px solid var(--border);
}

/* CHAT MAIN */
.chat-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  height: 100%;
  height: 100dvh;
  position: relative;
  background: var(--bg-main);
  min-width: 0;
  max-width: 100vw;
  overflow: hidden;
}

/* CHAT HEADER */
.chat-header {
  height: 52px;
  border-bottom: 1px solid var(--border);
  padding: 0 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: #090d16;
  gap: 8px;
  flex-shrink: 0;
  position: sticky;
  top: 0;
  z-index: 50;
}

.chat-header-left {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  flex: 1;
}

.chat-title-group {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
  overflow: hidden;
}

.chat-title {
  font-size: 14px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.model-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  color: var(--accent-cyan);
  background: rgba(56, 189, 248, 0.1);
  border: 1px solid rgba(56, 189, 248, 0.25);
  padding: 2px 7px;
  border-radius: 6px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 150px;
}

/* WORKING / GENERATING STATUS INDICATORS */
.working-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: rgba(16, 185, 129, 0.12);
  border: 1px solid rgba(52, 211, 153, 0.35);
  color: #34d399;
  padding: 2px 8px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
  animation: pulseGlow 2s infinite ease-in-out;
}

@keyframes pulseGlow {
  0%, 100% { box-shadow: 0 0 6px rgba(52, 211, 153, 0.2); }
  50% { box-shadow: 0 0 14px rgba(52, 211, 153, 0.45); border-color: rgba(52, 211, 153, 0.6); }
}

.working-pulse-dot {
  width: 6px;
  height: 6px;
  background: #10b981;
  border-radius: 50%;
  animation: pulse 1s infinite alternate;
}

.working-spinner {
  display: inline-block;
  animation: rotateSpin 1.8s linear infinite;
  transform-origin: center;
  font-size: 11px;
}

@keyframes rotateSpin {
  0% { transform: rotate(0deg) scale(0.9); }
  50% { transform: rotate(180deg) scale(1.15); }
  100% { transform: rotate(360deg) scale(0.9); }
}

.btn-stop-working {
  background: rgba(239, 68, 68, 0.2);
  border: 1px solid rgba(239, 68, 68, 0.4);
  color: #f87171;
  border-radius: 6px;
  font-size: 10px;
  font-weight: 700;
  padding: 1px 6px;
  cursor: pointer;
  margin-left: 3px;
  display: inline-flex;
  align-items: center;
  gap: 3px;
  transition: all 0.15s;
}

.btn-stop-working:hover {
  background: rgba(239, 68, 68, 0.4);
  color: #fff;
}

/* Sidebar Working Badge on Session Item */
.session-working-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  color: #38bdf8;
  font-size: 10px;
  font-weight: 600;
  background: rgba(56, 189, 248, 0.12);
  border: 1px solid rgba(56, 189, 248, 0.3);
  padding: 1px 6px;
  border-radius: 10px;
  animation: pulseGlowCyan 1.5s infinite alternate;
}

@keyframes pulseGlowCyan {
  0% { box-shadow: 0 0 4px rgba(56, 189, 248, 0.2); }
  100% { box-shadow: 0 0 10px rgba(56, 189, 248, 0.5); }
}

/* TABS: Chat vs 9Router vs n8n (Taste Skill Segmented Control) */
.header-tabs {
  display: flex;
  align-items: center;
  background: rgba(255, 255, 255, 0.04);
  padding: 3px;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.06);
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.4);
}

.tab-btn {
  background: transparent;
  border: 1px solid transparent;
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 500;
  padding: 5px 12px;
  border-radius: 7px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
  transition: all 0.16s cubic-bezier(0.16, 1, 0.3, 1);
  letter-spacing: -0.01em;
}

.tab-btn:hover {
  color: var(--text-main);
  background: rgba(255, 255, 255, 0.035);
}

.tab-btn:active {
  transform: scale(0.97);
}

.tab-btn.active {
  background: rgba(255, 255, 255, 0.09);
  border-color: rgba(255, 255, 255, 0.12);
  color: #fff;
  font-weight: 600;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.35), inset 0 1px 0 rgba(255, 255, 255, 0.15);
}

.chat-header-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.btn-secondary {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text-muted);
  font-size: 12px;
  padding: 6px 10px;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s;
  flex-shrink: 0;
}

.btn-secondary:hover {
  color: #fff;
}

/* CHAT BODY */
.chat-body {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 16px 14px 10px 14px;
  display: flex;
  flex-direction: column;
}

.empty-state {
  margin: auto;
  text-align: center;
  max-width: 480px;
  padding: 32px 16px;
}

.empty-icon {
  width: 58px;
  height: 58px;
  margin: 0 auto 16px auto;
  border-radius: 18px;
  background: rgba(56, 189, 248, 0.08);
  border: 1px solid rgba(56, 189, 248, 0.22);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 0 30px rgba(56, 189, 248, 0.12), inset 0 1px 0 rgba(255, 255, 255, 0.15);
}

.empty-state h2 {
  font-size: 21px;
  font-weight: 600;
  letter-spacing: -0.025em;
  margin-bottom: 8px;
  color: #fff;
}

.empty-state p {
  font-size: 13.5px;
  color: var(--text-muted);
  line-height: 1.6;
  margin-bottom: 24px;
}

.prompt-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
}

.chip {
  background: rgba(255, 255, 255, 0.035);
  border: 1px solid rgba(255, 255, 255, 0.08);
  color: #94a3b8;
  font-size: 12.5px;
  font-weight: 500;
  padding: 7px 15px;
  border-radius: 999px;
  cursor: pointer;
  transition: all 0.16s cubic-bezier(0.16, 1, 0.3, 1);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
}

.chip:hover {
  background: rgba(56, 189, 248, 0.08);
  border-color: rgba(56, 189, 248, 0.35);
  color: #f8fafc;
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(56, 189, 248, 0.15);
}

.chip:active {
  transform: scale(0.97);
}

/* MESSAGES */
.messages-container {
  display: flex;
  flex-direction: column;
  gap: 16px;
  max-width: 820px;
  width: 100%;
  margin: 0 auto;
}

.message-row {
  display: flex;
  gap: 10px;
  width: 100%;
}

.message-row.user {
  flex-direction: row-reverse;
}

.msg-avatar {
  width: 32px;
  height: 32px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  flex-shrink: 0;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.35);
}

.msg-avatar.ai {
  background: linear-gradient(135deg, #0284c7, #38bdf8);
  color: white;
  border: 1px solid rgba(56, 189, 248, 0.35);
}

.msg-avatar.user {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: #f1f5f9;
}

.msg-content-wrapper {
  max-width: 84%;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.message-bubble {
  padding: 12px 16px;
  border-radius: 14px;
  font-size: 14px;
  line-height: 1.6;
  letter-spacing: -0.01em;
  word-break: break-word;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.25);
}

/* MESSAGE META BAR & 1-CLICK COPY (Taste Skill) */
.msg-meta-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 3px;
  user-select: none;
}

.message-row.user .msg-meta-bar {
  align-self: flex-end;
  justify-content: flex-end;
  margin-right: 4px;
}

.message-row.ai .msg-meta-bar {
  align-self: flex-start;
  justify-content: flex-start;
  margin-left: 4px;
}

.msg-time {
  font-size: 10.5px;
  color: var(--text-dim);
  font-weight: 500;
  letter-spacing: 0.02em;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  opacity: 0.85;
  transition: opacity 0.15s;
}

.msg-time:hover {
  opacity: 1;
  color: var(--text-muted);
}

.btn-copy-msg {
  background: transparent;
  border: 1px solid transparent;
  color: var(--text-dim);
  font-size: 10.5px;
  font-weight: 500;
  padding: 2px 7px;
  border-radius: 6px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  opacity: 0.75;
  transition: all 0.16s ease;
}

.btn-copy-msg:hover {
  opacity: 1;
  color: var(--text-main);
  background: rgba(255, 255, 255, 0.06);
  border-color: rgba(255, 255, 255, 0.1);
}

.btn-copy-msg:active {
  transform: scale(0.96);
}

.btn-copy-msg.copied {
  color: #34d399 !important;
  border-color: rgba(52, 211, 153, 0.35) !important;
  background: rgba(16, 185, 129, 0.12) !important;
  opacity: 1 !important;
}

/* Tool execution pill */
.tool-call-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: rgba(0, 0, 0, 0.4);
  border: 1px solid rgba(255, 255, 255, 0.08);
  padding: 5px 12px;
  border-radius: 8px;
  font-size: 11.5px;
  margin-bottom: 8px;
  color: #94a3b8;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.03);
}

.tool-call-pill.executing {
  border-color: rgba(56, 189, 248, 0.5);
  color: #38bdf8;
  animation: pulse 1.5s infinite alternate;
}

.tool-call-pill.completed {
  border-color: rgba(16, 185, 129, 0.4);
  color: #34d399;
}

.tool-call-pill code {
  color: #fff;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
}

.tool-call-pill .arg-preview {
  color: #64748b;
  font-size: 11px;
}

.message-row.user .message-bubble {
  background: #141c2e;
  border: 1px solid rgba(56, 189, 248, 0.22);
  color: #f8fafc;
  border-bottom-right-radius: 4px;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.3), inset 0 1px 0 rgba(255, 255, 255, 0.06);
}

.message-row.ai .message-bubble {
  background: #0b0f19;
  border: 1px solid rgba(255, 255, 255, 0.07);
  color: #e2e8f0;
  border-bottom-left-radius: 4px;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.25), inset 0 1px 0 rgba(255, 255, 255, 0.04);
}

/* MARKDOWN PROSE & CODE BLOCKS (Taste Skill Precision) */
.message-bubble h1, .message-bubble h2, .message-bubble h3, .message-bubble h4 {
  color: #fff;
  font-weight: 600;
  letter-spacing: -0.02em;
  margin: 12px 0 6px 0;
}

.message-bubble h1 { font-size: 17px; }
.message-bubble h2 { font-size: 15.5px; }
.message-bubble h3 { font-size: 14.5px; }

.message-bubble p {
  margin: 6px 0;
}

.message-bubble p:first-child { margin-top: 0; }
.message-bubble p:last-child { margin-bottom: 0; }

.message-bubble ul, .message-bubble ol {
  padding-left: 20px;
  margin: 6px 0;
}

.message-bubble li {
  margin: 3px 0;
}

.message-bubble hr {
  border: none;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  margin: 12px 0;
}

.message-bubble blockquote {
  margin: 8px 0;
  padding: 8px 12px;
  background: rgba(56, 189, 248, 0.04);
  border-left: 3px solid #38bdf8;
  border-radius: 0 8px 8px 0;
  color: #cbd5e1;
  font-style: italic;
}

.message-bubble table {
  width: 100%;
  border-collapse: collapse;
  margin: 10px 0;
  font-size: 12.5px;
  overflow-x: auto;
  display: block;
}

.message-bubble th, .message-bubble td {
  border: 1px solid rgba(255, 255, 255, 0.08);
  padding: 6px 10px;
  text-align: left;
}

.message-bubble th {
  background: rgba(255, 255, 255, 0.04);
  font-weight: 600;
  color: #f1f5f9;
}

.message-bubble tr:nth-child(even) td {
  background: rgba(255, 255, 255, 0.02);
}

.message-bubble code:not(pre code) {
  background: rgba(255, 255, 255, 0.07);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: #38bdf8;
  padding: 2px 5px;
  border-radius: 5px;
  font-size: 12px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
}

/* CODE BLOCK CONTAINERS */
.code-block-wrapper {
  margin: 10px 0;
  border-radius: 10px;
  background: #050810;
  border: 1px solid rgba(255, 255, 255, 0.08);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4);
  overflow: hidden;
}

.code-block-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: rgba(255, 255, 255, 0.03);
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  padding: 5px 10px;
  font-size: 11px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  color: #64748b;
}

.code-block-lang {
  text-transform: uppercase;
  font-weight: 600;
  letter-spacing: 0.5px;
  color: #94a3b8;
}

.btn-copy-code {
  background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: #94a3b8;
  border-radius: 6px;
  padding: 3px 8px;
  font-size: 11px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  transition: all 0.16s cubic-bezier(0.16, 1, 0.3, 1);
}

.btn-copy-code:hover {
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
  border-color: rgba(56, 189, 248, 0.4);
}

.btn-copy-code:active {
  transform: scale(0.95);
}

.btn-copy-code.copied {
  color: #34d399;
  border-color: rgba(52, 211, 153, 0.4);
  background: rgba(16, 185, 129, 0.1);
}

.message-bubble pre {
  margin: 0;
  background: transparent;
  overflow-x: auto;
  max-width: 100%;
}

.message-bubble pre code {
  display: block;
  padding: 10px 12px;
  overflow-x: auto;
  font-size: 12.5px;
  line-height: 1.5;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  color: #e2e8f0;
}

/* TYPING & STREAMING INDICATOR (Taste Skill Skeletal Dots) */
.typing-indicator {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--text-muted);
  font-size: 13px;
  padding: 2px 0;
}

.typing-dots {
  display: inline-flex;
  gap: 4px;
  align-items: center;
}

.typing-dots span {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--accent-cyan);
  box-shadow: 0 0 6px var(--accent-cyan);
  animation: typingBounce 1.4s infinite ease-in-out both;
}

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

@keyframes typingBounce {
  0%, 80%, 100% { transform: scale(0.5); opacity: 0.35; }
  40% { transform: scale(1.15); opacity: 1; }
}

.chat-image {
  max-width: 100%;
  max-height: 300px;
  border-radius: 8px;
  cursor: pointer;
  display: block;
}

.chat-video {
  max-width: 100%;
  max-height: 260px;
  border-radius: 8px;
  display: block;
}

.voice-note-player {
  display: flex;
  align-items: center;
  gap: 10px;
  background: #0f172a;
  padding: 8px 12px;
  border-radius: 10px;
  border: 1px solid #334155;
  min-width: 200px;
  max-width: 100%;
}

.btn-play-voice {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.voice-info {
  flex: 1;
  min-width: 0;
}

.voice-waveform-bar {
  height: 5px;
  background: #334155;
  border-radius: 3px;
  overflow: hidden;
  margin-bottom: 4px;
}

.voice-progress {
  height: 100%;
  width: 0%;
  background: var(--accent-cyan);
}

.voice-duration {
  font-size: 11px;
  color: var(--text-muted);
}

/* ATTACHMENT TRAY (Gemini Style) */
.attachment-tray {
  background: transparent;
  padding: 4px 4px 10px 4px;
  width: 100%;
  max-width: 820px;
  margin: 0 auto;
}

.tray-content {
  display: flex;
  gap: 10px;
  overflow-x: auto;
  padding: 2px 4px;
}

.tray-item {
  position: relative;
  width: 68px;
  height: 68px;
  border-radius: 12px;
  border: 1.5px solid #38bdf8;
  overflow: hidden;
  background: #1e293b;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.45);
  animation: trayPopIn 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

@keyframes trayPopIn {
  from { transform: scale(0.7); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

.tray-item img, .tray-item video {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.tray-item-remove {
  position: absolute;
  top: 3px;
  right: 3px;
  background: rgba(15, 23, 42, 0.85);
  color: #f1f5f9;
  border: 1px solid rgba(255, 255, 255, 0.2);
  width: 20px;
  height: 20px;
  border-radius: 50%;
  font-size: 11px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.15s;
}

.tray-item-remove:hover {
  background: #ef4444;
  color: #fff;
  border-color: #ef4444;
}

/* VOICE RECORDING BAR & REALTIME WAVEFORM (Taste Skill) */
.voice-bar {
  background: rgba(14, 21, 37, 0.95);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-top: 1px solid rgba(56, 189, 248, 0.35);
  padding: 8px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-shrink: 0;
  box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.45);
}

.voice-status {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.recording-pulse {
  width: 10px;
  height: 10px;
  background: #ef4444;
  border-radius: 50%;
  box-shadow: 0 0 10px rgba(239, 68, 68, 0.8);
  animation: pulse 1s infinite alternate;
}

.voice-timer {
  font-weight: 700;
  font-size: 13.5px;
  color: #fff;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.02em;
}

.voice-canvas {
  flex: 1;
  height: 38px;
  min-width: 60px;
  max-width: 500px;
  background: rgba(8, 12, 22, 0.85);
  border: 1px solid rgba(56, 189, 248, 0.25);
  border-radius: 8px;
  box-shadow: inset 0 2px 6px rgba(0, 0, 0, 0.5);
  display: block;
}

.voice-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.btn-cancel-voice, .btn-send-voice {
  border: none;
  padding: 7px 12px;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  transition: all 0.16s cubic-bezier(0.16, 1, 0.3, 1);
  min-height: 36px;
}

.btn-cancel-voice {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: #cbd5e1;
}

.btn-cancel-voice:hover {
  background: rgba(239, 68, 68, 0.18);
  color: #f87171;
  border-color: rgba(239, 68, 68, 0.35);
}

.btn-send-voice {
  background: linear-gradient(135deg, #0284c7, #0369a1);
  border: 1px solid rgba(56, 189, 248, 0.4);
  color: white;
  box-shadow: 0 2px 8px rgba(2, 132, 199, 0.3);
}

.btn-send-voice:hover {
  background: linear-gradient(135deg, #0369a1, #075985);
}

.btn-cancel-voice:active, .btn-send-voice:active {
  transform: scale(0.96);
}

/* CHAT INPUT DOCK (Taste Skill Floating Capsule) */
.chat-input-dock {
  padding: 10px 14px 14px 14px;
  background: transparent;
  flex-shrink: 0;
  width: 100%;
}

.input-bar {
  max-width: 820px;
  margin: 0 auto;
  background: rgba(14, 19, 31, 0.88);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 28px;
  display: flex;
  align-items: flex-end;
  padding: 6px 10px;
  gap: 4px;
  width: 100%;
  box-sizing: border-box;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.45), inset 0 1px 0 rgba(255, 255, 255, 0.08);
  transition: border-color 0.2s cubic-bezier(0.16, 1, 0.3, 1), box-shadow 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

.input-bar:focus-within {
  border-color: rgba(56, 189, 248, 0.4);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5), 0 0 0 1px rgba(56, 189, 248, 0.25), inset 0 1px 0 rgba(255, 255, 255, 0.1);
}

.chat-textarea {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  color: var(--text-main);
  font-size: 14px;
  line-height: 1.5;
  letter-spacing: -0.01em;
  resize: none;
  max-height: 140px;
  padding: 8px 8px;
  min-width: 0;
}

.btn-icon {
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 7px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: all 0.16s cubic-bezier(0.16, 1, 0.3, 1);
}

.btn-icon:hover {
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
}

.btn-icon:active {
  transform: scale(0.92);
}

.btn-send {
  background: linear-gradient(135deg, #0284c7, #38bdf8);
  color: white;
  border: 1px solid rgba(56, 189, 248, 0.4);
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  box-shadow: 0 2px 10px rgba(2, 132, 199, 0.35), inset 0 1px 0 rgba(255, 255, 255, 0.25);
  transition: all 0.16s cubic-bezier(0.16, 1, 0.3, 1);
}

.btn-send:hover {
  background: linear-gradient(135deg, #0369a1, #0284c7);
  box-shadow: 0 4px 14px rgba(2, 132, 199, 0.5);
  transform: translateY(-1px);
}

.btn-send:active {
  transform: scale(0.92);
}

/* IFRAME VIEWS (9ROUTER & n8n) */
.router-view-container {
  display: none;
  width: 100%;
  height: calc(100% - 52px);
  position: relative;
  background: #000;
  flex-direction: column;
  flex: 1;
}

.router-view-container.active {
  display: flex;
}

.iframe-toolbar {
  height: 38px;
  background: #090d16;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 12px;
  flex-shrink: 0;
}

.iframe-toolbar-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  font-weight: 600;
  color: #e2e8f0;
}

.toolbar-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
}

.iframe-toolbar-actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
}

.btn-toolbar {
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: #94a3b8;
  padding: 4px 10px;
  border-radius: 6px;
  font-size: 11px;
  cursor: pointer;
  transition: all 0.15s;
}

.btn-toolbar:hover {
  background: #1e293b;
  color: #fff;
  border-color: #38bdf8;
}

.router-iframe {
  flex: 1;
  width: 100%;
  height: 100%;
  border: none;
}

/* BACKDROP OVERLAY FOR SIDEBAR ON MOBILE */
.sidebar-overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(0, 0, 0, 0.6);
  z-index: 90;
}

.sidebar-overlay.active {
  display: block;
}

/* MOBILE RESPONSIVE FIXES */
.mobile-only {
  display: none;
}

@media (max-width: 768px) {
  .sidebar {
    position: fixed;
    top: 0;
    left: -320px;
    height: 100dvh;
    height: 100%;
    box-shadow: 4px 0 20px rgba(0, 0, 0, 0.5);
    margin-left: 0 !important;
  }
  .sidebar.open {
    transform: translateX(320px);
  }
  .mobile-only {
    display: flex;
  }
  
  .chat-header {
    height: 50px;
    padding: 0 8px;
    position: sticky;
    top: 0;
    z-index: 50;
    background: #090d16;
  }
  
  .chat-title-group {
    cursor: pointer;
  }

  .chat-title {
    display: block !important; /* Show session title on mobile! */
    font-size: 13px;
    font-weight: 600;
    max-width: 105px;
    color: #fff;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  
  .model-badge {
    display: none !important; /* Hide model badge on mobile to give room for session title & tabs */
  }

  .header-tabs {
    gap: 2px;
  }

  .tab-btn {
    padding: 4px 6px;
    font-size: 11px;
  }
  
  .btn-action-primary {
    padding: 4px 8px;
    font-size: 11px;
    gap: 3px;
  }

  .btn-action-primary span {
    font-size: 11px;
  }
  
  .btn-action-danger {
    padding: 4px 6px;
  }

  .chat-body {
    padding: 10px 8px 8px 8px;
  }
  
  .message-bubble {
    font-size: 13.5px;
  }
  
  .msg-content-wrapper {
    max-width: 88%;
  }

  .chat-input-dock {
    padding: 6px 8px 8px 8px;
  }
  
  .input-bar {
    padding: 5px 6px;
    gap: 3px;
  }
  
  .btn-icon {
    padding: 5px;
  }
  
  .voice-canvas {
    display: none; /* Hide waveform canvas on mobile screens to fit controls */
  }
}
