:root {
  color-scheme: dark;
  --canvas: #0d0d0d;
  --sidebar-bg: #171717;
  --surface: #212121;
  --surface-2: #303030;
  --border: rgba(255, 255, 255, 0.15);
  --border-strong: rgba(255, 255, 255, 0.22);
  --text: #ffffff;
  --text-2: #cdcdcd;
  --text-3: #8f8f8f;
  --accent: #8ec5ff;
  --green: #10a37f;
  --send-bg: #ffffff;
  --send-fg: #0d0d0d;
  --code-bg: #0d0d0d;
  --shadow: 0 4px 16px rgba(0, 0, 0, 0.08);
}

html[data-theme="light"] {
  color-scheme: light;
  --canvas: #fcfcfc;
  --sidebar-bg: #f7f7f7;
  --surface: #ffffff;
  --surface-2: #ececec;
  --border: rgba(0, 0, 0, 0.1);
  --border-strong: rgba(0, 0, 0, 0.16);
  --text: #0d0d0d;
  --text-2: #414141;
  --text-3: #8f8f8f;
  --accent: #0285ff;
  --green: #10a37f;
  --send-bg: #0d0d0d;
  --send-fg: #ffffff;
  --code-bg: #f3f3f3;
}

* {
  box-sizing: border-box;
}

html, body {
  height: 100%;
}

body {
  margin: 0;
  background: var(--canvas);
  color: var(--text);
  font-family: -apple-system, "Segoe UI", "system-ui", Helvetica, Arial, sans-serif;
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}

.app {
  display: flex;
  height: 100vh;
  height: 100dvb;
}

.sidebar {
  width: 260px;
  flex: 0 0 260px;
  background: var(--sidebar-bg);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 0.875rem 0.75rem 1rem;
}

.sidebar-header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.375rem 0.5rem 0.75rem;
}

.blossom {
  width: 1.75rem;
  height: 1.75rem;
  color: var(--green);
  flex: none;
}

.brand {
  font-size: 1.0625rem;
  font-weight: 650;
  letter-spacing: -0.02em;
  user-select: text;
  cursor: text;
}

.new-chat {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  width: 100%;
  padding: 0.6875rem 1.25rem;
  border-radius: 1.75rem;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: 1.0625rem;
  font-weight: 590;
  cursor: pointer;
  box-shadow: var(--shadow);
  transition: background 0.15s ease, transform 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease;
}

.new-chat svg {
  width: 1.25rem;
  height: 1.25rem;
  transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.new-chat:hover {
  background: var(--surface-2);
  border-color: var(--accent);
  transform: translateY(-1px);
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.25);
}

.new-chat:hover svg {
  transform: rotate(90deg);
}

.new-chat:active {
  transform: translateY(0) scale(0.98);
}

.new-chat:disabled {
  opacity: 0.5;
  cursor: default;
}

.sidebar-body {
  flex: 1;
}

.sidebar-footer {
  border-top: 1px solid var(--border);
  padding-top: 0.75rem;
  display: grid;
  gap: 0.375rem;
  font-size: 0.75rem;
  color: var(--text-2);
}

.status-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.dot {
  width: 0.625rem;
  height: 0.625rem;
  border-radius: 50%;
  background: #8f8f8f;
  flex: none;
}

.dot.ok { background: #30d158; }
.dot.warn { background: #ffd60a; }
.dot.err { background: #ff453a; }

.lan-url {
  color: var(--text-3);
  word-break: break-all;
}

.chat-item {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  width: 100%;
  text-align: left;
  padding: 0.5rem 0.75rem;
  margin-bottom: 0.25rem;
  border: none;
  border-radius: 0.625rem;
  background: transparent;
  color: var(--text-2);
  font: inherit;
  font-size: 0.875rem;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}

.chat-item-label {
  flex: 1;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.chat-item-actions {
  display: none;
  align-items: center;
  gap: 0.125rem;
  flex: none;
}

.chat-item:hover .chat-item-actions,
.chat-item.active .chat-item-actions {
  display: flex;
}

.chat-item-btn {
  width: 1.5rem;
  height: 1.5rem;
  display: grid;
  place-items: center;
  border: none;
  border-radius: 0.375rem;
  background: transparent;
  color: var(--text-3);
  cursor: pointer;
}

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

.chat-item-btn svg {
  width: 1rem;
  height: 1rem;
}

.chat-item:hover {
  background: var(--surface-2);
}

.chat-item.active {
  background: var(--surface-2);
  color: var(--text);
}

.main {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.topbar {
  height: 3.5rem;
  flex: 0 0 3.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1.5rem;
  border-bottom: 1px solid var(--border);
}

.topbar-title {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 1rem;
  font-weight: 650;
  letter-spacing: -0.01em;
  user-select: text;
  cursor: text;
}

.topbar-title .blossom {
  width: 1.5rem;
  height: 1.5rem;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 0.625rem;
}

.topbar-status {
  font-size: 0.75rem;
  color: var(--text-3);
}

.icon-btn {
  width: 2.25rem;
  height: 2.25rem;
  display: grid;
  place-items: center;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-2);
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease, transform 0.15s ease;
}

a.icon-btn {
  text-decoration: none;
}

.icon-btn:hover {
  background: var(--surface-2);
  color: var(--text);
  transform: rotate(-6deg) scale(1.06);
}

.icon-btn:active {
  transform: rotate(0deg) scale(0.94);
}

.icon-btn svg {
  width: 1.125rem;
  height: 1.125rem;
  transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.icon-btn:hover svg {
  transform: rotate(90deg);
}

#github-btn {
  transition: background 0.15s ease, color 0.15s ease;
}
#github-btn:hover,
#github-btn:active {
  transform: none;
}
#github-btn svg,
#github-btn:hover svg {
  transform: none;
  transition: none;
}

html[data-theme="dark"] #icon-sun { display: none; }
html[data-theme="light"] #icon-moon { display: none; }

.messages {
  flex: 1;
  overflow-y: auto;
  padding: 1rem 0 2rem;
  scroll-behavior: smooth;
}

.messages > .msg {
  max-width: 48rem;
  margin: 0 auto;
  padding: 0.75rem 1.5rem;
  display: flex;
  gap: 1rem;
  align-items: flex-start;
}

.msg.user {
  justify-content: flex-end;
}

.user-bubble {
  background: var(--surface-2);
  border-radius: 1.25rem;
  padding: 0.625rem 0.875rem;
  max-width: 75%;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  color: var(--text);
  font-size: 1rem;
}

.user-imgs {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 0.4rem;
}

.user-imgs img {
  max-height: 10rem;
  max-width: 14rem;
  border-radius: 0.75rem;
  display: block;
}

.assistant-avatar {
  width: 1.875rem;
  height: 1.875rem;
  border-radius: 50%;
  background: var(--green);
  color: #ffffff;
  display: grid;
  place-items: center;
  flex: none;
  margin-top: 0.125rem;
}

.assistant-avatar svg {
  width: 1.375rem;
  height: 1.375rem;
}

.assistant-body {
  min-width: 0;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 0.375rem;
}

.assistant-name {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 0.375rem;
}

.gpt-badge {
  font-size: 0.625rem;
  font-weight: 600;
  padding: 0.0625rem 0.375rem;
  border-radius: 999px;
  border: 1px solid var(--border-strong);
  color: var(--text-2);
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

.markdown {
  font-size: 1rem;
  line-height: 1.6;
  color: var(--text);
  overflow-wrap: anywhere;
}

.markdown > :first-child { margin-top: 0; }
.markdown > :last-child { margin-bottom: 0; }

.markdown p { margin: 0.5rem 0; }
.markdown h1, .markdown h2, .markdown h3, .markdown h4 {
  margin: 1.25rem 0 0.5rem;
  line-height: 1.3;
  letter-spacing: -0.02em;
}
.markdown h1 { font-size: 1.5rem; }
.markdown h2 { font-size: 1.3rem; }
.markdown h3 { font-size: 1.15rem; }
.markdown ul, .markdown ol { margin: 0.5rem 0; padding-left: 1.5rem; }
.markdown li { margin: 0.25rem 0; }
.markdown a { color: var(--accent); text-decoration: underline; text-underline-offset: 0.125rem; }
.markdown blockquote {
  margin: 0.75rem 0;
  padding: 0.25rem 1rem;
  border-left: 3px solid var(--border-strong);
  color: var(--text-2);
}
.markdown hr { border: none; border-top: 1px solid var(--border); margin: 1rem 0; }
.markdown code {
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
  font-size: 0.875em;
  background: var(--surface-2);
  border-radius: 0.3125rem;
  padding: 0.125rem 0.3125rem;
}
.markdown pre {
  position: relative;
  background: transparent;
  border: none;
  border-radius: 0;
  padding: 0.875rem 1rem;
  overflow-x: auto;
  margin: 0;
}
.markdown pre code {
  background: none;
  padding: 0;
  font-size: 0.8125rem;
  line-height: 1.55;
}
.code-block {
  margin: 0.75rem 0;
  border: 1px solid var(--border);
  border-radius: 0.75rem;
  overflow: hidden;
  background: var(--code-bg);
}
.code-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.375rem 0.625rem;
  background: var(--surface-2);
  border-bottom: 1px solid var(--border);
}
.code-lang {
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
  font-size: 0.6875rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-3);
}
.code-actions {
  display: flex;
  gap: 0.25rem;
}
.code-btn {
  font-size: 0.6875rem;
  font-weight: 600;
  padding: 0.25rem 0.5rem;
  border-radius: 0.375rem;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-2);
  cursor: pointer;
}
.code-btn:hover {
  color: var(--text);
  background: var(--surface-2);
}
.code-block:hover .code-head {
  background: var(--surface-2);
}

/* ---- syntax highlighting (highlight.js) — GitHub-style palette, both themes ---- */
.hljs { color: var(--text); background: transparent; }
.markdown pre code.hljs { background: transparent; padding: 0; }
.hljs-comment, .hljs-quote { color: #8b949e; font-style: italic; }
.hljs-keyword, .hljs-selector-tag, .hljs-doctag, .hljs-meta .hljs-keyword, .hljs-template-tag { color: #ff7b72; }
.hljs-string, .hljs-regexp, .hljs-addition { color: #a5d6ff; }
.hljs-number, .hljs-literal, .hljs-symbol, .hljs-bullet { color: #79c0ff; }
.hljs-title, .hljs-title.function_, .hljs-section { color: #d2a8ff; }
.hljs-attr, .hljs-attribute, .hljs-variable, .hljs-template-variable, .hljs-type, .hljs-property { color: #79c0ff; }
.hljs-tag, .hljs-name, .hljs-built_in, .hljs-selector-class, .hljs-selector-id { color: #7ee787; }
.hljs-meta, .hljs-subst { color: #c9d1d9; }
.hljs-emphasis { font-style: italic; }
.hljs-strong { font-weight: 600; }
html[data-theme="light"] .hljs { color: var(--text); }
html[data-theme="light"] .hljs-comment, html[data-theme="light"] .hljs-quote { color: #6a737d; }
html[data-theme="light"] .hljs-keyword, html[data-theme="light"] .hljs-selector-tag, html[data-theme="light"] .hljs-doctag, html[data-theme="light"] .hljs-meta .hljs-keyword, html[data-theme="light"] .hljs-template-tag { color: #d73a49; }
html[data-theme="light"] .hljs-string, html[data-theme="light"] .hljs-regexp, html[data-theme="light"] .hljs-addition { color: #032f62; }
html[data-theme="light"] .hljs-number, html[data-theme="light"] .hljs-literal, html[data-theme="light"] .hljs-symbol, html[data-theme="light"] .hljs-bullet { color: #005cc5; }
html[data-theme="light"] .hljs-title, html[data-theme="light"] .hljs-title.function_, html[data-theme="light"] .hljs-section { color: #6f42c1; }
html[data-theme="light"] .hljs-attr, html[data-theme="light"] .hljs-attribute, html[data-theme="light"] .hljs-variable, html[data-theme="light"] .hljs-template-variable, html[data-theme="light"] .hljs-type, html[data-theme="light"] .hljs-property { color: #005cc5; }
html[data-theme="light"] .hljs-tag, html[data-theme="light"] .hljs-name, html[data-theme="light"] .hljs-built_in, html[data-theme="light"] .hljs-selector-class, html[data-theme="light"] .hljs-selector-id { color: #22863a; }
html[data-theme="light"] .hljs-meta, html[data-theme="light"] .hljs-subst { color: #24292e; }
.markdown table {
  border-collapse: collapse;
  margin: 0.75rem 0;
  width: 100%;
  display: block;
  overflow-x: auto;
}
.markdown th, .markdown td {
  border: 1px solid var(--border);
  padding: 0.4375rem 0.625rem;
  text-align: left;
}
.markdown th { background: var(--surface-2); font-weight: 600; }
.markdown img { max-width: 100%; border-radius: 0.5rem; }

.thinking-dots {
  display: inline-flex;
  gap: 0.25rem;
  padding: 0.5rem 0;
}
.thinking-dots span {
  width: 0.5rem;
  height: 0.5rem;
  border-radius: 50%;
  background: var(--text-3);
  animation: pulse 1.2s infinite ease-in-out;
}
.thinking-dots span:nth-child(2) { animation-delay: 0.15s; }
.thinking-dots span:nth-child(3) { animation-delay: 0.3s; }
@keyframes pulse {
  0%, 80%, 100% { opacity: 0.35; transform: scale(0.85); }
  40% { opacity: 1; transform: scale(1); }
}

.msg.streaming.has-text .markdown::after {
  content: "\258d";
  color: var(--text-2);
  animation: blink 1s step-end infinite;
  margin-left: 1px;
}
@keyframes blink { 50% { opacity: 0; } }

.msg-actions {
  display: flex;
  gap: 0.375rem;
  margin-top: 0.375rem;
}

.msg-action {
  display: inline-flex;
  align-items: center;
  gap: 0.3125rem;
  font-size: 0.75rem;
  padding: 0.3125rem 0.625rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-2);
  cursor: pointer;
}

.msg-action:hover {
  background: var(--surface-2);
}

.msg-action svg {
  width: 0.875rem;
  height: 0.875rem;
}

.msg-action.danger {
  border-color: rgba(255, 69, 58, 0.5);
  color: #ff6961;
}

.msg-action.danger:hover {
  background: rgba(255, 69, 58, 0.1);
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  display: grid;
  place-items: center;
  z-index: 50;
  overflow-y: auto;
  padding: 1rem;
}

#login-modal {
  z-index: 1200;
}

.login-modal {
  width: min(22rem, calc(100vw - 2rem));
}

.login-label {
  display: block;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-2);
  margin: 0.75rem 0 0.25rem;
}

.login-input {
  width: 100%;
  box-sizing: border-box;
  padding: 0.5rem 0.625rem;
  border-radius: 0.5rem;
  border: 1px solid var(--border);
  background: var(--input-bg, var(--canvas));
  color: var(--text);
  font-size: 0.875rem;
}

.login-input:focus {
  outline: none;
  border-color: #74aa9c;
}

.login-error {
  min-height: 1.25rem;
  margin: 0.5rem 0 0;
  font-size: 0.8125rem;
  color: #e5484d;
}

.login-actions {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin-top: 0.75rem;
}

.msg-action.ghost {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-2);
}

.modal-backdrop[hidden] {
  display: none;
}

.tab-panels {
  flex: 1;
  display: flex;
  min-height: 0;
}

.tab-panel {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
  min-width: 0;
}

.tab-panel[hidden] {
  display: none;
}

.chat-panel {
  display: flex;
  flex-direction: column;
}

.code-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  padding: 0.375rem 0.6875rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-2);
  font: inherit;
  font-size: 0.8125rem;
  font-weight: 550;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease, transform 0.15s ease,
    box-shadow 0.15s ease;
}

.code-btn svg {
  width: 0.9375rem;
  height: 0.9375rem;
  transition: transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.code-btn:hover {
  background: var(--surface-2);
  color: var(--text);
  border-color: var(--accent);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25);
}

.code-btn:hover svg {
  transform: scale(1.2);
}

.code-btn:active {
  transform: translateY(0) scale(0.96);
}

.code-btn:focus-visible,
.icon-btn:focus-visible,
.msg-action:focus-visible,
.send-btn:focus-visible,
.chat-item:focus-visible,
.new-chat:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.code-actions .code-btn {
  font-size: 0.6875rem;
  font-weight: 600;
  padding: 0.25rem 0.5rem;
  border-radius: 0.375rem;
  background: var(--surface);
}

.plain-reply {
  margin: 0;
  white-space: pre-wrap;
  word-break: break-word;
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
  font-size: 0.8125rem;
  line-height: 1.55;
}

.modal {
  margin: auto;
  width: min(26rem, calc(100vw - 2rem));
  max-height: calc(100vh - 2rem);
  overflow-y: auto;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: 1rem;
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.35);
  padding: 1rem;
}

.api-modal { width: min(38rem, calc(100vw - 2rem)); max-height: calc(100vh - 2rem); overflow-y: auto; }
.api-intro { margin: 0 0 0.25rem; font-size: 0.875rem; color: var(--text-2); }
.api-field { display: flex; flex-direction: column; gap: 0.375rem; }
.api-field > label { font-size: 0.75rem; color: var(--text-3); text-transform: uppercase; letter-spacing: 0.04em; }
.api-copy-row { display: flex; gap: 0.5rem; align-items: flex-start; }
.api-copy-row input,
#api-test-input,
.api-output {
  flex: 1;
  width: 100%;
  border: 1px solid var(--border-strong);
  border-radius: 0.625rem;
  background: var(--canvas);
  color: var(--text);
  font: 0.8125rem ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  padding: 0.5rem 0.625rem;
  outline: none;
}
#api-test-input { resize: vertical; min-height: 2.4rem; font-family: inherit; }
.api-output {
  margin: 0.375rem 0 0;
  max-height: 16rem;
  overflow: auto;
  white-space: pre-wrap;
  word-break: break-word;
}
.api-docs { border: 1px solid var(--border); border-radius: 0.625rem; padding: 0.5rem 0.75rem; }
.api-docs summary { cursor: pointer; font-size: 0.8125rem; color: var(--text-2); font-weight: 600; }
.api-docs pre {
  margin: 0.5rem 0 0;
  white-space: pre-wrap;
  word-break: break-word;
  font: 0.75rem ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  color: var(--text-2);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-bottom: 0.75rem;
  margin-bottom: 0.5rem;
  border-bottom: 1px solid var(--border);
}

.modal-title {
  font-size: 1.0625rem;
  font-weight: 650;
}

.modal-body {
  display: flex;
  flex-direction: column;
  gap: 0.875rem;
}

.setting-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.setting-label {
  font-size: 0.875rem;
  color: var(--text-2);
}

.settings-textarea {
  width: 100%;
  min-height: 5.5rem;
  resize: vertical;
  border: 1px solid var(--border-strong);
  border-radius: 0.625rem;
  background: var(--canvas);
  color: var(--text);
  font: inherit;
  font-size: 0.875rem;
  padding: 0.5rem 0.625rem;
  outline: none;
}

.settings-textarea:focus {
  border-color: color-mix(in srgb, var(--accent) 60%, var(--border-strong));
}

#settings-save-msg {
  font-size: 0.75rem;
  color: var(--text-3);
}

.setting-control .msg-action {
  padding: 0.4375rem 0.75rem;
}

.settings-select {
  border: 1px solid var(--border-strong);
  border-radius: 0.625rem;
  background: var(--canvas);
  color: var(--text);
  font: inherit;
  font-size: 0.875rem;
  padding: 0.4375rem 0.5rem;
  outline: none;
  max-width: 16rem;
}

.settings-select:focus {
  border-color: color-mix(in srgb, var(--accent) 60%, var(--border-strong));
}

.setting-hint {
  margin: 0.375rem 0 0;
  font-size: 0.75rem;
  color: var(--text-3);
  line-height: 1.45;
}

.cancel-note {
  margin-top: 0.5rem;
  font-size: 0.75rem;
  color: var(--text-3);
  font-style: italic;
}

.msg-action.speaking {
  color: var(--accent);
  animation: speak-pulse 1.1s ease-in-out infinite;
}

@keyframes speak-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.45; }
}

#mic:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.server-info {
  font-size: 0.8125rem;
  color: var(--text-3);
  word-break: break-all;
  text-align: right;
}

.error-box {
  border: 1px solid rgba(255, 69, 58, 0.4);
  background: rgba(255, 69, 58, 0.08);
  color: #ff6961;
  border-radius: 0.75rem;
  padding: 0.75rem 1rem;
  font-size: 0.875rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.welcome {
  text-align: center;
  padding-top: 12vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.75rem;
  user-select: none;
  cursor: default;
}

.welcome-blossom {
  width: 3.5rem;
  height: 3.5rem;
}

.welcome h1 {
  font-size: 1.75rem;
  font-weight: 500;
  letter-spacing: -0.02em;
  margin: 0;
}

.welcome-sub {
  color: var(--text-3);
  font-size: 0.875rem;
  margin: 0;
}

.composer-wrap {
  flex: 0 0 auto;
  padding: 0.5rem 1rem 0.75rem;
}

.attach-strip {
  max-width: 48rem;
  margin: 0 auto 0.4rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.attach-thumb {
  position: relative;
  width: 3.25rem;
  height: 3.25rem;
  border-radius: 0.65rem;
  overflow: hidden;
  border: 1px solid var(--border-strong);
  background: var(--surface-2);
}

.attach-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.attach-remove {
  position: absolute;
  top: 2px;
  right: 2px;
  width: 1.1rem;
  height: 1.1rem;
  line-height: 1;
  border: none;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.6);
  color: #fff;
  font-size: 0.7rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.attach-remove:hover {
  background: rgba(180, 40, 40, 0.9);
}

.toolbar {
  max-width: 48rem;
  margin: 0 auto;
  display: flex;
  align-items: center;
  gap: 0.625rem;
  padding: 0.375rem 0.25rem;
  min-height: 2rem;
}

.pill {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  font-size: 0.8125rem;
  font-weight: 500;
  padding: 0.375rem 0.75rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-2);
  cursor: pointer;
}

.pill svg {
  width: 0.9375rem;
  height: 0.9375rem;
}

.pill[aria-pressed="true"] {
  background: color-mix(in srgb, var(--accent) 18%, transparent);
  border-color: color-mix(in srgb, var(--accent) 45%, transparent);
  color: var(--accent);
}

.queue-info {
  font-size: 0.75rem;
  color: var(--text-3);
}

.rate-status {
  font-size: 0.75rem;
  color: var(--accent);
  padding: 0.15rem 0.6rem;
  border-radius: 999px;
  border: 1px solid color-mix(in srgb, var(--accent) 40%, transparent);
  background: color-mix(in srgb, var(--accent) 10%, transparent);
  animation: pulse-soft 1.6s ease-in-out infinite;
}

.rate-status[hidden] {
  display: none;
}

@keyframes pulse-soft {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.55; }
}

.composer {
  max-width: 48rem;
  margin: 0 auto;
  display: flex;
  align-items: flex-end;
  gap: 0.5rem;
  border: 1px solid var(--border-strong);
  border-radius: 1.75rem;
  background: var(--surface);
  padding: 0.5rem;
  box-shadow: var(--shadow);
}

.composer:focus-within {
  border-color: color-mix(in srgb, var(--accent) 60%, var(--border-strong));
}

#input {
  flex: 1;
  border: none;
  outline: none;
  resize: none;
  background: transparent;
  color: var(--text);
  font: inherit;
  font-size: 1.0625rem;
  line-height: 1.5;
  padding: 0.4375rem 0.75rem;
  max-height: 12rem;
  min-height: 2.5rem;
}

#input::placeholder {
  color: var(--text-3);
}

.send-btn {
  width: 2.75rem;
  height: 2.75rem;
  flex: none;
  border: none;
  border-radius: 50%;
  background: var(--send-bg);
  color: var(--send-fg);
  display: grid;
  place-items: center;
  cursor: pointer;
  transition: transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1), opacity 0.15s ease, box-shadow 0.2s ease;
}

.send-btn svg {
  width: 1.25rem;
  height: 1.25rem;
  transition: transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.send-btn:not(:disabled):hover {
  transform: scale(1.1);
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.3);
}

.send-btn:not(:disabled):hover svg {
  transform: translateY(-1px);
}

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

.send-btn:disabled {
  opacity: 0.4;
  cursor: default;
}

.disclaimer {
  max-width: 48rem;
  margin: 0.5rem auto 0;
  text-align: center;
  font-size: 0.75rem;
  color: var(--text-3);
}

/* ---- boot overlay: logo light-fill + progress ---- */
.boot-overlay[hidden] { display: none; }
.boot-overlay {
  position: fixed;
  inset: 0;
  z-index: 1000;
  background: var(--canvas);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  opacity: 1;
  transition: opacity 0.7s ease;
}
.boot-overlay.done {
  opacity: 0;
  pointer-events: none;
}
.boot-logo {
  position: relative;
  width: 5.5rem;
  height: 5.5rem;
}
.boot-logo svg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}
.boot-logo .boot-dim {
  opacity: 0.45;
  filter: saturate(0.6);
}
.boot-logo .boot-light {
  clip-path: inset(0 100% 0 0);
  transition: clip-path 0.9s cubic-bezier(0.22, 1, 0.36, 1);
  filter: drop-shadow(0 0 14px rgba(116, 170, 156, 0.65));
}
.boot-track {
  width: min(17rem, 70vw);
  height: 0.3125rem;
  border-radius: 999px;
  background: var(--border);
  overflow: hidden;
}
.boot-bar {
  height: 100%;
  width: 0%;
  border-radius: 999px;
  background: linear-gradient(90deg, #74aa9c, #9cc7bc);
  transition: width 0.6s ease;
}
.boot-pct {
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--text-2);
  font-variant-numeric: tabular-nums;
}
.boot-status {
  font-size: 0.8125rem;
  color: var(--text-3);
}

/* ---- update banner ---- */
.update-banner[hidden] { display: none; }
.update-banner {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.375rem 0.75rem;
  margin: 0 auto 0.25rem;
  width: fit-content;
  max-width: calc(100vw - 2rem);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 999px;
  font-size: 0.8125rem;
}
.update-banner .msg-action {
  padding: 0.1875rem 0.625rem;
  font-size: 0.75rem;
}

.demo-banner[hidden] { display: none; }
.demo-banner {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.375rem 0.75rem;
  margin: 0 auto 0.25rem;
  width: fit-content;
  max-width: calc(100vw - 2rem);
  background: color-mix(in srgb, var(--accent) 12%, var(--surface));
  border: 1px solid color-mix(in srgb, var(--accent) 40%, var(--border));
  border-radius: 999px;
  font-size: 0.8125rem;
  color: var(--text-2);
}
.demo-banner svg {
  width: 0.875rem;
  height: 0.875rem;
  flex: none;
  color: var(--accent);
}
.demo-banner a {
  color: var(--accent);
}

/* ---- mic button ---- */
.mic-btn.listening {
  background: #c2410c;
  color: #fff;
  animation: mic-pulse 1.2s ease-in-out infinite;
}
@keyframes mic-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(194, 65, 12, 0.5); }
  50% { box-shadow: 0 0 0 8px rgba(194, 65, 12, 0); }
}

/* ---- sidebar toggle + mobile drawer ---- */
.sidebar-toggle {
  display: none;
}

@media (max-width: 47.99rem) {
  .sidebar {
    display: none;
  }
  .sidebar-toggle {
    display: grid;
  }
  body.sidebar-open .sidebar {
    display: flex;
    position: fixed;
    inset: 0 auto 0 0;
    width: min(19rem, 84vw);
    z-index: 90;
    box-shadow: 0 0 40px rgba(0, 0, 0, 0.45);
  }
}
