:root {
  --bg: #f4f8fc;
  --ink: #102334;
  --muted: #5b6f82;
  --panel: #ffffff;
  --line: #d8e3ed;
  --primary: #0d6ea8;
  --primary-strong: #075681;
  --accent: #0c8f80;
  --danger: #bc3f3f;
  --warning: #a16810;
  --brand: #0d3553;
  --admin-link: #0e5079;
  --radius: 14px;
  --shadow: 0 18px 40px rgba(16, 35, 52, 0.11);
}

:root[data-theme="dark"] {
  --bg: #0f1825;
  --ink: #e7eef8;
  --muted: #9bb0c8;
  --panel: #172536;
  --line: #2d3f57;
  --primary: #3b88e4;
  --primary-strong: #286fca;
  --accent: #2fae9d;
  --danger: #d26666;
  --warning: #e0af5a;
  --brand: #d9e8fb;
  --admin-link: #c3d9f3;
  --shadow: 0 18px 40px rgba(3, 8, 16, 0.45);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
}

body {
  font-family: "Avenir Next", "Noto Sans SC", "PingFang SC", "Microsoft YaHei", sans-serif;
  color: var(--ink);
  min-height: 100vh;
  background:
    radial-gradient(80rem 55rem at 100% -15%, #bfe8df 0%, rgba(191, 232, 223, 0) 50%),
    radial-gradient(90rem 50rem at -20% 0%, #c9def5 0%, rgba(201, 222, 245, 0) 47%),
    var(--bg);
  position: relative;
}

:root[data-theme="dark"] body {
  background:
    radial-gradient(80rem 55rem at 100% -15%, #1d3444 0%, rgba(29, 52, 68, 0) 50%),
    radial-gradient(90rem 50rem at -20% 0%, #2a2a49 0%, rgba(42, 42, 73, 0) 47%),
    var(--bg);
}

.bg-shape {
  position: fixed;
  pointer-events: none;
  border-radius: 999px;
  filter: blur(40px);
  opacity: 0.5;
}

.bg-shape-1 {
  width: 22rem;
  height: 22rem;
  right: -6rem;
  top: 5rem;
  background: #64b5d6;
}

.bg-shape-2 {
  width: 24rem;
  height: 24rem;
  left: -8rem;
  bottom: -10rem;
  background: #7bc3af;
}

:root[data-theme="dark"] .bg-shape-1 {
  background: #2e4f66;
}

:root[data-theme="dark"] .bg-shape-2 {
  background: #2d5a55;
}

.topbar {
  max-width: 1200px;
  margin: 0 auto;
  padding: 18px 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  position: relative;
  z-index: 2;
}

.brand {
  font-weight: 800;
  letter-spacing: 0.02em;
  color: var(--brand);
}

.topbar-user {
  display: flex;
  gap: 12px;
  align-items: center;
  color: var(--muted);
  font-size: 14px;
}

.admin-link {
  color: var(--admin-link);
  text-decoration: none;
  font-weight: 600;
}

.theme-toggle {
  border: 1px solid var(--line);
  background: color-mix(in srgb, var(--panel) 85%, #ffffff 15%);
  color: var(--ink);
  border-radius: 10px;
  padding: 6px 10px;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.theme-toggle:hover {
  transform: translateY(-1px);
}

.container {
  max-width: 980px;
  margin: 14px auto 48px;
  padding: 0 20px;
  position: relative;
  z-index: 2;
}

.container-wide {
  max-width: 1640px;
}

.hero {
  margin: 8px 0 20px;
}

.title-image-wrap {
  display: flex;
  justify-content: center;
  margin: 2px 0 14px;
}

.title-image {
  display: block;
  width: min(100%, 760px);
  height: auto;
  max-height: 280px;
  object-fit: contain;
}

.hero h1 {
  margin: 0 0 8px;
  font-size: clamp(28px, 3.8vw, 40px);
  line-height: 1.05;
  letter-spacing: -0.01em;
  color: color-mix(in srgb, var(--ink) 88%, #22496d 12%);
}

.hero p {
  margin: 0;
  color: var(--muted);
}

.grid.two {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
}

.panel {
  background: color-mix(in srgb, var(--panel) 92%, #d9e8f5 8%);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
  backdrop-filter: blur(3px);
}

.panel.narrow {
  max-width: 420px;
}

.auth-panel {
  max-width: 520px;
  margin: 0 auto;
}

.panel h2 {
  margin: 0 0 14px;
  font-size: 20px;
  color: color-mix(in srgb, var(--ink) 88%, #22496d 12%);
}

.form {
  display: grid;
  gap: 8px;
}

label {
  font-size: 13px;
  font-weight: 700;
  color: #35516a;
}

input:not([type="checkbox"]):not([type="radio"]) {
  border: 1px solid color-mix(in srgb, var(--line) 90%, #bfd0de 10%);
  background: color-mix(in srgb, var(--panel) 88%, #f9fcff 12%);
  color: var(--ink);
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 14px;
  outline: none;
}

input:not([type="checkbox"]):not([type="radio"]):focus {
  border-color: #5aa7cf;
  box-shadow: 0 0 0 3px rgba(90, 167, 207, 0.2);
}

.btn {
  border: 1px solid color-mix(in srgb, var(--line) 88%, #a9bfce 12%);
  background: color-mix(in srgb, var(--panel) 80%, #edf3f8 20%);
  color: var(--ink);
  border-radius: 10px;
  padding: 10px 14px;
  font-weight: 700;
  cursor: pointer;
  transition: all 160ms ease;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.btn:hover {
  transform: translateY(-1px);
}

.btn-primary {
  background: linear-gradient(135deg, var(--primary), var(--primary-strong));
  color: #fff;
  border-color: #0d5f90;
}

.btn-accent {
  background: linear-gradient(135deg, var(--accent), #0b786c);
  color: #fff;
  border-color: #0b7065;
}

.btn-danger {
  background: var(--danger);
  color: #fff;
  border-color: #a63636;
}

.btn-mini {
  padding: 6px 10px;
  font-size: 12px;
}

.auth-divider {
  display: flex;
  align-items: center;
  margin: 12px 0 10px;
  color: var(--muted);
  font-size: 12px;
}

.auth-divider::before,
.auth-divider::after {
  content: "";
  flex: 1;
  border-top: 1px solid var(--line);
}

.auth-divider span {
  padding: 0 10px;
}

.auth-toggle-btn {
  width: 100%;
}

.auth-register-block {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px dashed var(--line);
}

.inline-check {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--muted);
}

.inline-check input[type="checkbox"] {
  width: 16px;
  height: 16px;
}

.alert {
  border-radius: 10px;
  border: 1px solid;
  padding: 12px 14px;
  margin-bottom: 14px;
  font-weight: 600;
  transition: opacity 180ms ease, transform 180ms ease;
}

.alert.is-dismissing {
  opacity: 0;
  transform: translateY(-4px);
}

.alert-success {
  background: #e8f7f2;
  border-color: #98d1c0;
  color: #105e50;
}

.alert-error {
  background: #fff0f0;
  border-color: #e1a4a4;
  color: #862d2d;
}

.table-wrap {
  width: 100%;
  overflow-x: auto;
}

.admin-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 0 0 12px;
}

.admin-user-list {
  display: grid;
  gap: 12px;
}

.admin-user-card {
  border: 1px solid color-mix(in srgb, var(--line) 86%, #b9cee1 14%);
  border-radius: 12px;
  background: color-mix(in srgb, var(--panel) 90%, #eaf3fd 10%);
  padding: 12px;
}

.admin-user-row {
  display: grid;
  gap: 12px;
}

.admin-user-row + .admin-user-row {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid color-mix(in srgb, var(--line) 85%, #d5e3ef 15%);
}

.admin-user-row-top {
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: start;
}

.admin-user-side {
  display: grid;
  gap: 8px;
  justify-items: end;
  align-content: start;
}

.admin-user-info-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px 14px;
}

.admin-user-meta {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}

.admin-user-key {
  font-size: 12px;
  color: var(--muted);
}

.admin-user-value {
  font-size: 14px;
  font-weight: 600;
  color: var(--ink);
  overflow-wrap: anywhere;
}

.admin-user-status {
  display: flex;
  align-items: flex-start;
}

.admin-user-top-actions {
  display: grid;
  gap: 6px;
  justify-items: stretch;
  width: 132px;
}

.admin-user-top-actions .admin-actions {
  display: grid;
  gap: 6px;
}

.admin-user-top-actions .inline-form {
  margin: 0;
  width: 100%;
}

.admin-user-top-actions .btn {
  width: 100%;
}

.admin-user-settings {
  margin-top: 10px;
}

.admin-user-row-controls {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.admin-control-block {
  border: 1px solid color-mix(in srgb, var(--line) 86%, #c7d9ea 14%);
  border-radius: 10px;
  background: color-mix(in srgb, var(--panel) 93%, #edf5fc 7%);
  padding: 10px;
}

.admin-control-block h3 {
  margin: 0 0 8px;
  font-size: 13px;
  color: color-mix(in srgb, var(--ink) 84%, #3a5a77 16%);
}

.admin-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

table {
  width: 100%;
  min-width: 1220px;
  border-collapse: collapse;
  font-size: 14px;
}

thead th {
  text-align: left;
  background: color-mix(in srgb, var(--panel) 74%, #dceaf7 26%);
  padding: 10px 8px;
  border-bottom: 1px solid var(--line);
  color: color-mix(in srgb, var(--ink) 90%, #21445d 10%);
}

tbody td {
  border-bottom: 1px solid color-mix(in srgb, var(--line) 84%, #e6edf3 16%);
  padding: 9px 8px;
  vertical-align: top;
}

.tag {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 3px 10px;
  font-size: 12px;
  font-weight: 700;
}

.tag-pending {
  background: #fff6e5;
  color: var(--warning);
}

.tag-approved {
  background: #e9f8f4;
  color: #0f6a57;
}

.tag-rejected {
  background: #fff1f1;
  color: #9e3535;
}

.inline-form {
  display: inline-flex;
  margin-right: 6px;
  margin-bottom: 6px;
}

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

.iframe-wrap {
  border: 1px solid var(--line);
  border-radius: 12px;
  overflow: hidden;
  min-height: 620px;
  height: calc(100dvh - 260px);
}

.iframe-wrap iframe {
  width: 100%;
  height: 100%;
  border: 0;
}

.hidden {
  display: none;
}

.usage-reminder-mask {
  position: fixed;
  inset: 0;
  background: rgba(10, 22, 35, 0.42);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 50;
  padding: 16px;
}

.usage-reminder-mask.hidden {
  display: none;
}

.usage-reminder-card {
  width: min(520px, 100%);
  border-radius: 14px;
  border: 1px solid var(--line);
  background: color-mix(in srgb, var(--panel) 94%, #e7f2fb 6%);
  box-shadow: var(--shadow);
  padding: 18px;
}

.usage-reminder-card h3 {
  margin: 0 0 8px;
}

.usage-reminder-card p {
  margin: 0 0 10px;
  color: var(--muted);
}

.usage-reminder-card .inline-form {
  margin-right: 8px;
}

:root[data-theme="dark"] .usage-reminder-mask {
  background: rgba(5, 8, 12, 0.56);
}

:root[data-theme="dark"] .usage-reminder-card {
  border-color: #3f444c;
  background: #2b3138;
}

:root[data-theme="dark"] .usage-reminder-card p {
  color: #bcc4cf;
}

.quota-meta {
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 12px;
}

.quota-form {
  display: grid;
  grid-template-columns: 48px 1fr;
  gap: 6px 8px;
  align-items: center;
  margin-bottom: 8px;
}

.quota-form label {
  font-size: 12px;
}

.quota-form input {
  min-width: 86px;
  padding: 6px 8px;
  font-size: 12px;
}

.quota-form .btn {
  grid-column: 1 / -1;
}

.chat-head-actions {
  margin-bottom: 10px;
}

.chat-test-app {
  display: grid;
  grid-template-columns: 300px minmax(0, 1fr);
  gap: 14px;
  min-height: 640px;
  height: calc(100dvh - 260px);
  border: 1px solid color-mix(in srgb, var(--line) 88%, #c7d8e8 12%);
  border-radius: 14px;
  padding: 10px;
  background: linear-gradient(180deg, #f8fbff, #f2f7fc);
  box-shadow: 0 12px 24px rgba(22, 46, 72, 0.12);
  color: var(--ink);
}

.chat-side {
  border: 1px solid var(--line);
  border-radius: 12px;
  background: linear-gradient(180deg, #f8fbff, #eef4fb);
  padding: 10px;
  display: flex;
  flex-direction: column;
  min-height: 0;
  height: 100%;
}

.chat-side-top {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 12px;
}

.session-list {
  list-style: none;
  margin: 0;
  padding: 0;
  overflow: auto;
  display: grid;
  gap: 8px;
}

.session-list,
.chat-box,
.md-code {
  scrollbar-width: thin;
}

.session-item {
  width: 100%;
  border: 1px solid var(--line);
  background: linear-gradient(180deg, #ffffff, #f3f8fd);
  color: var(--ink);
  border-radius: 10px;
  text-align: left;
  padding: 10px 11px;
  cursor: pointer;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  line-height: 1.35;
  min-height: 50px;
  overflow: hidden;
  text-overflow: ellipsis;
  word-break: break-word;
}

.session-item.active {
  border-color: var(--primary);
  background: color-mix(in srgb, var(--primary) 16%, #f7fbff 84%);
}

.chat-main {
  border: 1px solid var(--line);
  border-radius: 12px;
  background: linear-gradient(180deg, #f7fbff, #edf4fb);
  display: flex;
  flex-direction: column;
  min-height: 0;
  height: 100%;
  overflow: hidden;
}

.quota-bar {
  border-bottom: 1px solid var(--line);
  padding: 10px 12px;
  font-size: 13px;
  color: var(--muted);
  background: linear-gradient(180deg, #f7fbff, #edf4fb);
}

.chat-main .alert {
  margin: 10px 10px 0;
}

.chat-box {
  flex: 1;
  min-height: 0;
  overflow: auto;
  padding: 14px 12px 18px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  align-content: flex-start;
  background: linear-gradient(180deg, #f6faff, #edf4fb);
}

.chat-empty {
  color: var(--muted);
  width: min(760px, 96%);
  margin: auto;
  text-align: center;
  padding: 22px 16px;
  border: 1px dashed color-mix(in srgb, var(--line) 80%, #c6d7e8 20%);
  border-radius: 12px;
  background: color-mix(in srgb, var(--panel) 82%, #ecf4fd 18%);
}

.msg-row {
  display: flex;
  width: 100%;
  justify-content: center;
}

.msg-inner {
  width: min(1260px, 100%);
  display: flex;
  align-items: flex-start;
  gap: 10px;
}

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

.msg-assistant .msg-inner {
  justify-content: flex-start;
}

.msg-avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 1px solid #b3c8de;
  background: #fff;
  color: #2a4e73;
  display: inline-block;
  flex: 0 0 auto;
  margin-top: 2px;
  overflow: hidden;
}

.msg-user .msg-avatar {
  border-color: #8cb2da;
}

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

.msg-content {
  display: flex;
  flex-direction: column;
  min-width: 0;
  max-width: min(1120px, calc(100% - 42px));
}

.msg-user .msg-content {
  align-items: flex-end;
}

.msg-assistant .msg-content {
  align-items: flex-start;
}

.msg-bubble {
  display: inline-block;
  max-width: 100%;
  width: auto;
  border: 1px solid #c6d8ea;
  border-radius: 12px;
  padding: 10px 13px;
  background: #f7fbff;
}

.msg-user .msg-bubble {
  max-width: min(76%, 68ch);
  background: linear-gradient(180deg, #dfeeff, #c9e0fb);
  border-color: #99bee4;
}

.msg-text {
  margin: 0;
  word-break: normal;
  overflow-wrap: anywhere;
  font-size: 14px;
  line-height: 1.58;
  color: var(--ink);
}

.msg-text.msg-plain {
  white-space: pre-wrap;
  word-break: normal;
  overflow-wrap: anywhere;
}

.msg-text.msg-markdown {
  white-space: normal;
}

.msg-thinking {
  margin: 0 0 9px;
  border: 1px dashed #a8c1dd;
  border-radius: 10px;
  background: #edf5ff;
  padding: 6px 8px;
}

.msg-thinking summary {
  cursor: pointer;
  font-size: 12px;
  font-weight: 700;
  color: #2f6ea8;
}

.msg-thinking-body {
  margin-top: 8px;
  white-space: pre-wrap;
  word-break: break-word;
  font-size: 12px;
  line-height: 1.55;
  color: #4a6583;
}

.msg-markdown p,
.msg-markdown ul,
.msg-markdown ol,
.msg-markdown blockquote,
.msg-markdown pre,
.msg-markdown hr,
.msg-markdown .md-table-wrap {
  margin: 0.55em 0;
}

.msg-markdown hr,
.msg-markdown .md-hr {
  border: 0;
  border-top: 1px solid #b8cce2;
}

.msg-markdown h1,
.msg-markdown h2,
.msg-markdown h3,
.msg-markdown h4,
.msg-markdown h5,
.msg-markdown h6 {
  margin: 0.65em 0 0.35em;
  line-height: 1.32;
}

.msg-markdown ul,
.msg-markdown ol {
  padding-left: 1.35em;
}

.msg-markdown a {
  color: color-mix(in srgb, var(--primary) 88%, #3da4ff 12%);
  text-decoration: underline;
}

.msg-markdown blockquote {
  border-left: 3px solid #7ea8d1;
  padding: 4px 10px;
  color: var(--muted);
  background: #edf4fb;
  border-radius: 8px;
}

.md-table-wrap {
  overflow-x: auto;
  border: 1px solid #b8cde2;
  border-radius: 10px;
  background: #f5f9ff;
}

.md-table {
  width: 100%;
  min-width: 360px;
  border-collapse: collapse;
  table-layout: auto;
}

.md-table th,
.md-table td {
  border: 1px solid #b8cde2;
  padding: 8px 10px;
  text-align: left;
  vertical-align: top;
}

.md-table th {
  background: #e8f1fb;
  font-weight: 700;
}

.md-table td {
  background: #fdfefe;
}

.md-code {
  margin: 0;
  border: 1px solid #344154;
  background: #1e1e1e;
  border-radius: 10px;
  padding: 10px 12px;
  overflow: auto;
}

.md-code code {
  font-family: "SFMono-Regular", Menlo, Consolas, "Liberation Mono", monospace;
  font-size: 13px;
  white-space: pre;
  color: #d4d4d4;
}

.md-code-wrap {
  margin: 0.65em 0;
}

.md-mermaid {
  margin: 0.65em 0;
}

.md-mermaid-fallback[hidden] {
  display: none;
}

.md-mermaid-graph {
  overflow-x: auto;
  border: 1px solid #b8cde2;
  border-radius: 10px;
  background: #f8fbff;
  padding: 10px;
}

.md-mermaid-graph svg {
  display: block;
  height: auto;
  max-width: 100%;
}

.md-code-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 6px;
}

.md-code-lang {
  font-size: 12px;
  color: var(--muted);
}

.md-copy-btn {
  border: 1px solid #335b85;
  background: linear-gradient(135deg, #2b6cb6, #1d4f8f);
  color: #f2f8ff;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 700;
  padding: 4px 9px;
  cursor: pointer;
}

.md-copy-btn:hover {
  transform: translateY(-1px);
}

.tok-comment {
  color: #6a9955;
}

.tok-string {
  color: #ce9178;
}

.tok-number {
  color: #b5cea8;
}

.tok-keyword {
  color: #569cd6;
}

.tok-constant {
  color: #4fc1ff;
}

.tok-func {
  color: #dcdcaa;
}

.md-inline-code {
  font-family: "SFMono-Regular", Menlo, Consolas, "Liberation Mono", monospace;
  font-size: 0.92em;
  border: 1px solid #b9cde3;
  background: #eaf3ff;
  color: #27527c;
  border-radius: 6px;
  padding: 1px 7px;
}

.msg-markdown mark {
  background: #5a4a1b;
  color: #ffe9ad;
  border-radius: 4px;
  padding: 0 4px;
}

.chat-input-row {
  border-top: 1px solid var(--line);
  padding: 10px 12px 12px;
  margin-top: auto;
  position: sticky;
  bottom: 0;
  z-index: 4;
  background: linear-gradient(180deg, #f6faff, #edf4fb);
}

.chat-input-wrap {
  position: relative;
  min-height: 72px;
}

.chat-input-row textarea {
  width: 100%;
  resize: none;
  min-height: 72px;
  max-height: 168px;
  border-radius: 14px;
  border: 1px solid color-mix(in srgb, var(--line) 88%, #bfd0de 12%);
  background: color-mix(in srgb, #ffffff 86%, #edf5ff 14%);
  color: var(--ink);
  padding: 12px 54px 12px 12px;
  font-size: 14px;
  outline: none;
  line-height: 1.5;
}

.chat-input-row textarea:focus {
  border-color: #5aa7cf;
  box-shadow: 0 0 0 3px rgba(90, 167, 207, 0.2);
}

.chat-input-row textarea::placeholder {
  color: #73869b;
}

.chat-send-btn {
  position: absolute;
  right: 10px;
  bottom: 17px;
  width: 34px;
  height: 34px;
  border-radius: 999px;
  border: 1px solid #5d8fc2;
  background: linear-gradient(135deg, #5b93ce, #3d6ea9);
  color: #f6fffd;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
  transition: all 120ms ease;
}

.chat-send-btn:hover {
  transform: translateY(-1px);
}

.chat-send-btn.is-stopping {
  border-color: #ad4d4d;
  background: linear-gradient(135deg, #c55a5a, #ab3f3f);
}

.chat-send-glyph {
  line-height: 1;
}

:root[data-theme="dark"] .chat-test-app {
  border-color: #40444a;
  background: linear-gradient(180deg, #2f3339, #2c3036);
}

:root[data-theme="dark"] .admin-user-card {
  border-color: #3f4550;
  background: #2d333c;
}

:root[data-theme="dark"] .admin-user-row + .admin-user-row {
  border-top-color: #404752;
}

:root[data-theme="dark"] .admin-user-key {
  color: #9facbd;
}

:root[data-theme="dark"] .admin-user-value {
  color: #dde6f2;
}

:root[data-theme="dark"] .admin-control-block {
  border-color: #495360;
  background: #333a44;
}

:root[data-theme="dark"] .admin-control-block h3 {
  color: #d2ddea;
}

:root[data-theme="dark"] .chat-side {
  background: linear-gradient(180deg, #2d3239, #2a2e34);
  border-color: #3f444c;
}

:root[data-theme="dark"] .session-item {
  background: linear-gradient(180deg, #363b42, #32373e);
  border-color: #4a4f56;
  color: #d6d9de;
}

:root[data-theme="dark"] .session-item.active {
  background: linear-gradient(180deg, #3b4f68, #33465f);
  border-color: #5b88b8;
}

:root[data-theme="dark"] .chat-main {
  background: linear-gradient(180deg, #2e3238, #2a2e34);
  border-color: #3f444c;
}

:root[data-theme="dark"] .quota-bar {
  color: #adb3bc;
  border-bottom-color: #3f444c;
  background: linear-gradient(180deg, #32363c, #2f3339);
}

:root[data-theme="dark"] .chat-box {
  background: linear-gradient(180deg, #2d3137, #2a2e34);
}

:root[data-theme="dark"] .chat-empty {
  border-color: #4c5158;
  background: #333841;
}

:root[data-theme="dark"] .msg-assistant .msg-bubble {
  background: #333840;
  border-color: #4f555e;
}

:root[data-theme="dark"] .msg-user .msg-bubble {
  background: linear-gradient(180deg, #3d5677, #344c69);
  border-color: #567396;
}

:root[data-theme="dark"] .msg-thinking {
  border-color: #5a6470;
  background: #2f353d;
}

:root[data-theme="dark"] .msg-thinking summary {
  color: #9bbbe0;
}

:root[data-theme="dark"] .msg-thinking-body {
  color: #bdc7d3;
}

:root[data-theme="dark"] .msg-avatar {
  border-color: #4f555d;
  background: #1f2329;
}

:root[data-theme="dark"] .msg-user .msg-avatar {
  border-color: #5d7ea7;
}

:root[data-theme="dark"] .msg-markdown hr,
:root[data-theme="dark"] .msg-markdown .md-hr {
  border-top-color: #59606a;
}

:root[data-theme="dark"] .md-table-wrap {
  border-color: #4f5966;
  background: #30353c;
}

:root[data-theme="dark"] .md-table th,
:root[data-theme="dark"] .md-table td {
  border-color: #4f5966;
}

:root[data-theme="dark"] .md-table th {
  background: #3a414a;
  color: #e1e6ed;
}

:root[data-theme="dark"] .md-table td {
  background: #313740;
  color: #d4dae2;
}

:root[data-theme="dark"] .chat-input-row {
  background: linear-gradient(180deg, #2f3339, #2b2f35);
  border-top-color: #3f444c;
}

:root[data-theme="dark"] .chat-input-row textarea {
  background: #363b44;
  border-color: #4f5a66;
  color: #e4e8ee;
}

:root[data-theme="dark"] .chat-input-row textarea::placeholder {
  color: #8f96a0;
}

:root[data-theme="dark"] .md-copy-btn {
  border-color: #4f6787;
  background: linear-gradient(135deg, #3a5f89, #2d4f76);
}

:root[data-theme="dark"] .md-mermaid-graph {
  border-color: #4f5966;
  background: #313740;
}

:root[data-theme="dark"] .md-inline-code {
  border-color: #5f79a0;
  background: #2d4058;
  color: #ffd98e;
}

:root[data-theme="dark"] .msg-markdown mark {
  background: #5e4e1f;
  color: #ffe9ad;
}

:root[data-theme="dark"] .session-list,
:root[data-theme="dark"] .chat-box,
:root[data-theme="dark"] .md-code {
  scrollbar-color: #56606b #2a2d31;
}

:root[data-theme="dark"] .session-list::-webkit-scrollbar,
:root[data-theme="dark"] .chat-box::-webkit-scrollbar,
:root[data-theme="dark"] .md-code::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}

:root[data-theme="dark"] .session-list::-webkit-scrollbar-track,
:root[data-theme="dark"] .chat-box::-webkit-scrollbar-track,
:root[data-theme="dark"] .md-code::-webkit-scrollbar-track {
  background: #2a2d31;
  border-radius: 999px;
}

:root[data-theme="dark"] .session-list::-webkit-scrollbar-thumb,
:root[data-theme="dark"] .chat-box::-webkit-scrollbar-thumb,
:root[data-theme="dark"] .md-code::-webkit-scrollbar-thumb {
  background: #56606b;
  border-radius: 999px;
  border: 2px solid #2a2d31;
}

:root[data-theme="dark"] .session-list::-webkit-scrollbar-thumb:hover,
:root[data-theme="dark"] .chat-box::-webkit-scrollbar-thumb:hover,
:root[data-theme="dark"] .md-code::-webkit-scrollbar-thumb:hover {
  background: #687380;
}

@media (max-width: 900px) {
  .grid.two {
    grid-template-columns: 1fr;
  }

  .topbar {
    align-items: flex-start;
    flex-direction: column;
    gap: 10px;
  }

  .title-image {
    max-height: 210px;
  }

  .iframe-wrap {
    min-height: 520px;
    height: calc(100dvh - 210px);
  }

  .chat-test-app {
    grid-template-columns: 1fr;
    min-height: 580px;
    height: calc(100dvh - 220px);
    padding: 8px;
  }

  .chat-side {
    min-height: 180px;
    height: auto;
  }

  .admin-user-row-top {
    grid-template-columns: 1fr;
  }

  .admin-user-side {
    justify-items: start;
  }

  .admin-user-top-actions {
    width: 100%;
  }

  .admin-user-info-grid {
    grid-template-columns: 1fr;
  }

  .admin-user-row-controls {
    grid-template-columns: 1fr;
  }

  .chat-box {
    min-height: 0;
  }

  .chat-input-wrap {
    min-height: 72px;
  }

  .chat-input-row textarea {
    min-height: 72px;
    padding-right: 50px;
  }

  .chat-send-btn {
    width: 34px;
    height: 34px;
    bottom: 16px;
  }
}
