/**
 * Plugin Name:       PokéPapi LLM Council
 * File:              /var/www/vhosts/pokepapi.com/council/public/css/style.css
 * Plugin URI:        https://pokepapi.com
 * Description:       Refined dark theme for the LLM Council Dashboard
 * Version:           0.0.9
 * Author:            PokéPapi
 * Author URI:        https://pokepapi.com
 * License:           GPL-2.0+
 * License URI:       http://www.gnu.org/licenses/gpl-2.0.txt
 * Text Domain:       pokepapi-llm-council
 * Domain Path:       /languages
 */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&family=JetBrains+Mono:wght@400;500&display=swap');

:root {
  --bg-primary: #09090b;
  --bg-secondary: #111114;
  --bg-tertiary: #18181b;
  --bg-surface: #111114;
  --bg-glass: #111114;
  --bg-hover: #1f1f23;
  --accent: #6366f1;
  --accent-hover: #818cf8;
  --accent-glow: rgba(99, 102, 241, 0.2);
  --accent-dim: rgba(99, 102, 241, 0.08);
  --text-primary: #fafafa;
  --text-secondary: #a1a1aa;
  --text-dim: #52525b;
  --border: rgba(255, 255, 255, 0.06);
  --border-active: rgba(99, 102, 241, 0.4);
  --border-subtle: rgba(255, 255, 255, 0.04);
  --success: #22c55e;
  --warning: #eab308;
  --danger: #ef4444;
  --radius-sm: 6px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --radius-xl: 16px;
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.4);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.5);
  --shadow-lg: 0 8px 24px rgba(0,0,0,0.6);
  --transition: 150ms ease;
}

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

html, body {
  height: 100%; width: 100%; overflow: hidden;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg-primary); color: var(--text-primary);
  -webkit-font-smoothing: antialiased;
}

/* === LAYOUT === */
#app { display: flex; height: 100vh; height: 100dvh; width: 100vw; overflow: hidden; }

/* === SIDEBAR === */
#sidebar {
  width: 260px; min-width: 260px;
  background: var(--bg-secondary);
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
  z-index: 100; transition: transform var(--transition);
}
#sidebar.collapsed { transform: translateX(-260px); min-width: 0; width: 0; }

/* Sidebar backdrop overlay (mobile) */
#sidebar-backdrop {
  display: none; position: fixed; inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 99;
}
#sidebar-backdrop.visible { display: block; }

#sidebar-header {
  padding: 20px 20px 16px;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 12px;
}
#sidebar-logo {
  width: 36px; height: 36px; border-radius: 8px;
  object-fit: cover;
}
#sidebar-title { font-size: var(--fs-base); font-weight: 600; letter-spacing: -0.3px; }
#sidebar-subtitle { font-size: var(--fs-xs); color: var(--text-secondary); margin-top: 2px; }

#new-session-btn {
  margin: 12px 16px; padding: 10px;
  background: var(--accent);
  border: none; border-radius: var(--radius-md); color: #fff;
  font-family: inherit; font-size: 13px; font-weight: 500;
  cursor: pointer; transition: all var(--transition);
  display: flex; align-items: center; justify-content: center; gap: 8px;
}
#new-session-btn:hover { background: var(--accent-hover); }

#session-list {
  flex: 1; overflow-y: auto; padding: 8px;
  scrollbar-width: thin; scrollbar-color: var(--text-dim) transparent;
}
#session-list::-webkit-scrollbar { width: 4px; }
#session-list::-webkit-scrollbar-thumb { background: var(--text-dim); border-radius: 2px; }

.session-item {
  padding: 12px 14px; border-radius: var(--radius-md);
  cursor: pointer; transition: all var(--transition);
  margin-bottom: 4px; border: 1px solid transparent;
}
.session-item:hover { background: var(--bg-tertiary); border-color: var(--border); }
.session-item.active {
  background: var(--accent-dim); border-color: var(--border-active);
  box-shadow: inset 0 0 0 1px var(--accent-glow);
}
.session-item-header {
  display: flex; align-items: flex-start; gap: 4px;
}
.session-item-header .session-item-title { flex: 1; min-width: 0; }
.session-item-title {
  font-size: var(--fs-sm); font-weight: 500; white-space: nowrap;
  overflow: hidden; text-overflow: ellipsis; margin-bottom: 4px;
}
.session-item-date { font-size: 10px; color: var(--text-dim); margin-top: 4px; }
.session-item-actions {
  display: flex; gap: 2px; opacity: 0;
  transition: opacity var(--transition); flex-shrink: 0;
}
.session-item:hover .session-item-actions { opacity: 1; }
.session-action-btn {
  background: none; border: none; cursor: pointer;
  font-size: 12px; padding: 2px 4px; border-radius: 4px;
  transition: all var(--transition); line-height: 1;
  color: var(--text-dim);
}
.session-action-btn:hover { background: rgba(255,255,255,0.08); color: var(--text-primary); }
.session-action-btn.delete-btn:hover { color: var(--danger); }

.session-rename-input {
  width: 100%; background: var(--bg-primary); border: 1px solid var(--accent);
  border-radius: var(--radius-sm); color: var(--text-primary);
  font-family: inherit; font-size: 13px; padding: 3px 6px;
  outline: none; box-shadow: 0 0 0 2px var(--accent-dim);
}

#sidebar-footer {
  padding: 12px 16px;
  border-top: 1px solid var(--border);
}
#settings-btn {
  width: 100%; padding: 10px;
  background: var(--bg-tertiary); border: 1px solid var(--border);
  border-radius: var(--radius-md); color: var(--text-secondary);
  font-family: inherit; font-size: 13px; cursor: pointer;
  transition: all var(--transition);
  display: flex; align-items: center; justify-content: center; gap: 8px;
}
#settings-btn:hover { color: var(--text-primary); border-color: var(--text-secondary); }

/* === MAIN CONTENT === */
#main { flex: 1; display: flex; flex-direction: column; min-width: 0; min-height: 0; position: relative; overflow: hidden; }

/* --- Header Bar --- */
#header {
  height: 48px; padding: 0 16px;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 12px;
  z-index: 10; flex-shrink: 0;
}
#toggle-sidebar-btn {
  background: none; border: none; color: var(--text-secondary);
  cursor: pointer; font-size: 18px; padding: 6px;
  border-radius: var(--radius-sm); transition: all var(--transition);
}
#toggle-sidebar-btn:hover { color: var(--text-primary); background: var(--bg-tertiary); }
#header-title { font-size: var(--fs-base); font-weight: 600; flex: 1; }
.header-status {
  font-size: 11px; padding: 4px 10px; border-radius: 20px;
  display: flex; align-items: center; gap: 6px;
}
.header-status .dot {
  width: 7px; height: 7px; border-radius: 50%;
  animation: pulse-dot 2s infinite;
}
.header-status.connected { background: rgba(63,185,80,0.12); color: var(--success); }
.header-status.connected .dot { background: var(--success); }
.header-status.disconnected { background: rgba(248,81,73,0.12); color: var(--danger); }
.header-status.disconnected .dot { background: var(--danger); }

.header-btn {
  background: none; border: 1px solid var(--border); color: var(--text-secondary);
  cursor: pointer; font-size: var(--fs-sm); padding: 5px 10px;
  border-radius: var(--radius-sm); transition: all var(--transition);
  font-family: inherit;
}
.header-btn:hover { color: var(--text-primary); border-color: var(--text-secondary); }

@keyframes pulse-dot {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

/* --- Chat Output Area --- */
#chat-area {
  flex: 1; min-height: 0; overflow-y: auto; padding: 20px 24px;
  scroll-behavior: smooth;
  scrollbar-width: thin; scrollbar-color: var(--text-dim) transparent;
}
#chat-area::-webkit-scrollbar { width: 5px; }
#chat-area::-webkit-scrollbar-thumb { background: var(--text-dim); border-radius: 3px; }

/* Welcome Screen */
#welcome {
  flex: 1; display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  padding: 40px; text-align: center;
  min-height: 60vh;
}
#welcome-logo {
  width: 64px; height: 64px; border-radius: 14px;
  object-fit: cover;
  margin-bottom: 20px;
}
#welcome h1 { font-size: calc(20px * var(--font-scale)); font-weight: 600; margin-bottom: 8px; }
#welcome p { font-size: var(--fs-sm); color: var(--text-secondary); max-width: 400px; line-height: 1.6; }

/* Messages */
.msg { margin-bottom: 16px; display: flex; gap: 10px; animation: msg-in 0.3s ease-out; }
.msg.user { flex-direction: row-reverse; }
@keyframes msg-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }

.msg-avatar {
  width: 30px; height: 30px; border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0; margin-top: 2px; overflow: hidden;
}
.msg-avatar img { width: 100%; height: 100%; object-fit: contain; }
.msg.user .msg-avatar { background: var(--accent); font-size: 14px; }
.msg.system .msg-avatar { background: var(--bg-tertiary); border: 1px solid var(--border); padding: 4px; }

.msg-body { max-width: 78%; min-width: 60px; }
.msg-header {
  display: flex; align-items: center; gap: 8px; margin-bottom: 4px;
}
.msg-model-name {
  font-size: 12px; font-weight: 600; text-transform: capitalize;
  color: var(--accent-hover);
}
.msg-time { font-size: 11px; font-weight: 500; color: var(--text-secondary); opacity: 0.9; }
.msg.user .msg-time { text-align: right; }
.msg.user .msg-header { flex-direction: row-reverse; }

.msg-content {
  padding: 10px 14px; border-radius: var(--radius-md);
  font-family: 'Plus Jakarta Sans', 'Inter', -apple-system, sans-serif;
  font-size: var(--fs-base); line-height: 1.7; word-break: break-word;
  letter-spacing: 0.01em;
}
.msg.user .msg-content {
  background: var(--accent);
  color: #fff; border-bottom-right-radius: 4px;
}
.msg.system .msg-content {
  background: var(--bg-tertiary); color: var(--text-primary);
  border: 1px solid var(--border); border-bottom-left-radius: 4px;
}
.msg.system .msg-content pre {
  overflow-x: auto; background: var(--bg-primary);
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 10px; margin: 8px 0; font-size: 12px;
  font-family: 'JetBrains Mono', monospace;
}
.msg.system .msg-content code {
  font-family: 'JetBrains Mono', monospace; font-size: 12px;
  background: var(--bg-primary); padding: 1px 5px; border-radius: 3px;
}
.msg.system .msg-content pre code {
  background: none; padding: 0;
}

/* Code block action toolbar */
.code-toolbar {
  display: flex; gap: 4px; justify-content: flex-end;
  padding: 4px 6px; margin: -10px -10px 6px -10px;
  background: rgba(255,255,255,0.03);
  border-bottom: 1px solid var(--border);
  border-radius: var(--radius-sm) var(--radius-sm) 0 0;
}
.code-action-btn {
  background: rgba(255,255,255,0.06); border: 1px solid var(--border);
  color: var(--text-secondary); font-size: 11px; padding: 2px 8px;
  border-radius: 4px; cursor: pointer; font-family: inherit;
  transition: all 0.15s;
}
.code-action-btn:hover { background: rgba(139, 92, 246, 0.15); color: var(--text-primary); }

.msg.thinking .msg-content {
  border-left: 3px solid var(--accent);
  animation: thinking-pulse 1.5s ease-in-out infinite;
}
@keyframes thinking-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.7; }
}

.copy-btn {
  margin-top: 4px; background: none; border: 1px solid var(--border);
  color: var(--text-dim); font-size: 10px; padding: 3px 8px;
  border-radius: var(--radius-sm); cursor: pointer;
  font-family: inherit; transition: all var(--transition);
  display: inline-block; margin-right: 4px;
}
.copy-btn:hover { color: var(--text-primary); border-color: var(--text-secondary); }
.edit-btn:hover { color: var(--accent-hover); border-color: var(--accent); }

/* --- Input Area --- */
#input-area {
  padding: 12px 16px 16px;
  background: var(--bg-secondary);
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}
#input-row {
  display: flex; align-items: flex-end; gap: 8px;
  background: var(--bg-tertiary); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 6px 6px 6px 14px;
  transition: border-color var(--transition), box-shadow var(--transition);
}
#input-row:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-dim); }
#input-row.drag-over {
  border-color: var(--accent); box-shadow: 0 0 12px var(--accent-glow);
  background: rgba(139, 92, 246, 0.08);
}

/* Pending file attachments bar */
#pending-files-bar {
  display: none; flex-wrap: wrap; gap: 6px;
  padding: 6px 8px; margin-bottom: 4px;
  background: rgba(139, 92, 246, 0.06);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}
.pending-file-chip {
  display: inline-flex; align-items: center; gap: 4px;
  background: rgba(139, 92, 246, 0.15); color: var(--text-secondary);
  padding: 3px 8px; border-radius: 12px; font-size: 11px;
  border: 1px solid rgba(139, 92, 246, 0.3);
  animation: chipIn 0.2s ease-out;
}
@keyframes chipIn { from { opacity: 0; transform: scale(0.85); } to { opacity: 1; transform: scale(1); } }
.pending-file-remove {
  background: none; border: none; color: var(--text-dim); cursor: pointer;
  font-size: 14px; line-height: 1; padding: 0 2px; margin-left: 2px;
  transition: color 0.15s;
}
.pending-file-remove:hover { color: #ef4444; }

/* Scroll to bottom button */
.scroll-bottom-btn {
  display: none; position: fixed; bottom: 90px; left: 50%;
  transform: translateX(-50%); z-index: 50;
  width: 36px; height: 36px; border-radius: 50%;
  background: var(--bg-tertiary); border: 1px solid var(--border);
  color: var(--text-secondary); font-size: 14px; cursor: pointer;
  box-shadow: var(--shadow-md);
  transition: all 0.2s; opacity: 0;
}
.scroll-bottom-btn.visible { display: flex; align-items: center; justify-content: center; opacity: 1; }
.scroll-bottom-btn:hover { background: var(--bg-hover); color: var(--text-primary); }

#promptInput {
  flex: 1; background: none; border: none; outline: none;
  color: var(--text-primary); font-family: 'Plus Jakarta Sans', 'Inter', -apple-system, sans-serif;
  font-size: var(--fs-base); resize: none; line-height: 1.6;
  min-height: 22px; max-height: 40vh; padding: 6px 0;
  overflow-y: hidden;
}
#promptInput::placeholder { color: var(--text-dim); }

.input-btn {
  width: 34px; height: 34px; border-radius: var(--radius-sm);
  border: none; cursor: pointer; display: flex;
  align-items: center; justify-content: center;
  transition: all var(--transition); color: var(--text-secondary);
  background: transparent; font-size: 16px; flex-shrink: 0;
}
.input-btn:hover { color: var(--text-primary); background: rgba(255,255,255,0.06); }

#sendBtn {
  background: var(--accent);
  color: #fff; border-radius: 8px; font-size: var(--fs-sm); font-weight: 500;
  width: auto; padding: 8px 16px; font-family: inherit;
  display: inline-flex; align-items: center; gap: 5px; white-space: nowrap;
  border: none; cursor: pointer; transition: all var(--transition);
}
#sendBtn img { filter: brightness(10); }
#sendBtn:hover { background: var(--accent-hover); }

#stopBtn {
  background: var(--danger);
  color: #fff; border: none; border-radius: 8px; font-size: 12px; font-weight: 500;
  padding: 8px 12px; font-family: inherit; cursor: pointer;
  display: inline-flex; align-items: center; gap: 4px;
  animation: stopPulse 1.5s ease-in-out infinite; flex-shrink: 0;
}
#stopBtn:hover { opacity: 0.85; }
@keyframes stopPulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.7; }
}

#modelSelector {
  background: var(--bg-primary); border: 1px solid var(--border);
  color: var(--text-primary); border-radius: var(--radius-sm);
  padding: 6px 8px; font-family: inherit; font-size: 12px;
  cursor: pointer; flex-shrink: 0; outline: none;
  transition: border-color var(--transition);
}
#modelSelector:focus { border-color: var(--accent); }

/* === CUSTOM MODEL SELECTOR === */
.custom-select-wrap { position: relative; flex-shrink: 0; }
.custom-select-btn {
  display: flex; align-items: center; gap: 6px;
  background: var(--bg-primary); border: 1px solid var(--border);
  color: var(--text-primary); border-radius: var(--radius-sm);
  padding: 6px 10px; font-family: inherit; font-size: var(--fs-sm);
  cursor: pointer; outline: none; white-space: nowrap;
  transition: border-color var(--transition);
}
.custom-select-btn:hover, .custom-select-btn:focus { border-color: var(--accent); }
.custom-select-btn .sel-icon { font-size: 14px; }
.custom-select-btn .sel-label { font-weight: 500; }
.custom-select-btn .sel-arrow { font-size: 10px; color: var(--text-dim); margin-left: 2px; }

.custom-select-dropdown {
  display: none; position: absolute; bottom: calc(100% + 4px); right: 0;
  background: var(--bg-tertiary); border: 1px solid var(--border);
  border-radius: var(--radius-md); box-shadow: var(--shadow-lg);
  z-index: 100;
  min-width: 260px; max-height: 400px; overflow-y: auto;
  padding: 4px 0;
}
.custom-select-dropdown.open { display: block; }
.sel-option {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 14px; font-size: var(--fs-sm); cursor: pointer;
  color: var(--text-primary); transition: background 0.1s;
}
.sel-option:hover { background: rgba(139, 92, 246, 0.12); }
.sel-option.active { background: rgba(139, 92, 246, 0.2); color: var(--accent-hover); }
.sel-group-label {
  display: flex; align-items: center; gap: 6px;
  padding: 6px 14px 2px; font-size: 10px; font-weight: 700;
  color: var(--text-dim); text-transform: uppercase; letter-spacing: 0.05em;
  border-top: 1px solid var(--border); margin-top: 4px;
}
.sel-group-label:first-child { border-top: none; margin-top: 0; }
.sel-logo { width: 16px; height: 16px; flex-shrink: 0; }
.sel-group-label .sel-logo { width: 12px; height: 12px; opacity: 0.7; }

/* === QUICK ACTIONS PANEL (HIDDEN) === */
#quick-panel {
  display: none !important;
}
#quick-panel.collapsed { transform: translateX(var(--qp-width)); min-width: 0; width: 0; overflow: hidden; }

/* Scale variants */
#quick-panel[data-scale="small"] { --qp-width: 52px; --qp-btn: 36px; --qp-icon: 12px; --qp-label: 6px; --qp-gap: 3px; }
#quick-panel[data-scale="normal"] { --qp-width: 64px; --qp-btn: 44px; --qp-icon: 14px; --qp-label: 7px; --qp-gap: 4px; }
#quick-panel[data-scale="large"] { --qp-width: 80px; --qp-btn: 56px; --qp-icon: 18px; --qp-label: 8px; --qp-gap: 5px; }
#quick-panel[data-scale="xlarge"] { --qp-width: 96px; --qp-btn: 68px; --qp-icon: 22px; --qp-label: 10px; --qp-gap: 6px; }

.quick-btn {
  width: var(--qp-btn); height: var(--qp-btn); border-radius: var(--radius-md);
  border: 1px solid var(--border); background: var(--bg-tertiary);
  color: var(--text-secondary); cursor: pointer;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 2px; font-size: var(--qp-icon); transition: all var(--transition);
  position: relative;
}
.quick-btn:hover {
  color: var(--text-primary); border-color: var(--accent);
  background: var(--accent-dim); transform: scale(1.08);
}
.quick-btn-label {
  font-size: var(--qp-label); font-weight: 600; text-transform: uppercase;
  letter-spacing: 0.3px; line-height: 1;
}
.quick-btn .tooltip {
  display: none; position: absolute; right: calc(100% + 8px); top: 50%;
  transform: translateY(-50%); background: var(--bg-primary);
  border: 1px solid var(--border); color: var(--text-primary);
  font-size: 11px; padding: 4px 8px; border-radius: var(--radius-sm);
  white-space: nowrap; pointer-events: none;
}
.quick-btn:hover .tooltip { display: block; }

/* Tier toggle badge */
.quick-tier-badge {
  position: absolute; top: 2px; right: 2px;
  font-size: 7px; font-weight: 700; letter-spacing: 0.5px;
  padding: 1px 3px; border-radius: 3px;
  background: rgba(139,92,246,0.3); color: #c4b5fd;
  line-height: 1; pointer-events: none;
}
.quick-model-toggle[data-tier="fast"] { border-color: rgba(251,146,60,0.4); }
.quick-model-toggle[data-tier="fast"] .quick-tier-badge {
  background: rgba(251,146,60,0.3); color: #fb923c;
}

/* Export popup */
.export-popup {
  display: none; position: absolute; bottom: calc(100% + 8px); left: 0;
  background: var(--bg-tertiary);
  border: 1px solid var(--border); border-radius: 12px;
  padding: 16px; width: 310px; z-index: 100;
  box-shadow: 0 8px 32px rgba(0,0,0,0.5);
}
.export-popup.visible { display: block; }
.export-popup-title { font-weight: 600; font-size: 14px; margin-bottom: 10px; color: var(--text-primary); }
.export-popup-dates { display: flex; gap: 8px; margin-bottom: 10px; flex-wrap: wrap; }
.export-date-label { font-size: 11px; color: var(--text-secondary); flex: 1; min-width: 130px; }
.export-date-input {
  width: 100%; margin-top: 2px; padding: 6px; border-radius: 6px;
  border: 1px solid var(--border); background: var(--bg-secondary);
  color: var(--text-primary); font-size: 12px;
}
.export-popup-actions { display: flex; gap: 8px; }
.export-btn {
  flex: 1; padding: 8px; border: none; border-radius: 8px;
  color: #fff; font-weight: 600; cursor: pointer; font-size: 13px;
  transition: opacity 0.15s;
}
.export-btn:hover { opacity: 0.85; }
.export-btn-json { background: #3b82f6; }
.export-btn-pdf { background: var(--accent); }
.export-status { font-size: 11px; margin-top: 6px; color: var(--text-dim); }

/* === SETTINGS PANEL === */
#settingsModal {
  display: none; position: fixed; inset: 0; z-index: 1000;
  background: rgba(0,0,0,0.7);
  align-items: center; justify-content: center;
}
.settings-panel {
  display: flex; background: var(--bg-secondary); border: 1px solid var(--border);
  border-radius: var(--radius-xl); max-width: 760px; width: 94%;
  margin: 4% auto; max-height: 85vh; overflow: hidden;
  box-shadow: var(--shadow-lg); animation: scale-in 0.15s ease-out;
}
@keyframes scale-in { from { transform: scale(0.95); opacity: 0; } }

/* Sidebar Nav */
.settings-nav {
  width: 200px; min-width: 200px; background: var(--bg-primary);
  border-right: 1px solid var(--border); padding: 16px 10px;
  display: flex; flex-direction: column; gap: 2px; overflow-y: auto;
}
.settings-nav-header {
  display: flex; align-items: center; gap: 6px; font-size: 15px; font-weight: 700;
  padding: 4px 8px 14px; color: var(--text-primary);
}
.settings-close {
  margin-left: auto; font-size: 20px; background: none; border: none;
  color: var(--text-dim); cursor: pointer; line-height: 1;
}
.settings-close:hover { color: var(--text-primary); }
.settings-nav-btn {
  display: flex; align-items: center; gap: 10px; width: 100%;
  padding: 9px 12px; border: none; border-radius: var(--radius-sm);
  background: transparent; color: var(--text-secondary);
  font-family: inherit; font-size: 13px; font-weight: 500;
  cursor: pointer; transition: all 0.12s;
}
.settings-nav-btn:hover { background: rgba(255,255,255,0.04); color: var(--text-primary); }
.settings-nav-btn.active { background: rgba(139,92,246,0.12); color: var(--accent-hover); }
.settings-nav-btn svg { flex-shrink: 0; opacity: 0.7; }
.settings-nav-btn.active svg { opacity: 1; }
.settings-nav-divider { height: 1px; background: var(--border); margin: 10px 8px; }
.settings-nav-label {
  font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em;
  color: var(--text-dim); padding: 4px 12px;
}

/* Content Panes */
.settings-content {
  flex: 1; padding: 28px 32px; overflow-y: auto; min-height: 0;
}
.settings-pane { display: none; }
.settings-pane.active { display: block; }
.settings-pane h2 { font-size: 20px; font-weight: 700; margin-bottom: 4px; }
.settings-desc { font-size: 12px; color: var(--text-dim); margin-bottom: 20px; line-height: 1.5; }

/* Setting Elements */
.setting-group { margin-bottom: 20px; }
.setting-label { font-size: 13px; font-weight: 600; color: var(--text-primary); display: block; margin-bottom: 4px; }
.setting-label-sm { font-size: 11px; font-weight: 600; color: var(--text-dim); display: block; margin-bottom: 4px; }
.setting-hint { font-size: 11px; color: var(--text-dim); margin-bottom: 8px; line-height: 1.4; }
.setting-value-sm { font-size: 12px; color: var(--text-secondary); }
.setting-input, .setting-input-sm {
  width: 100%; padding: 8px 12px; background: var(--bg-tertiary);
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  color: var(--text-primary); font-family: inherit; outline: none;
  transition: border-color var(--transition);
}
.setting-input { font-size: 13px; }
.setting-input-sm { font-size: 12px; padding: 6px 10px; }
.setting-input:focus, .setting-input-sm:focus { border-color: var(--accent); }
.setting-textarea {
  width: 100%; min-height: 100px; padding: 10px 12px;
  background: var(--bg-tertiary); border: 1px solid var(--border);
  border-radius: var(--radius-md); color: var(--text-primary);
  font-family: 'Plus Jakarta Sans', 'Inter', sans-serif;
  font-size: 13px; resize: vertical; outline: none;
  transition: border-color var(--transition);
}
.setting-textarea:focus { border-color: var(--accent); }
.setting-btn-primary {
  padding: 10px 20px; background: var(--accent);
  border: none; border-radius: var(--radius-sm); color: #fff;
  font-family: inherit; font-size: 13px; font-weight: 500;
  cursor: pointer; transition: all var(--transition);
}
.setting-btn-primary:hover { background: var(--accent-hover); }
.setting-btn-danger {
  width: 100%; padding: 10px; background: var(--bg-tertiary);
  border: 1px solid var(--border); border-radius: var(--radius-md);
  color: var(--danger); font-family: inherit; font-size: 13px; cursor: pointer;
}
.setting-btn-danger:hover { background: rgba(239,68,68,0.1); border-color: var(--danger); }
.setting-status { font-size: 12px; text-align: center; margin-top: 8px; }

/* Model Row (Top + Fast side by side) */
.model-row { display: flex; gap: 12px; }
.model-col { flex: 1; }

/* ═══ TABLET (iPad) ═══ */
@media (max-width: 1024px) {
  #sidebar {
    position: fixed; left: 0; top: 0; bottom: 0; z-index: 100;
    width: 280px; min-width: 280px;
  }
  #sidebar.collapsed { transform: translateX(-260px); min-width: 0; width: 0; }

  #quick-panel { width: 48px; min-width: 48px; }
  .quick-btn { width: 36px; height: 36px; font-size: 13px; }
  .quick-btn-label { display: none; }
  .quick-tier-badge { display: none; }

  #canvas-panel { width: 360px; min-width: 280px; }

  .mode-toggle-btn { padding: 3px 7px; font-size: 10px; }
  #header { padding: 0 12px; gap: 8px; }
  .header-btn { font-size: 12px; padding: 4px 8px; }
}

/* ═══ MOBILE (Phone + Small Tablet) ═══ */
@media (max-width: 768px) {
  #app { flex-direction: column; height: 100vh; height: 100dvh; }

  /* Sidebar: overlay */
  #sidebar {
    position: fixed; left: 0; top: 0; bottom: 0; z-index: 200;
    width: 280px; min-width: 280px;
  }
  #sidebar.collapsed { transform: translateX(-260px); min-width: 0; width: 0; }

  /* Quick panel: hidden on mobile */
  #quick-panel { display: none; }

  /* Canvas panel: full width overlay */
  #canvas-panel {
    position: fixed; right: 0; top: 0; bottom: 0;
    width: 100vw !important; max-width: 100vw; z-index: 150;
  }

  /* Main area takes full space */
  #main { flex: 1; min-height: 0; display: flex; flex-direction: column; }

  /* Header: compact */
  #header {
    height: 46px; padding: 0 10px; gap: 6px;
    flex-shrink: 0;
  }
  #header-title { font-size: 13px; }
  .header-status { font-size: 10px; padding: 3px 8px; }
  .header-btn { font-size: 11px; padding: 4px 6px; }

  /* Hide mode toggle and guide on mobile — save space */
  .mode-toggle { display: none; }
  #help-guide-btn { display: none; }

  /* Chat area */
  #chat-area {
    flex: 1; min-height: 0; overflow-y: auto;
    padding: 10px 10px 10px;
    -webkit-overflow-scrolling: touch;
  }

  /* Messages */
  .msg { padding: 6px 0; }
  .msg-avatar { width: 28px; height: 28px; font-size: 14px; }
  .msg-avatar img { width: 28px; height: 28px; }
  .msg-body { max-width: 90%; }
  .msg-content { font-size: 13px; padding: 10px 12px; }
  .msg-header { font-size: 12px; }

  /* Input area: fixed to bottom, safe area aware */
  #input-area {
    padding: 8px 10px; padding-bottom: calc(8px + env(safe-area-inset-bottom, 0px));
    flex-shrink: 0;
    position: relative;
    z-index: 50;
  }
  #input-row {
    padding: 4px 4px 4px 10px; gap: 4px;
    border-radius: 12px;
  }
  #promptInput { font-size: 14px; min-height: 20px; }

  .input-btn { width: 30px; height: 30px; font-size: 14px; }
  #sendBtn { padding: 6px 12px; font-size: 12px; }
  #stopBtn { padding: 6px 10px; font-size: 11px; }

  /* Export popup: position above input, full width */
  .export-popup {
    width: calc(100vw - 20px); left: -10px;
    bottom: calc(100% + 6px);
  }

  /* Scroll to bottom */
  .scroll-bottom-btn { bottom: 75px; width: 36px; height: 36px; font-size: 14px; }

  /* Session files bar */
  #session-files-bar { padding: 4px 10px; font-size: 11px; }

  /* Custom model selector */
  .custom-select-dropdown { max-height: 50vh; }
  .sel-option { padding: 8px 10px; font-size: 12px; }

  /* Welcome */
  #welcome h1 { font-size: 20px; }
  #welcome p { font-size: 13px; max-width: 320px; }
  #welcome-logo { width: 64px; height: 64px; }

  /* Settings: full screen */
  .settings-panel { flex-direction: column; max-height: 90vh; width: 95vw; }
  .settings-nav {
    width: 100%; min-width: 100%; flex-direction: row; flex-wrap: wrap;
    padding: 10px; gap: 4px; border-right: none; border-bottom: 1px solid var(--border);
  }
  .settings-nav-header { width: 100%; padding-bottom: 8px; }
  .settings-nav-btn { flex: 0 0 auto; padding: 6px 10px; font-size: 12px; }
  .settings-nav-divider { display: none; }
  .settings-nav-label { display: none; }
  .settings-content { padding: 20px 16px; }
  .model-row { flex-direction: column; gap: 8px; }
}

/* ═══ SMALL PHONES ═══ */
@media (max-width: 480px) {
  #header { height: 42px; padding: 0 8px; gap: 4px; }
  #header-title { font-size: 12px; }
  .header-status { display: none; } /* Hide connected badge */
  #toggle-canvas-btn { display: none; } /* Canvas not useful on tiny screens */

  #chat-area { padding: 8px 8px; }
  .msg-content { font-size: 12px; padding: 8px 10px; }
  .msg-body { max-width: 92%; }

  #input-area { padding: 6px 8px; padding-bottom: calc(6px + env(safe-area-inset-bottom, 0px)); }
  #input-row { padding: 3px 3px 3px 8px; }
  #promptInput { font-size: 13px; }

  .export-popup { width: calc(100vw - 16px); left: -8px; }

  #welcome h1 { font-size: 18px; }
  #welcome-logo { width: 48px; height: 48px; }
}
.confirm-cancel { background: var(--bg-tertiary); color: var(--text-secondary); border: 1px solid var(--border); }
.confirm-cancel:hover { color: var(--text-primary); }
.confirm-ok { background: var(--danger); color: #fff; }
.confirm-ok:hover { background: #e5443d; }

/* === LLM CONFIG CARDS === */
.llm-config-card {
  background: var(--bg-primary); border: 1px solid var(--border);
  border-radius: var(--radius-md); margin-bottom: 10px; overflow: hidden;
}
.llm-config-header {
  display: flex; align-items: center; gap: 8px; padding: 10px 12px;
  background: rgba(255,255,255,0.02); border-bottom: 1px solid var(--border);
  font-size: 13px; font-weight: 600;
}
.llm-config-body { padding: 10px 12px; }
.conn-badge {
  margin-left: auto; font-size: 10px; font-weight: 600;
  padding: 2px 8px; border-radius: 10px;
  background: rgba(139, 92, 246, 0.15); color: var(--accent);
}
.config-select {
  background: var(--bg-primary); border: 1px solid var(--border);
  color: var(--text-primary); border-radius: var(--radius-sm);
  padding: 4px 6px; font-family: inherit; font-size: 11px;
  outline: none; cursor: pointer;
}
.refresh-models-btn {
  background: none; border: 1px solid var(--border); border-radius: var(--radius-sm);
  color: var(--text-secondary); cursor: pointer; padding: 3px 6px; font-size: 12px;
  transition: all 0.15s;
}
.refresh-models-btn:hover { background: rgba(139, 92, 246, 0.1); color: var(--text-primary); }

/* === CONFIRM DIALOG === */
#confirm-overlay {
  position: fixed; inset: 0; z-index: 1000;
  background: rgba(0,0,0,0.7);
  display: flex; align-items: center; justify-content: center;
  animation: fade-in 0.15s ease-out;
}
@keyframes fade-in { from { opacity: 0; } }
.confirm-box {
  background: var(--bg-secondary); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 24px;
  max-width: 360px; width: 90%; box-shadow: var(--shadow-lg);
}
.confirm-msg { font-size: 14px; line-height: 1.5; margin-bottom: 20px; }
.confirm-actions { display: flex; gap: 10px; justify-content: flex-end; }
.confirm-cancel, .confirm-ok {
  padding: 8px 18px; border-radius: var(--radius-sm);
  font-family: inherit; font-size: 13px; font-weight: 500;
  cursor: pointer; border: none; transition: all var(--transition);
}
.confirm-cancel { background: var(--bg-tertiary); color: var(--text-secondary); border: 1px solid var(--border); }
.confirm-cancel:hover { color: var(--text-primary); }
.confirm-ok { background: var(--danger); color: #fff; }
.confirm-ok:hover { background: #e5443d; }

/* === HELP GUIDE MODAL === */
#help-overlay {
  position: fixed; inset: 0; z-index: 1000;
  background: rgba(0,0,0,0.7);
  display: flex; align-items: center; justify-content: center;
  animation: fade-in 0.15s ease-out;
}
/* === GLOBAL FONT SCALE === */
:root { --font-scale: 1; --fs-base: calc(15px * var(--font-scale)); --fs-sm: calc(13px * var(--font-scale)); --fs-xs: calc(12px * var(--font-scale)); --fs-lg: calc(18px * var(--font-scale)); --fs-xl: calc(22px * var(--font-scale)); --icon-scale: var(--font-scale); }

/* Scale content areas without breaking viewport height */
#sidebar > * { zoom: var(--font-scale); }
#main > #header { zoom: var(--font-scale); }
#chat-area { zoom: var(--font-scale); }
#input-area { zoom: var(--font-scale); }
.settings-panel { zoom: var(--font-scale); }
.help-modal { zoom: var(--font-scale); }
#confirm-overlay .confirm-box { zoom: var(--font-scale); }

.help-modal {
  background: var(--bg-secondary); border: 1px solid var(--border);
  border-radius: var(--radius-xl); max-width: 820px; width: 94%;
  max-height: 85vh; display: flex; flex-direction: column;
  box-shadow: var(--shadow-lg);
}
.help-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 20px 24px 16px; border-bottom: 1px solid var(--border);
}
.help-header h2 { font-size: 15px; font-weight: 600; letter-spacing: -0.3px; }
.help-close {
  background: none; border: none; color: var(--text-secondary);
  font-size: 22px; cursor: pointer; padding: 4px 8px;
  border-radius: var(--radius-sm); transition: all var(--transition);
}
.help-close:hover { color: var(--text-primary); background: var(--bg-tertiary); }

/* Tabbed guide layout */
.help-layout {
  display: flex; flex: 1; min-height: 0; overflow: hidden;
}
.help-nav {
  width: 180px; min-width: 180px; padding: 12px 8px;
  border-right: 1px solid var(--border); overflow-y: auto;
  display: flex; flex-direction: column; gap: 2px;
  background: var(--bg-primary);
}
.help-nav-btn {
  display: block; width: 100%; text-align: left;
  padding: 8px 12px; border: none; border-radius: var(--radius-sm);
  background: transparent; color: var(--text-dim);
  font-family: inherit; font-size: 13px; font-weight: 500;
  cursor: pointer; transition: all 0.12s;
}
.help-nav-btn:hover { background: rgba(255,255,255,0.03); color: var(--text-secondary); }
.help-nav-btn.active { background: var(--accent-dim); color: var(--accent-hover); }
.help-content {
  flex: 1; padding: 24px 28px; overflow-y: auto;
  scrollbar-width: thin;
}
.help-tab { display: none; }
.help-tab.active { display: block; }
.help-tab h3 {
  font-size: 11px; font-weight: 600; margin-bottom: 12px;
  color: var(--text-dim); text-transform: uppercase; letter-spacing: 0.08em;
  padding-bottom: 8px; border-bottom: 1px solid var(--border);
}
.help-tab p {
  font-size: 14px; line-height: 1.7; color: var(--text-secondary); margin-bottom: 14px;
}
.help-tab ul { list-style: none; padding: 0; margin: 0; }
.help-tab li {
  padding: 5px 0; font-size: 14px; line-height: 1.7;
  color: var(--text-secondary);
}
.help-tab li strong { color: var(--text-primary); font-weight: 500; }
.help-tab li::before {
  content: ''; display: inline-block; width: 4px; height: 4px;
  background: var(--accent); border-radius: 50%;
  margin-right: 10px; vertical-align: middle;
}
/* Pipeline stage cards */
.help-stage {
  display: flex; align-items: flex-start; gap: 14px;
  padding: 10px 0; border-bottom: 1px solid var(--border-subtle);
}
.help-stage:last-child { border-bottom: none; }
.help-stage-num {
  width: 28px; height: 28px; border-radius: 50%;
  background: var(--accent-dim); color: var(--accent-hover);
  display: flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 600; flex-shrink: 0;
}
.help-stage div { font-size: 14px; line-height: 1.6; color: var(--text-secondary); }
.help-stage strong { color: var(--text-primary); }
/* Model cards */
.help-model-card {
  background: var(--bg-tertiary); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 10px 14px;
  font-size: 13px; line-height: 1.5; color: var(--text-secondary);
}
.help-model-card strong { color: var(--text-primary); display: block; margin-bottom: 2px; }
/* Command reference */
.help-cmd {
  display: flex; align-items: center; gap: 12px;
  padding: 6px 0; font-size: 14px; color: var(--text-secondary);
}
.help-cmd code {
  background: var(--bg-tertiary); border: 1px solid var(--border);
  padding: 2px 8px; border-radius: 4px; font-size: 13px;
  font-family: 'JetBrains Mono', monospace; color: var(--accent-hover);
  min-width: 100px;
}

/* Legacy help-section (keep for compatibility) */
.help-body { overflow-y: auto; padding: 20px 28px 28px; scrollbar-width: thin; }
.help-section { margin-bottom: 20px; }

/* === DATE INPUT DARK MODE FIX === */
input[type="datetime-local"],
input[type="date"],
input[type="time"] {
  color-scheme: dark;
}
.export-date-input {
  color-scheme: dark;
}
::-webkit-calendar-picker-indicator {
  filter: invert(1);
}

/* === RANGE SLIDER STYLING === */
input[type="range"] {
  -webkit-appearance: none; appearance: none;
  height: 4px; background: var(--bg-tertiary); border-radius: 2px;
  border: none; outline: none;
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none;
  width: 16px; height: 16px; border-radius: 50%;
  background: var(--accent); cursor: pointer;
  border: 2px solid var(--bg-primary);
}
input[type="range"]::-moz-range-thumb {
  width: 16px; height: 16px; border-radius: 50%;
  background: var(--accent); cursor: pointer;
  border: 2px solid var(--bg-primary);
}

/* === QUICK PANEL TIERS === */
.quick-divider {
  width: 80%; height: 1px; margin: 4px auto;
  background: var(--border); opacity: 0.5;
}
.quick-btn-fast {
  opacity: 0.7; transform: scale(0.9);
}
.quick-btn-fast:hover { opacity: 1; transform: scale(1); }
.quick-btn-fast .quick-btn-label { font-size: 8px; }

/* === LEGACY 768px block — superseded by comprehensive overhaul below === */
@media (max-width: 768px) {
  #chat-area { padding: 12px 14px; }
}

/* ═══════════════════════════════════════════════════════════════════════
   v0.3.3 — COMPREHENSIVE RESPONSIVE OVERHAUL
   Goal: Every UI element accessible at every breakpoint. Nothing hidden
   without an alternative entry point. Touch targets ≥36px. Safe-area
   insets respected on notched iPhones. iPad portrait/landscape covered.
   ═══════════════════════════════════════════════════════════════════════ */

/* ── Base styles for elements that previously had ZERO CSS ── */

/* Impersonation banner (added v0.3.0) — safe-area-aware (overrides inline style padding) */
#impersonation-banner {
  padding: calc(8px + env(safe-area-inset-top, 0px)) calc(16px + env(safe-area-inset-right, 0px)) 8px calc(16px + env(safe-area-inset-left, 0px)) !important;
}

/* Sidebar Projects section (added v0.3.1) */
.sidebar-section-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 14px 4px;
  font-size: 11px; font-weight: 600;
  color: var(--text-dim); text-transform: uppercase; letter-spacing: 0.5px;
}
.sidebar-section-header button {
  background: rgba(255,255,255,0.05);
  border: 1px solid var(--border);
  color: var(--text-secondary); border-radius: 4px;
  cursor: pointer; font-family: inherit;
  font-size: 10px; padding: 3px 10px;
  min-height: 24px;
}
.sidebar-section-header button:hover {
  background: rgba(139,92,246,0.15); color: #c4b5fd;
}
#projects-section { padding-bottom: 4px; }
#projects-recent-list { padding: 0 8px; }
.project-item:hover { background: rgba(255,255,255,0.04); }

/* Active project pill in input row (added v0.3.1) */
#active-project-pill { transition: background 0.15s; max-width: 200px; overflow: hidden; }
#active-project-pill:hover { background: rgba(139,92,246,0.28); }
#active-project-pill #active-project-name {
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

/* Settings logout (the bottom row uses margin-top:auto in flex-column) */
.settings-nav { display: flex; flex-direction: column; }

/* Admin nav visibility — JS toggles .is-admin-nav-visible on the wrapper div */
#admin-nav-items { display: none; }
#admin-nav-items.is-admin-nav-visible { display: block; }

/* === iPad landscape: ≤1024px ============================================ */
@media (max-width: 1024px) {
  /* Discussion mode bar: 8 buttons (5 targets + Round+1 + New Debate + label) — wrap if narrow */
  #discussion-mode-bar { flex-wrap: wrap; gap: 6px; padding: 8px 12px; }
  #discussion-mode-bar .mode-hint { font-size: 11px; flex-basis: 100%; }

  /* Header buttons: shrink */
  #header-title { font-size: 14px; }

  /* Settings panes have heavy content (Council, Models) — give them more room */
  .settings-panel { max-width: 92vw; }
}

/* === iPad portrait + phone landscape: ≤768px ============================ */
@media (max-width: 768px) {
  /* IMPERSONATION BANNER — wrap text, smaller */
  #impersonation-banner { font-size: 11px; line-height: 1.4; padding-top: calc(6px + env(safe-area-inset-top, 0px)); padding-bottom: 6px; }
  #impersonation-banner button { padding: 4px 10px !important; font-size: 11px !important; min-height: 28px; }

  /* HEADER — keep EVERYTHING accessible. The previous CSS hid mode-toggle and help-guide; that broke Developer access to code mode and removed the help guide entirely. Now we keep both visible, just compact. */
  .mode-toggle { display: flex !important; gap: 2px; padding: 2px; }
  .mode-toggle-btn { padding: 5px 9px; font-size: 10px; min-height: 32px; }
  #help-guide-btn { display: inline-flex !important; padding: 5px 8px; font-size: 11px; min-height: 32px; }
  #toggle-canvas-btn { padding: 5px 8px; font-size: 11px; min-height: 32px; }
  #header { gap: 6px; padding: 0 10px; flex-wrap: nowrap; overflow-x: auto; -webkit-overflow-scrolling: touch; }
  #header-title { display: none; } /* logo + status enough; saves space, sidebar header has the title */

  /* DISCUSSION MODE BAR — 5 target buttons + 2 action buttons must fit */
  #discussion-mode-bar { flex-wrap: wrap; gap: 4px; padding: 6px 10px; align-items: flex-start; }
  #discussion-mode-bar .mode-label { font-size: 10px; flex-basis: 100%; margin-bottom: 4px; font-weight: 600; }
  #discussion-mode-bar .mode-hint { display: none; }
  #discuss-target-wrap { display: flex; flex-wrap: wrap; gap: 4px; }
  .discuss-target-btn { font-size: 10px !important; padding: 6px 9px !important; min-height: 32px; }
  .discuss-target-btn img { width: 12px; height: 12px; }
  #continue-debate-btn, #new-debate-btn { font-size: 10px; padding: 5px 9px; min-height: 32px; }

  /* SIDEBAR PROJECTS */
  .sidebar-section-header { padding: 6px 12px 2px; font-size: 10px; }
  .sidebar-section-header button { font-size: 9px; padding: 2px 7px; min-height: 22px; }
  #projects-recent-list { padding: 0 6px; }

  /* ACTIVE PROJECT PILL — narrower, but still fully readable */
  #active-project-pill { max-width: 130px; font-size: 10px; padding: 3px 8px; }

  /* CHAT INPUT ROW — multiple buttons; allow wrap if cramped.
     Order: utility buttons first, then full-width prompt textarea, then model selector + send.
     This keeps the textarea always full-width and the action buttons (model picker, Send/Stop)
     visually grouped at the bottom-right. */
  #input-row { flex-wrap: wrap; row-gap: 6px; }
  #promptInput { flex: 1 1 100%; order: 50; min-height: 38px; }
  #modelSelectorWrap { order: 60; }
  #stopBtn, #sendBtn { order: 70; }

  /* SETTINGS PANEL — full screen on mobile */
  .settings-panel {
    width: 100vw; max-width: 100vw;
    height: 100vh; height: 100dvh; max-height: 100vh; max-height: 100dvh;
    border-radius: 0; flex-direction: column;
  }

  /* SETTINGS NAV — horizontal scroll instead of flex-wrap (cleaner UX) */
  .settings-nav {
    flex-direction: row !important; flex-wrap: nowrap !important;
    overflow-x: auto; overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
    padding: 6px 8px; gap: 4px;
    width: 100%; min-width: 0;
    border-right: none; border-bottom: 1px solid var(--border);
    flex-shrink: 0;
  }
  .settings-nav-header {
    flex: 0 0 auto; padding: 0 8px 0 0; border-right: 1px solid var(--border);
    margin-right: 4px;
  }
  .settings-nav-btn { flex: 0 0 auto; white-space: nowrap; padding: 8px 12px; font-size: 12px; min-height: 36px; }
  .settings-nav-divider { display: inline-block !important; width: 1px; height: 20px; background: var(--border); margin: 0 4px; align-self: center; flex: 0 0 auto; }
  .settings-nav-label { display: none; }
  #admin-nav-items.is-admin-nav-visible { display: contents !important; } /* admin items flow inline with regular nav buttons on mobile */
  /* Logout row: keep visible inline at the end, no margin-top auto in flex-row */
  .settings-nav > div:last-child {
    margin-top: 0 !important; margin-left: auto !important;
    padding-top: 0 !important; border-top: none !important;
    flex: 0 0 auto;
  }

  /* SETTINGS PANES — full-bleed scroll, prevent iOS auto-zoom on focus */
  .settings-content {
    padding: 16px 12px;
    flex: 1; overflow-y: auto;
    padding-bottom: calc(20px + env(safe-area-inset-bottom, 0px));
  }
  .setting-input, .setting-input-sm, .setting-textarea, select.setting-input, input.setting-input {
    font-size: 16px; /* iOS won't auto-zoom inputs ≥16px */
  }
  .llm-config-card { margin-bottom: 8px; }
  .model-row { flex-direction: column !important; gap: 8px; }

  /* Council pane is tall — extra bottom padding so save buttons clear keyboard/safe-area */
  #pane-council, #pane-models { padding-bottom: 100px; }

  /* IMAGE GEN POPUP — full-width on mobile */
  #imageGenPopup { width: calc(100vw - 20px) !important; left: -10px !important; max-height: 70vh; overflow-y: auto; }

  /* PROJECT DROPDOWN (chat-bar legacy — gone but defensive) + ALL-PROJECTS MODAL */
  #projects-all-modal > div { max-height: 80vh; padding: 16px !important; }

  /* CANVAS PANEL on mobile: full-screen overlay (already in legacy CSS but enforce) */
  #canvas-panel.visible {
    position: fixed; inset: 0; width: 100vw !important; max-width: 100vw;
    z-index: 200;
  }

  /* CONFIRM DIALOG — nicer mobile sizing */
  .confirm-box { width: 90vw; max-width: 360px; padding: 18px; }

  /* HELP GUIDE MODAL — stack vertically (was side-nav at 180px which crowded the content) */
  .help-modal { width: 100vw !important; max-width: 100vw; height: 100vh; height: 100dvh; max-height: 100vh; max-height: 100dvh; border-radius: 0; }
  .help-layout { flex-direction: column; }
  .help-nav {
    width: 100%; min-width: 100%; flex-direction: row; flex-wrap: nowrap;
    overflow-x: auto; overflow-y: hidden; padding: 8px;
    border-right: none; border-bottom: 1px solid var(--border);
    -webkit-overflow-scrolling: touch;
  }
  .help-nav-btn { flex: 0 0 auto; white-space: nowrap; padding: 8px 14px; min-height: 36px; }
  .help-content { padding: 16px; flex: 1; overflow-y: auto; }
  .help-close { padding: 8px 12px !important; font-size: 26px !important; min-width: 40px; min-height: 40px; }
}

/* === Small phones: ≤480px ================================================ */
@media (max-width: 480px) {
  /* Banner — most compact */
  #impersonation-banner { font-size: 10px; padding-left: 10px; padding-right: 10px; }
  #impersonation-banner button { font-size: 10px !important; padding: 3px 8px !important; }

  /* Header status pill removed for space; everything else stays accessible */
  .header-status { display: none; }
  /* OVERRIDE the legacy "display:none" rules for canvas — keep accessible via icon */
  #toggle-canvas-btn { display: inline-flex !important; padding: 4px 6px; font-size: 11px; }
  #toggle-canvas-btn .canvas-count { font-size: 9px; padding: 1px 5px; }

  /* Active project pill */
  #active-project-pill { max-width: 100px; padding: 2px 6px; font-size: 9px; }
  #active-project-pill svg { width: 10px; height: 10px; }

  /* Discussion bar buttons — tightest */
  .discuss-target-btn { font-size: 9px !important; padding: 5px 7px !important; }
  .discuss-target-btn img { width: 10px; height: 10px; }
  #continue-debate-btn, #new-debate-btn { font-size: 9px; padding: 4px 8px; }

  /* Settings nav — smaller buttons; KEEP nav-header visible (it has the X close button) */
  .settings-nav-btn { padding: 6px 9px; font-size: 11px; min-height: 34px; }
  .settings-nav-title-wrap { display: none; } /* hide ⚙️ Settings label on tiny phones; X is enough */
  .settings-nav-header { padding: 0 4px !important; gap: 0 !important; }
  .settings-close { font-size: 22px !important; padding: 4px 8px !important; min-width: 36px; min-height: 36px; }

  /* Welcome screen — keep readable */
  #welcome p { max-width: 92vw; }

  /* Model selector dropdown — full width */
  .custom-select-dropdown { left: 0; right: 0; max-width: 100vw; min-width: 0; }
  .sel-group-label { font-size: 9px; padding: 6px 10px 2px; }
  .sel-option { padding: 8px 10px; font-size: 11px; }
  .sel-option .sel-logo { width: 14px; height: 14px; }

  /* Image gen popup full-bleed */
  #imageGenPopup { width: calc(100vw - 16px) !important; left: -8px !important; }
  #imageGenPopup .setting-input-sm { font-size: 14px !important; padding: 6px 8px !important; }

  /* Quick model toggle (sidebar) — already mostly hidden, defensive sizing */
  .quick-model-toggle .quick-tier-badge { display: none; }
}

/* === Phone landscape (short height) ===================================== */
@media (max-height: 500px) and (orientation: landscape) {
  #header { height: 40px; }
  #welcome { padding: 8px; }
  #welcome-logo { width: 36px; height: 36px; }
  #welcome h1 { font-size: 14px; margin: 2px 0; }
  #welcome p { font-size: 11px; line-height: 1.3; }
  #input-area { padding: 4px 8px; padding-bottom: calc(4px + env(safe-area-inset-bottom, 0px)); }
  /* Discussion mode bar — single row by giving label less space */
  #discussion-mode-bar .mode-label { display: none; }
  #discussion-mode-bar { padding: 4px 10px; }
  /* Settings: shorter panes */
  .settings-content { padding: 10px 12px; }
  /* Help modal */
  .help-modal { max-height: 92vh; }
}

/* === Touch-coarse devices (any width) =================================== */
@media (hover: none) and (pointer: coarse) {
  /* Minimum touch targets per Apple HIG */
  .session-action-btn,
  .discuss-target-btn,
  .input-btn,
  .mode-toggle-btn,
  .header-btn,
  .settings-nav-btn,
  .quick-btn,
  #stopBtn,
  #sendBtn,
  .refresh-models-btn { min-width: 32px; min-height: 36px; }
  /* No long-press text selection on tap targets */
  button, .sel-option, .session-item, .project-item {
    -webkit-user-select: none; user-select: none; -webkit-touch-callout: none;
  }
  /* iOS-style momentum scrolling on long lists */
  .settings-content, #chat-area, .canvas-code-area, #projects-recent-list, .help-content,
  .custom-select-dropdown, #projects-all-list {
    -webkit-overflow-scrolling: touch;
  }
}

/* === Notched-device safe areas (covers all the iPhone Pro Max-class) ==== */
@supports (padding: env(safe-area-inset-bottom)) {
  #input-area { padding-bottom: max(8px, env(safe-area-inset-bottom)); }
  #sidebar-footer { padding-bottom: max(12px, env(safe-area-inset-bottom)); }
}

/* === SESSION FILES BAR === */
#session-files-bar {
  display: flex; align-items: center; gap: 8px;
  padding: 6px 20px; background: var(--bg-tertiary);
  border-bottom: 1px solid var(--border); flex-wrap: wrap;
  font-size: 12px;
}
.files-label { color: var(--text-secondary); flex-shrink: 0; }
.session-file-chip {
  display: inline-flex; align-items: center; gap: 4px;
  background: var(--accent-dim); border: 1px solid var(--border-active);
  border-radius: 20px; padding: 3px 10px; font-size: 11px; color: var(--text-primary);
}
.session-file-del {
  background: none; border: none; color: var(--danger); cursor: pointer;
  font-size: 12px; padding: 0 2px; line-height: 1;
}
.session-file-add {
  display: inline-flex; align-items: center; justify-content: center;
  width: 24px; height: 24px; border-radius: 50%;
  background: var(--bg-primary); border: 1px dashed var(--border);
  color: var(--text-secondary); font-size: 14px; cursor: pointer;
  transition: all var(--transition);
}
.session-file-add:hover { border-color: var(--accent); color: var(--accent); }

/* === UPLOAD AREA === */
.upload-area {
  display: block; padding: 14px; text-align: center;
  background: var(--bg-tertiary); border: 1px dashed var(--border);
  border-radius: var(--radius-md); cursor: pointer;
  font-size: 12px; color: var(--text-secondary);
  transition: all var(--transition);
}
.upload-area:hover { border-color: var(--accent); color: var(--text-primary); }

/* === DEBATE STAGE CARDS === */
.debate-stage {
  margin: 12px 0; border: 1px solid var(--border); border-radius: var(--radius-md);
  background: var(--bg-secondary); overflow: hidden;
}
.debate-stage-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 16px; background: var(--bg-tertiary);
  border-bottom: 1px solid var(--border); cursor: pointer;
  user-select: none;
}
.debate-stage-header:hover { background: var(--bg-hover, rgba(255,255,255,0.03)); }
.debate-stage-title {
  font-size: var(--fs-sm, 13px); font-weight: 600; color: var(--text-secondary);
  text-transform: uppercase; letter-spacing: 0.04em;
}
.debate-stage-toggle {
  font-size: 11px; color: var(--text-dim); transition: transform 0.2s;
}
.debate-stage.collapsed .debate-stage-body { display: none; }
.debate-stage.collapsed .debate-stage-toggle { transform: rotate(-90deg); }
.debate-stage-body { padding: 0; }

/* Individual model card within a stage */
.debate-card {
  border-bottom: 1px solid var(--border);
}
.debate-card:last-child { border-bottom: none; }
.debate-card-header {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 16px; cursor: pointer; user-select: none;
  transition: background 0.1s;
}
.debate-card-header:hover { background: rgba(255,255,255,0.02); }
.debate-card-avatar {
  width: 22px; height: 22px; border-radius: 6px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  background: var(--bg-tertiary); border: 1px solid var(--border);
  overflow: hidden; padding: 3px;
}
.debate-card-avatar img { width: 100%; height: 100%; object-fit: contain; }
.debate-card-name {
  font-size: var(--fs-sm, 13px); font-weight: 500; color: var(--text-primary);
  flex: 1;
}
.debate-card-meta {
  font-size: 11px; color: var(--text-dim);
}
.debate-card-confidence {
  font-size: 11px; font-weight: 600; padding: 1px 6px;
  border-radius: 10px; background: var(--accent-dim); color: var(--accent-hover);
}
.debate-card-arrow {
  font-size: 10px; color: var(--text-dim); transition: transform 0.2s;
}
.debate-card.collapsed .debate-card-content { display: none; }
.debate-card.collapsed .debate-card-arrow { transform: rotate(-90deg); }
.debate-card-content {
  padding: 8px 16px 12px 48px;
  font-size: var(--fs-base, 14px); line-height: 1.7; color: var(--text-primary);
  word-break: break-word;
}
.debate-card-content pre {
  overflow-x: auto; background: var(--bg-primary);
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 10px; margin: 8px 0; font-size: 12px;
  font-family: 'JetBrains Mono', monospace;
}
.debate-card-content code {
  font-family: 'JetBrains Mono', monospace; font-size: 12px;
  background: var(--bg-primary); padding: 1px 5px; border-radius: 3px;
}
.debate-card-content pre code { background: none; padding: 0; }
.debate-card-preview {
  padding: 0 16px 8px 48px; font-size: var(--fs-sm, 12px);
  color: var(--text-dim); line-height: 1.4;
  max-height: 40px; overflow: hidden;
}
.debate-card.collapsed .debate-card-preview { display: block; }
.debate-card:not(.collapsed) .debate-card-preview { display: none; }

/* Arbiter card — always prominent */
.debate-stage.arbiter { border-color: var(--accent-dim); }
.debate-stage.arbiter .debate-stage-header {
  background: var(--accent-dim);
}
.debate-stage.arbiter .debate-stage-title { color: var(--accent-hover); }

/* Streaming indicator on cards */
.debate-card.streaming .debate-card-name::after {
  content: ''; display: inline-block; width: 6px; height: 6px;
  border-radius: 50%; background: var(--accent); margin-left: 8px;
  animation: pulse-dot 1.5s infinite;
}

/* === DISCUSSION MODE INDICATOR === */
#discussion-mode-bar {
  display: none; align-items: center; gap: 8px;
  padding: 6px 16px;
  background: rgba(99, 102, 241, 0.06);
  border-bottom: 1px solid var(--border);
  font-size: 12px; color: var(--text-secondary);
}
#discussion-mode-bar.active { display: flex; }
#discussion-mode-bar .mode-label {
  font-weight: 500; color: var(--accent-hover);
}
#discussion-mode-bar .mode-hint {
  color: var(--text-dim); font-size: 11px;
}
#new-debate-btn {
  margin-left: auto; padding: 4px 12px;
  background: var(--bg-tertiary); border: 1px solid var(--border);
  border-radius: var(--radius-sm); color: var(--text-secondary);
  font-size: 11px; font-weight: 500; cursor: pointer;
  font-family: inherit; transition: all var(--transition);
}
#new-debate-btn:hover { color: var(--text-primary); border-color: var(--accent); }

/* Discussion target selector */
#discuss-target-wrap {
  display: none; align-items: center; gap: 6px;
}
#discuss-target-wrap.active { display: flex; }
.discuss-target-btn {
  padding: 3px 8px; border-radius: var(--radius-sm);
  background: none; border: 1px solid var(--border);
  color: var(--text-dim); font-size: 11px; cursor: pointer;
  font-family: inherit; transition: all var(--transition);
  display: inline-flex; align-items: center; gap: 4px;
}
.discuss-target-btn:hover { border-color: var(--text-secondary); color: var(--text-secondary); }
.discuss-target-btn.active {
  border-color: var(--accent); color: #fff;
  background: var(--accent); /* solid accent fill — much more visible than the prior dim version */
  box-shadow: 0 0 0 2px rgba(139, 92, 246, 0.25);
  font-weight: 600;
}
.discuss-target-btn img { width: 14px; height: 14px; }

/* === TRANSCRIPT FILTER ===
   When chat-area has data-filter set (claude/chatgpt/gemini/grok/deepseek), hide AI
   messages from non-matching providers. Human + system messages stay visible regardless. */
/* Descendant selector + !important so filter wins over .msg-row > .msg.system
   display: flex layout rules that would otherwise re-show the card. */
#chat-area[data-filter="claude"]   .msg[data-provider]:not([data-provider="claude"]):not([data-provider="human"]):not([data-provider="system"]) { display: none !important; }
#chat-area[data-filter="chatgpt"]  .msg[data-provider]:not([data-provider="chatgpt"]):not([data-provider="human"]):not([data-provider="system"]) { display: none !important; }
#chat-area[data-filter="gemini"]   .msg[data-provider]:not([data-provider="gemini"]):not([data-provider="human"]):not([data-provider="system"]) { display: none !important; }
#chat-area[data-filter="grok"]     .msg[data-provider]:not([data-provider="grok"]):not([data-provider="human"]):not([data-provider="system"]) { display: none !important; }
#chat-area[data-filter="deepseek"] .msg[data-provider]:not([data-provider="deepseek"]):not([data-provider="human"]):not([data-provider="system"]) { display: none !important; }
/* Same filter for live debate-cards (separate DOM structure from .msg cards). */
#chat-area[data-filter="claude"]   .debate-card[data-provider]:not([data-provider="claude"]) { display: none !important; }
#chat-area[data-filter="chatgpt"]  .debate-card[data-provider]:not([data-provider="chatgpt"]) { display: none !important; }
#chat-area[data-filter="gemini"]   .debate-card[data-provider]:not([data-provider="gemini"]) { display: none !important; }
#chat-area[data-filter="grok"]     .debate-card[data-provider]:not([data-provider="grok"]) { display: none !important; }
#chat-area[data-filter="deepseek"] .debate-card[data-provider]:not([data-provider="deepseek"]) { display: none !important; }

/* Purple top-stripe removed — filter status text + highlighted button already
   signal that a filter is active, the stripe was visual noise. */
@keyframes fadeOut {
  0%, 60% { opacity: 1; transform: translateX(-50%) translateY(0); }
  100% { opacity: 0; transform: translateX(-50%) translateY(-8px); }
}

/* Mode toggle refinement */
.mode-toggle {
  display: flex; border: 1px solid var(--border); border-radius: var(--radius-sm);
  overflow: hidden;
}
.mode-toggle-btn {
  padding: 4px 12px; background: none; border: none;
  color: var(--text-dim); font-size: 11px; font-weight: 500;
  cursor: pointer; transition: all var(--transition);
  font-family: inherit;
}
.mode-toggle-btn.active {
  background: var(--accent-dim); color: var(--accent-hover);
}
.mode-toggle-btn.active[data-mode="code"] {
  background: rgba(234, 179, 8, 0.12); color: #eab308;
}
.mode-toggle-btn:hover:not(.active) { color: var(--text-secondary); }

/* === END OF FILE (FILENAME: /var/www/vhosts/pokepapi.com/council/public/css/style.css) === */
