:root {
  color-scheme: light;
  --bg: #fafafa;
  --sidebar: rgba(246, 246, 246, 0.84);
  --surface: rgba(255, 255, 255, 0.88);
  --surface-muted: #eeeeef;
  --text: #111113;
  --muted: #666a70;
  --subtle: #8b8f96;
  --line: #e2e3e6;
  --line-strong: #cfd2d7;
  --accent: #111113;
  --accent-hover: #2b2d31;
  --on-accent: #ffffff;
  --user: #f0f1f3;
  --on-user: #17181b;
  --assistant: #f7f7f8;
  --focus: #5d6b82;
  --shadow: 0 16px 48px rgba(17, 17, 19, 0.13);
  --soft-shadow: 0 24px 80px rgba(17, 17, 19, 0.1);
  --radius-control: 999px;
  --radius-soft: 18px;
  --radius-panel: 28px;
  --chat-width: 980px;
}

body.dark {
  color-scheme: dark;
  --bg: #0d0d0f;
  --sidebar: rgba(20, 20, 22, 0.86);
  --surface: rgba(25, 25, 28, 0.88);
  --surface-muted: #242428;
  --text: #f4f4f5;
  --muted: #b4b4bb;
  --subtle: #83858c;
  --line: #303036;
  --line-strong: #45464d;
  --accent: #f4f4f5;
  --accent-hover: #ffffff;
  --on-accent: #111113;
  --user: #25262b;
  --on-user: #f1f2f4;
  --assistant: #1a1a1d;
  --focus: #a8b0bf;
  --shadow: 0 18px 52px rgba(0, 0, 0, 0.38);
  --soft-shadow: 0 24px 80px rgba(0, 0, 0, 0.32);
}

body.large-text {
  font-size: 17px;
}

body.high-contrast {
  --line: #7a7d84;
  --line-strong: #111113;
  --muted: #24262b;
  --subtle: #44474e;
  --focus: #000000;
}

body.dark.high-contrast {
  --line: #c8c8cc;
  --line-strong: #ffffff;
  --muted: #f4f4f5;
  --subtle: #d4d4d8;
}

body.color-blind {
  --accent: #c75b12;
  --accent-hover: #a8480d;
  --user: #fff1e8;
  --on-user: #4a1f05;
  --surface-muted: #fff4eb;
  --focus: #f97316;
}

body.dark.color-blind {
  --accent: #fb923c;
  --accent-hover: #fdba74;
  --user: #3b2417;
  --on-user: #fff7ed;
  --surface-muted: #2f2118;
  --focus: #f97316;
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
  font-family:
    Avenir, "Avenir Next", ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
  font-size: 15px;
}

button,
select,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
  transition:
    background 160ms ease,
    border-color 160ms ease,
    color 160ms ease,
    transform 160ms ease,
    box-shadow 160ms ease;
}

svg {
  display: block;
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.8;
}

.app-shell {
  display: grid;
  grid-template-columns: 292px minmax(0, 1fr);
  height: 100vh;
  height: 100dvh;
  min-height: 0;
  overflow: hidden;
  background: transparent;
}

.sidebar {
  display: flex;
  flex-direction: column;
  gap: 16px;
  min-height: 0;
  min-width: 0;
  overflow: hidden;
  margin: 14px 0 14px 14px;
  padding: 16px;
  border: 1px solid color-mix(in srgb, var(--line) 74%, transparent);
  border-radius: 26px;
  background: var(--sidebar);
  box-shadow: var(--soft-shadow);
  backdrop-filter: blur(18px);
}

.brand-row {
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 0;
  padding: 22px 2px 14px;
}

.brand-logo {
  width: 88%;
  height: auto;
  flex: 0 0 auto;
  object-fit: contain;
}

h1,
h2,
h3,
p {
  overflow-wrap: anywhere;
}

.new-chat,
.ghost-button,
.chat-item,
.theme-toggle,
.send-button,
.mic-button,
.download-button,
.prompt-chip,
.modal-close {
  border: 1px solid var(--line);
  border-radius: var(--radius-control);
  color: var(--text);
  background: var(--surface);
}

.new-chat {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin-top: 18px;
  min-height: 42px;
  padding: 0 16px;
  color: var(--on-accent);
  background: var(--accent);
  border-color: var(--accent);
  font-weight: 620;
  box-shadow: 0 10px 28px color-mix(in srgb, var(--accent) 18%, transparent);
}

body.dark .new-chat {
  color: var(--on-accent);
  background: var(--accent);
  border-color: var(--accent);
}

.new-chat:not(:disabled):hover {
  background: var(--accent-hover);
  transform: translateY(-1px);
}

body.dark .new-chat:not(:disabled):hover {
  background: var(--accent-hover);
}

.new-chat:disabled {
  cursor: not-allowed;
  opacity: 0.45;
  box-shadow: none;
}

.history-block {
  display: grid;
  gap: 4px;
  padding: 2px 4px 0;
}

.history-panel {
  display: flex;
  flex: 1;
  flex-direction: column;
  gap: 16px;
  min-height: 0;
}

.mobile-history-toggle {
  display: none;
}

.history-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 2px;
  color: var(--subtle);
  font-size: 0.76rem;
  font-weight: 650;
  text-transform: uppercase;
}

.history-search-toggle {
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  color: var(--subtle);
  background: transparent;
}

.history-search-toggle:hover,
.history-search-toggle[aria-expanded="true"] {
  color: var(--text);
  background: var(--surface-muted);
}

.history-search-toggle svg {
  width: 16px;
  height: 16px;
}

.history-search {
  position: relative;
  margin-top: 4px;
}

.history-search[hidden] {
  display: none;
}

.history-search > svg {
  position: absolute;
  top: 50%;
  left: 10px;
  width: 15px;
  height: 15px;
  color: var(--subtle);
  transform: translateY(-50%);
  pointer-events: none;
}

.history-search input {
  width: 100%;
  height: 36px;
  padding: 0 10px 0 32px;
  border: 1px solid var(--line);
  border-radius: 12px;
  outline: none;
  color: var(--text);
  background: color-mix(in srgb, var(--surface) 82%, transparent);
}

.history-search input:focus {
  border-color: var(--line-strong);
}

.history-search input::placeholder {
  color: var(--subtle);
}

.history-empty {
  margin: 10px 8px;
  color: var(--subtle);
  font-size: 0.78rem;
}

.chat-list {
  display: flex;
  flex: 1;
  flex-direction: column;
  gap: 2px;
  min-height: 160px;
  overflow: auto;
  padding: 0 8px 0 0;
}

.chat-item-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 32px 32px;
  align-items: center;
  gap: 6px;
  min-height: 38px;
  padding-right: 4px;
  border-color: transparent;
  border-radius: var(--radius-soft);
  background: transparent;
}

.chat-item {
  width: 100%;
  min-width: 0;
  min-height: 38px;
  padding: 9px 8px 9px 12px;
  border-color: transparent;
  border-radius: var(--radius-soft);
  background: transparent;
  color: var(--muted);
  text-align: left;
}

.chat-item strong,
.chat-item span {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chat-item strong {
  color: var(--text);
  font-size: 0.88rem;
  font-weight: 560;
}

.chat-item span {
  margin-top: 3px;
  font-size: 0.75rem;
}

.chat-item-row.active,
.chat-item-row:hover {
  border-color: transparent;
  background: color-mix(in srgb, var(--surface) 78%, transparent);
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--line) 55%, transparent);
}

.chat-item-row.active .chat-item,
.chat-item-row:hover .chat-item {
  background: transparent;
}

.download-button {
  display: inline-grid;
  place-items: center;
  width: 32px;
  height: 32px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  color: var(--subtle);
  background: transparent;
}

.download-button svg {
  width: 15px;
  height: 15px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.download-button:hover:not(:disabled) {
  color: var(--text);
  background: color-mix(in srgb, var(--surface-muted) 78%, transparent);
}

.download-button:disabled {
  cursor: not-allowed;
  opacity: 0.35;
}

.chat-download {
  justify-self: center;
}

.sidebar-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--line);
}

.ghost-button {
  display: flex;
  align-items: center;
  width: auto;
  min-height: 38px;
  flex: 1 1 auto;
  justify-content: flex-start;
  padding: 0 6px;
  border-color: transparent;
  background: transparent;
  color: var(--muted);
  text-align: left;
}

.ghost-button:hover {
  color: var(--text);
  background: color-mix(in srgb, var(--surface) 78%, transparent);
}

.chat-panel {
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto auto;
  height: 100%;
  min-height: 0;
  min-width: 0;
  overflow: hidden;
  background: transparent;
}

.top-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 0 0 auto;
}

.accessibility-menu,
.language-menu {
  position: relative;
}

.theme-toggle,
.accessibility-toggle,
.language-toggle {
  position: relative;
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  flex: 0 0 auto;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: var(--surface);
  color: var(--muted);
  appearance: none;
  -webkit-appearance: none;
}

.accessibility-toggle {
  border-color: transparent;
  background: transparent;
}

.theme-toggle:hover,
.accessibility-toggle:hover,
.accessibility-toggle[aria-expanded="true"],
.language-toggle:hover,
.language-toggle[aria-expanded="true"] {
  color: var(--text);
  background: var(--surface-muted);
  border-color: var(--line-strong);
}

.accessibility-toggle:hover,
.accessibility-toggle[aria-expanded="true"] {
  background: transparent;
  border-color: transparent;
}

.accessibility-toggle img,
.theme-toggle svg,
.language-toggle svg {
  width: 18px;
  height: 18px;
}

.accessibility-toggle img {
  width: 30px;
  height: 30px;
  object-fit: contain;
}

.accessibility-icon-mobile {
  display: none;
}

.language-toggle svg {
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
}

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

.language-panel {
  position: absolute;
  right: -88px;
  bottom: calc(100% + 12px);
  z-index: 10;
  display: none;
  width: min(246px, calc(100vw - 28px));
  padding: 12px;
  border: 1px solid color-mix(in srgb, var(--line-strong) 74%, transparent);
  border-radius: 18px;
  background: color-mix(in srgb, var(--surface) 96%, transparent);
  box-shadow: var(--shadow);
  backdrop-filter: blur(26px) saturate(1.1);
  -webkit-backdrop-filter: blur(26px) saturate(1.1);
}

.language-menu.open .language-panel {
  display: grid;
  gap: 9px;
}

.language-panel-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  padding: 0 4px;
}

.language-panel-header p {
  margin: 0;
  color: var(--text);
  font-size: 0.9rem;
  font-weight: 700;
}

.language-current {
  overflow: hidden;
  color: var(--subtle);
  font-size: 0.74rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.language-search {
  width: 100%;
  height: 38px;
  padding: 0 12px;
  border: 0;
  border-radius: 12px;
  outline: none;
  color: var(--text);
  background: var(--surface-muted);
  font: inherit;
  font-size: 0.82rem;
}

.language-search:focus {
  border-color: transparent;
  background: color-mix(in srgb, var(--surface-muted) 82%, var(--surface));
  box-shadow: none;
}

.language-status,
.language-empty {
  margin: 0;
  padding: 2px 5px;
  color: var(--subtle);
  font-size: 0.72rem;
  line-height: 1.35;
}

.language-status:empty {
  display: none;
}

.language-status.error {
  color: #a33d3d;
}

.language-panel[aria-busy="true"] .language-list {
  pointer-events: none;
  opacity: 0.58;
}

.language-list {
  display: grid;
  gap: 3px;
  max-height: min(46vh, 330px);
  padding-right: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-width: none;
  -ms-overflow-style: none;
}

.language-list::-webkit-scrollbar {
  display: none;
}

.language-option {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-height: 44px;
  padding: 8px 12px;
  border: 0;
  border-radius: 12px;
  color: var(--text);
  background: transparent;
  text-align: start;
}

.language-option:hover,
.language-option.selected {
  background: var(--surface-muted);
}

.language-option::after {
  content: "✓";
  grid-column: 2;
  grid-row: 1;
  color: var(--text);
  font-size: 0.85rem;
  opacity: 0;
}

.language-option.selected::after {
  opacity: 1;
}

.language-option span {
  grid-column: 1;
  min-width: 0;
}

.language-native-name {
  grid-row: 1;
  font-size: 0.84rem;
  font-weight: 600;
  line-height: 1.3;
}

body.dark .accessibility-toggle img {
  filter: invert(1);
}

.theme-toggle svg {
  stroke-width: 1.9;
}

.accessibility-panel {
  position: absolute;
  bottom: calc(100% + 12px);
  right: -44px;
  z-index: 8;
  display: none;
  width: 240px;
  padding: 12px;
  border: 1px solid color-mix(in srgb, var(--line-strong) 74%, transparent);
  border-radius: 18px;
  background: color-mix(in srgb, var(--surface) 94%, transparent);
  box-shadow: var(--shadow);
  backdrop-filter: blur(26px) saturate(1.1);
  -webkit-backdrop-filter: blur(26px) saturate(1.1);
}

.accessibility-menu.open .accessibility-panel {
  display: grid;
  gap: 8px;
}

.accessibility-panel p {
  margin: 0 4px 4px;
  color: var(--subtle);
  font-size: 0.8rem;
  font-weight: 700;
  text-transform: uppercase;
}

.accessibility-panel label {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 38px;
  padding: 0 8px;
  border-radius: 12px;
  color: var(--text);
}

.accessibility-panel label:hover {
  background: var(--surface-muted);
}

.accessibility-panel input {
  width: 18px;
  height: 18px;
  accent-color: var(--accent);
}

.theme-toggle .moon-icon {
  display: none;
  transform: translateX(-2px);
}

body.dark .theme-toggle .sun-icon {
  display: none;
}

body.dark .theme-toggle .moon-icon {
  display: block;
}

.messages {
  display: flex;
  flex-direction: column;
  gap: 14px;
  min-height: 0;
  overflow: auto;
  overscroll-behavior: contain;
  scrollbar-gutter: stable;
  padding: 40px 26px 28px;
}

.empty-state {
  display: grid;
  place-items: center;
  min-height: 100%;
  text-align: center;
}

.empty-state-inner {
  width: min(var(--chat-width), 100%);
  padding: 22px 0 18px;
}

.empty-state .mark {
  display: none;
}

.empty-state h2 {
  margin: 0 auto 14px;
  max-width: 620px;
  font-size: clamp(1rem, 2.45vw, 2.35rem);
  font-weight: 800;
  letter-spacing: 0;
  line-height: 1.08;
}

.empty-state h2 span {
  display: block;
}

.empty-state h2 span + span {
  margin-top: 3px;
}

.empty-state p {
  margin: 0 auto 30px;
  max-width: 720px;
  color: var(--muted);
  font-size: 1.08rem;
  line-height: 1.65;
}

.prompt-chips {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 12px;
  width: min(1040px, 100%);
  margin: 0 auto;
}

.prompt-chip {
  min-height: 44px;
  max-width: 100%;
  padding: 10px 15px;
  border-color: color-mix(in srgb, var(--line) 72%, transparent);
  background: color-mix(in srgb, var(--surface) 78%, transparent);
  color: var(--muted);
  font-size: 0.8rem;
  line-height: 1.3;
  overflow: hidden;
  text-align: left;
  text-overflow: ellipsis;
  white-space: nowrap;
  backdrop-filter: blur(12px);
}

.prompt-chip:hover {
  color: var(--text);
  border-color: var(--line-strong);
  background: var(--surface-muted);
  transform: translateY(-1px);
}

.message {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  width: min(var(--chat-width), 100%);
  margin: 0 auto;
}

.message.user {
  align-items: flex-end;
}

.bubble {
  max-width: min(760px, 100%);
  padding: 14px 16px;
  border: 0;
  border-radius: var(--radius-soft);
  line-height: 1.6;
  white-space: pre-wrap;
}

.user .bubble {
  color: var(--on-user);
  background: var(--user);
  border: 1px solid color-mix(in srgb, var(--line) 72%, transparent);
  border-bottom-right-radius: 10px;
  box-shadow: 0 12px 34px rgba(17, 17, 19, 0.08);
}

.assistant .bubble {
  color: var(--text);
  background: transparent;
  border-radius: 0;
  font-size: 1.02rem;
  white-space: normal;
}

body.dark .user .bubble {
  color: var(--on-user);
  border-color: transparent;
}

.message-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  width: min(760px, 100%);
  min-height: 26px;
  margin-top: -8px;
  padding: 0 0 0 10px;
}

.answer-download {
  width: 26px;
  height: 26px;
}

.answer-download svg {
  width: 14px;
  height: 14px;
}

.listen-reply {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 30px;
  padding: 0 10px;
  border: 0;
  border-radius: var(--radius-control);
  color: var(--muted);
  background: transparent;
  font-size: 0.8rem;
}

.listen-reply:hover {
  color: var(--text);
  background: var(--surface-muted);
}

.listen-reply.playing {
  color: var(--accent);
  background: var(--surface-muted);
}

.listen-reply svg {
  width: 15px;
  height: 15px;
}

.composer {
  position: relative;
  width: min(var(--chat-width), calc(100% - 44px));
  margin: 0 auto;
  padding: 12px 0 8px;
}

.privacy-note {
  width: min(var(--chat-width), calc(100% - 52px));
  margin: 0 auto;
  padding: 0 0 18px;
  color: var(--subtle);
  font-size: 0.72rem;
  line-height: 1.45;
  text-align: center;
}

.privacy-note strong {
  color: var(--muted);
  font-weight: 650;
}

body.rtl-text .privacy-details {
  display: block;
  direction: rtl;
  text-align: center;
  unicode-bidi: isolate;
}

body.rtl-text .privacy-details > * {
  unicode-bidi: isolate;
}

.privacy-note .copyright-line {
  display: block;
  direction: ltr;
  margin-top: 4px;
  unicode-bidi: isolate;
}

.privacy-note .copyright-line [dir="rtl"] {
  display: inline-block;
  direction: rtl;
  unicode-bidi: isolate;
}

.privacy-note a {
  color: inherit;
  font-weight: 650;
  text-decoration: none;
}

.privacy-note a:hover {
  color: var(--muted);
  text-decoration: underline;
  text-underline-offset: 3px;
}

.composer-shell {
  position: relative;
  display: grid;
  gap: 8px;
  transform: translateY(-10px);
  padding: 12px 13px;
  border: 1px solid color-mix(in srgb, var(--line) 86%, transparent);
  border-radius: 30px;
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  box-shadow: var(--soft-shadow);
  backdrop-filter: blur(22px);
}

.composer-shell::before {
  position: absolute;
  inset: -1px;
  padding: 1px;
  border-radius: inherit;
  background: linear-gradient(115deg, #ffd6e8, #c7ddff, #d7f8e8, #fff0bf, #e5d4ff, #ffd6e8);
  background-size: 240% 240%;
  content: "";
  opacity: 0;
  pointer-events: none;
  -webkit-mask:
    linear-gradient(#000 0 0) content-box,
    linear-gradient(#000 0 0);
  -webkit-mask-composite: xor;
  mask:
    linear-gradient(#000 0 0) content-box,
    linear-gradient(#000 0 0);
  mask-composite: exclude;
}

.composer-shell:focus-within {
  border-color: transparent;
}

.composer-shell:focus-within::before {
  animation: composer-focus-border 900ms ease-out 1 forwards;
}

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

.right-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

textarea {
  width: 100%;
  border: 0;
  border-radius: 18px;
  color: var(--text);
  background: transparent;
}

.source-picker {
  position: relative;
  min-width: 0;
}

.source-trigger {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  max-width: 230px;
  height: 32px;
  padding: 0 11px;
  border: 1px solid transparent;
  border-radius: 999px;
  color: var(--muted);
  background: color-mix(in srgb, var(--surface-muted) 86%, transparent);
}

.source-trigger span {
  overflow: hidden;
  max-width: 172px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.source-trigger svg {
  width: 16px;
  height: 16px;
  flex: 0 0 auto;
}

.source-trigger:hover,
.source-trigger[aria-expanded="true"] {
  color: var(--text);
  background: color-mix(in srgb, var(--surface-muted) 72%, var(--line));
}

.source-menu {
  position: absolute;
  left: 0;
  bottom: calc(100% + 10px);
  z-index: 5;
  display: none;
  width: min(420px, calc(100vw - 34px));
  padding: 14px 10px 10px;
  border: 1px solid color-mix(in srgb, var(--line-strong) 74%, transparent);
  border-radius: 18px;
  background: color-mix(in srgb, var(--bg) 96%, var(--surface));
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px) saturate(1.05);
  -webkit-backdrop-filter: blur(18px) saturate(1.05);
}

.source-picker.open .source-menu {
  display: block;
}

.source-menu p {
  margin: 0 14px 8px;
  color: var(--subtle);
  font-size: 1.02rem;
  line-height: 1.3;
}

.source-option {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  width: 100%;
  min-height: 46px;
  padding: 0 14px;
  border: 0;
  border-radius: 14px;
  color: var(--text);
  background: transparent;
  text-align: left;
  font-size: 1rem;
}

.source-option:hover,
.source-option.selected {
  background: var(--surface-muted);
}

.source-option svg {
  display: none;
  width: 18px;
  height: 18px;
  flex: 0 0 auto;
}

.source-option.selected svg {
  display: block;
}

textarea {
  min-height: 30px;
  padding: 5px 9px;
  overflow: hidden;
  resize: none;
  line-height: 1.45;
}

textarea::placeholder {
  color: var(--subtle);
}

textarea.multiline {
  border-radius: 18px;
}

textarea.scrollable {
  overflow-y: auto;
  scrollbar-color: color-mix(in srgb, var(--subtle) 36%, transparent) transparent;
  scrollbar-width: thin;
}

textarea.scrollable::-webkit-scrollbar {
  width: 6px;
}

textarea.scrollable::-webkit-scrollbar-track {
  background: transparent;
}

textarea.scrollable::-webkit-scrollbar-thumb {
  border-radius: 999px;
  background: color-mix(in srgb, var(--subtle) 32%, transparent);
}

textarea.scrollable::-webkit-scrollbar-thumb:hover {
  background: color-mix(in srgb, var(--subtle) 48%, transparent);
}

textarea:focus {
  outline: none;
}

button:focus-visible {
  outline: 2px solid color-mix(in srgb, var(--focus) 55%, transparent);
  outline-offset: 1px;
}

.send-button {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  color: var(--on-accent);
  background: var(--accent);
  border-color: var(--accent);
  box-shadow: 0 10px 26px color-mix(in srgb, var(--accent) 22%, transparent);
}

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

.mic-button {
  position: relative;
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border-color: transparent;
  background: transparent;
  color: var(--subtle);
}

.mic-button:hover {
  color: var(--text);
}

.mic-button.listening {
  color: #d92d20;
}

.mic-wave {
  position: absolute;
  inset: 3px;
  border-radius: 50%;
  opacity: 0;
  background: currentColor;
}

.mic-button.listening .mic-wave {
  animation: mic-pulse 1.35s ease-out infinite;
  opacity: 0.15;
}

.speech-status {
  margin: 0;
  max-width: 150px;
  color: var(--subtle);
  font-size: 0.78rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

@keyframes mic-pulse {
  0% {
    transform: scale(0.76);
    opacity: 0.24;
  }

  70% {
    transform: scale(1.45);
    opacity: 0;
  }

  100% {
    transform: scale(1.45);
    opacity: 0;
  }
}

@keyframes composer-focus-border {
  0% {
    background-position: 0% 50%;
    opacity: 0;
  }

  42% {
    background-position: 100% 50%;
    opacity: 1;
  }

  100% {
    background-position: 50% 50%;
    opacity: 1;
  }
}

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

.send-button:hover {
  background: var(--accent-hover);
  transform: translateY(-1px);
}

body.dark .send-button {
  color: var(--on-accent);
  background: var(--accent);
  border-color: var(--accent);
}

body.dark .send-button:hover {
  background: var(--accent-hover);
}

.about-modal {
  width: min(640px, calc(100vw - 32px));
  padding: 26px;
  border: 1px solid var(--line);
  border-radius: var(--radius-panel);
  color: var(--text);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.about-modal::backdrop {
  background: rgba(0, 0, 0, 0.42);
  backdrop-filter: blur(6px) saturate(0.9);
  -webkit-backdrop-filter: blur(6px) saturate(0.9);
}

.about-modal-header {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 36px;
  gap: 12px;
  align-items: center;
  margin-bottom: 8px;
}

.about-modal .eyebrow {
  margin: 0;
  color: var(--subtle);
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
}

.about-modal h2 {
  margin: 0 0 12px;
  font-size: 1.55rem;
  font-weight: 650;
}

.about-logo {
  display: block;
  width: auto;
  height: 1.35rem;
  object-fit: contain;
}

.about-logo-dark,
body.dark .about-logo-light {
  display: none;
}

body.dark .about-logo-dark {
  display: block;
}

.about-modal p {
  color: var(--muted);
  line-height: 1.65;
}

.about-modal > p {
  font-size: 0.84rem;
  line-height: 1.55;
}

.about-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-top: 18px;
}

.about-grid section {
  padding: 14px;
  border: 0;
  border-radius: var(--radius-soft);
  background: var(--surface-muted);
}

.about-grid h3 {
  margin: 0 0 8px;
  font-size: 0.96rem;
  font-weight: 650;
}

.about-grid p {
  margin: 0;
}

.about-grid section:first-child p {
  font-size: 0.8rem;
  line-height: 1.55;
}

.contact-list {
  display: grid;
  gap: 12px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.contact-list li {
  display: grid;
  gap: 3px;
  padding-bottom: 11px;
  border-bottom: 1px solid color-mix(in srgb, var(--line) 70%, transparent);
}

.contact-list li:last-child {
  padding-bottom: 0;
  border-bottom: 0;
}

.contact-list strong {
  display: block;
  color: var(--text);
  font-size: 0.9rem;
  font-weight: 650;
}

.contact-list span {
  color: var(--subtle);
  font-size: 0.82rem;
}

.contact-list a {
  color: var(--muted);
  text-decoration: none;
}

.contact-list a:hover {
  color: var(--text);
  text-decoration: underline;
}

.modal-close {
  position: static;
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  padding: 0;
  background: transparent;
  color: var(--muted);
  font-size: 1.35rem;
  line-height: 1;
}

.modal-close:hover {
  color: var(--text);
  background: var(--surface-muted);
}

@media (max-width: 840px), (max-width: 1024px) and (max-height: 600px) and (hover: none) and (pointer: coarse) {
  body {
    overflow: hidden;
  }

  .app-shell {
    grid-template-columns: 1fr;
    grid-template-rows: auto minmax(0, 1fr);
    height: 100vh;
    height: 100dvh;
    min-height: 0;
    overflow: hidden;
  }

  .sidebar {
    position: relative;
    z-index: 12;
    display: grid;
    grid-template-columns: minmax(0, 1fr) 120px 40px;
    grid-template-rows: 40px 30px;
    gap: 6px;
    min-height: 0;
    margin: 8px 8px 0;
    padding: 8px 12px;
    overflow: visible;
    border-radius: 20px;
  }

  .brand-row {
    position: relative;
    top: 4px;
    grid-column: 1;
    grid-row: 1;
    justify-content: flex-start;
    margin-left: 4px;
    padding: 0;
  }

  .brand-logo {
    width: auto;
    max-width: 116px;
    height: 34px;
  }

  .new-chat {
    position: relative;
    top: 4px;
    grid-column: 3;
    grid-row: 1;
    width: 40px;
    height: 40px;
    min-height: 40px;
    align-self: center;
    margin: 0;
    padding: 0;
    border-radius: 50%;
    box-shadow: none;
  }

  .new-chat-label {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
  }

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

  .sidebar-footer {
    display: contents;
  }

  .top-actions {
    position: relative;
    top: 4px;
    grid-column: 2;
    grid-row: 1;
    justify-self: end;
    gap: 8px;
  }

  .theme-toggle,
  .accessibility-toggle,
  .language-toggle {
    width: 32px;
    height: 32px;
    min-height: 32px;
  }

  .accessibility-toggle {
    border-color: var(--line);
    background: var(--surface);
  }

  .accessibility-toggle:hover,
  .accessibility-toggle[aria-expanded="true"] {
    border-color: var(--line-strong);
    background: var(--surface-muted);
  }

  .accessibility-toggle .accessibility-icon-desktop {
    display: none;
  }

  .accessibility-toggle .accessibility-icon-mobile {
    display: block;
    width: 18px;
    height: 18px;
    stroke-width: 1.9;
  }

  .mobile-history-toggle,
  .ghost-button {
    display: inline-flex;
    align-items: center;
    min-height: 30px;
    padding: 0;
    border: 0;
    border-radius: 10px;
    color: var(--muted);
    background: transparent;
    font-size: 0.82rem;
    font-weight: 400;
  }

  .mobile-history-toggle {
    grid-column: 2 / 4;
    grid-row: 2;
    justify-content: flex-end;
    gap: 6px;
  }

  .mobile-history-toggle svg {
    width: 15px;
    height: 15px;
    transition: transform 160ms ease;
  }

  .sidebar.history-open .mobile-history-toggle svg {
    transform: rotate(180deg);
  }

  .ghost-button {
    grid-column: 1;
    grid-row: 2;
    justify-content: flex-start;
    width: auto;
    margin-left: 4px;
  }

  .mobile-history-toggle:hover,
  .mobile-history-toggle[aria-expanded="true"],
  .ghost-button:hover {
    color: var(--text);
    background: var(--surface-muted);
  }

  .history-panel {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    left: 0;
    z-index: 20;
    display: none;
    gap: 8px;
    max-height: min(55vh, 430px);
    padding: 14px 10px 12px 14px;
    overflow: hidden;
    border: 1px solid var(--line);
    border-radius: 20px;
    background: var(--surface);
    box-shadow: var(--shadow);
  }

  .sidebar.history-open .history-panel {
    display: flex;
  }

  .history-header {
    padding: 0 4px 4px;
  }

  .accessibility-panel {
    top: calc(100% + 10px);
    right: 0;
    bottom: auto;
  }

  .language-panel {
    position: fixed;
    top: 110px;
    right: 16px;
    bottom: auto;
    left: 16px;
    width: auto;
    max-height: calc(100dvh - 126px);
  }

  .language-list {
    max-height: min(58dvh, 430px);
  }

  .chat-panel {
    height: 100%;
    min-height: 0;
    overflow: hidden;
  }

  .chat-list {
    max-height: 340px;
    min-height: 0;
  }

  .messages {
    min-height: 0;
    padding: 24px 18px 18px;
  }

  .composer {
    width: calc(100% - 32px);
  }

  .composer-actions {
    align-items: flex-end;
  }

  .source-trigger {
    max-width: 180px;
  }

  .source-trigger span {
    max-width: 122px;
  }

  .source-menu {
    bottom: calc(100% + 8px);
    width: min(360px, calc(100vw - 48px));
    max-height: min(55dvh, 360px);
    padding: 10px 8px 8px;
    overflow-y: auto;
    overscroll-behavior: contain;
    border-radius: 16px;
  }

  .source-menu p {
    margin: 2px 10px 6px;
    font-size: 0.82rem;
  }

  .source-option {
    gap: 12px;
    min-height: 40px;
    padding: 7px 10px;
    font-size: 0.82rem;
    line-height: 1.25;
  }

  .source-option span {
    min-width: 0;
  }

  .source-option svg {
    width: 16px;
    height: 16px;
  }

  .privacy-note {
    padding-bottom: 10px;
    font-size: 0.68rem;
  }

  .privacy-details,
  .copyright-organization {
    display: none;
  }

  .privacy-note .copyright-line {
    margin-top: 0;
  }

  .empty-state-inner {
    width: min(560px, 100%);
    padding: 20px 0 16px;
  }

  .empty-state h2 {
    max-width: 460px;
    margin-bottom: 10px;
    font-size: 1.25rem;
    line-height: 1.22;
  }

  .empty-state p {
    max-width: 460px;
    margin-bottom: 24px;
    font-size: 0.95rem;
    line-height: 1.45;
  }

  .prompt-chips {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 6px;
    width: min(420px, 100%);
  }

  .prompt-chip {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 36px;
    min-height: 36px;
    padding: 4px 10px;
    font-size: 0.75rem;
    line-height: 1.35;
    text-align: center;
    text-overflow: clip;
    white-space: normal;
  }
}

@media (max-width: 520px) {
  .app-shell {
    min-height: 100vh;
  }

  .empty-state-inner {
    width: min(360px, 100%);
    padding: 16px 0 12px;
  }

  .empty-state h2 {
    max-width: 320px;
    margin-bottom: 8px;
    font-size: 1.05rem;
  }

  .empty-state p {
    max-width: 320px;
    margin-bottom: 20px;
    font-size: 0.875rem;
  }

  .prompt-chips {
    gap: 6px;
    width: min(340px, 100%);
  }

  .prompt-chip {
    height: 40px;
    min-height: 40px;
    padding: 4px 8px;
    font-size: 0.72rem;
  }

  .about-grid {
    grid-template-columns: 1fr;
  }

  .sidebar {
    grid-template-columns: minmax(0, 1fr) 102px 38px;
    margin: 6px 6px 0;
    padding: 8px 10px;
  }

  .brand-logo {
    max-width: 104px;
    height: 30px;
  }

  .new-chat {
    width: 38px;
    height: 38px;
    min-height: 38px;
  }

  .theme-toggle,
  .accessibility-toggle,
  .language-toggle {
    width: 30px;
    height: 30px;
    min-height: 30px;
  }

  .top-actions {
    gap: 6px;
  }

  .language-panel {
    top: 106px;
    right: 10px;
    left: 10px;
    max-height: calc(100dvh - 116px);
    padding: 10px;
  }

  .language-list {
    max-height: min(56dvh, 390px);
  }

  .mobile-history-toggle,
  .ghost-button {
    font-size: 0.78rem;
  }

  .messages {
    padding: 18px 12px 14px;
  }
}

/* ── Typing / loading indicator ──────────────────────────────────────────── */
.typing-bubble {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 14px 18px;
  min-width: 56px;
}

.typing-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--muted);
  animation: typingBounce 1.2s ease-in-out infinite;
}

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

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

.streaming-bubble::after {
  content: "";
  display: inline-block;
  width: 2px;
  height: 1.05em;
  margin-left: 4px;
  border-radius: 1px;
  background: currentColor;
  vertical-align: -0.16em;
  animation: streamCursorBlink 0.8s steps(2, start) infinite;
}

@keyframes streamCursorBlink {
  50% { opacity: 0; }
}

@media (prefers-reduced-motion: reduce) {
  .typing-dot,
  .streaming-bubble::after {
    animation: none;
  }
}

/* ── Markdown rendering inside assistant bubbles ─────────────────────────── */
.assistant .bubble p {
  margin: 0;
}

.assistant .bubble p + p {
  margin-top: 0.9em;
}

.assistant .bubble ul,
.assistant .bubble ol {
  margin: 0.75em 0 0.75em 1.4em;
  padding: 0;
}

.assistant .bubble > :first-child {
  margin-top: 0;
}

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

.assistant .bubble li {
  margin-bottom: 3px;
  line-height: 1.55;
  overflow-wrap: anywhere;
}

.assistant .bubble strong {
  font-weight: 600;
}

.assistant .bubble em {
  font-style: italic;
}

.assistant .bubble h2,
.assistant .bubble h3,
.assistant .bubble h4 {
  margin: 1em 0 0.45em;
  font-size: 1.05em;
  line-height: 1.4;
  font-weight: 600;
}

.assistant .bubble h2 {
  font-size: 1.12em;
}

.assistant .bubble a {
  color: inherit;
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
}

.assistant .bubble a:hover {
  text-decoration-thickness: 2px;
}

/* Inline citation superscripts [1] [2] */
.assistant .bubble sup.cite {
  font-size: 0.72em;
  vertical-align: super;
  color: var(--muted);
  font-weight: 600;
  letter-spacing: 0;
}

.assistant .bubble .sources-heading {
  margin-bottom: 0.4em;
  font-weight: 600;
}

.assistant .bubble ol.sources-list {
  margin: 0;
  padding: 0.65em 0 0;
  border-top: 1px solid var(--line);
  list-style: none;
}

.assistant .bubble ol.sources-list li {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: start;
  gap: 0.22em;
  margin-bottom: 0.35em;
}

.assistant .bubble .source-number {
  position: relative;
  top: -0.08em;
  font-size: 0.68em;
  line-height: 1;
  font-weight: 600;
  color: var(--muted);
}

.assistant .bubble .source-reference-text {
  min-width: 0;
}

/* ── Right-to-left text without mirroring the interface layout ──────────── */
[data-i18n][dir="rtl"],
[data-i18n-placeholder][dir="rtl"],
#sourceLabel[dir="rtl"],
.bubble[dir="rtl"],
.language-native-name[dir="rtl"],
.language-current[dir="rtl"] {
  direction: rtl;
  text-align: right;
  unicode-bidi: plaintext;
}

body.rtl-text .contact-list span {
  direction: rtl;
  text-align: right;
  unicode-bidi: isolate;
}

body.rtl-text .contact-list strong {
  direction: ltr;
  text-align: left;
  unicode-bidi: isolate;
}

.assistant .bubble[dir="rtl"] ul,
.assistant .bubble[dir="rtl"] ol {
  margin-right: 1.4em;
  margin-left: 0;
}

.history-storage-status {
  flex: 0 0 auto;
  margin: 8px 24px 0;
  color: var(--text);
  font-size: 0.8rem;
  text-align: center;
}
.history-interrupted {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 0.8rem;
}
.chat-delete:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

.sidebar-utilities {
  display: grid;
  flex: 0 0 auto;
  gap: 2px;
  padding: 4px;
  border: 1px solid color-mix(in srgb, var(--line) 65%, transparent);
  border-radius: 14px;
  background: color-mix(in srgb, var(--surface) 35%, transparent);
}
.sidebar-utilities .clear-history-button,
.sidebar-utilities .publication-link {
  display: grid;
  grid-template-columns: 16px minmax(0, 1fr) 14px;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-height: 38px;
  padding: 8px 10px;
  border: 0;
  border-radius: 9px;
  background: transparent;
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 400;
  line-height: 1.4;
  text-align: start;
  text-decoration: none;
}
.sidebar-utilities svg {
  width: 16px;
  height: 16px;
  stroke-width: 1.6;
}
.sidebar-utilities .external-link-icon {
  width: 14px;
  height: 14px;
  opacity: 0.65;
}
.sidebar-utilities .clear-history-button:hover:not(:disabled),
.sidebar-utilities .publication-link:hover {
  color: var(--text);
  background: var(--surface-muted);
}
.clear-history-button:focus-visible,
.publication-link:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}
.clear-history-button:disabled {
  opacity: 0.45;
  cursor: default;
}
.publication-link-mobile {
  display: none;
}
@media (max-width: 840px), (max-width: 1024px) and (max-height: 600px) and (hover: none) and (pointer: coarse) {
  .sidebar-utilities {
    padding: 4px 0 0;
    border: 0;
    border-top: 1px solid var(--line);
    border-radius: 0;
    background: transparent;
  }
  .sidebar-utilities .publication-link-sidebar {
    display: none;
  }
  .publication-link-mobile {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    margin-top: 4px;
    padding: 6px 12px;
    min-height: 30px;
    border-radius: 10px;
    color: var(--muted);
    font-size: 0.75rem;
    line-height: 1.4;
    text-decoration: none;
  }
  .publication-link-mobile svg {
    width: 14px;
    height: 14px;
  }
  .publication-link-mobile:hover {
    color: var(--text);
    text-decoration: underline;
    text-underline-offset: 3px;
  }
}
