:root {
    color-scheme: dark;
    --bg-0: #050816;
    --bg-1: #0a1023;
    --bg-2: #111a36;
    --panel: rgba(14, 22, 45, 0.74);
    --line: rgba(137, 169, 255, 0.18);
    --line-strong: rgba(123, 208, 255, 0.3);
    --text: #f2f6ff;
    --text-soft: #a6b6d9;
    --text-muted: #7d8cab;
    --accent: #7bd0ff;
    --success: #49d59b;
    --warning: #ffbf69;
    --danger: #ff6f87;
    --shadow: 0 28px 80px rgba(2, 6, 23, 0.45);
    --glow: 0 0 0 1px rgba(123, 208, 255, 0.08), 0 24px 48px rgba(0, 0, 0, 0.28);
    --radius-xl: 28px;
    --radius-lg: 22px;
    --radius-md: 16px;
}

* {
    box-sizing: border-box;
}

html {
    min-height: 100%;
}

body {
    margin: 0;
    min-height: 100%;
    font-family: "Segoe UI Variable Display", Bahnschrift, "Segoe UI", sans-serif;
    color: var(--text);
    background:
        radial-gradient(circle at top left, rgba(102, 241, 221, 0.11), transparent 28%),
        radial-gradient(circle at top right, rgba(127, 140, 255, 0.16), transparent 32%),
        linear-gradient(180deg, var(--bg-0) 0%, var(--bg-1) 42%, var(--bg-2) 100%);
}

code,
.cell-code {
    font-family: "Cascadia Code", Consolas, monospace;
}

.galaxy-backdrop {
    position: fixed;
    inset: 0;
    overflow: hidden;
    pointer-events: none;
}

.galaxy-orb {
    position: absolute;
    border-radius: 999px;
    filter: blur(22px);
    opacity: 0.8;
}

.orb-a {
    width: 320px;
    height: 320px;
    top: -80px;
    left: -50px;
    background: radial-gradient(circle, rgba(123, 208, 255, 0.45) 0%, rgba(123, 208, 255, 0.02) 70%);
}

.orb-b {
    width: 440px;
    height: 440px;
    top: 18%;
    right: -140px;
    background: radial-gradient(circle, rgba(102, 241, 221, 0.22) 0%, rgba(102, 241, 221, 0.01) 72%);
}

.orb-c {
    width: 340px;
    height: 340px;
    bottom: -140px;
    left: 18%;
    background: radial-gradient(circle, rgba(127, 140, 255, 0.24) 0%, rgba(127, 140, 255, 0.01) 72%);
}

.galaxy-grid {
    position: absolute;
    inset: 0;
    background-image:
        linear-gradient(rgba(255, 255, 255, 0.03) 1px, transparent 1px),
        linear-gradient(90deg, rgba(255, 255, 255, 0.03) 1px, transparent 1px);
    background-size: 44px 44px;
    mask-image: linear-gradient(180deg, rgba(0, 0, 0, 0.45), transparent 92%);
}

.shell-frame {
    position: relative;
    z-index: 1;
    max-width: 1360px;
    margin: 0 auto;
    padding: 28px;
}

.page-stack {
    display: flex;
    flex-direction: column;
    gap: 22px;
}

.glass-card,
.glass-inset {
    position: relative;
    border: 1px solid var(--line);
    background: rgba(14, 22, 45, 0.74);
    box-shadow: var(--shadow);
    backdrop-filter: blur(24px);
    -webkit-backdrop-filter: blur(24px);
}

.glass-card {
    border-radius: var(--radius-xl);
}

.glass-inset {
    border-radius: var(--radius-lg);
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.06), rgba(255, 255, 255, 0.03));
    box-shadow: var(--glow);
}

.topbar {
    display: flex;
    justify-content: space-between;
    gap: 24px;
    padding: 24px 26px;
    margin-bottom: 22px;
    align-items: center;
}

.brand-block {
    min-width: 260px;
}

.brand-link {
    display: inline-flex;
    align-items: center;
    gap: 14px;
    color: var(--text);
    text-decoration: none;
}

.brand-mark {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 54px;
    height: 54px;
    border-radius: 18px;
    font-weight: 700;
    letter-spacing: 0.08em;
    background: linear-gradient(135deg, rgba(123, 208, 255, 0.34), rgba(102, 241, 221, 0.18));
    border: 1px solid rgba(123, 208, 255, 0.34);
    box-shadow: 0 0 0 1px rgba(123, 208, 255, 0.08), 0 12px 40px rgba(20, 88, 179, 0.22);
}

.brand-copy {
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.brand-kicker,
.eyebrow {
    font-size: 11px;
    letter-spacing: 0.2em;
    text-transform: uppercase;
    color: var(--accent);
}

.brand-name {
    font-size: 22px;
    font-weight: 700;
}

.brand-subtitle,
.hero-text,
.table-copy,
.fact-detail,
.quick-link-detail,
.footer-copy,
.note-stack p,
.section-lead,
.telegram-detail {
    margin: 0;
    color: var(--text-soft);
    line-height: 1.65;
}

.topbar-right {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 14px;
}

.primary-nav,
.subnav-strip,
.hero-actions,
.banner-actions,
.pager-actions,
.quick-link-grid,
.footer-meta,
.chip-row,
.top-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.nav-link,
.subnav-link,
.utility-link,
.action-link,
.stat-card,
.quick-link {
    transition: transform 180ms ease, border-color 180ms ease, background 180ms ease, box-shadow 180ms ease;
}

.nav-link,
.subnav-link,
.utility-link {
    text-decoration: none;
    color: var(--text-soft);
}

.nav-link {
    padding: 10px 14px;
    border-radius: 999px;
    border: 1px solid transparent;
}

.nav-link:hover,
.nav-link.is-active,
.subnav-link:hover,
.subnav-link.is-active {
    color: var(--text);
    border-color: rgba(123, 208, 255, 0.26);
    background: rgba(123, 208, 255, 0.1);
}

.chip,
.data-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    border-radius: 999px;
    padding: 7px 12px;
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0.02em;
    border: 1px solid transparent;
    white-space: nowrap;
}

.chip-accent,
.tone-accent {
    background: rgba(127, 140, 255, 0.18);
    color: #c9d0ff;
    border-color: rgba(127, 140, 255, 0.28);
}

.chip-info,
.tone-info {
    background: rgba(123, 208, 255, 0.16);
    color: #c7efff;
    border-color: rgba(123, 208, 255, 0.28);
}

.chip-neutral,
.tone-neutral {
    background: rgba(255, 255, 255, 0.06);
    color: #d2ddf7;
    border-color: rgba(255, 255, 255, 0.09);
}

.chip-success,
.tone-success {
    background: rgba(73, 213, 155, 0.15);
    color: #bff3dd;
    border-color: rgba(73, 213, 155, 0.28);
}

.chip-warning,
.tone-warning {
    background: rgba(255, 191, 105, 0.15);
    color: #ffe2b2;
    border-color: rgba(255, 191, 105, 0.28);
}

.chip-danger,
.tone-danger {
    background: rgba(255, 111, 135, 0.16);
    color: #ffd0d9;
    border-color: rgba(255, 111, 135, 0.28);
}

.hero-panel,
.page-banner {
    display: grid;
    grid-template-columns: minmax(0, 1.8fr) minmax(260px, 0.9fr);
    gap: 22px;
    padding: 28px;
    overflow: hidden;
}

.hero-panel::after,
.page-banner::after,
.table-card::before {
    content: "";
    position: absolute;
    inset: auto auto -25% -8%;
    width: 320px;
    height: 220px;
    background: radial-gradient(circle, rgba(123, 208, 255, 0.18), transparent 72%);
    pointer-events: none;
}

.hero-panel h1,
.page-banner h1 {
    margin: 14px 0 12px;
    font-size: clamp(32px, 5vw, 48px);
    line-height: 1.05;
    letter-spacing: -0.03em;
}

.hero-side,
.section-card {
    padding: 22px;
}

.queue-observability-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 16px;
    margin-bottom: 18px;
}

.queue-observability-card {
    min-width: 0;
    padding: 18px;
}

.compact-toolbar {
    margin-bottom: 12px;
    padding: 0;
}

.compact-table-wrap {
    max-height: 260px;
    overflow: auto;
}

.compact-data-table th,
.compact-data-table td {
    padding: 10px 12px;
    font-size: 12px;
}

.compact-empty {
    padding: 16px;
}

.queue-filter-form {
    display: grid;
    grid-template-columns: repeat(3, minmax(180px, 1fr));
    gap: 14px;
    width: 100%;
}

.queue-filter-field {
    display: grid;
    gap: 7px;
    color: var(--text-muted);
    font-size: 12px;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.queue-filter-field input {
    width: 100%;
    border: 1px solid rgba(156, 214, 255, 0.18);
    border-radius: 14px;
    background: rgba(5, 10, 22, 0.72);
    color: var(--text);
    padding: 12px 13px;
    outline: none;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04);
}

.queue-filter-field input:focus {
    border-color: rgba(80, 201, 255, 0.64);
    box-shadow: 0 0 0 3px rgba(80, 201, 255, 0.12);
}

.queue-filter-actions {
    display: flex;
    align-items: end;
    gap: 10px;
    flex-wrap: wrap;
}

.footer-bar {
    padding: 22px;
}

.side-metric {
    display: flex;
    flex-direction: column;
    gap: 5px;
    padding: 12px 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.side-metric:last-child {
    border-bottom: 0;
}

.side-metric-label,
.fact-label,
.stat-label,
.quick-link-title,
.detail-list dt {
    color: var(--text-muted);
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.12em;
}

.stats-grid,
.fact-grid,
.two-column,
.telegram-status-grid {
    display: grid;
    gap: 18px;
}

.stats-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
}

.report-grid {
    grid-template-columns: repeat(5, minmax(0, 1fr));
}

.two-column {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.telegram-status-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
    margin-top: 18px;
}

.stat-card {
    display: flex;
    flex-direction: column;
    gap: 14px;
    padding: 22px;
    color: var(--text);
    text-decoration: none;
    border-radius: var(--radius-lg);
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.06), rgba(255, 255, 255, 0.03));
    border: 1px solid rgba(255, 255, 255, 0.08);
    box-shadow: var(--glow);
}

.stat-card:hover,
.quick-link:hover,
.action-link:hover {
    transform: translateY(-2px);
}

.stat-card.tone-info { box-shadow: 0 18px 46px rgba(59, 130, 246, 0.14); }
.stat-card.tone-accent { box-shadow: 0 18px 46px rgba(99, 102, 241, 0.14); }
.stat-card.tone-success { box-shadow: 0 18px 46px rgba(16, 185, 129, 0.14); }
.stat-card.tone-warning { box-shadow: 0 18px 46px rgba(245, 158, 11, 0.14); }

.stat-value {
    font-size: clamp(28px, 4vw, 40px);
    font-weight: 700;
    letter-spacing: -0.04em;
}

.stat-detail {
    color: var(--text-soft);
    line-height: 1.6;
}

.section-head {
    display: flex;
    justify-content: space-between;
    gap: 14px;
    align-items: flex-start;
    margin-bottom: 18px;
}

.section-head h2,
.table-toolbar h2 {
    margin: 6px 0 0;
    font-size: 24px;
    letter-spacing: -0.03em;
}

.fact-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.fact-card,
.telegram-status-card {
    padding: 18px;
}

.fact-topline {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    align-items: center;
    margin-bottom: 10px;
}

.quick-link-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.quick-link {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 18px;
    border-radius: var(--radius-md);
    text-decoration: none;
    color: var(--text);
}

.quick-link:hover {
    border-color: var(--line-strong);
    background: rgba(123, 208, 255, 0.09);
}

.telegram-status-card {
    display: grid;
    gap: 12px;
    min-height: 210px;
}

.telegram-primary {
    font-size: 20px;
    line-height: 1.25;
    letter-spacing: -0.02em;
}

.telegram-status-footer {
    margin-top: auto;
}

.detail-list {
    display: grid;
    gap: 18px;
    margin: 0;
}

.detail-list div {
    padding-bottom: 16px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.detail-list div:last-child {
    border-bottom: 0;
    padding-bottom: 0;
}

.detail-list dd {
    margin: 8px 0 0;
    color: var(--text);
    line-height: 1.7;
    word-break: break-word;
}

.note-stack {
    display: grid;
    gap: 14px;
}

.notice-banner {
    padding: 15px 16px;
    border-radius: var(--radius-md);
    border: 1px solid transparent;
    line-height: 1.6;
}

.notice-banner.is-info {
    background: rgba(123, 208, 255, 0.1);
    border-color: rgba(123, 208, 255, 0.22);
    color: #d1f0ff;
}

.notice-banner.is-warning {
    background: rgba(255, 191, 105, 0.1);
    border-color: rgba(255, 191, 105, 0.22);
    color: #ffe2b2;
}

.action-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 11px 16px;
    border-radius: 999px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    background: rgba(255, 255, 255, 0.04);
    color: var(--text);
    text-decoration: none;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04);
}

.action-link.is-primary {
    border-color: rgba(123, 208, 255, 0.3);
    background: linear-gradient(135deg, rgba(123, 208, 255, 0.24), rgba(102, 241, 221, 0.12));
}

.subnav-strip {
    padding: 6px 2px 0;
}

.subnav-link {
    padding: 10px 14px;
    border-radius: 999px;
    border: 1px solid rgba(255, 255, 255, 0.06);
    background: rgba(255, 255, 255, 0.04);
}

.table-card {
    padding: 0;
    overflow: hidden;
}

.table-toolbar {
    display: flex;
    justify-content: space-between;
    gap: 18px;
    align-items: flex-start;
    padding: 24px 24px 18px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.table-wrap {
    overflow-x: auto;
}

.table-wrap.is-export-friendly .cell-wrap {
    max-width: none;
    display: block;
    overflow: visible;
    -webkit-line-clamp: unset;
}

.data-table.is-export-friendly td,
.data-table.is-export-friendly th {
    white-space: nowrap;
}

.data-table.is-export-friendly td .cell-wrap {
    white-space: normal;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
}

.data-table th,
.data-table td {
    padding: 15px 18px;
    text-align: left;
    vertical-align: top;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.data-table th {
    position: sticky;
    top: 0;
    z-index: 1;
    background: rgba(10, 16, 35, 0.96);
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.14em;
    font-size: 11px;
}

.data-table tbody tr {
    transition: background 160ms ease;
}

.data-table tbody tr:hover {
    background: rgba(123, 208, 255, 0.06);
}

.cell-placeholder {
    color: var(--text-muted);
}

.cell-code {
    display: inline-block;
    color: #d9e8ff;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.08);
    padding: 6px 10px;
    border-radius: 999px;
    white-space: nowrap;
}

.cell-wrap {
    display: -webkit-box;
    max-width: 340px;
    overflow: hidden;
    color: var(--text-soft);
    white-space: normal;
    word-break: break-word;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}

.cell-meta {
    margin-top: 8px;
    display: block;
    max-width: 160px;
}

.image-thumb-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 116px;
    height: 92px;
    overflow: hidden;
    border-radius: 14px;
    border: 1px solid rgba(123, 208, 255, 0.22);
    background: rgba(255, 255, 255, 0.04);
    box-shadow: var(--glow);
}

.image-thumb {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.cell-danger {
    color: #ffd2da;
}

.cell-stack {
    display: grid;
    gap: 8px;
}

.chat-cell {
    display: grid;
    gap: 8px;
    min-width: 240px;
}

.chat-cell-header,
.chat-meta-row,
.filter-links,
.group-summary-facts {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
}

.chat-title {
    font-size: 14px;
    line-height: 1.45;
}

.cell-link {
    color: var(--accent);
    text-decoration: none;
    font-size: 12px;
    font-weight: 600;
}

.cell-link:hover {
    color: var(--text);
}

.filter-strip {
    display: grid;
    gap: 18px;
    padding: 22px 24px;
}

.scope-strip,
.context-link-strip {
    display: grid;
    gap: 18px;
    padding: 22px 24px;
}

.top-filter-links {
    margin-top: 18px;
}

.filter-strip h2,
.group-summary-card h2 {
    margin: 0;
    font-size: 24px;
    letter-spacing: -0.02em;
}

.filter-links {
    align-items: stretch;
}

.filter-link {
    display: grid;
    gap: 4px;
    min-width: 220px;
    padding: 14px 16px;
    border-radius: 18px;
    border: 1px solid rgba(123, 208, 255, 0.16);
    background: rgba(255, 255, 255, 0.04);
    color: var(--text-soft);
    text-decoration: none;
}

.filter-link strong {
    color: var(--text);
    font-size: 14px;
}

.filter-link span {
    color: var(--text-muted);
    font-size: 12px;
    line-height: 1.5;
}

.filter-link:hover,
.filter-link.is-active {
    border-color: rgba(123, 208, 255, 0.3);
    background: rgba(123, 208, 255, 0.1);
    transform: translateY(-1px);
}

.group-summary-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 18px;
}

.group-summary-card {
    display: grid;
    gap: 16px;
    padding: 22px;
}

.group-summary-head {
    display: flex;
    justify-content: space-between;
    gap: 14px;
    align-items: flex-start;
}

.group-summary-fact {
    display: grid;
    gap: 4px;
    min-width: 120px;
    padding: 12px 14px;
    border-radius: 14px;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.06);
}

.group-summary-fact span {
    color: var(--text-muted);
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

.group-summary-fact strong {
    font-size: 14px;
}

.empty-state {
    display: grid;
    justify-items: flex-start;
    gap: 14px;
    padding: 40px 24px;
    margin: 24px;
}

.empty-state h2 {
    margin: 0;
    font-size: 28px;
    letter-spacing: -0.03em;
}

.empty-state p {
    margin: 0;
    max-width: 620px;
    color: var(--text-soft);
    line-height: 1.7;
}



.queue-observability-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 16px;
    margin-bottom: 18px;
}

.queue-observability-card {
    min-width: 0;
    padding: 18px;
}

.compact-toolbar {
    margin-bottom: 12px;
    padding: 0;
}

.compact-table-wrap {
    max-height: 260px;
    overflow: auto;
}

.compact-data-table th,
.compact-data-table td {
    padding: 10px 12px;
    font-size: 12px;
}

.compact-empty {
    padding: 16px;
}

.queue-filter-form {
    display: grid;
    grid-template-columns: repeat(3, minmax(180px, 1fr));
    gap: 14px;
    width: 100%;
}

.queue-filter-field {
    display: grid;
    gap: 7px;
    color: var(--text-muted);
    font-size: 12px;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.queue-filter-field input {
    width: 100%;
    border: 1px solid rgba(156, 214, 255, 0.18);
    border-radius: 14px;
    background: rgba(5, 10, 22, 0.72);
    color: var(--text);
    padding: 12px 13px;
    outline: none;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04);
}

.queue-filter-field input:focus {
    border-color: rgba(80, 201, 255, 0.64);
    box-shadow: 0 0 0 3px rgba(80, 201, 255, 0.12);
}

.queue-filter-actions {
    display: flex;
    align-items: end;
    gap: 10px;
    flex-wrap: wrap;
}

.footer-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
    margin-top: 22px;
    padding: 18px 22px;
}

.utility-link:hover {
    color: var(--text);
}

.fade-up {
    animation: fade-up 420ms ease both;
}

@keyframes fade-up {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@media (prefers-reduced-motion: reduce) {
    .fade-up,
    .nav-link,
    .subnav-link,
    .utility-link,
    .action-link,
    .stat-card,
    .quick-link {
        animation: none;
        transition: none;
    }
}

@media (max-width: 1180px) {
    .stats-grid,
    .report-grid,
    .queue-observability-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .two-column,
    .hero-panel,
    .page-banner {
        grid-template-columns: 1fr;
    }

    .quick-link-grid,
    .fact-grid,
    .queue-filter-form {
        grid-template-columns: 1fr;
    }

    .telegram-status-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 860px) {
    .shell-frame {
        padding: 16px;
    }

    .topbar,
    .footer-bar,
    .hero-panel,
    .page-banner,
    .section-card,
    .hero-side {
        padding: 18px;
    }

    .topbar {
        align-items: flex-start;
    }

    .topbar,
    .footer-bar,
    .table-toolbar {
        flex-direction: column;
    }

    .topbar-right {
        width: 100%;
        align-items: flex-start;
    }

    .stats-grid,
    .report-grid,
    .telegram-status-grid,
    .queue-observability-grid {
        grid-template-columns: 1fr;
    }

    .data-table th,
    .data-table td {
        padding: 12px 14px;
    }
}

@media (max-width: 640px) {
    .brand-name {
        font-size: 18px;
    }

    .hero-panel h1,
    .page-banner h1 {
        font-size: 30px;
    }

    .cell-wrap {
        max-width: 240px;
    }
}

/* Task 65 mobile-first admin shell */
.admin-shell {
    min-height: 100vh;
}

.admin-sidebar {
    position: fixed;
    inset: 18px auto 18px 18px;
    z-index: 20;
    width: 286px;
    padding: 18px;
    display: flex;
    flex-direction: column;
    gap: 18px;
    overflow: hidden;
}

.sidebar-brand {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.sidebar-close,
.hamburger-button,
.ghost-button {
    border: 1px solid rgba(123, 208, 255, 0.22);
    color: var(--text);
    background: rgba(255, 255, 255, 0.06);
    border-radius: 14px;
    cursor: pointer;
}

.sidebar-close {
    display: none;
    width: 40px;
    height: 40px;
    font-size: 24px;
}

.sidebar-nav {
    display: flex;
    flex-direction: column;
    gap: 8px;
    min-height: 0;
    overflow-y: auto;
    padding-right: 2px;
}

.sidebar-link {
    display: flex;
    align-items: center;
    gap: 12px;
    min-height: 46px;
    padding: 11px 12px;
    border-radius: 16px;
    color: var(--text-soft);
    text-decoration: none;
    border: 1px solid transparent;
    transition: background 160ms ease, border-color 160ms ease, transform 160ms ease;
}

.sidebar-link:hover,
.sidebar-link.is-active {
    color: var(--text);
    background: rgba(123, 208, 255, 0.12);
    border-color: rgba(123, 208, 255, 0.28);
}

.sidebar-link.is-active {
    box-shadow: inset 3px 0 0 var(--accent), 0 12px 34px rgba(11, 103, 165, 0.16);
}

.sidebar-link.is-secondary {
    min-height: 42px;
    font-size: 14px;
}

.sidebar-icon {
    display: inline-grid;
    place-items: center;
    width: 28px;
    height: 28px;
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.06);
    color: var(--accent);
    flex: 0 0 auto;
}

.sidebar-group {
    margin-top: 8px;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    padding-top: 10px;
}

.sidebar-group summary {
    min-height: 42px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    cursor: pointer;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.14em;
    font-size: 11px;
    list-style: none;
}

.sidebar-group summary::-webkit-details-marker {
    display: none;
}

.sidebar-group summary::after {
    content: "+";
    color: var(--accent);
}

.sidebar-group[open] summary::after {
    content: "-";
}

.sidebar-footer {
    margin-top: auto;
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.admin-main {
    position: relative;
    z-index: 1;
    margin-left: 322px;
    padding: 18px 22px 24px 0;
    max-width: 1580px;
}

.admin-topbar {
    position: sticky;
    top: 14px;
    z-index: 15;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    padding: 14px 16px;
    margin-bottom: 18px;
}

.hamburger-button {
    display: none;
    width: 46px;
    height: 46px;
    padding: 10px;
}

.hamburger-button span {
    display: block;
    height: 2px;
    margin: 5px 0;
    background: var(--text);
    border-radius: 999px;
}

.admin-title-block {
    display: grid;
    gap: 3px;
    min-width: 0;
}

.admin-title-block strong {
    overflow-wrap: anywhere;
}

.account-menu {
    position: relative;
}

.account-menu summary {
    display: flex;
    align-items: center;
    gap: 10px;
    min-height: 46px;
    padding: 6px 8px;
    border-radius: 16px;
    cursor: pointer;
    list-style: none;
}

.account-menu summary::-webkit-details-marker {
    display: none;
}

.account-avatar {
    display: inline-grid;
    place-items: center;
    width: 36px;
    height: 36px;
    border-radius: 12px;
    background: linear-gradient(135deg, rgba(123, 208, 255, 0.26), rgba(102, 241, 221, 0.12));
    color: var(--text);
    font-weight: 800;
}

.account-copy {
    display: grid;
    gap: 1px;
    color: var(--text);
}

.account-copy small {
    color: var(--text-muted);
}

.account-menu-panel {
    position: absolute;
    right: 0;
    top: calc(100% + 10px);
    min-width: 180px;
    padding: 10px;
    display: grid;
    gap: 6px;
}

.account-menu-panel a {
    color: var(--text-soft);
    text-decoration: none;
    padding: 10px 12px;
    border-radius: 12px;
}

.account-menu-panel a:hover {
    color: var(--text);
    background: rgba(123, 208, 255, 0.1);
}

.login-shell {
    display: grid;
    place-items: center;
    min-height: 100vh;
    padding: 20px;
}

.login-frame {
    position: relative;
    z-index: 1;
    width: min(100%, 460px);
}

.login-card {
    padding: clamp(22px, 7vw, 34px);
}

.login-brand {
    display: flex;
    align-items: center;
    gap: 14px;
    margin-bottom: 16px;
}

.login-brand h1 {
    margin: 4px 0 0;
    font-size: clamp(30px, 8vw, 42px);
    line-height: 1;
}

.login-form,
.settings-form {
    display: grid;
    gap: 16px;
    margin-top: 20px;
}

.form-field,
.settings-field {
    display: grid;
    gap: 8px;
    color: var(--text-muted);
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.1em;
}

.form-field input,
.settings-field input {
    min-height: 48px;
    border: 1px solid rgba(156, 214, 255, 0.18);
    border-radius: 15px;
    background: rgba(5, 10, 22, 0.72);
    color: var(--text);
    padding: 12px 14px;
    outline: none;
    overflow-wrap: anywhere;
}

.form-field input:focus,
.settings-field input:focus {
    border-color: rgba(80, 201, 255, 0.64);
    box-shadow: 0 0 0 3px rgba(80, 201, 255, 0.12);
}

.password-input-wrap {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 8px;
}

.ghost-button {
    min-width: 72px;
    padding: 0 14px;
}

.check-row {
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--text-soft);
    min-height: 44px;
}

.check-row input {
    width: 18px;
    height: 18px;
}

.full-width-action {
    width: 100%;
    justify-content: center;
    min-height: 48px;
}

button.action-link {
    font: inherit;
    cursor: pointer;
}

button.action-link:disabled,
.action-link.is-loading {
    opacity: 0.66;
    cursor: progress;
    transform: none;
}

.notice-banner.is-success {
    border-color: rgba(73, 213, 155, 0.28);
    background: rgba(73, 213, 155, 0.12);
}

.notice-banner.is-danger {
    border-color: rgba(255, 111, 135, 0.28);
    background: rgba(255, 111, 135, 0.12);
}

.settings-layout {
    display: grid;
    grid-template-columns: 240px minmax(0, 1fr);
    gap: 18px;
    align-items: start;
}

.settings-subnav {
    position: sticky;
    top: 92px;
    padding: 14px;
    display: grid;
    gap: 8px;
}

.settings-subnav a {
    color: var(--text-soft);
    text-decoration: none;
    padding: 11px 12px;
    border-radius: 13px;
}

.settings-subnav a:hover {
    color: var(--text);
    background: rgba(123, 208, 255, 0.1);
}

.settings-section-stack {
    display: grid;
    gap: 16px;
}

.settings-card {
    padding: 18px;
}

.settings-card summary {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    cursor: pointer;
    list-style: none;
    min-height: 48px;
}

.settings-card summary::-webkit-details-marker {
    display: none;
}

.settings-card summary strong {
    display: block;
    margin-top: 4px;
    font-size: 20px;
}

.settings-field-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 14px;
}

.settings-field.is-technical input {
    font-family: "Cascadia Code", Consolas, monospace;
    font-size: 12px;
}

.settings-actions {
    display: flex;
    align-items: center;
    gap: 14px;
    flex-wrap: wrap;
}

.mobile-drawer-backdrop {
    display: none;
}

@media (max-width: 980px) {
    .admin-sidebar {
        inset: 0 auto 0 0;
        width: min(86vw, 330px);
        border-radius: 0 28px 28px 0;
        transform: translateX(-104%);
        transition: transform 220ms ease;
    }

    body.sidebar-open .admin-sidebar {
        transform: translateX(0);
    }

    .mobile-drawer-backdrop {
        position: fixed;
        inset: 0;
        z-index: 19;
        display: block;
        background: rgba(0, 0, 0, 0.48);
        opacity: 0;
        pointer-events: none;
        transition: opacity 200ms ease;
    }

    body.sidebar-open .mobile-drawer-backdrop {
        opacity: 1;
        pointer-events: auto;
    }

    .sidebar-close,
    .hamburger-button {
        display: inline-block;
    }

    .admin-main {
        margin-left: 0;
        padding: max(12px, env(safe-area-inset-top)) 12px 18px;
    }

    .admin-topbar {
        top: max(8px, env(safe-area-inset-top));
        border-radius: 20px;
    }

    .settings-layout {
        grid-template-columns: 1fr;
    }

    .settings-subnav {
        position: relative;
        top: 0;
        display: flex;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    .settings-subnav a {
        white-space: nowrap;
    }

    .settings-field-grid {
        grid-template-columns: 1fr;
    }

    .sidebar-group:not([open]) .sidebar-link {
        display: none;
    }
}

@media (max-width: 640px) {
    .admin-title-block strong {
        font-size: 15px;
    }

    .account-copy {
        display: none;
    }

    .page-stack {
        gap: 16px;
    }

    .hero-panel,
    .page-banner,
    .section-card,
    .table-toolbar,
    .footer-bar {
        padding: 16px;
    }

    .stats-grid,
    .report-grid,
    .telegram-status-grid,
    .queue-filter-form,
    .queue-observability-grid {
        grid-template-columns: 1fr;
    }

    .data-table th,
    .data-table td {
        padding: 11px 12px;
    }

    .cell-wrap {
        max-width: 260px;
        overflow-wrap: anywhere;
    }
}


/* Task 65 tightened operations-console layout */
.admin-page-header {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 14px;
    align-items: center;
    padding: 18px 20px;
}

.admin-page-header h1 {
    margin: 4px 0 5px;
    font-size: clamp(24px, 4vw, 34px);
    line-height: 1.08;
    letter-spacing: -0.02em;
}

.header-actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 9px;
    flex-wrap: wrap;
}

.ops-metric-grid {
    display: grid;
    grid-template-columns: repeat(6, minmax(0, 1fr));
    gap: 12px;
}

.ops-metric-card {
    display: grid;
    gap: 8px;
    min-height: 126px;
    padding: 16px;
    color: var(--text);
    text-decoration: none;
}

.ops-metric-card strong {
    font-size: clamp(26px, 5vw, 36px);
    line-height: 1;
}

.ops-metric-card small,
.ops-list-row span,
.ops-list-row small,
.mini-report-card small {
    color: var(--text-soft);
    line-height: 1.45;
}

.ops-panel-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 14px;
}

.ops-panel-grid.two-wide {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.ops-panel {
    padding: 16px;
    min-width: 0;
}


.panel-caption {
    margin: 6px 0 0;
    color: var(--muted);
    font-size: 0.82rem;
    line-height: 1.45;
    overflow-wrap: anywhere;
}

.inline-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    justify-content: flex-end;
}

.ops-panel-head {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 10px;
    margin-bottom: 12px;
}

.ops-panel-head h2 {
    margin: 3px 0 0;
    font-size: 18px;
}

.ops-list {
    display: grid;
    gap: 8px;
}

.ops-list-row {
    display: grid;
    grid-template-columns: auto minmax(72px, auto) minmax(0, 1fr);
    align-items: center;
    gap: 10px;
    min-height: 48px;
    padding: 10px;
    border-radius: 15px;
    color: var(--text);
    text-decoration: none;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.06);
}

.ops-list-row.is-static {
    text-decoration: none;
}

.ops-list-row strong,
.ops-list-row span,
.ops-list-row small {
    min-width: 0;
    overflow-wrap: anywhere;
}

.empty-compact {
    padding: 14px;
    border-radius: 15px;
    color: var(--text-muted);
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.06);
}

.status-rail {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 10px;
}

.status-step {
    display: grid;
    gap: 8px;
    padding: 13px;
    color: var(--text);
    text-decoration: none;
}

.status-step span,
.status-step small {
    min-width: 0;
    overflow-wrap: anywhere;
}

.ops-link-grid,
.compact-report-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 10px;
}

.mini-report-card {
    display: grid;
    gap: 8px;
    padding: 14px;
    color: var(--text);
    text-decoration: none;
}

.mini-report-card strong {
    font-size: 22px;
}

.compact-facts {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.page-banner {
    padding: 18px 20px;
}

.page-banner h1 {
    font-size: clamp(24px, 4vw, 34px);
}

@media (max-width: 1280px) {
    .ops-metric-grid {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }

    .ops-panel-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 760px) {
    .admin-page-header {
        grid-template-columns: 1fr;
        padding: 15px;
    }

    .header-actions {
        justify-content: flex-start;
    }

    .ops-metric-grid,
    .ops-panel-grid,
    .ops-panel-grid.two-wide,
    .status-rail,
    .ops-link-grid,
    .compact-report-grid,
    .compact-facts {
        grid-template-columns: 1fr;
    }

    .ops-list-row {
        grid-template-columns: 1fr;
        align-items: start;
    }

    .ops-metric-card {
        min-height: 104px;
    }

    .ops-panel {
        padding: 14px;
    }
}

.settings-field select {
    min-height: 48px;
    border: 1px solid rgba(156, 214, 255, 0.18);
    border-radius: 15px;
    background: rgba(5, 10, 22, 0.72);
    color: var(--text);
    padding: 12px 14px;
    outline: none;
}

.table-action-stack {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.text-button {
    border: 0;
    background: transparent;
    color: var(--accent);
    cursor: pointer;
    padding: 0;
    font: inherit;
    text-decoration: underline;
    text-underline-offset: 3px;
}

.check-row-field .check-row {
    margin-top: 2px;
}

/* Telegram template settings */
.template-console {
    display: grid;
    grid-template-columns: minmax(220px, 300px) minmax(0, 1fr);
    gap: 18px;
    align-items: start;
}
.template-list {
    padding: 14px;
    display: grid;
    gap: 10px;
    position: sticky;
    top: 92px;
}
.template-list-header,
.template-card-head {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    align-items: flex-start;
}
.template-list-item {
    display: flex;
    justify-content: space-between;
    gap: 10px;
    padding: 12px;
    border: 1px solid rgba(255,255,255,0.08);
    border-radius: 16px;
    text-decoration: none;
    color: inherit;
    background: rgba(255,255,255,0.035);
    min-height: 48px;
}
.template-list-item small,
.template-reference-entry small,
.template-textarea-label small {
    display: block;
    color: var(--muted-text);
    word-break: break-word;
}
.template-list-item.is-active {
    border-color: rgba(89, 214, 255, 0.55);
    background: rgba(89, 214, 255, 0.12);
    box-shadow: 0 0 0 1px rgba(89, 214, 255, 0.12) inset;
}
.template-editor-stack {
    display: grid;
    gap: 18px;
    min-width: 0;
}
.template-editor-card,
.template-preview-card,
.template-reference-card {
    padding: 18px;
}
.template-form {
    display: grid;
    gap: 12px;
    margin-top: 16px;
}
.template-textarea-label span {
    display: block;
    font-weight: 700;
}
.template-form textarea {
    width: 100%;
    min-height: 220px;
    resize: vertical;
    border-radius: 18px;
    border: 1px solid rgba(255,255,255,0.12);
    background: rgba(3, 7, 18, 0.72);
    color: var(--text);
    padding: 14px;
    font: 500 0.95rem/1.55 ui-monospace, SFMono-Regular, Consolas, monospace;
    word-break: break-word;
}
.template-form textarea:focus {
    outline: none;
    border-color: rgba(89, 214, 255, 0.75);
    box-shadow: 0 0 0 3px rgba(89, 214, 255, 0.12);
}
.placeholder-chip-wrap {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}
.placeholder-chip {
    border: 1px solid rgba(89, 214, 255, 0.25);
    color: var(--text);
    background: rgba(89, 214, 255, 0.08);
    border-radius: 999px;
    padding: 8px 10px;
    font-size: 0.82rem;
    cursor: pointer;
    min-height: 38px;
    word-break: break-word;
}
.placeholder-chip:hover:not(:disabled) {
    border-color: rgba(89, 214, 255, 0.7);
    transform: translateY(-1px);
}
.placeholder-chip:disabled {
    opacity: 0.55;
    cursor: not-allowed;
}
.placeholder-chip.is-static {
    cursor: default;
}
.template-actions,
.template-restore-form {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: center;
}
.template-restore-form {
    margin-top: 14px;
    padding-top: 14px;
    border-top: 1px solid rgba(255,255,255,0.08);
}
.telegram-preview-output {
    white-space: pre-wrap;
    word-break: break-word;
    margin: 14px 0 0;
    padding: 14px;
    border-radius: 18px;
    background: rgba(3, 7, 18, 0.68);
    border: 1px solid rgba(255,255,255,0.1);
    color: var(--text);
    line-height: 1.55;
}
.placeholder-reference-grid,
.template-reference-list {
    display: grid;
    gap: 10px;
}
.placeholder-reference-row,
.template-reference-entry {
    display: grid;
    gap: 8px;
    padding: 12px;
    border-radius: 16px;
    background: rgba(255,255,255,0.04);
    border: 1px solid rgba(255,255,255,0.08);
}
.placeholder-reference-row {
    grid-template-columns: minmax(120px, 220px) minmax(0, 1fr);
    align-items: start;
}
.placeholder-reference-row code,
.template-reference-card code {
    color: var(--accent);
    white-space: normal;
    word-break: break-word;
}
@media (max-width: 840px) {
    .template-console {
        grid-template-columns: 1fr;
    }
    .template-list {
        position: static;
    }
    .placeholder-reference-row {
        grid-template-columns: 1fr;
    }
    .template-editor-card,
    .template-preview-card,
    .template-reference-card {
        padding: 14px;
    }
}

.quick-action-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 14px;
}
.quick-action-card {
    display: grid;
    gap: 6px;
    padding: 16px;
    color: inherit;
    text-decoration: none;
    border: 1px solid rgba(89, 214, 255, 0.18);
    border-radius: 18px;
}
.quick-action-card:hover {
    border-color: rgba(89, 214, 255, 0.55);
    transform: translateY(-1px);
}
.quick-action-card span:last-child {
    color: var(--muted-text);
}

/* Task 69 Telegram template editor redesign */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}
.template-page-header {
    align-items: center;
}
.template-header-actions {
    align-items: center;
}
.template-mode-chip,
.template-status {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 28px;
    padding: 5px 9px;
    border-radius: 999px;
    font-size: 0.74rem;
    font-weight: 800;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    border: 1px solid rgba(255,255,255,0.1);
    color: var(--muted-text);
    background: rgba(255,255,255,0.045);
    white-space: nowrap;
}
.template-mode-chip.is-editable,
.template-status.is-custom {
    color: #b8f7d5;
    border-color: rgba(74, 222, 128, 0.32);
    background: rgba(34, 197, 94, 0.12);
}
.template-mode-chip.is-readonly {
    color: #e6d2ff;
    border-color: rgba(168, 85, 247, 0.3);
    background: rgba(168, 85, 247, 0.1);
}
.template-status.is-default,
.template-status.is-muted {
    color: rgba(226, 232, 240, 0.78);
}
.template-workspace {
    display: grid;
    grid-template-columns: minmax(230px, 0.82fr) minmax(420px, 1.65fr) minmax(280px, 0.95fr);
    gap: 18px;
    align-items: start;
}
.template-catalog-panel,
.template-editor-panel,
.template-preview-panel,
.template-placeholder-panel {
    min-width: 0;
    border: 1px solid rgba(255,255,255,0.09);
}
.template-catalog-panel {
    position: sticky;
    top: 92px;
    display: grid;
    gap: 14px;
    padding: 16px;
    max-height: calc(100vh - 120px);
    overflow: auto;
}
.panel-kicker {
    color: var(--accent);
    font-size: 0.72rem;
    font-weight: 900;
    letter-spacing: 0.12em;
    text-transform: uppercase;
}
.template-catalog-head,
.template-editor-header,
.inspector-head {
    display: flex;
    justify-content: space-between;
    gap: 14px;
    align-items: flex-start;
}
.template-catalog-head h2,
.template-editor-header h2,
.inspector-head h2 {
    margin: 2px 0 0;
    font-size: 1.08rem;
    line-height: 1.2;
}
.template-editor-header h2 {
    font-size: 1.35rem;
}
.template-catalog-head p,
.template-editor-header p,
.template-inspector-note,
.template-action-note,
.template-editor-help {
    margin: 6px 0 0;
    color: var(--muted-text);
    line-height: 1.45;
}
.template-catalog-head > span {
    display: inline-grid;
    place-items: center;
    min-width: 34px;
    height: 34px;
    border-radius: 12px;
    font-weight: 900;
    color: var(--text);
    background: rgba(89, 214, 255, 0.1);
    border: 1px solid rgba(89, 214, 255, 0.18);
}
.template-search-box input {
    width: 100%;
    min-height: 44px;
    border: 1px solid rgba(255,255,255,0.1);
    border-radius: 14px;
    background: rgba(4, 9, 24, 0.72);
    color: var(--text);
    padding: 0 12px;
    outline: none;
}
.template-search-box input:focus {
    border-color: rgba(89, 214, 255, 0.65);
    box-shadow: 0 0 0 3px rgba(89, 214, 255, 0.11);
}
.template-category-stack {
    display: grid;
    gap: 16px;
}
.template-category {
    display: grid;
    gap: 8px;
}
.template-category h3 {
    margin: 0;
    color: rgba(226, 232, 240, 0.7);
    font-size: 0.74rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
}
.template-catalog-list {
    display: grid;
    gap: 7px;
}
.template-catalog-item {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 10px;
    align-items: center;
    min-height: 58px;
    padding: 10px 11px;
    color: inherit;
    text-decoration: none;
    border: 1px solid rgba(255,255,255,0.07);
    border-radius: 15px;
    background: rgba(255,255,255,0.035);
}
.template-catalog-item:hover {
    border-color: rgba(89, 214, 255, 0.34);
    background: rgba(89, 214, 255, 0.07);
}
.template-catalog-item.is-active {
    border-color: rgba(89, 214, 255, 0.68);
    background: linear-gradient(135deg, rgba(89, 214, 255, 0.16), rgba(255,255,255,0.04));
    box-shadow: 0 0 0 1px rgba(89, 214, 255, 0.12) inset;
}
.template-catalog-copy {
    display: grid;
    gap: 3px;
    min-width: 0;
}
.template-catalog-copy strong,
.template-catalog-copy small {
    overflow-wrap: anywhere;
}
.template-catalog-copy small {
    color: var(--muted-text);
    font-size: 0.76rem;
}
.template-editor-panel {
    display: grid;
    gap: 16px;
    padding: 20px;
}
.template-meta-row {
    display: flex;
    flex-wrap: wrap;
    gap: 7px;
    justify-content: flex-end;
}
.template-meta-row span {
    padding: 6px 9px;
    border-radius: 999px;
    color: rgba(226, 232, 240, 0.74);
    background: rgba(255,255,255,0.045);
    border: 1px solid rgba(255,255,255,0.08);
    font-size: 0.76rem;
    overflow-wrap: anywhere;
}
.template-editor-error {
    padding: 12px 14px;
    border-radius: 16px;
    color: #fecaca;
    background: rgba(239, 68, 68, 0.12);
    border: 1px solid rgba(248, 113, 113, 0.3);
    line-height: 1.45;
    overflow-wrap: anywhere;
}
.template-editor-form {
    display: grid;
    gap: 10px;
}
.template-textarea-label span {
    display: block;
    font-weight: 800;
    color: var(--text);
}
.template-textarea-label small {
    display: block;
    margin-top: 4px;
    color: var(--muted-text);
    line-height: 1.45;
}
.template-editor-form textarea {
    width: 100%;
    min-height: 430px;
    resize: vertical;
    border-radius: 20px;
    border: 1px solid rgba(255,255,255,0.12);
    background: rgba(3, 7, 18, 0.76);
    color: var(--text);
    padding: 16px;
    font: 500 0.98rem/1.6 ui-monospace, SFMono-Regular, Consolas, monospace;
    outline: none;
    overflow-wrap: anywhere;
}
.template-editor-form textarea:focus {
    border-color: rgba(89, 214, 255, 0.75);
    box-shadow: 0 0 0 4px rgba(89, 214, 255, 0.12);
}
.template-editor-form textarea[readonly] {
    opacity: 0.86;
}
.template-editor-help code {
    color: var(--accent);
    overflow-wrap: anywhere;
}
.template-action-bar {
    position: sticky;
    bottom: 14px;
    z-index: 2;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px;
    padding: 12px;
    border: 1px solid rgba(255,255,255,0.1);
    border-radius: 18px;
    background: rgba(8, 13, 30, 0.92);
    backdrop-filter: blur(16px);
    box-shadow: 0 18px 55px rgba(0,0,0,0.28);
}
.template-action-bar form {
    margin: 0;
}
.template-action-note {
    flex: 1 1 220px;
    font-size: 0.86rem;
}
.template-inspector-stack {
    position: sticky;
    top: 92px;
    display: grid;
    gap: 18px;
    min-width: 0;
    max-height: calc(100vh - 120px);
    overflow: auto;
}
.template-preview-panel,
.template-placeholder-panel {
    padding: 16px;
}
.telegram-message-preview {
    margin-top: 14px;
    padding: 12px;
    border-radius: 22px;
    background:
        radial-gradient(circle at top left, rgba(89, 214, 255, 0.14), transparent 42%),
        rgba(3, 7, 18, 0.62);
    border: 1px solid rgba(255,255,255,0.09);
}
.telegram-message-preview pre {
    margin: 0;
    padding: 14px 15px;
    border-radius: 18px 18px 18px 6px;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
    color: #e6f7ff;
    background: linear-gradient(135deg, rgba(15, 23, 42, 0.94), rgba(8, 47, 73, 0.68));
    border: 1px solid rgba(125, 211, 252, 0.16);
    box-shadow: 0 14px 34px rgba(0,0,0,0.22);
    font: 500 0.94rem/1.55 inherit;
}
.placeholder-group-stack {
    display: grid;
    gap: 10px;
    margin-top: 14px;
}
.placeholder-group {
    border: 1px solid rgba(255,255,255,0.08);
    border-radius: 16px;
    background: rgba(255,255,255,0.035);
    overflow: hidden;
}
.placeholder-group summary {
    display: flex;
    justify-content: space-between;
    gap: 10px;
    align-items: center;
    min-height: 46px;
    padding: 0 12px;
    cursor: pointer;
    font-weight: 800;
}
.placeholder-group summary small {
    color: var(--muted-text);
}
.placeholder-token-grid {
    display: grid;
    gap: 8px;
    padding: 0 10px 10px;
}
.placeholder-token {
    display: grid;
    gap: 4px;
    text-align: left;
    border: 1px solid rgba(89, 214, 255, 0.18);
    background: rgba(89, 214, 255, 0.065);
    color: var(--text);
    border-radius: 14px;
    padding: 9px 10px;
    cursor: pointer;
    min-height: 54px;
}
.placeholder-token:hover:not(:disabled) {
    border-color: rgba(89, 214, 255, 0.62);
    background: rgba(89, 214, 255, 0.1);
}
.placeholder-token:disabled {
    opacity: 0.72;
    cursor: not-allowed;
}
.placeholder-token code {
    color: var(--accent);
    overflow-wrap: anywhere;
}
.placeholder-token span {
    color: var(--muted-text);
    font-size: 0.78rem;
    line-height: 1.35;
}
.template-reference-drawer {
    display: grid;
    gap: 14px;
}
.template-reference-list.compact {
    margin-top: 14px;
}
.template-reference-entry.compact {
    grid-template-columns: minmax(220px, 0.8fr) minmax(0, 1.2fr);
    align-items: start;
}
.reference-group-strip {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}
.reference-group-strip span {
    padding: 7px 9px;
    border-radius: 999px;
    color: rgba(226,232,240,0.78);
    background: rgba(255,255,255,0.045);
    border: 1px solid rgba(255,255,255,0.08);
    font-size: 0.78rem;
}

.template-deprecated-alert {
    display: grid;
    gap: 7px;
    padding: 12px 14px;
    border-radius: 16px;
    color: #fde68a;
    background: rgba(245, 158, 11, 0.1);
    border: 1px solid rgba(245, 158, 11, 0.28);
    line-height: 1.45;
    overflow-wrap: anywhere;
}
.template-deprecated-alert code,
.placeholder-token.is-deprecated code {
    color: #fbbf24;
}
.placeholder-token.is-deprecated {
    border-color: rgba(245, 158, 11, 0.28);
    background: rgba(245, 158, 11, 0.075);
}
.placeholder-token small {
    width: fit-content;
    padding: 3px 7px;
    border-radius: 999px;
    color: #fde68a;
    background: rgba(245, 158, 11, 0.12);
    border: 1px solid rgba(245, 158, 11, 0.2);
    font-size: 0.68rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}
.placeholder-token em {
    color: rgba(253, 230, 138, 0.86);
    font-size: 0.76rem;
    line-height: 1.35;
    font-style: normal;
    overflow-wrap: anywhere;
}
@media (max-width: 1180px) {
    .template-workspace {
        grid-template-columns: minmax(220px, 0.8fr) minmax(0, 1.5fr);
    }
    .template-inspector-stack {
        grid-column: 1 / -1;
        position: static;
        max-height: none;
        grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    }
}
@media (max-width: 760px) {
    .template-page-header,
    .template-catalog-head,
    .template-editor-header,
    .inspector-head {
        align-items: stretch;
        flex-direction: column;
    }
    .template-workspace {
        grid-template-columns: 1fr;
    }
    .template-catalog-panel,
    .template-inspector-stack {
        position: static;
        max-height: none;
        overflow: visible;
    }
    .template-inspector-stack {
        grid-template-columns: 1fr;
    }
    .template-editor-panel {
        padding: 15px;
    }
    .template-editor-form textarea {
        min-height: 360px;
        font-size: 0.96rem;
    }
    .template-action-bar {
        bottom: 10px;
    }
    .template-action-bar .action-link,
    .template-action-bar form,
    .template-action-bar form .action-link {
        width: 100%;
        justify-content: center;
    }
    .template-meta-row {
        justify-content: flex-start;
    }
    .template-reference-entry.compact {
        grid-template-columns: 1fr;
    }
}


/* Task 71 Telegram template editor simplification */
.template-quiet-header {
    padding: 4px 0 12px;
    border: 0;
    background: transparent;
    box-shadow: none;
}
.template-quiet-header h1 {
    margin-bottom: 5px;
    font-size: clamp(26px, 4vw, 36px);
    letter-spacing: -0.03em;
}
.template-quiet-header .table-copy {
    max-width: 680px;
    color: rgba(203, 213, 225, 0.72);
}
.template-clean-workspace {
    display: grid;
    grid-template-columns: minmax(230px, 290px) minmax(520px, 1fr) minmax(270px, 340px);
    grid-template-areas: "catalog editor inspector";
    gap: 24px;
    align-items: start;
}
.template-clean-workspace .template-catalog-panel,
.template-clean-workspace .template-editor-panel,
.template-clean-workspace .template-preview-panel,
.template-clean-workspace .template-placeholder-panel {
    min-width: 0;
    border: 0;
    box-shadow: none;
}
.template-surface {
    grid-area: editor;
    padding: clamp(22px, 3vw, 34px);
    border-radius: 30px;
    background: linear-gradient(180deg, rgba(14, 23, 42, 0.82), rgba(8, 13, 29, 0.76));
    box-shadow: 0 26px 72px rgba(0, 0, 0, 0.28);
}
.template-soft-panel {
    border-radius: 24px;
    background: rgba(12, 18, 36, 0.48);
}
.template-clean-workspace .template-catalog-panel {
    grid-area: catalog;
    position: sticky;
    top: 92px;
    display: grid;
    gap: 18px;
    max-height: calc(100vh - 120px);
    padding: 6px 4px 6px 0;
    overflow: auto;
    background: transparent;
}
.template-clean-workspace .template-inspector-stack {
    grid-area: inspector;
    position: sticky;
    top: 92px;
    display: grid;
    gap: 18px;
    max-height: calc(100vh - 120px);
    overflow: auto;
}
.template-clean-workspace .template-preview-panel,
.template-clean-workspace .template-placeholder-panel {
    padding: 18px;
}
.template-clean-workspace .template-editor-header {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 20px;
    align-items: start;
}
.template-context-line {
    margin: 0 0 8px;
    color: rgba(125, 211, 252, 0.78);
    font-size: 0.78rem;
    font-weight: 800;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    overflow-wrap: anywhere;
}
.template-editor-hero h2 {
    margin: 0;
    color: var(--text);
    font-size: clamp(24px, 3vw, 36px);
    line-height: 1.05;
    letter-spacing: -0.035em;
}
.template-editor-hero p:not(.template-context-line) {
    max-width: 720px;
    margin-top: 10px;
    color: rgba(203, 213, 225, 0.68);
    font-size: 0.98rem;
    line-height: 1.55;
}
.template-quiet-status {
    display: flex;
    gap: 8px;
    justify-content: flex-end;
    flex-wrap: wrap;
    color: rgba(226, 232, 240, 0.72);
    font-size: 0.78rem;
}
.template-quiet-status span {
    padding: 5px 8px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.055);
}
.template-clean-workspace .template-textarea-label span {
    font-size: 0.92rem;
    font-weight: 850;
    letter-spacing: 0.01em;
}
.template-clean-workspace .template-textarea-label small,
.template-clean-workspace .template-editor-help,
.template-clean-workspace .template-inspector-note,
.template-clean-workspace .template-action-note {
    color: rgba(203, 213, 225, 0.64);
}
.template-clean-workspace .template-editor-form {
    gap: 12px;
}
.template-clean-workspace .template-editor-form textarea {
    min-height: min(58vh, 620px);
    border: 1px solid rgba(148, 163, 184, 0.16);
    border-radius: 24px;
    background: rgba(2, 6, 23, 0.68);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04);
    padding: 22px;
    font-size: 1rem;
    line-height: 1.7;
}
.template-clean-workspace .template-editor-form textarea:focus {
    border-color: rgba(125, 211, 252, 0.56);
    box-shadow: 0 0 0 4px rgba(56, 189, 248, 0.1), inset 0 1px 0 rgba(255, 255, 255, 0.04);
}
.template-clean-workspace .template-editor-form textarea[readonly] {
    background: rgba(15, 23, 42, 0.52);
    color: rgba(226, 232, 240, 0.84);
}
.template-clean-workspace .template-action-bar {
    position: static;
    display: flex;
    align-items: center;
    gap: 12px;
    margin-top: 2px;
    padding: 14px 0 0;
    border: 0;
    border-top: 1px solid rgba(148, 163, 184, 0.12);
    border-radius: 0;
    background: transparent;
    box-shadow: none;
    backdrop-filter: none;
}
.template-readonly-note {
    color: rgba(203, 213, 225, 0.7);
    line-height: 1.5;
}
.template-clean-workspace .is-secondary-danger {
    color: #fecaca;
    border-color: rgba(248, 113, 113, 0.22);
    background: rgba(127, 29, 29, 0.18);
}
.template-clean-workspace .template-catalog-head {
    display: block;
    padding: 0 4px;
}
.template-clean-workspace .template-catalog-head h2,
.template-clean-workspace .inspector-head h2 {
    margin: 0;
    font-size: 1rem;
    letter-spacing: -0.01em;
}
.template-clean-workspace .template-catalog-head p,
.template-clean-workspace .inspector-head p {
    margin: 5px 0 0;
    color: rgba(203, 213, 225, 0.58);
    font-size: 0.86rem;
    line-height: 1.4;
}
.template-clean-workspace .template-search-box input {
    min-height: 52px;
    border: 1px solid rgba(148, 163, 184, 0.16);
    border-radius: 18px;
    background: rgba(15, 23, 42, 0.66);
    padding: 0 16px;
    font-size: 0.96rem;
}
.template-clean-workspace .template-search-box input::placeholder {
    color: rgba(148, 163, 184, 0.72);
}
.template-clean-workspace .template-category-stack {
    gap: 20px;
}
.template-clean-workspace .template-category h3 {
    padding: 0 4px;
    color: rgba(148, 163, 184, 0.74);
    font-size: 0.72rem;
    letter-spacing: 0.12em;
}
.template-clean-workspace .template-catalog-list {
    gap: 3px;
}
.template-clean-workspace .template-catalog-item {
    min-height: 62px;
    padding: 11px 12px;
    border: 0;
    border-radius: 16px;
    background: transparent;
    text-decoration: none;
    box-shadow: none;
}
.template-clean-workspace .template-catalog-item:hover {
    background: rgba(255, 255, 255, 0.045);
    transform: none;
}
.template-clean-workspace .template-catalog-item.is-active {
    background: rgba(56, 189, 248, 0.11);
    box-shadow: inset 3px 0 0 rgba(125, 211, 252, 0.9);
}
.template-clean-workspace .template-catalog-copy strong {
    font-size: 0.92rem;
    font-weight: 760;
    line-height: 1.25;
}
.template-clean-workspace .template-catalog-copy small {
    color: rgba(148, 163, 184, 0.76);
    font-size: 0.74rem;
}
.template-list-state {
    color: rgba(203, 213, 225, 0.62);
    font-size: 0.72rem;
    white-space: nowrap;
}
.template-list-state.is-custom {
    color: #86efac;
}
.template-clean-workspace .telegram-message-preview {
    margin-top: 14px;
    padding: 0;
    border: 0;
    border-radius: 0;
    background: transparent;
}
.template-clean-workspace .telegram-message-preview pre {
    border: 0;
    border-radius: 22px 22px 22px 8px;
    background: rgba(15, 23, 42, 0.74);
    box-shadow: none;
    padding: 16px;
    color: rgba(226, 246, 255, 0.96);
    font-size: 0.94rem;
}
.template-clean-workspace .placeholder-group-stack {
    gap: 4px;
    margin-top: 12px;
}
.template-clean-workspace .placeholder-group {
    border: 0;
    border-top: 1px solid rgba(148, 163, 184, 0.1);
    border-radius: 0;
    background: transparent;
}
.template-clean-workspace .placeholder-group:first-child {
    border-top: 0;
}
.template-clean-workspace .placeholder-group summary {
    min-height: 44px;
    padding: 0;
    font-size: 0.88rem;
}
.template-clean-workspace .placeholder-token-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    padding: 2px 0 12px;
}
.template-clean-workspace .placeholder-token {
    display: inline-flex;
    align-items: center;
    min-height: 34px;
    max-width: 100%;
    padding: 7px 10px;
    border: 1px solid rgba(125, 211, 252, 0.16);
    border-radius: 999px;
    background: rgba(56, 189, 248, 0.065);
}
.template-clean-workspace .placeholder-token:hover:not(:disabled) {
    background: rgba(56, 189, 248, 0.12);
    border-color: rgba(125, 211, 252, 0.32);
    transform: none;
}
.template-clean-workspace .placeholder-token span,
.template-clean-workspace .placeholder-token em {
    display: none;
}
.template-clean-workspace .placeholder-token code {
    color: rgba(186, 230, 253, 0.95);
    font-size: 0.78rem;
}
.template-clean-workspace .placeholder-token small {
    margin-left: 5px;
    padding: 2px 6px;
    border: 0;
    background: rgba(245, 158, 11, 0.16);
    font-size: 0.62rem;
}
.template-clean-workspace .template-deprecated-alert,
.template-clean-workspace .template-editor-error {
    border: 0;
    box-shadow: none;
}
.template-advanced-reference {
    margin-top: 8px;
    padding: 0;
    color: rgba(203, 213, 225, 0.74);
}
.template-advanced-reference summary {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    align-items: center;
    min-height: 54px;
    padding: 0;
    cursor: pointer;
}
.template-advanced-reference summary > span:last-child {
    color: rgba(148, 163, 184, 0.76);
    font-size: 0.84rem;
}
.template-advanced-reference .template-reference-entry.compact {
    border: 0;
    border-top: 1px solid rgba(148, 163, 184, 0.1);
    border-radius: 0;
    background: transparent;
}
.template-advanced-reference .reference-group-strip span {
    border: 0;
    background: rgba(255, 255, 255, 0.035);
}
@media (max-width: 1180px) {
    .template-clean-workspace {
        grid-template-columns: minmax(220px, 300px) minmax(0, 1fr);
        grid-template-areas:
            "catalog editor"
            "inspector inspector";
    }
    .template-clean-workspace .template-inspector-stack {
        grid-area: inspector;
        grid-column: auto;
        position: static;
        grid-template-columns: minmax(0, 0.9fr) minmax(0, 1.1fr);
        max-height: none;
        overflow: visible;
    }
}
@media (max-width: 760px) {
    .template-quiet-header {
        padding-top: 0;
    }
    .template-clean-workspace {
        grid-template-columns: 1fr;
        grid-template-areas:
            "editor"
            "inspector"
            "catalog";
        gap: 18px;
    }
    .template-surface {
        padding: 18px;
        border-radius: 24px;
    }
    .template-clean-workspace .template-editor-header {
        grid-template-columns: 1fr;
        gap: 12px;
    }
    .template-quiet-status {
        justify-content: flex-start;
    }
    .template-clean-workspace .template-editor-form textarea {
        min-height: 380px;
        padding: 16px;
        font-size: 0.96rem;
    }
    .template-clean-workspace .template-action-bar {
        align-items: stretch;
        flex-direction: column;
    }
    .template-clean-workspace .template-action-bar .action-link,
    .template-clean-workspace .template-action-bar form,
    .template-clean-workspace .template-action-bar form .action-link {
        width: 100%;
        justify-content: center;
    }
    .template-clean-workspace .template-inspector-stack {
        grid-area: inspector;
        grid-column: auto;
        position: static;
        grid-template-columns: 1fr;
        max-height: none;
        overflow: visible;
    }
    .template-clean-workspace .template-catalog-panel {
        grid-area: catalog;
        position: static;
        max-height: none;
        overflow: visible;
        padding: 0;
    }
    .template-clean-workspace .template-preview-panel,
    .template-clean-workspace .template-placeholder-panel {
        padding: 16px;
    }
    .template-clean-workspace .template-catalog-item {
        min-height: 58px;
    }
}


/* Task 73 premium Telegram template selector buttons */
.template-clean-workspace .template-catalog-panel {
    padding-right: 2px;
}

.template-clean-workspace .template-catalog-list {
    display: grid;
    gap: 10px;
}

.template-clean-workspace .template-category-stack {
    gap: 24px;
}

.template-clean-workspace .template-category {
    gap: 10px;
}

.template-clean-workspace .template-category h3 {
    display: flex;
    align-items: center;
    gap: 9px;
    padding: 0 6px;
    color: rgba(203, 213, 225, 0.66);
    font-size: 0.72rem;
    font-weight: 850;
    letter-spacing: 0.14em;
}

.template-clean-workspace .template-category h3::after {
    content: "";
    height: 1px;
    flex: 1 1 auto;
    background: linear-gradient(90deg, rgba(125, 211, 252, 0.22), transparent);
}

.template-selector-form {
    margin: 0;
    min-width: 0;
}

.template-selector-form[hidden] {
    display: none !important;
}

.template-selector-button {
    position: relative;
    isolation: isolate;
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
    gap: 12px;
    width: 100%;
    min-height: 76px;
    padding: 14px 14px 14px 16px;
    overflow: hidden;
    border: 1px solid rgba(148, 163, 184, 0.16);
    border-radius: 22px;
    background:
        radial-gradient(circle at 18% 0%, rgba(125, 211, 252, 0.12), transparent 34%),
        linear-gradient(145deg, rgba(15, 23, 42, 0.78), rgba(7, 12, 28, 0.9));
    box-shadow:
        inset 0 1px 0 rgba(255, 255, 255, 0.055),
        0 14px 34px rgba(0, 0, 0, 0.12);
    color: var(--text);
    text-align: left;
    text-decoration: none;
    cursor: pointer;
    appearance: none;
    -webkit-appearance: none;
    transition: transform 160ms ease, border-color 160ms ease, background 160ms ease, box-shadow 160ms ease;
}

.template-selector-button::before {
    content: "";
    position: absolute;
    inset: 0;
    z-index: -1;
    opacity: 0;
    background:
        radial-gradient(circle at 28% 0%, rgba(56, 189, 248, 0.22), transparent 42%),
        linear-gradient(145deg, rgba(15, 23, 42, 0.92), rgba(8, 47, 73, 0.54));
    transition: opacity 180ms ease;
}

.template-selector-button::after {
    content: "";
    position: absolute;
    inset: 10px auto 10px 0;
    width: 3px;
    border-radius: 0 999px 999px 0;
    background: rgba(125, 211, 252, 0);
    transition: background 160ms ease, box-shadow 160ms ease;
}

.template-selector-button:hover {
    transform: translateY(-2px);
    border-color: rgba(125, 211, 252, 0.36);
    box-shadow:
        inset 0 1px 0 rgba(255, 255, 255, 0.07),
        0 18px 42px rgba(8, 47, 73, 0.22),
        0 0 0 1px rgba(125, 211, 252, 0.06);
}

.template-selector-button:hover::before,
.template-selector-button.is-active::before {
    opacity: 1;
}

.template-selector-button:focus-visible {
    outline: none;
    border-color: rgba(125, 211, 252, 0.82);
    box-shadow:
        0 0 0 4px rgba(56, 189, 248, 0.18),
        0 20px 48px rgba(8, 47, 73, 0.28);
}

.template-selector-button.is-active {
    border-color: rgba(125, 211, 252, 0.74);
    background:
        radial-gradient(circle at 20% 0%, rgba(56, 189, 248, 0.25), transparent 36%),
        linear-gradient(145deg, rgba(14, 54, 88, 0.72), rgba(10, 18, 38, 0.94));
    box-shadow:
        inset 0 1px 0 rgba(255, 255, 255, 0.08),
        inset 0 0 0 1px rgba(125, 211, 252, 0.16),
        0 20px 54px rgba(8, 47, 73, 0.34),
        0 0 28px rgba(56, 189, 248, 0.13);
}

.template-selector-button.is-active::after {
    background: rgba(125, 211, 252, 0.96);
    box-shadow: 0 0 18px rgba(56, 189, 248, 0.55);
}

.template-selector-button.is-custom:not(.is-active) {
    border-color: rgba(134, 239, 172, 0.24);
}

.template-selector-copy {
    display: grid;
    gap: 5px;
    min-width: 0;
}

.template-selector-copy strong,
.template-selector-copy small {
    min-width: 0;
    overflow-wrap: anywhere;
}

.template-selector-copy strong {
    color: rgba(248, 250, 252, 0.95);
    font-size: 0.95rem;
    font-weight: 820;
    line-height: 1.22;
    letter-spacing: -0.01em;
}

.template-selector-copy small {
    color: rgba(148, 163, 184, 0.76);
    font-family: "Cascadia Code", Consolas, monospace;
    font-size: 0.72rem;
    line-height: 1.35;
}

.template-selector-button.is-active .template-selector-copy small {
    color: rgba(186, 230, 253, 0.82);
}

.template-selector-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 26px;
    padding: 5px 9px;
    border-radius: 999px;
    border: 1px solid rgba(148, 163, 184, 0.14);
    background: rgba(15, 23, 42, 0.64);
    color: rgba(203, 213, 225, 0.72);
    font-size: 0.68rem;
    font-weight: 850;
    letter-spacing: 0.04em;
    line-height: 1;
    white-space: nowrap;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.045);
}

.template-selector-badge.is-custom {
    border-color: rgba(134, 239, 172, 0.28);
    background: rgba(21, 128, 61, 0.15);
    color: rgba(187, 247, 208, 0.94);
}

.template-selector-button.is-active .template-selector-badge.is-default {
    border-color: rgba(125, 211, 252, 0.28);
    background: rgba(14, 165, 233, 0.16);
    color: rgba(224, 242, 254, 0.92);
}

.template-selector-button.is-active .template-selector-badge.is-custom {
    border-color: rgba(134, 239, 172, 0.44);
    background: linear-gradient(135deg, rgba(34, 197, 94, 0.24), rgba(14, 165, 233, 0.14));
    color: rgba(220, 252, 231, 0.98);
}

.template-clean-workspace .template-search-box input {
    border-color: rgba(125, 211, 252, 0.18);
    background:
        linear-gradient(145deg, rgba(15, 23, 42, 0.82), rgba(7, 12, 28, 0.86));
    box-shadow:
        inset 0 1px 0 rgba(255, 255, 255, 0.045),
        0 12px 28px rgba(0, 0, 0, 0.12);
}

.template-clean-workspace .template-search-box input:focus {
    border-color: rgba(125, 211, 252, 0.72);
    box-shadow:
        0 0 0 4px rgba(56, 189, 248, 0.14),
        0 16px 38px rgba(8, 47, 73, 0.22);
}

@media (max-width: 760px) {
    .template-selector-button {
        min-height: 68px;
        padding: 13px 12px 13px 14px;
        border-radius: 20px;
    }

    .template-selector-badge {
        min-height: 24px;
        padding: 5px 8px;
    }
}


/* Task 79: command-oriented Telegram template catalog */
.template-trigger-panel {
    margin: 0 24px 8px;
    padding: 16px 18px;
    border: 1px solid rgba(105, 166, 255, 0.18);
    border-radius: 18px;
    background: rgba(12, 24, 44, 0.52);
    display: grid;
    gap: 12px;
}

.template-trigger-panel p {
    margin: 4px 0 0;
    color: var(--text-muted);
    line-height: 1.55;
}

.template-trigger-chip-row {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.template-trigger-chip-row code,
.template-selector-triggers {
    overflow-wrap: anywhere;
}

.template-trigger-chip-row code {
    border: 1px solid rgba(83, 205, 255, 0.22);
    border-radius: 999px;
    padding: 6px 10px;
    background: rgba(35, 196, 255, 0.08);
    color: #bfefff;
    font-size: 0.82rem;
}

.template-catalog-stats {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
    padding: 0 24px 16px;
}

.template-catalog-stats span {
    border: 1px solid rgba(148, 163, 184, 0.16);
    border-radius: 14px;
    padding: 8px 10px;
    background: rgba(15, 23, 42, 0.52);
    color: var(--text-muted);
    font-size: 0.8rem;
    font-weight: 700;
}

.template-command-group h3 {
    letter-spacing: 0.16em;
}

.template-selector-triggers {
    display: block;
    margin-top: 8px;
    color: rgba(191, 239, 255, 0.68);
    font-size: 0.78rem;
    line-height: 1.35;
}

.template-selector-button.is-active .template-selector-triggers {
    color: rgba(226, 246, 255, 0.9);
}

@media (max-width: 720px) {
    .template-trigger-panel {
        margin: 0 14px 8px;
        padding: 14px;
    }

    .template-catalog-stats {
        grid-template-columns: 1fr;
        padding: 0 14px 14px;
    }
}


/* Template block variable visibility */
.template-block-variable-panel {
    margin: 0 24px 10px;
    padding: 18px;
    border: 1px solid rgba(59, 130, 246, 0.22);
    border-radius: 20px;
    background: linear-gradient(180deg, rgba(15, 34, 62, 0.72), rgba(8, 16, 31, 0.58));
}

.template-block-variable-head {
    display: flex;
    justify-content: space-between;
    gap: 14px;
    margin-bottom: 14px;
}

.template-block-variable-head h3 {
    margin: 4px 0 6px;
    color: var(--text-main);
    font-size: 1rem;
    font-weight: 800;
}

.template-block-variable-head p {
    margin: 0;
    color: var(--text-muted);
    line-height: 1.55;
}

.template-block-variable-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
}

.template-block-variable-card {
    border: 1px solid rgba(148, 163, 184, 0.18);
    border-radius: 16px;
    padding: 12px;
    background: rgba(5, 12, 24, 0.54);
    min-width: 0;
}

.template-block-variable-card.is-used {
    border-color: rgba(34, 197, 94, 0.42);
    box-shadow: 0 0 0 1px rgba(34, 197, 94, 0.08), 0 14px 34px rgba(20, 83, 45, 0.16);
}

.template-block-variable-card header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 10px;
    margin-bottom: 9px;
}

.template-block-variable-card header span {
    border: 1px solid rgba(148, 163, 184, 0.2);
    border-radius: 999px;
    padding: 4px 8px;
    color: var(--text-muted);
    font-size: 0.72rem;
    font-weight: 800;
    white-space: nowrap;
}

.template-block-variable-card.is-used header span {
    border-color: rgba(34, 197, 94, 0.4);
    color: #b8f7cf;
    background: rgba(34, 197, 94, 0.08);
}

.template-block-variable-card p {
    margin: 0 0 10px;
    color: var(--text-muted);
    line-height: 1.5;
    font-size: 0.88rem;
}

.template-block-variable-card pre {
    margin: 0;
    max-height: 220px;
    overflow: auto;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
    border: 1px solid rgba(59, 130, 246, 0.14);
    border-radius: 12px;
    padding: 10px;
    background: rgba(2, 6, 23, 0.68);
    color: #d7ecff;
    font-size: 0.78rem;
    line-height: 1.45;
}

.template-block-token {
    border: 1px solid rgba(83, 205, 255, 0.24);
    border-radius: 999px;
    padding: 6px 10px;
    background: rgba(35, 196, 255, 0.08);
    color: #c8efff;
    cursor: pointer;
    text-align: left;
    max-width: 100%;
}

.template-block-token code {
    white-space: normal;
    overflow-wrap: anywhere;
}

.template-block-token:hover:not(:disabled),
.template-block-token:focus-visible:not(:disabled) {
    border-color: rgba(56, 189, 248, 0.72);
    box-shadow: 0 0 0 3px rgba(56, 189, 248, 0.14);
}

.template-block-token:disabled {
    opacity: 0.65;
    cursor: not-allowed;
}

@media (max-width: 860px) {
    .template-block-variable-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 720px) {
    .template-block-variable-panel {
        margin: 0 14px 10px;
        padding: 14px;
    }
}


.template-block-edit-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin-top: 10px;
    min-height: 34px;
    border: 1px solid rgba(56, 189, 248, 0.24);
    border-radius: 999px;
    padding: 6px 11px;
    color: #c8efff;
    background: rgba(14, 165, 233, 0.08);
    font-size: 0.8rem;
    font-weight: 800;
    text-decoration: none;
}

.template-block-edit-link:hover,
.template-block-edit-link:focus-visible {
    border-color: rgba(56, 189, 248, 0.7);
    color: #ffffff;
    box-shadow: 0 0 0 3px rgba(56, 189, 248, 0.14);
}
