/* ============================================================
   Аксель — gateway styles
   palette: calm blue + warm coral accent (Gergert SUP family)
   ============================================================ */

:root {
  --primary:       #3B82F6;
  --primary-hover: #2563EB;
  --primary-dark:  #1D4ED8;
  --primary-50:    #EFF6FF;
  --primary-100:   #DBEAFE;
  --primary-200:   #BFDBFE;

  --accent:        #F97316;
  --accent-hover:  #EA580C;

  --text:          #0F172A;
  --text-2:        #334155;
  --muted:         #64748B;
  --muted-2:       #94A3B8;

  --bg:            #F8FAFC;
  --card:          #FFFFFF;
  --border:        #E2E8F0;

  --ok:            #047857;
  --ok-bg:         #ECFDF5;
  --warn:          #B45309;
  --warn-bg:       #FEF3C7;
  --err:           #B91C1C;
  --err-bg:        #FEE2E2;

  --r-sm: 8px;
  --r-md: 12px;
  --r-lg: 16px;
  --r-xl: 20px;

  --shadow-sm: 0 4px 12px rgba(15, 23, 42, .05);
  --shadow-md: 0 8px 24px rgba(15, 23, 42, .08);
  --shadow-lg: 0 16px 40px rgba(15, 23, 42, .12);

  --max: 920px;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  font-family: 'Manrope', system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-weight: 500;
  font-size: 16px;
  color: var(--text);
  background: var(--bg);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

img { max-width: 100%; display: block; }
a { color: var(--primary); text-decoration: none; }
a:hover { color: var(--primary-hover); }
button { font-family: inherit; cursor: pointer; }

h1, h2, h3, h4 {
  margin: 0 0 .6em;
  letter-spacing: -.015em;
  line-height: 1.2;
  font-weight: 800;
}
h1 { font-size: clamp(2rem, 5vw, 3rem); }
h2 { font-size: clamp(1.5rem, 3vw, 2rem); }
h3 { font-size: 1.25rem; font-weight: 700; }
h4 { font-size: 1.05rem; font-weight: 700; }

p { margin: 0 0 1em; }

code {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  background: var(--primary-50);
  color: var(--primary-dark);
  padding: 1px 6px;
  border-radius: 4px;
  font-size: .9em;
}

hr {
  border: 0;
  border-top: 1px solid var(--border);
  margin: 1.5rem 0;
}

/* ============================================================
   LAYOUT
   ============================================================ */
.container {
  max-width: var(--max);
  margin: 0 auto;
  padding: 0 20px;
}
.container-wide { max-width: 1180px; }

main.page {
  padding: 24px 0 60px;
  min-height: calc(100vh - 70px - 100px);
}

section { margin-bottom: 2rem; }

/* ============================================================
   TOP NAV
   ============================================================ */
.topnav {
  background: rgba(255, 255, 255, .85);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 50;
}
.topnav-inner {
  display: flex;
  align-items: center;
  height: 64px;
  gap: 20px;
}
.brand {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-weight: 800;
  font-size: 18px;
  color: var(--text);
  letter-spacing: -.01em;
}
.brand:hover { color: var(--text); }
.brand-mark {
  width: 28px; height: 28px;
  border-radius: 8px;
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 14px;
  font-weight: 800;
  box-shadow: 0 2px 8px rgba(59, 130, 246, .3);
}
.nav-actions {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 18px;
  font-weight: 600;
  font-size: 15px;
}
.nav-actions a {
  color: var(--text-2);
}
.nav-actions a:hover { color: var(--primary); }
.nav-actions .sep { color: var(--muted-2); }

/* «Привязать Telegram» кнопка в topnav */
.nav-tg-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: linear-gradient(135deg, #0088cc 0%, #229ed9 100%);
  color: #fff;
  border: 0;
  border-radius: 999px;
  padding: 7px 14px;
  font-family: inherit;
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
  letter-spacing: -.005em;
  box-shadow: 0 2px 8px rgba(34, 158, 217, .25);
  transition: transform .15s ease, box-shadow .15s ease, filter .15s ease;
}
.nav-tg-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 14px rgba(34, 158, 217, .35);
  filter: brightness(1.05);
}
.nav-tg-btn svg { display: block; }

/* ============================================================
   MODAL (overlay + card)
   ============================================================ */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, .55);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
  padding: 20px;
  animation: modal-fade .18s ease-out;
}
.modal-overlay[hidden] { display: none; }
.modal-card {
  position: relative;
  background: var(--card, #fff);
  border-radius: 18px;
  padding: 32px 28px 24px;
  max-width: 440px;
  width: 100%;
  box-shadow: 0 20px 60px rgba(15, 23, 42, .25);
  animation: modal-pop .2s ease-out;
}
.modal-card h2 {
  margin: 0 0 12px;
  font-size: 22px;
  font-weight: 800;
  letter-spacing: -.01em;
}
.modal-desc {
  margin: 0 0 22px;
  font-size: 14px;
  line-height: 1.55;
  color: var(--muted, #64748b);
}
.modal-close {
  position: absolute;
  top: 12px; right: 12px;
  width: 32px; height: 32px;
  border: 0;
  background: transparent;
  border-radius: 999px;
  font-size: 22px;
  line-height: 1;
  color: var(--muted, #64748b);
  cursor: pointer;
  transition: background .15s ease, color .15s ease;
}
.modal-close:hover {
  background: var(--primary-50, rgba(59, 130, 246, .1));
  color: var(--text, #0f172a);
}
.modal-cta {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  padding: 14px 20px;
  font-size: 16px;
  background: linear-gradient(135deg, #0088cc 0%, #229ed9 100%);
  color: #fff;
  box-shadow: 0 6px 18px rgba(34, 158, 217, .3);
}
.modal-cta:hover {
  background: linear-gradient(135deg, #0077b5 0%, #1c8dc4 100%);
  color: #fff;
  transform: translateY(-1px);
  box-shadow: 0 10px 24px rgba(34, 158, 217, .4);
}
.modal-cancel {
  display: block;
  width: 100%;
  margin-top: 10px;
  padding: 10px 16px;
  font-size: 14px;
}
body.modal-open { overflow: hidden; }

@keyframes modal-fade {
  from { opacity: 0; }
  to   { opacity: 1; }
}
@keyframes modal-pop {
  from { opacity: 0; transform: translateY(8px) scale(.98); }
  to   { opacity: 1; transform: translateY(0)   scale(1);    }
}

/* ============================================================
   FOOTER
   ============================================================ */
.site-footer {
  border-top: 1px solid var(--border);
  background: var(--card);
  padding: 28px 0;
  color: var(--muted);
  font-size: 14px;
  margin-top: 3rem;
}
.footer-inner {
  display: flex;
  flex-wrap: wrap;
  gap: 18px;
  justify-content: space-between;
  align-items: center;
}
.footer-links { display: flex; gap: 18px; flex-wrap: wrap; }
.footer-links a { color: var(--muted); }
.footer-links a:hover { color: var(--primary); }

/* ============================================================
   CARDS
   ============================================================ */
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 24px;
  box-shadow: var(--shadow-sm);
}
.card + .card { margin-top: 16px; }
.card h3:first-child,
.card h2:first-child { margin-top: 0; }

.card-narrow {
  max-width: 460px;
  margin: 40px auto;
}

/* ============================================================
   BUTTONS
   ============================================================ */
.btn,
button.btn,
a.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-family: inherit;
  font-weight: 700;
  font-size: 15px;
  padding: 12px 22px;
  border: 0;
  border-radius: 999px;
  text-decoration: none;
  transition: all .2s ease;
  letter-spacing: -.005em;
  cursor: pointer;
  line-height: 1;
}

.btn-primary {
  background: var(--primary);
  color: #fff;
  box-shadow: 0 6px 18px rgba(59, 130, 246, .25);
}
.btn-primary:hover {
  background: var(--primary-hover);
  color: #fff;
  transform: translateY(-1px);
  box-shadow: 0 10px 24px rgba(59, 130, 246, .35);
}

.btn-accent {
  background: var(--accent);
  color: #fff;
  box-shadow: 0 6px 18px rgba(249, 115, 22, .35);
}
.btn-accent:hover {
  background: var(--accent-hover);
  color: #fff;
  transform: translateY(-1px);
  box-shadow: 0 10px 24px rgba(249, 115, 22, .45);
}

.btn-secondary {
  background: var(--card);
  color: var(--text-2);
  border: 1.5px solid var(--border);
}
.btn-secondary:hover {
  border-color: var(--primary);
  color: var(--primary);
}

.btn-ghost {
  background: transparent;
  color: var(--text-2);
  border: 1.5px solid transparent;
}
.btn-ghost:hover {
  background: var(--primary-50);
  color: var(--primary-dark);
}

.btn-danger {
  background: var(--card);
  color: var(--err);
  border: 1.5px solid var(--err-bg);
}
.btn-danger:hover {
  background: var(--err-bg);
  color: var(--err);
}

.btn-sm { padding: 8px 14px; font-size: 13px; }
.btn-block { width: 100%; }

/* ============================================================
   FORMS
   ============================================================ */
.form-field { margin-bottom: 1rem; }
.form-field label {
  display: block;
  font-weight: 600;
  font-size: 14px;
  color: var(--text-2);
  margin-bottom: 6px;
}

input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
input[type="month"],
input[type="search"],
textarea,
select {
  width: 100%;
  font-family: inherit;
  font-size: 15px;
  font-weight: 500;
  padding: 12px 14px;
  border: 1.5px solid var(--border);
  border-radius: var(--r-md);
  background: var(--card);
  color: var(--text);
  transition: border-color .15s, background .15s, box-shadow .15s;
}
input:focus,
textarea:focus,
select:focus {
  outline: 0;
  border-color: var(--primary);
  background: #fff;
  box-shadow: 0 0 0 3px rgba(59, 130, 246, .15);
}
textarea { resize: vertical; min-height: 96px; line-height: 1.5; }
select { cursor: pointer; }

/* radio cards (onboarding) */
.radio-list { display: flex; flex-direction: column; gap: 8px; margin: 4px 0 0; }
.radio-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  border: 1.5px solid var(--border);
  border-radius: var(--r-md);
  background: var(--card);
  cursor: pointer;
  transition: all .15s;
  font-size: 15px;
  font-weight: 500;
}
.radio-card:hover {
  border-color: var(--primary-200);
  background: var(--primary-50);
}
.radio-card input[type="radio"] {
  width: 18px; height: 18px;
  accent-color: var(--primary);
  margin: 0;
  flex-shrink: 0;
}
.radio-card:has(input:checked) {
  border-color: var(--primary);
  background: var(--primary-50);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, .12);
}

/* ============================================================
   ALERTS
   ============================================================ */
.alert {
  padding: 12px 16px;
  border-radius: var(--r-md);
  font-size: 14px;
  margin: 0 0 1rem;
  border: 1px solid transparent;
}
.alert-err { background: var(--err-bg); color: var(--err); border-color: rgba(185, 28, 28, .15); }
.alert-ok  { background: var(--ok-bg); color: var(--ok); border-color: rgba(4, 120, 87, .15); }
.alert-warn { background: var(--warn-bg); color: var(--warn); border-color: rgba(180, 83, 9, .15); }
.alert strong { font-weight: 800; }

/* ============================================================
   UTILITIES
   ============================================================ */
.muted { color: var(--muted); }
.text-sm { font-size: 13px; }
.text-xs { font-size: 12px; }
.center { text-align: center; }
.mt-0 { margin-top: 0; }
.mt-1 { margin-top: .5rem; }
.mt-2 { margin-top: 1rem; }
.mt-3 { margin-top: 1.5rem; }
.mb-0 { margin-bottom: 0; }
.mb-1 { margin-bottom: .5rem; }
.mb-2 { margin-bottom: 1rem; }
.flex { display: flex; }
.flex-between { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.flex-wrap { flex-wrap: wrap; }
.gap-1 { gap: .5rem; }
.gap-2 { gap: 1rem; }

.tag {
  display: inline-block;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .06em;
  text-transform: uppercase;
  padding: 3px 9px;
  border-radius: 999px;
  background: var(--primary-50);
  color: var(--primary-dark);
  border: 1px solid var(--primary-100);
}
.tag-accent { background: rgba(249, 115, 22, .12); color: var(--accent-hover); border-color: rgba(249, 115, 22, .25); }

.badge {
  display: inline-block;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .04em;
  padding: 3px 8px;
  border-radius: 999px;
  background: var(--bg);
  color: var(--text-2);
  border: 1px solid var(--border);
}
.badge-ok      { background: var(--ok-bg); color: var(--ok); border-color: rgba(4,120,87,.2); }
.badge-err     { background: var(--err-bg); color: var(--err); border-color: rgba(185,28,28,.2); }
.badge-admin   { background: var(--primary-50); color: var(--primary-dark); border-color: var(--primary-100); }
.badge-web     { background: var(--primary-50); color: var(--primary-dark); border-color: var(--primary-100); }
.badge-tg      { background: var(--ok-bg); color: var(--ok); border-color: rgba(4,120,87,.2); }
.badge-both    { background: var(--warn-bg); color: var(--warn); border-color: rgba(180,83,9,.2); }

/* ============================================================
   HERO (landing)
   ============================================================ */
.hero {
  padding: 60px 0 40px;
  text-align: center;
}
.hero-eyebrow {
  display: inline-block;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--primary-dark);
  background: var(--primary-50);
  border: 1px solid var(--primary-100);
  padding: 6px 14px;
  border-radius: 999px;
  margin-bottom: 20px;
}
.hero h1 {
  font-size: clamp(2.2rem, 6vw, 3.4rem);
  margin: 0 0 16px;
  letter-spacing: -.025em;
}
.hero .lead {
  font-size: clamp(1rem, 2vw, 1.2rem);
  color: var(--muted);
  max-width: 600px;
  margin: 0 auto 32px;
}
.hero-cta {
  display: flex;
  gap: 12px;
  justify-content: center;
  flex-wrap: wrap;
}

.features-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 16px;
  margin: 48px 0;
}
.feature-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 24px;
  box-shadow: var(--shadow-sm);
  transition: transform .25s, box-shadow .25s;
}
.feature-card:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-md);
}
.feature-icon {
  width: 44px; height: 44px;
  border-radius: 12px;
  background: linear-gradient(135deg, var(--primary-50) 0%, var(--primary-100) 100%);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 12px;
  color: var(--primary-dark);
}
.feature-card h3 {
  margin: 0 0 6px;
  font-size: 17px;
  font-weight: 800;
}
.feature-card p {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.55;
}

.price-block {
  background: linear-gradient(135deg, var(--primary-50) 0%, #fff 100%);
  border: 1px solid var(--primary-100);
  border-radius: var(--r-xl);
  padding: 32px;
  text-align: center;
  margin: 32px 0;
}
.price-block .price {
  font-size: 2.4rem;
  font-weight: 800;
  letter-spacing: -.02em;
  color: var(--text);
  margin-bottom: 8px;
}
.price-block .price-note {
  color: var(--muted);
  font-size: 14px;
  margin: 0;
}

/* ============================================================
   ONBOARDING
   ============================================================ */
.onb-progress {
  display: flex;
  align-items: center;
  gap: 8px;
  justify-content: center;
  margin: 8px 0 28px;
}
.onb-dot {
  width: 10px; height: 10px;
  border-radius: 50%;
  background: var(--border);
  transition: all .25s;
}
.onb-dot.active {
  background: var(--primary);
  width: 32px;
  border-radius: 5px;
}
.onb-dot.done {
  background: var(--primary-200);
}
.step-counter {
  text-align: center;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .12em;
  color: var(--muted);
  margin-bottom: 6px;
}
.onb-card {
  max-width: 540px;
  margin: 24px auto;
}
.onb-actions {
  display: flex;
  gap: 12px;
  margin-top: 24px;
}
.onb-actions .btn { flex: 1; }
.onb-save-later {
  text-align: center;
  margin-top: 16px;
  font-size: 13px;
}
.onb-save-later button {
  background: none;
  border: 0;
  padding: 0;
  color: var(--muted);
  text-decoration: underline;
  cursor: pointer;
  font-size: 13px;
  font-family: inherit;
}

/* ============================================================
   CHAT
   ============================================================ */
body.chat-page {
  height: 100vh;
  overflow: hidden;
  background: var(--bg);
}
.chat-wrap {
  display: flex;
  flex-direction: column;
  height: calc(100vh - 64px);
  max-width: 920px;
  margin: 0 auto;
  padding: 0 20px;
}
.chat-header {
  padding: 16px 0 8px;
  flex-shrink: 0;
}
.chat-header h1 {
  font-size: 1.4rem;
  margin: 0 0 2px;
}
.chat-header .meta {
  color: var(--muted);
  font-size: 13px;
}
#log {
  flex: 1;
  overflow-y: auto;
  padding: 16px 4px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  scroll-behavior: smooth;
}
.msg {
  display: flex;
  flex-direction: column;
  max-width: 80%;
  animation: msgIn .2s ease;
}
@keyframes msgIn {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}
.msg.user {
  align-self: flex-end;
  align-items: flex-end;
}
.msg.assistant,
.msg.error {
  align-self: flex-start;
  align-items: flex-start;
}
.msg .body {
  padding: 12px 16px;
  border-radius: 18px;
  font-size: 15px;
  line-height: 1.55;
  word-wrap: break-word;
  overflow-wrap: anywhere;
}
.msg.user .body {
  background: var(--primary);
  color: #fff;
  border-bottom-right-radius: 4px;
  white-space: pre-wrap;
  box-shadow: 0 4px 14px rgba(59, 130, 246, .25);
}
.msg.user .body a { color: #cfe1ff; text-decoration: underline; }
.msg.assistant .body {
  background: var(--card);
  color: var(--text);
  border: 1px solid var(--border);
  border-bottom-left-radius: 4px;
  box-shadow: var(--shadow-sm);
}
.msg.error .body {
  background: var(--err-bg);
  color: var(--err);
  border: 1px solid rgba(185, 28, 28, .2);
  border-bottom-left-radius: 4px;
}
.msg .body p:first-child { margin-top: 0; }
.msg .body p:last-child  { margin-bottom: 0; }
.msg .body p { margin: .5em 0; }
.msg .body h1,
.msg .body h2,
.msg .body h3 { font-size: 1.05rem; margin: .7em 0 .3em; }
.msg .body code {
  background: rgba(15, 23, 42, .07);
  color: var(--text);
  padding: 1px 5px;
  border-radius: 4px;
  font-size: .88em;
}
.msg.user .body code { background: rgba(255,255,255,.22); color: #fff; }
.msg .body pre {
  background: #1e293b;
  color: #e2e8f0;
  padding: 12px 14px;
  border-radius: 10px;
  overflow-x: auto;
  font-size: 13px;
  margin: .5em 0;
  line-height: 1.45;
}
.msg .body pre code { background: none; color: inherit; padding: 0; }
.msg .body ul,
.msg .body ol { margin: .4em 0; padding-left: 1.4em; }
.msg .body blockquote {
  border-left: 3px solid var(--primary-200);
  margin: .5em 0;
  padding: .1em .8em;
  color: var(--muted);
}
.cursor {
  display: inline-block;
  width: 6px; height: 1em;
  background: currentColor;
  vertical-align: -2px;
  margin-left: 2px;
  animation: blink 1s step-end infinite;
  opacity: .6;
}
@keyframes blink { 50% { opacity: 0; } }

.chat-form {
  flex-shrink: 0;
  padding: 12px 0 16px;
  border-top: 1px solid var(--border);
  background: var(--bg);
}
.chat-input-row {
  display: flex;
  gap: 10px;
  align-items: flex-end;
  background: var(--card);
  border: 1.5px solid var(--border);
  border-radius: 22px;
  padding: 8px 8px 8px 16px;
  transition: border-color .15s, box-shadow .15s;
}
.chat-input-row:focus-within {
  border-color: var(--primary);
  box-shadow: 0 0 0 4px rgba(59, 130, 246, .1);
}
.chat-input-row textarea {
  flex: 1;
  border: 0;
  background: transparent;
  padding: 6px 0;
  min-height: 24px;
  max-height: 200px;
  font-size: 15px;
  resize: none;
  line-height: 1.45;
  font-family: inherit;
}
.chat-input-row textarea:focus {
  outline: 0;
  background: transparent;
  box-shadow: none;
}
.send-btn {
  width: 40px; height: 40px;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  border: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: all .15s;
  padding: 0;
  box-shadow: 0 4px 12px rgba(59, 130, 246, .3);
}
.send-btn:hover:not(:disabled) {
  background: var(--primary-hover);
  transform: scale(1.05);
}
.send-btn:disabled {
  background: var(--muted-2);
  cursor: not-allowed;
  box-shadow: none;
}
.send-btn svg { width: 18px; height: 18px; }
.send-btn .icon-stop { display: none; }
.send-btn.is-stop { background: #ef4444; }
.send-btn.is-stop:hover { background: #dc2626; transform: scale(1.05); }
.send-btn.is-stop .icon-send { display: none; }
.send-btn.is-stop .icon-stop { display: block; }
.msg-stopped-note {
  margin-top: 6px;
  font-size: 12px;
  color: var(--muted);
  font-style: italic;
}
.chat-hint {
  font-size: 12px;
  color: var(--muted);
  text-align: center;
  margin: 8px 0 0;
}

/* ---------- icon buttons (mic / attach) ---------- */
.icon-btn {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: transparent;
  color: var(--muted);
  border: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  padding: 0;
  cursor: pointer;
  transition: background .15s, color .15s, transform .15s;
}
.icon-btn:hover:not(:disabled) {
  background: rgba(0,0,0,.06);
  color: var(--text, #111);
}
.icon-btn:disabled {
  opacity: .45;
  cursor: not-allowed;
}
.icon-btn svg {
  width: 20px;
  height: 20px;
}
.icon-btn.recording {
  background: #ef4444;
  color: #fff;
  animation: mic-pulse 1.2s infinite;
}
.icon-btn.recording:hover:not(:disabled) {
  background: #dc2626;
  color: #fff;
}
@keyframes mic-pulse {
  0%   { box-shadow: 0 0 0 0 rgba(239, 68, 68, .55); }
  70%  { box-shadow: 0 0 0 12px rgba(239, 68, 68, 0); }
  100% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0); }
}

/* ---------- attachments tray (above input) ---------- */
.attachments {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 8px 4px 10px;
}
.attach-card {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px 6px 6px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  max-width: 240px;
  position: relative;
}
.attach-card img {
  width: 44px;
  height: 44px;
  object-fit: cover;
  border-radius: 8px;
  flex-shrink: 0;
}
.attach-icon {
  width: 44px;
  height: 44px;
  border-radius: 8px;
  background: rgba(0,0,0,.04);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  flex-shrink: 0;
}
.attach-meta {
  display: flex;
  flex-direction: column;
  min-width: 0;
  font-size: 12px;
  line-height: 1.25;
}
.attach-name {
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 140px;
}
.attach-size {
  color: var(--muted);
}
.attach-remove {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 0;
  background: rgba(0,0,0,.08);
  color: var(--text, #111);
  font-size: 16px;
  line-height: 1;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  margin-left: 2px;
}
.attach-remove:hover { background: rgba(0,0,0,.18); }

/* ---------- attachments shown inside a sent user msg ---------- */
.msg-attachments {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 6px;
}
.msg-chip {
  display: inline-block;
  padding: 3px 8px;
  background: rgba(0,0,0,.06);
  border-radius: 999px;
  font-size: 12px;
  color: var(--muted);
}

/* ---------- toast ---------- */
.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%) translateY(80px);
  background: #111827;
  color: #fff;
  padding: 10px 16px;
  border-radius: 10px;
  font-size: 14px;
  box-shadow: 0 8px 24px rgba(0,0,0,.25);
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s, transform .2s;
  z-index: 9999;
  max-width: 90vw;
}
.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}
.toast.error {
  background: #b91c1c;
}

/* ============================================================
   ACCOUNT
   ============================================================ */
.field-row {
  display: flex;
  gap: 12px;
  padding: 8px 0;
  font-size: 15px;
  border-bottom: 1px solid var(--border);
}
.field-row:last-child { border-bottom: 0; }
.field-row .field-label {
  flex: 0 0 140px;
  color: var(--muted);
  font-weight: 600;
  font-size: 14px;
}
.field-row .field-value {
  flex: 1;
  color: var(--text);
}

.usage-bar {
  width: 100%;
  height: 10px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 999px;
  overflow: hidden;
  margin: 8px 0;
}
.usage-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--primary) 0%, var(--primary-dark) 100%);
  transition: width .3s ease;
}
.usage-bar-fill.warn {
  background: linear-gradient(90deg, #F59E0B 0%, var(--accent) 100%);
}
.usage-bar-fill.over {
  background: var(--err);
}
.code-display {
  display: inline-block;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 1.6rem;
  letter-spacing: .35em;
  background: var(--primary-50);
  color: var(--primary-dark);
  border: 2px dashed var(--primary);
  padding: 12px 22px;
  border-radius: var(--r-md);
  margin: 8px 0;
}
.tg-link-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 0;
  border-bottom: 1px dotted var(--border);
}
.tg-link-row:last-child { border-bottom: 0; }
.tg-link-row form { margin: 0; }

details summary {
  cursor: pointer;
  font-weight: 600;
  color: var(--primary-dark);
  padding: 6px 0;
}
details[open] summary { margin-bottom: .5rem; }

/* ============================================================
   PAYWALL
   ============================================================ */
.paywall-card {
  text-align: center;
  padding: 36px;
  background: linear-gradient(135deg, #fff 0%, var(--primary-50) 100%);
  border: 1px solid var(--primary-100);
  border-radius: var(--r-xl);
}
.paywall-card .price-big {
  font-size: 2.6rem;
  font-weight: 800;
  letter-spacing: -.02em;
  margin: 12px 0 18px;
  color: var(--text);
}
.paywall-card .contact-handle {
  font-size: 1.15rem;
  font-weight: 700;
  margin: 12px 0 18px;
}

/* ============================================================
   ADMIN
   ============================================================ */
.adminnav {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: 6px;
  margin: 12px 0 24px;
  font-size: 14px;
}
.adminnav a {
  padding: 8px 14px;
  border-radius: var(--r-sm);
  color: var(--text-2);
  font-weight: 600;
  transition: background .15s, color .15s;
}
.adminnav a:hover {
  background: var(--primary-50);
  color: var(--primary-dark);
}
.adminnav a.active,
.adminnav a strong {
  background: var(--primary);
  color: #fff;
  font-weight: 700;
}
.adminnav a.active:hover { background: var(--primary-hover); color: #fff; }

.metrics-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 12px;
  margin: 12px 0 24px;
}
.metric {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: 16px 18px;
  box-shadow: var(--shadow-sm);
}
.metric .label {
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .06em;
  margin-bottom: 4px;
}
.metric .value {
  font-size: 1.6rem;
  font-weight: 800;
  letter-spacing: -.02em;
  color: var(--text);
}

table.data-grid {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 14px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  overflow: hidden;
}
table.data-grid th {
  background: var(--primary);
  color: #fff;
  font-weight: 700;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: .06em;
  text-align: left;
  padding: 10px 12px;
  white-space: nowrap;
}
table.data-grid td {
  padding: 10px 12px;
  border-top: 1px solid var(--border);
  vertical-align: top;
}
table.data-grid tbody tr:nth-child(even) { background: rgba(59, 130, 246, .03); }
table.data-grid tbody tr:hover { background: var(--primary-50); }
table.data-grid .actions { white-space: nowrap; display: flex; gap: 4px; flex-wrap: wrap; }
table.data-grid .actions form { margin: 0; display: inline-block; }
.cost-overlimit { color: var(--err); font-weight: 700; }

.filters-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: 12px 14px;
  margin: 12px 0;
  font-size: 14px;
}
.filters-bar label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--muted);
  font-weight: 500;
}
.filters-bar input,
.filters-bar select {
  padding: 6px 10px;
  font-size: 14px;
  width: auto;
}
.filters-bar input[type="text"],
.filters-bar input[type="search"] {
  min-width: 200px;
}

.profile-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 14px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: 18px 20px;
  margin: 12px 0 20px;
  font-size: 14px;
}
.profile-grid .field strong {
  display: block;
  color: var(--muted);
  font-weight: 600;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .08em;
  margin-bottom: 4px;
}

.timeline {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 13px;
  background: var(--card);
  border: 1px solid var(--border);
  padding: 14px 18px;
  border-radius: var(--r-md);
  white-space: pre;
  overflow-x: auto;
  line-height: 1.5;
  color: var(--text-2);
}

/* admin chat bubbles (conversation detail) */
.chat-static { display: flex; flex-direction: column; gap: 8px; margin: 16px 0; }
.bubble {
  max-width: 78%;
  padding: 10px 14px;
  border-radius: 16px;
  font-size: 14px;
  line-height: 1.5;
  word-wrap: break-word;
  white-space: pre-wrap;
  box-shadow: var(--shadow-sm);
}
.bubble.user {
  align-self: flex-end;
  background: var(--primary);
  color: #fff;
  border-bottom-right-radius: 4px;
}
.bubble.user a { color: #cfe1ff; }
.bubble.assistant {
  align-self: flex-start;
  background: var(--card);
  color: var(--text);
  border: 1px solid var(--border);
  border-bottom-left-radius: 4px;
}
.bubble pre {
  background: rgba(15, 23, 42, .06);
  padding: 8px 10px;
  border-radius: 6px;
  overflow-x: auto;
  font-size: 12px;
  margin: 6px 0;
  white-space: pre-wrap;
}
.bubble code { background: rgba(15, 23, 42, .08); padding: 0 4px; border-radius: 3px; font-size: 12px; }
.bubble.user code { background: rgba(255,255,255,.22); color: #fff; }
.bubble .meta { font-size: 11px; opacity: .7; margin-top: 5px; }
.bubble.user .meta { text-align: right; }
.bubble .ch-tag { display:inline-block; padding: 0 5px; border-radius: 4px; background: rgba(255,255,255,.22); }
.bubble.assistant .ch-tag { background: rgba(15, 23, 42, .07); }
.day-sep {
  text-align: center;
  font-size: 12px;
  color: var(--muted);
  margin: 14px 0 4px;
  position: relative;
}
.day-sep::before,
.day-sep::after {
  content: '';
  position: absolute;
  top: 50%;
  width: calc(50% - 50px);
  height: 1px;
  background: var(--border);
}
.day-sep::before { left: 0; }
.day-sep::after  { right: 0; }
.search-result {
  padding: 12px 14px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  margin-bottom: 10px;
}
.search-result .meta {
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 4px;
}
.search-result mark { background: #FEF08A; padding: 0 2px; border-radius: 2px; }
.load-more { text-align: center; margin: 16px 0; }

/* ============================================================
   FADE-IN ON SCROLL
   ============================================================ */
.fade-in {
  opacity: 0;
  transform: translateY(16px);
  transition: opacity .6s ease, transform .6s ease;
}
.fade-in.visible {
  opacity: 1;
  transform: translateY(0);
}

/* ============================================================
   FOCUS / A11Y
   ============================================================ */
button:focus-visible,
a:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-width: 640px) {
  .container { padding: 0 16px; }
  .topnav-inner { height: 56px; gap: 12px; }
  .nav-actions { gap: 12px; font-size: 14px; }
  .brand { font-size: 16px; }
  .brand-mark { width: 24px; height: 24px; font-size: 12px; }

  h1 { font-size: 1.8rem; }
  h2 { font-size: 1.4rem; }

  .features-grid { grid-template-columns: 1fr; }
  .price-block { padding: 24px 20px; }

  .card { padding: 18px; }
  .paywall-card { padding: 24px 18px; }
  .paywall-card .price-big { font-size: 2.1rem; }

  .hero { padding: 32px 0 24px; }
  .hero-cta .btn { width: 100%; }

  .onb-actions { flex-direction: column; }

  .chat-wrap { padding: 0 12px; }
  .msg { max-width: 92%; }
  .nav-tg-btn { padding: 6px 10px; font-size: 13px; }
  .nav-tg-btn span { display: none; }
  .modal-card { padding: 26px 20px 20px; border-radius: 14px; }
  .modal-card h2 { font-size: 19px; }
  .icon-btn { width: 40px; height: 40px; }
  .icon-btn svg { width: 22px; height: 22px; }
  .chat-input-row { gap: 6px; padding: 6px 6px 6px 10px; }
  .attach-card { max-width: 100%; }

  .field-row { flex-direction: column; gap: 4px; }
  .field-row .field-label { flex: 0; }

  table.data-grid { display: block; overflow-x: auto; white-space: nowrap; font-size: 13px; }
  table.data-grid td, table.data-grid th { padding: 8px 10px; }

  .filters-bar { padding: 10px; }
  .filters-bar input[type="text"] { min-width: 140px; }

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