/* ============================================================
   🐸 Kvakalka Web — стили
   Тёмная тема, минимализм, мобильный-first.
   Никаких тяжёлых эффектов — только transform/opacity.
   ============================================================ */

/* ============================================================
   ПЕРЕМЕННЫЕ
   ============================================================ */
:root {
    /* Цвета */
    --bg: #0a0a0a;
    --bg-soft: #111111;
    --surface: #161616;
    --surface-2: #1c1c1c;
    --surface-3: #232323;
    --border: #262626;
    --border-hover: #333333;

    --text: #ededed;
    --text-dim: #a1a1a1;
    --text-muted: #6b6b6b;

    --accent: #10b981;
    --accent-hover: #14d195;
    --accent-soft: rgba(16, 185, 129, 0.1);

    --danger: #ef4444;
    --danger-soft: rgba(239, 68, 68, 0.1);
    --warn: #f59e0b;
    --info: #3b82f6;

    /* Размеры */
    --radius: 12px;
    --radius-sm: 8px;
    --radius-lg: 16px;
    --radius-xl: 20px;

    /* Тени — очень лёгкие, для производительности */
    --shadow-sm: 0 1px 2px rgba(0,0,0,0.3);
    --shadow: 0 4px 12px rgba(0,0,0,0.4);

    /* Шрифт */
    --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
            "Helvetica Neue", Arial, "Noto Sans", sans-serif;
    --font-mono: ui-monospace, "SF Mono", Menlo, Monaco, Consolas, monospace;

    /* Анимации */
    --transition: 0.15s ease;
    --transition-med: 0.25s ease;
}

/* ============================================================
   RESET
   ============================================================ */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    -webkit-text-size-adjust: 100%;
    -webkit-tap-highlight-color: transparent;
    scroll-behavior: smooth;
}

body {
    font-family: var(--font);
    font-size: 15px;
    line-height: 1.5;
    color: var(--text);
    background: var(--bg);
    min-height: 100vh;
    min-height: 100dvh;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    padding-bottom: env(safe-area-inset-bottom);
}

img, svg { display: block; max-width: 100%; }

button, input, textarea, select {
    font: inherit;
    color: inherit;
    background: none;
    border: none;
    outline: none;
}

button { cursor: pointer; -webkit-user-select: none; user-select: none; }

a { color: inherit; text-decoration: none; }
a:hover { color: var(--accent); }

ul, ol { list-style: none; }

/* ============================================================
   ХЕДЕР
   ============================================================ */
.header {
    position: sticky;
    top: 0;
    z-index: 100;
    background: rgba(10, 10, 10, 0.85);
    border-bottom: 1px solid var(--border);
    padding-top: env(safe-area-inset-top);
}

.header-inner {
    max-width: 1100px;
    margin: 0 auto;
    padding: 12px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
}

.logo {
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--text);
    transition: opacity var(--transition);
}
.logo:hover { opacity: 0.85; color: var(--text); }

.logo-icon {
    font-size: 24px;
    line-height: 1;
}

.logo-text {
    display: flex;
    flex-direction: column;
    line-height: 1.1;
}

.logo-title {
    font-weight: 700;
    font-size: 16px;
    letter-spacing: -0.01em;
}

.logo-sub {
    font-size: 11px;
    color: var(--text-muted);
    font-family: var(--font-mono);
}

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

.feature-badge {
    display: flex;
    gap: 6px;
    font-size: 11px;
    font-family: var(--font-mono);
    color: var(--text-muted);
}
.feature-badge span {
    padding: 3px 7px;
    border: 1px solid var(--border);
    border-radius: 100px;
}
.feature-badge span.on { color: var(--accent); border-color: var(--accent-soft); }

.icon-btn {
    width: 38px;
    height: 38px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-sm);
    color: var(--text-dim);
    transition: background var(--transition), color var(--transition);
}
.icon-btn:hover {
    background: var(--surface);
    color: var(--text);
}
.icon-btn svg { width: 20px; height: 20px; }

/* ============================================================
   MAIN
   ============================================================ */
.main {
    max-width: 1100px;
    margin: 0 auto;
    padding: 32px 20px 60px;
}

/* ============================================================
   HERO
   ============================================================ */
.hero {
    text-align: center;
    padding: 24px 0 40px;
}

.hero-title {
    font-size: clamp(32px, 8vw, 48px);
    font-weight: 800;
    letter-spacing: -0.03em;
    line-height: 1.1;
    background: linear-gradient(135deg, #ededed 0%, #10b981 100%);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    margin-bottom: 10px;
}

.hero-sub {
    color: var(--text-dim);
    font-size: clamp(14px, 3.6vw, 16px);
}

/* ============================================================
   TABS
   ============================================================ */
.tabs {
    display: flex;
    gap: 4px;
    overflow-x: auto;
    scrollbar-width: none;
    -ms-overflow-style: none;
    padding: 4px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    margin-bottom: 24px;
}
.tabs::-webkit-scrollbar { display: none; }

.tab {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    gap: 7px;
    padding: 10px 14px;
    border-radius: var(--radius-sm);
    color: var(--text-dim);
    font-size: 13px;
    font-weight: 500;
    white-space: nowrap;
    transition: background var(--transition), color var(--transition);
}
.tab svg { width: 16px; height: 16px; flex-shrink: 0; }
.tab:hover { color: var(--text); background: var(--surface-2); }
.tab.active {
    background: var(--surface-3);
    color: var(--text);
}

/* ============================================================
   ПАНЕЛИ
   ============================================================ */
.panel {
    display: none;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 24px;
    animation: fadeIn 0.2s ease;
}
.panel.active { display: block; }

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

.panel-head { margin-bottom: 20px; }

.panel-head h2 {
    font-size: 20px;
    font-weight: 700;
    letter-spacing: -0.01em;
    margin-bottom: 4px;
}

.panel-desc {
    color: var(--text-dim);
    font-size: 13px;
}

/* ============================================================
   DROPZONE
   ============================================================ */
.dropzone {
    position: relative;
    border: 2px dashed var(--border);
    border-radius: var(--radius);
    background: var(--bg-soft);
    transition: border-color var(--transition), background var(--transition);
    cursor: pointer;
}
.dropzone:hover { border-color: var(--border-hover); }
.dropzone.dragover {
    border-color: var(--accent);
    background: var(--accent-soft);
}

.dropzone-inner {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 40px 20px;
    text-align: center;
    pointer-events: none;
}

.dropzone-icon {
    width: 44px;
    height: 44px;
    color: var(--text-muted);
    margin-bottom: 4px;
}

.dropzone-title {
    font-size: 15px;
    font-weight: 600;
    color: var(--text);
}

.dropzone-sub {
    font-size: 13px;
    color: var(--text-muted);
}

.dropzone .btn {
    pointer-events: auto;
    margin-top: 12px;
}

/* ============================================================
   КНОПКИ
   ============================================================ */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 9px 16px;
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-weight: 600;
    letter-spacing: -0.005em;
    transition: background var(--transition), color var(--transition),
                transform var(--transition), opacity var(--transition);
    white-space: nowrap;
    border: 1px solid transparent;
    -webkit-user-select: none;
    user-select: none;
}
.btn:active { transform: scale(0.98); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }

.btn-primary {
    background: var(--accent);
    color: #0a0a0a;
}
.btn-primary:hover:not(:disabled) { background: var(--accent-hover); }

.btn-ghost {
    background: var(--surface-2);
    color: var(--text);
    border-color: var(--border);
}
.btn-ghost:hover:not(:disabled) { background: var(--surface-3); border-color: var(--border-hover); }

.btn-danger {
    background: var(--danger-soft);
    color: var(--danger);
    border-color: rgba(239, 68, 68, 0.3);
}
.btn-danger:hover:not(:disabled) { background: rgba(239, 68, 68, 0.2); }

.btn-sm { padding: 6px 12px; font-size: 13px; }
.btn-lg { padding: 12px 24px; font-size: 15px; }

/* ============================================================
   FORMAT PICKER
   ============================================================ */
.format-picker {
    margin-bottom: 20px;
}

.format-picker label {
    display: block;
    font-size: 13px;
    color: var(--text-dim);
    margin-bottom: 8px;
}

.format-buttons {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}

.format-btn {
    padding: 8px 14px;
    border-radius: var(--radius-sm);
    background: var(--surface-2);
    border: 1px solid var(--border);
    color: var(--text-dim);
    font-size: 13px;
    font-weight: 600;
    transition: all var(--transition);
}
.format-btn:hover { border-color: var(--border-hover); color: var(--text); }
.format-btn.active {
    background: var(--accent);
    color: #0a0a0a;
    border-color: var(--accent);
}

/* ============================================================
   ОЧЕРЕДЬ
   ============================================================ */
.queue-section,
.results-section {
    margin-top: 24px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 20px;
    animation: fadeIn 0.25s ease;
}

.queue-head,
.results-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 14px;
    gap: 12px;
}

.queue-head h3,
.results-head h3 {
    font-size: 16px;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 8px;
}

.queue-count {
    font-size: 12px;
    font-weight: 500;
    color: var(--text-muted);
    padding: 2px 8px;
    background: var(--surface-2);
    border-radius: 100px;
    font-family: var(--font-mono);
}

.queue-list,
.results-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-height: 400px;
    overflow-y: auto;
    padding-right: 4px;
    margin-bottom: 16px;
    scrollbar-width: thin;
    scrollbar-color: var(--surface-3) transparent;
}
.queue-list::-webkit-scrollbar,
.results-list::-webkit-scrollbar { width: 6px; }
.queue-list::-webkit-scrollbar-thumb,
.results-list::-webkit-scrollbar-thumb {
    background: var(--surface-3);
    border-radius: 3px;
}

.queue-item,
.result-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    transition: border-color var(--transition);
}
.queue-item:hover,
.result-item:hover { border-color: var(--border-hover); }

.item-thumb {
    width: 42px;
    height: 42px;
    flex-shrink: 0;
    border-radius: 6px;
    background: var(--surface-3);
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
    font-size: 18px;
}
.item-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.item-info {
    flex: 1;
    min-width: 0;
}

.item-name {
    font-size: 13px;
    font-weight: 500;
    color: var(--text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-bottom: 2px;
}

.item-meta {
    font-size: 11px;
    color: var(--text-muted);
    font-family: var(--font-mono);
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}
.item-meta .ok { color: var(--accent); }
.item-meta .err { color: var(--danger); }
.item-meta .warn { color: var(--warn); }

.item-remove {
    width: 32px;
    height: 32px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
    color: var(--text-muted);
    transition: background var(--transition), color var(--transition);
}
.item-remove:hover { background: var(--danger-soft); color: var(--danger); }
.item-remove svg { width: 16px; height: 16px; }

.item-download {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    border-radius: 6px;
    background: var(--accent-soft);
    color: var(--accent);
    font-size: 12px;
    font-weight: 600;
    flex-shrink: 0;
    transition: background var(--transition);
}
.item-download:hover { background: rgba(16, 185, 129, 0.2); color: var(--accent); }
.item-download svg { width: 14px; height: 14px; }

/* ============================================================
   ДЕЙСТВИЯ (кнопки после очереди)
   ============================================================ */
.queue-actions,
.results-actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.queue-actions .btn-lg,
.results-actions .btn-lg {
    flex: 1;
    min-width: 160px;
}

/* ============================================================
   ПРОГРЕСС
   ============================================================ */
.progress-wrap {
    margin-top: 16px;
    display: flex;
    align-items: center;
    gap: 12px;
}

.progress-bar {
    flex: 1;
    height: 6px;
    background: var(--surface-3);
    border-radius: 3px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    width: 0%;
    background: var(--accent);
    border-radius: 3px;
    transition: width 0.2s linear;
}

.progress-text {
    font-size: 12px;
    font-family: var(--font-mono);
    color: var(--text-dim);
    min-width: 44px;
    text-align: right;
}

/* ============================================================
   РЕЗУЛЬТАТЫ
   ============================================================ */
.results-summary {
    font-size: 13px;
    color: var(--text-dim);
}

.results-summary strong { color: var(--accent); font-weight: 600; }

.results-expires {
    margin-top: 14px;
    font-size: 12px;
    color: var(--text-muted);
    text-align: center;
}

/* ============================================================
   НАСТРОЙКИ
   ============================================================ */
.settings-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 20px;
    margin-bottom: 24px;
}

@media (min-width: 640px) {
    .settings-grid { grid-template-columns: 1fr 1fr; }
}

.setting {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.setting > label {
    font-size: 13px;
    color: var(--text-dim);
    font-weight: 500;
}

.slider-row {
    display: flex;
    align-items: center;
    gap: 12px;
}

.slider-row input[type="range"] { flex: 1; }

.opt-value {
    font-size: 12px;
    font-family: var(--font-mono);
    color: var(--accent);
    font-weight: 600;
    min-width: 42px;
    text-align: right;
}

/* Range */
input[type="range"] {
    -webkit-appearance: none;
    appearance: none;
    height: 4px;
    background: var(--surface-3);
    border-radius: 2px;
    width: 100%;
    cursor: pointer;
}
input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 18px;
    height: 18px;
    background: var(--accent);
    border-radius: 50%;
    cursor: pointer;
    transition: transform var(--transition);
}
input[type="range"]::-webkit-slider-thumb:active { transform: scale(1.15); }
input[type="range"]::-moz-range-thumb {
    width: 18px;
    height: 18px;
    background: var(--accent);
    border-radius: 50%;
    border: none;
    cursor: pointer;
}

/* Switch */
.switch {
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    -webkit-user-select: none;
    user-select: none;
}
.switch input { position: absolute; opacity: 0; pointer-events: none; }
.switch-slider {
    position: relative;
    width: 38px;
    height: 22px;
    background: var(--surface-3);
    border-radius: 11px;
    transition: background var(--transition);
    flex-shrink: 0;
}
.switch-slider::after {
    content: "";
    position: absolute;
    top: 3px;
    left: 3px;
    width: 16px;
    height: 16px;
    background: var(--text-dim);
    border-radius: 50%;
    transition: transform var(--transition), background var(--transition);
}
.switch input:checked + .switch-slider { background: var(--accent); }
.switch input:checked + .switch-slider::after {
    transform: translateX(16px);
    background: #0a0a0a;
}

/* ============================================================
   GIF ОПЦИИ
   ============================================================ */
.gif-options {
    display: grid;
    grid-template-columns: 1fr;
    gap: 16px;
    margin-bottom: 20px;
    padding: 16px;
    background: var(--bg-soft);
    border: 1px solid var(--border);
    border-radius: var(--radius);
}
@media (min-width: 640px) {
    .gif-options { grid-template-columns: 1fr 1fr; align-items: end; }
}

.opt {
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.opt > label {
    font-size: 13px;
    color: var(--text-dim);
    font-weight: 500;
}
.opt .slider-row { width: 100%; }

/* ============================================================
   ФУТЕР
   ============================================================ */
.footer {
    text-align: center;
    padding: 30px 20px;
    color: var(--text-muted);
    font-size: 13px;
    border-top: 1px solid var(--border);
    margin-top: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    flex-wrap: wrap;
}
.footer .heart { color: var(--accent); }
.footer a { color: var(--text-dim); font-weight: 500; }
.footer a:hover { color: var(--accent); }

/* ============================================================
   ТОСТЫ
   ============================================================ */
.toasts {
    position: fixed;
    bottom: 20px;
    right: 20px;
    left: 20px;
    z-index: 200;
    display: flex;
    flex-direction: column;
    gap: 8px;
    pointer-events: none;
    align-items: flex-end;
}
@media (max-width: 500px) {
    .toasts { left: 20px; align-items: stretch; }
}

.toast {
    pointer-events: auto;
    padding: 12px 16px;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 13px;
    color: var(--text);
    box-shadow: var(--shadow);
    max-width: 360px;
    animation: toastIn 0.2s ease;
}
.toast.err { border-color: rgba(239, 68, 68, 0.4); color: #fca5a5; }
.toast.ok { border-color: rgba(16, 185, 129, 0.4); color: #6ee7b7; }

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

/* ============================================================
   СКРЫТИЕ
   ============================================================ */
[hidden] { display: none !important; }

/* ============================================================
   СКРОЛЛБАР (общий)
   ============================================================ */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
    background: var(--surface-3);
    border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover { background: var(--border-hover); }

/* ============================================================
   МОБИЛЬНЫЕ ДОРАБОТКИ
   ============================================================ */
@media (max-width: 500px) {
    .main { padding: 20px 14px 50px; }
    .panel { padding: 18px; }
    .queue-section, .results-section { padding: 16px; }
    .hero { padding: 16px 0 28px; }
    .dropzone-inner { padding: 32px 14px; }
    .dropzone-icon { width: 36px; height: 36px; }
    .queue-actions, .results-actions { flex-direction: column; }
    .queue-actions .btn, .results-actions .btn { width: 100%; }
    .tabs { padding: 3px; }
    .tab { padding: 9px 12px; font-size: 12px; }
    .tab svg { width: 14px; height: 14px; }
}

/* ============================================================
   PREFERS-REDUCED-MOTION
   ============================================================ */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
}

/* ============================================================
   ВЫДЕЛЕНИЕ ТЕКСТА
   ============================================================ */
::selection {
    background: var(--accent-soft);
    color: var(--accent-hover);
}

.settings-group {
    margin-bottom: 28px;
    padding-bottom: 24px;
    border-bottom: 1px solid var(--border);
}
.settings-group:last-of-type {
    border-bottom: none;
    padding-bottom: 12px;
}
.settings-group-title {
    font-size: 13px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--accent);
    margin-bottom: 16px;
}

/* ============================================================
   ZIP-зона
   ============================================================ */
.drop-or {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    margin: 16px 0;
    color: var(--text-muted);
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.1em;
}
.drop-or::before,
.drop-or::after {
    content: "";
    flex: 1;
    height: 1px;
    background: var(--border);
}

.dropzone-zip {
    border-style: solid;
    border-color: var(--border);
    background: var(--surface-2);
}
.dropzone-zip:hover { border-color: var(--accent); }
.dropzone-zip .dropzone-icon { color: var(--accent); }

.dropzone-hint {
    font-size: 11px;
    color: var(--text-muted);
    margin-top: 4px;
    font-family: var(--font-mono);
}

.dropzone.has-file {
    border-color: var(--accent);
    background: var(--accent-soft);
}
.dropzone.has-file .dropzone-title {
    color: var(--accent);
}

.settings-group {
    margin-bottom: 28px;
    padding-bottom: 24px;
    border-bottom: 1px solid var(--border);
}
.settings-group:last-of-type {
    border-bottom: none;
    padding-bottom: 12px;
}
.settings-group-title {
    font-size: 13px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--accent);
    margin-bottom: 16px;
}

/* ============================================================
   ПАРАМЕТРЫ НА ПАНЕЛИ
   ============================================================ */
.params-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    padding: 10px 12px;
    background: var(--bg-soft);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    margin-bottom: 16px;
    min-height: 40px;
    align-items: center;
}

.param-chip {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 4px 10px;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: 100px;
    font-size: 11px;
    font-weight: 600;
    font-family: var(--font-mono);
    color: var(--text-dim);
    white-space: nowrap;
}

.param-chip .param-label {
    color: var(--text-muted);
    font-weight: 500;
}

.param-chip .param-value {
    color: var(--accent);
}

.param-chip.warn {
    border-color: rgba(245, 158, 11, 0.3);
}
.param-chip.warn .param-value {
    color: var(--warn);
}

.param-chip.on {
    border-color: rgba(16, 185, 129, 0.3);
    background: var(--accent-soft);
}

/* ============================================================
   ИСТОРИЯ
   ============================================================ */
.history-filters {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
    margin-bottom: 16px;
}

.filter-btn {
    padding: 6px 12px;
    border-radius: var(--radius-sm);
    background: var(--surface-2);
    border: 1px solid var(--border);
    color: var(--text-dim);
    font-size: 12px;
    font-weight: 600;
    transition: all var(--transition);
}
.filter-btn:hover { border-color: var(--border-hover); color: var(--text); }
.filter-btn.active {
    background: var(--accent);
    color: #0a0a0a;
    border-color: var(--accent);
}

.history-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-height: 600px;
    overflow-y: auto;
    padding-right: 4px;
    margin-bottom: 16px;
    scrollbar-width: thin;
    scrollbar-color: var(--surface-3) transparent;
}
.history-list::-webkit-scrollbar { width: 6px; }
.history-list::-webkit-scrollbar-thumb {
    background: var(--surface-3);
    border-radius: 3px;
}

.history-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    transition: border-color var(--transition);
}
.history-item:hover { border-color: var(--border-hover); }

.history-op-icon {
    width: 38px;
    height: 38px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--surface-3);
    border-radius: 8px;
    font-size: 18px;
}

.history-info {
    flex: 1;
    min-width: 0;
}

.history-name {
    font-size: 13px;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 3px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.history-meta {
    font-size: 11px;
    color: var(--text-muted);
    font-family: var(--font-mono);
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}
.history-meta .ok { color: var(--accent); }
.history-meta .dim { color: var(--text-muted); }

.history-time {
    font-size: 10px;
    color: var(--text-muted);
    font-family: var(--font-mono);
    margin-top: 3px;
}

.history-dl {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 6px 10px;
    border-radius: 6px;
    background: var(--accent-soft);
    color: var(--accent);
    font-size: 11px;
    font-weight: 600;
    flex-shrink: 0;
    transition: background var(--transition);
    text-decoration: none;
}
.history-dl:hover { background: rgba(16, 185, 129, 0.2); color: var(--accent); }
.history-dl svg { width: 12px; height: 12px; }

.history-dl.gone {
    background: var(--surface-3);
    color: var(--text-muted);
    cursor: not-allowed;
}

.history-empty {
    text-align: center;
    padding: 40px 20px;
    color: var(--text-muted);
}
.history-empty-icon {
    font-size: 48px;
    margin-bottom: 12px;
    opacity: 0.5;
}
.history-empty-title {
    font-size: 15px;
    font-weight: 600;
    color: var(--text-dim);
    margin-bottom: 4px;
}
.history-empty-sub {
    font-size: 13px;
}

.history-actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}
.history-actions .btn { flex: 1; min-width: 140px; }


/* ============================================================
   ЗАМКИ НА ТАБАХ
   ============================================================ */
.tab.locked {
    opacity: 0.5;
    position: relative;
}
.tab.locked::after {
    content: "🔒";
    font-size: 10px;
    margin-left: 4px;
    opacity: 0.8;
}
.tab.locked:hover {
    color: var(--text-dim);
    background: var(--surface-2);
}

/* ============================================================
   ПАНЕЛЬ ЗАМКА (вместо содержимого таба)
   ============================================================ */
.lock-screen {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 60px 24px;
    text-align: center;
    min-height: 320px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    animation: fadeIn 0.25s ease;
}

.lock-icon {
    font-size: 64px;
    margin-bottom: 20px;
    opacity: 0.85;
}

.lock-title {
    font-size: 20px;
    font-weight: 700;
    color: var(--text);
    margin-bottom: 8px;
}

.lock-text {
    font-size: 14px;
    color: var(--text-dim);
    max-width: 360px;
    line-height: 1.5;
    margin-bottom: 24px;
}

.lock-actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    justify-content: center;
}

/* ============================================================
   КНОПКА ВОЙТИ / ПРОФИЛЬ В ХЕДЕРЕ
   ============================================================ */
.auth-header-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 7px 14px;
    border-radius: var(--radius-sm);
    background: var(--accent);
    color: #0a0a0a;
    font-size: 13px;
    font-weight: 600;
    transition: background var(--transition), transform var(--transition);
    white-space: nowrap;
}
.auth-header-btn:hover {
    background: var(--accent-hover);
    color: #0a0a0a;
    transform: translateY(-1px);
}
.auth-header-btn svg {
    width: 14px;
    height: 14px;
}

.avatar-btn {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    overflow: hidden;
    background: var(--surface-2);
    border: 2px solid var(--accent);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform var(--transition), border-color var(--transition);
    flex-shrink: 0;
}
.avatar-btn:hover {
    transform: scale(1.05);
    border-color: var(--accent-hover);
}
.avatar-btn img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}
.avatar-btn .avatar-initial {
    font-size: 15px;
    font-weight: 700;
    color: var(--accent);
}

/* ============================================================
   ИНДИКАТОР КВОТЫ (аноним)
   ============================================================ */
.quota-banner {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    background: linear-gradient(90deg, rgba(16,185,129,0.08), rgba(16,185,129,0.02));
    border: 1px solid rgba(16,185,129,0.25);
    border-radius: var(--radius);
    margin-bottom: 20px;
    animation: fadeIn 0.3s ease;
}

.quota-icon {
    font-size: 22px;
    flex-shrink: 0;
}

.quota-info {
    flex: 1;
    min-width: 0;
}

.quota-title {
    font-size: 13px;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 2px;
}

.quota-sub {
    font-size: 12px;
    color: var(--text-dim);
    font-family: var(--font-mono);
}

.quota-bar {
    margin-top: 6px;
    height: 4px;
    background: var(--surface-3);
    border-radius: 2px;
    overflow: hidden;
}
.quota-bar-fill {
    height: 100%;
    background: var(--accent);
    border-radius: 2px;
    transition: width 0.3s ease;
}
.quota-bar-fill.warn { background: var(--warn); }
.quota-bar-fill.danger { background: var(--danger); }

.quota-banner.warn {
    background: linear-gradient(90deg, rgba(245,158,11,0.08), rgba(245,158,11,0.02));
    border-color: rgba(245,158,11,0.3);
}
.quota-banner.danger {
    background: linear-gradient(90deg, rgba(239,68,68,0.1), rgba(239,68,68,0.02));
    border-color: rgba(239,68,68,0.3);
}

.quota-banner .btn {
    flex-shrink: 0;
    padding: 6px 12px;
    font-size: 12px;
}

/* ============================================================
   КРАСНЫЙ ТОСТ (уведомление о лимите)
   ============================================================ */
.toast.toast-limit {
    background: linear-gradient(135deg, rgba(239,68,68,0.15), rgba(239,68,68,0.08));
    border: 1px solid rgba(239,68,68,0.4);
    color: #fecaca;
    padding: 14px 18px;
    display: flex;
    align-items: flex-start;
    gap: 10px;
    max-width: 380px;
    font-size: 13px;
    line-height: 1.45;
    box-shadow: 0 8px 24px rgba(239,68,68,0.15);
}
.toast.toast-limit .toast-icon {
    font-size: 20px;
    flex-shrink: 0;
    margin-top: 1px;
}
.toast.toast-limit .toast-content {
    flex: 1;
}
.toast.toast-limit .toast-title {
    font-weight: 700;
    color: #fca5a5;
    margin-bottom: 3px;
}
.toast.toast-limit .toast-text {
    color: #fecaca;
    opacity: 0.9;
    font-size: 12px;
}
.toast.toast-limit a {
    color: #fca5a5;
    font-weight: 600;
    text-decoration: underline;
    display: inline-block;
    margin-top: 6px;
}

/* ============================================================
   СТРАНИЦА ВХОДА
   ============================================================ */
.auth-page {
    min-height: 100vh;
    min-height: 100dvh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px 16px;
    background: radial-gradient(circle at 50% 0%, rgba(16,185,129,0.08), transparent 60%),
                var(--bg);
}

.auth-container {
    width: 100%;
    max-width: 380px;
    display: flex;
    flex-direction: column;
    gap: 24px;
    animation: authFadeIn 0.5s ease;
}

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

.auth-header {
    text-align: center;
}

.auth-logo {
    font-size: 56px;
    line-height: 1;
    margin-bottom: 16px;
    filter: drop-shadow(0 0 24px rgba(16,185,129,0.3));
    animation: logoFloat 3s ease-in-out infinite;
}

@keyframes logoFloat {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-4px); }
}

.auth-title {
    font-size: 24px;
    font-weight: 800;
    letter-spacing: -0.02em;
    color: var(--text);
    margin-bottom: 6px;
}

.auth-subtitle {
    font-size: 13px;
    color: var(--text-dim);
    line-height: 1.4;
}

.auth-card {
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 20px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
}

.auth-btn-wrap {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

#telegramWidgetContainer {
    display: flex;
    justify-content: center;
    padding: 4px 0;
}

.auth-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 13px 16px;
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-weight: 600;
    border: 1px solid var(--border);
    background: var(--surface-2);
    color: var(--text);
    cursor: pointer;
    transition: all var(--transition);
    text-decoration: none;
    position: relative;
    width: 100%;
}

.auth-btn:hover:not(:disabled) {
    background: var(--surface-3);
    border-color: var(--border-hover);
    transform: translateY(-1px);
}

.auth-btn:active:not(:disabled) {
    transform: translateY(0);
}

.auth-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.auth-btn-icon {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
}

.auth-btn-telegram {
    background: #229ED9;
    border-color: #229ED9;
    color: #fff;
}
.auth-btn-telegram:hover:not(:disabled) {
    background: #1e8fc4;
    border-color: #1e8fc4;
    color: #fff;
}

.auth-btn-google {
    background: var(--surface-2);
    color: var(--text);
}

.auth-btn-badge {
    position: absolute;
    right: 12px;
    font-size: 9px;
    font-weight: 700;
    padding: 2px 6px;
    background: var(--surface-3);
    color: var(--text-muted);
    border-radius: 4px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.auth-btn-anon {
    background: transparent;
    color: var(--text-dim);
    font-weight: 500;
}
.auth-btn-anon:hover {
    color: var(--text);
    background: var(--surface-2);
    border-color: var(--border-hover);
}

.auth-divider {
    display: flex;
    align-items: center;
    gap: 12px;
    color: var(--text-muted);
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    margin: 4px 0;
}
.auth-divider::before,
.auth-divider::after {
    content: "";
    flex: 1;
    height: 1px;
    background: var(--border);
}

.auth-terms {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    font-size: 12px;
    color: var(--text-dim);
    cursor: pointer;
    line-height: 1.4;
    padding: 0 4px;
}

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

.auth-checkbox-visual {
    position: relative;
    width: 18px;
    height: 18px;
    flex-shrink: 0;
    border: 1.5px solid var(--border-hover);
    border-radius: 5px;
    background: var(--surface);
    transition: all var(--transition);
    margin-top: 1px;
}
.auth-checkbox-visual::after {
    content: "";
    position: absolute;
    top: 3px;
    left: 6px;
    width: 4px;
    height: 8px;
    border: solid #0a0a0a;
    border-width: 0 2px 2px 0;
    transform: rotate(45deg) scale(0);
    transition: transform var(--transition);
}
.auth-terms input:checked + .auth-checkbox-visual {
    background: var(--accent);
    border-color: var(--accent);
}
.auth-terms input:checked + .auth-checkbox-visual::after {
    transform: rotate(45deg) scale(1);
}

.auth-terms-text a {
    color: var(--accent);
    text-decoration: none;
}
.auth-terms-text a:hover { text-decoration: underline; }

.auth-back {
    text-align: center;
    font-size: 13px;
    color: var(--text-muted);
    text-decoration: none;
    transition: color var(--transition);
    padding: 8px;
}
.auth-back:hover { color: var(--text); }

/* ============================================================
   СТРАНИЦА ПРОФИЛЯ
   ============================================================ */
.profile-page {
    min-height: 100vh;
}

.profile-container {
    max-width: 640px;
    margin: 0 auto;
    animation: fadeIn 0.3s ease;
}

.profile-loading {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-muted);
    font-size: 14px;
}

.profile-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 32px 24px;
    text-align: center;
}

.profile-avatar-wrap {
    display: inline-block;
    margin-bottom: 16px;
}

.profile-avatar {
    position: relative;
    width: 96px;
    height: 96px;
    border-radius: 50%;
    overflow: hidden;
    background: var(--surface-2);
    border: 3px solid var(--accent);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: transform var(--transition), border-color var(--transition);
    box-shadow: 0 0 0 4px rgba(16,185,129,0.1);
}
.profile-avatar:hover {
    transform: scale(1.03);
    border-color: var(--accent-hover);
}

.profile-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.profile-avatar-placeholder {
    font-size: 38px;
    font-weight: 800;
    color: var(--accent);
    background: var(--accent-soft);
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.profile-avatar-overlay {
    position: absolute;
    inset: 0;
    background: rgba(0,0,0,0.65);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 26px;
    opacity: 0;
    transition: opacity var(--transition);
    pointer-events: none;
}
.profile-avatar:hover .profile-avatar-overlay {
    opacity: 1;
}

.profile-name {
    font-size: 22px;
    font-weight: 700;
    color: var(--text);
    letter-spacing: -0.01em;
    margin-bottom: 4px;
}

.profile-username {
    font-size: 14px;
    color: var(--accent);
    margin-bottom: 8px;
    font-family: var(--font-mono);
}

.profile-id {
    font-size: 12px;
    color: var(--text-muted);
    font-family: var(--font-mono);
    margin-bottom: 4px;
}
.profile-id span {
    color: var(--text-dim);
}

.profile-joined {
    font-size: 12px;
    color: var(--text-muted);
    margin-bottom: 24px;
}

.profile-stats {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
    padding: 20px 0;
    border-top: 1px solid var(--border);
    border-bottom: 1px solid var(--border);
    margin-bottom: 24px;
}

.profile-stat {
    text-align: center;
}

.profile-stat-value {
    font-size: 18px;
    font-weight: 700;
    color: var(--accent);
    margin-bottom: 4px;
    font-family: var(--font-mono);
}

.profile-stat-label {
    font-size: 11px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

.profile-actions {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.profile-actions .btn {
    width: 100%;
}

.btn-badge-inline {
    display: inline-block;
    font-size: 9px;
    font-weight: 700;
    padding: 2px 6px;
    background: var(--surface-3);
    color: var(--text-muted);
    border-radius: 4px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-left: 6px;
    vertical-align: middle;
}

.profile-hint {
    margin-top: 20px;
    padding: 14px 16px;
    background: var(--accent-soft);
    border: 1px solid rgba(16,185,129,0.2);
    border-radius: var(--radius);
    font-size: 12px;
    color: var(--text-dim);
    line-height: 1.5;
    text-align: center;
}
.profile-hint strong { color: var(--accent); }

@media (max-width: 500px) {
    .profile-card { padding: 24px 18px; }
    .profile-avatar { width: 84px; height: 84px; }
    .profile-avatar-placeholder { font-size: 32px; }
    .profile-name { font-size: 20px; }
    .profile-stats { gap: 8px; }
    .profile-stat-value { font-size: 15px; }
    .profile-stat-label { font-size: 10px; }
}