/* ============================================
   Zando AI - Claude-Style Light Theme
   ============================================ */

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

/* --- CSS Variables (Claude-inspired) --- */
:root {
  /* === Light backgrounds === */
  --bg: #FFFFFF;
  --bg-sidebar: #F7F7F8;
  --bg-input: #FFFFFF;
  --bg-hover: #F1F1F3;
  --bg-active: #E7E7E9;
  --bg-card: #FFFFFF;
  --bg-elevated: #FFFFFF;
  --bg-surface: #F7F7F8;

  /* === Borders === */
  --border: #E7E7E9;
  --border-subtle: #F1F1F3;
  --border-hover: #D1D1D6;

  /* === Text hierarchy === */
  --text: #1F2024;
  --text-primary: #1F2024;
  --text-secondary: #6F6F78;
  --text-muted: #8B8B93;
  --text-dim: #A8A8B0;
  --text-tertiary: #A8A8B0;

  /* === Accent (Claude orange/coral) === */
  --accent: #D97757;
  --accent-hover: #C86647;
  --accent-glow: rgba(217, 119, 87, 0.15);
  --accent-soft: rgba(217, 119, 87, 0.08);
  --accent-gradient: linear-gradient(135deg, #D97757, #E89B7B);

  /* === Message colors === */
  --msg-user: #F0F0F2;
  --msg-assistant: #FFFFFF;

  /* === Semantic colors === */
  --blue: #4B7BE5;
  --danger: #E5484D;
  --danger-soft: rgba(229, 72, 77, 0.08);
  --green: #30A46C;
  --green-soft: rgba(48, 164, 108, 0.08);
  --warning: #F5A623;
  --warning-soft: rgba(245, 166, 35, 0.08);
  --info: #3E9ED1;
  --info-soft: rgba(62, 158, 209, 0.08);

  /* === Shadows === */
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.04);
  --shadow-md: 0 2px 8px rgba(0,0,0,0.06);
  --shadow-lg: 0 4px 16px rgba(0,0,0,0.08);

  /* === Typography === */
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-mono: 'JetBrains Mono', 'Fira Code', monospace;

  /* === Spacing === */
  --radius-sm: 6px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 20px;
}

/* --- Dark Mode Variables (Soft Dark - Not Pure Black) --- */
[data-theme="dark"] {
  /* === Dark backgrounds (soft, not pure black) === */
  --bg: #1E1E23;
  --bg-sidebar: #16161A;
  --bg-input: #25252A;
  --bg-hover: #2C2C32;
  --bg-active: #34343A;
  --bg-card: #25252A;
  --bg-elevated: #2C2C32;
  --bg-surface: #25252A;

  /* === Borders === */
  --border: #34343A;
  --border-subtle: #2C2C32;
  --border-hover: #42424A;

  /* === Text hierarchy === */
  --text: #E8E8EA;
  --text-primary: #F2F2F4;
  --text-secondary: #C8C8D0;
  --text-muted: #A8A8B0;
  --text-dim: #8B8B93;
  --text-tertiary: #B0B0B8;

  /* === Accent (same but brighter for dark) === */
  --accent: #E89B7B;
  --accent-hover: #F0AE92;
  --accent-glow: rgba(232, 155, 123, 0.2);
  --accent-soft: rgba(232, 155, 123, 0.12);
  --accent-gradient: linear-gradient(135deg, #E89B7B, #F0AE92);

  /* === Message colors === */
  --msg-user: #2C2C32;
  --msg-assistant: #25252A;

  /* === Semantic colors === */
  --blue: #5B8EF5;
  --danger: #F06368;
  --danger-soft: rgba(240, 99, 104, 0.12);
  --green: #3DB878;
  --green-soft: rgba(61, 184, 120, 0.12);
  --warning: #FFB84D;
  --warning-soft: rgba(255, 184, 77, 0.12);
  --info: #52AEE0;
  --info-soft: rgba(82, 174, 224, 0.12);

  /* === Shadows (stronger for dark mode) === */
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.3);
  --shadow-md: 0 2px 8px rgba(0,0,0,0.4);
  --shadow-lg: 0 4px 16px rgba(0,0,0,0.5);
}


/* --- Global Reset --- */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html, body {
  height: 100%;
  font-family: var(--font-sans);
  font-size: 15px;
  line-height: 1.6;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* --- Scrollbar --- */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

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

::-webkit-scrollbar-thumb {
  background: var(--border-hover);
  border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--text-muted);
}

/* --- App Container --- */
.app-container {
  display: flex;
  height: 100vh;
  overflow: hidden;
}

/* --- Sidebar --- */
.sidebar {
  width: 260px;
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  transition: width 0.3s ease, margin-left 0.3s ease, transform 0.3s ease;
  overflow: hidden;
  flex-shrink: 0;
}

.sidebar.closed {
  width: 0;
  margin-left: 0;
  border-right: none;
}

.sidebar-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}

/* Search box - elevated with shadow */
.sidebar-search {
  padding: 12px 16px 16px;
}
.search-input {
  width: 100%;
  padding: 11px 14px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 10px;
  font-size: 13px;
  color: var(--text);
  outline: none;
  box-sizing: border-box;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.12), 0 1px 3px rgba(0, 0, 0, 0.06);
  transition: box-shadow 0.2s, border-color 0.2s;
}
.search-input:focus {
  border-color: var(--accent);
  box-shadow: 0 4px 12px rgba(217, 119, 87, 0.15), 0 1px 3px rgba(0, 0, 0, 0.06);
}
.search-input::placeholder {
  color: var(--text-muted);
}

.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 18px;
  font-weight: 600;
  color: var(--text);
}

.sidebar-logo-icon {
  width: 28px;
  height: 28px;
  background: var(--accent-gradient);
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-weight: 700;
  font-size: 16px;
}

.new-chat-btn {
  width: 100%;
  padding: 10px 16px;
  margin-top: 12px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  color: var(--text);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
  transition: all 0.2s;
}

.new-chat-btn:hover {
  background: var(--bg-hover);
  border-color: var(--border-hover);
}

.new-chat-btn svg {
  width: 18px;
  height: 18px;
}

/* --- Session List --- */
.session-list {
  flex: 1;
  overflow-y: auto;
  padding: 12px;
}

.session-item {
  padding: 10px 12px;
  margin-bottom: 4px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.15s;
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--text-secondary);
  font-size: 14px;
}

.session-item:hover {
  background: var(--bg-hover);
  color: var(--text);
}

.session-item.active {
  background: var(--bg-active);
  color: var(--text);
  font-weight: 500;
}

.session-item-icon {
  width: 18px;
  height: 18px;
  opacity: 0.6;
}

.session-item-text {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--text-secondary);
  font-size: 13px;
}

/* 3-dot menu button */
.session-item-menu {
  opacity: 0.3;
  width: 24px;
  height: 24px;
  min-width: 24px;
  border: none;
  background: transparent;
  border-radius: 6px;
  cursor: pointer;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s;
  padding: 0;
}

.session-item:hover .session-item-menu {
  opacity: 1;
}

.session-item-menu:hover {
  background: var(--bg-hover);
  color: var(--text);
}

/* Section headers (Bertanda bintang / Terbaru) */
.history-section-header {
  padding: 14px 12px 6px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 6px;
  user-select: none;
  border-top: 1px solid var(--border);
  margin-top: 8px;
}

/* Context menu popup */
.session-context-menu {
  position: fixed;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 8px 30px rgba(0,0,0,0.12), 0 2px 8px rgba(0,0,0,0.06);
  padding: 6px;
  min-width: 170px;
  z-index: 9999;
  animation: ctxFadeIn 0.12s ease-out;
}

@keyframes ctxFadeIn {
  from { opacity: 0; transform: scale(0.95) translateY(-4px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}

.ctx-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 8px 12px;
  border: none;
  background: transparent;
  border-radius: 8px;
  cursor: pointer;
  font-size: 13px;
  color: var(--text);
  transition: background 0.1s;
  text-align: left;
}

.ctx-item:hover {
  background: var(--bg-hover);
}

.ctx-item svg {
  flex-shrink: 0;
}

.ctx-danger {
  color: #dc2626;
}

.ctx-danger:hover {
  background: #fef2f2;
}

/* --- Sidebar Footer --- */
.sidebar-footer {
  padding: 16px 20px;
  border-top: 2px solid var(--border);
  background: var(--bg-sidebar);
}

.user-profile {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px;
  border-radius: var(--radius-sm);
  transition: background 0.15s;
}

.user-profile:hover {
  background: var(--bg-hover);
}

.user-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--accent-gradient);
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-weight: 600;
  font-size: 14px;
}

.user-info {
  flex: 1;
  overflow: hidden;
}

.user-name {
  font-size: 14px;
  font-weight: 500;
  color: var(--text);
}

.user-plan {
  font-size: 12px;
  color: var(--text-muted);
}

/* --- Main Content --- */
.main-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--bg);
}

/* --- Top Bar --- */
.top-bar {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--bg);
  flex-shrink: 0;
}

.top-bar-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--text);
  text-align: left;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 6px;
  padding: 4px 8px;
  outline: none;
  transition: all 0.2s;
  flex: 1;
  min-width: 0;
  font-family: inherit;
}
.top-bar-title:not([readonly]) {
  border-color: var(--border);
  background: var(--bg-surface, #fff);
  cursor: text;
}
.top-bar-title:hover {
  border-color: var(--border);
}
.top-bar-title:focus {
  border-color: var(--accent);
  background: var(--bg-surface, #fff);
}

/* --- Messages Container --- */
.messages-container {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 24px;
  padding-bottom: 32px;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

/* --- Message Rows --- */
.msg-row {
  display: flex;
  gap: 16px;
  max-width: 750px;
  width: 100%;
  margin: 0 auto;
}

.msg-user {
  display: flex;
  flex-direction: row-reverse;
  gap: 12px;
  align-items: flex-start;
  max-width: 750px;
  width: 100%;
  margin: 0 auto;
  justify-content: flex-start;
}

.msg-ai {
  display: flex;
  gap: 16px;
  max-width: 900px;
  width: 100%;
  margin: 0 auto;
}

.msg-ai-inner {
  display: flex;
  gap: 16px;
  flex: 1;
  min-width: 0;
}

/* --- Message Avatars --- */
.msg-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 14px;
}

.msg-avatar-assistant {
  background: var(--accent-gradient);
  color: white;
}

.msg-avatar-user {
  background: var(--msg-user);
  color: var(--text);
}

.msg-ai-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 14px;
  background: var(--accent-gradient);
  color: white;
}

.msg-user-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 14px;
  background: var(--msg-user);
  color: var(--text);
  margin-top: 4px;
}

/* --- Message Bubbles --- */
.msg-assistant-bubble {
  flex: 1;
  background: var(--msg-assistant);
  padding: 4px 0;
  border-radius: var(--radius-md);
  line-height: 1.7;
  color: var(--text);
}

.msg-ai-content {
  flex: 1;
  min-width: 0;
  overflow-x: hidden;
}

.msg-ai-text {
  line-height: 1.7;
  color: var(--text);
  overflow-x: hidden;
  word-wrap: break-word;
  overflow-wrap: break-word;
  min-width: 0;
  max-width: 100%;
}

/* Message row spacing */
.msg-ai + .msg-ai,
.msg-ai + .msg-user,
.msg-user + .msg-ai,
.msg-user + .msg-user {
  margin-top: 20px;
}

.msg-ai-actions {
  display: flex;
  gap: 8px;
  margin-top: 10px;
  opacity: 0.4;
  transition: opacity 0.2s ease;
}

.msg-ai:hover .msg-ai-actions {
  opacity: 1;
}

/* Code copy button (inside code blocks) */
.code-copy-btn {
  position: absolute;
  top: 8px;
  right: 8px;
  padding: 4px 10px;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 6px;
  color: rgba(255, 255, 255, 0.7);
  font-size: 11px;
  font-family: inherit;
  cursor: pointer;
  transition: all 0.15s;
  backdrop-filter: blur(4px);
  z-index: 2;
}

.code-copy-btn:hover {
  background: rgba(255, 255, 255, 0.2);
  color: #fff;
}

/* Message action buttons (Salin, Ulangi, etc.) */
.msg-copy-btn,
.msg-action-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 6px 12px;
  background: var(--bg-surface, #F7F7F8);
  border: 1px solid var(--border, #E7E7E9);
  border-radius: 8px;
  color: var(--text-secondary, #6F6F78);
  font-size: 12px;
  font-family: inherit;
  cursor: pointer;
  transition: all 0.15s;
}

.msg-copy-btn:hover,
.msg-action-btn:hover {
  background: var(--bg-hover, #EFEFEF);
  color: var(--text, #1F2024);
  border-color: var(--border-strong, #CDCDD0);
}

.msg-copy-btn svg,
.msg-action-btn svg {
  flex-shrink: 0;
}

.msg-user-bubble {
  background: var(--msg-user);
  padding: 14px 18px;
  border-radius: var(--radius-lg);
  border-top-right-radius: 4px;
  max-width: 70%;
  line-height: 1.6;
  color: var(--text);
}

/* --- Message Content --- */
.msg-assistant-bubble p {
  margin-bottom: 14px;
}

.msg-assistant-bubble p:last-child {
  margin-bottom: 0;
}

.msg-user-bubble p {
  margin-bottom: 8px;
}

.msg-user-bubble p:last-child {
  margin-bottom: 0;
}

/* --- Markdown Headings (AI messages) --- */
.msg-ai-text h1 {
  font-size: 1.5em;
  font-weight: 700;
  margin: 24px 0 12px 0;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
  color: var(--text-primary);
}

.msg-ai-text h2 {
  font-size: 1.3em;
  font-weight: 600;
  margin: 20px 0 10px 0;
  color: var(--text-primary);
}

.msg-ai-text h3 {
  font-size: 1.15em;
  font-weight: 600;
  margin: 18px 0 8px 0;
  color: var(--text-primary);
}

.msg-ai-text h4, .msg-ai-text h5, .msg-ai-text h6 {
  font-size: 1em;
  font-weight: 600;
  margin: 16px 0 6px 0;
  color: var(--text-secondary);
}

/* First heading no top margin */
.msg-ai-text > h1:first-child,
.msg-ai-text > h2:first-child,
.msg-ai-text > h3:first-child {
  margin-top: 0;
}

/* Lists */
.msg-ai-text ul, .msg-ai-text ol {
  margin: 8px 0 14px 0;
  padding-left: 24px;
}

.msg-ai-text li {
  margin-bottom: 6px;
  line-height: 1.6;
}

.msg-ai-text li:last-child {
  margin-bottom: 0;
}

/* Blockquote */
.msg-ai-text blockquote {
  border-left: 3px solid var(--accent);
  padding: 8px 16px;
  margin: 12px 0;
  background: var(--accent-soft);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  color: var(--text-secondary);
}

/* Tables */
.msg-ai-text table {
  width: 100%;
  border-collapse: collapse;
  margin: 14px 0;
  font-size: 14px;
  display: block;
  overflow-x: auto;
  max-width: 100%;
}

.msg-ai-text th {
  background: var(--bg-surface);
  font-weight: 600;
  text-align: left;
  padding: 10px 12px;
  border: 1px solid var(--border);
}

.msg-ai-text td {
  padding: 8px 12px;
  border: 1px solid var(--border);
}

.msg-ai-text hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 20px 0;
}

/* Artifact document tables */
.artifact-document table {
  width: 100%;
  border-collapse: collapse;
  margin: 14px 0;
  font-size: 14px;
  display: block;
  overflow-x: auto;
  max-width: 100%;
}

.artifact-document th {
  background: var(--bg-surface);
  font-weight: 600;
  text-align: left;
  padding: 10px 12px;
  border: 1px solid var(--border);
}

.artifact-document td {
  padding: 8px 12px;
  border: 1px solid var(--border);
}

.artifact-document hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 20px 0;
}

.artifact-document h1,
.artifact-document h2,
.artifact-document h3 {
  margin-top: 24px;
  margin-bottom: 12px;
  font-weight: 600;
  line-height: 1.3;
}

.artifact-document h1 {
  font-size: 24px;
}

.artifact-document h2 {
  font-size: 20px;
}

.artifact-document h3 {
  font-size: 17px;
}

.artifact-document p {
  margin-bottom: 12px;
  line-height: 1.6;
}

.artifact-document ul,
.artifact-document ol {
  margin: 12px 0;
  padding-left: 24px;
}

.artifact-document li {
  margin-bottom: 6px;
}

.artifact-document strong {
  font-weight: 600;
}

/* --- Code Blocks --- */
.msg-ai-text pre,
.msg-user-bubble pre {
  background: #1E1E2E;
  color: #D4D4D4;
  padding: 16px 18px;
  border-radius: var(--radius-md);
  overflow-x: auto;
  max-width: 100%;
  margin: 14px 0;
  font-family: var(--font-mono);
  font-size: 13px;
  line-height: 1.6;
  border: 1px solid rgba(255,255,255,0.06);
  box-sizing: border-box;
}

.msg-ai-text code,
.msg-user-bubble code {
  background: var(--bg-surface);
  padding: 2px 7px;
  border-radius: 5px;
  font-family: var(--font-mono);
  font-size: 13px;
  border: 1px solid var(--border-subtle);
}

.msg-ai-text pre code,
.msg-user-bubble pre code {
  background: transparent;
  padding: 0;
  border: none;
}

/* --- Message Meta --- */
.msg-timestamp {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 6px;
}

.msg-ai-actions {
  display: flex;
  gap: 8px;
  margin-top: 10px;
  opacity: 0.4;
  transition: opacity 0.2s ease;
}

.msg-ai:hover .msg-ai-actions {
  opacity: 1;
}

.msg-action-btn {
  padding: 6px 10px;
  background: var(--bg-hover);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-size: 12px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 4px;
  transition: all 0.15s;
}

.msg-action-btn:hover {
  background: var(--bg-active);
  color: var(--text);
}

/* Like/Dislike active states - OBVIOUS color change */
.msg-action-btn.liked {
  color: #16a34a !important;
  background: rgba(22, 163, 74, 0.1) !important;
  border-color: #16a34a !important;
  fill: #16a34a !important;
}

.msg-action-btn.liked svg {
  fill: #16a34a;
  stroke: #16a34a;
}

.msg-action-btn.disliked {
  color: #dc2626 !important;
  background: rgba(220, 38, 38, 0.1) !important;
  border-color: #dc2626 !important;
}

.msg-action-btn.disliked svg {
  fill: #dc2626;
  stroke: #dc2626;
}

/* Token count - more visible */
.msg-token-info {
  font-size: 11px;
  color: var(--text-secondary, #666);
  padding: 4px 10px;
  background: var(--bg-surface, #F7F7F8);
  border: 1px solid var(--border);
  border-radius: 12px;
  font-weight: 500;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.msg-token-info::before {
  content: "📊";
  font-size: 10px;
}
  font-weight: 500;
  letter-spacing: 0.02em;
}

/* --- User Images --- */
.msg-user-image {
  max-width: 240px;
  max-height: 240px;
  width: auto;
  height: auto;
  object-fit: contain;
  border-radius: var(--radius-md);
  margin-bottom: 8px;
  display: block;
  cursor: pointer;
  transition: opacity 0.2s, transform 0.2s;
}

.msg-user-image:hover {
  opacity: 0.85;
  transform: scale(1.02);
}

/* --- Input Area --- */
.input-area {
  padding: 12px 16px;
  background: var(--bg);
  flex-shrink: 0;
}

.input-wrapper {
  max-width: 900px;
  margin: 0 auto;
  background: var(--bg-input);
  border: 1px solid #444 !important;
  border-radius: var(--radius-lg);
  box-shadow: none !important;
  transition: all 0.2s;
}

.input-wrapper:focus-within {
  border-color: #444 !important;
  box-shadow: none !important;
}

.input-top {
  display: flex;
  align-items: flex-end;
  padding: 12px 16px;
  gap: 12px;
}

.message-input {
  flex: 1;
  border: none;
  outline: none;
  background: transparent;
  font-family: var(--font-sans);
  font-size: 15px;
  line-height: 1.6;
  color: var(--text);
  resize: none;
  max-height: 200px;
}

.message-input::placeholder {
  color: var(--text-muted);
}

.input-bottom {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 16px 12px;
  border-top: 1px solid var(--border-subtle);
}

.input-controls {
  display: flex;
  gap: 8px;
  align-items: center;
}

.input-btn {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  border: none;
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s;
}

.input-btn:hover {
  background: var(--bg-hover);
  color: var(--text);
}

.input-btn svg {
  width: 18px;
  height: 18px;
}

/* --- Model Selector --- */
.model-selector {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  background: var(--bg-surface, #F7F7F8);
  border: 1px solid var(--border);
  border-radius: 20px;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-secondary, #666);
  cursor: pointer;
  transition: all 0.2s ease;
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg width='10' height='6' viewBox='0 0 10 6' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M1 1l4 4 4-4' stroke='%238B8B93' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 32px;
  max-width: 220px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.model-selector:hover {
  background-color: var(--bg-hover, #EFEFEF);
  color: var(--text);
  border-color: var(--border-strong, #CDCDD0);
}

.model-selector:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(217, 119, 87, 0.15);
}

.model-selector-icon {
  width: 16px;
  height: 16px;
}

.model-selector-arrow {
  width: 14px;
  height: 14px;
  color: var(--text-muted);
}

/* --- Send Button --- */
.send-btn {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: none;
  background: var(--accent);
  color: white;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s;
}

.send-btn:hover {
  background: var(--accent-hover);
  transform: scale(1.05);
}

.send-btn:disabled {
  background: var(--bg-hover);
  color: var(--text-muted);
  cursor: not-allowed;
  transform: none;
}

.send-btn.active {
  background: var(--accent);
  color: white;
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(232, 115, 78, 0.3);
}

.send-btn.active:hover {
  background: var(--accent-hover);
  transform: scale(1.08);
  box-shadow: 0 3px 12px rgba(232, 115, 78, 0.4);
}

.send-btn svg {
  width: 18px;
  height: 18px;
}

/* --- Typing Indicator --- */
.typing-indicator {
  display: flex;
  gap: 6px;
  padding: 12px 0;
  align-items: center;
}

.typing-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--accent);
  animation: typingWave 1.4s ease-in-out infinite;
  opacity: 0.6;
}

.typing-dot:nth-child(2) {
  animation-delay: 0.2s;
}

.typing-dot:nth-child(3) {
  animation-delay: 0.4s;
}

@keyframes typingWave {
  0%, 60%, 100% {
    opacity: 0.3;
    transform: translateY(0) scale(0.9);
  }
  30% {
    opacity: 1;
    transform: translateY(-10px) scale(1.1);
  }
}

/* --- Welcome Screen --- */
.welcome-screen {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  padding: 40px 24px;
  text-align: center;
}

.welcome-logo {
  width: 64px;
  height: 64px;
  background: var(--accent-gradient);
  border-radius: var(--radius-lg);
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-size: 32px;
  font-weight: 700;
  margin-bottom: 24px;
}

.welcome-title {
  font-size: 28px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 12px;
}

.welcome-subtitle {
  font-size: 16px;
  color: var(--text-secondary);
  margin-bottom: 40px;
}

.welcome-suggestions {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  max-width: 600px;
  width: 100%;
}

.suggestion-card {
  padding: 16px 20px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all 0.2s;
  text-align: left;
}

.suggestion-card:hover {
  background: var(--bg-hover);
  border-color: var(--accent, #D97757);
  box-shadow: 0 4px 12px rgba(217, 119, 87, 0.12);
  transform: translateY(-2px);
}

.suggestion-title {
  font-size: 14px;
  font-weight: 500;
  color: var(--text);
  margin-bottom: 4px;
}

.suggestion-desc {
  font-size: 13px;
  color: var(--text-secondary);
}

/* --- File Previews --- */
.file-previews {
  display: none;
  gap: 8px;
  padding: 12px 16px 0;
  flex-wrap: wrap;
  max-width: 900px;
  margin: 0 auto;
}

.file-preview-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  background: var(--bg-hover);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 13px;
  color: var(--text);
}

.file-preview-item img {
  width: 32px;
  height: 32px;
  object-fit: cover;
  border-radius: 4px;
}

.file-preview-name {
  max-width: 150px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.file-preview-remove {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: none;
  background: var(--bg-active);
  color: var(--text-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  transition: all 0.15s;
}

.file-preview-remove:hover {
  background: var(--danger);
  color: white;
}

/* --- Mobile Responsive --- */
@media (max-width: 768px) {
  /* Sidebar: slide-in overlay with backdrop */
  .sidebar {
    position: fixed;
    left: 0;
    top: 0;
    height: 100vh;
    height: 100dvh;
    z-index: 1000;
    transform: translateX(-100%);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    width: 280px;
    box-shadow: none;
  }

  .sidebar.open {
    transform: translateX(0);
    box-shadow: var(--shadow-lg);
  }

  /* Backdrop overlay */
  .sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.4);
    z-index: 999;
    backdrop-filter: blur(2px);
    -webkit-backdrop-filter: blur(2px);
  }

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

  /* Main content full width */
  .main-content {
    width: 100% !important;
    margin-left: 0 !important;
  }

  /* Messages container */
  .messages-container {
    padding: 12px 14px;
  }

  /* AI messages: compact on mobile */
  .msg-ai {
    gap: 10px;
    max-width: 100%;
  }

  .msg-ai-inner {
    gap: 10px;
  }

  .msg-ai-avatar {
    width: 28px;
    height: 28px;
    font-size: 12px;
  }

  .msg-ai-text {
    font-size: 14.5px;
    line-height: 1.65;
  }

  /* Headings smaller on mobile */
  .msg-ai-text h1 { font-size: 1.3em; margin: 20px 0 12px; }
  .msg-ai-text h2 { font-size: 1.15em; margin: 18px 0 12px; }
  .msg-ai-text h3 { font-size: 1.05em; margin: 16px 0 10px; }

  /* User messages */
  .msg-user {
    max-width: 100%;
  }

  .msg-user-bubble {
    max-width: 90%;
    padding: 12px 16px;
    font-size: 14.5px;
  }

  /* Always show actions on mobile (no hover) */
  .msg-ai-actions {
    opacity: 1;
    margin-top: 8px;
    gap: 6px;
    flex-wrap: wrap;
  }

  .msg-copy-btn,
  .msg-action-btn {
    padding: 7px 12px;
    font-size: 12px;
    border-radius: 8px;
    min-height: 36px;
  }

  .code-copy-btn {
    padding: 5px 10px;
    font-size: 11px;
    border-radius: 6px;
    top: 6px;
    right: 6px;
  }

  /* Code blocks: mobile-friendly */
  .msg-ai-text pre,
  .msg-user-bubble pre {
    padding: 12px 14px;
    font-size: 12px;
    border-radius: 10px;
    margin: 10px 0;
    -webkit-overflow-scrolling: touch;
  }

  .msg-ai-text code,
  .msg-user-bubble code {
    font-size: 12px;
    padding: 1px 5px;
  }

  /* Lists tighter on mobile */
  .msg-ai-text ul, .msg-ai-text ol {
    padding-left: 20px;
    margin: 10px 0 16px 0;
  }

  .msg-ai-text li {
    margin-bottom: 8px;
    line-height: 1.6;
  }

  .msg-ai-text p {
    margin-bottom: 12px;
  }

  /* Tables scroll */
  .msg-ai-text table {
    font-size: 13px;
  }

  .msg-ai-text th, .msg-ai-text td {
    padding: 6px 8px;
  }

  /* Input area */
  .input-area {
    padding: 10px 12px;
  }

  .input-area textarea {
    font-size: 15px;
    padding: 12px 14px;
  }

  /* Bottom bar */
  .bottom-bar {
    padding: 8px 12px;
  }

  /* Welcome screen mobile */
  .welcome-screen {
    padding: 24px 16px;
  }

  .welcome-screen .welcome-title {
    font-size: 1.5em;
  }

  .welcome-suggestions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    width: 100%;
  }

  .suggestion-card {
    padding: 14px;
    font-size: 13px;
  }

  /* Message spacing tighter */
  .msg-ai + .msg-ai,
  .msg-ai + .msg-user,
  .msg-user + .msg-ai,
  .msg-user + .msg-user {
    margin-top: 18px;
  }

  /* Sidebar items touch-friendly */
  .session-item {
    padding: 12px 14px;
    min-height: 44px;
  }

  .session-item-menu {
    width: 28px;
    height: 28px;
  }
}

/* --- Extra small screens --- */
@media (max-width: 380px) {
  .messages-container {
    padding: 10px 10px;
  }

  .msg-ai-text {
    font-size: 14px;
  }

  .msg-user-bubble {
    max-width: 95%;
    padding: 10px 14px;
  }

  .suggestion-card {
    padding: 12px;
    font-size: 12px;
  }

  .welcome-suggestions {
    grid-template-columns: 1fr;
  }
}

/* --- Utility Classes --- */
.hidden {
  display: none !important;
}

.flex {
  display: flex;
}

.items-center {
  align-items: center;
}

.gap-2 {
  gap: 8px;
}

.gap-4 {
  gap: 16px;
}

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

.msg-row,
.msg-user {
  animation: fadeIn 0.3s ease;
}

/* --- Settings Modal --- */
.settings-modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  animation: fadeIn 0.2s ease;
}

.settings-modal {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  width: 92%;
  max-width: 720px;
  max-height: 88vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.35), 0 8px 32px rgba(0, 0, 0, 0.2);
  animation: slideUp 0.3s ease;
}

.settings-modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 20px 24px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-surface);
}

.settings-modal-header h3 {
  margin: 0;
  font-size: 18px;
  font-weight: 600;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 8px;
}

.settings-close-btn {
  background: transparent;
  border: none;
  font-size: 28px;
  cursor: pointer;
  color: var(--text-muted);
  padding: 0;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  transition: all 0.2s;
  line-height: 1;
}

.settings-close-btn:hover {
  color: var(--text-primary);
  background: var(--bg-hover);
}

.settings-tabs {
  display: flex;
  gap: 4px;
  padding: 0 24px;
  border-bottom: 1px solid var(--border-subtle);
  background: var(--bg-surface);
}

.settings-tab {
  padding: 12px 16px;
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
  color: var(--text-secondary);
  transition: all 0.2s;
}

.settings-tab.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

.settings-tab:hover:not(.active) {
  color: var(--text-primary);
  background: var(--bg-hover);
}

.settings-content {
  padding: 24px;
  overflow-y: auto;
  flex: 1;
}

.settings-tab-content {
  display: none;
}

.settings-tab-content.active {
  display: block;
}

.settings-section {
  margin-bottom: 24px;
}

.settings-section-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 12px;
}

.settings-input, .settings-textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-family: inherit;
  background: var(--bg-input);
  color: var(--text-primary);
  transition: all 0.2s;
}

.settings-input:focus, .settings-textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.settings-textarea {
  min-height: 100px;
  resize: vertical;
  line-height: 1.5;
}

.settings-btn {
  padding: 10px 16px;
  border-radius: var(--radius-sm);
  border: none;
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
  transition: all 0.2s;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.settings-btn-primary {
  background: var(--accent);
  color: white;
  box-shadow: 0 1px 2px rgba(0,0,0,0.05);
}

.settings-btn-primary:hover {
  background: var(--accent-hover);
  box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.settings-btn-secondary {
  background: var(--bg-hover);
  color: var(--text-primary);
  border: 1px solid var(--border);
}

.settings-btn-secondary:hover {
  background: var(--bg-active);
  border-color: var(--border-hover);
}
.skill-item {
  display: flex;
  align-items: center;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  margin-bottom: 8px;
  background: var(--bg-surface);
  transition: all 0.2s;
}

.skill-item:hover {
  border-color: var(--border-hover);
  background: var(--bg-hover);
}

.settings-body {
  padding: 20px 24px;
  max-height: 60vh;
  overflow-y: auto;
}

.settings-panel {
  display: none;
}

.settings-panel.active {
  display: block;
}

.settings-desc {
  font-size: 13px;
  color: var(--text-secondary);
  margin-bottom: 16px;
  line-height: 1.5;
}

.settings-hint {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 8px;
}

/* --- Settings Footer Buttons --- */
.settings-footer {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 12px;
  padding: 16px 24px;
  border-top: 1px solid var(--border);
  background: var(--bg-surface);
}

.settings-save-btn {
  padding: 11px 20px;
  background: var(--accent-gradient);
  color: white;
  border: none;
  border-radius: var(--radius-md);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  box-shadow: 0 2px 8px var(--accent-glow);
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.settings-save-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px var(--accent-glow);
}

.settings-save-btn:active {
  transform: translateY(0);
}

.settings-reset-btn {
  padding: 11px 20px;
  background: var(--bg-hover);
  color: var(--text-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.settings-reset-btn:hover {
  background: var(--bg-active);
  border-color: var(--border-hover);
}

/* ============================================
   Questionnaire Blocks
   ============================================ */
.questionnaire-block {
  margin: 16px 0;
  padding: 20px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
  position: relative;
}

.questionnaire-close {
  position: absolute;
  top: 12px;
  right: 12px;
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 24px;
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  border-radius: var(--radius-sm);
  transition: all 0.2s;
  line-height: 1;
  padding: 0;
}

.questionnaire-close:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.questionnaire-question {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 12px;
  line-height: 1.5;
}

.questionnaire-options {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.questionnaire-option {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  background: var(--bg-card);
  border: 1.5px solid var(--border);
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s ease;
  font-size: 14px;
  color: var(--text-primary);
  text-align: left;
  width: 100%;
}

.questionnaire-option:hover:not(:disabled) {
  border-color: var(--accent);
  background: var(--accent-soft);
  transform: translateY(-1px);
}

.questionnaire-option:disabled {
  cursor: not-allowed;
  opacity: 0.6;
}

.questionnaire-option-selected {
  border-color: var(--accent);
  background: var(--accent-soft);
  font-weight: 500;
}

.option-number {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  background: var(--accent);
  color: white;
  border-radius: 50%;
  font-size: 12px;
  font-weight: 600;
  flex-shrink: 0;
}

.questionnaire-option-selected .option-number {
  background: var(--accent-hover);
}

.option-label {
  flex: 1;
  line-height: 1.4;
}

/* Dark mode questionnaire */
.app:not(.light) .questionnaire-block {
  background: rgba(255, 255, 255, 0.03);
  border-color: rgba(255, 255, 255, 0.1);
}

.app:not(.light) .questionnaire-question {
  color: rgba(255, 255, 255, 0.95);
}

.app:not(.light) .questionnaire-option {
  background: rgba(255, 255, 255, 0.04);
  border-color: rgba(255, 255, 255, 0.12);
  color: rgba(255, 255, 255, 0.90);
}

.app:not(.light) .questionnaire-option:hover:not(:disabled) {
  background: rgba(217, 119, 87, 0.12);
  border-color: rgba(217, 119, 87, 0.4);
}

.app:not(.light) .questionnaire-option-selected {
  background: rgba(217, 119, 87, 0.15);
  border-color: rgba(217, 119, 87, 0.5);
}

/* Quiz stepper additions */
.quiz-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}

.quiz-stepper {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-secondary);
}

.quiz-custom-input {
  margin-top: 8px;
}

.quiz-other-input {
  width: 100%;
  padding: 10px 14px;
  background: var(--bg-card);
  border: 1.5px solid var(--border);
  border-radius: 8px;
  font-size: 14px;
  color: var(--text-primary);
  transition: all 0.2s;
}

.quiz-other-input:focus {
  outline: none;
  border-color: var(--accent);
  background: var(--bg-surface);
}

.quiz-other-input::placeholder {
  color: var(--text-muted);
}

.quiz-nav {
  margin-top: 12px;
  display: flex;
  gap: 8px;
}

.quiz-back-btn {
  padding: 8px 16px;
  background: var(--bg-card);
  border: 1.5px solid var(--border);
  border-radius: 8px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.2s;
}

.quiz-back-btn:hover {
  background: var(--bg-hover);
  border-color: var(--accent);
  color: var(--text-primary);
}

/* Dark mode quiz additions */
.app:not(.light) .quiz-other-input {
  background: rgba(255, 255, 255, 0.04);
  border-color: rgba(255, 255, 255, 0.12);
  color: rgba(255, 255, 255, 0.90);
}

.app:not(.light) .quiz-other-input:focus {
  background: rgba(255, 255, 255, 0.06);
  border-color: rgba(217, 119, 87, 0.4);
}

.app:not(.light) .quiz-back-btn {
  background: rgba(255, 255, 255, 0.04);
  border-color: rgba(255, 255, 255, 0.12);
  color: rgba(255, 255, 255, 0.70);
}

.app:not(.light) .quiz-back-btn:hover {
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(217, 119, 87, 0.4);
  color: rgba(255, 255, 255, 0.90);
}

/* ============================================
   Thinking/Reasoning Block
   ============================================ */
.thinking-box {
  margin: 12px 0;
  border: 2px solid #8b5cf6;
  border-radius: 10px;
  background: linear-gradient(135deg, rgba(139, 92, 246, 0.08), rgba(99, 102, 241, 0.08));
  overflow: hidden;
}

.thinking-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 16px;
  cursor: pointer;
  user-select: none;
  background: rgba(139, 92, 246, 0.12);
  border-bottom: 1px solid rgba(139, 92, 246, 0.2);
  transition: background 0.2s ease;
}

.thinking-header:hover {
  background: rgba(139, 92, 246, 0.18);
}

.thinking-icon {
  font-size: 12px;
  transition: transform 0.2s ease;
  color: #8b5cf6;
}

.thinking-box.collapsed .thinking-icon {
  transform: rotate(-90deg);
}

.thinking-label {
  font-weight: 600;
  font-size: 14px;
  color: #7c3aed;
}

.thinking-body {
  padding: 16px;
  font-size: 13px;
  line-height: 1.6;
  color: var(--text-secondary);
  white-space: pre-wrap;
  background: rgba(255, 255, 255, 0.5);
  max-height: 400px;
  overflow-y: auto;
  font-family: 'JetBrains Mono', monospace;
}

.thinking-box.collapsed .thinking-body {
  display: none;
}

/* Dark mode reasoning */
.app:not(.light) .thinking-box {
  border-color: rgba(139, 92, 246, 0.5);
  background: linear-gradient(135deg, rgba(139, 92, 246, 0.12), rgba(99, 102, 241, 0.12));
}

.app:not(.light) .thinking-header {
  background: rgba(139, 92, 246, 0.15);
  border-bottom-color: rgba(139, 92, 246, 0.3);
}

.app:not(.light) .thinking-header:hover {
  background: rgba(139, 92, 246, 0.22);
}

.app:not(.light) .thinking-icon {
  color: #a78bfa;
}

.app:not(.light) .thinking-label {
  color: #a78bfa;
}

.app:not(.light) .thinking-body {
  background: rgba(0, 0, 0, 0.2);
  color: rgba(255, 255, 255, 0.75);
}

/* ============================================
   Edit Button (Hover-only)
   ============================================ */
.msg-edit-btn {
  position: absolute;
  bottom: 8px;
  right: 8px;
  background: rgba(0, 0, 0, 0.5);
  border: none;
  border-radius: 6px;
  padding: 6px 8px;
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.2s ease, background 0.2s ease;
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
}

.msg-user-bubble {
  position: relative;
}

.msg-user-bubble:hover .msg-edit-btn {
  opacity: 1;
}

.msg-edit-btn:hover {
  background: rgba(0, 0, 0, 0.7);
}

.app:not(.light) .msg-edit-btn {
  background: rgba(255, 255, 255, 0.15);
}

.app:not(.light) .msg-edit-btn:hover {
  background: rgba(255, 255, 255, 0.25);
}

/* ============================================
   Enhanced Thinking Animation
   ============================================ */
.typing-indicator {
  display: flex;
  gap: 6px;
  padding: 12px 16px;
}

/* Ensure typing indicator row matches message width */
.typing-indicator-row {
  max-width: 900px !important;
}

.typing-dot {
  width: 8px;
  height: 8px;
  background: var(--accent);
  border-radius: 50%;
  animation: typing-bounce 1.4s infinite ease-in-out;
}

.typing-dot:nth-child(1) {
  animation-delay: 0s;
}

.typing-dot:nth-child(2) {
  animation-delay: 0.2s;
}

.typing-dot:nth-child(3) {
  animation-delay: 0.4s;
}

@keyframes typing-bounce {
  0%, 60%, 100% {
    transform: translateY(0);
    opacity: 0.4;
  }
  30% {
    transform: translateY(-8px);
    opacity: 1;
  }
}

.typing-indicator-row .msg-ai-avatar {
  animation: avatar-pulse 2s infinite ease-in-out;
}

@keyframes avatar-pulse {
  0%, 100% {
    box-shadow: 0 0 0 0 rgba(217, 119, 87, 0.4);
  }
  50% {
    box-shadow: 0 0 0 8px rgba(217, 119, 87, 0);
  }
}

/* ============================================
   Image Lightbox
   ============================================ */
.image-lightbox {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.9);
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
}

.image-lightbox.active {
  opacity: 1;
  pointer-events: all;
}

.lightbox-content {
  max-width: 90vw;
  max-height: 90vh;
  position: relative;
}

.lightbox-content img {
  max-width: 100%;
  max-height: 90vh;
  object-fit: contain;
  border-radius: var(--radius-lg);
  box-shadow: 0 8px 32px rgba(0,0,0,0.4);
}

.lightbox-close {
  position: absolute;
  top: -40px;
  right: 0;
  background: rgba(255, 255, 255, 0.9);
  border: none;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  color: var(--text);
  transition: all 0.2s;
}

.lightbox-close:hover {
  background: white;
  transform: scale(1.1);
}

/* ============================================
   Theme Toggle Button
   ============================================ */
.theme-toggle {
  width: 32px;
  height: 32px;
  border: none;
  background: var(--bg-hover);
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
  flex-shrink: 0;
}

.theme-toggle:hover {
  background: var(--bg-active);
  transform: scale(1.05);
}

.theme-toggle svg {
  transition: opacity 0.3s, transform 0.3s;
}

/* Show sun in dark mode, moon in light mode */
[data-theme="light"] .moon-icon,
[data-theme="dark"] .sun-icon {
  display: none;
}

[data-theme="light"] .sun-icon,
[data-theme="dark"] .moon-icon {
  display: block;
}

/* Default (no data-theme = light) */
.moon-icon {
  display: none;
}

/* ============================================
   Dark Mode Sidebar Fixes
   ============================================ */
[data-theme="dark"] .sidebar-logo,
[data-theme="dark"] .sidebar-logo span {
  color: var(--text-primary);
}

[data-theme="dark"] .new-chat-btn {
  color: var(--text-primary);
}

[data-theme="dark"] .search-input {
  color: var(--text-primary);
  background: var(--bg-input);
}

[data-theme="dark"] .search-input::placeholder {
  color: var(--text-muted);
}

[data-theme="dark"] .history-item {
  color: var(--text-secondary);
}

[data-theme="dark"] .history-item:hover {
  color: var(--text-primary);
}

[data-theme="dark"] .user-name {
  color: var(--text-primary);
}

[data-theme="dark"] .sidebar-footer {
  border-top-color: var(--border);
  background: var(--bg-sidebar);
}

/* ============================================
   AI Response Images (Markdown)
   ============================================ */
.msg-ai-text img,
.msg-assistant-bubble img {
  max-width: 180px;
  max-height: 180px;
  border-radius: var(--radius-md);
  margin: 12px 0;
  display: block;
  cursor: pointer;
  transition: opacity 0.2s, transform 0.2s;
}

.msg-ai-text img:hover,
.msg-assistant-bubble img:hover {
  opacity: 0.85;
  transform: scale(1.02);
}

/* ============================================
   Memory Modal (Professional Popup)
   ============================================ */
.memory-modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  animation: fadeIn 0.2s ease;
}

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

.memory-modal {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  box-shadow: 0 20px 60px rgba(0,0,0,0.3);
  width: 90%;
  max-width: 700px;
  max-height: 85vh;
  display: flex;
  flex-direction: column;
  animation: slideUp 0.3s ease;
  border: 1px solid var(--border);
}

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

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

.memory-modal-header h3 {
  margin: 0;
  font-size: 18px;
  font-weight: 600;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 8px;
}

.memory-close-btn {
  background: transparent;
  border: none;
  font-size: 28px;
  color: var(--text-muted);
  cursor: pointer;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  transition: background 0.2s, color 0.2s;
  line-height: 1;
  padding: 0;
}

.memory-close-btn:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.memory-desc {
  margin: 0;
  padding: 16px 24px;
  font-size: 13px;
  color: var(--text-secondary);
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border-subtle);
  line-height: 1.5;
}

.memory-list {
  flex: 1;
  overflow-y: auto;
  padding: 16px 24px;
}

.memory-loading {
  text-align: center;
  padding: 40px 20px;
  color: var(--text-muted);
  font-size: 14px;
}

.memory-item {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 14px 16px;
  margin-bottom: 12px;
  display: flex;
  align-items: flex-start;
  gap: 12px;
  transition: border-color 0.2s, background 0.2s;
}

.memory-item:hover {
  background: var(--bg-hover);
  border-color: var(--border-hover);
}

.memory-item-icon {
  font-size: 18px;
  flex-shrink: 0;
  margin-top: 2px;
}

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

.memory-item-category {
  display: inline-block;
  font-size: 11px;
  font-weight: 600;
  color: var(--accent);
  background: var(--accent-soft);
  padding: 3px 8px;
  border-radius: 4px;
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.memory-item-text {
  font-size: 14px;
  color: var(--text-primary);
  line-height: 1.5;
  word-wrap: break-word;
}

.memory-item-actions {
  display: flex;
  gap: 6px;
  flex-shrink: 0;
}

.memory-item-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 6px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s, color 0.2s;
  font-size: 14px;
}

.memory-item-btn:hover {
  background: var(--bg-active);
  color: var(--text-primary);
}

.memory-modal-footer {
  padding: 16px 24px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
}

.memory-clear-all-btn {
  background: var(--danger-soft);
  color: var(--danger);
  border: 1px solid transparent;
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  gap: 6px;
}

.memory-clear-all-btn:hover {
  background: var(--danger);
  color: #fff;
  border-color: var(--danger);
}

/* Mobile responsive */
@media (max-width: 768px) {
  .memory-modal {
    width: 95%;
    max-height: 90vh;
    margin: 20px;
  }

  .memory-modal-header,
  .memory-desc,
  .memory-list,
  .memory-modal-footer {
    padding-left: 16px;
    padding-right: 16px;
  }
}

/* ========== SETTINGS MODAL BUTTONS ========== */

/* Generate by AI Button */
.btn-generate-ai {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-generate-ai:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}

.btn-generate-ai:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

.generate-input-row {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-top: 10px;
}

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

.btn-generate-go {
    padding: 10px 18px;
    background: #667eea;
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    white-space: nowrap;
    transition: all 0.2s;
}

.btn-generate-go:hover {
    background: #5a6fd6;
    transform: translateY(-1px);
}

.btn-generate-cancel {
    padding: 10px 14px;
    background: var(--bg-tertiary);
    color: var(--text-secondary);
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-generate-cancel:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

/* Skills Tab Buttons */
.btn-new-skill {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 10px 18px;
    background: var(--accent);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-new-skill:hover {
    background: var(--accent-hover);
    transform: translateY(-1px);
}

.btn-select-all {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 10px 14px;
    background: var(--bg-tertiary);
    color: var(--text-secondary);
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    margin-left: auto;
}

.btn-select-all:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.skills-toolbar {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 16px;
}

.skill-delete-bar {
    display: none;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    margin-top: 12px;
    background: rgba(239, 68, 68, 0.08);
    border: 1px solid rgba(239, 68, 68, 0.25);
    border-radius: 10px;
    animation: slideUp 0.2s ease;
}

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

.skill-delete-count {
    font-size: 13px;
    color: #ef4444;
    font-weight: 600;
}

.btn-delete-selected {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 8px 16px;
    background: #ef4444;
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-delete-selected:hover {
    background: #dc2626;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(239, 68, 68, 0.3);
}

/* Language Tab Select */
.settings-select-wrapper {
    margin-top: 12px;
}

.settings-select {
    width: 100%;
    padding: 10px 14px;
    background: var(--bg-tertiary);
    color: var(--text-primary);
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 13px;
    cursor: pointer;
    transition: all 0.2s;
}

.settings-select:hover {
    background: var(--bg-hover);
    border-color: var(--accent);
}

.settings-select:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(113, 50, 245, 0.1);
}

/* ========== SKILL EDIT MODAL ========== */

.skill-edit-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.7);
    z-index: 10001;
    display: flex;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(4px);
}

.skill-edit-modal {
    background: var(--bg-card);
    border-radius: 16px;
    width: 90%;
    max-width: 650px;
    max-height: 85vh;
    display: flex;
    flex-direction: column;
    border: 1px solid var(--border);
    box-shadow: 0 20px 60px rgba(0,0,0,0.5);
    overflow: hidden;
    animation: modalSlideUp 0.3s ease;
}

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

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

.skill-edit-header h3 {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary);
}

.skill-edit-body {
    flex: 1;
    overflow-y: auto;
    padding: 20px 24px;
}

.skill-edit-footer {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 10px;
    padding: 16px 24px;
    border-top: 1px solid var(--border);
}

/* New Skill Modal (wider) */
.new-skill-wide {
    max-width: 800px;
}

.ns-field-card {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 16px;
    margin-bottom: 16px;
}

.ns-field-card-prompt {
    padding: 18px;
}

.ns-field-label-row {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    margin-bottom: 10px;
}

.ns-field-icon {
    font-size: 20px;
    flex-shrink: 0;
}

.ns-field-title {
    display: block;
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 2px;
}

.ns-field-hint {
    display: block;
    font-size: 12px;
    color: var(--text-tertiary);
}

.ns-field-input {
    width: 100%;
    padding: 10px 14px;
    background: var(--bg-input);
    color: var(--text-primary);
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 14px;
    transition: all 0.2s;
}

.ns-field-input:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(113, 50, 245, 0.1);
}

.ns-field-textarea {
    width: 100%;
    min-height: 160px;
    padding: 12px 14px;
    background: var(--bg-input);
    color: var(--text-primary);
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 13px;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    resize: vertical;
    line-height: 1.6;
    transition: all 0.2s;
}

.ns-field-textarea:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(113, 50, 245, 0.1);
}

/* Personality header */
.personality-header {
    transform: translateY(-1px);
}

/* Split Panel Layout (Claude-style) */
.app-container.artifact-open {
    display: flex;
    height: 100vh;
    overflow: hidden;
}

.app-container.artifact-open .main-content {
    flex: 0 0 55%;
    min-width: 400px;
    border-right: 1px solid var(--border);
}

.artifact-panel {
    flex: 1;
    background: var(--bg-primary);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    animation: slideInRight 0.3s ease;
}

@keyframes slideInRight {
    from { transform: translateX(100%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

.artifact-panel-header {
    padding: 1rem;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--bg-card);
}

.artifact-panel-title {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-primary);
}

.artifact-panel-actions {
    display: flex;
    gap: 0.5rem;
}

.artifact-panel-body {
    flex: 1;
    overflow: auto;
    padding: 1rem;
}

/* Mobile: collapse to modal */
@media (max-width: 768px) {
    .app-container.artifact-open {
        display: block;
    }
    .artifact-panel {
        position: fixed;
        top: 0;
        right: 0;
        bottom: 0;
        left: 0;
        z-index: 1000;
    }
}

/* === QA FIXES: Accessibility + UX Improvements === */

/* Focus-visible: keyboard-only focus indicators */
button:focus-visible,
input:focus-visible,
textarea:focus-visible,
select:focus-visible,
a:focus-visible,
[tabindex]:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 4px;
}

/* Model selector: visual selected state */
.model-selector {
  font-weight: 600;
  color: var(--text);
}
.model-selector option:checked,
.model-selector option[selected] {
  font-weight: 700;
  color: var(--accent);
}

/* User message images: constrained within bubble, no overflow */
.msg-user-bubble .msg-user-image {
  max-width: 100%;
  width: 100%;
  max-height: 300px;
  object-fit: contain;
  border-radius: var(--radius-md);
  margin-bottom: 8px;
  display: block;
}

/* Multiple images grid in user bubble */
.msg-user-images-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: 8px;
  margin-bottom: 8px;
}
.msg-user-images-grid .msg-user-image {
  width: 100%;
  height: 120px;
  max-height: 120px;
  object-fit: cover;
  margin-bottom: 0;
}

/* File attachment indicator in user bubble */
.msg-user-file-attachment {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  background: var(--bg-hover);
  border-radius: var(--radius-sm);
  font-size: 13px;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

/* Typing indicator: enhanced with "thinking" text */
.typing-indicator-row .msg-ai-content::after {
  content: "Zando AI sedang berpikir...";
  display: block;
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 4px;
  animation: pulseFade 1.5s ease-in-out infinite;
}

@keyframes pulseFade {
  0%, 100% { opacity: 0.4; }
  50% { opacity: 1; }
}

/* prefers-reduced-motion: respect user's motion preference */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
  .typing-indicator-row .msg-ai-content::after {
    animation: none;
    opacity: 0.8;
  }
  .auth-logo-icon {
    animation: none;
  }
  body::before {
    animation: none;
  }
}

/* Touch target: minimum 44px for interactive elements on mobile */
@media (max-width: 768px) {
  .input-btn,
  .send-btn,
  .msg-copy-btn,
  .msg-action-btn,
  .file-preview-remove,
  .memory-close-btn,
  .settings-close-btn {
    min-height: 40px;
    min-width: 40px;
  }
}

/* Error toast styling */
.toast-container {
    position: fixed;
    bottom: 80px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 10000;
    display: flex;
    flex-direction: column;
    gap: 8px;
    pointer-events: none;
}
.toast {
    padding: 10px 20px;
    border-radius: 8px;
    font-size: 14px;
    color: white;
    background: var(--accent);
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    animation: toast-in 0.3s ease;
    pointer-events: auto;
    max-width: 90vw;
    text-align: center;
}
.toast.toast-out {
    animation: toast-out 0.3s ease forwards;
}
@keyframes toast-in {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}
@keyframes toast-out {
    from { opacity: 1; transform: translateY(0); }
    to { opacity: 0; transform: translateY(20px); }
}
.toast-error {
  background: var(--danger);
  color: white;
}
.toast-warning {
  background: var(--warning);
  color: white;
}

/* Empty state hint animation */
.message-input:placeholder-shown + .input-bottom .send-btn:not(.active) {
  opacity: 0.5;
}

/* Typing cursor for AI streaming */
.typing-cursor {
  display: inline-block;
  width: 8px;
  height: 16px;
  background: var(--accent);
  border-radius: 2px;
  margin-left: 2px;
  vertical-align: text-bottom;
  animation: blink-cursor 1s step-end infinite;
}
@keyframes blink-cursor {
  0%, 50% { opacity: 1; }
  51%, 100% { opacity: 0; }
}

/* Image lightbox */
.image-lightbox {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.85);
  z-index: 20000;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: zoom-out;
  animation: toast-in 0.2s ease;
}
.image-lightbox img {
  max-width: 90vw;
  max-height: 90vh;
  object-fit: contain;
  border-radius: 8px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.4);
}

/* ============================================
   Questionnaire Card
   ============================================ */
.questionnaire-card {
  max-width: 640px;
  margin: 16px auto;
  background: var(--bg-surface, #fff);
  border: 1px solid var(--border, #e5e5e5);
  border-radius: 16px;
  box-shadow: 0 4px 24px rgba(0,0,0,0.08);
  overflow: hidden;
}

.questionnaire-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-subtle, #f0f0f0);
}

.questionnaire-icon { font-size: 20px; }

.questionnaire-title {
  flex: 1;
  font-size: 15px;
  font-weight: 600;
  color: var(--text-primary, #1a1a1a);
}

.questionnaire-progress {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted, #888);
  background: var(--bg-hover, #f5f5f5);
  padding: 4px 10px;
  border-radius: 12px;
}

.questionnaire-body {
  padding: 20px;
  max-height: 50vh;
  overflow-y: auto;
}

.questionnaire-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 20px 16px;
  border-top: 1px solid var(--border-subtle, #f0f0f0);
}

/* Question groups */
.q-group {
  margin-bottom: 20px;
}
.q-group:last-child { margin-bottom: 0; }

.q-label {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary, #1a1a1a);
  margin-bottom: 10px;
  line-height: 1.5;
}

.q-num {
  flex-shrink: 0;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--accent, #d97757);
  color: #fff;
  font-size: 12px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-top: 1px;
}

.q-options {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.q-option {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 10px 16px;
  background: var(--bg-card, #f9f9f9);
  border: 1.5px solid var(--border, #e0e0e0);
  border-radius: 10px;
  font-size: 13px;
  color: var(--text-secondary, #555);
  cursor: pointer;
  transition: all 0.15s ease;
  font-family: inherit;
}

.q-option:hover {
  border-color: var(--accent, #d97757);
  background: var(--accent-soft, rgba(217,119,87,0.08));
}

.q-option.active {
  border-color: var(--accent, #d97757);
  background: var(--accent-soft, rgba(217,119,87,0.12));
  color: var(--accent, #d97757);
  font-weight: 600;
}

.q-color-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  flex-shrink: 0;
  border: 1px solid rgba(0,0,0,0.1);
}

.q-option-custom {
  font-style: italic;
  color: var(--text-muted, #888);
}

.q-custom-input {
  display: flex;
  gap: 8px;
  align-items: center;
  width: 100%;
  margin-top: 4px;
}

.q-custom-input input {
  flex: 1;
  padding: 10px 14px;
  border: 1.5px solid var(--border, #e0e0e0);
  border-radius: 10px;
  font-size: 13px;
  font-family: inherit;
  background: var(--bg-input, #fff);
  color: var(--text, #1a1a1a);
  outline: none;
}

.q-custom-input button {
  padding: 10px 16px;
  background: var(--accent, #d97757);
  color: #fff;
  border: none;
  border-radius: 10px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
}

/* Buttons */
.questionnaire-back {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  background: transparent;
  border: 1px solid var(--border, #e0e0e0);
  border-radius: 10px;
  font-size: 13px;
  color: var(--text-secondary, #555);
  cursor: pointer;
  font-family: inherit;
}

.questionnaire-submit {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 10px 20px;
  background: var(--accent, #d97757);
  color: #fff;
  border: none;
  border-radius: 10px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  transition: opacity 0.2s;
}

.questionnaire-submit:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.questionnaire-submit:not(:disabled):hover {
  opacity: 0.9;
}

.submit-arrow { transition: transform 0.2s; }
.questionnaire-submit:not(:disabled):hover .submit-arrow {
  transform: translateX(2px);
}

/* Dark mode */
.app:not(.light) .questionnaire-card {
  background: rgba(255,255,255,0.04);
  border-color: rgba(255,255,255,0.1);
}

.app:not(.light) .questionnaire-title {
  color: rgba(255,255,255,0.95);
}

.app:not(.light) .q-label {
  color: rgba(255,255,255,0.95);
}

.app:not(.light) .q-option {
  background: rgba(255,255,255,0.04);
  border-color: rgba(255,255,255,0.12);
  color: rgba(255,255,255,0.85);
}

.app:not(.light) .q-option.active {
  background: rgba(217,119,87,0.15);
  border-color: rgba(217,119,87,0.5);
  color: rgba(217,119,87,1);
}

.app:not(.light) .q-custom-input input {
  background: rgba(255,255,255,0.04);
  border-color: rgba(255,255,255,0.12);
  color: rgba(255,255,255,0.95);
}

.app:not(.light) .questionnaire-progress {
  background: rgba(255,255,255,0.06);
}

/* Mobile */
@media (max-width: 768px) {
  .questionnaire-card {
    margin: 8px;
    border-radius: 12px;
  }
  .questionnaire-body { padding: 16px; }
  .q-options { flex-direction: column; }
  .q-option { width: 100%; justify-content: flex-start; }
}
