:root {
  --bg: #ffffff;
  --text: #1f2329;
  --muted: #8a8f98;
  --line: #eceff3;
  --primary: #3b82f6;
  --primary-soft: #eff6ff;
  --user: #dbeafe;
  --bot: #f5f6f8;
  --danger: #ef4444;
  --card: #f8fafc;
  --shadow: 0 4px 16px rgba(15, 23, 42, 0.06);
  --shadow-lg: 0 18px 48px rgba(15, 23, 42, 0.16);
  font-family: "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
}
* { box-sizing: border-box; }
html, body {
  margin: 0;
  height: 100%;
  height: 100dvh;
  max-height: 100dvh;
  overflow: hidden;
  background: #fff;
  color: var(--text);
}
body {
  overscroll-behavior: none;
  -webkit-text-size-adjust: 100%;
  touch-action: manipulation;
}
.app {
  max-width: 720px;
  margin: 0 auto;
  width: 100%;
  height: 100dvh;
  max-height: 100dvh;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto auto;
  background: #fff;
  overflow: hidden;
}
@supports (height: 100svh) {
  html, body, .app {
    height: 100svh;
    max-height: 100svh;
  }
}
@supports (height: 100dvh) {
  html, body, .app {
    height: 100dvh;
    max-height: 100dvh;
  }
}
.top { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 8px; padding: 10px 10px; border-bottom: 1px solid var(--line); background: #fff; }
.top-left { display: flex; justify-content: flex-start; align-items: center; gap: 2px; min-width: 0; }
.top-actions { display: flex; justify-content: flex-end; align-items: center; gap: 2px; min-width: 0; position: static; right: auto; top: auto; transform: none; }
.top-title { text-align: center; }
.top-title h1 { margin: 0; font-size: 17px; font-weight: 600; }
.top-title .sub { margin: 2px 0 0; font-size: 12px; color: var(--muted); }
.icon-btn { appearance: none; border: none; background: transparent; color: #2b2f36; border-radius: 999px; min-width: 40px; height: 40px; padding: 0 10px; font-size: 14px; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; }
.icon-btn:hover { background: #f3f4f6; }
.icon-btn:active { transform: scale(0.96); }
.icon-btn:disabled { opacity: 0.45; cursor: not-allowed; }
.top-btn {
  gap: 4px;
  width: auto;
  min-width: 40px;
  padding: 0 10px;
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
}
.top-btn svg { display: block; flex: 0 0 auto; }
.btn-text { line-height: 1; }
.chat {
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 16px 14px 8px;
  background: #fff;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
}
.msg-row {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin: 10px 0;
  max-width: 100%;
}
.msg-row.user { align-items: flex-end; }
.msg-row.assistant { align-items: flex-start; }
.msg {
  max-width: min(86%, 520px);
  margin: 0;
  padding: 12px 14px;
  border-radius: 16px;
  line-height: 1.55;
  font-size: 16px;
  white-space: pre-wrap;
  word-break: break-word;
}
.msg.user { background: var(--user); border-bottom-right-radius: 6px; }
.msg.assistant { background: var(--bot); border-bottom-left-radius: 6px; }
.msg.system {
  margin: 8px auto 14px;
  max-width: 92%;
  background: transparent;
  color: var(--muted);
  font-size: 13px;
  text-align: center;
  padding: 4px 8px;
}
.msg-actions {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px;
  border-radius: 999px;
  background: rgba(255,255,255,.92);
  border: 1px solid #e8edf5;
  box-shadow: 0 4px 14px rgba(15, 23, 42, 0.08);
  opacity: 0;
  transform: translateY(2px);
  pointer-events: none;
  transition: opacity .15s ease, transform .15s ease;
}
.msg-row.active .msg-actions,
.msg-row:focus-within .msg-actions {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}
@media (hover: hover) and (pointer: fine) {
  .msg-row:hover .msg-actions {
    opacity: 1;
    transform: translateY(0);
    pointer-events: auto;
  }
}
.msg-act {
  appearance: none;
  border: none;
  background: #fff;
  color: #4b5563;
  width: 34px;
  height: 34px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  cursor: pointer;
  padding: 0;
  transition: background .15s ease, color .15s ease, width .15s ease;
}
.msg-act:hover {
  background: #f3f4f6;
  color: #111827;
}
.msg-act[data-act="delete"]:hover {
  background: #fef2f2;
  color: #dc2626;
}
.msg-act[data-act="copy"] {
  width: auto;
  min-width: 34px;
  padding: 0 10px;
  font-size: 12px;
  font-weight: 600;
}
.msg-act .msg-act-label {
  display: none;
}
.msg-act[data-act="copy"]:hover .msg-act-label,
.msg-act[data-act="copy"].done .msg-act-label,
.msg-row.active .msg-act[data-act="copy"] .msg-act-label {
  display: inline;
}
.msg-act.done {
  color: #2563eb;
  background: #eff6ff;
}
.msg-act svg {
  display: block;
  flex: 0 0 auto;
}
.composer {
  position: sticky;
  bottom: 0;
  z-index: 20;
  background: rgba(255, 255, 255, 0.96);
  backdrop-filter: blur(10px);
  border-top: none;
  padding: 6px 12px calc(10px + env(safe-area-inset-bottom, 0px));
  display: grid;
  gap: 8px;
  box-shadow: 0 -6px 18px rgba(15, 23, 42, 0.04);
}
.quick { display: flex; gap: 8px; overflow-x: auto; padding: 2px 2px 4px; scrollbar-width: none; }
.quick::-webkit-scrollbar { display: none; }
.quick button { flex: 0 0 auto; border: 1px solid var(--line); background: #fff; color: #3c4048; border-radius: 999px; padding: 8px 12px; font-size: 13px; white-space: nowrap; box-shadow: 0 1px 2px rgba(15,23,42,.03); cursor: pointer; }
.quick button:active { background: #f7f8fa; }
.input-bar { display: flex; align-items: flex-end; gap: 6px; background: #fff; border: 1px solid #e6e8ec; border-radius: 24px; padding: 6px 8px 6px 14px; box-shadow: var(--shadow); min-height: 48px; }
textarea#input { flex: 1; min-width: 0; border: none !important; outline: none; resize: none; background: transparent; font-family: inherit; font-size: 16px; line-height: 1.45; max-height: 120px; min-height: 24px; padding: 8px 0; color: var(--text); pointer-events: auto !important; user-select: text !important; -webkit-user-select: text !important; position: relative; z-index: 50; }
textarea#input::placeholder { color: #a0a6b0; }
.input-bar .icon-btn { flex: 0 0 auto; width: 40px; height: 40px; padding: 0; font-size: 18px; }
.input-bar .mic { color: #3a3f47; font-size: 20px; user-select: none; -webkit-user-select: none; }
.input-bar .mic.recording { background: #fee2e2; color: var(--danger); box-shadow: 0 0 0 4px rgba(239,68,68,.12); }
.input-bar .send { background: var(--primary); color: #fff; font-size: 13px; font-weight: 600; width: auto; min-width: 52px; padding: 0 12px; }
.input-bar .send:disabled { background: #e8eaee; color: #9aa0a8; }
.status {
  margin: 0;
  min-height: 1.1em;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
  text-align: center;
  padding: 0 4px;
}
.chat-status {
  border-top: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.96);
  padding: 6px 16px 3px;
}
.chat-status:empty {
  display: none;
}
.btn { appearance: none; border: 1px solid var(--line); background: #fff; color: var(--text); border-radius: 12px; padding: 11px 14px; font-size: 15px; font-weight: 600; cursor: pointer; transition: background .15s ease, border-color .15s ease, transform .12s ease; }
.btn.primary { background: var(--primary); border-color: var(--primary); color: #fff; box-shadow: 0 8px 18px rgba(59, 130, 246, 0.22); }
.btn.ghost { background: transparent; }
.btn:hover { background: #f8fafc; }
.btn.primary:hover { background: #2563eb; border-color: #2563eb; }
.btn:active { transform: scale(0.98); }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }

/* ===== Settings modal ===== */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.48);
  backdrop-filter: blur(4px);
  display: grid;
  place-items: center;
  padding: 12px;
  z-index: 30;
}
.modal.hidden { display: none; }
.hidden { display: none !important; }
.provider-editor.hidden { display: none !important; }
/* ===== Mobile install / PWA tip ===== */
.install-tip {
  position: fixed;
  left: max(12px, env(safe-area-inset-left, 0px));
  right: max(12px, env(safe-area-inset-right, 0px));
  bottom: calc(116px + env(safe-area-inset-bottom, 0px));
  z-index: 80;
  max-width: 680px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 12px;
  border: 1px solid rgba(191, 219, 254, 0.95);
  border-radius: 16px;
  background: rgba(239, 246, 255, 0.96);
  color: #1e3a8a;
  box-shadow: 0 14px 38px rgba(15, 23, 42, 0.16);
  backdrop-filter: blur(12px);
  font-size: 13px;
  line-height: 1.45;
}
.install-tip span {
  min-width: 0;
}
.install-tip-actions {
  display: inline-flex;
  align-items: center;
  flex: 0 0 auto;
  gap: 6px;
}
.install-tip button {
  appearance: none;
  border: 1px solid #bfdbfe;
  background: #fff;
  color: #1d4ed8;
  border-radius: 999px;
  padding: 7px 10px;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
}
.install-tip .install-tip-primary {
  background: #2563eb;
  border-color: #2563eb;
  color: #fff;
}
.install-tip button:active {
  transform: scale(0.98);
}
@media (max-width: 420px) {
  .install-tip {
    bottom: calc(108px + env(safe-area-inset-bottom, 0px));
    align-items: flex-start;
  }
  .install-tip-actions {
    flex-direction: column;
    align-items: stretch;
  }
}
@media (display-mode: standalone) {
  .install-tip {
    display: none !important;
  }
}
.modal-card {
  width: min(920px, 100%);
  max-height: min(92dvh, 920px);
  overflow: auto;
  background: #fff;
  border-radius: 18px;
  padding: 16px;
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
}
.settings-sheet {
  display: grid;
  grid-template-rows: auto auto 1fr auto;
  gap: 0;
  padding: 0;
  overflow: hidden;
  width: min(760px, 100%);
  max-height: min(94dvh, 900px);
  border: none;
  border-radius: 22px;
  box-shadow: var(--shadow-lg);
  background:
    radial-gradient(circle at top right, rgba(59,130,246,.10), transparent 28%),
    #fff;
}
.settings-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 18px 18px 10px;
}
.settings-kicker {
  margin: 0 0 4px;
  color: #3b82f6;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.04em;
}
.settings-head h2 {
  margin: 0;
  font-size: 22px;
  line-height: 1.25;
}
.settings-desc {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.55;
  max-width: 52ch;
}
.icon-close {
  appearance: none;
  width: 40px;
  height: 40px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fff;
  color: #4b5563;
  font-size: 24px;
  line-height: 1;
  cursor: pointer;
  flex: 0 0 auto;
}
.icon-close:hover { background: #f8fafc; }

.settings-tabs {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  padding: 0 14px 12px;
  scrollbar-width: none;
}
.settings-tabs::-webkit-scrollbar { display: none; }
.settings-tab {
  appearance: none;
  flex: 0 0 auto;
  border: 1px solid transparent;
  background: #f3f4f6;
  color: #4b5563;
  border-radius: 999px;
  padding: 9px 14px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all .15s ease;
}
.settings-tab:hover { background: #eef2f7; }
.settings-tab.active {
  background: var(--primary-soft);
  color: #1d4ed8;
  border-color: #bfdbfe;
  box-shadow: inset 0 0 0 1px rgba(59,130,246,.08);
}

.settings-body {
  overflow: auto;
  padding: 4px 14px 14px;
  display: grid;
  gap: 12px;
  background: linear-gradient(180deg, rgba(248,250,252,.55), transparent 40%);
}
.settings-panel {
  display: none;
  gap: 12px;
}
.settings-panel.active {
  display: grid;
}
.settings-card {
  background: #fff;
  border: 1px solid #e8edf5;
  border-radius: 18px;
  padding: 14px;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.03);
}
.card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 12px;
}
.card-head h3 {
  margin: 0;
  font-size: 16px;
}
.card-head p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}
.card-badge {
  flex: 0 0 auto;
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 12px;
  font-weight: 700;
  color: #1d4ed8;
  background: var(--primary-soft);
}
.card-badge.soft {
  color: #475569;
  background: #f1f5f9;
}



.provider-manager {
  display: grid;
  gap: 10px;
}
.provider-picker-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: end;
  gap: 10px;
}
.provider-picker-field {
  margin: 0;
}
.provider-toolbar {
  align-items: center;
  justify-content: flex-end;
  margin-top: 0;
}
.provider-toolbar .btn {
  min-width: 88px;
  padding-inline: 12px;
}

.provider-list {
  display: grid;
  gap: 10px;
  margin-bottom: 0;
}
.provider-item {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 12px;
  border: 1px solid #e8edf5;
  border-radius: 14px;
  background: #f8fafc;
}
.provider-item.active {
  border-color: #93c5fd;
  background: #eff6ff;
}
.provider-item-main {
  min-width: 0;
  display: grid;
  gap: 4px;
}
.provider-item-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--text);
}
.provider-item-meta {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
  word-break: break-all;
}
.provider-item-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 2px;
}
.provider-tag {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 2px 8px;
  font-size: 11px;
  font-weight: 700;
  color: #475569;
  background: #e2e8f0;
}
.provider-tag.ok {
  color: #166534;
  background: #dcfce7;
}
.provider-tag.warn {
  color: #9a3412;
  background: #ffedd5;
}
.provider-item-actions {
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex: 0 0 auto;
}
.provider-item-actions .btn {
  min-width: 64px;
  padding: 7px 10px;
  font-size: 13px;
}
.provider-editor {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px dashed #dbe3ef;
}
.provider-empty {
  padding: 14px;
  border: 1px dashed #d7dee8;
  border-radius: 14px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
  background: #fff;
}
.settings-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}
.settings-actions.mini-actions {
  margin-top: 10px;
}
.field-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}
.field {
  display: grid;
  gap: 6px;
  min-width: 0;
}
.field.full { grid-column: 1 / -1; }
.field-label {
  font-size: 13px;
  color: #64748b;
  font-weight: 600;
}
.field-help {
  margin-top: -2px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}
.field input,
.field textarea,
.field select {
  width: 100%;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  padding: 11px 12px;
  font-size: 15px;
  font-family: inherit;
  color: var(--text);
  background: #fff;
  transition: border-color .15s ease, box-shadow .15s ease;
  pointer-events: auto !important;
  user-select: text !important;
  position: relative;
  z-index: 50;
}
.field textarea {
  resize: vertical;
  min-height: 110px;
  line-height: 1.5;
}
.field input:focus,
.field textarea:focus,
.field select:focus {
  outline: none;
  border-color: #93c5fd;
  box-shadow: 0 0 0 4px rgba(59, 130, 246, 0.12);
}

.secret-input {
  display: flex;
  align-items: center;
  gap: 8px;
}
.secret-input input {
  flex: 1;
  min-width: 0;
}
.eye-btn {
  flex: 0 0 auto;
  width: 44px;
  height: 44px;
  border-radius: 12px;
  border: 1px solid #d7dde8;
  background: #f7f9fc;
  font-size: 18px;
  cursor: pointer;
  user-select: none;
}
.eye-btn:hover { background: #eef4ff; }
.eye-btn[aria-pressed="true"] {
  background: #e8f0ff;
  border-color: #8fb0ef;
}

.switch-list {
  display: grid;
  gap: 8px;
  margin-top: 12px;
}
.switch-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 12px;
  border-radius: 14px;
  background: #f8fafc;
  border: 1px solid #eef2f7;
  cursor: pointer;
}
.switch-row span {
  display: grid;
  gap: 2px;
  min-width: 0;
}
.switch-row strong {
  font-size: 14px;
  font-weight: 650;
  color: var(--text);
}
.switch-row small {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.4;
}
.switch-input {
  appearance: none;
  width: 46px;
  height: 28px;
  border-radius: 999px;
  background: #d1d5db;
  position: relative;
  flex: 0 0 auto;
  cursor: pointer;
  transition: background .18s ease;
  border: none;
  outline: none;
}
.switch-input::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.2);
  transition: transform .18s ease;
}
.switch-input:checked {
  background: #3b82f6;
}
.switch-input:checked::after {
  transform: translateX(18px);
}
.switch-input:focus-visible {
  box-shadow: 0 0 0 4px rgba(59, 130, 246, 0.18);
}

.action-tiles {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}
.action-tile {
  appearance: none;
  text-align: left;
  border: 1px solid #e5eaf2;
  background: linear-gradient(180deg, #fff, #f8fafc);
  border-radius: 16px;
  padding: 14px 14px;
  cursor: pointer;
  display: grid;
  gap: 4px;
  transition: border-color .15s ease, transform .12s ease, box-shadow .15s ease;
}
.action-tile:hover {
  border-color: #bfdbfe;
  box-shadow: 0 8px 18px rgba(15, 23, 42, 0.05);
}
.action-tile:active { transform: scale(0.985); }
.action-tile strong {
  font-size: 14px;
  color: var(--text);
}
.action-tile span {
  font-size: 12px;
  color: var(--muted);
  line-height: 1.4;
}
.action-tile.danger {
  border-color: #fecaca;
  background: linear-gradient(180deg, #fff, #fff7f7);
}
.action-tile.danger strong { color: #b91c1c; }

.settings-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px calc(14px + env(safe-area-inset-bottom, 0px));
  border-top: 1px solid #eef2f7;
  background: rgba(255,255,255,.92);
  backdrop-filter: blur(8px);
}
.settings-status {
  margin: 0;
  flex: 1;
  min-width: 0;
  color: #64748b;
  font-size: 13px;
  line-height: 1.45;
}
.settings-footer-actions {
  display: flex;
  gap: 8px;
  flex: 0 0 auto;
}

@media (max-width: 720px) {
  .field-grid,
  .action-tiles { grid-template-columns: 1fr; }
  .settings-footer {
    flex-direction: column;
    align-items: stretch;
  }
  .settings-footer-actions {
    width: 100%;
  }
  .settings-footer-actions .btn {
    flex: 1;
  }
  .provider-picker-row {
    grid-template-columns: 1fr;
    align-items: stretch;
  }
  .provider-toolbar {
    justify-content: stretch;
  }
  .provider-toolbar .btn {
    flex: 1 1 auto;
  }
  .settings-head h2 { font-size: 20px; }
}

.input-bar .mic {
  position: relative;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: #f3f4f6;
  color: #222;
}
.input-bar .mic .mic-dot {
  width: 10px;
  height: 16px;
  border: 2px solid currentColor;
  border-radius: 999px;
  display: block;
  position: relative;
}
.input-bar .mic .mic-dot::after {
  content: "";
  position: absolute;
  left: 50%;
  bottom: -7px;
  width: 14px;
  height: 8px;
  border: 2px solid currentColor;
  border-top: none;
  border-radius: 0 0 10px 10px;
  transform: translateX(-50%);
}
.input-bar .mic.recording {
  background: #ef4444;
  color: #fff;
  box-shadow: 0 0 0 5px rgba(239, 68, 68, 0.15);
  animation: pulse-mic 1s ease-in-out infinite;
}
@keyframes pulse-mic {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.06); }
}


/* ===== History panel ===== */
.history-sheet {
  width: min(560px, 100%);
  max-height: min(88dvh, 760px);
  display: grid;
  grid-template-rows: auto auto 1fr;
  padding: 0;
  overflow: hidden;
  border: none;
  border-radius: 22px;
  box-shadow: var(--shadow-lg);
  background:
    radial-gradient(circle at top left, rgba(59,130,246,.08), transparent 30%),
    #fff;
}
.history-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 18px 18px 8px;
}
.history-head h2 {
  margin: 0;
  font-size: 22px;
}
.history-toolbar {
  padding: 0 14px 10px;
}
.history-list {
  overflow: auto;
  padding: 0 14px 16px;
  display: grid;
  gap: 8px;
}
.history-empty {
  color: var(--muted);
  font-size: 14px;
  line-height: 1.5;
  padding: 18px 8px;
  text-align: center;
}
.history-item {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  align-items: stretch;
  border: 1px solid #e8edf5;
  border-radius: 16px;
  background: #fff;
  padding: 6px;
}
.history-item.active {
  border-color: #bfdbfe;
  background: #f8fbff;
  box-shadow: inset 0 0 0 1px rgba(59,130,246,.08);
}
.history-main {
  appearance: none;
  border: none;
  background: transparent;
  text-align: left;
  border-radius: 12px;
  padding: 10px 10px;
  cursor: pointer;
  display: grid;
  gap: 4px;
  min-width: 0;
}
.history-main strong {
  font-size: 15px;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.history-main span {
  font-size: 12px;
  color: var(--muted);
}
.history-main:hover { background: #f8fafc; }
.history-del {
  appearance: none;
  border: 1px solid #fecaca;
  background: #fff7f7;
  color: #b91c1c;
  border-radius: 12px;
  padding: 0 12px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}
.history-del:hover { background: #fee2e2; }

@media (max-width: 720px) {
  .top {
    grid-template-columns: auto minmax(0, 1fr) auto;
    gap: 4px;
    padding: 8px 8px;
  }
  .top-left,
  .top-actions {
    gap: 0;
  }
  .top-btn {
    width: 40px;
    min-width: 40px;
    padding: 0;
  }
  .top-btn .btn-text {
    display: none;
  }
  .top-title {
    min-width: 0;
    padding: 0 4px;
  }
  .top-title h1 {
    font-size: 16px;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  .top-title .sub {
    display: none;
  }
  .top-actions .icon-btn {
    min-width: 40px;
    width: 40px;
    padding: 0;
  }
}


/* ===== Voice toggle ===== */
.voice-toggle {
  width: 40px;
  min-width: 40px;
  height: 40px;
  padding: 0;
  color: #64748b;
}
.voice-toggle .voice-svg {
  display: block;
  fill: currentColor;
}
.voice-toggle .voice-body {
  fill: currentColor;
}
.voice-toggle .voice-wave {
  fill: none;
}
.voice-toggle .voice-slash {
  display: none;
}
.voice-toggle.on {
  background: #eff6ff;
  color: #2563eb;
}
.voice-toggle:not(.on) {
  color: #94a3b8;
}
.voice-toggle:not(.on) .voice-wave {
  display: none;
}
.voice-toggle:not(.on) .voice-slash {
  display: block;
}
