@font-face {
  font-family: Vazirmatn;
  src: url("vazirmatn.woff2") format("woff2");
  font-weight: 400;
  font-display: swap;
}
:root {
  color-scheme: dark;
  --bg: #151b1d;
  --side: #101618;
  --panel: #1d2528;
  --hover: #273235;
  --line: #303c3e;
  --text: #e9efee;
  --muted: #92a29f;
  --accent: #36c7b2;
  --accent-soft: #1b3b36;
  --ink: #05231e;
  --error: #ff9a95;
  --shadow: 0 20px 80px #0005;
}
:root[data-theme="light"] {
  color-scheme: light;
  --bg: #f8faf9;
  --side: #eef3f1;
  --panel: #fff;
  --hover: #e9f0ee;
  --line: #d5e0dc;
  --text: #1b302b;
  --muted: #667e74;
  --accent: #0b8d77;
  --accent-soft: #deefe9;
  --ink: #fff;
  --error: #ba3838;
  --shadow: 0 20px 80px #29403520;
}
* {
  box-sizing: border-box;
}
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font:
    16px/1.8 Vazirmatn,
    system-ui,
    sans-serif;
}
button,
input,
textarea,
select {
  font: inherit;
}
button,
a,
input,
select,
textarea {
  -webkit-tap-highlight-color: transparent;
}
button {
  cursor: pointer;
}
button,
a {
  transition:
    background 0.15s,
    color 0.15s,
    border-color 0.15s;
}
button:disabled {
  opacity: 0.45;
  cursor: wait;
}
button {
  color: inherit;
}
a {
  color: var(--accent);
}
button:focus-visible,
a:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 4px;
}
input,
textarea,
select {
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 11px 12px;
  width: 100%;
  min-width: 0;
  outline: none;
}
input:focus,
textarea:focus,
select:focus {
  border-color: var(--accent);
}
input[type="checkbox"] {
  width: 18px;
  height: 18px;
  accent-color: var(--accent);
}
[hidden] {
  display: none !important;
}
svg.icon {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
  flex-shrink: 0;
}
.app-shell {
  display: flex;
  height: 100dvh;
  min-height: 420px;
  overflow: hidden;
}
.sidebar {
  width: 278px;
  flex: 0 0 278px;
  background: var(--side);
  border-left: 1px solid var(--line);
  padding: 30px 20px 16px;
  display: flex;
  flex-direction: column;
  gap: 23px;
}
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: var(--text);
  padding: 0 6px;
  margin-bottom: 8px;
}
.brand img {
  width: 45px;
  height: 51px;
  object-fit: contain;
}
.brand > span {
  font:
    600 25px/1.1 system-ui,
    sans-serif;
  letter-spacing: -1px;
}
.brand > span > span {
  color: var(--accent);
}
.brand small {
  display: block;
  font:
    12px/2.2 Vazirmatn,
    sans-serif;
  letter-spacing: 0;
  color: var(--muted);
  direction: rtl;
}
.primary,
.outline,
.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  border: 1px solid transparent;
  border-radius: 10px;
  padding: 11px 18px;
  font-size: 14px;
  text-decoration: none;
}
.primary {
  background: var(--accent);
  color: var(--ink);
  font-weight: 700;
}
.primary:hover {
  filter: brightness(1.08);
}
.outline {
  background: transparent;
  border-color: var(--line);
}
.outline:hover {
  background: var(--hover);
}
.new-chat {
  justify-content: flex-start;
}
.new-chat kbd {
  margin-right: auto;
  font: 16px system-ui;
  opacity: 0.5;
}
.search {
  display: flex;
  align-items: center;
  gap: 9px;
  color: var(--muted);
}
.search input {
  font-size: 14px;
  border: 0;
  background: transparent;
  padding: 4px 0;
}
.section-label {
  font-size: 12px;
  color: var(--muted);
  display: flex;
  justify-content: space-between;
  margin-bottom: -12px;
}
.chat-list {
  flex: 1;
  overflow: auto;
  min-height: 40px;
  display: flex;
  flex-direction: column;
  gap: 5px;
}
.history-item {
  display: flex;
  gap: 9px;
  align-items: center;
  border: 0;
  background: transparent;
  text-align: right;
  padding: 10px 9px;
  border-radius: 9px;
  font-size: 14px;
  color: var(--muted);
  width: 100%;
}
.history-item span:last-child {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.history-item svg {
  width: 16px;
  opacity: 0.65;
}
.history-item:hover,
.history-item.active {
  color: var(--text);
  background: var(--hover);
}
.history-empty {
  color: var(--muted);
  font-size: 13px;
  padding: 8px 0;
  line-height: 2;
}
.sidebar-bottom {
  margin-top: auto;
  border-top: 1px solid var(--line);
  padding-top: 16px;
  display: grid;
  gap: 11px;
}
.profile-button,
.nav-button {
  display: flex;
  align-items: center;
  gap: 11px;
  background: transparent;
  border: 0;
  text-align: right;
  padding: 6px;
  font-size: 14px;
}
.profile-button > span:last-child {
  margin-right: auto;
  color: var(--muted);
}
.user-avatar {
  display: grid;
  place-items: center;
  background: var(--accent-soft);
  border: 1px solid var(--line);
  color: var(--accent);
  width: 35px;
  height: 35px;
  border-radius: 50%;
}
.usage {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  font-size: 12px;
  color: var(--muted);
}
.usage progress {
  width: 100%;
  height: 4px;
  accent-color: var(--accent);
  display: block;
  margin-top: 8px;
}
.workspace {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}
.topbar {
  padding: 20px 32px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid transparent;
  gap: 12px;
}
.header-group {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}
.model-control {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}
.model-label {
  font-size: 13px;
  color: var(--muted);
  white-space: nowrap;
}
.model-control select {
  border: 0;
  background: transparent;
  font-size: 15px;
  padding: 6px 4px;
  width: auto;
  max-width: 230px;
}
.badge {
  font-size: 12px;
  background: var(--accent-soft);
  color: var(--accent);
  border-radius: 6px;
  padding: 3px 8px;
  white-space: nowrap;
}
.icon-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  width: 36px;
  height: 36px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
}
.icon-button:hover {
  background: var(--hover);
  color: var(--text);
}
.small {
  padding: 6px 12px;
  font-size: 13px;
}
.mobile-menu {
  display: none;
}
.chat-view {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}
.scroll-area {
  overflow: auto;
  flex: 1;
  scroll-behavior: smooth;
}
.conversation {
  max-width: 820px;
  min-height: 100%;
  margin: auto;
  padding: 26px 26px 40px;
  display: flex;
  flex-direction: column;
  gap: 28px;
}
.welcome {
  margin: auto 0;
  text-align: center;
  padding: 12px 0 34px;
}
.welcome-art {
  width: 91px;
  height: 105px;
  object-fit: contain;
  margin-bottom: 15px;
  filter: drop-shadow(0 8px 28px #0dbf9a22);
}
.eyebrow {
  color: var(--accent);
  font-size: 13px;
  margin: 0 0 8px;
}
.welcome h1 {
  font-size: clamp(25px, 3vw, 36px);
  font-weight: 500;
  line-height: 1.8;
  letter-spacing: -1px;
  margin: 0 0 8px;
}
.welcome h1 strong {
  color: var(--accent);
  font-weight: 500;
}
.welcome > p:last-of-type {
  color: var(--muted);
  font-size: 15px;
  margin: 0 0 30px;
}
.suggestions {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 11px;
  text-align: right;
  margin-top: 34px;
}
.suggestion {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 8px;
  border: 1px solid var(--line);
  background: transparent;
  padding: 16px;
  border-radius: 13px;
  text-align: right;
  min-height: 133px;
}
.suggestion:hover {
  background: var(--panel);
  border-color: #52776c;
  transform: translateY(-2px);
}
.suggestion svg {
  color: var(--accent);
  margin-bottom: 5px;
}
.suggestion strong {
  font-size: 14px;
  font-weight: 500;
}
.suggestion small {
  font-size: 12px;
  color: var(--muted);
  line-height: 1.8;
}
.message {
  display: flex;
  gap: 14px;
  max-width: 100%;
  min-width: 0;
}
.message.user {
  align-self: flex-start;
  margin-right: auto;
  max-width: 90%;
}
.message.user .bubble {
  background: var(--hover);
  padding: 13px 20px;
  border-radius: 16px 16px 16px 3px;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.message.assistant > img {
  width: 30px;
  height: 37px;
  object-fit: contain;
  flex-shrink: 0;
  margin-top: 4px;
}
.message-body {
  flex: 1;
  min-width: 0;
}
.message-meta {
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 10px;
  display: flex;
  gap: 12px;
}
.bubble {
  font-size: 16px;
  line-height: 2;
  overflow-wrap: anywhere;
}
.bubble p {
  margin: 0 0 14px;
}
.bubble h2,
.bubble h3 {
  font-size: 19px;
  margin: 18px 0 9px;
}
.bubble ul,
.bubble ol {
  padding-right: 24px;
}
.bubble code {
  font:
    14px/1.7 ui-monospace,
    monospace;
  direction: ltr;
  unicode-bidi: isolate;
  background: var(--hover);
  padding: 2px 5px;
  border-radius: 4px;
}
.code-block {
  margin: 16px 0;
  max-width: 100%;
  border: 1px solid var(--line);
  border-radius: 12px;
  overflow: hidden;
  background: var(--side);
}
.code-head {
  padding: 6px 13px;
  display: flex;
  justify-content: space-between;
  direction: ltr;
  background: var(--panel);
  font: 12px/2 system-ui;
}
.code-head button {
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 12px;
}
.code-block pre {
  margin: 0;
  padding: 16px;
  overflow: auto;
  text-align: left;
  direction: ltr;
  white-space: pre;
}
.code-block code {
  background: transparent;
  padding: 0;
}
.message-images {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin: 6px 0 12px;
}
.message-images img {
  max-width: 240px;
  max-height: 180px;
  object-fit: cover;
  border-radius: 10px;
}
.copy-answer {
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 12px;
  padding: 0;
  margin-top: 8px;
}
.pending:after {
  content: "●";
  display: inline-block;
  color: var(--accent);
  font-size: 12px;
  animation: pulse 1s infinite;
}
@keyframes pulse {
  50% {
    opacity: 0.2;
  }
}
.composer-wrap {
  width: 100%;
  max-width: 820px;
  margin: 0 auto;
  padding: 0 26px 10px;
}
.composer {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 19px;
  padding: 9px 15px 11px;
  box-shadow: 0 5px 30px #0000000d;
}
.composer:focus-within {
  border-color: #4e7c71;
}
.composer textarea {
  resize: none;
  border: 0;
  padding: 8px 2px;
  background: transparent;
  max-height: 180px;
  font-size: 16px;
}
.composer textarea:focus {
  outline: 0;
}
.composer textarea::placeholder {
  color: var(--muted);
}
.composer-bottom {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
.composer-hint {
  font-size: 12px;
  color: var(--muted);
}
.send-button {
  width: 38px;
  height: 38px;
  background: var(--accent);
  color: var(--ink);
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 11px;
}
.notice {
  font-size: 12px;
  text-align: center;
  color: var(--muted);
  margin: 10px 0 0;
}
.chat-tools {
  display: flex;
  gap: 16px;
  margin-bottom: 8px;
}
.chat-tools button {
  background: transparent;
  border: 0;
  font-size: 12px;
  color: var(--muted);
}
.danger-text {
  color: var(--error) !important;
}
.attachments {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.attachment {
  position: relative;
}
.attachment img {
  width: 68px;
  height: 60px;
  object-fit: cover;
  border-radius: 8px;
}
.attachment button {
  position: absolute;
  top: 0;
  left: 0;
  background: var(--side);
  border: 0;
  border-radius: 4px;
  color: var(--text);
  line-height: 1;
}
.toast {
  position: fixed;
  bottom: 24px;
  left: 24px;
  z-index: 20;
  background: var(--text);
  color: var(--bg);
  padding: 13px 20px;
  max-width: min(90vw, 440px);
  border-radius: 12px;
  box-shadow: var(--shadow);
  font-size: 14px;
}
dialog {
  color: var(--text);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 30px;
  width: min(460px, calc(100vw - 30px));
  max-height: 90dvh;
  box-shadow: var(--shadow);
}
dialog::backdrop {
  background: #0009;
  backdrop-filter: blur(5px);
}
.dialog-close {
  position: absolute;
  left: 12px;
  top: 12px;
}
dialog h2 {
  font-size: 23px;
  margin: 4px 0 10px;
}
dialog p {
  font-size: 14px;
  color: var(--muted);
}
.stack {
  display: grid;
  gap: 17px;
}
.stack label {
  display: grid;
  gap: 6px;
  font-size: 14px;
}
.stack .check-label {
  display: flex;
  align-items: center;
  gap: 9px;
}
.stack button.primary {
  margin-top: 4px;
}
.form-error,
.error {
  color: var(--error);
  font-size: 14px;
}
.text-button {
  border: 0;
  background: transparent;
  color: var(--accent);
  font-size: 14px;
  text-align: center;
  padding: 8px;
}
.dialog-logo {
  width: 45px;
  height: 55px;
  object-fit: contain;
}
.admin-view {
  overflow: auto;
  padding: 24px 36px 50px;
}
.admin-heading {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}
.admin-heading h1 {
  font-size: 28px;
  margin: 0;
}
.admin-heading p {
  color: var(--muted);
  font-size: 14px;
  margin: 6px 0 24px;
}
.stat-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
  margin: 12px 0 28px;
}
.stat {
  background: var(--panel);
  border: 1px solid var(--line);
  padding: 18px;
  border-radius: 13px;
}
.stat strong {
  display: block;
  font: 500 29px/1.6 Vazirmatn;
  color: var(--accent);
}
.stat span {
  font-size: 13px;
  color: var(--muted);
}
.admin-tabs {
  display: flex;
  gap: 6px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 24px;
  overflow: auto;
}
.admin-tabs button {
  border: 0;
  background: transparent;
  color: var(--muted);
  padding: 12px 17px;
  white-space: nowrap;
  font-size: 14px;
  border-bottom: 2px solid transparent;
}
.admin-tabs button.active {
  color: var(--accent);
  border-color: var(--accent);
}
.panel {
  padding: 22px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px;
  margin-bottom: 15px;
}
.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 20px;
}
.panel h2 {
  font-size: 18px;
  margin: 0;
}
.table-wrap {
  overflow: auto;
}
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
  text-align: right;
}
th {
  color: var(--muted);
  font-weight: 400;
  font-size: 12px;
}
td,
th {
  padding: 13px 10px;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}
td small {
  display: block;
  color: var(--muted);
  direction: ltr;
  text-align: right;
  font-size: 12px;
}
.provider-list {
  display: grid;
  gap: 13px;
}
.provider-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 15px;
}
.provider-row small {
  display: block;
  color: var(--muted);
  font-size: 12px;
  overflow-wrap: anywhere;
}
.muted {
  color: var(--muted);
  font-size: 14px;
}
.settings-form {
  max-width: 640px;
}
.settings-form textarea {
  min-height: 140px;
}
.install-page {
  display: grid;
  place-items: center;
  min-height: 100dvh;
  padding: 28px 15px;
}
.install-card {
  width: 100%;
  max-width: 520px;
  padding: 32px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 20px;
}
.install-logo {
  width: 60px;
  height: 70px;
  object-fit: contain;
}
.install-card h1 {
  font-size: 25px;
}
.install-card p {
  color: var(--muted);
  font-size: 14px;
}
.requirements {
  padding: 16px 25px;
  border: 1px solid var(--line);
  border-radius: 10px;
  font-size: 13px;
}
.backdrop {
  display: none;
}
.two-col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 15px;
}
@media (min-width: 1500px) {
  .conversation,
  .composer-wrap {
    max-width: 900px;
  }
  .welcome h1 {
    font-size: 40px;
  }
}
@media (max-width: 1100px) {
  .sidebar {
    width: 240px;
    flex-basis: 240px;
    padding: 25px 16px 16px;
  }
  .suggestions {
    grid-template-columns: repeat(2, 1fr);
  }
  .suggestion {
    min-height: 105px;
    gap: 3px;
  }
  .welcome {
    padding-bottom: 10px;
  }
  .stat-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}
@media (max-width: 760px) {
  .sidebar {
    position: fixed;
    inset: 0 0 0 auto;
    z-index: 10;
    transform: translateX(105%);
    transition: transform 0.2s;
    width: 280px;
  }
  .sidebar.open {
    transform: none;
  }
  .backdrop:not([hidden]) {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 9;
    background: #0008;
    border: 0;
  }
  .mobile-menu {
    display: flex;
  }
  .topbar {
    padding: 12px 14px;
  }
  .model-label {
    display: none;
  }
  .model-control select {
    max-width: 145px;
    font-size: 14px;
  }
  .header-group {
    gap: 5px;
  }
  .badge {
    display: none;
  }
  .conversation {
    padding: 15px 18px 28px;
  }
  .welcome-art {
    width: 62px;
    height: 74px;
    margin-bottom: 8px;
  }
  .welcome h1 {
    font-size: 26px;
  }
  .welcome > p:last-of-type {
    font-size: 14px;
    margin-bottom: 20px;
  }
  .suggestions {
    gap: 8px;
    margin-top: 23px;
  }
  .suggestion {
    padding: 12px;
    min-height: 100px;
  }
  .composer-wrap {
    padding: 0 12px 8px;
  }
  .composer-hint {
    font-size: 10px;
  }
  .notice {
    font-size: 11px;
  }
  .message.user {
    max-width: 95%;
  }
  .message-images img {
    max-width: 180px;
  }
  .message {
    gap: 9px;
  }
  .bubble {
    font-size: 15px;
  }
  .admin-view {
    padding: 20px 16px;
  }
  .admin-heading h1 {
    font-size: 23px;
  }
  .panel {
    padding: 15px;
  }
  .stat-grid {
    gap: 9px;
  }
  .stat {
    padding: 14px;
  }
  .two-col {
    grid-template-columns: 1fr;
  }
  .chat-tools {
    gap: 12px;
  }
  .toast {
    left: 15px;
    bottom: 15px;
  }
  .model-control {
    gap: 0;
  }
}
@media (prefers-reduced-motion: reduce) {
  * {
    scroll-behavior: auto !important;
    animation: none !important;
    transition: none !important;
  }
}

.md-paragraph {
  margin-bottom: 14px;
}
.bubble:empty {
  min-height: 22px;
}

.small,
.model-label,
.chat-tools button,
.copy-answer,
.code-head button {
  font-size: 14px;
}
@media (max-width: 760px) {
  .composer-hint,
  .notice {
    font-size: 12px;
  }
  .composer-hint {
    max-width: 190px;
  }
}
/* Product panels extend the existing teal identity. */
.model-picker-trigger {
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--panel);
  padding: 7px 14px;
  display: flex;
  align-items: center;
  gap: 16px;
  font-size: 15px;
  color: var(--text);
  max-width: 280px;
}
.model-picker-trigger span {
  color: var(--accent);
}
.picker-list {
  display: grid;
  gap: 6px;
  max-height: 58dvh;
  overflow: auto;
  margin-top: 20px;
}
.picker-option {
  display: flex;
  gap: 12px;
  width: 100%;
  text-align: right;
  background: transparent;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 14px;
}
.picker-option[aria-checked="true"] {
  border-color: var(--accent);
  background: var(--accent-soft);
}
.picker-option:hover:not(:disabled) {
  background: var(--hover);
}
.picker-option strong {
  font-size: 16px;
}
.picker-option small {
  display: block;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.8;
}
.picker-check {
  color: var(--accent);
}
.picker-badges {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 7px;
  font-size: 12px;
  color: var(--accent);
}
.stop-button {
  font-size: 14px;
  padding: 6px 12px;
  border-color: var(--accent);
  color: var(--accent);
}
.revision-button {
  margin-inline-start: 15px;
}
.message.user .revision-button {
  display: block;
  margin-inline-start: 0;
  margin-top: 9px;
}
.stopped-label {
  color: var(--accent);
}
.chat-tools {
  flex-wrap: wrap;
  row-gap: 5px;
}
.prompt-layer {
  border-right: 2px solid var(--accent);
  padding: 8px 14px;
  margin: 16px 0;
}
.prompt-layer p {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.char-counter {
  display: block;
  text-align: left;
  color: var(--muted);
  font-size: 12px;
}
.policy-note {
  border-right: 3px solid var(--accent);
  background: var(--accent-soft);
  padding: 12px 16px;
  font-size: 14px;
}
.preset-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--line);
  padding: 14px 0;
  gap: 16px;
}
.preset-row small {
  display: block;
  color: var(--muted);
  font-size: 13px;
}
#settingsDrawer {
  position: fixed;
  inset: 0 auto 0 0;
  margin: 0;
  width: min(680px, 95vw);
  max-width: none;
  height: 100dvh;
  max-height: 100dvh;
  border-radius: 0 22px 22px 0;
  padding: 0;
  overflow: auto;
  animation: drawer-enter 0.2s ease-out;
}
#settingsDrawer::backdrop {
  background: #0009;
  backdrop-filter: blur(3px);
}
.settings-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 20px;
  padding: 28px 30px 20px;
  border-bottom: 1px solid var(--line);
}
.settings-header h2 {
  font-size: 24px;
  margin: 4px 0;
}
.settings-header .eyebrow {
  font-size: 12px;
}
#settingsTabs {
  display: flex;
  gap: 2px;
  overflow: auto;
  padding: 0 22px;
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  background: var(--panel);
  z-index: 1;
}
#settingsTabs button {
  border: 0;
  border-bottom: 2px solid transparent;
  background: transparent;
  white-space: nowrap;
  padding: 16px 10px;
  font-size: 14px;
  color: var(--muted);
}
#settingsTabs button[aria-selected="true"] {
  color: var(--accent);
  border-color: var(--accent);
}
#settingsBody {
  padding: 25px 30px 40px;
  animation: content-enter 0.15s ease-out;
}
#settingsBody h3 {
  font-size: 20px;
  margin: 0 0 12px;
}
#settingsBody .stack {
  margin-top: 24px;
}
#settingsBody textarea {
  resize: vertical;
  min-height: 120px;
  line-height: 1.9;
}
.settings-divider {
  font-size: 14px;
  color: var(--muted);
  border-top: 1px solid var(--line);
  padding-top: 18px;
  margin-top: 15px;
}
.settings-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 24px;
}
.appearance-sample {
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: 12px;
  line-height: 2;
}
.usage-detail {
  padding: 24px 0;
}
.usage-detail strong {
  font-size: 32px;
  font-weight: 500;
}
.usage-detail small {
  font-size: 16px;
  color: var(--muted);
}
.usage-detail progress {
  display: block;
  width: 100%;
  height: 7px;
  accent-color: var(--accent);
  margin-top: 16px;
}
.usage-facts {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  font-size: 14px;
}
.usage-facts dt {
  color: var(--muted);
}
.usage-facts dd {
  margin: 0;
}
.toast {
  animation: content-enter 0.15s ease-out;
}
:root[data-font="90"] .bubble,
:root[data-font="90"] #prompt {
  font-size: 15px;
}
:root[data-font="110"] .bubble,
:root[data-font="110"] #prompt {
  font-size: 18px;
}
:root[data-font="120"] .bubble,
:root[data-font="120"] #prompt {
  font-size: 20px;
}
:root[data-density="compact"] .conversation {
  gap: 15px;
}
:root[data-density="compact"] .history-item {
  padding-block: 6px;
}
:root[data-density="compact"] .bubble {
  line-height: 1.7;
}
@keyframes drawer-enter {
  from {
    transform: translateX(-24px);
    opacity: 0;
  }
  to {
    transform: none;
    opacity: 1;
  }
}
@keyframes content-enter {
  from {
    opacity: 0.4;
    transform: translateY(4px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}
@media (max-width: 760px) {
  #settingsDrawer {
    inset: auto 0 0 0;
    width: 100vw;
    height: 94dvh;
    border-radius: 20px 20px 0 0;
    animation: content-enter 0.2s ease-out;
  }
  .settings-header {
    padding: 20px;
  }
  .settings-header h2 {
    font-size: 21px;
  }
  #settingsBody {
    padding: 20px;
  }
  #settingsTabs {
    padding: 0 10px;
  }
  .model-picker-trigger {
    max-width: 180px;
    font-size: 14px;
    padding: 6px 9px;
    gap: 8px;
  }
  .model-label {
    display: none;
  }
  .composer-hint {
    display: none;
  }
  .chat-tools button {
    font-size: 13px;
  }
}
@media (prefers-reduced-motion: reduce) {
  #settingsDrawer,
  #settingsBody,
  .toast {
    animation: none !important;
  }
}
/* Operational workbench: calm navigation, readable diagnostics, shared account rhythm. */
.admin-workbench {
  display: grid;
  grid-template-columns: 190px minmax(0, 1fr);
  gap: 24px;
  align-items: start;
}
.admin-workbench .admin-tabs {
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 20px;
  border: 0;
  gap: 5px;
  margin: 0;
  padding: 8px;
  background: var(--panel);
  border-radius: 16px;
}
.admin-workbench .admin-tabs button {
  text-align: right;
  border: 0;
  border-radius: 10px;
  padding: 12px;
  font-size: 14px;
  transition:
    background 0.18s,
    color 0.18s;
}
.admin-workbench .admin-tabs button.active {
  background: rgba(21, 184, 166, 0.14);
  color: var(--accent);
}
#adminPanel {
  min-width: 0;
  animation: settingsContent 0.18s ease-out;
}
.dashboard-columns {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px;
}
.metric-row,
.health-provider,
.user-activity {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 0;
  border-bottom: 1px solid var(--line);
}
.health-provider {
  flex-wrap: wrap;
}
.health-provider h3 {
  margin: 0 0 6px;
}
.health-tests {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.empty-note {
  padding: 24px 0;
  color: var(--muted);
  line-height: 1.9;
}
.activity-chart {
  height: 190px;
  display: flex;
  gap: 16px;
  align-items: stretch;
  direction: ltr;
  margin-top: 24px;
}
.activity-day {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  min-width: 0;
}
.activity-track {
  height: 125px;
  width: 100%;
  max-width: 42px;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  background: rgba(21, 184, 166, 0.035);
  border-radius: 6px;
  overflow: hidden;
}
.activity-success {
  background: #15b8a6;
}
.activity-error {
  background: #df727c;
}
.activity-day small {
  font-size: 13px;
  color: var(--muted);
}
.log-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: end;
  margin: 20px 0;
}
.log-filters label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 14px;
  flex: 1;
  min-width: 125px;
}
.log-filters input,
.log-filters select {
  width: 100%;
}
.pagination {
  display: flex;
  gap: 12px;
  align-items: center;
  justify-content: space-between;
  margin-top: 20px;
  font-size: 14px;
}
.status-pill {
  display: inline-block;
  padding: 4px 9px;
  border-radius: 7px;
  font-size: 14px;
  line-height: 1.7;
}
.status-success {
  color: #15b8a6;
  background: rgba(21, 184, 166, 0.09);
}
.status-error {
  color: #db6877;
  background: rgba(219, 104, 119, 0.09);
}
.status-stopped {
  color: var(--muted);
  background: var(--panel);
}
.diagnostic-result {
  margin-top: 20px;
  border: 1px solid var(--line);
  border-inline-start: 3px solid #df727c;
  border-radius: 12px;
  padding: 20px;
  line-height: 1.9;
}
.diagnostic-result.result-ok {
  border-inline-start-color: #15b8a6;
}
.diagnostic-result strong {
  font-size: 18px;
}
.diagnostic-facts {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 10px 20px;
  font-size: 14px;
}
.diagnostic-facts dd {
  margin: 0;
  text-align: end;
  overflow-wrap: anywhere;
}
.diagnostic-facts dt {
  color: var(--muted);
}
.loading-line {
  color: var(--muted);
  padding: 20px 0;
  animation: diagnosticPulse 1.2s ease-in-out infinite;
}
.account-intro {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 24px;
}
.account-intro h3,
.account-intro p {
  margin: 0;
}
.account-intro p {
  font-size: 14px;
  overflow-wrap: anywhere;
}
.account-quota {
  padding: 24px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: rgba(21, 184, 166, 0.04);
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.account-quota > strong {
  font-size: 32px;
  color: #15b8a6;
}
.account-quota small {
  font-size: 16px;
  color: var(--muted);
}
.account-quota progress {
  width: 100%;
}
.account-shortcuts {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin: 20px 0;
}
.user-activity small {
  display: block;
  color: var(--muted);
  margin-top: 6px;
  font-size: 13px;
}
@keyframes diagnosticPulse {
  50% {
    opacity: 0.5;
  }
}
@media (max-width: 900px) {
  .admin-workbench {
    display: block;
  }
  .admin-workbench .admin-tabs {
    position: static;
    flex-direction: row;
    overflow: auto;
    margin-bottom: 20px;
    white-space: nowrap;
  }
  .admin-workbench .admin-tabs button {
    flex-shrink: 0;
  }
  .dashboard-columns {
    grid-template-columns: 1fr;
  }
  .activity-chart {
    gap: 8px;
  }
  .diagnostic-facts {
    gap: 8px;
  }
  .user-activity {
    align-items: flex-start;
    flex-wrap: wrap;
  }
  .pagination {
    flex-wrap: wrap;
  }
}
@media (prefers-reduced-motion: reduce) {
  .loading-line,
  #adminPanel {
    animation: none;
  }
}
/* Conversation controls and language-aware message layout. */
.conversation-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  width: min(100%, 900px);
  margin: 0 auto;
  padding: 14px 26px;
  border-bottom: 1px solid var(--line);
  flex-shrink: 0;
  position: relative;
  z-index: 4;
}
.conversation-heading {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.conversation-kicker {
  font-size: 12px;
  color: var(--muted);
}
.conversation-heading strong {
  font-size: 15px;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  display: block;
  max-width: 55vw;
}
.conversation-actions,
.message-actions {
  display: flex;
  align-items: center;
  gap: 4px;
}
.tool-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  padding: 8px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  flex-shrink: 0;
  transition:
    background 0.15s,
    color 0.15s,
    transform 0.15s;
}
.tool-button:hover {
  background: var(--hover);
  color: var(--text);
}
.tool-button:active {
  transform: scale(0.94);
}
.tool-button:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
.tool-button:disabled,
.tool-button[aria-disabled="true"] {
  opacity: 0.4;
  cursor: not-allowed;
}
.tool-button .icon {
  width: 19px;
  height: 19px;
}
.tool-button[aria-pressed="true"],
.tool-button.has-instruction {
  color: var(--accent);
  background: var(--accent-soft);
}
.chat-menu {
  position: relative;
}
.chat-menu > summary {
  list-style: none;
}
.chat-menu > summary::-webkit-details-marker {
  display: none;
}
.chat-menu[open] > summary {
  background: var(--hover);
  color: var(--text);
}
.chat-menu-panel {
  position: absolute;
  inset-inline-end: 0;
  top: calc(100% + 9px);
  width: 225px;
  padding: 8px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  gap: 3px;
  animation: settingsContent 0.14s ease-out;
}
.chat-menu-panel button {
  display: flex;
  gap: 12px;
  align-items: center;
  width: 100%;
  border: 0;
  background: transparent;
  border-radius: 8px;
  color: var(--text);
  padding: 10px 12px;
  font-size: 14px;
  text-align: start;
}
.chat-menu-panel button:hover {
  background: var(--hover);
}
.chat-menu-panel .danger-text {
  color: var(--error);
}
.menu-caption {
  font-size: 12px;
  color: var(--muted);
  padding: 5px 12px 8px;
}
.menu-divider {
  height: 1px;
  background: var(--line);
  margin: 5px;
}
.chat-menu-panel .icon {
  width: 18px;
  height: 18px;
}
.message[data-direction="rtl"] {
  direction: rtl;
  text-align: right;
}
.message[data-direction="ltr"] {
  direction: ltr;
  text-align: left;
}
.message.user[data-direction="rtl"] {
  margin-right: 0;
  margin-left: auto;
  align-self: flex-start;
}
.message.user[data-direction="ltr"] {
  margin-left: 0;
  margin-right: auto;
  align-self: flex-end;
}
.message.user {
  max-width: 85%;
}
.user-content {
  min-width: 0;
}
.message.user[data-direction="rtl"] .bubble {
  border-radius: 18px 18px 4px 18px;
}
.message.user[data-direction="ltr"] .bubble {
  border-radius: 18px 18px 18px 4px;
}
.message-actions {
  margin-top: 7px;
  min-height: 36px;
}
.message .message-actions .tool-button {
  margin: 0;
  display: inline-flex;
  padding: 8px;
  font-size: 14px;
}
.message .bubble {
  text-align: start;
  overflow-wrap: anywhere;
}
.message .md-paragraph {
  unicode-bidi: plaintext;
  text-align: start;
}
.message .md-paragraph[dir="rtl"] {
  direction: rtl;
}
.message .md-paragraph[dir="ltr"] {
  direction: ltr;
}
.message pre,
.message code,
.code-block {
  direction: ltr;
  text-align: left;
  unicode-bidi: isolate;
}
.message-meta {
  align-items: center;
  gap: 10px;
}
.message-meta bdi:first-child {
  font-size: 14px;
  color: var(--text);
}
.code-head .tool-button {
  margin: 0;
  width: 32px;
  height: 32px;
  padding: 6px;
}
.code-head .tool-button .icon {
  width: 17px;
  height: 17px;
}
@media (hover: hover) {
  .message-actions {
    opacity: 0.55;
    transition: opacity 0.15s;
  }
  .message:hover .message-actions,
  .message:focus-within .message-actions {
    opacity: 1;
  }
}
@media (max-width: 640px) {
  .conversation-bar {
    padding: 10px 16px;
    gap: 8px;
  }
  .conversation-kicker {
    display: none;
  }
  .conversation-heading strong {
    font-size: 14px;
    max-width: 48vw;
  }
  .conversation-actions .tool-button {
    width: 40px;
    height: 40px;
  }
  .message.user {
    max-width: 94%;
  }
  .message-actions .tool-button {
    width: 40px;
    height: 40px;
  }
  .message {
    gap: 10px;
  }
  .chat-menu-panel {
    width: 215px;
  }
  .conversation {
    padding-top: 24px;
  }
}
@media (prefers-reduced-motion: reduce) {
  .tool-button,
  .message-actions {
    transition: none;
  }
  .chat-menu-panel {
    animation: none;
  }
}
/* Auth forms: visible field guidance, stable pending state and touch targets. */
.auth-heading {
  text-align: center;
}
.auth-heading .dialog-logo {
  margin: 0 auto 12px;
}
.auth-heading h2 {
  margin: 0;
}
.auth-heading p {
  margin: 8px 0 20px;
  color: var(--muted);
}
.auth-switch {
  display: flex;
  padding: 4px;
  gap: 4px;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 12px;
  margin-bottom: 24px;
}
.auth-switch button {
  flex: 1;
  padding: 9px 14px;
  border: 0;
  background: transparent;
  border-radius: 9px;
  color: var(--muted);
  font-size: 15px;
}
.auth-switch button[aria-pressed="true"] {
  background: var(--accent-soft);
  color: var(--accent);
}
#authForm {
  gap: 7px;
}
#authForm > label {
  margin-top: 10px;
  font-size: 14px;
}
#authForm > input {
  width: 100%;
}
#authForm .field-error {
  color: var(--error);
  font-size: 13px;
  line-height: 1.7;
}
#authForm .field-error:empty,
#authForm .form-error:empty {
  display: none;
}
#authForm [aria-invalid="true"] {
  border-color: var(--error);
}
#authForm .form-error {
  margin: 10px 0;
  padding: 10px 12px;
  background: color-mix(in srgb, var(--error) 8%, transparent);
  border-radius: 9px;
}
#authForm .auth-submit {
  width: 100%;
  min-height: 46px;
  margin-top: 18px;
}
#authForm[aria-busy="true"] {
  opacity: 0.8;
}
.password-field {
  position: relative;
  display: flex;
  align-items: center;
}
.password-field input {
  width: 100%;
  padding-left: 12px;
  padding-right: 50px;
}
.password-field .password-toggle {
  position: absolute;
  right: 4px;
  width: 40px;
  height: 40px;
}
#forgotPassword {
  display: block;
  margin: 18px auto 0;
  min-height: 40px;
}
.auth-switch button:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* WebView and on-screen keyboard viewport; no fixed minimum blocking composer. */
.app-shell { height: 100vh; height: var(--app-height, 100dvh); min-height: 0;
  padding-top: env(safe-area-inset-top, 0px);
  padding-right: env(safe-area-inset-right, 0px);
  padding-left: env(safe-area-inset-left, 0px);
  padding-bottom: env(safe-area-inset-bottom, 0px); }
#settingsDrawer { height: var(--app-height, 100dvh); max-height: var(--app-height, 100dvh);
  padding-bottom: env(safe-area-inset-bottom, 0px); padding-top: env(safe-area-inset-top, 0px); }
dialog { max-height: calc(var(--app-height, 100vh) - 24px); overflow-y: auto; }
.scroll-area, .settings-body { overscroll-behavior-y: contain; }
.export-text { width: 100%; min-height: 160px; max-height: 35vh; resize: vertical; user-select: text; }
.export-actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 16px; }
@media (max-width: 760px) {
  input, select, textarea { font-size: 16px; }
  .sidebar { padding-top: max(20px, env(safe-area-inset-top)); padding-bottom: max(16px, env(safe-area-inset-bottom)); }
  .composer-wrap { padding-bottom: 8px; }
}
@media (max-height: 480px) and (max-width: 760px) {
  .notice, .composer-hint, .conversation-kicker { display: none; }
  .topbar { min-height: 48px; padding-top: 4px; padding-bottom: 4px; }
}

/* Immediate thumbnail and real upload progress. */
.attachments { gap: 14px; padding: 6px 2px; }
.attachments:empty { padding: 0; }
.attachment { width: 86px; height: 86px; flex-shrink: 0; }
.attachment img { display: block; width: 100%; height: 100%; border-radius: 14px; border: 1px solid var(--line); }
.attachment button { z-index: 2; top: -6px; right: -6px; left: auto; width: 28px; height: 28px; display: grid; place-items: center; border-radius: 50%; border: 1px solid var(--line); font-size: 21px; box-shadow: 0 2px 8px #0003; }
.attachment button:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.upload-overlay { position: absolute; inset: 0; border-radius: 14px; background: #0008; display: flex; align-items: center; justify-content: center; flex-direction: column; gap: 2px; color: #fff; pointer-events: none; }
.upload-ring { width: 48px; height: 48px; border-radius: 50%; background: conic-gradient(var(--accent) var(--progress), #ffffff40 0); display: grid; place-items: center; direction: ltr; }
.upload-ring span { display: grid; place-items: center; width: 41px; height: 41px; border-radius: 50%; background: #172426; color: white; font-size: 12px; }
.upload-overlay small { font-size: 10px; line-height: 1.2; }
.project-heading { display:flex; align-items:center; gap:12px; flex-wrap:wrap; }
.project-list { display:grid; gap:10px; margin-top:18px; }
.project-tile { text-align:right; padding:16px; background:var(--side); color:var(--text); border:1px solid var(--line); border-radius:12px; }
.project-tile small, .project-file small { display:block; color:var(--muted); font-size:12px; }
.project-controls { display:flex; flex-wrap:wrap; gap:8px; margin:16px 0; }
.project-file { display:flex; align-items:center; justify-content:space-between; gap:8px; border-bottom:1px solid var(--line); padding:10px 0; overflow-wrap:anywhere; }
.project-upload { display:block; padding:16px; border:1px dashed var(--accent); border-radius:12px; }
.project-upload input { display:block; width:100%; margin-top:8px; }
.project-banner { padding:8px 24px; background:var(--accent-soft); color:var(--accent); font-size:13px; }
#modal:has(.project-heading), #modal:has(#subscriptionForm) { width:min(740px,calc(100vw - 24px)); }

/* SVG progress stays mounted so upload events do not restart the animation. */
.upload-ring { position:relative; width:52px; height:52px; background:none; }
.upload-ring svg { position:absolute; inset:0; width:52px; height:52px; transform:rotate(-90deg); }
.upload-ring circle { fill:none; stroke-width:3; }
.upload-track { stroke:#ffffff40; }
.upload-arc { stroke:#fff; stroke-linecap:round; transition:stroke-dasharray .18s linear; }
.upload-ring span { width:39px; height:39px; background:#0005; }
.upload-ring.is-waiting svg { animation:upload-spin 1s linear infinite; }
.upload-ring.is-processing svg { animation:upload-breathe .9s ease-in-out infinite alternate; }
@keyframes upload-spin { to { transform:rotate(270deg); } }
@keyframes upload-breathe { to { opacity:.35; } }
@media (prefers-reduced-motion: reduce) { .upload-ring svg { animation:none!important; } .upload-arc { transition:none; } }
#webSearchToggle[aria-pressed="true"] { color:var(--accent); border-color:var(--accent); background:var(--accent-soft); }
