@font-face {
  font-family: Inter;
  src: url("/assets/inter-cyrillic.woff2") format("woff2");
  font-weight: 400 700;
  font-display: swap;
  unicode-range: U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116;
}
@font-face {
  font-family: Inter;
  src: url("/assets/inter-latin.woff2") format("woff2");
  font-weight: 400 700;
  font-display: swap;
}
@font-face {
  font-family: "Material Symbols";
  src: url("/assets/symbols.woff2") format("woff2");
  font-display: block;
}
@font-face {
  font-family: "IBM Plex Mono";
  src: url("/assets/ibm-plex-mono.woff2") format("woff2");
  font-display: swap;
}

:root {
  color-scheme: light;
  --canvas: #f7f8fa;
  --paper: #fff;
  --ink: #202936;
  --muted: #606c7d;
  --line: #e8ebf0;
  --control: #dfe4eb;
  --accent: #2962e8;
  --accent-text: #2053cd;
  --selected: #edf3ff;
  --hover: #f3f6fc;
  --safe: #1c6947;
  --danger: #a33838;
  --pending: #815418;
  --margin: 32px;
  --chat-width: 714px;
  --mono: "IBM Plex Mono", ui-monospace, monospace;
  background: var(--canvas);
  color: var(--ink);
  font: 15px/1.55 Inter, -apple-system, system-ui, sans-serif;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body, h1, h2, h3, p { margin: 0; }
a { color: var(--accent-text); }
button, input, select, textarea { font: inherit; color: inherit; }
button, select { cursor: pointer; }
button:disabled { cursor: default; opacity: .5; }
:focus-visible { outline: 3px solid #9bb9ff; outline-offset: 2px; }
code { font: .92em var(--mono); }
.icon { display: inline-block; flex: 0 0 auto; width: 1em; overflow: hidden; white-space: nowrap; font: 20px/1 "Material Symbols"; font-feature-settings: "liga"; }

.shell { display: grid; grid-template-columns: 226px minmax(0, 1fr); height: 100dvh; }
.sidebar { display: flex; flex-direction: column; min-height: 0; gap: 10px; padding: 24px 15px 14px; border-right: 1px solid var(--line); background: var(--paper); }
.brand { display: flex; align-items: center; gap: 9px; margin: 0 4px 17px; font-size: 18px; font-weight: 650; letter-spacing: -.04em; }
.brand > span > span:not(.icon) { color: var(--accent-text); }
.brand-symbol, .avatar { display: inline-grid; flex: 0 0 auto; place-items: center; width: 34px; height: 34px; border-radius: 7px; background: var(--selected); color: var(--accent-text); }
.primary, .secondary, .danger {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px; min-height: 37px; padding: 5px 12px;
  border: 1px solid var(--control); border-radius: 6px; background: var(--paper); color: var(--ink);
  text-decoration: none; font-size: 13px; font-weight: 550;
}
.primary { border-color: var(--accent); background: var(--accent); color: var(--paper); }
.primary:hover:not(:disabled) { background: var(--accent-text); }
.secondary:hover { background: var(--hover); }
.danger { color: var(--danger); }
.sidebar .new-chat { justify-content: flex-start; }
.search { display: flex; align-items: center; gap: 7px; padding: 3px 8px; color: var(--muted); }
.search input { min-width: 0; width: 100%; padding-block: 4px; border: 0; background: none; font-size: 12px; }
.history { min-height: 0; flex: 1; overflow: auto; margin-block: 10px; }
.history h2 { padding: 6px 9px 3px; font-size: 11px; font-weight: 600; color: var(--muted); }
.history button, .setting-link {
  display: flex; align-items: center; gap: 8px; min-height: 38px; padding: 7px 9px;
  border: 0; border-radius: 6px; background: none; color: var(--muted); font-size: 13px; text-align: left;
}
.history button { width: 100%; }
.history button .label { text-overflow: ellipsis; overflow: hidden; white-space: nowrap; }
.history button .icon { font-size: 16px; }
.history button:hover, .setting-link:hover, .icon-button:hover:not(.primary) { background: var(--hover); color: var(--accent-text); }
.history button[aria-current="true"], .setting-link[aria-current="true"] { background: var(--selected); color: var(--accent-text); font-weight: 600; }
.sidebar-bottom { display: grid; gap: 7px; }
.account { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: 7px; border-top: 1px solid var(--line); padding: 9px 3px 2px; }
.account strong, .account small { display: block; overflow: hidden; text-overflow: ellipsis; }
.account strong { font-size: 12px; }
.account small { color: var(--muted); font-size: 11px; }

.workspace { display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.topbar { display: flex; flex-shrink: 0; align-items: center; gap: 10px; min-height: 64px; padding: 8px 25px; border-bottom: 1px solid var(--line); background: var(--paper); }
.top-new { margin-left: auto; }
.mobile-menu { display: none; }
.icon-button { display: inline-grid; flex: 0 0 auto; place-items: center; width: 36px; height: 36px; padding: 0; border: 0; border-radius: 7px; background: transparent; color: var(--muted); cursor: pointer; }
.icon-button.primary { background: var(--accent); color: var(--paper); }
.model-controls { display: grid; grid-template-columns: 136px 220px; gap: 8px; min-width: 0; }
.model-field { position: relative; min-width: 0; }
.model-field > span { position: absolute; pointer-events: none; top: 4px; left: 9px; font-size: 10px; line-height: 1.3; color: var(--muted); }
.model-field select { width: 100%; min-height: 43px; padding: 15px 8px 3px; border: 1px solid var(--control); border-radius: 6px; background: var(--paper); font-size: 13px; font-weight: 550; text-overflow: ellipsis; }
.notice { margin: 8px var(--margin) 0; padding: 8px 12px; border-radius: 6px; background: #fdf2f2; color: var(--danger); font-size: 13px; }
.thread, .admin { flex: 1; min-height: 0; overflow: auto; overscroll-behavior: contain; }
.empty { display: grid; align-content: center; justify-items: center; gap: 13px; min-height: 100%; padding: 20px; }
.empty h1 { font-size: clamp(28px, 5vw, 38px); font-weight: 650; letter-spacing: -.045em; }
.empty .brand-symbol { width: 46px; height: 46px; }
.conversation { display: grid; gap: 22px; width: min(calc(100% - 2 * var(--margin)), var(--chat-width)); margin: 0 auto; padding-block: 28px 20px; }
.conversation:empty { display: none; }
.message { min-width: 0; overflow-wrap: anywhere; }
.message.user { justify-self: end; width: fit-content; max-width: 83%; padding: 10px 14px; border: 1px solid #dfe8fa; border-radius: 11px 11px 4px 11px; background: var(--selected); }
.answer-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-bottom: 6px; color: var(--muted); font-size: 12px; }
.answer-meta strong { color: var(--ink); font-weight: 650; }
.answer-meta .brand-symbol { width: 25px; height: 25px; }
.answer-meta .icon { font-size: 15px; }
.message-content { white-space: pre-wrap; }
.message img, .message video { display: block; max-width: 100%; max-height: 460px; border-radius: 8px; }
.message audio { display: block; max-width: 100%; }
.message-assets { display: grid; gap: 7px; margin-top: 8px; }
.file-link { width: fit-content; overflow-wrap: anywhere; font-size: 13px; }
.status { color: var(--muted); font-size: 12px; }
.status.failed { color: var(--danger); }
.status.pending { color: var(--pending); }
.job-card { margin-top: 7px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 8px; background: var(--paper); }

.composer-region { flex-shrink: 0; padding: 10px var(--margin) max(14px, env(safe-area-inset-bottom)); }
.composer { display: grid; gap: 4px; max-width: var(--chat-width); margin: auto; padding: 8px; border: 1px solid var(--control); border-radius: 11px; background: var(--paper); }
.composer:focus-within { border-color: #9bb9ff; }
.composer textarea { width: 100%; min-height: 38px; max-height: 140px; padding: 5px 6px; border: 0; resize: vertical; background: none; font-size: 14px; }
.composer textarea:focus { outline: 0; }
.composer-actions { display: flex; align-items: center; gap: 7px; }
.composer-actions .send { margin-left: auto; }
.composer-caption { color: var(--muted); font-size: 12px; }
.attachments { display: flex; flex-wrap: wrap; gap: 6px; padding-inline: 6px; }
.attachments button { max-width: 100%; padding: 4px 8px; border: 1px solid var(--control); border-radius: 5px; background: var(--hover); font-size: 12px; overflow-wrap: anywhere; }

.admin-body { width: min(calc(100% - 2 * var(--margin)), 860px); margin: auto; padding: 34px 0; }
.admin h1 { margin-bottom: 14px; font-size: 25px; font-weight: 650; letter-spacing: -.03em; }
.tabs { display: flex; flex-wrap: wrap; gap: 15px; border-bottom: 1px solid var(--line); }
.tabs button { padding: 8px 0 9px; border: 0; border-bottom: 2px solid transparent; background: none; color: var(--muted); font-size: 13px; }
.tabs button[aria-current="true"] { border-color: var(--accent); color: var(--accent-text); font-weight: 600; }
.section-heading { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin: 19px 0 12px; }
.section-heading h2 { font-size: 16px; }
.table-wrap { overflow: auto; border: 1px solid var(--line); border-radius: 8px; background: var(--paper); }
table { width: 100%; text-align: left; border-collapse: collapse; font-size: 13px; }
th, td { padding: 10px 11px; border-bottom: 1px solid var(--line); overflow-wrap: anywhere; }
thead { background: #fcfcfd; color: var(--muted); font-size: 12px; }
tbody tr:last-child > * { border-bottom: 0; }
.table-wrap button { padding: 0; border: 0; color: var(--accent-text); background: none; text-align: left; }
.table-wrap small { display: block; color: var(--muted); }
.admin-form { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; padding: 15px; border: 1px solid var(--line); border-radius: 8px; background: var(--paper); }
.admin-form label { display: grid; gap: 4px; font-size: 12px; color: var(--muted); }
.admin-form input, .admin-form textarea, .admin-form select { width: 100%; min-width: 0; padding: 7px; border: 1px solid var(--control); border-radius: 5px; background: var(--paper); color: var(--ink); font-size: 13px; }
.admin-form .wide, .form-actions { grid-column: 1 / -1; }
.form-actions { display: flex; flex-wrap: wrap; justify-content: end; gap: 8px; }
.login { display: grid; place-items: center; min-height: 100dvh; padding: 24px 16px max(24px, env(safe-area-inset-bottom)); }
.login-card {
  display: grid; justify-items: center; width: min(100%, 392px); padding: clamp(22px, 7vw, 36px);
  border: 1px solid #dce1ec; border-radius: 14px; background: var(--paper);
  box-shadow: 0 6px 24px #202b4f0a; text-align: center;
}
.login-mark { display: grid; place-items: center; width: 48px; height: 48px; border-radius: 10px; background: #edf0fb; color: #273a8b; }
.login-card h1 { margin-top: 17px; font-size: clamp(24px, 7.2vw, 30px); line-height: 1.2; letter-spacing: -.04em; }
.login-description { margin-top: 9px; color: var(--muted); font-size: 14px; line-height: 1.5; text-wrap: balance; }
.login-error { margin-top: 13px; padding: 8px 12px; border-radius: 6px; background: #fdf0f1; color: #8d212a; font-size: 13px; }
.login-action {
  display: flex; align-items: center; justify-content: center; gap: 7px;
  width: 100%; min-height: 46px; margin-top: 22px; padding: 8px 12px; border-radius: 7px;
  background: #273a8b; color: var(--paper); font-size: 14px; font-weight: 650; text-decoration: none;
}
.login-action:hover { background: #1d327f; }

@media (max-width: 700px) {
  :root { --margin: 14px; }
  .shell { display: block; }
  .workspace { height: 100dvh; }
  .sidebar { position: fixed; z-index: 4; inset: 0 auto 0 0; width: min(278px, 83vw); display: none; }
  .sidebar.visible { display: flex; }
  .scrim { position: fixed; z-index: 3; inset: 0; background: #192b4960; border: 0; }
  .topbar { min-height: 61px; padding: 5px 9px; gap: 6px; }
  .mobile-menu { display: inline-grid; }
  .top-new { display: none; }
  .model-controls { flex: 1; grid-template-columns: minmax(88px, 2fr) minmax(0, 3fr); gap: 6px; }
  .message.user { max-width: 92%; }
  .admin-body { padding-block: 21px; }
}

@media (max-width: 410px) {
  .admin-form { grid-template-columns: minmax(0, 1fr); }
  th, td { padding-inline: 7px; }
}

@media (pointer: coarse) {
  .icon-button { width: 44px; height: 44px; }
  .composer textarea, .admin-form input, .admin-form select, .admin-form textarea, .search input { font-size: 16px; }
}
