/* FRK(RM) by I44 — веб-версия в стиле приложения */

@font-face {
  font-family: "JetBrains Mono";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("/fonts/JetBrainsMono-Regular.ttf") format("truetype");
}

@font-face {
  font-family: "JetBrains Mono";
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url("/fonts/JetBrainsMono-Medium.ttf") format("truetype");
}

:root {
  --bg: #000;
  --surface: #0d0d0f;
  --surface2: #151517;
  --surface3: #1c1c1f;
  --line: #242427;
  --line2: #2e2e32;
  --text: #f3f1ec;
  --muted: #8f8c86;
  --gold: #d8b274;
  --gold-soft: rgba(216, 178, 116, 0.14);
  --gold-line: rgba(216, 178, 116, 0.3);
  --ok: #8fc79b;
  --ok-soft: rgba(143, 199, 155, 0.09);
  --ok-line: rgba(143, 199, 155, 0.25);
  --err: #d98a8a;
  --err-soft: rgba(217, 138, 138, 0.08);
  --err-line: rgba(217, 138, 138, 0.26);
  --mono: "JetBrains Mono", "Cascadia Code", Consolas, monospace;
  --sans: "Roboto", "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
  -webkit-font-smoothing: antialiased;
}

[hidden] {
  display: none !important;
}

html,
body {
  margin: 0;
  background: #070708;
}

body {
  color: var(--text);
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.5;
  min-height: 100dvh;
  overscroll-behavior-y: none;
}

body.chat-open,
body.sheet-open,
body.html-open {
  overflow: hidden;
}

button,
input,
textarea {
  font: inherit;
  color: inherit;
}

button {
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

button:disabled {
  cursor: default;
  opacity: 0.55;
}

:focus-visible {
  outline: 2px solid var(--gold-line);
  outline-offset: 2px;
}

.sprite {
  position: absolute;
  width: 0;
  height: 0;
  overflow: hidden;
}

.icon {
  width: 18px;
  height: 18px;
  flex: none;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.9;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* ------------------------------------------------------------- Каркас */

.app {
  width: 100%;
  max-width: 430px;
  min-height: 100dvh;
  margin: 0 auto;
  background: var(--bg);
  display: flex;
  flex-direction: column;
  position: relative;
}

@media (min-width: 520px) {
  .app {
    box-shadow: 0 0 0 1px #141416, 0 40px 120px rgba(0, 0, 0, 0.85);
  }
}

.appbar {
  position: sticky;
  top: 0;
  z-index: 10;
  flex: none;
  height: 60px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 0 12px 0 20px;
  background: #000;
}

.app > .appbar {
  height: calc(60px + env(safe-area-inset-top));
  padding-top: env(safe-area-inset-top);
}

.brand {
  display: flex;
  align-items: center;
  min-width: 0;
}

.mark {
  width: 12px;
  height: 12px;
  border-radius: 3.5px;
  background: var(--gold);
  box-shadow: 0 0 0 4px rgba(216, 178, 116, 0.1);
  flex: none;
}

.brand-name {
  font-size: 16px;
  font-weight: 500;
  letter-spacing: -0.1px;
  margin-left: 10px;
  white-space: nowrap;
}

.byline {
  font-size: 11px;
  color: var(--muted);
  letter-spacing: 0.8px;
  margin-left: 8px;
  white-space: nowrap;
}

.bar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: none;
}

.icon-btn {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: var(--surface2);
  color: #c9c6c0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: border-color 0.15s ease, color 0.15s ease, background 0.15s ease;
}

.icon-btn:hover {
  border-color: var(--line2);
  color: var(--gold);
}

.btn-label {
  display: none;
}

.content {
  flex: 1;
  padding: 4px 20px calc(72px + env(safe-area-inset-bottom));
}

.page-title {
  font-size: 31px;
  line-height: 1.14;
  letter-spacing: -0.9px;
  font-weight: 500;
  margin: 8px 0 22px;
}

.page-sub {
  display: none;
}

.offline {
  margin: 0 0 14px;
  padding: 11px 14px;
  border-radius: 14px;
  border: 1px solid var(--err-line);
  background: var(--err-soft);
  color: #e2b1b1;
  font-size: 12.5px;
  line-height: 1.45;
}

.offline b {
  color: #f0d0d0;
  font-weight: 500;
}

/* ------------------------------------------------------------- Карточки */

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 28px;
  padding: 20px;
  margin-bottom: 12px;
}

.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
  min-height: 27px;
}

.eyebrow {
  margin: 0;
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 1.7px;
  text-transform: uppercase;
  color: var(--muted);
  white-space: nowrap;
}

.head-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-left: auto;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  height: 27px;
  padding: 0 11px;
  border-radius: 999px;
  background: #161618;
  border: 1px solid #26262a;
  font-size: 11.5px;
  color: var(--muted);
  white-space: nowrap;
  transition: color 0.15s ease, background 0.15s ease, border-color 0.15s ease;
}

.chip i {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--muted);
  display: block;
  flex: none;
}

.chip.ok {
  color: var(--ok);
  border-color: var(--ok-line);
  background: var(--ok-soft);
}

.chip.ok i {
  background: var(--ok);
}

.chip.warn {
  color: var(--gold);
  border-color: var(--gold-line);
  background: var(--gold-soft);
}

.chip.warn i {
  background: var(--gold);
}

.chip.bad {
  color: var(--err);
  border-color: var(--err-line);
  background: var(--err-soft);
}

.chip.bad i {
  background: var(--err);
}

.key-box {
  display: block;
  margin-top: 14px;
  background: #08080a;
  border: 1px solid #1b1b1f;
  border-radius: 18px;
  padding: 15px 16px;
  font-family: var(--mono);
  font-size: 13.5px;
  line-height: 1.55;
  color: #edeae3;
  overflow-wrap: anywhere;
  user-select: all;
}

.card-actions {
  display: flex;
  gap: 8px;
  margin-top: 12px;
}

.divider {
  height: 1px;
  background: #1d1d20;
  margin: 16px 0 14px;
}

.row {
  display: flex;
  align-items: center;
}

.row.between {
  justify-content: space-between;
  gap: 10px;
}

.row.gap8 {
  gap: 8px;
}

.tiny {
  font-size: 11.5px;
  color: #6e6c68;
  margin: 0;
}

.note {
  margin: 10px 0 0;
  font-size: 12.5px;
  line-height: 1.5;
  color: var(--muted);
  white-space: pre-line;
}

.note.error {
  color: var(--err);
}

.note.warn {
  color: var(--gold);
}

.note.ok {
  color: var(--ok);
}

.new-note {
  display: none;
}

.account-line {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid #1d1d20;
  font-size: 11.5px;
  color: #7c7a75;
  overflow-wrap: anywhere;
}

/* ------------------------------------------------------------- Кнопки */

.pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 38px;
  padding: 0 16px;
  border-radius: 999px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--text);
  font-size: 13.5px;
  font-weight: 500;
  white-space: nowrap;
  transition: filter 0.15s ease, background 0.15s ease, border-color 0.15s ease,
    transform 0.1s ease;
}

.pill:active:not(:disabled) {
  transform: scale(0.98);
}

.pill .icon {
  width: 16px;
  height: 16px;
}

.pill.tonal {
  background: var(--surface3);
}

.pill.tonal:hover {
  background: #242428;
}

.pill.gold {
  background: var(--gold-soft);
  border-color: var(--gold-line);
  color: var(--gold);
}

.pill.gold:hover {
  background: rgba(216, 178, 116, 0.2);
}

.pill.outline {
  border-color: var(--line2);
  color: var(--text);
}

.pill.outline:hover {
  border-color: #3c3c41;
  background: rgba(255, 255, 255, 0.03);
}

.pill.solid {
  background: var(--gold);
  color: #1a1408;
  font-weight: 600;
}

.pill.solid:hover {
  filter: brightness(1.04);
}

.pill.xs {
  height: 32px;
  padding: 0 13px;
  font-size: 12.5px;
  gap: 6px;
}

.pill.xs .icon {
  width: 14px;
  height: 14px;
}

.pill.wide {
  width: 100%;
  height: 46px;
  margin-top: 16px;
  font-size: 14px;
}

.text-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 0;
  border: 0;
  background: none;
  font-size: 13px;
  font-weight: 500;
  color: var(--gold);
  transition: opacity 0.15s ease;
}

.text-btn:hover {
  opacity: 0.8;
}

.text-btn.subtle {
  color: var(--muted);
}

.text-btn.subtle:hover {
  color: var(--text);
}

/* ------------------------------------------------------------- Баланс */

.balance-row {
  display: flex;
  align-items: baseline;
  gap: 2px;
  margin-top: 6px;
}

.balance-number {
  font-size: clamp(44px, 13.5vw, 56px);
  line-height: 1.02;
  font-weight: 500;
  letter-spacing: -2.6px;
  font-variant-numeric: tabular-nums;
}

.balance-unit {
  font-size: 26px;
  font-weight: 500;
  letter-spacing: -0.5px;
  color: var(--muted);
}

.balance-sub {
  margin: 8px 0 0;
  font-family: var(--mono);
  font-size: 12.5px;
  color: #a9a6a0;
  overflow-wrap: anywhere;
}

.balance-sub:empty {
  display: none;
}

.balance-row.small .balance-number {
  font-size: 30px;
  letter-spacing: -1.2px;
}

.balance-row.small .balance-unit {
  font-size: 15px;
}

/* ------------------------------------------------------------- График */

.chart-body {
  margin-top: 4px;
}

.chart-stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin-top: 16px;
}

.chart-stat {
  min-width: 0;
  padding: 10px 12px;
  border-radius: 14px;
  border: 1px solid #1b1b1f;
  background: #0a0a0c;
}

.chart-stat-label {
  display: block;
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.chart-stat strong {
  display: block;
  margin-top: 4px;
  font-size: 17px;
  font-weight: 500;
  letter-spacing: -0.3px;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.chart-canvas-wrap {
  position: relative;
  min-height: 220px;
  margin-top: 14px;
}

.usage-chart {
  display: block;
  width: 100%;
  height: 220px;
}

.chart-empty {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  margin: 0;
  padding: 0 24px;
  text-align: center;
}

.chart-caption {
  margin: 10px 0 0;
  color: #6e6c68;
  font-size: 11px;
}

@media (max-width: 520px) {
  .chart-stat {
    padding: 9px 10px;
  }

  .chart-stat-label {
    font-size: 9.5px;
    letter-spacing: 0.08em;
  }

  .chart-stat strong {
    font-size: 16px;
  }
}

/* ------------------------------------------------------------- Поля */

.field {
  display: block;
  width: 100%;
  height: 52px;
  margin: 0 0 14px;
  padding: 0 16px;
  border-radius: 16px;
  border: 1px solid #232327;
  background: #0a0a0c;
  color: var(--text);
  font-size: 15px;
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.field::placeholder {
  color: #5c5a56;
}

.field:focus {
  border-color: var(--gold-line);
  box-shadow: 0 0 0 3px rgba(216, 178, 116, 0.1);
}

.field.mono {
  font-family: var(--mono);
  font-size: 13.5px;
}

.field-label {
  display: block;
  margin: 0 0 6px 2px;
  font-size: 10.5px;
  font-weight: 500;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
}

#key-check-input {
  margin-bottom: 12px;
}

.check-note {
  margin: 8px 0 14px;
}

.check-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 4px 0 22px;
  font-size: 13px;
  color: #b4b1ab;
}

.check-row input {
  width: 18px;
  height: 18px;
  flex: none;
  accent-color: var(--gold);
}

/* ------------------------------------------------------------- Проверка ключа */

#key-check-run {
  height: 50px;
}

.result {
  margin-top: 14px;
  padding: 14px 16px;
  border-radius: 18px;
  border: 1px solid #232327;
  background: #0b0b0d;
}

.result.gold {
  border-color: var(--gold-line);
}

.result.bad {
  border-color: var(--err-line);
}

.result .balance-row {
  margin-top: 0;
}

.result .note {
  margin-top: 8px;
}

/* ------------------------------------------------------------- Подвал */

.foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 6px 4px 24px;
}

.foot-row {
  display: flex;
  align-items: center;
  gap: 7px;
  color: #66645f;
  font-size: 11.5px;
}

.foot-row .icon {
  width: 13px;
  height: 13px;
}

/* ------------------------------------------------------------- Бейдж */

.badge-hit {
  position: absolute;
  bottom: 2px;
  right: 4px;
  z-index: 12;
  width: 72px;
  height: 48px;
  display: grid;
  place-items: center;
  padding: 0;
  border: 0;
  background: transparent;
  transition: opacity 0.15s ease, transform 0.15s ease;
}

.badge-hit img {
  width: 56px;
  height: 32px;
  object-fit: contain;
  opacity: 0.86;
  pointer-events: none;
}

.badge-hit:hover img {
  opacity: 1;
}

.badge-hit:active {
  transform: scale(0.94);
}

body.chat-open .badge-hit {
  display: none;
}

/* ------------------------------------------------------------- Чат */

.chat {
  position: fixed;
  inset: 0;
  z-index: 20;
  width: 100%;
  max-width: 430px;
  height: 100dvh;
  margin: 0 auto;
  background: var(--bg);
  display: flex;
  flex-direction: column;
  padding-top: env(safe-area-inset-top);
}

@media (min-width: 520px) {
  .chat {
    box-shadow: 0 0 0 1px #141416, 0 40px 120px rgba(0, 0, 0, 0.85);
  }
}

.chat-bar {
  position: static;
  background: var(--bg);
  backdrop-filter: none;
  padding: 8px 12px;
  justify-content: flex-start;
}

.chat-title {
  font-size: 17px;
  font-weight: 500;
  margin: 0 0 0 12px;
  flex: 1;
}

.model-pill {
  max-width: 150px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  padding: 7px 13px;
  border-radius: 999px;
  border: 1px solid var(--line2);
  background: transparent;
  color: var(--text);
  font-family: var(--mono);
  font-size: 12px;
  transition: border-color 0.15s ease, color 0.15s ease;
}

.model-pill:hover {
  border-color: var(--gold-line);
  color: var(--gold);
}

.messages {
  flex: 1;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 4px 16px 8px;
  display: flex;
  flex-direction: column;
  scrollbar-width: thin;
  scrollbar-color: #2e2e32 transparent;
}

.messages::-webkit-scrollbar,
.sheet::-webkit-scrollbar,
.sheet-list::-webkit-scrollbar,
.log::-webkit-scrollbar {
  width: 8px;
}

.messages::-webkit-scrollbar-thumb,
.sheet::-webkit-scrollbar-thumb,
.sheet-list::-webkit-scrollbar-thumb,
.log::-webkit-scrollbar-thumb {
  background: #2e2e32;
  border-radius: 99px;
}

.chat-empty {
  margin: auto;
  max-width: 300px;
  padding: 20px 0;
  text-align: center;
  font-size: 13px;
  line-height: 1.6;
  color: var(--muted);
  white-space: pre-line;
}

.msg-row {
  display: flex;
  width: 100%;
  margin: 5px 0;
}

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

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

.bubble {
  max-width: 78%;
  padding: 11px 15px;
  border-radius: 20px;
  font-size: 14.5px;
  line-height: 1.5;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  user-select: text;
}

.msg-row.assistant .bubble {
  background: var(--surface3);
  border-bottom-left-radius: 4px;
}

.msg-row.user .bubble {
  background: #2a2318;
  border-bottom-right-radius: 4px;
}

.system-note {
  width: 100%;
  margin: 6px 0;
  text-align: center;
  font-size: 12px;
  line-height: 1.5;
  color: var(--err);
  white-space: pre-wrap;
}

.typing {
  color: var(--muted);
  font-size: 14px;
  animation: pulse 1.2s ease-in-out infinite;
}

@keyframes pulse {
  0%,
  100% {
    opacity: 0.45;
  }
  50% {
    opacity: 1;
  }
}

.reasoning {
  max-width: 78%;
  margin: 4px 0;
  padding: 9px 12px;
  border-radius: 14px;
  border: 1px solid #232327;
  background: #0a0a0c;
}

.reasoning summary {
  list-style: none;
  cursor: pointer;
  font-size: 10.5px;
  font-weight: 500;
  letter-spacing: 1.2px;
  text-transform: uppercase;
  color: var(--muted);
  user-select: none;
}

.reasoning summary::-webkit-details-marker {
  display: none;
}

.reasoning[open] summary {
  color: #a9a6a0;
}

.reasoning-body {
  margin-top: 6px;
  font-size: 12.5px;
  line-height: 1.6;
  color: #9c9992;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  user-select: text;
}

.code-card {
  width: 100%;
  margin: 4px 0;
  border-radius: 14px;
  border: 1px solid #232327;
  background: #0a0a0c;
  overflow: hidden;
}

.code-head {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 8px 4px 12px;
}

.code-lang {
  flex: 1;
  font-size: 10.5px;
  font-weight: 500;
  letter-spacing: 1.1px;
  text-transform: uppercase;
  color: var(--muted);
}

.code-action {
  padding: 4px 8px;
  border: 0;
  background: none;
  color: var(--gold);
  font-size: 11.5px;
  font-weight: 500;
  border-radius: 8px;
}

.code-action:hover {
  background: var(--gold-soft);
}

.code-card pre {
  margin: 0;
  padding: 4px 12px 12px;
  overflow-x: auto;
  font-family: var(--mono);
  font-size: 12.5px;
  line-height: 1.55;
  color: #d8d4cc;
}

.usage,
.usages {
  flex: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 4px 20px 6px;
  font-size: 11.5px;
  color: var(--muted);
}

.usage #left,
.usages #left {
  color: var(--gold);
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.composer {
  flex: none;
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 6px 12px calc(12px + env(safe-area-inset-bottom));
  background: var(--bg);
}

.composer textarea {
  flex: 1;
  min-height: 48px;
  max-height: 128px;
  padding: 12px 18px;
  border-radius: 24px;
  border: 1px solid #232327;
  background: #0a0a0c;
  color: var(--text);
  font-size: 15px;
  line-height: 1.45;
  resize: none;
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.composer textarea::placeholder {
  color: #5c5a56;
}

.composer textarea:focus {
  border-color: var(--gold-line);
  box-shadow: 0 0 0 3px rgba(216, 178, 116, 0.08);
}

.send {
  width: 48px;
  height: 48px;
  flex: none;
  border: 0;
  border-radius: 50%;
  background: var(--gold);
  color: #1a1408;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: filter 0.15s ease, transform 0.1s ease;
}

.send .icon {
  width: 20px;
  height: 20px;
  stroke-width: 2.1;
}

.send:hover {
  filter: brightness(1.05);
}

.send:active {
  transform: scale(0.96);
}

/* ------------------------------------------------------------- Шторки */

.scrim {
  position: fixed;
  inset: 0;
  z-index: 30;
  background: rgba(0, 0, 0, 0.64);
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
  animation: fade 0.2s ease;
}

@keyframes fade {
  from {
    opacity: 0;
  }
}

.sheet {
  position: fixed;
  left: 50%;
  bottom: 0;
  z-index: 40;
  transform: translateX(-50%);
  width: 100%;
  max-width: 430px;
  max-height: 90dvh;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 10px 20px calc(26px + env(safe-area-inset-bottom));
  border-radius: 32px 32px 0 0;
  background: #131315;
  box-shadow: 0 -24px 60px rgba(0, 0, 0, 0.6);
  animation: sheet-up 0.28s cubic-bezier(0.2, 0.8, 0.2, 1);
}

@keyframes sheet-up {
  from {
    transform: translate(-50%, 100%);
  }
}

.handle {
  width: 36px;
  height: 4px;
  margin: 0 auto 18px;
  border-radius: 2px;
  background: #3a3a3e;
}

.sheet h2 {
  margin: 0 0 8px;
  font-size: 23px;
  font-weight: 500;
  letter-spacing: -0.4px;
}

.sheet-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.sheet-title-row h2 {
  margin: 0;
}

.sheet-sub {
  margin: 8px 0 20px;
  font-size: 13px;
  line-height: 1.5;
  color: var(--muted);
}

.sheet-sub:last-child {
  margin-bottom: 0;
}

.sheet-actions {
  display: flex;
  gap: 10px;
  margin-top: 20px;
}

.sheet-actions .pill {
  flex: 1;
  height: 50px;
  font-size: 14.5px;
}

.sheet-list {
  max-height: 46dvh;
  overflow-y: auto;
  overscroll-behavior: contain;
  margin: 8px -4px 0;
}

.model-row {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 12px 14px;
  border: 1px solid transparent;
  border-radius: 14px;
  background: none;
  color: #c9c6c0;
  font-family: var(--mono);
  font-size: 13px;
  text-align: left;
  overflow-wrap: anywhere;
}

.model-row:hover {
  background: var(--surface3);
}

.model-row.active {
  border-color: var(--gold-line);
  background: var(--gold-soft);
  color: var(--gold);
}

.model-row .icon {
  width: 16px;
  height: 16px;
  margin-left: auto;
}

.search-box {
  display: flex;
  align-items: center;
  gap: 10px;
  height: 46px;
  padding: 0 14px;
  margin: 0 0 6px;
  border-radius: 14px;
  border: 1px solid #232327;
  background: #0a0a0c;
  color: var(--muted);
}

.search-box .icon {
  width: 16px;
  height: 16px;
}

.search-box input {
  flex: 1;
  border: 0;
  background: none;
  outline: none;
  font-size: 14px;
  color: var(--text);
}

.history-list {
  margin-top: 12px;
}

.history-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 0;
}

.history-open {
  flex: 1;
  min-width: 0;
  padding: 10px 12px;
  border: 1px solid transparent;
  border-radius: 14px;
  background: none;
  color: var(--text);
  text-align: left;
}

.history-open:hover {
  background: var(--surface3);
}

.history-name {
  display: block;
  font-size: 14px;
  line-height: 1.35;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.history-meta {
  display: block;
  margin-top: 2px;
  font-size: 11px;
  color: #6e6c68;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.history-delete {
  width: 36px;
  height: 36px;
  flex: none;
  border: 0;
  border-radius: 50%;
  background: none;
  color: #6e6c68;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.history-delete:hover {
  background: var(--err-soft);
  color: var(--err);
}

.history-delete .icon {
  width: 16px;
  height: 16px;
}

.log {
  margin: 0;
  max-height: 42dvh;
  overflow: auto;
  padding: 12px;
  border-radius: 14px;
  border: 1px solid #232327;
  background: #08080a;
  font-family: var(--mono);
  font-size: 11.5px;
  line-height: 1.55;
  color: #a9a6a0;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.log:empty::before {
  content: "Ожидаю первые строки…";
  color: #5e5c58;
}

.account-result {
  border-radius: 14px;
  border: 1px solid var(--gold-line);
  background: #0b0b0d;
  padding: 4px 14px;
}

.account-row {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px 0;
  border-bottom: 1px solid #1d1d20;
}

.account-row:last-child {
  border-bottom: 0;
}

.account-row .info {
  flex: 1;
  min-width: 0;
}

.account-row .label {
  display: block;
  font-size: 11px;
  color: var(--muted);
}

.account-row .value {
  display: block;
  margin-top: 2px;
  font-family: var(--mono);
  font-size: 12.5px;
  color: var(--text);
  overflow-wrap: anywhere;
  user-select: all;
}

.account-row .copy {
  padding: 4px 6px;
  border: 0;
  background: none;
  color: var(--gold);
  font-size: 11.5px;
  font-weight: 500;
  white-space: nowrap;
}

.install-steps {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.install-step {
  display: flex;
  gap: 12px;
  font-size: 13px;
  line-height: 1.5;
  color: #b9b6b0;
}

.install-step b {
  flex: none;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--gold-soft);
  border: 1px solid var(--gold-line);
  color: var(--gold);
  font-size: 11.5px;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.egg-sheet {
  text-align: center;
}

.egg-icon {
  width: 96px;
  height: 96px;
  margin: 4px auto 20px;
  border-radius: 24px;
  border: 1px solid var(--gold-line);
  display: block;
}

.egg-title {
  margin: 0;
  font-size: 25px;
  font-weight: 500;
  letter-spacing: -0.5px;
  text-align: center;
}

.egg-sheet .sheet-actions {
  margin-top: 24px;
}

/* ------------------------------------------------------------- HTML-прогон */

.html-modal {
  position: fixed;
  inset: 0;
  z-index: 90;
  display: flex;
  flex-direction: column;
  background: #0a0a0c;
}

.html-head {
  flex: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 10px 10px 16px;
  padding-top: calc(10px + env(safe-area-inset-top));
  font-size: 15px;
  font-weight: 500;
}

.html-head .text-btn {
  padding: 6px 10px;
}

.html-modal iframe {
  flex: 1;
  width: 100%;
  border: 0;
  background: #fff;
}

/* ------------------------------------------------------------- Тост */

.toast {
  position: fixed;
  left: 50%;
  bottom: 84px;
  z-index: 80;
  transform: translateX(-50%);
  max-width: min(340px, calc(100vw - 40px));
  padding: 10px 18px;
  border-radius: 999px;
  border: 1px solid var(--line2);
  background: #1c1c1f;
  color: var(--text);
  font-size: 12.5px;
  text-align: center;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.5);
  animation: toast-in 0.18s ease;
}

@keyframes toast-in {
  from {
    opacity: 0;
    transform: translate(-50%, 8px);
  }
}

/* ------------------------------------------------------------- Адаптив */

@media (max-width: 380px) {
  .eyebrow {
    font-size: 10.5px;
    letter-spacing: 1.2px;
  }
}

@media (max-width: 360px) {
  .content {
    padding-left: 16px;
    padding-right: 16px;
  }

  .appbar {
    padding-left: 16px;
  }

  .balance-number {
    letter-spacing: -2px;
  }
}

/* ------------------------------------------------------------- Компьютер */

@keyframes modal-in {
  from {
    opacity: 0;
    transform: translate(-50%, calc(-50% + 16px));
  }
}

@media (min-width: 720px) {
  .app {
    max-width: 680px;
  }

  .app > .appbar {
    padding: 0 24px 0 28px;
  }

  .content {
    padding: 8px 28px calc(64px + env(safe-area-inset-bottom));
  }

  .page-title {
    font-size: 36px;
    margin: 10px 0 24px;
  }

  .card {
    padding: 22px;
  }

  .badge-hit {
    position: absolute;
    right: 8px;
    bottom: 8px;
  }

  .chat {
    max-width: 680px;
  }

  .sheet {
    top: 50%;
    bottom: auto;
    transform: translate(-50%, -50%);
    max-width: 500px;
    max-height: 86dvh;
    padding: 12px 24px 24px;
    border-radius: 28px;
    animation: modal-in 0.22s ease;
    box-shadow: 0 30px 90px rgba(0, 0, 0, 0.72);
  }

  .sheet .handle {
    display: none;
  }

  .sheet-list {
    max-height: 48dvh;
  }

  .html-modal {
    inset: 20px;
    max-width: 1100px;
    margin: 0 auto;
    border-radius: 22px;
    border: 1px solid #1d1d20;
    overflow: hidden;
    box-shadow: 0 30px 90px rgba(0, 0, 0, 0.72);
  }

  .toast {
    bottom: 32px;
  }
}

@media (min-width: 1024px) {
  body {
    background: #060607;
  }

  .app {
    max-width: 1180px;
  }

  .app > .appbar {
    height: 76px;
    padding: 0 32px;
    border-bottom: 1px solid #141416;
  }

  .mark {
    width: 13px;
    height: 13px;
  }

  .brand-name {
    font-size: 18px;
    margin-left: 12px;
  }

  .byline {
    font-size: 12px;
    margin-left: 10px;
  }

  .icon-btn.labeled {
    width: auto;
    height: 42px;
    padding: 0 17px;
    border-radius: 999px;
    gap: 8px;
  }

  .icon-btn.labeled .btn-label {
    display: inline;
    font-size: 13.5px;
    font-weight: 500;
  }

  .content {
    display: grid;
    grid-template-columns: minmax(0, 1.18fr) minmax(0, 0.82fr);
    grid-template-areas:
      "head head"
      "key balance"
      "chart chart"
      "check new"
      "foot foot";
    gap: 16px;
    align-content: start;
    padding: 22px 32px calc(88px + env(safe-area-inset-bottom));
  }

  .page-head {
    grid-area: head;
    margin: 4px 0 10px;
  }

  .page-title {
    font-size: 40px;
    letter-spacing: -1.2px;
    margin: 0;
  }

  .page-sub {
    display: block;
    margin: 6px 0 0;
    font-size: 14.5px;
    color: var(--muted);
  }

  .content > .card {
    margin-bottom: 0;
    padding: 24px;
  }

  .key-card {
    grid-area: key;
  }

  .balance-card {
    grid-area: balance;
    display: flex;
    flex-direction: column;
  }

  .balance-card .balance-row {
    margin-top: 18px;
  }

  .balance-card .balance-number {
    font-size: clamp(56px, 5vw, 68px);
  }

  .balance-card .balance-unit {
    font-size: 30px;
  }

  .balance-card .account-line {
    margin-top: auto;
  }

  .chart-card {
    grid-area: chart;
  }

  .chart-stats {
    gap: 12px;
  }

  .chart-stat strong {
    font-size: 19px;
  }

  .chart-canvas-wrap {
    min-height: 260px;
  }

  .usage-chart {
    height: 260px;
  }

  .check-card {
    grid-area: check;
    display: flex;
    flex-direction: column;
  }

  .check-card #key-check-run {
    margin-top: auto;
  }

  .new-card {
    grid-area: new;
    display: flex;
    flex-direction: column;
    justify-content: center;
  }

  .new-note {
    display: block;
    margin: 8px 0 0;
  }

  .new-card .pill.wide {
    margin-top: 14px;
  }

  .foot {
    grid-area: foot;
    margin-top: 6px;
    padding: 18px 76px 0 4px;
    border-top: 1px solid #151517;
  }

  .badge-hit {
    right: 16px;
    bottom: 12px;
  }

  .chat {
    max-width: none;
  }

  .chat-bar {
    width: 100%;
    max-width: 1000px;
    height: 76px;
    margin: 0 auto;
    padding: 0 24px 0 16px;
    border-bottom: 1px solid #151517;
  }

  .chat-title {
    font-size: 19px;
  }

  .model-pill {
    max-width: 240px;
    font-size: 12.5px;
  }

  .messages {
    width: 100%;
    max-width: 1000px;
    margin: 0 auto;
    padding: 20px 28px;
  }

  .chat-empty {
    max-width: 380px;
  }

  .bubble,
  .reasoning {
    max-width: 68%;
  }

  .bubble {
    font-size: 15px;
  }

  .usage {
    width: 100%;
    max-width: 1000px;
    margin: 0 auto;
    padding: 4px 32px 8px;
  }

  .composer {
    width: 100%;
    max-width: 1000px;
    margin: 0 auto;
    padding: 8px 24px 24px;
  }

  .composer textarea {
    min-height: 52px;
    max-height: 180px;
    padding: 14px 20px;
  }

  .send {
    width: 52px;
    height: 52px;
  }

  .toast {
    bottom: 36px;
  }
}

@media (hover: hover) and (min-width: 1024px) {
  .card {
    transition: border-color 0.18s ease;
  }

  .card:hover {
    border-color: #2c2c30;
  }
}

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

/* Cloudflare Workers: доступны ключ и чат, остальные блоки скрыты. */
.cf-worker .balance-card,
.cf-worker .chart-card,
.cf-worker .check-card,
.cf-worker .new-card,
.cf-worker #opencode-btn {
  display: none !important;
}
