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

:root {
  --bg-deep:    #1a1a2e;
  --bg-mid:     #16213e;
  --bg-panel:   #0f3460;
  --bg-card:    #1e2a45;
  --bg-input:   #162040;
  --accent:     #e94560;
  --accent-2:   #533483;
  --accent-glow:#e94560aa;
  --text:       #e8eaf6;
  --text-dim:   #8892b0;
  --text-muted: #4a5568;
  --border:     #233554;
  --border-hl:  #e9456044;
  --user-bubble:#1a365d;
  --ai-bubble:  #162040;
  --success:    #48bb78;
  --warning:    #ed8936;
  --error:      #fc5c65;
  --radius:     12px;
  --radius-sm:  8px;
  --shadow:     0 4px 24px rgba(0,0,0,.4);
  --shadow-lg:  0 8px 40px rgba(0,0,0,.6);
  --font:       'Inter', 'Segoe UI', system-ui, sans-serif;
  --mono:       'JetBrains Mono', 'Fira Code', monospace;
  --transition: .2s ease;
}

[data-theme="light"] {
  --bg-deep:    #f0f4f8;
  --bg-mid:     #e2e8f0;
  --bg-panel:   #cbd5e0;
  --bg-card:    #ffffff;
  --bg-input:   #edf2f7;
  --accent:     #e94560;
  --accent-2:   #6b46c1;
  --text:       #1a202c;
  --text-dim:   #4a5568;
  --text-muted: #a0aec0;
  --border:     #bee3f8;
  --border-hl:  #e9456033;
  --user-bubble:#ebf8ff;
  --ai-bubble:  #f7fafc;
  --shadow:     0 4px 24px rgba(0,0,0,.08);
  --shadow-lg:  0 8px 40px rgba(0,0,0,.14);
}

/* ── Base ── */
html, body { height: 100%; }
body {
  font-family: var(--font);
  background: var(--bg-deep);
  color: var(--text);
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  transition: background var(--transition), color var(--transition);
}

/* ── Header ── */
header {
  background: var(--bg-mid);
  border-bottom: 1px solid var(--border);
  padding: 0 24px;
  height: 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
  box-shadow: var(--shadow);
  z-index: 10;
}

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

.brand-icon {
  width: 38px;
  height: 38px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  box-shadow: 0 0 16px var(--accent-glow);
}

.brand-text h1 {
  font-size: 15px;
  font-weight: 700;
  letter-spacing: .02em;
  line-height: 1.2;
}

.brand-text p {
  font-size: 11px;
  color: var(--text-dim);
  font-weight: 400;
}

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

/* Status pill */
.status-pill {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 5px 12px;
  border-radius: 20px;
  border: 1px solid var(--border);
  background: var(--bg-card);
  font-size: 12px;
  color: var(--text-dim);
  cursor: default;
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--text-muted);
  transition: background var(--transition);
}

.status-dot.connected { background: var(--success); box-shadow: 0 0 6px var(--success); }
.status-dot.error     { background: var(--error);   box-shadow: 0 0 6px var(--error);   }

/* Icon buttons */
.icon-btn {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--bg-card);
  color: var(--text-dim);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  transition: all var(--transition);
}

.icon-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--border-hl);
}

/* Language select */
.lang-select {
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--bg-card);
  color: var(--text);
  font-size: 12px;
  cursor: pointer;
  outline: none;
  transition: border-color var(--transition);
}

.lang-select:hover, .lang-select:focus { border-color: var(--accent); }

/* ── Main layout ── */
main {
  display: flex;
  flex: 1;
  overflow: hidden;
  gap: 0;
}

/* ── Panel toggle buttons ── */
.panel-toggle-btn {
  font-size: 15px;
  opacity: 0.45;
  transition: opacity var(--transition), color var(--transition), border-color var(--transition);
}

.panel-toggle-btn.active {
  opacity: 1;
  color: var(--accent);
  border-color: var(--accent);
}

/* ── Left panel ── */
.panel-left {
  width: 300px;
  min-width: 0;
  background: var(--bg-mid);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  flex-shrink: 0;
  transition: width 0.3s ease;
}

.panel-left.hidden {
  width: 0 !important;
  border: none !important;
}

.panel-left.no-transition,
.panel-workspace.no-transition {
  transition: none !important;
}

.panel-header {
  padding: 16px 18px 12px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 8px;
}

.panel-header h2 {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: .06em;
}

.panel-icon { font-size: 14px; }

.panel-body {
  flex: 1;
  overflow-y: auto;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

/* Step items */
.step-item {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px 12px;
  background: var(--bg-card);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  animation: slideIn .25s ease;
}

.step-icon {
  font-size: 14px;
  min-width: 20px;
  padding-top: 1px;
}

.step-content { flex: 1; min-width: 0; }

.step-title {
  font-size: 12px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 2px;
}

.step-desc {
  font-size: 11px;
  color: var(--text-dim);
  word-break: break-word;
}

.step-time {
  font-size: 10px;
  color: var(--text-muted);
  white-space: nowrap;
  padding-top: 2px;
}

/* Thinking indicator */
.thinking-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  background: var(--bg-card);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-hl);
}

.thinking-dots span {
  display: inline-block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent);
  animation: bounce 1.2s infinite;
}

.thinking-dots span:nth-child(2) { animation-delay: .2s; }
.thinking-dots span:nth-child(3) { animation-delay: .4s; }

@keyframes bounce {
  0%, 60%, 100% { transform: translateY(0); }
  30%           { transform: translateY(-5px); }
}

/* Token counter */
.token-bar {
  padding: 10px 14px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  font-size: 11px;
  color: var(--text-muted);
  background: var(--bg-deep);
  flex-shrink: 0;
}

/* ── Right panel (chat) ── */
.panel-right {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--bg-deep);
}

.chat-header {
  padding: 14px 20px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-mid);
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.chat-header h2 {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: .06em;
}

.msg-count {
  margin-left: auto;
  background: var(--bg-panel);
  color: var(--text-dim);
  border-radius: 10px;
  padding: 2px 8px;
  font-size: 11px;
}

/* Messages */
.messages {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.message {
  display: flex;
  gap: 12px;
  animation: fadeUp .3s ease;
  max-width: 100%;
}

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

.avatar {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 15px;
  flex-shrink: 0;
  align-self: flex-end;
}

.message.user .avatar {
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
}

.message.assistant .avatar {
  background: linear-gradient(135deg, var(--accent-2), var(--bg-panel));
  box-shadow: 0 0 10px rgba(83,52,131,.5);
}

.bubble {
  max-width: min(640px, 80%);
  padding: 12px 16px;
  border-radius: var(--radius);
  line-height: 1.65;
  font-size: 14px;
  position: relative;
  word-wrap: break-word;
}

.message.user .bubble {
  background: var(--user-bubble);
  border: 1px solid var(--border-hl);
  border-bottom-right-radius: 4px;
}

.message.assistant .bubble {
  background: var(--ai-bubble);
  border: 1px solid var(--border);
  border-bottom-left-radius: 4px;
}

.bubble-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 6px;
}

.bubble-role {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--accent);
}

.message.user .bubble-role { color: var(--text-dim); }

.bubble-time {
  font-size: 10px;
  color: var(--text-muted);
}

.bubble-text { color: var(--text); }

/* Markdown-ish styles inside bubble */
.bubble-text code {
  font-family: var(--mono);
  font-size: 12px;
  background: rgba(0,0,0,.25);
  padding: 1px 5px;
  border-radius: 4px;
  color: #7ec8e3;
}

.bubble-text pre {
  background: rgba(0,0,0,.3);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px;
  overflow-x: auto;
  margin-top: 8px;
  font-family: var(--mono);
  font-size: 12px;
  line-height: 1.5;
}

.bubble-text strong { color: var(--text); font-weight: 700; }
.bubble-text em     { color: var(--text-dim); font-style: italic; }

/* Cursor blink */
.cursor {
  display: inline-block;
  width: 2px;
  height: 14px;
  background: var(--accent);
  margin-left: 2px;
  animation: blink .8s steps(2) infinite;
  vertical-align: middle;
}

@keyframes blink { 0%,100%{opacity:1} 50%{opacity:0} }

/* Welcome */
.welcome {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  color: var(--text-dim);
  text-align: center;
  padding: 40px;
}

.welcome-icon {
  font-size: 48px;
  animation: float 3s ease-in-out infinite;
}

@keyframes float {
  0%,100% { transform: translateY(0); }
  50%     { transform: translateY(-8px); }
}

.welcome h3 { font-size: 18px; color: var(--text); font-weight: 600; }
.welcome p  { font-size: 13px; max-width: 360px; line-height: 1.6; }

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

.chip {
  padding: 7px 14px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 20px;
  font-size: 12px;
  color: var(--text-dim);
  cursor: pointer;
  transition: all var(--transition);
}

.chip:hover {
  border-color: var(--accent);
  color: var(--text);
  background: var(--border-hl);
}

/* ── Input area ── */
.input-area {
  padding: 16px 20px;
  background: var(--bg-mid);
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}

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

.input-wrapper {
  flex: 1;
  position: relative;
  display: flex;
  align-items: flex-end;
  gap: 8px;
}

/* Attach button */
.attach-btn {
  width: 42px;
  height: 42px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--bg-card);
  color: var(--text-dim);
  font-size: 18px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition);
  flex-shrink: 0;
  margin-bottom: 3px;
}

.attach-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--border-hl);
}

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

textarea#userInput {
  flex: 1;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-family: var(--font);
  font-size: 14px;
  padding: 12px 16px;
  resize: none;
  line-height: 1.5;
  min-height: 48px;
  max-height: 160px;
  outline: none;
  transition: border-color var(--transition), box-shadow var(--transition);
  overflow-y: auto;
}

textarea#userInput::placeholder { color: var(--text-muted); }

textarea#userInput:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--border-hl);
}

.char-count {
  position: absolute;
  bottom: 8px;
  right: 12px;
  font-size: 10px;
  color: var(--text-muted);
  pointer-events: none;
}

/* Buttons */
.btn-group { display: flex; gap: 8px; }

.btn {
  height: 48px;
  padding: 0 18px;
  border-radius: var(--radius);
  border: 1px solid transparent;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 7px;
  white-space: nowrap;
  transition: all var(--transition);
  outline: none;
}

.btn-primary {
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #fff;
  box-shadow: 0 4px 14px var(--accent-glow);
}

.btn-primary:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: 0 6px 20px var(--accent-glow);
}

.btn-primary:disabled {
  opacity: .5;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

.btn-stop {
  background: transparent;
  border-color: var(--error);
  color: var(--error);
}

.btn-stop:hover { background: rgba(252,92,101,.1); }
.btn-stop:disabled { opacity: .35; cursor: not-allowed; }

.btn-clear {
  background: transparent;
  border-color: var(--border);
  color: var(--text-dim);
}

.btn-clear:hover { border-color: var(--text-dim); color: var(--text); }

/* ── Scrollbar ── */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* ── Animations ── */
@keyframes slideIn {
  from { opacity: 0; transform: translateX(-10px); }
  to   { opacity: 1; transform: translateX(0); }
}

@keyframes fadeUp {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ── Toast ── */
.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 1000;
}

.toast {
  padding: 10px 18px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 13px;
  color: var(--text);
  box-shadow: var(--shadow-lg);
  animation: slideIn .25s ease;
  display: flex;
  align-items: center;
  gap: 8px;
}

.toast.success { border-color: var(--success); }
.toast.error   { border-color: var(--error);   }

/* ── Chat History Panel ── */
.panel-section {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-height: 0;
}

.panel-section-history {
  flex: 1.5;
  border-bottom: 1px solid var(--border);
}

.panel-section-progress {
  flex: 1;
}

.history-list {
  flex: 1;
  overflow-y: auto;
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-height: 0;
}

.history-empty {
  text-align: center;
  padding: 20px 12px;
  font-size: 12px;
  color: var(--text-muted);
}

.history-item {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 10px;
  background: var(--bg-card);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  cursor: pointer;
  transition: all var(--transition);
  animation: slideIn .2s ease;
}

.history-item:hover {
  border-color: var(--accent);
  background: var(--border-hl);
}

.history-item.active {
  border-color: var(--accent);
  background: var(--border-hl);
}

.history-item-content {
  flex: 1;
  min-width: 0;
}

.history-item-title {
  font-size: 12px;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  margin-bottom: 2px;
}

.history-item-date {
  font-size: 10px;
  color: var(--text-muted);
}

.history-delete-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 3px 5px;
  border-radius: 4px;
  font-size: 11px;
  opacity: 0;
  transition: all var(--transition);
  line-height: 1;
  flex-shrink: 0;
}

.history-item:hover .history-delete-btn {
  opacity: 1;
}

.history-delete-btn:hover {
  color: var(--error);
  background: rgba(252,92,101,.1);
}

.new-chat-btn {
  margin-left: auto;
  width: 26px;
  height: 26px;
  font-size: 20px;
  font-weight: 300;
  flex-shrink: 0;
}

/* Inline title edit input */
.title-edit-input {
  width: 100%;
  background: var(--bg-input);
  border: 1px solid var(--accent);
  border-radius: 4px;
  color: var(--text);
  font-family: var(--font);
  font-size: 12px;
  padding: 2px 6px;
  outline: none;
  box-shadow: 0 0 0 2px var(--border-hl);
  min-width: 0;
}

/* ── Brand subtitle with model selector ── */
.brand-sub {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 11px;
  color: var(--text-dim);
  font-weight: 400;
}

.model-select-inline {
  font-size: 11px;
  padding: 2px 6px;
  border-radius: 4px;
  border: 1px solid var(--border);
  background: var(--bg-card);
  color: var(--accent);
  font-weight: 600;
  cursor: pointer;
  outline: none;
  max-width: 160px;
  transition: border-color var(--transition);
}

.model-select-inline:hover,
.model-select-inline:focus { border-color: var(--accent); }

.icon-btn-xs {
  width: 22px;
  height: 22px;
  font-size: 12px;
  flex-shrink: 0;
}

/* ── Model management modal ── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.72);
  z-index: 500;
  display: none;
  align-items: center;
  justify-content: center;
  animation: fadeIn .2s ease;
}

.modal-overlay.open { display: flex; }

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

.modal-panel {
  background: var(--bg-mid);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  width: min(480px, 95vw);
  max-height: 80vh;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-lg);
  animation: fadeUp .2s ease;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.modal-header h3 { font-size: 15px; font-weight: 600; }

.modal-body {
  flex: 1;
  overflow-y: auto;
  padding: 18px 20px;
  display: flex;
  flex-direction: column;
  gap: 22px;
}

.modal-section h4 {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .07em;
  color: var(--text-dim);
  margin-bottom: 10px;
}

.installed-model-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  margin-bottom: 6px;
  gap: 8px;
}

.installed-model-info { display: flex; align-items: baseline; gap: 8px; flex: 1; min-width: 0; }
.installed-model-name { font-size: 13px; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.installed-model-size { font-size: 11px; color: var(--text-muted); white-space: nowrap; flex-shrink: 0; }

.install-row { display: flex; gap: 8px; }

.model-input {
  flex: 1;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-family: var(--font);
  font-size: 13px;
  padding: 8px 12px;
  outline: none;
  transition: border-color var(--transition);
  min-width: 0;
}

.model-input:focus { border-color: var(--accent); }

.pull-progress { margin-top: 12px; }

.progress-bar-container {
  height: 6px;
  background: var(--bg-card);
  border-radius: 3px;
  overflow: hidden;
}

.progress-bar {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  border-radius: 3px;
  width: 0%;
  transition: width .4s ease;
}

.progress-text {
  font-size: 11px;
  color: var(--text-dim);
  margin-top: 6px;
}

/* ── Bubble action buttons (copy / speak) ── */
.bubble-meta-right {
  display: flex;
  align-items: center;
  gap: 6px;
}

.bubble-actions {
  display: flex;
  gap: 3px;
  opacity: 0;
  transition: opacity var(--transition);
}

.bubble:hover .bubble-actions { opacity: 1; }

.bubble-action-btn {
  width: 24px;
  height: 24px;
  border-radius: 5px;
  border: 1px solid var(--border);
  background: var(--bg-deep);
  color: var(--text-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  transition: all var(--transition);
  position: relative;
  padding: 0;
  line-height: 1;
}

.bubble-action-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--border-hl);
}

.bubble-action-btn.speaking {
  color: var(--accent);
  border-color: var(--accent);
  background: var(--border-hl);
}

.copy-tooltip {
  position: absolute;
  bottom: calc(100% + 5px);
  left: 50%;
  transform: translateX(-50%);
  background: var(--bg-panel);
  color: var(--text);
  font-size: 10px;
  padding: 3px 7px;
  border-radius: 4px;
  white-space: nowrap;
  pointer-events: none;
  border: 1px solid var(--border);
  z-index: 10;
}

/* ── Workspace panel ── */
.panel-workspace {
  width: 0;
  min-width: 0;
  background: var(--bg-mid);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  flex-shrink: 0;
  transition: width 0.3s ease;
}

.panel-workspace.hidden {
  width: 0 !important;
  border: none !important;
}

.workspace-body {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
}

.workspace-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  color: var(--text-muted);
  text-align: center;
  padding: 24px;
}

.workspace-icon { font-size: 36px; opacity: 0.4; }
.workspace-title { font-size: 13px; font-weight: 600; color: var(--text-dim); }
.workspace-soon  { font-size: 11px; color: var(--text-muted); }

/* ── Resize handles ── */
.resize-handle {
  width: 5px;
  background: var(--border);
  cursor: col-resize;
  flex-shrink: 0;
  transition: background var(--transition);
  position: relative;
  z-index: 1;
}

.resize-handle:hover,
.resize-handle.dragging { background: var(--accent); }

/* ── Attachments preview ── */
.attachments-preview {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 12px;
  max-height: 120px;
  overflow-y: auto;
}

.input-area.drag-active {
  background: rgba(233, 69, 96, 0.1);
  border-color: var(--accent);
}

.attachment-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 12px;
  color: var(--text);
  max-width: 200px;
  animation: fadeIn .2s ease;
}

.attachment-thumb {
  width: 32px;
  height: 32px;
  border-radius: 4px;
  object-fit: cover;
  background: var(--bg-input);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  flex-shrink: 0;
}

.attachment-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 4px;
}

.attachment-info {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.attachment-name {
  font-size: 11px;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.attachment-size {
  font-size: 10px;
  color: var(--text-muted);
}

.attachment-remove {
  width: 20px;
  height: 20px;
  border-radius: 4px;
  border: none;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  line-height: 1;
  transition: all var(--transition);
  flex-shrink: 0;
}

.attachment-remove:hover {
  background: rgba(252, 92, 101, 0.2);
  color: var(--error);
}

/* ── Drag & drop overlay ── */
.drag-overlay {
  position: absolute;
  inset: 0;
  background: rgba(233, 69, 96, 0.15);
  border: 2px dashed var(--accent);
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  z-index: 10;
  opacity: 0;
  transition: opacity 0.2s ease;
}

.drag-overlay.active {
  opacity: 1;
}

.drag-overlay-text {
  font-size: 16px;
  font-weight: 600;
  color: var(--accent);
  background: var(--bg-card);
  padding: 12px 24px;
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
}

/* ── Messages with attachments ── */
.message-attachments {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}

.message-attachment {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  background: rgba(0,0,0,0.2);
  border-radius: 12px;
  font-size: 11px;
  color: var(--text-dim);
}

.message-attachment img {
  width: 20px;
  height: 20px;
  object-fit: cover;
  border-radius: 3px;
}
@media (max-width: 768px) {
  header { padding: 0 14px; }
  .brand-text p { display: none; }
  .brand-sub { display: none; }

  main { flex-direction: column; }

  .resize-handle { display: none !important; }

  .panel-left {
    width: 100% !important;
    min-width: 0;
    border-right: none;
    border-bottom: 1px solid var(--border);
    max-height: 300px;
    transition: max-height 0.3s ease;
  }

  .panel-left.mobile-hidden {
    max-height: 0 !important;
    border-bottom: none;
    overflow: hidden;
  }

  .panel-workspace { display: none !important; }

  #toggleWorkspaceBtn { display: none; }

  .panel-section-history { min-height: 130px; }
  .panel-section-progress { min-height: 80px; }

  .bubble { max-width: 90%; }
  .messages { padding: 12px; }
  .input-area { padding: 10px 12px; }
  .btn span.btn-label { display: none; }
  .btn { padding: 0 12px; }
}

@media (max-width: 480px) {
  .header-controls .lang-select { display: none; }
  .status-pill span { display: none; }
}

/* ── Live Preview Styles ── */

.preview-badge-status {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--success);
  box-shadow: 0 0 6px var(--success);
  margin-left: auto;
  animation: pulse 2s infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

.preview-container {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  height: 100%;
}

.preview-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px;
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  gap: 10px;
  flex-shrink: 0;
}

.preview-devices {
  display: flex;
  gap: 6px;
  flex: 1;
}

.preview-device-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-input);
  color: var(--text-dim);
  font-size: 12px;
  font-family: var(--font);
  cursor: pointer;
  transition: all var(--transition);
  flex: 1;
  justify-content: center;
}

.preview-device-btn:hover {
  border-color: var(--accent);
  color: var(--text);
  background: var(--border-hl);
}

.preview-device-btn.active {
  border-color: var(--accent);
  background: var(--border-hl);
  color: var(--accent);
}

.preview-device-btn .device-icon {
  font-size: 14px;
}

.preview-device-btn .device-label {
  font-weight: 500;
}

@media (max-width: 900px) {
  .preview-device-btn .device-label {
    display: none;
  }
}

.preview-actions {
  display: flex;
  gap: 6px;
}

.preview-action-btn {
  width: 32px;
  height: 32px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-input);
  color: var(--text-dim);
  font-size: 14px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition);
}

.preview-action-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--border-hl);
}

.preview-action-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.preview-frame-wrapper {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: var(--bg-deep);
  overflow: auto;
}

.preview-device-frame {
  background: var(--bg-card);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  border: 1px solid var(--border);
  transition: all var(--transition);
  overflow: hidden;
  position: relative;
}

.preview-device-frame[data-device="mobile"] {
  width: 375px;
  max-width: 100%;
  height: 667px;
  max-height: calc(100vh - 300px);
}

.preview-device-frame[data-device="tablet"] {
  width: 768px;
  max-width: 100%;
  height: 1024px;
  max-height: calc(100vh - 300px);
}

.preview-device-frame[data-device="desktop"] {
  width: 100%;
  height: 100%;
  min-height: 400px;
}

.preview-device-frame::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 24px;
  background: var(--bg-mid);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 8px;
  gap: 6px;
  z-index: 2;
}

.preview-device-frame[data-device="mobile"]::before,
.preview-device-frame[data-device="tablet"]::before {
  content: '● ● ●';
  font-size: 8px;
  color: var(--text-muted);
  letter-spacing: 2px;
  padding-left: 12px;
  line-height: 24px;
}

.preview-device-frame[data-device="desktop"]::before {
  content: '● ● ●';
  font-size: 8px;
  color: var(--text-muted);
  letter-spacing: 2px;
  padding-left: 12px;
  line-height: 24px;
}

#previewIframe {
  width: 100%;
  height: calc(100% - 24px);
  margin-top: 24px;
  border: none;
  background: white;
}

.preview-info {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  background: var(--bg-card);
  border-top: 1px solid var(--border);
  font-size: 11px;
  color: var(--text-muted);
  flex-shrink: 0;
}

.preview-info-text {
  display: flex;
  align-items: center;
  gap: 6px;
}

.preview-info-text::before {
  content: '🎨';
}

/* Message preview badge */
.preview-available-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: white;
  font-size: 10px;
  font-weight: 600;
  border-radius: 10px;
  margin-left: 8px;
  cursor: pointer;
  transition: all var(--transition);
  vertical-align: middle;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.preview-available-badge:hover {
  transform: scale(1.05);
  box-shadow: 0 2px 8px var(--accent-glow);
}

.preview-available-badge::before {
  content: '👁️';
  font-size: 9px;
}

/* Mobile preview adjustments */
@media (max-width: 768px) {
  .preview-device-frame[data-device="mobile"] {
    width: 320px;
    height: 568px;
  }

  .preview-device-frame[data-device="tablet"] {
    width: 100%;
    height: 500px;
  }

  .preview-toolbar {
    padding: 8px;
  }

  .preview-device-btn {
    padding: 6px 8px;
  }
}

/* ── Triad Agent Badges & Mode Switch Styles ── */
.triad-status-container {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--bg-card);
  padding: 4px 10px;
  border-radius: 20px;
  border: 1px solid var(--border);
}

.triad-badge {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 11px;
  font-weight: 500;
  color: var(--text-muted);
  background: var(--bg-mid);
  padding: 3px 8px;
  border-radius: 12px;
}

.triad-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #ff4d4d;
  box-shadow: 0 0 4px #ff4d4d;
}

.triad-dot.online {
  background: #00e676;
  box-shadow: 0 0 6px #00e676;
}

.triad-mode-switch {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  background: linear-gradient(135deg, rgba(0,230,118,0.1), rgba(0,184,212,0.1));
  border: 1px solid rgba(0,230,118,0.3);
  padding: 4px 12px;
  border-radius: 20px;
  user-select: none;
  transition: all var(--transition);
}

.triad-mode-switch:hover {
  border-color: rgba(0,230,118,0.6);
  box-shadow: 0 0 10px rgba(0,230,118,0.2);
}

.triad-mode-switch input {
  display: none;
}

.triad-mode-switch .slider {
  width: 28px;
  height: 16px;
  background: var(--bg-card);
  border-radius: 10px;
  position: relative;
  transition: 0.3s;
  border: 1px solid var(--border);
}

.triad-mode-switch .slider::before {
  content: "";
  position: absolute;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  top: 1px;
  left: 1px;
  background: var(--text-muted);
  transition: 0.3s;
}

.triad-mode-switch input:checked + .slider {
  background: #00e676;
  border-color: #00e676;
}

.triad-mode-switch input:checked + .slider::before {
  transform: translateX(12px);
  background: #000;
}

.triad-mode-switch .mode-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-main);
}

/* ── View Switcher Buttons ── */
.view-switcher-group {
  display: flex;
  background: var(--bg-card);
  padding: 3px;
  border-radius: 18px;
  border: 1px solid var(--border);
}

.view-switch-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 600;
  padding: 5px 14px;
  border-radius: 14px;
  cursor: pointer;
  transition: all var(--transition);
}

.view-switch-btn.active {
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: white;
  box-shadow: 0 2px 8px var(--accent-glow);
}

/* ── Kanban Container & Layout ── */
.kanban-container {
  display: flex;
  flex: 1;
  height: calc(100vh - 60px);
  background: var(--bg-dark);
  overflow: hidden;
}

/* Kanban Sidebar: Folder Tree */
.kanban-sidebar {
  width: 280px;
  background: var(--bg-mid);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
}

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

.sidebar-title {
  font-weight: 700;
  font-size: 14px;
  color: var(--text-main);
}

.btn-xs-primary {
  background: var(--accent);
  color: white;
  border: none;
  font-size: 11px;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 12px;
  cursor: pointer;
  transition: all var(--transition);
}

.btn-xs-primary:hover {
  filter: brightness(1.1);
  transform: translateY(-1px);
}

.folder-tree-list {
  flex: 1;
  overflow-y: auto;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.folder-item {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
}

.folder-item-header {
  padding: 10px 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
  font-weight: 600;
  font-size: 13px;
  background: rgba(255,255,255,0.02);
}

.folder-name-group {
  display: flex;
  align-items: center;
  gap: 8px;
}

.folder-color-badge {
  width: 10px;
  height: 10px;
  border-radius: 50%;
}

.project-list {
  padding: 6px 8px 8px 24px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.project-item {
  padding: 8px 10px;
  border-radius: 8px;
  font-size: 12px;
  color: var(--text-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  transition: all var(--transition);
}

.project-item:hover, .project-item.active {
  background: var(--accent-alpha, rgba(0, 230, 118, 0.15));
  color: var(--text-main);
  font-weight: 600;
}

.add-project-btn {
  font-size: 11px;
  color: var(--accent);
  background: transparent;
  border: none;
  cursor: pointer;
  padding: 4px 8px;
  text-align: left;
}

/* Kanban Board Main Area */
.kanban-board-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--bg-dark);
}

.kanban-header-bar {
  padding: 16px 24px;
  background: var(--bg-mid);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.active-folder-tag {
  font-size: 11px;
  font-weight: 600;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

#activeProjectTitle {
  font-size: 20px;
  font-weight: 700;
  margin: 2px 0;
  color: var(--text-main);
}

.active-project-desc {
  font-size: 12px;
  color: var(--text-muted);
}

.kanban-actions {
  display: flex;
  gap: 10px;
}

.btn-secondary {
  background: var(--bg-card);
  color: var(--text-main);
  border: 1px solid var(--border);
}

/* 4 Column Grid */
.kanban-board-grid {
  flex: 1;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  padding: 20px;
  overflow-x: auto;
  overflow-y: hidden;
}

.kanban-column {
  background: var(--bg-mid);
  border: 1px solid var(--border);
  border-radius: 12px;
  display: flex;
  flex-direction: column;
  max-height: 100%;
  overflow: hidden;
}

.column-header {
  padding: 14px 16px;
  font-weight: 700;
  font-size: 13px;
  display: flex;
  align-items: center;
  gap: 8px;
  border-bottom: 1px solid var(--border);
}

.header-todo { border-top: 3px solid #64b5f6; }
.header-progress { border-top: 3px solid #ffb74d; }
.header-triad { border-top: 3px solid #b388ff; }
.header-done { border-top: 3px solid #00e676; }

.column-title {
  flex: 1;
}

.card-count-badge {
  background: var(--bg-card);
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 11px;
  color: var(--text-muted);
}

.card-list {
  flex: 1;
  overflow-y: auto;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-height: 150px;
}

/* Kanban Task Card */
.kanban-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  cursor: grab;
  transition: all var(--transition);
  position: relative;
}

.kanban-card:hover {
  transform: translateY(-2px);
  border-color: rgba(255,255,255,0.2);
  box-shadow: 0 4px 12px rgba(0,0,0,0.3);
}

.card-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.card-priority {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  padding: 2px 6px;
  border-radius: 6px;
}

.priority-high { background: rgba(255, 77, 77, 0.2); color: #ff4d4d; }
.priority-normal { background: rgba(0, 184, 212, 0.2); color: #00b8d4; }
.priority-low { background: rgba(158, 158, 158, 0.2); color: #9e9e9e; }

.card-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-main);
  line-height: 1.3;
}

.card-desc {
  font-size: 11px;
  color: var(--text-muted);
  line-height: 1.4;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.card-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 4px;
  padding-top: 8px;
  border-top: 1px solid rgba(255,255,255,0.05);
}

.btn-triad-launch {
  background: linear-gradient(135deg, #7c4dff, #00e676);
  color: white;
  border: none;
  font-size: 11px;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 12px;
  cursor: pointer;
  transition: all var(--transition);
  display: flex;
  align-items: center;
  gap: 4px;
}

.btn-triad-launch:hover {
  transform: scale(1.03);
  box-shadow: 0 2px 8px rgba(124, 77, 255, 0.4);
}

.card-actions {
  display: flex;
  gap: 4px;
}

.card-move-btn {
  background: var(--bg-mid);
  border: 1px solid var(--border);
  color: var(--text-muted);
  font-size: 10px;
  padding: 2px 6px;
  border-radius: 4px;
  cursor: pointer;
}

.card-move-btn:hover {
  color: var(--text-main);
  background: var(--bg-dark);
}

/* Modals */
.modal-panel-sm {
  max-width: 450px;
}

.modal-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 14px;
}

.modal-field label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-main);
}

/* Modal Large */
.modal-panel-lg {
  max-width: 750px;
  width: 90%;
}

/* Task Modal File Upload Preview */
.task-modal-files-preview {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 8px;
}

.task-file-tag {
  background: var(--bg-mid);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 4px 8px;
  font-size: 11px;
  color: var(--text-main);
  display: flex;
  align-items: center;
  gap: 6px;
}

.task-file-remove {
  cursor: pointer;
  color: #ff5252;
  font-weight: bold;
}

/* Media Grids */
.media-grid-images {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 10px;
  margin-bottom: 12px;
}

.media-image-item {
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid var(--border);
  aspect-ratio: 16/9;
  background: #000;
}

.media-image-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform var(--transition);

}

.media-image-item img:hover {
  transform: scale(1.05);
}

.media-grid-videos {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 12px;
}

.media-video-item video {
  width: 100%;
  max-height: 350px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: #000;
}

.media-grid-files {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.media-file-item {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  text-decoration: none;
  color: var(--text-main);
  font-size: 12px;
  transition: background var(--transition);
}

.media-file-item:hover {
  background: var(--bg-mid);
  border-color: var(--accent);
}

.media-badges-group {
  display: flex;
  gap: 6px;
  margin-top: 4px;
}

.media-card-badge {
  font-size: 10px;
  background: var(--bg-mid);
  border: 1px solid var(--border);
  padding: 2px 6px;
  border-radius: 4px;
  color: var(--text-muted);
}



