/* ============================================================
   Senku Chat UI — Production Styles
   Professional chat interface with dark/light themes.
   Inter font, responsive, accessible.
   ============================================================ */

/* ============================================================
   CSS Custom Properties — Dark Theme (default)
   ============================================================ */
:root {
  /* Dark theme colors */
  --color-bg: #0a0a0a;
  --color-bg-elevated: #141414;
  --color-surface: #1e1e1e;
  --color-surface-hover: #262626;
  --color-border: #2a2a2a;
  --color-border-subtle: #1e1e1e;

  --color-text: #f0f0f0;
  --color-text-secondary: #a1a1a1;
  --color-text-tertiary: #5c5c5c;
  --color-text-inverse: #0a0a0a;

  --color-accent: #10b981;
  --color-accent-hover: #059669;
  --color-accent-subtle: rgba(16, 185, 129, 0.06);
  --color-accent-muted: rgba(16, 185, 129, 0.12);

  --color-user-bubble: #2563eb;
  --color-user-bubble-text: #ffffff;

  --color-error: #ef4444;
  --color-error-bg: rgba(239, 68, 68, 0.06);
  --color-error-border: rgba(239, 68, 68, 0.18);

  --color-code-bg: #161616;
  --color-code-header: #1e1e1e;
  --color-inline-code-bg: #1e1e1e;
  --color-inline-code-text: #e879f9;

  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-mono: 'JetBrains Mono', 'SF Mono', 'Fira Code', 'Consolas', monospace;

  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --radius-xl: 20px;
  --radius-full: 9999px;

  --shadow-sm: 0 1px 2px rgba(0,0,0,0.3);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.4);
  --shadow-lg: 0 8px 32px rgba(0,0,0,0.5);

  --header-height: 66px;
  --sidebar-width: 272px;
  --content-max-width: 720px;
  --input-max-width: 720px;

  --transition-fast: 150ms ease;
  --transition-normal: 250ms ease;
  --transition-theme: background-color 300ms ease, color 300ms ease, border-color 300ms ease;
}

/* ============================================================
   Light Theme
   ============================================================ */
[data-theme="light"] {
  --color-bg: #fafafa;
  --color-bg-elevated: #ffffff;
  --color-surface: #f3f3f3;
  --color-surface-hover: #eaeaea;
  --color-border: #e5e5e5;
  --color-border-subtle: #f0f0f0;

  --color-text: #171717;
  --color-text-secondary: #525252;
  --color-text-tertiary: #a3a3a3;
  --color-text-inverse: #ffffff;

  --color-accent-subtle: rgba(16, 185, 129, 0.05);
  --color-accent-muted: rgba(16, 185, 129, 0.1);

  --color-error-bg: rgba(239, 68, 68, 0.04);

  --color-code-bg: #f6f6f6;
  --color-code-header: #eeeeee;
  --color-inline-code-bg: #f0f0f0;
  --color-inline-code-text: #d946ef;

  --shadow-sm: 0 1px 2px rgba(0,0,0,0.04);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.06);
  --shadow-lg: 0 8px 32px rgba(0,0,0,0.1);
}

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

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

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0,0,0,0);
  white-space: nowrap;
  border: 0;
}

/* ============================================================
   Layout
   ============================================================ */
.app-layout {
  display: flex;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
}

.main-wrapper {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-width: 0;
  height: 100%;
}

/* ============================================================
   Sidebar
   ============================================================ */
.sidebar {
  width: var(--sidebar-width);
  height: 100%;
  background: var(--color-bg-elevated);
  border-right: 1px solid var(--color-border);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  transition: transform var(--transition-normal), width var(--transition-normal), var(--transition-theme);
  z-index: 100;
  overflow: hidden;
}

/* Desktop collapsed state */
.sidebar.collapsed {
  width: 0;
  border-right: none;
  overflow: hidden;
}

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

.sidebar-title {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--color-text-tertiary);
}

.sidebar-close {
  display: none;
}

.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  backdrop-filter: blur(2px);
  z-index: 99;
  opacity: 0;
  transition: opacity var(--transition-normal);
}

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

.topics-nav {
  flex: 1;
  overflow-y: auto;
  padding: 16px 14px;
}

.topic-category {
  margin-bottom: 4px;
}

.topic-category-title {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--color-text-tertiary);
  padding: 10px 10px 4px;
}

.topic-item {
  display: block;
  width: 100%;
  padding: 8px 10px;
  margin: 1px 0;
  border: none;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--color-text-secondary);
  font-size: 13px;
  font-family: var(--font-sans);
  text-align: left;
  cursor: pointer;
  transition: background var(--transition-fast), color var(--transition-fast);
  line-height: 1.4;
}

.topic-item:hover {
  background: var(--color-surface-hover);
  color: var(--color-text);
}

/* ============================================================
   Header — Glass morphism
   ============================================================ */
.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: var(--header-height);
  padding: 0 16px;
  border-bottom: 1px solid var(--color-border);
  background: rgba(20, 20, 20, 0.75);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  flex-shrink: 0;
  z-index: 10;
  transition: var(--transition-theme);
}

[data-theme="light"] .app-header {
  background: rgba(255, 255, 255, 0.75);
}

.header-left,
.header-right {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 80px;
}

.header-right {
  justify-content: flex-end;
}

.header-center {
  text-align: center;
}

.app-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--color-text);
  letter-spacing: -0.02em;
}

.btn-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--color-text-secondary);
  cursor: pointer;
  transition: background var(--transition-fast), color var(--transition-fast), border-color var(--transition-fast);
}

.btn-icon:hover {
  background: var(--color-surface);
  color: var(--color-text);
  border-color: var(--color-text-tertiary);
}

.btn-icon:focus-visible {
  outline: 2px solid var(--color-accent);
  outline-offset: 2px;
}

/* ============================================================
   Chat Main
   ============================================================ */
.chat-main {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  scroll-behavior: smooth;
}

.messages-container {
  max-width: var(--content-max-width);
  margin: 0 auto;
  padding: 24px 24px 40px;
}

/* ============================================================
   Welcome State
   ============================================================ */
.welcome-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 60px 20px 40px;
  animation: fadeIn 400ms ease;
}

.welcome-icon {
  font-size: 36px;
  margin-bottom: 16px;
  opacity: 0.8;
}

.welcome-title {
  font-size: 22px;
  font-weight: 700;
  color: var(--color-text);
  margin-bottom: 8px;
  letter-spacing: -0.02em;
}

.welcome-subtitle {
  font-size: 14px;
  color: var(--color-text-secondary);
  max-width: 400px;
  line-height: 1.5;
  margin-bottom: 32px;
}

.welcome-suggestions {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 8px;
  width: 100%;
  max-width: 500px;
}

.welcome-suggestion {
  padding: 12px 16px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  background: var(--color-bg-elevated);
  color: var(--color-text-secondary);
  font-size: 13px;
  font-family: var(--font-sans);
  text-align: left;
  cursor: pointer;
  transition: background var(--transition-fast), border-color var(--transition-fast), color var(--transition-fast);
  line-height: 1.4;
}

.welcome-suggestion:hover {
  background: var(--color-surface);
  border-color: var(--color-accent);
  color: var(--color-text);
}

.welcome-suggestion:focus-visible {
  outline: 2px solid var(--color-accent);
  outline-offset: 2px;
}

/* ============================================================
   Messages — Chat bubble layout
   ============================================================ */
.message {
  padding: 8px 0;
  animation: messageSlideIn 350ms cubic-bezier(0.16, 1, 0.3, 1);
}

.message + .message {
  border-top: none;
}

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

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

.message-row {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  max-width: 85%;
}

/* Assistant messages — left aligned */
.message-assistant .message-row {
  margin-right: auto;
}

/* User messages — right aligned, reversed order */
.message-user .message-row {
  margin-left: auto;
  flex-direction: row-reverse;
}

.message-avatar {
  flex-shrink: 0;
  width: 28px;
  height: 28px;
  border-radius: var(--radius-full);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 600;
  margin-top: 2px;
  overflow: hidden;
}

.message-user .message-avatar {
  background: var(--color-user-bubble);
  color: var(--color-user-bubble-text);
  font-size: 11px;
}

.message-assistant .message-avatar {
  background: var(--color-accent-muted);
  color: var(--color-accent);
  font-size: 14px;
}

.message-assistant .message-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.message-content {
  flex: 1;
  min-width: 0;
  position: relative;
}

/* User bubble styling */
.message-user .message-content {
  background: var(--color-user-bubble);
  color: var(--color-user-bubble-text);
  border-radius: var(--radius-lg) var(--radius-lg) 4px var(--radius-lg);
  padding: 10px 14px;
}

.message-user .message-author {
  display: none;
}

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

/* Assistant bubble styling */
.message-assistant .message-content {
  background: var(--color-surface);
  border-radius: var(--radius-lg) var(--radius-lg) var(--radius-lg) 4px;
  padding: 12px 16px;
}

.message-author {
  font-size: 12px;
  font-weight: 600;
  color: var(--color-text-secondary);
  margin-bottom: 4px;
}

.message-body {
  font-size: 14px;
  line-height: 1.7;
  color: var(--color-text);
  word-wrap: break-word;
  overflow-wrap: break-word;
}

/* ============================================================
   Copy Button on Assistant Messages
   ============================================================ */
.msg-copy-btn {
  position: absolute;
  top: 8px;
  right: 8px;
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 4px 8px;
  border: 1px solid var(--color-border);
  border-radius: 4px;
  background: var(--color-bg-elevated);
  color: var(--color-text-tertiary);
  font-size: 10px;
  font-family: var(--font-sans);
  cursor: pointer;
  opacity: 0;
  transition: opacity var(--transition-fast), background var(--transition-fast), color var(--transition-fast);
  z-index: 2;
}

.message-assistant .message-content:hover .msg-copy-btn {
  opacity: 1;
}

.msg-copy-btn:hover {
  background: var(--color-surface-hover);
  color: var(--color-text);
}

.msg-copy-btn.copied {
  color: var(--color-accent);
  border-color: var(--color-accent);
}

/* ============================================================
   Feedback Thumbs
   ============================================================ */
.msg-feedback {
  display: flex;
  gap: 4px;
  margin-top: 8px;
  padding-top: 6px;
  border-top: 1px solid var(--color-border-subtle);
}

.feedback-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  border: 1px solid transparent;
  border-radius: 4px;
  background: transparent;
  font-size: 13px;
  cursor: pointer;
  opacity: 0.5;
  transition: opacity var(--transition-fast), background var(--transition-fast), border-color var(--transition-fast);
}

.feedback-btn:hover {
  opacity: 1;
  background: var(--color-surface-hover);
  border-color: var(--color-border);
}

.feedback-btn.selected {
  opacity: 1;
  border-color: var(--color-accent);
  background: var(--color-accent-subtle);
}

/* ============================================================
   Collapsible Long Responses
   ============================================================ */
.msg-collapsed .message-body {
  max-height: 7.5em;
  overflow: hidden;
  position: relative;
}

.msg-collapsed .message-body::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 3em;
  background: linear-gradient(transparent, var(--color-surface));
  pointer-events: none;
}

.msg-expand-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin-top: 6px;
  padding: 4px 10px;
  border: 1px solid var(--color-border);
  border-radius: 4px;
  background: transparent;
  color: var(--color-accent);
  font-size: 11px;
  font-family: var(--font-sans);
  cursor: pointer;
  transition: background var(--transition-fast);
}

.msg-expand-btn:hover {
  background: var(--color-accent-subtle);
}

/* ============================================================
   Markdown Rendering
   ============================================================ */
.message-body p {
  margin-bottom: 12px;
}
.message-body p:last-child {
  margin-bottom: 0;
}

.message-body strong { font-weight: 600; }
.message-body em { font-style: italic; }

.message-body a {
  color: var(--color-accent);
  text-decoration: underline;
  text-underline-offset: 2px;
  text-decoration-color: rgba(16, 185, 129, 0.4);
}
.message-body a:hover {
  text-decoration-color: var(--color-accent);
}

/* Inline code */
.message-body code {
  font-family: var(--font-mono);
  font-size: 0.85em;
  background: var(--color-inline-code-bg);
  color: var(--color-inline-code-text);
  padding: 2px 6px;
  border-radius: 4px;
}

/* Code blocks */
.code-block-wrapper {
  position: relative;
  margin: 14px 0;
  border-radius: var(--radius-md);
  overflow: hidden;
  border: 1px solid var(--color-border);
}

.code-block-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 12px;
  background: var(--color-code-header);
  border-bottom: 1px solid var(--color-border);
}

.code-block-lang {
  font-size: 11px;
  font-weight: 500;
  color: var(--color-text-tertiary);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.code-copy-btn {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 3px 8px;
  border: none;
  border-radius: 4px;
  background: transparent;
  color: var(--color-text-tertiary);
  font-size: 11px;
  font-family: var(--font-sans);
  cursor: pointer;
  transition: background var(--transition-fast), color var(--transition-fast);
}

.code-copy-btn:hover {
  background: var(--color-surface-hover);
  color: var(--color-text);
}

.code-copy-btn.copied {
  color: var(--color-accent);
}

.code-block-wrapper pre {
  margin: 0;
  padding: 14px 16px;
  background: var(--color-code-bg);
  overflow-x: auto;
  font-family: var(--font-mono);
  font-size: 12.5px;
  line-height: 1.55;
}

.code-block-wrapper pre code {
  background: none;
  padding: 0;
  color: inherit;
  font-size: inherit;
  border-radius: 0;
}

/* Headings */
.message-body h1, .message-body h2, .message-body h3, .message-body h4 {
  margin-top: 20px;
  margin-bottom: 8px;
  font-weight: 600;
  line-height: 1.3;
  color: var(--color-text);
}
.message-body h1 { font-size: 1.3em; }
.message-body h2 { font-size: 1.15em; }
.message-body h3 { font-size: 1.05em; }
.message-body h4 { font-size: 1em; color: var(--color-text-secondary); }

.message-body h1:first-child,
.message-body h2:first-child,
.message-body h3:first-child {
  margin-top: 0;
}

/* Lists */
.message-body ul, .message-body ol {
  margin: 8px 0 12px;
  padding-left: 22px;
}
.message-body li {
  margin-bottom: 4px;
}
.message-body li > ul, .message-body li > ol {
  margin-top: 4px;
  margin-bottom: 0;
}

/* Blockquotes */
.message-body blockquote {
  border-left: 3px solid var(--color-accent);
  padding-left: 14px;
  margin: 12px 0;
  color: var(--color-text-secondary);
}

/* Tables */
.message-body table {
  width: 100%;
  border-collapse: collapse;
  margin: 14px 0;
  font-size: 13px;
}
.message-body th, .message-body td {
  border: 1px solid var(--color-border);
  padding: 8px 12px;
  text-align: left;
}
.message-body th {
  background: var(--color-surface);
  font-weight: 600;
}

.message-body hr {
  border: none;
  border-top: 1px solid var(--color-border);
  margin: 16px 0;
}

/* ============================================================
   Thinking Indicator — Collapsible with elapsed time
   ============================================================ */
.thinking-indicator {
  padding: 8px 0;
  animation: fadeIn 200ms ease;
}

.thinking-row {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  max-width: 85%;
  margin-right: auto;
}

.thinking-avatar {
  flex-shrink: 0;
  width: 28px;
  height: 28px;
  border-radius: var(--radius-full);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  background: var(--color-accent-muted);
  color: var(--color-accent);
  margin-top: 2px;
  overflow: hidden;
}

.thinking-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.thinking-content {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  background: var(--color-surface);
  border-radius: var(--radius-lg) var(--radius-lg) var(--radius-lg) 4px;
}

.thinking-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--color-accent);
  animation: thinkingPulse 1.5s ease-in-out infinite;
}

@keyframes thinkingPulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.4; transform: scale(0.85); }
}

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

.thinking-timer {
  font-size: 12px;
  color: var(--color-text-tertiary);
  font-variant-numeric: tabular-nums;
}

/* Collapsible thinking details */
.thinking-details {
  border: none;
  margin: 0;
}

.thinking-details summary {
  cursor: pointer;
  list-style: none;
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  color: var(--color-text-tertiary);
  margin-top: 4px;
  padding: 2px 0;
}

.thinking-details summary::-webkit-details-marker { display: none; }

.thinking-details summary::before {
  content: '▶';
  font-size: 8px;
  transition: transform var(--transition-fast);
}

.thinking-details[open] summary::before {
  transform: rotate(90deg);
}

/* ============================================================
   Error Messages
   ============================================================ */
.message-error .message-body {
  background: var(--color-error-bg);
  border: 1px solid var(--color-error-border);
  border-radius: var(--radius-md);
  padding: 12px 16px;
  color: var(--color-error);
  font-size: 13px;
}

.retry-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-top: 10px;
  padding: 6px 14px;
  border: 1px solid var(--color-error-border);
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--color-error);
  font-size: 13px;
  font-family: var(--font-sans);
  cursor: pointer;
  transition: background var(--transition-fast);
}

.retry-btn:hover {
  background: var(--color-error-bg);
}

/* ============================================================
   Input Footer
   ============================================================ */
.input-footer {
  flex-shrink: 0;
  padding: 12px 24px 14px;
  background: var(--color-bg);
  border-top: 1px solid var(--color-border-subtle);
  transition: var(--transition-theme);
  position: relative;
}

.input-form {
  max-width: var(--input-max-width);
  margin: 0 auto;
  position: relative;
}

/* ============================================================
   Markdown Toolbar — Row above input
   ============================================================ */
.md-toolbar {
  display: flex;
  gap: 4px;
  padding: 4px 8px;
  margin-bottom: 4px;
}

.md-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border: 1px solid var(--color-border);
  border-radius: 4px;
  background: var(--color-surface);
  color: var(--color-text-secondary);
  font-size: 12px;
  font-family: var(--font-sans);
  cursor: pointer;
  transition: background var(--transition-fast), color var(--transition-fast), border-color var(--transition-fast);
}

.md-btn:hover {
  background: var(--color-surface-hover);
  color: var(--color-text);
  border-color: var(--color-text-tertiary);
}

.md-btn code {
  font-family: var(--font-mono);
  font-size: 10px;
  background: none;
  padding: 0;
  color: inherit;
}

/* ============================================================
   Input Box — Modern pill shape
   ============================================================ */
.input-box {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  background: var(--color-bg-elevated);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: 12px 16px 12px 18px;
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast), var(--transition-theme);
  box-shadow: none;
}

.input-box:focus-within {
  border-color: rgba(255, 255, 255, 0.12);
  box-shadow: none;
}

[data-theme="light"] .input-box:focus-within {
  border-color: rgba(0, 0, 0, 0.15);
}

.message-input {
  flex: 1;
  border: none;
  outline: none;
  background: transparent;
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 1.5;
  color: var(--color-text);
  resize: none;
  max-height: 180px;
  overflow-y: auto;
  padding: 2px 0;
  min-width: 0;
}

.message-input:focus {
  outline: none;
  box-shadow: none;
}

.message-input:focus-visible {
  outline: none;
}

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

/* ============================================================
   Send Button — Gradient accent
   ============================================================ */
.send-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border: none;
  border-radius: var(--radius-full);
  background: linear-gradient(135deg, #10b981, #06b6d4);
  color: white;
  cursor: pointer;
  flex-shrink: 0;
  transition: transform 100ms ease, opacity var(--transition-fast), filter var(--transition-fast);
}

.send-btn:hover:not(:disabled) {
  filter: brightness(1.1);
}

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

.send-btn:disabled {
  opacity: 0.3;
  cursor: not-allowed;
}

/* ============================================================
   Auto-Suggest Dropdown
   ============================================================ */
.autosuggest-container {
  position: absolute;
  bottom: 100%;
  left: 0;
  right: 0;
  max-width: var(--input-max-width);
  margin: 0 auto 6px;
  background: var(--color-bg-elevated);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md);
  overflow: hidden;
  z-index: 50;
}

.autosuggest-item {
  display: block;
  width: 100%;
  padding: 8px 14px;
  border: none;
  background: transparent;
  color: var(--color-text-secondary);
  font-size: 13px;
  font-family: var(--font-sans);
  text-align: left;
  cursor: pointer;
  transition: background var(--transition-fast), color var(--transition-fast);
}

.autosuggest-item:hover,
.autosuggest-item.active {
  background: var(--color-surface-hover);
  color: var(--color-text);
}

.autosuggest-item + .autosuggest-item {
  border-top: 1px solid var(--color-border-subtle);
}

/* ============================================================
   Footer
   ============================================================ */
.footer-meta {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 10px 0 2px;
}

.footer-logos {
  display: flex;
  align-items: center;
  gap: 12px;
}

.footer-org-logo {
  height: 50px;
  object-fit: contain;
  opacity: 0.85;
}

.footer-team-logo {
  height: 50px;
  object-fit: contain;
  opacity: 0.85;
}

.footer-logo-divider {
  width: 1px;
  height: 36px;
  background: var(--color-border);
}

[data-theme="light"] .footer-org-logo,
[data-theme="light"] .footer-team-logo {
  opacity: 1;
}

.footer-credit {
  text-align: center;
  font-size: 11px;
  color: var(--color-text-tertiary);
}

.footer-credit a {
  color: var(--color-accent);
  text-decoration: underline;
  text-underline-offset: 2px;
  text-decoration-color: rgba(16, 185, 129, 0.5);
  transition: color var(--transition-fast), text-decoration-color var(--transition-fast);
}

.footer-credit a:hover {
  color: var(--color-accent-hover);
  text-decoration-color: var(--color-accent);
}

/* ============================================================
   Mobile Responsive
   ============================================================ */
@media (max-width: 768px) {
  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    height: 100%;
    transform: translateX(-100%);
    box-shadow: var(--shadow-lg);
    width: var(--sidebar-width);
  }

  .sidebar.open {
    transform: translateX(0);
  }

  .sidebar.collapsed {
    width: var(--sidebar-width);
    transform: translateX(-100%);
    border-right: 1px solid var(--color-border);
  }

  .sidebar-close {
    display: flex;
  }

  .messages-container {
    padding: 16px 16px 32px;
  }

  .input-footer {
    padding: 10px 12px 10px;
  }

  .input-box {
    padding: 10px 12px 10px 16px;
    border-radius: var(--radius-lg);
  }

  .message-input {
    font-size: 16px; /* Prevents iOS zoom */
  }

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

  .welcome-state {
    padding: 40px 16px 24px;
  }

  .md-toolbar { display: none; }
}

@media (min-width: 769px) {
  .sidebar-close {
    display: none;
  }
}

/* ============================================================
   Reduced Motion
   ============================================================ */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
  .chat-main {
    scroll-behavior: auto;
  }
}

/* ============================================================
   Scrollbar
   ============================================================ */
.chat-main::-webkit-scrollbar,
.topics-nav::-webkit-scrollbar {
  width: 5px;
}
.chat-main::-webkit-scrollbar-track,
.topics-nav::-webkit-scrollbar-track {
  background: transparent;
}
.chat-main::-webkit-scrollbar-thumb,
.topics-nav::-webkit-scrollbar-thumb {
  background: var(--color-border);
  border-radius: 3px;
}
.chat-main::-webkit-scrollbar-thumb:hover,
.topics-nav::-webkit-scrollbar-thumb:hover {
  background: var(--color-text-tertiary);
}

/* ============================================================
   Focus & Accessibility
   ============================================================ */
*:focus-visible {
  outline: 2px solid var(--color-border);
  outline-offset: 2px;
}

/* ============================================================
   High Contrast
   ============================================================ */
@media (forced-colors: active) {
  .message-avatar { border: 1px solid CanvasText; }
  .send-btn { border: 1px solid ButtonText; }
  .input-box { border: 2px solid CanvasText; }
  .btn-icon { border: 1px solid CanvasText; }
}


/* ============================================================
   Beta Banner
   ============================================================ */
.beta-banner {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 16px;
  background: rgba(234, 179, 8, 0.08);
  border-bottom: 1px solid rgba(234, 179, 8, 0.15);
  color: #eab308;
  font-size: 0.75rem;
  font-weight: 500;
  text-align: center;
  justify-content: center;
}

.beta-banner svg {
  flex-shrink: 0;
  color: #eab308;
  width: 14px;
  height: 14px;
}

[data-theme="light"] .beta-banner {
  background: rgba(234, 179, 8, 0.06);
  border-bottom-color: rgba(234, 179, 8, 0.12);
  color: #92400e;
}

[data-theme="light"] .beta-banner svg {
  color: #92400e;
}

/* ============================================================
   Header Logos & Senku Brand
   ============================================================ */
.senku-brand {
  display: flex;
  align-items: center;
  gap: 10px;
}

.senku-logo {
  height: 50px;
  width: 50px;
  object-fit: cover;
  border-radius: 50%;
  border: 2px solid var(--color-accent-muted);
}

/* ============================================================
   Sidebar — Topics & Sample Questions (split sections)
   ============================================================ */
.topic-section {
  margin-bottom: 22px;
}

.topic-section:last-child {
  margin-bottom: 0;
}

.topic-section-title {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--color-text-tertiary);
  margin-bottom: 6px;
  padding: 0 2px;
}

.topic-section-desc {
  font-size: 11.5px;
  color: var(--color-text-tertiary);
  margin-bottom: 10px;
  padding: 0 2px;
  line-height: 1.4;
}

/* Topic chips — inline pill buttons with gradient hover */
.topic-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.topic-chip {
  display: inline-flex;
  width: auto;
  align-items: center;
  padding: 5px 12px;
  border-radius: 14px;
  font-size: 11.5px;
  font-weight: 500;
  background: var(--color-accent-subtle);
  border: 1px solid var(--color-accent-muted);
  color: var(--color-accent);
  cursor: pointer;
  transition: all 0.15s ease;
  white-space: nowrap;
  margin: 0;
}

.topic-chip:hover {
  background: linear-gradient(135deg, rgba(16, 185, 129, 0.15), rgba(6, 182, 212, 0.15));
  border-color: var(--color-accent);
  transform: translateY(-1px);
}

/* Sample question items — full-width list style */
.topic-questions {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.topic-question {
  display: block;
  width: 100%;
  text-align: left;
  padding: 7px 10px;
  border-radius: 6px;
  font-size: 12px;
  color: var(--color-text-secondary);
  background: transparent;
  border: 1px solid transparent;
  cursor: pointer;
  transition: all 0.15s ease;
  line-height: 1.4;
}

.topic-question:hover {
  background: var(--color-surface-hover);
  border-color: var(--color-border);
  color: var(--color-text);
}


/* ============================================================
   Sidebar — MCP Installation Section
   ============================================================ */
.sidebar-mcp-section {
  margin-top: 8px;
  padding: 18px 14px 14px;
  border-top: 1px solid var(--color-border);
}

.mcp-section-title {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--color-text-tertiary);
  margin-bottom: 6px;
}

.mcp-description {
  font-size: 11.5px;
  color: var(--color-text-tertiary);
  margin-bottom: 12px;
  line-height: 1.45;
}

.mcp-code {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: 6px;
  padding: 10px;
  overflow-x: auto;
  margin: 4px 0;
}

.mcp-code code {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--color-text-secondary);
  white-space: pre;
  line-height: 1.5;
}

.mcp-docs-link {
  display: inline-block;
  font-size: 11.5px;
  color: var(--color-accent);
  text-decoration: none;
  font-weight: 500;
  margin-top: 4px;
}

.mcp-docs-link:hover {
  text-decoration: underline;
}


/* ============================================================
   Sidebar Resize Handle
   ============================================================ */
.sidebar-resize {
  width: 4px;
  cursor: col-resize;
  background: transparent;
  flex-shrink: 0;
  position: relative;
  z-index: 10;
  transition: background 0.15s;
}

.sidebar-resize:hover,
.sidebar-resize.active {
  background: var(--color-accent);
}

.sidebar-resize::after {
  content: '';
  position: absolute;
  top: 0;
  left: -3px;
  right: -3px;
  bottom: 0;
}

@media (max-width: 768px) {
  .sidebar-resize { display: none; }
}

/* Report Embed Styles */
.report-embed{margin-top:12px;border:1px solid var(--border-subtle);border-radius:8px;overflow:hidden;background:var(--bg-secondary)}
.report-embed-header{display:flex;justify-content:space-between;align-items:center;padding:8px 12px;background:var(--bg-tertiary);border-bottom:1px solid var(--border-subtle);font-size:12px}
.report-embed-actions{display:flex;gap:8px}
.report-expand-btn,.report-open-btn{background:var(--bg-primary);border:1px solid var(--border-subtle);border-radius:4px;padding:3px 8px;font-size:11px;color:var(--text-primary);cursor:pointer;text-decoration:none}
.report-expand-btn:hover,.report-open-btn:hover{background:var(--accent-primary);color:#fff}
.report-iframe{width:100%;height:400px;border:none;display:block}
.report-embed.expanded .report-iframe{height:80vh}


/* Report Fullscreen Overlay */
.report-fullscreen-overlay{position:fixed;top:0;left:0;width:100%;height:100%;background:var(--bg-primary);z-index:10000;display:none;flex-direction:column}
.report-fullscreen-overlay.visible{display:flex}
.report-fullscreen-header{display:flex;justify-content:space-between;align-items:center;padding:10px 16px;background:var(--bg-secondary);border-bottom:1px solid var(--border-subtle)}
.report-fullscreen-header span{font-size:14px;font-weight:600}
.report-back-btn{background:var(--accent-primary);color:#fff;border:none;border-radius:6px;padding:6px 14px;font-size:13px;cursor:pointer}
.report-back-btn:hover{opacity:0.9}
.report-fullscreen-iframe{flex:1;width:100%;border:none}


/* Report Link Label (replaces raw URL in message) */
.report-link-label{background:var(--accent-primary);color:#fff;padding:2px 8px;border-radius:4px;font-size:12px;font-weight:500}

