:root {
  --indigo: #312e81;
  --indigo-strong: #1b2a4a;
  --amber: #d97706;
  --amber-soft: #fef3c7;
  --ink: #1a1a2e;
  --muted: #6b7280;
  --line: #e5e7eb;
  --paper: #fafbfc;
  --panel: #ffffff;
  --user: #f7f1e6;
  --danger: #b91c1c;
  --ok: #166534;
  --shadow: 0 18px 42px rgba(26, 26, 46, 0.08);
  --page-glow: radial-gradient(circle at top right, rgba(217, 119, 6, 0.08), transparent 28%);
  --page-base: linear-gradient(180deg, #f6f8fb 0%, #eef2f7 100%);
  --surface-soft: #fafbfc;
  --surface-subtle: #f8fafc;
  --surface-tint: #eef2ff;
  --focus-outline: rgba(49, 46, 129, 0.12);
  --focus-border: rgba(49, 46, 129, 0.35);
  --overlay: rgba(15, 23, 42, 0.42);
}

:root[data-theme="dark"] {
  --indigo: #c3d6ff;
  --indigo-strong: #f8fbff;
  --amber: #f6ad3c;
  --amber-soft: rgba(246, 173, 60, 0.18);
  --ink: #e8eef8;
  --muted: #9fb2cc;
  --line: #223754;
  --paper: #06101d;
  --panel: #0b192c;
  --user: #132742;
  --danger: #f7b2b2;
  --ok: #8ce6ad;
  --shadow: 0 24px 64px rgba(1, 8, 20, 0.58);
  --page-glow:
    radial-gradient(circle at top right, rgba(246, 173, 60, 0.14), transparent 28%),
    radial-gradient(circle at 16% 18%, rgba(59, 130, 246, 0.12), transparent 24%);
  --page-base: linear-gradient(180deg, #020816 0%, #071324 48%, #09172a 100%);
  --surface-soft: #10233a;
  --surface-subtle: #122943;
  --surface-tint: #173453;
  --focus-outline: rgba(195, 214, 255, 0.18);
  --focus-border: rgba(195, 214, 255, 0.42);
  --overlay: rgba(1, 8, 20, 0.82);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  font-family: Manrope, "Segoe UI", sans-serif;
  color: var(--ink);
  background:
    var(--page-glow),
    var(--page-base);
  padding: 24px;
}

:root[data-theme="dark"] body {
  color: var(--ink);
}

button,
input,
textarea,
select {
  font: inherit;
}

a {
  color: var(--indigo);
}

.shell {
  width: min(1360px, 100%);
  margin: 0 auto;
}

.frame {
  border: 1px solid var(--line);
  border-radius: 20px;
  overflow: hidden;
  background: var(--panel);
  box-shadow: var(--shadow);
  min-height: min(90vh, 980px);
}

:root[data-theme="dark"] .frame,
:root[data-theme="dark"] .topbar,
:root[data-theme="dark"] .settings,
:root[data-theme="dark"] .history-panel,
:root[data-theme="dark"] .composer,
:root[data-theme="dark"] .dialog {
  background: rgba(11, 25, 44, 0.94);
  backdrop-filter: blur(12px);
}

.sidebar {
  display: none;
}

.brand-kicker {
  font-size: 0.78rem;
  letter-spacing: 0.12em;
  color: var(--indigo);
  font-weight: 700;
}

.brand-lockup,
.topbar-brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-lockup.compact {
  gap: 8px;
}

.app-mark {
  width: 48px;
  height: 48px;
  border-radius: 14px;
  flex: 0 0 auto;
  box-shadow: 0 8px 18px rgba(49, 46, 129, 0.14);
}

.app-mark.compact {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  box-shadow: none;
}

.wordmark {
  margin: 0;
  font-size: 2rem;
  line-height: 1.05;
  color: var(--indigo-strong);
  letter-spacing: 0.02em;
}

.tagline,
.card p,
.card li,
.topbar span,
.hint,
.setting-option span,
.helper-text,
.viewer-meta {
  color: var(--muted);
  line-height: 1.6;
}

.tagline,
.card p,
.card li {
  font-size: 0.94rem;
}

.card {
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 16px;
  background: var(--panel);
}

.card h2,
.card h3 {
  margin: 0 0 10px;
  font-size: 0.92rem;
  color: var(--indigo-strong);
}

.card ul {
  margin: 0;
  padding-left: 18px;
  display: grid;
  gap: 8px;
}

.main {
  display: grid;
  grid-template-rows: auto auto auto 1fr auto;
  min-height: 0;
  background: var(--paper);
}

:root[data-theme="dark"] .main {
  background:
    radial-gradient(circle at top right, rgba(29, 78, 216, 0.08), transparent 24%),
    linear-gradient(180deg, #071322 0%, #081525 55%, #09192c 100%);
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 14px;
  padding: 16px 18px 14px;
  border-bottom: 1px solid var(--line);
  background: var(--panel);
}

.topbar strong {
  display: block;
  font-size: 1rem;
  color: var(--indigo-strong);
}

.topbar span {
  display: block;
  margin-top: 4px;
  font-size: 0.8rem;
  max-width: 520px;
}

.header-stack {
  display: grid;
  gap: 8px;
}

.status-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.status-detail {
  font-size: 0.84rem;
  color: var(--muted);
  line-height: 1.5;
}

.status-badge {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 5px 10px;
  background: var(--amber-soft);
  color: #92400e;
  font-size: 0.74rem;
  font-weight: 700;
  letter-spacing: 0.03em;
}

.status-badge.ok {
  background: #dcfce7;
  color: var(--ok);
}

.status-badge.offline {
  background: #fee2e2;
  color: var(--danger);
}

:root[data-theme="dark"] .status-badge {
  background: rgba(246, 173, 60, 0.14);
  color: #ffd79c;
}

:root[data-theme="dark"] .status-badge.ok {
  background: rgba(34, 197, 94, 0.18);
  color: #b8f7c9;
}

:root[data-theme="dark"] .status-badge.offline {
  background: rgba(248, 113, 113, 0.18);
  color: #ffd0d0;
}

.actions,
.message-actions,
.source-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

button,
.button-link {
  border-radius: 999px;
  padding: 10px 14px;
  font-size: 0.88rem;
  cursor: pointer;
  transition: background-color 0.15s ease, color 0.15s ease, border-color 0.15s ease;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.ghost,
.button-link.ghost {
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--indigo-strong);
}

.ghost:hover,
.button-link.ghost:hover {
  border-color: #cbd5e1;
  background: var(--surface-subtle);
}

:root[data-theme="dark"] .ghost,
:root[data-theme="dark"] .button-link.ghost {
  background: rgba(11, 25, 44, 0.92);
  border-color: #27405f;
  color: var(--indigo-strong);
}

:root[data-theme="dark"] .ghost:hover,
:root[data-theme="dark"] .button-link.ghost:hover {
  background: #132a45;
  border-color: #36547b;
}

.accent {
  border: 1px solid var(--amber);
  background: var(--amber);
  color: #ffffff;
  font-weight: 600;
}

.accent:hover {
  background: #b45309;
  border-color: #b45309;
}

.accent.danger-button {
  border-color: #dc2626;
  background: #dc2626;
}

.accent.danger-button:hover {
  border-color: #b91c1c;
  background: #b91c1c;
}

.mini,
.button-link.mini {
  padding: 7px 10px;
  font-size: 0.8rem;
}

.icon-button {
  width: 42px;
  height: 42px;
  padding: 0;
  flex: 0 0 auto;
}

.icon-button.mini {
  width: 34px;
  height: 34px;
}

.icon-button svg {
  width: 18px;
  height: 18px;
}

.icon-button.is-done {
  border-color: #bbf7d0;
  background: #ecfdf5;
  color: var(--ok);
}

.icon-button.is-active {
  border-color: rgba(217, 119, 6, 0.35);
  background: var(--amber-soft);
  color: var(--amber);
}

.icon-button:disabled,
button:disabled {
  cursor: not-allowed;
  opacity: 0.6;
}

.send-button.is-loading {
  position: relative;
}

.send-button.is-loading::after {
  content: "";
  position: absolute;
  inset: 14px;
  border-radius: 999px;
  border: 2px solid rgba(255, 255, 255, 0.35);
  border-top-color: #ffffff;
  animation: spin 0.8s linear infinite;
}

.send-button.is-loading svg {
  opacity: 0.18;
}

.send-button {
  width: 52px;
  height: 52px;
}

.settings,
.history-panel {
  border-bottom: 1px solid var(--line);
  background: var(--panel);
  padding: 0 18px;
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.18s ease, padding-top 0.18s ease, padding-bottom 0.18s ease;
}

.settings.open,
.history-panel.open {
  max-height: 560px;
  padding-top: 16px;
  padding-bottom: 16px;
}

.dashboard-strip {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 10px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--line);
  background: linear-gradient(180deg, var(--panel) 0%, var(--surface-soft) 100%);
}

.dashboard-card {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 12px;
  background: var(--panel);
  text-align: left;
  display: grid;
  gap: 4px;
}

.dashboard-card:hover {
  border-color: rgba(49, 46, 129, 0.2);
  background: var(--surface-subtle);
}

.dashboard-card.is-summary {
  background: var(--surface-tint);
}

:root[data-theme="dark"] .dashboard-strip {
  background: linear-gradient(180deg, rgba(11, 25, 44, 0.96) 0%, rgba(13, 31, 51, 0.96) 100%);
}

:root[data-theme="dark"] .dashboard-card {
  background: linear-gradient(180deg, rgba(16, 35, 58, 0.98) 0%, rgba(11, 25, 44, 0.98) 100%);
  border-color: #27405f;
  box-shadow: inset 0 1px 0 rgba(195, 214, 255, 0.04);
}

:root[data-theme="dark"] .dashboard-card:hover {
  background: #15304d;
  border-color: #35557d;
}

.dashboard-label {
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--indigo);
}

.dashboard-value {
  font-size: 1.35rem;
  line-height: 1;
  font-weight: 800;
  color: var(--indigo-strong);
}

.dashboard-meta {
  font-size: 0.74rem;
  line-height: 1.4;
  color: var(--muted);
}

.dashboard-empty {
  grid-column: 1 / -1;
  font-size: 0.82rem;
  color: var(--muted);
}

.workspace-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
  padding: 12px 18px;
  border-bottom: 1px solid var(--line);
  background:
    linear-gradient(90deg, rgba(49, 46, 129, 0.04), rgba(217, 119, 6, 0.04)),
    var(--panel);
}

.workspace-info {
  display: grid;
  gap: 4px;
}

.workspace-info strong {
  font-size: 0.84rem;
  color: var(--indigo-strong);
}

.workspace-info span {
  font-size: 0.76rem;
  color: var(--muted);
}

.workspace-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.workspace-pill,
.meta-pill {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 4px 9px;
  border: 1px solid var(--line);
  background: var(--surface-subtle);
  color: var(--indigo-strong);
  font-size: 0.72rem;
  font-weight: 700;
}

.workspace-pill.accent-pill {
  border-color: rgba(217, 119, 6, 0.22);
  background: var(--amber-soft);
  color: #92400e;
}

:root[data-theme="dark"] .workspace-bar {
  background:
    linear-gradient(90deg, rgba(59, 130, 246, 0.08), rgba(246, 173, 60, 0.08)),
    rgba(11, 25, 44, 0.96);
}

:root[data-theme="dark"] .workspace-pill,
:root[data-theme="dark"] .meta-pill {
  background: rgba(16, 35, 58, 0.92);
  border-color: #2b486c;
}

:root[data-theme="dark"] .workspace-pill.accent-pill {
  background: rgba(246, 173, 60, 0.16);
  border-color: rgba(246, 173, 60, 0.2);
  color: #ffcf95;
}

.settings-grid {
  display: grid;
  gap: 18px;
}

.settings-section {
  display: grid;
  gap: 12px;
}

.settings h3 {
  margin: 0 0 10px;
  font-size: 0.9rem;
  color: var(--indigo-strong);
}

.settings p {
  margin: 0 0 12px;
  font-size: 0.82rem;
}

.panel-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.panel-head h3 {
  margin: 0 0 6px;
  font-size: 0.9rem;
  color: var(--indigo-strong);
}

.panel-head p {
  margin: 0;
  font-size: 0.82rem;
  color: var(--muted);
}

.history-list {
  display: grid;
  gap: 10px;
}

.history-toolbar {
  display: grid;
  gap: 10px;
  margin-bottom: 14px;
}

.history-toolbar strong {
  display: block;
  font-size: 0.8rem;
  color: var(--indigo-strong);
}

.history-toolbar span {
  display: block;
  margin-top: 4px;
  font-size: 0.76rem;
  color: var(--muted);
}

.filter-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.filter-chip.active {
  border-color: rgba(49, 46, 129, 0.2);
  background: var(--surface-tint);
}

.history-group {
  display: grid;
  gap: 10px;
}

.history-group-label {
  font-size: 0.76rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--indigo);
  padding-left: 4px;
}

.history-item {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 12px 14px;
  background: var(--surface-soft);
  text-align: left;
  display: grid;
  gap: 6px;
}

.history-item-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.history-item.active {
  border-color: rgba(49, 46, 129, 0.2);
  background: var(--surface-tint);
}

:root[data-theme="dark"] .history-item,
:root[data-theme="dark"] .setting-option,
:root[data-theme="dark"] .card {
  background: rgba(16, 35, 58, 0.9);
  border-color: #27405f;
}

:root[data-theme="dark"] .history-item.active,
:root[data-theme="dark"] .filter-chip.active {
  background: #183654;
  border-color: #3a5d88;
}

.history-title {
  font-size: 0.88rem;
  font-weight: 700;
  color: var(--indigo-strong);
}

.history-meta,
.history-empty {
  font-size: 0.78rem;
  color: var(--muted);
  line-height: 1.5;
}

.history-project-pill {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 3px 8px;
  background: var(--surface-tint);
  color: var(--indigo);
  font-size: 0.7rem;
  font-weight: 700;
  white-space: nowrap;
}

.setting-options {
  display: grid;
  gap: 10px;
}

.setting-option {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px;
  background: var(--surface-soft);
}

.compact-options {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

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

.setting-option input {
  margin-top: 2px;
}

.setting-option strong {
  display: block;
  font-size: 0.88rem;
  color: var(--indigo-strong);
}

.favorite-editors {
  display: grid;
  gap: 10px;
}

.favorite-editor {
  display: grid;
  grid-template-columns: 72px minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
}

.favorite-editor-label {
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--indigo-strong);
}

.messages {
  padding: 18px;
  overflow-y: auto;
  display: grid;
  gap: 14px;
  align-content: start;
}

:root[data-theme="dark"] .messages {
  background:
    radial-gradient(circle at 88% 8%, rgba(246, 173, 60, 0.04), transparent 16%),
    linear-gradient(180deg, rgba(6, 16, 29, 0.36) 0%, rgba(8, 21, 37, 0.08) 100%);
}

.message {
  max-width: min(920px, 100%);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 14px 16px;
  background: var(--panel);
}

.message.user {
  justify-self: end;
  background: var(--user);
  border-color: #e8dccb;
}

.message.bot {
  justify-self: start;
}

:root[data-theme="dark"] .message {
  border-color: #2a4466;
  box-shadow: 0 14px 28px rgba(1, 8, 20, 0.22);
}

:root[data-theme="dark"] .message.bot {
  background: linear-gradient(180deg, rgba(247, 250, 255, 0.98) 0%, rgba(235, 242, 252, 0.98) 100%);
  border-color: rgba(246, 173, 60, 0.42);
}

:root[data-theme="dark"] .message.user {
  background: linear-gradient(180deg, rgba(19, 39, 66, 0.98) 0%, rgba(14, 31, 52, 0.98) 100%);
  border-color: #55749a;
}

:root[data-theme="dark"] .message.user .message-role,
:root[data-theme="dark"] .message.user .message-body,
:root[data-theme="dark"] .message.user .message-body strong,
:root[data-theme="dark"] .message.user .message-body h1,
:root[data-theme="dark"] .message.user .message-body h2,
:root[data-theme="dark"] .message.user .message-body h3 {
  color: #edf4ff;
}

:root[data-theme="dark"] .message.bot .message-role {
  color: #8ea7ff;
}

.message.thinking {
  border-style: dashed;
  background: var(--surface-soft);
}

.message.thinking .message-body {
  color: var(--muted);
}

:root[data-theme="dark"] .message.thinking {
  background: rgba(16, 35, 58, 0.95);
  border-color: #395980;
}

:root[data-theme="dark"] .message.thinking .message-body,
:root[data-theme="dark"] .message.thinking .message-role {
  color: #c3d6ff;
}

.message-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
  font-size: 0.78rem;
}

.message-role {
  font-weight: 700;
  letter-spacing: 0.06em;
  color: var(--indigo);
}

.message-subhead {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 10px;
}

.mode-badge {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 3px 8px;
  background: var(--amber-soft);
  color: #92400e;
  font-size: 0.72rem;
  font-weight: 700;
}

:root[data-theme="dark"] .mode-badge {
  background: rgba(246, 173, 60, 0.16);
  color: #b85e0d;
}

.message-body,
.viewer-body {
  font-size: 0.96rem;
  line-height: 1.7;
  color: var(--ink);
}

.message-body p,
.viewer-body p {
  margin: 0 0 10px;
}

.message-body h1,
.message-body h2,
.message-body h3,
.viewer-body h1,
.viewer-body h2,
.viewer-body h3 {
  margin: 0 0 10px;
  line-height: 1.3;
  color: var(--indigo-strong);
}

.message-body h1,
.viewer-body h1 {
  font-size: 1.18rem;
}

.message-body h2,
.viewer-body h2 {
  font-size: 1.05rem;
}

.message-body h3,
.viewer-body h3 {
  font-size: 0.96rem;
}

.message-body p:last-child,
.message-body h1:last-child,
.message-body h2:last-child,
.message-body h3:last-child,
.message-body ul:last-child,
.message-body ol:last-child,
.message-body blockquote:last-child,
.message-body table:last-child,
.message-body .media-block:last-child,
.message-body .mermaid-shell:last-child,
.message-body pre:last-child,
.viewer-body p:last-child,
.viewer-body h1:last-child,
.viewer-body h2:last-child,
.viewer-body h3:last-child,
.viewer-body ul:last-child,
.viewer-body ol:last-child,
.viewer-body blockquote:last-child,
.viewer-body table:last-child,
.viewer-body .media-block:last-child,
.viewer-body .mermaid-shell:last-child,
.viewer-body pre:last-child {
  margin-bottom: 0;
}

.message-body ul,
.message-body ol,
.viewer-body ul,
.viewer-body ol {
  margin: 0 0 10px;
  padding-left: 20px;
}

.message-body strong,
.viewer-body strong {
  color: var(--indigo-strong);
}

.message-body em,
.viewer-body em {
  font-style: italic;
}

.message-body code,
.viewer-body code {
  font-family: "JetBrains Mono", "SFMono-Regular", monospace;
  font-size: 0.9em;
  padding: 1px 4px;
  border-radius: 4px;
  background: var(--surface-tint);
  color: var(--indigo-strong);
}

:root[data-theme="dark"] .message.bot .message-body,
:root[data-theme="dark"] .message.bot .message-body strong,
:root[data-theme="dark"] .message.bot .message-body h1,
:root[data-theme="dark"] .message.bot .message-body h2,
:root[data-theme="dark"] .message.bot .message-body h3,
:root[data-theme="dark"] .message.bot .message-body code {
  color: #102132;
}

:root[data-theme="dark"] .message.bot .message-body code {
  background: rgba(17, 33, 50, 0.08);
}

.message-body pre,
.viewer-body pre {
  margin: 0 0 10px;
  padding: 12px;
  border-radius: 10px;
  overflow-x: auto;
  background: var(--surface-subtle);
  border: 1px solid var(--line);
  font-family: "JetBrains Mono", "SFMono-Regular", monospace;
  font-size: 0.85rem;
  line-height: 1.6;
}

.message-body pre code,
.viewer-body pre code {
  padding: 0;
  background: transparent;
}

.message-body blockquote,
.viewer-body blockquote {
  margin: 0 0 10px;
  padding: 10px 12px;
  border-left: 3px solid var(--amber);
  border-radius: 0 10px 10px 0;
  background: var(--surface-soft);
  color: var(--muted);
}

.message-body table,
.viewer-body table {
  width: 100%;
  margin: 0 0 10px;
  border-collapse: collapse;
  border: 1px solid var(--line);
  border-radius: 12px;
  overflow: hidden;
  display: block;
  overflow-x: auto;
  background: var(--panel);
}

.message-body thead,
.viewer-body thead {
  background: var(--surface-soft);
}

.message-body th,
.message-body td,
.viewer-body th,
.viewer-body td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  border-right: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
  min-width: 120px;
}

.message-body th:last-child,
.message-body td:last-child,
.viewer-body th:last-child,
.viewer-body td:last-child {
  border-right: 0;
}

.message-body tr:last-child td,
.viewer-body tr:last-child td {
  border-bottom: 0;
}

.media-block {
  margin: 0 0 10px;
}

.media-block img {
  display: block;
  max-width: 100%;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: var(--panel);
}

.media-block figcaption {
  margin-top: 8px;
  font-size: 0.76rem;
  color: var(--muted);
}

.mermaid-shell {
  margin: 0 0 10px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface-soft);
  overflow-x: auto;
}

.mermaid-shell svg {
  max-width: 100%;
  height: auto;
}

.sources-panel {
  margin-top: 12px;
  border-top: 1px solid var(--line);
  padding-top: 12px;
}

.sources-summary {
  cursor: pointer;
  list-style: none;
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--indigo-strong);
}

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

.sources {
  margin-top: 10px;
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  font-size: 0.76rem;
  color: var(--muted);
}

.source-prefix {
  color: var(--muted);
}

.source-link {
  color: var(--indigo);
  font-weight: 600;
  text-decoration: none;
  border: 1px solid var(--line);
  background: var(--surface-subtle);
  border-radius: 999px;
  padding: 4px 8px;
}

.source-link:hover {
  text-decoration: underline;
}

:root[data-theme="dark"] .sources-summary {
  color: #35569d;
}

:root[data-theme="dark"] .source-link {
  background: rgba(19, 39, 66, 0.08);
  border-color: rgba(29, 78, 216, 0.18);
  color: #2d58b3;
}

.composer {
  border-top: 1px solid var(--line);
  background: var(--panel);
  padding: 14px 18px 18px;
}

.composer-utility {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}

.slash-bar {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.composer-tools {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.project-picker {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 4px 6px 4px 12px;
  background: var(--panel);
}

.project-picker span,
.decision-picker span {
  font-size: 0.76rem;
  font-weight: 700;
  color: var(--indigo-strong);
}

.project-select,
.decision-frame-select {
  border: 0;
  background: transparent;
  color: var(--ink);
  padding: 4px 22px 4px 2px;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
}

.project-select:focus {
  outline: none;
}

.decision-picker {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 4px 6px 4px 12px;
  background: var(--panel);
}

:root[data-theme="dark"] .project-picker,
:root[data-theme="dark"] .decision-picker {
  background: rgba(16, 35, 58, 0.95);
  border-color: #284464;
}

.decision-frame-select:focus {
  outline: none;
}

.slash-chip {
  font-family: "JetBrains Mono", "SFMono-Regular", monospace;
  letter-spacing: -0.01em;
}

.quick-prompts {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 10px;
}

.workflow-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 10px;
}

.prompt-chip {
  padding-inline: 12px;
}

.workflow-chip {
  padding-inline: 12px;
}

.workflow-add {
  padding-inline: 10px;
}

.focus-note {
  margin-bottom: 10px;
  font-size: 0.76rem;
  color: var(--muted);
}

.focus-banner {
  display: none;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
  border: 1px solid rgba(49, 46, 129, 0.12);
  border-radius: 14px;
  padding: 10px 12px;
  background: var(--surface-tint);
}

:root[data-theme="dark"] .focus-banner {
  background: rgba(16, 35, 58, 0.96);
  border-color: #2f4c71;
}

.focus-banner strong {
  font-size: 0.82rem;
  color: var(--indigo-strong);
}

.focus-banner span {
  flex: 1 1 auto;
  font-size: 0.76rem;
  color: var(--muted);
}

.composer form,
.access-form {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
}

.composer form[aria-busy="true"] textarea {
  opacity: 0.82;
}

.attachment-list {
  display: none;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 10px;
}

.attachment-list.has-items {
  display: flex;
}

.composer-presence {
  margin-top: 10px;
  font-size: 0.76rem;
  color: var(--muted);
  line-height: 1.5;
}

.attachment-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 6px 6px 6px 12px;
  background: var(--surface-subtle);
  font-size: 0.76rem;
  color: var(--muted);
}

:root[data-theme="dark"] .attachment-chip {
  background: rgba(16, 35, 58, 0.95);
  border-color: #2c496d;
  color: #c3d6ff;
}

.attachment-remove {
  padding: 5px 8px;
}

textarea,
input[type="password"],
input[type="text"] {
  width: 100%;
  border-radius: 14px;
  border: 1px solid var(--line);
  padding: 14px 16px;
  color: var(--ink);
  background: var(--panel);
  line-height: 1.5;
}

:root[data-theme="dark"] textarea,
:root[data-theme="dark"] input[type="password"],
:root[data-theme="dark"] input[type="text"],
:root[data-theme="dark"] .entry-select {
  background: rgba(8, 20, 34, 0.94);
  border-color: #294567;
  color: #edf4ff;
}

:root[data-theme="dark"] textarea::placeholder,
:root[data-theme="dark"] input[type="password"]::placeholder,
:root[data-theme="dark"] input[type="text"]::placeholder {
  color: #7e94b3;
}

textarea {
  min-height: 84px;
  max-height: 220px;
  resize: vertical;
}

textarea:focus,
input[type="password"]:focus,
input[type="text"]:focus {
  outline: 2px solid var(--focus-outline);
  border-color: var(--focus-border);
}

.hint,
.helper-text {
  margin-top: 8px;
  font-size: 0.76rem;
}

.overlay {
  position: fixed;
  inset: 0;
  background: var(--overlay);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.overlay.open {
  display: flex;
}

.dialog {
  width: min(560px, 100%);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 22px;
  box-shadow: var(--shadow);
}

.dialog h2 {
  margin: 0 0 8px;
  color: var(--indigo-strong);
  font-size: 1.1rem;
}

.entry-dialog {
  width: min(680px, 100%);
}

.entry-dialog-head {
  margin-bottom: 16px;
}

.entry-form {
  display: grid;
  gap: 14px;
}

.entry-fields {
  display: grid;
  gap: 12px;
}

.entry-field {
  display: grid;
  gap: 8px;
}

.entry-field-label {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--indigo-strong);
}

.entry-field-help {
  font-size: 0.74rem;
  color: var(--muted);
}

.entry-select {
  width: 100%;
  border-radius: 14px;
  border: 1px solid var(--line);
  padding: 14px 16px;
  color: var(--ink);
  background: var(--panel);
  line-height: 1.5;
}

.entry-select:focus {
  outline: 2px solid var(--focus-outline);
  border-color: var(--focus-border);
}

.entry-actions {
  display: flex;
  justify-content: flex-end;
}

.error-text {
  color: var(--danger);
}

.viewer-shell {
  width: min(980px, 100%);
  margin: 0 auto;
}

.viewer-frame {
  border: 1px solid var(--line);
  border-radius: 20px;
  overflow: hidden;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.viewer-top {
  padding: 18px 22px;
  border-bottom: 1px solid var(--line);
  background: var(--surface-soft);
  display: grid;
  gap: 8px;
}

.viewer-title {
  margin: 0;
  font-size: 1rem;
  color: var(--indigo-strong);
}

.viewer-body {
  padding: 22px;
}

body.focus-mode {
  padding: 14px;
}

body.focus-mode .topbar,
body.focus-mode .settings,
body.focus-mode .history-panel,
body.focus-mode .focus-note {
  display: none;
}

body.focus-mode .focus-banner {
  display: flex;
}

body.focus-mode .frame {
  min-height: calc(100vh - 28px);
}

body.focus-mode .main {
  min-height: calc(100vh - 28px);
}

@media (min-width: 981px) {
  body.focus-mode .main {
    grid-template-columns: minmax(0, 1.4fr) minmax(340px, 0.6fr);
    grid-template-rows: 1fr;
  }

  body.focus-mode .messages {
    grid-column: 1;
    border-right: 1px solid var(--line);
    padding: 22px;
  }

  body.focus-mode .composer {
    grid-column: 2;
    border-top: 0;
    padding: 22px;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    background:
      radial-gradient(circle at top right, rgba(217, 119, 6, 0.08), transparent 36%),
      linear-gradient(180deg, var(--panel) 0%, var(--surface-subtle) 100%);
  }

  body.focus-mode .composer form {
    grid-template-columns: 1fr;
  }

  body.focus-mode textarea {
    min-height: 220px;
  }
}

@media (max-width: 1180px) {
  .dashboard-strip {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
}

@media (max-width: 720px) {
  body {
    padding: 12px;
  }

  .topbar,
  .history-panel,
  .settings,
  .workspace-bar,
  .messages,
  .composer {
    padding-left: 14px;
    padding-right: 14px;
  }

  .topbar {
    align-items: stretch;
    flex-direction: column;
  }

  .actions {
    justify-content: flex-start;
  }

  .message {
    max-width: 100%;
  }

  .panel-head {
    flex-direction: column;
    align-items: stretch;
  }

  .composer-utility,
  .workspace-bar,
  .focus-banner {
    flex-direction: column;
    align-items: stretch;
  }

  .history-item-top {
    flex-direction: column;
    align-items: stretch;
  }

  .dashboard-strip {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .composer-tools {
    justify-content: space-between;
  }

  .project-picker,
  .decision-picker {
    width: 100%;
    justify-content: space-between;
  }

  .favorite-editor {
    grid-template-columns: 1fr;
  }

  .compact-options {
    grid-template-columns: 1fr;
  }

  .composer form,
  .access-form {
    grid-template-columns: 1fr;
  }
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}
