:root {
    --bg: #07080d;
    --bg-elevated: #0f1118;
    --surface: #141822;
    --surface-hover: #1a2030;
    --border: rgba(255, 255, 255, 0.08);
    --border-active: rgba(168, 85, 247, 0.55);
    --text: #f4f4f5;
    --muted: #9ca3af;
    --accent: #a855f7;
    --accent-soft: rgba(168, 85, 247, 0.15);
    --accent-glow: rgba(168, 85, 247, 0.35);
    --male: #3b82f6;
    --female: #ec4899;
    --success: #22c55e;
    --warn: #fbbf24;
    --radius: 16px;
    --radius-sm: 10px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
    /* Только локальные/system шрифты — без Google Fonts (РФ) */
    font-family: system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, 'Noto Sans', sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    line-height: 1.5;
}

body::before {
    content: '';
    position: fixed;
    inset: 0;
    background:
        radial-gradient(ellipse 80% 50% at 50% -20%, rgba(168, 85, 247, 0.18), transparent),
        radial-gradient(ellipse 60% 40% at 100% 50%, rgba(59, 130, 246, 0.08), transparent);
    pointer-events: none;
    z-index: 0;
}

.wrap { position: relative; z-index: 1; max-width: 1100px; margin: 0 auto; padding: 24px 20px 80px; }

/* Top bar */
.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
    margin-bottom: 32px;
    padding-bottom: 20px;
    border-bottom: 1px solid var(--border);
}

.topbar-brand {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text);
    text-decoration: none;
    background: linear-gradient(135deg, #fff, #c4b5fd, #a855f7);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.topbar-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }

.balance-widget {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 14px;
    border-radius: 999px;
    background: var(--accent-soft);
    border: 1px solid var(--border-active);
    font-size: 0.85rem;
    white-space: nowrap;
    flex-shrink: 0;
}

.balance-widget [data-guest-bar-text] {
    font-weight: 600;
    font-variant-numeric: tabular-nums;
}

.balance-widget .balance-num {
    font-weight: 700;
    color: #e9d5ff;
    font-variant-numeric: tabular-nums;
}

.balance-widget.guest { border-color: var(--border); background: var(--surface); }
.balance-widget.guest .balance-num { color: var(--muted); font-weight: 500; }

button.balance-widget {
    font-family: inherit;
    color: inherit;
    margin: 0;
}

.balance-widget--clickable {
    cursor: pointer;
    transition: border-color 0.15s, background 0.15s, box-shadow 0.15s;
}

.balance-widget--clickable:hover {
    border-color: rgba(192, 132, 252, 0.65);
    background: rgba(168, 85, 247, 0.22);
    box-shadow: 0 0 0 1px rgba(168, 85, 247, 0.2);
}

.balance-widget--clickable:focus-visible {
    outline: 2px solid rgba(168, 85, 247, 0.55);
    outline-offset: 2px;
}

.btn {
    padding: 10px 18px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text);
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-family: inherit;
    transition: all 0.2s;
}

.btn:hover { border-color: rgba(255,255,255,0.2); background: var(--surface-hover); }

.btn-primary {
    background: linear-gradient(135deg, #9333ea, #7c3aed);
    border: none;
    color: #fff;
    box-shadow: 0 4px 20px var(--accent-glow);
}

.btn-primary:hover { transform: translateY(-1px); }

.btn-ghost { background: transparent; }

.btn:disabled,
.btn[disabled] {
    opacity: 0.35;
    cursor: not-allowed;
    pointer-events: none;
}

/* Папка на главной — в стиле вкладок голосов */
.folder-bar {
    margin-bottom: 16px;
    padding: 16px 18px;
    border-radius: var(--radius);
    background: linear-gradient(145deg, rgba(168, 85, 247, 0.08), rgba(15, 17, 24, 0.95));
    border: 1px solid rgba(168, 85, 247, 0.22);
    box-shadow: 0 4px 24px rgba(0, 0, 0, 0.25), inset 0 1px 0 rgba(255, 255, 255, 0.04);
}

.folder-bar__head {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 14px;
}

.folder-bar__icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border-radius: 12px;
    background: var(--accent-soft);
    border: 1px solid var(--border-active);
    color: #c4b5fd;
    flex-shrink: 0;
}

.folder-bar__text { display: flex; flex-direction: column; gap: 2px; }

.folder-bar__title {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text);
}

.folder-bar__hint {
    font-size: 0.75rem;
    color: var(--muted);
}

.folder-pills {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.folder-pill {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 16px;
    border-radius: 999px;
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--muted);
    font-size: 0.88rem;
    font-weight: 500;
    font-family: inherit;
    cursor: pointer;
    transition: border-color 0.2s, background 0.2s, color 0.2s, box-shadow 0.2s, transform 0.15s;
}

.folder-pill:hover {
    color: var(--text);
    border-color: rgba(255, 255, 255, 0.18);
    background: var(--surface-hover);
}

.folder-pill.active {
    background: linear-gradient(135deg, rgba(147, 51, 234, 0.35), rgba(124, 58, 237, 0.2));
    border-color: var(--border-active);
    color: #e9d5ff;
    box-shadow: 0 0 20px var(--accent-glow);
}

.folder-pill__name { line-height: 1.2; }

.folder-pill__badge {
    font-size: 0.65rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    padding: 2px 8px;
    border-radius: 999px;
    background: rgba(168, 85, 247, 0.2);
    color: #c4b5fd;
    font-weight: 600;
}

.folder-pill.active .folder-pill__badge {
    background: rgba(255, 255, 255, 0.12);
    color: #f3e8ff;
}

@media (max-width: 640px) {
    .folder-pills { gap: 6px; }
    .folder-pill { flex: 1 1 auto; justify-content: center; min-width: calc(50% - 6px); }
}

section {
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 24px;
    margin-bottom: 20px;
}

section h2 {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    color: var(--muted);
    margin-bottom: 18px;
    font-weight: 600;
}

/* Modal */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.65);
    z-index: 1000;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 16px;
}

.modal-overlay.open { display: flex; }

#authModal.open {
    z-index: 1100;
}

#noticeModal.open {
    z-index: 2000;
}

.modal {
    width: 100%;
    max-width: 420px;
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 28px;
}

.modal h3 { margin-bottom: 8px; font-size: 1.25rem; }
.modal p.sub { color: var(--muted); font-size: 0.9rem; margin-bottom: 20px; line-height: 1.5; }

/* Branded scroll (RechAI purple) — use instead of default OS scrollbars */
.rechai-scroll {
    scrollbar-width: thin;
    scrollbar-color: rgba(168, 85, 247, 0.55) rgba(255, 255, 255, 0.06);
}

.rechai-scroll::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

.rechai-scroll::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.05);
    border-radius: 999px;
}

.rechai-scroll::-webkit-scrollbar-thumb {
    background: linear-gradient(180deg, rgba(192, 132, 252, 0.75), rgba(124, 58, 237, 0.85));
    border-radius: 999px;
    border: 2px solid transparent;
    background-clip: padding-box;
}

.rechai-scroll::-webkit-scrollbar-thumb:hover {
    background: linear-gradient(180deg, rgba(216, 180, 254, 0.9), rgba(147, 51, 234, 0.95));
    background-clip: padding-box;
}

.rechai-scroll::-webkit-scrollbar-corner {
    background: transparent;
}

.modal-actions {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
    flex-wrap: wrap;
    margin-top: 4px;
}

.confirm-modal { max-width: 440px; }

.notice-modal {
    max-width: 440px;
    position: relative;
    text-align: center;
}

.notice-modal__close {
    position: absolute;
    top: 12px;
    right: 12px;
    padding: 4px 10px;
    line-height: 1;
}

.notice-modal__icon {
    width: 56px;
    height: 56px;
    margin: 0 auto 16px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    font-weight: 700;
}

.notice-modal--success .notice-modal__icon {
    background: rgba(34, 197, 94, 0.15);
    border: 1px solid rgba(74, 222, 128, 0.4);
    color: #86efac;
}

.notice-modal--error .notice-modal__icon {
    background: rgba(239, 68, 68, 0.12);
    border: 1px solid rgba(248, 113, 113, 0.4);
    color: #fca5a5;
}

.notice-modal--wait .notice-modal__icon {
    background: rgba(168, 85, 247, 0.12);
    border: 1px solid rgba(192, 132, 252, 0.35);
    color: #e9d5ff;
}

.notice-modal--info .notice-modal__icon {
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid var(--border);
    color: var(--muted);
}

.notice-modal--share .notice-modal__icon {
    background: rgba(34, 197, 94, 0.14);
    border: 1px solid rgba(74, 222, 128, 0.45);
    color: #4ade80;
}

.notice-modal--share .notice-modal__icon svg {
    display: block;
}

.notice-modal h3 {
    margin-bottom: 10px;
    font-size: 1.2rem;
}

.notice-modal p.sub {
    margin-bottom: 22px;
    white-space: pre-line;
}

.notice-modal .btn-primary {
    width: 100%;
}

.notice-spinner {
    width: 40px;
    height: 40px;
    margin: 0 auto 18px;
    border: 3px solid rgba(168, 85, 247, 0.2);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: notice-spin 0.85s linear infinite;
}

@keyframes notice-spin {
    to { transform: rotate(360deg); }
}

.btn-danger {
    background: rgba(239, 68, 68, 0.18);
    border-color: rgba(248, 113, 113, 0.45);
    color: #fecaca;
}

.btn-danger:hover:not(:disabled) {
    background: rgba(239, 68, 68, 0.28);
    border-color: rgba(248, 113, 113, 0.65);
}

.btn-sm {
    padding: 6px 12px;
    font-size: 0.82rem;
    min-height: 34px;
}

.input {
    width: 100%;
    padding: 12px 14px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text);
    font-size: 1rem;
    font-family: inherit;
    margin-bottom: 12px;
}

.input:focus {
    outline: none;
    border-color: var(--border-active);
    box-shadow: 0 0 0 3px var(--accent-soft);
}

.oauth-row { display: flex; flex-direction: column; gap: 10px; margin: 16px 0; }
.oauth-btn {
    width: 100%;
    justify-content: center;
    padding: 12px;
}

.divider {
    text-align: center;
    color: var(--muted);
    font-size: 0.8rem;
    margin: 16px 0;
    position: relative;
}
.divider::before, .divider::after {
    content: '';
    position: absolute;
    top: 50%;
    width: 40%;
    height: 1px;
    background: var(--border);
}
.divider::before { left: 0; }
.divider::after { right: 0; }

/* Package cards */
.packages-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 16px;
}

.packages-grid--tariffs {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 14px;
    min-width: 0;
}

.packages-grid--tariffs .package-card {
    min-width: 0;
    padding: 18px 16px 16px;
    display: flex;
    flex-direction: column;
    height: 100%;
}

.packages-grid--tariffs .pkg-name {
    font-size: 1.12rem;
    margin-bottom: 6px;
    padding-right: 52px;
    line-height: 1.2;
}

.packages-grid--tariffs .pkg-tagline {
    font-size: 0.78rem;
    margin-bottom: 12px;
    line-height: 1.45;
    flex: 1;
    min-height: 2.6em;
}

.packages-grid--tariffs .pkg-chars {
    font-size: 1.05rem;
    line-height: 1.3;
    margin-bottom: 6px;
    font-variant-numeric: tabular-nums;
}

.packages-grid--tariffs .pkg-price {
    font-size: 1.35rem;
    margin-bottom: 8px;
}

.packages-grid--tariffs .pkg-price-note {
    margin-top: 0;
    margin-bottom: 14px;
}

.packages-grid--tariffs .package-card__buy,
.packages-grid--tariffs .btn {
    width: 100%;
    margin-top: auto;
}

.packages-grid--tariffs .pkg-badge {
    top: 12px;
    right: 12px;
    font-size: 0.62rem;
    padding: 3px 8px;
}

.package-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 22px;
    position: relative;
    transition: all 0.2s;
}

.package-card:hover {
    border-color: var(--border-active);
    transform: translateY(-2px);
}

.package-card.featured {
    border-color: var(--border-active);
    box-shadow: 0 0 0 1px var(--accent-soft);
}

.pkg-badge {
    position: absolute;
    top: 14px;
    right: 14px;
    font-size: 0.7rem;
    padding: 4px 10px;
    border-radius: 999px;
    background: var(--accent);
    color: #fff;
    font-weight: 600;
}

.pkg-name { font-size: 1.35rem; font-weight: 700; margin-bottom: 4px; }
.pkg-tagline { color: var(--muted); font-size: 0.85rem; margin-bottom: 16px; }
.pkg-chars { font-size: 1.5rem; font-weight: 700; color: #e9d5ff; margin-bottom: 4px; }
.pkg-price { font-size: 1.75rem; font-weight: 700; margin-bottom: 18px; }

.pkg-price-note {
    font-size: 0.8rem;
    color: var(--muted);
    margin-top: -10px;
    margin-bottom: 14px;
}

.prices-modal__intro {
    font-size: 0.9rem;
    color: var(--muted);
    line-height: 1.55;
    margin: 0 0 20px;
}

.prices-modal__foot {
    font-size: 0.85rem;
    color: var(--muted);
    line-height: 1.55;
    margin: 20px 0 0;
    padding-top: 16px;
    border-top: 1px solid var(--border);
}

/* Cabinet — dismissible promo blocks */
.cabinet-promo-panel {
    position: relative;
    margin-bottom: 36px;
}

.cabinet-promo-panel[hidden] {
    display: none !important;
}

.cabinet-promo-panel__head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 20px;
}

.cabinet-promo-panel__head h2 {
    margin-bottom: 8px;
}

.cabinet-promo-panel__intro {
    color: var(--muted);
    font-size: 0.9rem;
    margin: 0;
    line-height: 1.5;
    max-width: 640px;
}

.cabinet-promo-panel__close {
    flex-shrink: 0;
    padding: 6px 10px !important;
    min-height: auto !important;
    line-height: 1;
    color: var(--muted);
    cursor: pointer;
    z-index: 2;
}

.cabinet-promo-panel__close:hover {
    color: var(--text);
}

.cabinet-promo-panel__close:focus-visible {
    outline: 2px solid rgba(168, 85, 247, 0.55);
    outline-offset: 2px;
}

.cabinet-promo-panel__close--corner {
    position: absolute;
    top: 10px;
    right: 10px;
    z-index: 1;
}

/* Dictations — sidebar block (desktop) */
.sidebar-mic {
    margin-top: 16px;
    background: linear-gradient(165deg, rgba(88, 28, 135, 0.16), rgba(20, 24, 34, 0.92));
    border-color: rgba(168, 85, 247, 0.26);
}

.sidebar-mic__head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 8px;
    margin-bottom: 12px;
}

.sidebar-mic__title {
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
}

.sidebar-mic__icon {
    font-size: 1.4rem;
    line-height: 1;
    flex-shrink: 0;
}

.sidebar-mic__head h2 {
    margin: 0;
}

.sidebar-mic__hint {
    color: var(--muted);
    font-size: 0.82rem;
    line-height: 1.5;
    margin: 0 0 10px;
}

.sidebar-mic__status {
    line-height: 1.45;
}

.sidebar-mic .mic-packages-status {
    margin-bottom: 8px;
}

.sidebar-mic__btn {
    width: 100%;
    margin-top: 0;
}

.char-packages-modal {
    max-width: min(960px, calc(100vw - 32px));
    width: 100%;
    max-height: calc(100vh - 32px);
    display: flex;
    flex-direction: column;
    padding: 0;
    overflow: hidden;
}

.char-packages-modal__head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    padding: 22px 22px 0;
    flex-shrink: 0;
}

.char-packages-modal__head h3 {
    margin: 0 0 6px;
    font-size: 1.2rem;
}

.char-packages-modal__sub {
    margin: 0;
    line-height: 1.45;
}

.char-packages-modal__close {
    flex-shrink: 0;
    padding: 4px 10px;
}

.char-packages-modal__body {
    padding: 18px 22px 24px;
    overflow-x: hidden;
    overflow-y: auto;
    min-width: 0;
}

.modal:has(.packages-grid--tariffs),
.content-modal:has(.packages-grid--tariffs) {
    max-width: min(960px, calc(100vw - 32px));
    width: min(960px, calc(100vw - 32px));
}

/* Mic packages — compact teaser + buy modal */
.mic-packages-teaser {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    flex-wrap: wrap;
    margin-bottom: 36px;
    padding: 18px 44px 18px 20px;
    background: linear-gradient(135deg, rgba(88, 28, 135, 0.18), rgba(20, 24, 34, 0.95));
    border: 1px solid rgba(168, 85, 247, 0.28);
    border-radius: var(--radius);
}

.mic-packages-teaser__main {
    display: flex;
    align-items: flex-start;
    gap: 14px;
    flex: 1;
    min-width: 220px;
}

.mic-packages-teaser__icon {
    font-size: 1.75rem;
    line-height: 1;
    margin-top: 2px;
}

.mic-packages-teaser__text h2 {
    margin: 0 0 4px;
    font-size: 1.15rem;
}

.mic-packages-teaser__hint {
    color: var(--muted);
    font-size: 0.85rem;
    margin: 0 0 6px;
    line-height: 1.45;
    max-width: 520px;
}

.mic-packages-teaser__btn {
    flex-shrink: 0;
    white-space: nowrap;
}

.mic-packages-status {
    font-size: 0.88rem;
    color: #d8b4fe;
    margin: 0;
}

.mic-buy-modal {
    width: min(440px, calc(100vw - 32px));
    max-height: calc(100vh - 32px);
    display: flex;
    flex-direction: column;
    padding: 0;
    overflow: hidden;
}

.mic-buy-modal__head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    padding: 22px 22px 0;
}

.mic-buy-modal__head h3 {
    margin: 0 0 6px;
    font-size: 1.2rem;
}

.mic-buy-modal__sub {
    margin: 0;
    line-height: 1.45;
}

.mic-buy-modal__close {
    flex-shrink: 0;
    padding: 4px 10px;
}

.mic-buy-modal__body {
    padding: 16px 22px 24px;
    overflow-x: hidden;
    overflow-y: auto;
    min-width: 0;
}

.mic-buy-modal__status {
    margin-bottom: 14px;
}

.mic-packages-card {
    max-width: none;
    background: linear-gradient(160deg, rgba(88, 28, 135, 0.22), rgba(20, 24, 34, 0.98));
    border: 1px solid rgba(168, 85, 247, 0.35);
    border-radius: var(--radius);
    padding: 24px 24px 22px;
    box-shadow: 0 8px 32px rgba(168, 85, 247, 0.12);
}

.mic-packages-card--modal {
    margin: 0;
}

.mic-packages-slider-head {
    display: flex;
    align-items: baseline;
    gap: 8px;
    margin-bottom: 16px;
}

.mic-packages-count {
    font-size: 2.5rem;
    font-weight: 700;
    line-height: 1;
    background: linear-gradient(135deg, #f5d0fe, #c084fc);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
}

.mic-packages-count-suffix {
    font-size: 1rem;
    color: var(--muted);
}

.mic-packages-range {
    width: 100%;
    height: 6px;
    margin: 0 0 8px;
    accent-color: var(--accent);
    cursor: pointer;
}

.mic-packages-ticks {
    display: flex;
    justify-content: space-between;
    font-size: 0.72rem;
    color: var(--muted);
    margin-bottom: 12px;
    padding: 0 2px;
}

.mic-packages-caption {
    font-size: 0.82rem;
    color: var(--muted);
    margin: 0 0 16px;
    font-style: italic;
}

.mic-packages-price-row {
    display: flex;
    align-items: baseline;
    gap: 12px;
    margin-bottom: 6px;
}

.mic-packages-price {
    font-size: 1.75rem;
    font-weight: 700;
}

.mic-packages-per {
    font-size: 0.9rem;
    color: var(--muted);
}

.mic-packages-tagline {
    font-size: 0.85rem;
    color: var(--muted);
    margin: 0 0 18px;
    min-height: 1.2em;
}

.mic-packages-buy {
    width: 100%;
}

.site-footer {
    margin-top: 56px;
    padding-top: 28px;
    border-top: 1px solid var(--border);
}

.site-footer__link {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 0;
    border: none;
    background: none;
    color: var(--text);
    font: inherit;
    font-size: 0.9rem;
    text-decoration: none;
    cursor: pointer;
    transition: color 0.15s;
}

.site-footer__link:hover {
    color: #e9d5ff;
}

.site-footer__legal {
    margin-top: 12px;
    font-size: 0.78rem;
    color: var(--muted);
    line-height: 1.5;
}

.site-footer__legal p {
    margin: 0 0 4px;
}

.site-footer__legal p:last-child {
    margin-bottom: 0;
}

/* Cabinet layout */
.cabinet-grid {
    display: grid;
    grid-template-columns: 280px 1fr;
    gap: 20px;
    align-items: start;
}

.sidebar {
    position: sticky;
    top: 16px;
    align-self: start;
    z-index: 2;
}

.sidebar > section {
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px 18px;
}

@media (max-width: 900px) {
    .cabinet-grid {
        grid-template-columns: 1fr;
        gap: 24px;
    }

    .sidebar {
        position: static;
        top: auto;
        z-index: auto;
    }

    .main-col {
        min-width: 0;
    }

}

.sidebar-folders {
    --folder-action: 34px;
    --folder-count: 2rem;
    --folder-gap: 8px;
    --folder-pad-x: 12px;
}

.folder-list { list-style: none; }

.folder-item {
    display: grid;
    grid-template-columns: minmax(0, 1fr) var(--folder-count) var(--folder-action);
    gap: var(--folder-gap);
    align-items: center;
    padding: 10px var(--folder-pad-x);
    border-radius: var(--radius-sm);
    cursor: pointer;
    margin-bottom: 6px;
    border: 1px solid transparent;
}

.folder-item:hover, .folder-item.active {
    background: var(--surface);
    border-color: var(--border);
}

.folder-item__name {
    grid-column: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.folder-item__aside {
    display: contents;
}

.folder-item .count {
    grid-column: 2;
    color: var(--muted);
    font-size: 0.8rem;
    text-align: right;
    font-variant-numeric: tabular-nums;
    line-height: 1;
}

.folder-item__del-slot {
    grid-column: 3;
    width: var(--folder-action);
    height: var(--folder-action);
    display: flex;
    align-items: center;
    justify-content: center;
    justify-self: end;
}

.folder-action-btn {
    box-sizing: border-box;
    width: var(--folder-action);
    height: var(--folder-action);
    min-width: var(--folder-action);
    padding: 0;
    margin: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 9px;
    line-height: 0;
    font-family: inherit;
    flex-shrink: 0;
}

.folder-create {
    display: grid;
    grid-template-columns: minmax(0, 1fr) var(--folder-action);
    gap: var(--folder-gap);
    margin-top: 12px;
    padding: 0 var(--folder-pad-x);
    align-items: center;
}

.folder-create__input {
    margin: 0;
    min-width: 0;
}

.folder-create__add {
    justify-self: end;
    font-size: 0;
    line-height: 1;
    position: relative;
    color: #fff;
}

/* Геометрически по центру квадрата (символ «+» в шрифте визуально проваливается вниз) */
.folder-create__add::before,
.folder-create__add::after {
    content: '';
    position: absolute;
    left: 50%;
    top: 50%;
    background: currentColor;
    border-radius: 1px;
    transform: translate(-50%, -50%);
}

.folder-create__add::before {
    width: 11px;
    height: 2px;
}

.folder-create__add::after {
    width: 2px;
    height: 11px;
}

.folder-item__del {
    border: 1px solid var(--border);
    background: rgba(255, 255, 255, 0.03);
    color: var(--muted);
    cursor: pointer;
    transition: color 0.15s, border-color 0.15s, background 0.15s;
}

.folder-item__del .icon-close {
    display: block;
}

.folder-item__del:hover {
    color: #fecaca;
    border-color: rgba(248, 113, 113, 0.45);
    background: rgba(239, 68, 68, 0.14);
}

/* Кастомный выбор папки (вместо нативного select) */
.folder-picker {
    position: relative;
    width: 100%;
}
.folder-picker__trigger {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    width: 100%;
    padding: 12px 14px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-active);
    background: var(--surface);
    color: var(--text);
    font-size: 0.95rem;
    font-weight: 500;
    font-family: inherit;
    cursor: pointer;
    text-align: left;
    transition: border-color 0.2s, box-shadow 0.2s, background 0.2s;
}
.folder-picker__trigger:hover {
    background: var(--surface-hover);
    border-color: rgba(168, 85, 247, 0.5);
}
.folder-picker.is-open .folder-picker__trigger {
    border-color: var(--border-active);
    box-shadow: 0 0 0 3px var(--accent-soft);
}
.folder-picker__value {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.folder-picker__chevron {
    flex-shrink: 0;
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s ease;
}
.folder-picker__chevron::after {
    content: '';
    width: 8px;
    height: 8px;
    border-right: 2px solid #c4b5fd;
    border-bottom: 2px solid #c4b5fd;
    transform: rotate(45deg) translate(-1px, -2px);
}
.folder-picker.is-open .folder-picker__chevron {
    transform: rotate(180deg);
}
.folder-picker__menu {
    position: absolute;
    left: 0;
    right: 0;
    top: calc(100% + 6px);
    z-index: 20;
    padding: 6px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-active);
    background: var(--bg-elevated);
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.45);
    max-height: 220px;
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: rgba(168, 85, 247, 0.45) transparent;
}
.folder-picker__option {
    display: block;
    width: 100%;
    padding: 11px 12px;
    border: none;
    border-radius: 8px;
    background: transparent;
    color: var(--text);
    font-size: 0.9rem;
    font-family: inherit;
    text-align: left;
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
}
.folder-picker__option:hover {
    background: var(--surface-hover);
}
.folder-picker__option.is-active {
    background: linear-gradient(135deg, rgba(147, 51, 234, 0.35), rgba(124, 58, 237, 0.2));
    color: #e9d5ff;
    font-weight: 600;
}

.tx-table { width: 100%; border-collapse: collapse; font-size: 0.85rem; }
.tx-table th, .tx-table td {
    text-align: left;
    padding: 12px 10px;
    border-bottom: 1px solid var(--border);
}
.tx-table th { color: var(--muted); font-weight: 500; font-size: 0.75rem; text-transform: uppercase; }

.status-pill {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 600;
}
.status-completed { background: rgba(34,197,94,0.15); color: var(--success); }
.status-pending { background: rgba(251,191,36,0.15); color: var(--warn); }

.history-item {
    display: flex;
    align-items: center;
    gap: 14px;
    flex-wrap: wrap;
    padding: 14px 0;
    border-bottom: 1px solid var(--border);
}
.history-item:last-child { border-bottom: none; }

.history-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.history-card {
    padding: 18px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
}

.history-card__head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 8px;
}

.history-card__speaker {
    font-weight: 600;
    font-size: 1rem;
    color: #e9d5ff;
}

.history-card__date {
    font-size: 0.75rem;
    color: var(--muted);
    white-space: nowrap;
    flex-shrink: 0;
}

.history-card__preview {
    font-size: 0.88rem;
    line-height: 1.5;
    color: var(--text);
    margin: 0 0 14px;
    word-break: break-word;
    display: -webkit-box;
    -webkit-line-clamp: 4;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.history-card__player {
    width: 100%;
    margin-bottom: 0;
}

/* Компактный кастомный плеер (вместо нативного) */
.vplayer {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 6px 12px 6px 6px;
    border-radius: 12px;
    background: linear-gradient(180deg, #ffffff 0%, #f3f3f7 100%);
    border: 1px solid rgba(255, 255, 255, 0.9);
    box-shadow: 0 2px 14px rgba(0, 0, 0, 0.22);
}

.vplayer audio {
    display: none;
}

.vplayer__play {
    flex-shrink: 0;
    width: 34px;
    height: 34px;
    padding: 0;
    border: none;
    border-radius: 50%;
    background: linear-gradient(135deg, #9333ea, #a855f7);
    color: #fff;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 8px rgba(147, 51, 234, 0.35);
    transition: transform 0.15s, box-shadow 0.15s;
}

.vplayer__play:hover {
    transform: scale(1.04);
    box-shadow: 0 4px 12px rgba(147, 51, 234, 0.45);
}

.vplayer__play.is-playing .vplayer__icon--play { display: none; }
.vplayer__play:not(.is-playing) .vplayer__icon--pause { display: none; }

.vplayer__progress {
    flex: 1;
    min-width: 0;
    height: 4px;
    margin: 0;
    -webkit-appearance: none;
    appearance: none;
    background: rgba(0, 0, 0, 0.12);
    border-radius: 999px;
    cursor: pointer;
}

.vplayer__progress::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: #9333ea;
    border: 2px solid #fff;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.2);
}

.vplayer__progress::-moz-range-thumb {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: #9333ea;
    border: 2px solid #fff;
}

.vplayer__time {
    flex-shrink: 0;
    font-size: 0.72rem;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
    color: #4b5563;
    min-width: 4.8em;
    text-align: right;
}

.vplayer__volume {
    display: flex;
    align-items: center;
    gap: 4px;
    flex-shrink: 0;
}

.vplayer__vol-btn {
    flex-shrink: 0;
    width: 28px;
    height: 28px;
    padding: 0;
    border: none;
    border-radius: 8px;
    background: transparent;
    color: #6b7280;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s, color 0.15s;
}

.vplayer__vol-btn:hover {
    background: rgba(147, 51, 234, 0.1);
    color: #9333ea;
}

.vplayer__vol-btn.is-muted {
    color: #9ca3af;
}

.vplayer__vol-icon {
    display: block;
}

.vplayer__vol-btn.is-muted .vplayer__vol-icon--on,
.vplayer__vol-btn:not(.is-muted) .vplayer__vol-icon--off {
    display: none;
}

.vplayer__volume-range {
    flex-shrink: 0;
    width: 52px;
    height: 4px;
    margin: 0;
    -webkit-appearance: none;
    appearance: none;
    background: rgba(0, 0, 0, 0.12);
    border-radius: 999px;
    cursor: pointer;
}

.vplayer__volume-range::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: #9333ea;
    border: 2px solid #fff;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
}

.vplayer__volume-range::-moz-range-thumb {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: #9333ea;
    border: 2px solid #fff;
}

.history-card__media {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-bottom: 14px;
}

.history-card__toolbar {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 0;
    width: 100%;
}

.history-card__toolbar .btn,
.history-card__toolbar a.btn,
.history-card__toolbar .share-btn {
    flex: 1;
    justify-content: center;
    text-align: center;
    min-width: 0;
}

.history-card__toolbar .btn,
.history-card__toolbar a.btn {
    padding: 10px 12px;
}

.history-card__folder-picker {
    display: none;
    flex: 1;
    min-width: 0;
}

.history-card__folder-pills {
    flex: 1;
    min-width: 0;
}

@media (min-width: 769px) {
    .history-card__preview { -webkit-line-clamp: 2; }

    .history-card__media {
        display: flex;
        align-items: center;
        gap: 14px;
        flex-wrap: wrap;
        margin-bottom: 14px;
    }

    .history-card__player {
        flex: 1;
        min-width: 240px;
        margin-bottom: 0;
    }

    .history-card__toolbar {
        flex-shrink: 0;
        margin-bottom: 0;
        width: auto;
    }

    .history-card__toolbar .btn,
    .history-card__toolbar a.btn,
    .history-card__toolbar .share-btn {
        flex: 0 0 auto;
        min-width: 108px;
    }
}

.folder-move {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    padding-top: 14px;
    border-top: 1px solid rgba(139, 92, 246, 0.12);
}

.folder-move__label {
    font-size: 0.72rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--muted);
    flex-shrink: 0;
}

.folder-pills--compact {
    gap: 6px;
    flex: 1;
}

.folder-pills--compact .folder-pill {
    padding: 6px 12px;
    font-size: 0.8rem;
}

.history-empty {
    color: var(--muted);
    padding: 16px 0;
}

.pagination {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 12px;
    margin-top: 16px;
    padding-top: 12px;
    border-top: 1px solid var(--border);
}

.pagination__info {
    font-size: 0.85rem;
    color: var(--muted);
}

.pagination__controls {
    display: flex;
    gap: 8px;
}

@media (max-width: 768px) {
    .history-card { padding: 14px; }

    .history-card__head {
        flex-direction: column;
        gap: 4px;
    }

    .history-card__date { white-space: normal; }

    .history-card__preview {
        -webkit-line-clamp: 5;
        font-size: 0.9rem;
    }

    .vplayer {
        padding: 6px 10px 6px 6px;
        gap: 8px;
    }

    .vplayer__time {
        font-size: 0.68rem;
        min-width: 4.4em;
    }

    .vplayer__volume-range {
        width: 40px;
    }

    .folder-move {
        flex-direction: column;
        align-items: stretch;
        gap: 8px;
    }

    .history-card__folder-pills { display: none !important; }

    .history-card__folder-picker {
        display: block !important;
        width: 100%;
    }

    .folder-move__label {
        margin-bottom: 2px;
    }

    .history-card__toolbar {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 8px;
        width: 100%;
    }

    .history-card__toolbar .share-btn {
        grid-column: 1 / -1;
        width: 100%;
    }

    .history-card__toolbar .btn,
    .history-card__toolbar a.btn {
        flex: unset;
        width: auto;
        min-width: 0;
        padding: 10px 8px;
        font-size: 0.82rem;
    }
}

@media (min-width: 769px) {
    .history-card__folder-picker { display: none !important; }
}

@media (max-width: 640px) {
    .wrap { padding: 16px 14px 60px; }
    .topbar { flex-direction: column; align-items: stretch; }
    .topbar-actions { justify-content: space-between; }
    .tx-table { font-size: 0.75rem; }
    .tx-table th:nth-child(3), .tx-table td:nth-child(3) { display: none; }
}

/* Storage quota (cabinet sidebar) */
.storage-quota {
    margin-top: 16px;
    padding-top: 16px;
    border-top: 1px solid var(--border);
}

.storage-quota__head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 10px;
}

.storage-quota__label {
    font-size: 0.78rem;
    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--muted);
}

.storage-quota__value {
    font-size: 0.82rem;
    font-weight: 600;
    color: #e9d5ff;
    white-space: nowrap;
}

.storage-quota__track {
    height: 8px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid var(--border);
    overflow: hidden;
}

.storage-quota__fill {
    height: 100%;
    width: 0;
    border-radius: 999px;
    background: linear-gradient(90deg, #7c3aed, #a855f7);
    transition: width 0.35s ease;
}

.storage-quota.is-warn .storage-quota__fill,
.storage-quota__fill.is-warn {
    background: linear-gradient(90deg, #d97706, #f59e0b);
}

.storage-quota.is-full .storage-quota__fill,
.storage-quota__fill.is-full {
    background: linear-gradient(90deg, #dc2626, #ef4444);
}

.storage-quota__hint {
    margin: 8px 0 0;
    font-size: 0.75rem;
    line-height: 1.45;
    color: var(--muted);
}

.storage-quota.is-full .storage-quota__hint {
    color: #fca5a5;
}

.storage-quota.is-warn .storage-quota__hint {
    color: #fcd34d;
}

/* Folder section toolbar + bulk delete */
.folder-section__head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
    margin-bottom: 12px;
}

.folder-section__head h2 {
    margin: 0;
}

.folder-section__tools {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.bulk-toolbar {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
    padding: 10px 14px;
    margin-bottom: 12px;
    border: 1px solid rgba(168, 85, 247, 0.35);
    border-radius: var(--radius-sm);
    background: rgba(124, 58, 237, 0.08);
}

.bulk-toolbar__select-all {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-size: 0.88rem;
    cursor: pointer;
    user-select: none;
}

.bulk-toolbar__select-all input {
    width: 16px;
    height: 16px;
    accent-color: #a855f7;
    cursor: pointer;
}

.bulk-toolbar__count {
    font-size: 0.82rem;
    color: var(--muted);
    margin-right: auto;
}

.history-card {
    transition: border-color 0.15s, box-shadow 0.15s;
}

.history-card.is-selected {
    border-color: rgba(168, 85, 247, 0.55);
    box-shadow: 0 0 0 1px rgba(168, 85, 247, 0.25);
}

.history-card__head {
    display: flex;
    align-items: flex-start;
    gap: 10px;
}

.history-card__head-main {
    flex: 1;
    min-width: 0;
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
}

.history-card__select {
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    padding-top: 2px;
    cursor: pointer;
}

.history-card__checkbox {
    width: 18px;
    height: 18px;
    accent-color: #a855f7;
    cursor: pointer;
}

@media (max-width: 640px) {
    .folder-section__head {
        flex-direction: column;
        align-items: stretch;
    }

    .folder-section__tools {
        justify-content: flex-start;
    }

    .bulk-toolbar {
        flex-direction: column;
        align-items: stretch;
    }

    .bulk-toolbar__count {
        margin-right: 0;
    }

    .bulk-toolbar .btn {
        width: 100%;
    }
}

/* Cabinet header + transactions modal */
.cabinet-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
    margin-bottom: 28px;
}

.cabinet-header__main h1 {
    font-size: 1.75rem;
    font-weight: 700;
    margin: 0 0 6px;
}

.cabinet-header__main p {
    margin: 0;
    color: var(--muted);
}

.cabinet-header__tx {
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    white-space: nowrap;
}

.cabinet-header__tx-count {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 1.4rem;
    height: 1.4rem;
    padding: 0 6px;
    border-radius: 999px;
    background: rgba(168, 85, 247, 0.2);
    color: #e9d5ff;
    font-size: 0.72rem;
    font-weight: 700;
}

.tx-modal {
    width: min(560px, calc(100vw - 28px));
    max-height: min(82vh, 640px);
    padding: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.tx-modal__head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    padding: 18px 18px 12px;
    border-bottom: 1px solid var(--border);
}

.tx-modal__head h3 {
    margin: 0 0 4px;
    font-size: 1.15rem;
}

.tx-modal__sub {
    margin: 0 !important;
    font-size: 0.82rem !important;
}

.tx-modal__close {
    flex-shrink: 0;
    padding: 6px 10px !important;
    min-height: auto !important;
}

.tx-modal__body {
    flex: 1;
    min-height: 0;
    min-width: 0;
    overflow-x: hidden;
    overflow-y: auto;
    padding: 8px 12px 12px;
}

.tx-modal__loading,
.tx-modal__empty {
    margin: 24px 8px;
    text-align: center;
    color: var(--muted);
    font-size: 0.9rem;
}

.tx-list {
    list-style: none;
    margin: 0;
    padding: 0;
}

.tx-item {
    padding: 12px 10px;
    border-bottom: 1px solid var(--border);
}

.tx-item:last-child {
    border-bottom: none;
}

.tx-item__row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}

.tx-item__row--meta {
    margin-top: 6px;
    flex-wrap: wrap;
    font-size: 0.78rem;
    color: var(--muted);
}

.tx-item__pkg {
    font-weight: 600;
    color: #e9d5ff;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.tx-item__amount {
    font-weight: 600;
    white-space: nowrap;
}

.tx-item__date {
    white-space: nowrap;
}

.tx-item__chars {
    color: var(--success);
    font-weight: 600;
}

.tx-modal__pagination {
    flex-shrink: 0;
    margin: 0;
    padding: 10px 14px 14px;
    border-top: 1px solid var(--border);
    justify-content: space-between;
}

@media (max-width: 640px) {
    .cabinet-header {
        flex-direction: column;
        align-items: stretch;
    }

    .cabinet-header__tx {
        width: 100%;
        justify-content: center;
    }

    .tx-modal {
        width: calc(100vw - 16px);
        max-height: 88vh;
    }

    .tx-modal__head {
        padding: 14px 14px 10px;
    }

    .mic-packages-teaser {
        flex-direction: column;
        align-items: stretch;
        padding: 16px 40px 16px 16px;
    }

    .mic-packages-teaser__btn {
        width: 100%;
    }

    .char-packages-modal__head {
        padding: 16px 16px 0;
    }

    .char-packages-modal__body {
        padding: 14px 16px 20px;
    }

    .packages-grid--tariffs {
        grid-template-columns: 1fr;
        gap: 12px;
    }

    .packages-grid--tariffs .pkg-tagline {
        min-height: 0;
    }

    .mic-buy-modal__head {
        padding: 16px 16px 0;
    }

    .mic-buy-modal__body {
        padding: 14px 16px 20px;
    }

    .tx-item__row--meta {
        gap: 6px 10px;
    }

    .tx-item__row--meta .status-pill {
        margin-left: auto;
    }
}

/* --- Share audio --- */
.result-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px;
}

.share-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 18px;
    border: none;
    border-radius: var(--radius-sm, 10px);
    background: linear-gradient(135deg, #9333ea 0%, #7c3aed 55%, #6d28d9 100%);
    color: #fff;
    font-size: 0.85rem;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    white-space: nowrap;
    box-shadow: 0 4px 18px rgba(147, 51, 234, 0.35);
    transition: transform 0.15s ease, box-shadow 0.15s ease, filter 0.15s ease;
}

.share-btn:hover {
    filter: brightness(1.08);
    box-shadow: 0 6px 22px rgba(147, 51, 234, 0.45);
    transform: translateY(-1px);
}

.share-btn:active {
    transform: translateY(0);
}

.share-btn--done {
    background: linear-gradient(135deg, #059669 0%, #047857 100%);
    box-shadow: 0 4px 16px rgba(5, 150, 105, 0.35);
}

.share-btn svg {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
}
