/* Fanifay.com — Modern Dual-Theme UI & Cabinet Studio (Dark: Gray/Green, Light: White/Pink) */
:root {
    --radius-sm: 9px;
    --radius-md: 14px;
    --radius-lg: 18px;
    --container: 1120px;
    --header-h: 60px;
    --font-sans: "Plus Jakarta Sans", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    --font-mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

/* Dark Theme: Obsidian Slate Gray + Emerald Green */
html[data-theme="dark"] {
    --bg: #090c0e;
    --bg-elev: #0e1316;
    --bg-card: #13191d;
    --bg-soft: #1a2228;
    --bg-header: rgba(9, 12, 14, 0.92);
    --border: #222c33;
    --border-strong: #2f3e47;
    --text: #f1f5f7;
    --text-muted: #92a0a8;
    --accent: #22c55e;
    --accent-2: #16a34a;
    --accent-soft: rgba(34, 197, 94, 0.13);
    --accent-border: rgba(34, 197, 94, 0.34);
    --accent-on: #042411;
    --hero-aura: radial-gradient(65% 48% at 50% 0%, rgba(34, 197, 94, 0.13), transparent 70%);
    --tg-bubble-in: #1c252b;
    --tg-bubble-out: #143624;
    --danger: #ef4444;
    --danger-soft: rgba(239, 68, 68, 0.14);
    --warn: #eab308;
    --warn-soft: rgba(234, 179, 8, 0.14);
    --shadow-sm: 0 2px 10px rgba(0, 0, 0, 0.28);
    --shadow-md: 0 16px 38px rgba(0, 0, 0, 0.42);
}

/* Light Theme: Pure White + Rose Pink */
html[data-theme="light"] {
    --bg: #ffffff;
    --bg-elev: #fdf7fa;
    --bg-card: #ffffff;
    --bg-soft: #f9edf3;
    --bg-header: rgba(255, 255, 255, 0.94);
    --border: #efdbe6;
    --border-strong: #e3bfd2;
    --text: #181014;
    --text-muted: #6f5763;
    --accent: #ec4899;
    --accent-2: #db2777;
    --accent-soft: rgba(236, 72, 153, 0.10);
    --accent-border: rgba(236, 72, 153, 0.34);
    --accent-on: #ffffff;
    --hero-aura: radial-gradient(65% 48% at 50% 0%, rgba(236, 72, 153, 0.10), transparent 70%);
    --tg-bubble-in: #f5ebf0;
    --tg-bubble-out: #fce7f3;
    --danger: #dc2626;
    --danger-soft: rgba(220, 38, 38, 0.10);
    --warn: #d97706;
    --warn-soft: rgba(217, 119, 6, 0.10);
    --shadow-sm: 0 2px 12px rgba(219, 39, 119, 0.05);
    --shadow-md: 0 16px 36px rgba(219, 39, 119, 0.09);
}

*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }

body {
    margin: 0;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    font-family: var(--font-sans);
    font-size: 14.5px;
    line-height: 1.5;
    color: var(--text);
    background-color: var(--bg);
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
}

main { flex: 1 0 auto; }
img { display: block; max-width: 100%; height: auto; }
a { color: inherit; text-decoration: none; }
button, input, textarea, select { font: inherit; color: inherit; }

.container {
    width: 100%;
    max-width: var(--container);
    margin-inline: auto;
    padding-inline: 16px;
}

/* Header */
.site-header {
    position: sticky;
    top: 0;
    z-index: 50;
    background: var(--bg-header);
    border-bottom: 1px solid var(--border);
}

.header-inner {
    height: var(--header-h);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.brand {
    display: inline-flex;
    align-items: center;
    gap: 9px;
    font-weight: 800;
    font-size: 16px;
    letter-spacing: -0.025em;
    flex-shrink: 0;
}

.brand-mark {
    width: 32px;
    height: 32px;
    border-radius: 9px;
    overflow: hidden;
    display: block;
    border: 1px solid var(--border);
    flex-shrink: 0;
}

.brand-mark-sm { width: 24px; height: 24px; border-radius: 6px; }
.brand-logo { width: 100%; height: 100%; object-fit: cover; transform: scale(1.22); }

html[data-theme="dark"] .brand-logo-light { display: none; }
html[data-theme="light"] .brand-logo-dark { display: none; }

.nav-links { display: flex; align-items: center; gap: 4px; }

.nav-link {
    padding: 6px 12px;
    border-radius: 9px;
    color: var(--text-muted);
    font-weight: 600;
    font-size: 13.5px;
    white-space: nowrap;
    transition: color 140ms ease, background-color 140ms ease;
}

.nav-link:hover, .nav-link.is-active { color: var(--text); background: var(--bg-soft); }

.header-actions { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }

/* Language & Theme Controls */
.lang-switch {
    display: inline-flex;
    background: var(--bg-soft);
    border: 1px solid var(--border);
    border-radius: 9px;
    padding: 2px;
}

.lang-btn {
    padding: 4px 8px;
    border-radius: 7px;
    font-size: 11.5px;
    font-weight: 700;
    color: var(--text-muted);
    transition: background-color 140ms ease, color 140ms ease;
}

.lang-btn.is-active { background: var(--accent); color: var(--accent-on); }

.theme-toggle {
    display: inline-grid;
    place-items: center;
    width: 32px;
    height: 32px;
    padding: 0;
    border-radius: 9px;
    background: var(--bg-soft);
    border: 1px solid var(--border);
    cursor: pointer;
}

.theme-toggle:hover { border-color: var(--border-strong); }
html[data-theme="dark"] .theme-icon-sun { display: none; }
html[data-theme="light"] .theme-icon-moon { display: none; }

.burger-btn {
    display: none;
    width: 34px;
    height: 34px;
    border-radius: 9px;
    border: 1px solid var(--border);
    background: var(--bg-soft);
    place-items: center;
    cursor: pointer;
}

.mobile-drawer { border-top: 1px solid var(--border); background: var(--bg-elev); }
.mobile-drawer-inner { padding-block: 10px 14px; display: flex; flex-direction: column; gap: 4px; }
.mobile-link { padding: 10px 12px; border-radius: 9px; font-weight: 600; font-size: 14px; }
.mobile-link:hover { background: var(--bg-soft); }

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 9px 16px;
    border-radius: 10px;
    font-weight: 600;
    font-size: 13.5px;
    line-height: 1.2;
    border: 1px solid transparent;
    cursor: pointer;
    transition: transform 120ms ease, opacity 140ms ease, border-color 140ms ease, background-color 140ms ease;
    white-space: nowrap;
}

.btn:active { transform: translateY(1px); }
.btn-sm { padding: 6px 11px; font-size: 12.5px; border-radius: 8px; }
.btn-lg { padding: 11px 20px; font-size: 14.5px; }
.btn-block { width: 100%; }

.btn-primary {
    background: linear-gradient(135deg, var(--accent), var(--accent-2));
    color: var(--accent-on);
}
.btn-primary:hover { opacity: 0.94; }

.btn-secondary { background: var(--bg-soft); color: var(--text); border-color: var(--border); }
.btn-secondary:hover { border-color: var(--border-strong); }

.btn-ghost { background: transparent; color: var(--text-muted); border-color: var(--border); }
.btn-ghost:hover { color: var(--text); background: var(--bg-soft); }

.btn-danger { background: var(--danger-soft); color: var(--danger); border-color: rgba(239, 68, 68, 0.25); }
.is-disabled { opacity: 0.65; cursor: default; }

/* Badges & Alerts */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 3px 9px;
    border-radius: 999px;
    font-size: 11.5px;
    font-weight: 600;
    background: var(--accent-soft);
    color: var(--accent);
    border: 1px solid var(--accent-border);
    white-space: nowrap;
}

.badge-neutral { background: var(--bg-soft); color: var(--text-muted); border-color: var(--border); }
.dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.notice-wrap { margin-top: 12px; }

.alert {
    padding: 10px 14px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    flex-wrap: wrap;
    font-size: 13.5px;
}

.alert-success { background: var(--accent-soft); border-color: var(--accent-border); }
.alert-warning { background: var(--warn-soft); border-color: var(--warn); }
.alert-error { background: var(--danger-soft); border-color: var(--danger); }

/* Sections */
.section { padding-block: 44px; }
.section-elev {
    background: var(--bg-elev);
    border-top: 1px solid var(--border);
    border-bottom: 1px solid var(--border);
}

.section-head { max-width: 600px; margin-bottom: 22px; }

.section-title {
    margin: 0 0 6px;
    font-size: clamp(1.35rem, 2.5vw, 1.9rem);
    font-weight: 800;
    line-height: 1.18;
    letter-spacing: -0.025em;
}

.section-subtitle { margin: 0; color: var(--text-muted); font-size: 14.5px; }

/* Hero */
.hero { padding-block: 40px 48px; }
.hero-glow { background-image: var(--hero-aura); }

.hero-grid {
    display: grid;
    grid-template-columns: 1.15fr 0.85fr;
    gap: 28px;
    align-items: center;
}

.hero-title {
    margin: 12px 0 12px;
    font-size: clamp(1.75rem, 3.6vw, 2.75rem);
    font-weight: 800;
    line-height: 1.1;
    letter-spacing: -0.035em;
}

.hero-subtitle { margin: 0 0 20px; color: var(--text-muted); font-size: 15.5px; max-width: 50ch; }
.hero-cta { display: flex; flex-wrap: wrap; gap: 10px; }

.phone-frame {
    padding: 8px;
    border-radius: 22px;
    background: var(--bg-soft);
    border: 1px solid var(--border-strong);
    box-shadow: var(--shadow-md);
}

/* Telegram Preview Card */
.tg-preview-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 15px;
    overflow: hidden;
}

.tg-preview-top {
    padding: 10px 14px;
    background: var(--bg-soft);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}

.tg-bot-meta { display: flex; align-items: center; gap: 9px; }

.tg-avatar {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--accent), var(--accent-2));
    color: var(--accent-on);
    display: grid;
    place-items: center;
    font-weight: 700;
    font-size: 13px;
    flex-shrink: 0;
}

.tg-bot-title { font-weight: 700; font-size: 13.5px; line-height: 1.2; }
.tg-bot-sub { font-size: 11.5px; color: var(--text-muted); }

.tg-chat-body {
    padding: 14px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    min-height: 138px;
}

.tg-msg {
    max-width: 88%;
    padding: 8px 12px;
    border-radius: 12px;
    font-size: 13.5px;
    line-height: 1.4;
    white-space: pre-line;
    word-break: break-word;
}

.tg-msg-user {
    align-self: flex-end;
    background: var(--tg-bubble-out);
    border: 1px solid var(--accent-border);
    border-bottom-right-radius: 4px;
}

.tg-msg-bot {
    align-self: flex-start;
    background: var(--tg-bubble-in);
    border: 1px solid var(--border);
    border-bottom-left-radius: 4px;
}

.tg-msg-img { width: 100%; max-height: 130px; object-fit: cover; border-radius: 8px; margin-bottom: 6px; }

.tg-inline-btn {
    margin-top: 7px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    padding: 7px 10px;
    border-radius: 8px;
    background: var(--accent-soft);
    border: 1px solid var(--accent-border);
    color: var(--accent);
    font-weight: 600;
    font-size: 12.5px;
}

.tg-preview-foot {
    padding: 9px 14px;
    border-top: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

/* Templates 3-Card Carousel (PC & Mobile) */
.carousel-head {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 14px;
    margin-bottom: 18px;
}

.carousel-arrows { display: flex; gap: 6px; flex-shrink: 0; }

.carousel-btn {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    border: 1px solid var(--border);
    background: var(--bg-card);
    color: var(--text);
    font-size: 20px;
    line-height: 1;
    cursor: pointer;
    display: grid;
    place-items: center;
    transition: border-color 140ms ease, background-color 140ms ease;
}

.carousel-btn:hover { border-color: var(--accent); background: var(--accent-soft); }

.tpl-carousel-track {
    display: flex;
    gap: 16px;
    overflow-x: auto;
    scroll-snap-type: x mandatory;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
    padding-bottom: 4px;
}

.tpl-carousel-track::-webkit-scrollbar { display: none; }

.tpl-slide {
    flex: 0 0 calc((100% - 32px) / 3);
    scroll-snap-align: start;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    overflow: hidden;
    box-shadow: var(--shadow-sm);
    display: flex;
    flex-direction: column;
    transition: border-color 150ms ease, transform 150ms ease;
}

.tpl-slide:hover { border-color: var(--border-strong); transform: translateY(-2px); }
.tpl-slide.is-placeholder { opacity: 0.72; }
.tpl-slide.is-placeholder:hover { transform: none; }

.tpl-slide-media {
    aspect-ratio: 16 / 10;
    background: var(--bg-soft);
    overflow: hidden;
}

.tpl-slide-media img { width: 100%; height: 100%; object-fit: cover; }

.tpl-slide-body {
    padding: 14px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    gap: 12px;
    flex: 1 1 auto;
}

.tpl-slide-title {
    margin: 0;
    font-size: 16px;
    font-weight: 700;
    letter-spacing: -0.015em;
    line-height: 1.25;
}

.tpl-slide-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 7px;
}

.tpl-slide-actions-single { grid-template-columns: 1fr; }

/* Plans */
.plans-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 14px;
}

.plans-grid-auto {
    grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
}

.plan-card.is-locked {
    opacity: 0.6;
}

.radio-pills-auto {
    grid-template-columns: repeat(auto-fit, minmax(145px, 1fr));
}

.radio-pill.is-locked .radio-pill-box {
    opacity: 0.55;
    cursor: not-allowed;
}

.plan-info-panel {
    margin-top: 8px;
    padding: 12px 14px;
    border-radius: 10px;
    background: var(--bg-soft);
    border: 1px solid var(--border);
}

.cab-balance-mini {
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding: 9px 11px;
    border-radius: 10px;
    background: var(--bg-soft);
    border: 1px solid var(--border);
}

.cab-balance-mini:hover {
    border-color: var(--accent-border);
}

.cab-balance-vals {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    font-size: 12.5px;
    font-weight: 700;
    color: var(--accent);
}

.plan-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 20px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    gap: 14px;
    box-shadow: var(--shadow-sm);
}

.plan-card.is-featured {
    border-color: var(--accent-border);
    box-shadow: 0 0 0 1px var(--accent-border), var(--shadow-md);
}

.plan-head-row {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 10px;
    flex-wrap: wrap;
}

.plan-name { margin: 0; font-size: 18px; font-weight: 800; }
.plan-prices { text-align: right; }
.plan-price-main { font-size: 20px; font-weight: 800; letter-spacing: -0.02em; line-height: 1.15; }
.plan-price-alt { font-size: 13.5px; font-weight: 600; color: var(--accent); }
.plan-desc { margin: 0; color: var(--text-muted); font-size: 13px; }
.plan-foot { display: flex; flex-direction: column; gap: 10px; }

.plan-note-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 12.5px;
    font-weight: 600;
    padding: 6px 10px;
    border-radius: 8px;
    background: var(--bg-soft);
    border: 1px solid var(--border);
}

/* Template Detail & Create */
.page-head { padding-block: 24px 40px; }

.breadcrumb {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    color: var(--text-muted);
    margin-bottom: 12px;
}
.breadcrumb:hover { color: var(--text); }

.tpl-top-card {
    display: grid;
    grid-template-columns: 1.25fr 0.75fr;
    gap: 20px;
    align-items: center;
}

.tpl-top-cta { display: flex; flex-direction: column; gap: 10px; }
.tpl-plan-chips { display: grid; gap: 6px; }

.tpl-plan-chip {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 7px 11px;
    border-radius: 9px;
    background: var(--bg-soft);
    border: 1px solid var(--border);
    font-size: 12.5px;
}

.tpl-plan-chip:hover { border-color: var(--accent-border); }
.tpl-plan-chip strong { color: var(--accent); font-weight: 600; }

.detail-grid {
    display: grid;
    grid-template-columns: 1.25fr 0.75fr;
    gap: 20px;
    align-items: start;
}

.create-preview-sticky { position: sticky; top: calc(var(--header-h) + 16px); }

.card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 18px;
    box-shadow: var(--shadow-sm);
}

.card-title { margin: 0 0 12px; font-size: 16.5px; font-weight: 700; }
.template-meta-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap; }

.code-pill {
    font-family: var(--font-mono);
    font-size: 11.5px;
    padding: 3px 8px;
    border-radius: 6px;
    background: var(--bg-soft);
    border: 1px solid var(--border);
    color: var(--text-muted);
}

.feature-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.feature-list li { display: flex; align-items: flex-start; gap: 8px; font-size: 13.5px; }
.feature-check { color: var(--accent); flex-shrink: 0; font-weight: 700; }

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

.gallery-item {
    border: 1px solid var(--border);
    border-radius: 10px;
    overflow: hidden;
    background: var(--bg-soft);
    cursor: pointer;
    padding: 0;
    text-align: left;
}
.gallery-item:hover { border-color: var(--accent-border); }
.gallery-item img { width: 100%; aspect-ratio: 16 / 10; object-fit: cover; }
.gallery-cap { padding: 7px 9px; font-size: 12px; color: var(--text-muted); }

/* Video Player Box */
.video-box {
    position: relative;
    border-radius: 10px;
    overflow: hidden;
    border: 1px solid var(--border);
    background: var(--bg-soft);
    aspect-ratio: 16 / 9;
}

.video-poster-btn { position: relative; width: 100%; height: 100%; border: 0; padding: 0; background: transparent; cursor: pointer; display: block; }
.video-poster-btn img { width: 100%; height: 100%; object-fit: cover; }

.video-play-circle {
    position: absolute;
    inset: 50% auto auto 50%;
    transform: translate(-50%, -50%);
    width: 52px;
    height: 52px;
    border-radius: 50%;
    background: var(--accent);
    color: var(--accent-on);
    display: grid;
    place-items: center;
    box-shadow: 0 6px 18px rgba(0, 0, 0, 0.35);
}

.video-box video, .video-box iframe { width: 100%; height: 100%; border: 0; display: block; }
.video-empty-note { margin: 9px 0 0; font-size: 12.5px; color: var(--text-muted); }

/* Forms */
.form-grid { display: grid; gap: 13px; }
.field { display: flex; flex-direction: column; gap: 5px; }
.field-label { font-size: 13px; font-weight: 600; }
.field-hint { font-size: 12px; color: var(--text-muted); }

.input, .textarea, .select {
    width: 100%;
    padding: 9px 12px;
    border-radius: 9px;
    background: var(--bg-soft);
    border: 1px solid var(--border);
    color: var(--text);
    font-size: 14px;
    transition: border-color 140ms ease;
}

.input:focus, .textarea:focus, .select:focus { outline: none; border-color: var(--accent); }
.textarea { min-height: 92px; resize: vertical; }

.radio-pills { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.radio-pill { position: relative; }
.radio-pill input { position: absolute; opacity: 0; pointer-events: none; }

.radio-pill-box {
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding: 10px;
    border-radius: 10px;
    border: 1px solid var(--border);
    background: var(--bg-soft);
    cursor: pointer;
    font-size: 13px;
}

.radio-pill input:checked + .radio-pill-box { border-color: var(--accent); background: var(--accent-soft); }
.split-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }

/* Telegram Login Widget */
.tg-auth-box { display: flex; flex-direction: column; gap: 10px; }

.tg-widget-wrap {
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 14px;
    border-radius: 10px;
    background: var(--bg-soft);
    border: 1px solid var(--border);
    min-height: 66px;
}

/* =========================================================
   CABINET STUDIO (Left Sidebar + Stats + Modular Bot Panel)
   ========================================================= */
.cab-body { background: var(--bg); }
.cab-backdrop[hidden] { display: none; }

.cab-backdrop {
    position: fixed;
    inset: 0;
    z-index: 80;
    background: rgba(0, 0, 0, 0.55);
}

.cab-shell {
    display: grid;
    grid-template-columns: 264px minmax(0, 1fr);
    min-height: 100vh;
}

.cab-sidebar {
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
    background: var(--bg-elev);
    border-right: 1px solid var(--border);
    padding: 16px 14px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.cab-sb-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.cab-close-btn {
    display: none;
    width: 32px;
    height: 32px;
    border-radius: 8px;
    border: 1px solid var(--border);
    background: var(--bg-soft);
    font-size: 20px;
    line-height: 1;
    cursor: pointer;
    place-items: center;
}

.cab-sb-block, .cab-sb-group { display: flex; flex-direction: column; gap: 5px; }

.cab-sb-label {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    padding-inline: 6px;
    margin-bottom: 2px;
}

.cab-bot-select { font-size: 13px; padding: 8px 10px; }

.cab-nav-link {
    display: flex;
    align-items: center;
    gap: 9px;
    padding: 9px 11px;
    border-radius: 9px;
    font-size: 13.5px;
    font-weight: 600;
    color: var(--text-muted);
    transition: background-color 140ms ease, color 140ms ease;
}

.cab-nav-link:hover { color: var(--text); background: var(--bg-soft); }

.cab-nav-link.is-active {
    background: var(--accent-soft);
    color: var(--accent);
    border: 1px solid var(--accent-border);
}

.cab-nav-ico { display: inline-flex; flex-shrink: 0; }
.cab-nav-dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; flex-shrink: 0; }

.cab-nav-badge {
    margin-left: auto;
    padding: 1px 7px;
    border-radius: 999px;
    font-size: 11px;
    background: var(--bg-soft);
    border: 1px solid var(--border);
    color: var(--text);
}

.cab-sb-foot {
    margin-top: auto;
    padding-top: 12px;
    border-top: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.cab-sb-controls {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.cab-user-chip {
    display: flex;
    align-items: center;
    gap: 9px;
    padding: 8px;
    border-radius: 10px;
    background: var(--bg-soft);
    border: 1px solid var(--border);
}
.cab-user-chip.is-active { border-color: var(--accent-border); }

.cab-sb-foot-links { display: flex; gap: 6px; }

.studio-avatar, .studio-avatar-img {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    flex-shrink: 0;
    object-fit: cover;
}

.studio-avatar {
    display: grid;
    place-items: center;
    background: linear-gradient(135deg, var(--accent), var(--accent-2));
    color: var(--accent-on);
    font-weight: 700;
    font-size: 14px;
}

.studio-user-meta { min-width: 0; display: flex; flex-direction: column; }
.studio-user-name { font-weight: 700; font-size: 13.5px; line-height: 1.2; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.studio-user-sub { font-size: 11.5px; color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.cab-workspace { display: flex; flex-direction: column; min-width: 0; }

.cab-topbar {
    position: sticky;
    top: 0;
    z-index: 30;
    height: 58px;
    padding-inline: 20px;
    background: var(--bg-header);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.cab-topbar-left { display: flex; align-items: center; gap: 10px; min-width: 0; }

.cab-page-title {
    margin: 0;
    font-size: 17px;
    font-weight: 800;
    letter-spacing: -0.02em;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.cab-topbar-right { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }
.cab-top-select { width: auto; max-width: 190px; padding: 6px 10px; font-size: 13px; }
.cab-content { padding: 20px; max-width: 1100px; width: 100%; }

/* KPI & 7-Day Activity Chart */
.kpi-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.kpi-grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }

.kpi-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 14px 16px;
    display: flex;
    flex-direction: column;
    gap: 4px;
    box-shadow: var(--shadow-sm);
}

.kpi-label { font-size: 12px; color: var(--text-muted); font-weight: 500; }
.kpi-value { font-size: 24px; font-weight: 800; letter-spacing: -0.025em; line-height: 1.1; }

.studio-grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; align-items: start; }
.panel-split { display: grid; grid-template-columns: 1.15fr 0.85fr; gap: 16px; align-items: start; }

.chart-bars {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 8px;
    height: 168px;
    align-items: end;
}

.chart-col {
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-end;
    gap: 6px;
}

.chart-num { font-size: 11px; font-weight: 700; color: var(--text-muted); }

.chart-track {
    width: 100%;
    max-width: 28px;
    flex: 1 1 auto;
    background: var(--bg-soft);
    border-radius: 7px;
    display: flex;
    align-items: flex-end;
    overflow: hidden;
}

.chart-fill {
    width: 100%;
    background: linear-gradient(180deg, var(--accent), var(--accent-2));
    border-radius: 7px;
    min-height: 4px;
}

.chart-day { font-size: 11px; color: var(--text-muted); }

/* Lists, Logs & Bots */
.logs-list { display: grid; gap: 7px; }

.log-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    flex-wrap: wrap;
    padding: 9px 11px;
    border-radius: 9px;
    background: var(--bg-soft);
    border: 1px solid var(--border);
    font-size: 13px;
}

.bots-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.bots-search { flex: 1 1 220px; max-width: 320px; }
.filter-pills { display: flex; gap: 6px; flex-wrap: wrap; }
.bots-list { display: grid; gap: 12px; }

.bot-item {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 15px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.bot-item-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.bot-title-line { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-size: 15.5px; margin-bottom: 6px; }
.bot-badges { display: flex; gap: 5px; flex-wrap: wrap; }
.bot-actions-row { display: flex; gap: 6px; flex-wrap: wrap; }

.webhook-row {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    background: var(--bg-soft);
    border: 1px solid var(--border);
    padding: 7px 10px;
    border-radius: 8px;
}

.webhook-code { font-family: var(--font-mono); font-size: 12px; word-break: break-all; flex: 1 1 200px; }

.panel-sub-pills { display: none; gap: 6px; overflow-x: auto; padding-bottom: 10px; margin-bottom: 6px; }
.tabs { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 14px; }

.tab-btn {
    padding: 7px 12px;
    border-radius: 8px;
    border: 1px solid var(--border);
    background: var(--bg-soft);
    color: var(--text-muted);
    font-weight: 600;
    font-size: 12.5px;
    cursor: pointer;
    white-space: nowrap;
}

.tab-btn.is-active { background: var(--accent); color: var(--accent-on); border-color: transparent; }

/* Mobile Bottom Nav inside Cabinet */
.cab-bottom-nav { display: none; }

/* Lightbox */
.lightbox[hidden] { display: none; }
.lightbox { position: fixed; inset: 0; z-index: 100; background: rgba(8, 10, 12, 0.92); display: flex; align-items: center; justify-content: center; padding: 16px; }
.lightbox-stage { max-width: 920px; max-height: 86vh; text-align: center; }
.lightbox-stage img { max-height: 75vh; margin-inline: auto; border-radius: 10px; }
.lightbox-caption { color: #e2e8f0; margin: 10px 0 0; font-size: 13.5px; }

.lightbox-close, .lightbox-nav {
    position: fixed;
    border: 1px solid rgba(255, 255, 255, 0.2);
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    font-size: 22px;
    line-height: 1;
    cursor: pointer;
    display: grid;
    place-items: center;
}

.lightbox-close { top: 14px; right: 14px; }
.lightbox-prev { left: 12px; top: 50%; transform: translateY(-50%); }
.lightbox-next { right: 12px; top: 50%; transform: translateY(-50%); }

/* Footer */
.site-footer {
    border-top: 1px solid var(--border);
    padding-block: 18px;
    background: var(--bg-elev);
    font-size: 13px;
    color: var(--text-muted);
}

.footer-inner { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.footer-brand { display: flex; align-items: center; gap: 8px; }
.footer-links { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.footer-links a:hover { color: var(--text); }

/* Responsive Breakpoints */
@media (max-width: 960px) {
    .hero-grid, .detail-grid, .tpl-top-card, .studio-grid-2, .panel-split, .plans-grid, .plans-grid-auto {
        grid-template-columns: 1fr;
    }

    .create-preview-sticky { position: static; }
    .kpi-grid, .kpi-grid-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }

    /* Cabinet Mobile Slide-In Sidebar + Bottom Nav */
    .cab-shell { grid-template-columns: 1fr; }

    .cab-sidebar {
        position: fixed;
        left: 0;
        top: 0;
        bottom: 0;
        width: 280px;
        max-width: 85vw;
        z-index: 90;
        transform: translateX(-105%);
        transition: transform 200ms ease;
    }

    .cab-sidebar.is-open { transform: translateX(0); }
    .cab-close-btn { display: grid; }
    .cab-menu-trigger { display: grid; }
    .cab-topbar { padding-inline: 14px; }
    .cab-content { padding: 14px 14px calc(76px + env(safe-area-inset-bottom)); }
    .panel-sub-pills { display: flex; }

    .cab-bottom-nav {
        position: fixed;
        left: 0;
        right: 0;
        bottom: 0;
        z-index: 60;
        display: grid;
        grid-template-columns: repeat(4, 1fr);
        background: var(--bg-header);
        border-top: 1px solid var(--border);
        padding: 6px 4px calc(6px + env(safe-area-inset-bottom));
    }

    .cab-bottom-item {
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        gap: 3px;
        padding: 4px 2px;
        font-size: 10.5px;
        font-weight: 600;
        color: var(--text-muted);
        background: transparent;
        border: 0;
        cursor: pointer;
    }

    .cab-bottom-item.is-active { color: var(--accent); }
}

@media (max-width: 720px) {
    .nav-links, .hide-sm { display: none; }
    .burger-btn { display: grid; }

    .section { padding-block: 32px; }
    .hero { padding-block: 24px 30px; }
    .page-head { padding-block: 16px 28px; }

    /* 3-card Carousel even on phone screens! */
    .tpl-carousel-track { gap: 7px; }
    .tpl-slide { flex: 0 0 calc((100% - 14px) / 3); border-radius: 10px; }
    .tpl-slide-body { padding: 8px; gap: 7px; }
    .tpl-slide-title { font-size: 12px; }
    .tpl-slide-actions { grid-template-columns: 1fr; gap: 4px; }
    .tpl-slide-actions .btn { padding: 5px 4px; font-size: 11px; border-radius: 7px; }

    .bots-search { max-width: none; width: 100%; }
    .radio-pills, .split-2 { grid-template-columns: 1fr; }
}

/* ==========================================================================
   Chat-First Bot Builder Workspace
   ========================================================================== */

.chat-workspace {
    height: 100dvh;
    overflow: hidden;
}

.chat-head-agent {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
}

.chat-head-ava {
    position: relative;
    width: 34px;
    height: 34px;
    flex-shrink: 0;
}

.chat-head-ava-clip {
    display: block;
    width: 100%;
    height: 100%;
    border-radius: 50%;
    overflow: hidden;
    border: 1px solid var(--border);
    background: var(--bg-soft);
}

.chat-agent-dot {
    position: absolute;
    right: -1px;
    bottom: -1px;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--accent);
    border: 2px solid var(--bg-header);
}

.chat-agent-sub {
    font-size: 11.5px;
    color: var(--accent);
    font-weight: 600;
    line-height: 1.1;
}

.chat-notice-strip {
    padding: 8px 20px 0;
}

.chat-stage {
    flex: 1 1 auto;
    min-height: 0;
    display: grid;
    grid-template-columns: minmax(0, 1fr) 360px;
    overflow: hidden;
}

.chat-pane {
    display: flex;
    flex-direction: column;
    min-height: 0;
    border-right: 1px solid var(--border);
    background: var(--bg);
}

.chat-messages {
    flex: 1 1 auto;
    overflow-y: auto;
    padding: 18px 20px;
    display: flex;
    flex-direction: column;
    gap: 14px;
    scroll-behavior: smooth;
}

.chat-msg {
    display: flex;
    gap: 10px;
    max-width: 740px;
    animation: chatFadeIn 150ms ease;
}

@keyframes chatFadeIn {
    from { opacity: 0; transform: translateY(5px); }
    to { opacity: 1; transform: translateY(0); }
}

.chat-msg-bot {
    align-self: flex-start;
    width: 100%;
    max-width: 720px;
}

.chat-msg-user {
    align-self: flex-end;
    justify-content: flex-end;
    max-width: 82%;
}

.chat-bot-ava {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    overflow: hidden;
    background: var(--bg-soft);
    border: 1px solid var(--border);
    color: var(--text);
    font-weight: 800;
    font-size: 13px;
    display: grid;
    place-items: center;
    flex-shrink: 0;
    margin-top: 2px;
}

.chat-bot-col { min-width: 0; flex: 1 1 auto; }

.chat-bubble {
    padding: 12px 14px;
    border-radius: 14px;
    font-size: 14px;
    line-height: 1.5;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.chat-bubble-bot {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-top-left-radius: 4px;
    box-shadow: var(--shadow-sm);
}

.chat-bubble-user {
    background: var(--accent);
    color: var(--accent-on);
    border-top-right-radius: 4px;
    font-weight: 600;
    white-space: pre-wrap;
    word-break: break-word;
}

.chat-text {
    white-space: pre-wrap;
    word-break: break-word;
}

.chat-choices {
    display: flex;
    flex-wrap: wrap;
    gap: 7px;
}

.chat-tpl-list, .chat-plan-list {
    display: grid;
    gap: 9px;
}

.chat-tpl-card {
    display: grid;
    grid-template-columns: 92px minmax(0, 1fr);
    gap: 11px;
    padding: 10px;
    border-radius: 11px;
    background: var(--bg-soft);
    border: 1px solid var(--border);
    align-items: center;
}

.chat-tpl-thumb {
    width: 92px;
    height: 68px;
    object-fit: cover;
    border-radius: 8px;
    background: var(--bg);
}

.chat-tpl-info {
    display: flex;
    flex-direction: column;
    gap: 6px;
    min-width: 0;
}

.chat-mini-card {
    padding: 11px 12px;
    border-radius: 11px;
    background: var(--bg-soft);
    border: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    gap: 7px;
}

.chat-mini-card.is-locked {
    opacity: 0.62;
}

.chat-mini-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    flex-wrap: wrap;
}

.chat-mini-desc {
    font-size: 13px;
    color: var(--text-muted);
    line-height: 1.4;
}

.chat-warn-note {
    font-size: 12.5px;
    font-weight: 600;
    color: var(--warn);
}

.chat-plan-feats {
    margin: 0;
    padding: 0;
    list-style: none;
    display: grid;
    gap: 3px;
    font-size: 12.5px;
    color: var(--text-muted);
}

.chat-summary-card {
    background: var(--bg-soft);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 10px 12px;
    display: grid;
    gap: 6px;
}

.chat-sum-row {
    display: grid;
    grid-template-columns: 92px minmax(0, 1fr);
    gap: 8px;
    font-size: 13px;
}

.chat-sum-k { color: var(--text-muted); }
.chat-sum-v { word-break: break-word; white-space: pre-wrap; }

.chat-auth-bar {
    padding: 12px 18px;
    background: var(--bg-elev);
    border-top: 1px solid var(--accent-border);
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.chat-auth-bar[hidden] { display: none; }

.chat-auth-bar-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    flex-wrap: wrap;
    font-size: 13.5px;
}

.chat-composer {
    padding: 10px 18px 14px;
    background: var(--bg-elev);
    border-top: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.chat-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.chat-chips[hidden] { display: none; }

.chat-chip {
    padding: 5px 10px;
    border-radius: 999px;
    border: 1px solid var(--border);
    background: var(--bg-soft);
    color: var(--text);
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: border-color 140ms ease, background-color 140ms ease;
}

.chat-chip:hover { border-color: var(--accent-border); }
.chat-chip.is-accent {
    background: var(--accent-soft);
    color: var(--accent);
    border-color: var(--accent-border);
}

.chat-composer-row {
    display: flex;
    align-items: flex-end;
    gap: 8px;
}

.chat-tool-btn[hidden] { display: none; }

.chat-input {
    flex: 1 1 auto;
    resize: none;
    min-height: 42px;
    max-height: 120px;
    line-height: 1.4;
    padding: 10px 12px;
}

.chat-send-btn {
    min-height: 42px;
    flex-shrink: 0;
}

/* Right Preview Column */
.chat-preview-col {
    background: var(--bg-elev);
    padding: 18px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.chat-preview-mobile-head {
    display: none;
    align-items: center;
    justify-content: space-between;
}

.chat-live-card {
    box-shadow: var(--shadow-md);
}

.tg-preview-photo {
    display: block;
    width: 100%;
    max-height: 170px;
    object-fit: cover;
    border-radius: 8px;
    margin-bottom: 6px;
}

.tg-preview-photo[hidden] { display: none; }

.chat-summary-pills {
    padding: 10px 14px 14px;
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    border-top: 1px solid var(--border);
}

.chat-preview-toggle {
    display: none;
}

@media (max-width: 1120px) {
    .chat-stage {
        grid-template-columns: 1fr;
    }

    .chat-pane { border-right: 0; }
    .chat-preview-toggle { display: inline-flex; }

    .chat-preview-col {
        position: fixed;
        inset: 0;
        z-index: 95;
        background: var(--bg);
        transform: translateX(105%);
        transition: transform 200ms ease;
        padding: 16px;
    }

    .chat-preview-col.is-open { transform: translateX(0); }
    .chat-preview-mobile-head { display: flex; }
}

@media (max-width: 960px) {
    .chat-workspace {
        height: calc(100dvh - 54px - env(safe-area-inset-bottom));
    }

    .chat-messages { padding: 14px 12px; }
    .chat-composer { padding: 8px 12px 10px; }
    .chat-auth-bar { padding: 10px 12px; }
    .chat-input { font-size: 16px; }
}

@media (max-width: 520px) {
    .chat-tpl-card { grid-template-columns: 1fr; }
    .chat-tpl-thumb { width: 100%; height: 120px; }
    .chat-sum-row { grid-template-columns: 1fr; gap: 2px; }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { transition: none !important; scroll-behavior: auto !important; }
}
