/* ═══ tokens ═══ */
:root {
  --brand-start: #0A0A0B;
  --brand-end: #3F3F46;
  --ink: #0A0A0B;
  --ink-soft: #18181B;
  --mute: #52525B;
  --faint: #A1A1AA;
  --line: #E4E4E7;
  --line-soft: #F4F4F5;
  --bg: #F8FAFC;
  --card: #FFFFFF;
  --ok: #10B981;
  --warn: #F59E0B;
  --bad: #EF4444;
  --radius: 1rem;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }

html, body {
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  color: var(--ink);
  font-family: 'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif;
  font-size: 15px;
  line-height: 1.55;
}

code, pre, .mono-strong {
  font-family: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
}

::selection { background: rgba(10, 10, 11, .18); }

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #D4D4D8; border-radius: 99px; border: 2px solid var(--bg); }
::-webkit-scrollbar-thumb:hover { background: var(--faint); }

/* ═══ helpers ═══ */
.grad-text {
  background: linear-gradient(100deg, var(--brand-start), var(--brand-end));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.muted { color: var(--mute); font-size: .85rem; }
.muted.block { display: block; margin: 0 0 .35rem; }

.lbl {
  margin: 1.4rem 0 .45rem;
  font-size: .72rem;
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--faint);
}
.panel-head .lbl { margin: 0; }

.lead { margin: 0 0 .55rem; color: var(--ink-soft); font-weight: 500; }

.ic { width: 15px; height: 15px; flex: none; }

/* ═══ topbar ═══ */
.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  background: rgba(255, 255, 255, .85);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
}

.topbar-inner {
  max-width: 1020px;
  margin: 0 auto;
  padding: 0 20px;
  height: 62px;
  display: flex;
  align-items: center;
  gap: 22px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: var(--ink);
}

.brand-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border-radius: 10px;
  background: linear-gradient(100deg, var(--brand-start), var(--brand-end));
  color: #fff;
  font-family: 'JetBrains Mono', monospace;
  font-weight: 600;
  font-size: .82rem;
  box-shadow: 0 4px 14px -4px rgba(10, 10, 11, .45);
}

.brand-name { font-weight: 700; font-size: 1rem; letter-spacing: -.01em; }
.brand-name b { font-weight: 500; color: var(--mute); }

.topbar-right { margin-left: auto; }

/* tabs */
.tabs {
  display: flex;
  gap: 4px;
  background: var(--line-soft);
  border: 1px solid var(--line);
  border-radius: .65rem;
  padding: 3px;
}

.tab {
  appearance: none;
  border: 0;
  background: transparent;
  padding: .45rem .95rem;
  border-radius: .5rem;
  font: inherit;
  font-size: .86rem;
  font-weight: 600;
  color: var(--mute);
  cursor: pointer;
  transition: color .18s, background-color .18s, box-shadow .18s;
}

.tab:hover { color: var(--ink); }

.tab.active {
  color: var(--ink);
  background: var(--card);
  box-shadow: 0 1px 3px rgba(9, 9, 11, .12);
}

/* ═══ status chip + dot ═══ */
.chip {
  display: inline-flex;
  align-items: center;
  gap: .45rem;
  padding: .32rem .75rem;
  border-radius: 99px;
  border: 1px solid var(--line);
  background: var(--card);
  font-size: .76rem;
  font-weight: 600;
  color: var(--mute);
  white-space: nowrap;
}

.dot {
  position: relative;
  display: inline-block;
  width: .5rem;
  height: .5rem;
  border-radius: 99px;
  background: var(--faint);
  flex: none;
}

.dot::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: inherit;
  animation: pulse-ring 2s cubic-bezier(.4, 0, .6, 1) infinite;
}

@keyframes pulse-ring {
  0%, 100% { opacity: 1; transform: scale(1); }
  50%      { opacity: .35; transform: scale(1.9); }
}

.chip-on { border-color: #0A0A0B; background: #0A0A0B; color: #FFFFFF; }
.chip-on .dot { background: #FFFFFF; }

.chip-off { border-color: #D4D4D8; background: #FAFAFA; color: var(--mute); }
.chip-off .dot { background: var(--faint); }

/* ═══ layout ═══ */
.container {
  width: 100%;
  max-width: 1020px;
  margin: 0 auto;
  padding: 26px 20px 40px;
  flex: 1;
}

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  transition: box-shadow .25s, border-color .25s;
}

.card.pad { padding: 24px; animation: fade-up .42s cubic-bezier(.16, 1, .3, 1) both; }
.card.pad:hover { box-shadow: 0 10px 30px -14px rgba(9, 9, 11, .12); }

@keyframes fade-up {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: none; }
}

/* stat tiles */
.statgrid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 12px;
  margin-bottom: 14px;
}

.stat { padding: 14px 18px; }

.stat-label {
  margin: 0 0 6px;
  font-size: .68rem;
  font-weight: 700;
  letter-spacing: .07em;
  text-transform: uppercase;
  color: var(--faint);
}

.stat-value {
  font-size: .84rem;
  font-weight: 600;
  color: var(--ink-soft);
  word-break: break-all;
}

.stat-action { display: flex; flex-direction: column; justify-content: space-between; gap: 6px; }
.stat-action .btn { align-self: flex-start; }

.statusstrip { margin-bottom: 12px; }

/* ═══ buttons ═══ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .45rem;
  border: 0;
  border-radius: .7rem;
  font: inherit;
  font-size: .88rem;
  font-weight: 600;
  padding: .6rem 1.15rem;
  cursor: pointer;
  white-space: nowrap;
  transition: transform .18s cubic-bezier(.16, 1, .3, 1), box-shadow .18s,
              background-color .18s, border-color .18s, opacity .18s;
}

.btn:active:not(:disabled) { transform: scale(.97); }
.btn:disabled { opacity: .55; cursor: not-allowed; }

.btn-primary {
  color: #fff;
  background: linear-gradient(100deg, var(--brand-start), var(--brand-end));
  box-shadow: 0 2px 6px -2px rgba(10, 10, 11, .4);
}

.btn-primary:hover:not(:disabled) {
  box-shadow: 0 10px 26px -8px rgba(10, 10, 11, .55);
  transform: translateY(-1px);
}

.btn-ghost {
  color: var(--ink-soft);
  background: var(--card);
  border: 1px solid var(--line);
}

.btn-ghost:hover:not(:disabled) { background: #FAFAFA; border-color: #D4D4D8; }

.btn-small { padding: .42rem .8rem; font-size: .8rem; border-radius: .6rem; }

.row-btns { display: flex; align-items: center; gap: 14px; margin-top: 12px; }

/* ═══ fields ═══ */
.field {
  width: 100%;
  font: inherit;
  color: var(--ink);
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: .7rem;
  padding: .6rem .85rem;
  outline: none;
  transition: border-color .18s, box-shadow .18s;
}

.field:focus-visible {
  border-color: var(--brand-end);
  box-shadow: 0 0 0 3px rgba(10, 10, 11, .15);
}

.pg-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 14px;
  margin-bottom: 12px;
}

.sel { max-width: 340px; appearance: auto; cursor: pointer; }

.area { resize: vertical; min-height: 110px; line-height: 1.5; }

.switchline {
  display: inline-flex;
  align-items: center;
  gap: .55rem;
  font-size: .86rem;
  font-weight: 500;
  color: var(--mute);
  cursor: pointer;
  user-select: none;
}

.switchline input { position: absolute; opacity: 0; pointer-events: none; }

.switch {
  width: 36px;
  height: 21px;
  border-radius: 99px;
  background: #D4D4D8;
  position: relative;
  transition: background-color .2s;
  flex: none;
}

.switch::after {
  content: '';
  position: absolute;
  top: 2.5px;
  left: 2.5px;
  width: 16px;
  height: 16px;
  border-radius: 99px;
  background: #fff;
  box-shadow: 0 1px 3px rgba(9, 9, 11, .25);
  transition: transform .2s cubic-bezier(.16, 1, .3, 1);
}

.switchline input:checked + .switch {
  background: linear-gradient(100deg, var(--brand-start), var(--brand-end));
}

.switchline input:checked + .switch::after { transform: translateX(15px); }
.switchline input:focus-visible + .switch { box-shadow: 0 0 0 3px rgba(10, 10, 11, .2); }

/* ═══ terminal-ish blocks ═══ */
.termlog {
  background: #0A0A0B;
  color: #E4E4E7;
  border-radius: .8rem;
  padding: 1rem 1.1rem;
  overflow-x: auto;
  font-family: 'JetBrains Mono', monospace;
  font-size: .8rem;
  line-height: 1.65;
  white-space: pre-wrap;
  word-break: break-word;
}

.termlog::-webkit-scrollbar { height: 8px; }
.termlog::-webkit-scrollbar-thumb { background: #3F3F46; border: 0; }

.connlog { margin-bottom: 14px; max-height: 220px; overflow-y: auto; }
.connlog.ok   { box-shadow: inset 0 0 0 1px rgba(228, 228, 231, .65); }
.connlog.fail { box-shadow: inset 0 0 0 1px rgba(82, 82, 91, .9); }

.snippet { margin: 0; }

.reasoning-text {
  max-height: 240px;
  overflow-y: auto;
  margin-top: 10px;
  color: #A1A1AA;
}

.dim { color: var(--faint); }
.errline { color: #D4D4D8; }

/* reasoning collapsible */
.reasoning {
  margin-top: 14px;
  border: 1px dashed var(--line);
  border-radius: .7rem;
  padding: .55rem .85rem;
}

.reasoning summary {
  display: inline-flex;
  align-items: center;
  gap: .45rem;
  cursor: pointer;
  font-size: .82rem;
  font-weight: 600;
  color: var(--mute);
  list-style: none;
}

.reasoning summary::-webkit-details-marker { display: none; }
.reasoning summary:hover { color: var(--ink); }

/* output / markdown */
.output {
  margin-top: 16px;
  max-height: 480px;
  overflow-y: auto;
}

.output.md {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: .8rem;
  color: var(--ink-soft);
  padding: 1.05rem 1.2rem;
  font-family: 'Inter', system-ui, sans-serif;
  font-size: .92rem;
}

.output.md p { margin: 0 0 .7em; }
.output.md p:last-child { margin-bottom: 0; }

.output.md h2, .output.md h3, .output.md h4 { margin: 1em 0 .45em; line-height: 1.3; }
.output.md h2 { font-size: 1.15em; }
.output.md h3 { font-size: 1.05em; }
.output.md h4 { font-size: .98em; }

.output.md a { color: var(--ink); text-decoration: none; }
.output.md a:hover { text-decoration: underline; }

a.cite {
  font-size: .74em;
  font-weight: 600;
  padding: .08em .4em;
  border-radius: .4rem;
  background: #F4F4F5;
  color: #0A0A0B !important;
}

.output.md code {
  background: var(--line-soft);
  border-radius: .3rem;
  padding: .1em .35em;
  font-size: .84em;
  color: var(--ink-soft);
}

.codeblock {
  background: #0A0A0B;
  color: #E4E4E7;
  border-radius: .6rem;
  padding: .8rem .95rem;
  overflow-x: auto;
  font-family: 'JetBrains Mono', monospace;
  font-size: .78rem;
  line-height: 1.6;
}

.mdlist { margin: .3em 0 .7em; padding-left: 1.25em; }
.mdlist li { margin: .25em 0; }
.mdlist ul { margin: .2em 0; }

.tablewrap { overflow-x: auto; margin: .6em 0; }

.mdtable { border-collapse: collapse; width: 100%; font-size: .87em; }
.mdtable th, .mdtable td {
  border: 1px solid var(--line);
  padding: .45em .7em;
  text-align: left;
}
.mdtable th { background: var(--line-soft); font-weight: 600; }

blockquote {
  margin: .6em 0;
  padding: .35em .95em;
  border-left: 3px solid var(--ink);
  background: var(--line-soft);
  border-radius: 0 .5rem .5rem 0;
  color: var(--mute);
}

hr { border: 0; border-top: 1px solid var(--line); margin: 1em 0; }
del { color: var(--faint); }

/* ═══ docs tab bits ═══ */
.copyline {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: .65rem .9rem;
}

.card-inset { background: var(--line-soft); border: 1px solid var(--line); border-radius: .7rem; }
.copyline code { flex: 1; min-width: 0; word-break: break-all; font-size: .84rem; }

.note {
  margin-top: 1.5rem;
  padding: .95rem 1.1rem;
  border: 1px solid #FDE68A;
  border-radius: .7rem;
  background: #FFFBEB;
  color: #92400E;
  font-size: .86rem;
  line-height: 1.6;
}

.note b { font-weight: 700; }
.note code { background: #FEF3C7; border-radius: .3rem; padding: .06em .3em; }

/* ═══ panels ═══ */
.panel { display: none; }
.panel.active { display: block; animation: fade-up .35s cubic-bezier(.16, 1, .3, 1) both; }

.panel-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}

.panel-head h2 {
  margin: 0;
  font-size: 1.18rem;
  font-weight: 700;
  letter-spacing: -.01em;
}

/* ═══ footer ═══ */
.statusbar {
  border-top: 1px solid var(--line);
  background: var(--card);
}

.statusbar-inner {
  max-width: 1020px;
  margin: 0 auto;
  padding: 13px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  font-size: .76rem;
  color: var(--faint);
}

#sbLeft { transition: color .3s; }
#sbLeft.on { color:  #0A0A0B; font-weight: 600; }

/* ═══ toasts ═══ */
.toasts {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 90;
  display: flex;
  flex-direction: column;
  gap: 10px;
  pointer-events: none;
}

.toast {
  min-width: 220px;
  max-width: min(360px, calc(100vw - 40px));
  padding: .7rem 1rem;
  border-radius: .75rem;
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--ink-soft);
  font-size: .84rem;
  font-weight: 500;
  box-shadow: 0 10px 30px -10px rgba(9, 9, 11, .22);
  animation: toast-in .28s cubic-bezier(.16, 1, .3, 1) both;
}

@keyframes toast-in {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: none; }
}

.toast.ok  { border-color: #0A0A0B; color: #0A0A0B; }
.toast.err { border-color: #A1A1AA; background: #F4F4F5; color: #18181B; }

/* ═══ responsive ═══ */
@media (max-width: 680px) {
  .topbar-inner { flex-wrap: wrap; height: auto; padding: 10px 16px; row-gap: 8px; }
  .tabs { order: 3; width: 100%; }
  .container { padding: 18px 14px 32px; }
  .card.pad { padding: 18px; }
  .statgrid { grid-template-columns: 1fr 1fr; }
  .pg-row { align-items: stretch; flex-direction: column; }
  .sel { max-width: none; }
}


/* ═══ shell / sidebar ═══ */
body { display: block; }

.container { max-width: 1152px; }

.shell { display: flex; min-height: 100vh; align-items: stretch; }

.sidebar {
  position: fixed;
  inset-block: 0;
  left: 0;
  z-index: 50;
  width: 264px;
  display: flex;
  flex-direction: column;
  background: var(--card);
  border-right: 1px solid var(--line);
}

.side-head {
  height: 62px;
  display: flex;
  align-items: center;
  padding: 0 20px;
  border-bottom: 1px solid var(--line-soft);
}

.side-nav { flex: 1; padding: 18px 16px; overflow-y: auto; }

.side-cap {
  margin: 0 0 8px;
  padding: 0 10px;
  font-size: .68rem;
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--faint);
}

.navlink {
  position: relative;
  display: flex;
  align-items: center;
  gap: .65rem;
  width: 100%;
  border: 0;
  background: transparent;
  text-align: left;
  padding: .6rem .8rem;
  border-radius: .6rem;
  font: inherit;
  font-size: .9rem;
  font-weight: 500;
  color: var(--mute);
  cursor: pointer;
  transition: color .18s, background-color .18s;
}

.navlink:hover { color: var(--ink); background: var(--line-soft); }

.navlink.active { color: #0A0A0B; background: #F4F4F5; font-weight: 600; }

.navlink.active::before {
  content: '';
  position: absolute;
  left: -16px;
  top: 18%;
  bottom: 18%;
  width: 3px;
  border-radius: 99px;
  background: linear-gradient(180deg, var(--brand-start), var(--brand-end));
}

.side-foot { padding: 16px; border-top: 1px solid var(--line-soft); }

.side-promo {
  margin-bottom: 12px;
  padding: 12px 14px;
  border-radius: .75rem;
  border: 1px solid #BFDBFE;
  background: linear-gradient(135deg, rgba(239, 246, 255, .85), rgba(236, 254, 255, .55));
}

.promo-title {
  display: flex;
  align-items: center;
  gap: .45rem;
  font-size: .76rem;
  font-weight: 700;
  color: var(--ink-soft);
  margin-bottom: 4px;
}

.side-promo p { margin: 0; font-size: .73rem; line-height: 1.55; color: var(--mute); }

.side-ver { margin: 10px 0 0; font-size: .72rem; color: var(--faint); transition: color .3s; }
#sbLeft.on { color:  #0A0A0B; font-weight: 600; }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; margin-left: 264px; }

.pagehead {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  height: 62px;
  padding: 0 28px;
  background: rgba(248, 250, 252, .85);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
}

.pagehead h1 {
  margin: 0;
  font-size: 1.02rem;
  font-weight: 600;
  letter-spacing: -.01em;
  color: var(--ink);
}

/* ═══ model cards ═══ */
.mgrid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(215px, 1fr));
  gap: 14px;
  margin-bottom: 18px;
}

.mcard {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  text-align: left;
  gap: 4px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--card);
  font: inherit;
  cursor: pointer;
  transition: box-shadow .22s, border-color .22s, transform .22s;
  animation: fade-up .4s cubic-bezier(.16, 1, .3, 1) both;
}

.mcard:hover {
  border-color: #D4D4D8;
  box-shadow: 0 12px 30px -12px rgba(9, 9, 11, .15);
  transform: translateY(-2px);
}

.mcard.selected {
  border-color: transparent;
  box-shadow: 0 0 0 2px var(--ink), 0 10px 26px -12px rgba(9, 9, 11, .4);
}

.mlogo {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  padding: 7px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
  margin-bottom: 6px;
}

.mlogo img { width: 100%; height: 100%; object-fit: contain; }

.mname {
  font-size: .95rem;
  font-weight: 700;
  color: var(--ink);
  letter-spacing: -.01em;
}

.mdesc {
  font-size: .8rem;
  line-height: 1.5;
  color: var(--mute);
  min-height: 2.9em;
}

.mid {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-top: 10px;
  padding: .5rem .7rem;
  border: 1px solid var(--line);
  border-radius: .55rem;
  background: var(--line-soft);
}

.mid code {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: .72rem;
  font-weight: 600;
  color: var(--ink-soft);
}

.mcheck { width: 13px; height: 13px; color: #fff; opacity: 0; transform: scale(.6); transition: opacity .18s, transform .18s; flex: none; }

.selected .mcheck { opacity: 1; transform: none; color: var(--ink); }

.mtags { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; padding-top: 10px; border-top: 1px solid var(--line-soft); }

.mtag {
  font-style: normal;
  font-size: .68rem;
  font-weight: 600;
  padding: .14rem .55rem;
  border-radius: 99px;
  border: 1px solid var(--line);
  color: var(--mute);
}

.tag-search { border-color: #D4D4D8; background: #FAFAFA; color: #18181B; }
.tag-think  { border-color: #E4E4E7; background: #F4F4F5; color: #3F3F46; }
.tag-def    { border-color: #0A0A0B; background: #0A0A0B; color: #FFFFFF; }

.pg-row-top { margin-bottom: 12px; }

/* ═══ responsive ═══ */
@media (max-width: 900px) {
  .shell { flex-direction: column; }

  .sidebar {
    position: sticky;
    top: 0;
    width: 100%;
    flex-direction: row;
    align-items: center;
    gap: 10px;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .side-head { height: auto; border: 0; padding: 10px 14px; }
  .side-nav { display: flex; flex: 1; padding: 6px; gap: 4px; overflow-x: auto; }
  .side-cap, .side-promo, #connBadgeTop { display: none; }
  .side-foot { border: 0; padding: 6px 10px 6px 0; margin-left: auto; }
  .navlink.active::before { display: none; }
  .main { margin-left: 0; }
  .pagehead { padding: 0 16px; }
  .container { padding: 18px 16px 32px; }
}


/* ═══ api keys ═══ */
.newkey {
  margin-top: 14px;
  padding: 14px 16px;
  border-color: #0A0A0B;
  background: #FAFAFA;
  animation: fade-up .35s cubic-bezier(.16, 1, .3, 1) both;
}

.newkey-cap {
  margin: 0 0 8px;
  font-size: .78rem;
  font-weight: 600;
  color: #0A0A0B;
}

.krow {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: .7rem .9rem;
  border: 1px solid var(--line);
  border-radius: .7rem;
  margin-bottom: 8px;
  transition: border-color .18s, box-shadow .18s;
}

.krow:hover { border-color: #D4D4D8; box-shadow: 0 4px 14px -8px rgba(9, 9, 11, .15); }

.kname { font-weight: 600; font-size: .88rem; color: var(--ink); min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.kprefix {
  font-family: 'JetBrains Mono', monospace;
  font-size: .76rem;
  color: var(--mute);
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.kdate { margin-left: auto; font-size: .76rem; color: var(--faint); flex: none; }

.kdel { color: var(--mute); }
.krow:hover .kdel:hover { color: #0A0A0B; border-color: #0A0A0B; background: #F4F4F5; }


/* ═══ chat ═══ */
.chatlog {
  display: flex;
  flex-direction: column;
  gap: 14px;
  max-height: 52vh;
  overflow-y: auto;
  padding: 16px;
  background: #FAFAFA;
  border: 1px solid var(--line);
  border-radius: .8rem;
  margin-bottom: 12px;
}

.chat-hint { text-align: center; margin: auto; }

.msg {
  max-width: 86%;
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.msg.user { align-self: flex-end; align-items: flex-end; }
.msg.assistant { align-self: flex-start; align-items: stretch; }

.msg .who {
  font-size: .66rem;
  font-weight: 700;
  letter-spacing: .07em;
  text-transform: uppercase;
  color: var(--faint);
  padding: 0 .3rem;
}

.msg .body {
  padding: .65rem .95rem;
  border-radius: .95rem;
  font-size: .9rem;
  line-height: 1.6;
  word-break: break-word;
}

.msg.user .body {
  background: var(--ink);
  color: #FFFFFF;
  border-bottom-right-radius: .3rem;
  white-space: pre-wrap;
}

.msg.assistant .body {
  background: var(--card);
  border: 1px solid var(--line);
  border-bottom-left-radius: .3rem;
}

.msg.pending .body { opacity: .7; }

.msg .body p { margin: 0 0 .6em; }
.msg .body p:last-child, .msg .body :last-child { margin-bottom: 0; }
.msg .body ul, .msg .body ol { margin: .3em 0 .6em; padding-left: 1.25em; }
.msg .body h2, .msg .body h3, .msg .body h4 { margin: .7em 0 .35em; }
.msg .body a { color: var(--ink); text-decoration: underline; }
.msg .body blockquote { margin: .5em 0; padding: .3em .9em; border-left: 3px solid #0A0A0B; background: #F4F4F5; }
.msg .body hr { border: 0; border-top: 1px solid var(--line); }

.msg .body code {
  background: var(--line-soft);
  border-radius: .3rem;
  padding: .08em .32em;
  font-size: .85em;
}

.msg.user .body code { background: rgba(255, 255, 255, .18); }

.msg .body pre.codeblock {
  background: #0A0A0B;
  color: #E4E4E7;
  border-radius: .6rem;
  padding: .75rem .9rem;
  overflow-x: auto;
  font-family: 'JetBrains Mono', monospace;
  font-size: .78rem;
  line-height: 1.6;
  margin: .5em 0;
}

.tablewrap { overflow-x: auto; margin: .5em 0; }

.chat-input {
  display: flex;
  align-items: flex-end;
  gap: 10px;
}

.chat-input .area { flex: 1; resize: none; min-height: 52px; max-height: 180px; line-height: 1.5; }

.btn-send { height: 52px; width: 56px; padding: 0; justify-content: center; }

.chat-foot {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-top: 10px;
}

.chat-foot #pgStatus { margin-left: auto; }

@media (max-width: 680px) {
  .msg { max-width: 96%; }
}


/* ═══ гейт подписки ═══ */
a.btn { text-decoration: none; }

.subgate {
  padding: 16px 18px;
  border-color: #0A0A0B;
  background: #FAFAFA;
  animation: fade-up .35s cubic-bezier(.16, 1, .3, 1) both;
}

.sub-title {
  margin: 0 0 5px;
  font-size: .9rem;
  font-weight: 600;
  color: var(--ink);
}

.sub-sub {
  margin: 0 0 14px;
  max-width: 64ch;
  font-size: .82rem;
  line-height: 1.55;
  color: var(--mute);
}

.sub-sub strong { color: var(--ink); font-weight: 600; }

.sub-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }

.substrip { margin: 10px 0 0; font-size: .76rem; color: var(--faint); }
.substrip a { color: var(--mute); text-decoration: underline; text-underline-offset: 2px; }
.substrip a:hover { color: var(--ink); }

@media (max-width: 640px) {
  .sub-actions { flex-direction: column; align-items: stretch; }
}
