:root {
    --bg: #eef1fb;
    --surface: rgba(255, 255, 255, 0.88);
    --surface-solid: #ffffff;
    --surface-2: rgba(244, 246, 252, 0.9);
    --surface-3: #f1f3f9;
    --text: #1a1f2e;
    --text-soft: #3d465c;
    --muted: #6b7390;
    --border: rgba(20, 30, 70, 0.10);
    --border-strong: rgba(20, 30, 70, 0.18);

    --accent: #6366f1;
    --accent-hover: #4f46e5;
    --accent-soft: rgba(99, 102, 241, 0.12);
    --accent-grad: linear-gradient(135deg, #6366f1 0%, #8b5cf6 50%, #ec4899 100%);

    --danger: #ef4444;
    --danger-soft: rgba(239, 68, 68, 0.1);
    --success: #10b981;

    --radius: 16px;
    --radius-sm: 10px;
    --shadow: 0 1px 2px rgba(20, 30, 70, 0.05), 0 2px 6px rgba(20, 30, 70, 0.04), 0 12px 32px rgba(99, 102, 241, 0.14);
    --shadow-lg: 0 2px 6px rgba(20, 30, 70, 0.06), 0 4px 14px rgba(20, 30, 70, 0.08), 0 28px 56px rgba(99, 102, 241, 0.22);
    --shadow-card-hover: 0 2px 8px rgba(20, 30, 70, 0.08), 0 20px 48px rgba(99, 102, 241, 0.18);

    --header-h: 68px;
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
    background: var(--bg);
    color: var(--text);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", "SF Pro Display", Inter, Arial, sans-serif;
    font-size: 15px;
    line-height: 1.5;
    height: 100vh;
    -webkit-font-smoothing: antialiased;
    position: relative;
    overflow: hidden;
}

.bg { position: fixed; inset: 0; z-index: -1; overflow: hidden; pointer-events: none; }

.bg__blob {
    position: absolute;
    border-radius: 50%;
    filter: blur(100px);
    opacity: 0.55;
    animation: float 22s ease-in-out infinite;
}
.bg__blob--1 { width: 520px; height: 520px; background: #a5b4fc; top: -120px; left: -100px; }
.bg__blob--2 { width: 460px; height: 460px; background: #f0abfc; top: 40%; right: -120px; animation-delay: -7s; animation-duration: 28s; }
.bg__blob--3 { width: 420px; height: 420px; background: #bae6fd; bottom: -80px; left: 30%; animation-delay: -14s; animation-duration: 30s; }

@keyframes float {
    0%, 100% { transform: translate(0, 0) scale(1); }
    33%      { transform: translate(40px, -30px) scale(1.08); }
    66%      { transform: translate(-30px, 50px) scale(0.96); }
}

.app {
    width: 100%;
    max-width: 100%;
    height: 100vh;
    padding: 14px 20px 16px;
    display: flex;
    flex-direction: column;
    gap: 14px;
}

/* ---------- Header + Toolbar ---------- */

.app__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    flex: 0 0 auto;
}

.app__brand { display: flex; align-items: center; gap: 12px; flex: 0 1 auto; min-width: 0; }

.app__brand-sub {
    margin: 0;
    font-size: 12px;
    line-height: 1.3;
}

.app__logo {
    width: 40px; height: 40px; border-radius: 12px;
    background: var(--accent-grad); color: #fff;
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0;
    box-shadow: 0 6px 18px rgba(99, 102, 241, 0.35);
}
.app__logo svg { width: 20px; height: 20px; }

.app__brand-text h1 {
    font-size: 18px;
    font-weight: 600;
    margin: 0;
    letter-spacing: -0.02em;
    background: var(--accent-grad);
    -webkit-background-clip: text; background-clip: text;
    color: transparent;
    white-space: nowrap;
}

.app__logout { flex: 0 0 auto; }

.muted { color: var(--muted); }

.toolbar {
    flex: 0 0 auto;
    width: 100%;
    min-width: 0;
    display: flex;
    align-items: stretch;
    gap: 10px;
    padding: 6px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    backdrop-filter: blur(20px) saturate(180%);
    -webkit-backdrop-filter: blur(20px) saturate(180%);
}

.toolbar__drop {
    flex: 1 1 auto;
    min-width: 0;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px 14px;
    border: 1.5px dashed var(--border-strong);
    border-radius: var(--radius-sm);
    background: var(--surface-2);
    cursor: pointer;
    transition: border-color .18s ease, background .18s ease;
    text-align: left;
    color: var(--text);
    font: inherit;
    outline: none;
}
.toolbar__drop:hover, .toolbar__drop:focus-visible, .toolbar__drop.is-drag {
    border-color: var(--accent);
    background: var(--accent-soft);
}

.toolbar__drop-icon {
    width: 22px; height: 22px;
    color: var(--accent);
    flex-shrink: 0;
}

.toolbar__drop-text {
    display: flex; flex-direction: column; gap: 0;
    line-height: 1.25;
    min-width: 0;
    overflow: hidden;
}
.toolbar__drop-title {
    font-size: 14px; font-weight: 500;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.toolbar__drop-sub {
    font-size: 12px;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

.toolbar__divider {
    width: 1px;
    background: var(--border);
    margin: 4px 0;
}

.toolbar__record {
    display: flex; align-items: center; gap: 8px;
    padding: 0 6px 0 2px;
    flex-shrink: 0;
}

.record__timer {
    font-variant-numeric: tabular-nums;
    font-size: 14px;
    padding-left: 2px;
}

.link {
    background: none; border: none; padding: 0;
    color: var(--accent);
    cursor: pointer; font: inherit;
    text-decoration: underline; text-underline-offset: 2px;
}

/* ---------- Buttons ---------- */

.btn {
    appearance: none;
    border: 1px solid transparent;
    border-radius: 10px;
    padding: 8px 14px;
    font: inherit;
    font-weight: 500;
    font-size: 14px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    text-decoration: none;
    transition: background .15s ease, border-color .15s ease, transform .1s ease, box-shadow .15s ease, color .15s ease;
    user-select: none;
    white-space: nowrap;
}
.btn:active { transform: translateY(1px); }
.btn svg { flex-shrink: 0; }

.btn--primary {
    background: var(--accent-grad);
    color: #fff;
    box-shadow: 0 4px 14px rgba(99, 102, 241, 0.35);
}
.btn--primary:hover {
    box-shadow: 0 6px 20px rgba(99, 102, 241, 0.45);
    transform: translateY(-1px);
}

.btn--ghost {
    background: var(--surface-solid);
    color: var(--text);
    border-color: var(--border-strong);
}
.btn--ghost:hover {
    background: var(--surface-3);
    border-color: var(--accent);
    color: var(--accent);
}

.btn--danger-ghost {
    background: var(--surface-solid);
    color: var(--danger);
    border-color: rgba(239, 68, 68, 0.22);
}
.btn--danger-ghost:hover {
    background: var(--danger-soft);
    border-color: var(--danger);
    color: var(--danger);
}

.btn[disabled] { opacity: .55; pointer-events: none; }
.btn.is-disabled,
.btn[aria-disabled="true"] {
    opacity: .55;
    cursor: not-allowed;
    filter: grayscale(25%);
}
.btn--primary[disabled] {
    background: rgba(16, 185, 129, 0.85);
    box-shadow: none;
    opacity: 1;
}

.record__dot {
    width: 9px; height: 9px;
    border-radius: 50%; background: #fff;
    display: inline-block;
    transition: background .15s ease;
    box-shadow: 0 0 0 0 rgba(255, 255, 255, 0.6);
}
.is-recording .record__dot { animation: pulse 1.2s ease-in-out infinite; }
.is-paused .record__dot { opacity: 0.6; }

@keyframes pulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(255, 255, 255, 0.7); }
    50%      { box-shadow: 0 0 0 8px rgba(255, 255, 255, 0); }
}

/* ---------- Grid (flex для плавного раскрытия колонок) ---------- */

.app__grid {
    display: flex;
    gap: 0;
    flex: 1 1 auto;
    min-height: 0;
    transition: gap .45s cubic-bezier(0.4, 0, 0.2, 1);
}

body.has-output .app__grid { gap: 14px; }

.app__col {
    display: flex;
    flex-direction: column;
    gap: 12px;
    min-width: 0;
    min-height: 0;
    overflow: hidden;
    transition:
        flex-grow .45s cubic-bezier(0.4, 0, 0.2, 1),
        opacity .3s ease .05s,
        transform .45s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Левая колонка всегда растянута; в idle-состоянии занимает всю ширину.
   Правая колонка по умолчанию свёрнута, раскрывается когда появился вывод. */
.app__col--preview { flex: 1 1 0; }

.app__col--output {
    flex: 0 0 0;
    opacity: 0;
    transform: translateX(24px);
    pointer-events: none;
}

body.has-output .app__col--output {
    flex: 1 1 0;
    opacity: 1;
    transform: translateX(0);
    pointer-events: auto;
}

/* Idle: тулбар более «воздушный», дропзона заметнее */
body:not(.has-preview) .toolbar { padding: 12px; gap: 14px; }
body:not(.has-preview) .toolbar__drop { padding: 16px 20px; gap: 14px; }
body:not(.has-preview) .toolbar__drop-icon { width: 26px; height: 26px; }
body:not(.has-preview) .toolbar__drop-title { font-size: 15px; }

.toolbar,
.toolbar__drop,
.toolbar__drop-icon,
.toolbar__drop-title {
    transition: padding .4s cubic-bezier(0.4, 0, 0.2, 1),
                gap .4s cubic-bezier(0.4, 0, 0.2, 1),
                width .4s cubic-bezier(0.4, 0, 0.2, 1),
                height .4s cubic-bezier(0.4, 0, 0.2, 1),
                font-size .4s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ---------- Cards ---------- */

.card {
    background: var(--surface);
    backdrop-filter: blur(20px) saturate(180%);
    -webkit-backdrop-filter: blur(20px) saturate(180%);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 14px 16px;
    box-shadow: var(--shadow);
    display: flex;
    flex-direction: column;
    gap: 12px;
    animation: card-in .32s cubic-bezier(0.2, 0.6, 0.2, 1) both;
    min-height: 0;
    flex: 0 0 auto;
    transition: box-shadow .25s ease, border-color .25s ease;
}

.card:hover {
    box-shadow: var(--shadow-card-hover);
}

.card.is-leaving {
    animation: card-out .22s cubic-bezier(0.4, 0, 0.6, 1) forwards;
    pointer-events: none;
}

@keyframes card-in {
    from { opacity: 0; transform: translateY(10px) scale(0.985); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes card-out {
    from { opacity: 1; transform: translateY(0) scale(1); }
    to   { opacity: 0; transform: translateY(-6px) scale(0.985); }
}

/* Дропзона «недоступна» во время обработки или записи — визуально и кликом */
body.is-busy .toolbar__drop {
    opacity: .55;
    pointer-events: none;
}

/* Кнопка «Записать голос» блокируется во время генерации — но НЕ во время самой записи (там видны pause/stop) */
body.is-busy:not(.is-recording):not(.is-paused) #recordBtn {
    opacity: .55;
    pointer-events: none;
}

/* ---------- Wave (recording) ---------- */

.card--wave {
    flex: 0 0 auto;
    min-height: 200px;
    max-height: 320px;
}

.wave__head {
    display: flex; justify-content: space-between; align-items: center;
    font-weight: 600; font-size: 14px;
    flex: 0 0 auto;
}
.wave__title { display: flex; align-items: center; gap: 8px; }
.wave__title::before {
    content: "";
    width: 8px; height: 8px; border-radius: 50%;
    background: var(--danger);
    animation: pulse-red 1.2s ease-in-out infinite;
}
@keyframes pulse-red {
    0%, 100% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.6); }
    50%      { box-shadow: 0 0 0 6px rgba(239, 68, 68, 0); }
}

.wave {
    display: block;
    width: 100%;
    flex: 1 1 auto;
    min-height: 140px;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
}

/* ---------- Preview ---------- */

.card--preview {
    flex: 1 1 auto;
    min-height: 0;
    overflow: hidden;
}

.preview__head {
    display: flex; justify-content: space-between; align-items: flex-start;
    gap: 12px;
    flex: 0 0 auto;
}
.preview__head-main { min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.preview__title {
    font-weight: 600; font-size: 15px;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.preview__meta {
    font-size: 12px;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.preview__badge {
    font-size: 12px; padding: 3px 9px;
    background: var(--accent-soft); color: var(--accent);
    border-radius: 999px;
    font-variant-numeric: tabular-nums;
    flex-shrink: 0;
}

.preview__media {
    flex: 1 1 auto;
    min-height: 0;
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: stretch;
    justify-content: center;
    gap: 14px;
    overflow: hidden;
    position: relative;
}

.preview__audio {
    width: 100%;
    border-radius: var(--radius-sm);
    box-shadow: 0 1px 2px rgba(20, 30, 70, 0.06);
    flex: 0 0 auto;
}

/* Декоративная подложка-pulse под аудио, чтобы карточка не выглядела «пустой» */
.preview__media::after {
    content: "";
    display: none;
    flex: 1 1 auto;
    min-height: 80px;
    border-radius: var(--radius-sm);
    background:
        radial-gradient(circle at 20% 50%, rgba(99, 102, 241, 0.18), transparent 40%),
        radial-gradient(circle at 50% 50%, rgba(139, 92, 246, 0.18), transparent 45%),
        radial-gradient(circle at 80% 50%, rgba(236, 72, 153, 0.18), transparent 40%),
        var(--surface-2);
    border: 1px dashed var(--border);
    opacity: .9;
}
.preview__media:has(audio)::after {
    display: block;
}

.preview__video {
    width: 100%; height: 100%;
    max-height: 100%;
    object-fit: contain;
    border-radius: var(--radius-sm);
    background: #000;
    display: block;
}

.preview__fallback {
    padding: 18px 16px;
    background: var(--surface-2);
    border: 1px dashed var(--border-strong);
    border-radius: var(--radius-sm);
    text-align: center;
    display: flex; flex-direction: column; align-items: center; gap: 6px;
    font-size: 13px;
}
.preview__fallback svg { width: 26px; height: 26px; color: var(--muted); opacity: 0.8; }

.preview__actions {
    flex: 0 0 auto;
    display: flex; gap: 8px; flex-wrap: wrap;
}
.preview__actions .btn { flex: 1 1 auto; min-width: 130px; }
.preview__actions .btn--danger-ghost { flex: 0 1 auto; min-width: 110px; }

/* ---------- Status ---------- */

.card--status { flex: 0 0 auto; gap: 8px; }

.status__head {
    display: flex; justify-content: space-between; align-items: center; gap: 12px;
}
.status__name {
    font-weight: 500;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
    max-width: 70%;
    font-size: 14px;
}
.status__state {
    font-size: 12px; padding: 4px 10px;
    border-radius: 999px; background: var(--surface-3); color: var(--muted);
    white-space: nowrap; font-weight: 500;
}
.status__state.is-processing { background: var(--accent-soft); color: var(--accent); }
.status__state.is-done       { background: rgba(16,185,129,.14); color: var(--success); }
.status__state.is-error      { background: rgba(239,68,68,.14); color: var(--danger); }

.progress {
    width: 100%; height: 6px;
    background: var(--surface-3);
    border-radius: 999px; overflow: hidden;
}
.progress__bar {
    height: 100%; background: var(--accent-grad);
    border-radius: 999px; transition: width .3s ease;
    box-shadow: 0 0 12px rgba(99, 102, 241, 0.4);
}
.status__meta { font-size: 12px; }

/* ---------- Result ---------- */

.card--result {
    flex: 1 1 auto;
    min-height: 0;
    overflow: hidden;
}

.card--result .result__head {
    display: flex; justify-content: space-between; align-items: flex-start;
    gap: 10px; flex-wrap: wrap;
    flex: 0 0 auto;
}

.result__title-wrap {
    display: flex; flex-direction: column; gap: 4px;
    min-width: 0; flex: 1 1 auto;
}
.result__title { font-weight: 600; font-size: 15px; }
.result__hint { font-size: 12px; font-weight: 400; margin-left: 6px; }

.result__stats {
    font-size: 12px;
    display: inline-flex; flex-wrap: wrap;
    gap: 5px 8px; align-items: center;
}
.result__stats .stat {
    display: inline-flex; align-items: center; gap: 5px;
    padding: 2px 8px;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: 999px;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}
.result__stats .stat svg { width: 12px; height: 12px; color: var(--accent); flex-shrink: 0; }

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

.result__viewer {
    flex: 1 1 auto;
    min-height: 0;
    width: 100%;
    overflow-y: auto;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    background: var(--surface-solid);
    color: var(--text);
    padding: 12px 14px;
    font: inherit;
    font-size: 14px;
    line-height: 1.7;
    outline: none;
    transition: border-color .15s ease;
    scroll-behavior: smooth;
    white-space: pre-wrap;
    word-wrap: break-word;
}
.result__viewer:focus { border-color: var(--accent); }
.result__viewer:empty::before {
    content: "Текст появится здесь…";
    color: var(--muted);
}

.result__viewer--words {
    white-space: normal;
    font-size: 15px;
    line-height: 1.85;
}

.result__word {
    display: inline;
    padding: 2px 4px;
    margin: 0 -1px;
    border-radius: 5px;
    cursor: pointer;
    transition: background-color .2s ease-out, color .2s ease-out, box-shadow .2s ease-out;
}
.result__word:hover { background: var(--surface-3); }
.result__word--active {
    background-color: #6366f1;
    background-image: var(--accent-grad);
    color: #fff;
    box-shadow: 0 2px 10px rgba(99, 102, 241, 0.35);
}
.result__word--active:hover { background-image: var(--accent-grad); }

/* Поиск: все найденные слова + активное совпадение */
.result__word.is-search-match {
    background-color: rgba(250, 204, 21, 0.28);
    box-shadow: inset 0 0 0 1px rgba(202, 138, 4, 0.35);
}
.result__word.is-search-current {
    background-color: #facc15 !important;
    background-image: none !important;
    color: #1a1f2e !important;
    box-shadow: 0 2px 12px rgba(202, 138, 4, 0.45);
}

/* ---------- Result search bar ---------- */

.result__search {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 4px 6px 4px 12px;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    transition: border-color .15s ease, box-shadow .15s ease;
}
.result__search:focus-within {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-soft);
    background: var(--surface-solid);
}

.result__search-icon {
    width: 16px; height: 16px;
    color: var(--muted);
    flex-shrink: 0;
}

.result__search input {
    flex: 1 1 auto;
    border: none;
    background: transparent;
    outline: none;
    font: inherit;
    font-size: 14px;
    color: var(--text);
    padding: 6px 0;
    min-width: 0;
}
.result__search input::placeholder { color: var(--muted); }
.result__search input::-webkit-search-cancel-button,
.result__search input::-webkit-search-decoration { appearance: none; display: none; }

.result__search-count {
    font-size: 12px;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
    padding: 0 4px;
}

.result__search-btn {
    appearance: none;
    border: 1px solid transparent;
    background: transparent;
    color: var(--muted);
    width: 28px; height: 28px;
    border-radius: 6px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background .15s, color .15s;
    padding: 0;
}
.result__search-btn:hover:not(:disabled) {
    background: var(--surface-solid);
    color: var(--accent);
}
.result__search-btn:disabled { opacity: .35; cursor: default; }
.result__search-btn svg { width: 14px; height: 14px; }

/* ---------- Segmented switcher (Текст / Саммари) ---------- */

.seg {
    display: inline-flex;
    padding: 3px;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: 999px;
    gap: 2px;
    flex-shrink: 0;
}
.seg__btn {
    appearance: none;
    border: none;
    background: transparent;
    color: var(--muted);
    padding: 6px 12px;
    border-radius: 999px;
    font: inherit;
    font-size: 13px;
    font-weight: 500;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
    transition: background .18s ease, color .18s ease, box-shadow .18s ease;
    white-space: nowrap;
}
.seg__btn:hover { color: var(--text); }
.seg__btn.is-active {
    background: var(--surface-solid);
    color: var(--text);
    box-shadow: 0 1px 2px rgba(20, 30, 70, 0.06), 0 4px 12px rgba(99, 102, 241, 0.15);
}
.seg__btn svg { color: currentColor; flex-shrink: 0; }

/* ---------- Summary pane ---------- */

.summary {
    flex: 1 1 auto;
    min-height: 0;
    width: 100%;
    overflow-y: auto;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    background: var(--surface-solid);
    padding: 16px 18px;
    scroll-behavior: smooth;
    animation: card-in .35s cubic-bezier(0.2, 0.6, 0.2, 1) both;
}

.summary__placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    gap: 10px;
    min-height: 220px;
    padding: 24px;
}
.summary__placeholder-icon {
    width: 52px; height: 52px;
    border-radius: 14px;
    background: var(--accent-soft);
    color: var(--accent);
    display: flex; align-items: center; justify-content: center;
}
.summary__placeholder-icon svg { width: 26px; height: 26px; }
.summary__placeholder-title { font-weight: 600; font-size: 15px; }
.summary__placeholder-hint { font-size: 13px; max-width: 420px; }
.summary__generate { margin-top: 6px; }

.summary__loading {
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 10px 2px;
}
.summary__skeleton {
    height: 14px;
    border-radius: 8px;
    background: linear-gradient(90deg, var(--surface-3) 0%, rgba(99, 102, 241, 0.08) 50%, var(--surface-3) 100%);
    background-size: 200% 100%;
    animation: skeleton-shimmer 1.25s ease-in-out infinite;
}
.summary__skeleton--title { height: 22px; width: 55%; }
.summary__skeleton--line { height: 12px; width: 100%; }
.summary__skeleton--short { width: 65%; }
.summary__skeleton--chips { height: 24px; width: 70%; border-radius: 999px; }
.summary__loading-hint { text-align: center; font-size: 12px; margin-top: 6px; }

@keyframes skeleton-shimmer {
    0% { background-position: 100% 0; }
    100% { background-position: -100% 0; }
}

.summary__error {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    padding: 24px;
    text-align: center;
}
.summary__error-title {
    font-weight: 600;
    color: var(--danger);
}
.summary__error-text { font-size: 13px; max-width: 420px; }

.summary__content {
    display: flex;
    flex-direction: column;
    gap: 18px;
}

.summary__header {
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding-bottom: 14px;
    border-bottom: 1px solid var(--border);
}
.summary__title {
    font-size: 20px;
    font-weight: 700;
    color: var(--text);
    line-height: 1.3;
    margin: 0;
}
.summary__lede {
    font-size: 14px;
    color: var(--text-soft);
    line-height: 1.6;
}

.summary__section-title {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12px;
    font-weight: 600;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin: 0 0 8px;
}
.summary__section-title svg {
    width: 14px; height: 14px; color: var(--accent); flex-shrink: 0;
}

.summary__list {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.summary__list li {
    position: relative;
    padding: 10px 12px 10px 34px;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 14px;
    line-height: 1.55;
    color: var(--text);
    transition: border-color .18s ease, transform .18s ease, box-shadow .18s ease;
}
.summary__list li:hover {
    border-color: var(--border-strong);
    transform: translateY(-1px);
    box-shadow: var(--shadow);
}
.summary__list li::before {
    content: "";
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    width: 14px; height: 14px;
    border-radius: 50%;
    background: var(--accent-grad);
    box-shadow: 0 2px 6px rgba(99, 102, 241, 0.35);
}
.summary__list--actions li::before {
    background: #10b981;
    box-shadow: 0 2px 6px rgba(16, 185, 129, 0.4);
}
.summary__list--actions li {
    padding-left: 38px;
}
.summary__list--actions li::before {
    width: 16px; height: 16px;
    background: none;
    box-shadow: none;
    border: 2px solid #10b981;
    border-radius: 5px;
    left: 12px;
}

.summary__chips {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}
.summary__chip {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 10px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 500;
    background: var(--accent-soft);
    color: var(--accent);
    border: 1px solid rgba(99, 102, 241, 0.18);
}
.summary__chip::before {
    content: "#";
    opacity: 0.6;
    font-weight: 600;
}

.summary__meta {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    padding-top: 6px;
    border-top: 1px dashed var(--border);
}
.summary__meta-item {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    border-radius: 999px;
    background: var(--surface-2);
    border: 1px solid var(--border);
    font-size: 12px;
    font-variant-numeric: tabular-nums;
}
.summary__meta-item svg { width: 12px; height: 12px; color: var(--muted); flex-shrink: 0; }

.summary__sentiment {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 600;
    border: 1px solid transparent;
}
.summary__sentiment--positive {
    background: rgba(16, 185, 129, 0.12);
    color: #047857;
    border-color: rgba(16, 185, 129, 0.28);
}
.summary__sentiment--neutral {
    background: var(--accent-soft);
    color: var(--accent);
    border-color: rgba(99, 102, 241, 0.22);
}
.summary__sentiment--negative {
    background: rgba(239, 68, 68, 0.12);
    color: #b91c1c;
    border-color: rgba(239, 68, 68, 0.3);
}

.summary__empty {
    font-size: 13px;
    color: var(--muted);
    font-style: italic;
}

/* Скрываем плейсхолдер вьюера, когда активна вкладка саммари */
.card--result.is-summary .result__viewer,
.card--result.is-summary .result__search { display: none !important; }
.card--result:not(.is-summary) .summary { display: none !important; }

/* ---------- Empty state ---------- */

.empty-state {
    flex: 1 1 auto;
    display: flex; flex-direction: column;
    align-items: center; justify-content: center;
    text-align: center;
    padding: 24px;
    gap: 8px;
    background: var(--surface);
    backdrop-filter: blur(10px);
    border: 1.5px dashed var(--border-strong);
    border-radius: var(--radius);
    color: var(--muted);
    min-height: 0;
    animation: card-in .35s cubic-bezier(0.2, 0.6, 0.2, 1) both;
}
.empty-state__icon {
    width: 48px; height: 48px; border-radius: 14px;
    background: var(--accent-soft); color: var(--accent);
    display: flex; align-items: center; justify-content: center;
    margin-bottom: 2px;
}
.empty-state__icon svg { width: 22px; height: 22px; }
.empty-state__title { font-weight: 600; color: var(--text); font-size: 14px; }
.empty-state__hint { font-size: 13px; max-width: 360px; }

.hidden { display: none !important; }

/* ---------- Global drop overlay ---------- */

.drop-overlay {
    position: fixed;
    inset: 0;
    z-index: 900;
    background: rgba(99, 102, 241, 0.18);
    backdrop-filter: blur(14px) saturate(140%);
    -webkit-backdrop-filter: blur(14px) saturate(140%);
    display: flex;
    align-items: center;
    justify-content: center;
    pointer-events: none;
    animation: overlay-in .18s ease;
}

@keyframes overlay-in {
    from { opacity: 0; transform: scale(0.98); }
    to   { opacity: 1; transform: scale(1); }
}

.drop-overlay__inner {
    border: 2.5px dashed var(--accent);
    background: var(--surface-solid);
    border-radius: var(--radius);
    padding: 28px 44px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    box-shadow: var(--shadow-lg);
    text-align: center;
}

.drop-overlay__inner svg {
    width: 52px;
    height: 52px;
    color: var(--accent);
    margin-bottom: 4px;
}

.drop-overlay__title {
    font-weight: 600;
    font-size: 18px;
    color: var(--text);
}

.drop-overlay__hint {
    font-size: 13px;
    color: var(--muted);
}

/* ---------- Modal ---------- */

.modal {
    position: fixed;
    inset: 0;
    z-index: 1100;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: overlay-in .22s cubic-bezier(0.2, 0.6, 0.2, 1);
}

.modal__backdrop {
    position: absolute;
    inset: 0;
    background: rgba(20, 30, 70, 0.45);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    cursor: pointer;
}

.modal__card {
    position: relative;
    background: var(--surface-solid);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 28px 28px 24px;
    max-width: 460px;
    width: calc(100% - 32px);
    box-shadow: var(--shadow-lg);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    text-align: center;
    animation: modal-in .28s cubic-bezier(0.2, 0.6, 0.2, 1);
}

@keyframes modal-in {
    from { opacity: 0; transform: translateY(12px) scale(0.96); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
}

.modal__icon {
    width: 60px; height: 60px;
    border-radius: 18px;
    background: var(--accent-soft);
    color: var(--accent);
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 4px;
}
.modal__icon svg { width: 28px; height: 28px; }

.modal__title { font-weight: 600; font-size: 18px; margin: 0; color: var(--text); }
.modal__text {
    font-size: 14px;
    color: var(--muted);
    margin: 0;
    line-height: 1.55;
    max-width: 380px;
}

.modal__actions {
    display: flex;
    gap: 10px;
    margin-top: 10px;
    width: 100%;
    justify-content: center;
    flex-wrap: wrap;
}
.modal__actions .btn { min-width: 140px; }

/* ---------- Toast ---------- */

.toast {
    position: fixed;
    left: 50%;
    bottom: 20px;
    transform: translateX(-50%);
    background: var(--text);
    color: #fff;
    padding: 10px 18px;
    border-radius: 999px;
    font-size: 14px;
    box-shadow: var(--shadow-lg);
    z-index: 1000;
}

/* ---------- Login ---------- */

html:has(.app--auth), body:has(.app--auth) {
    height: auto;
    overflow: auto;
}

.app--auth {
    min-height: 100vh;
    height: auto;
    width: 100%;
    max-width: 100%;
    margin: 0;
    padding: 24px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 20px;
}

.card--login {
    max-width: 420px;
    width: 100%;
    margin: 0 auto;
}
.login__header { text-align: center; }
.login__header h1 {
    margin: 0 0 4px; font-size: 24px; font-weight: 600;
    letter-spacing: -0.025em;
    background: var(--accent-grad);
    -webkit-background-clip: text; background-clip: text; color: transparent;
    display: inline-block;
}
.login__form { display: flex; flex-direction: column; gap: 14px; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field__label { font-size: 13px; color: var(--muted); }
.field__input {
    border: 1px solid var(--border-strong);
    background: var(--surface-solid); color: var(--text);
    border-radius: var(--radius-sm);
    padding: 11px 14px;
    font: inherit; font-size: 15px;
    outline: none;
    transition: border-color .15s ease, box-shadow .15s ease;
}
.field__input:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-soft);
}
.login__error {
    background: rgba(239, 68, 68, .12);
    color: var(--danger);
    border-radius: var(--radius-sm);
    padding: 10px 12px;
    font-size: 14px;
}
.btn--block { width: 100%; }

/* ---------- Adaptive ---------- */

@media (max-width: 1080px) {
    .app__brand-text h1 { font-size: 16px; }
    .toolbar__drop-sub { display: none; }
    .toolbar__drop-title { font-size: 13px; }
}

/* Планшеты и узкие десктопы: колонки в стек, разрешаем вертикальный скролл */
@media (max-width: 900px) {
    html, body { overflow: auto; height: auto; }
    .app {
        height: auto;
        min-height: 100vh;
        padding: 14px 14px 32px;
        gap: 12px;
    }
    .app__grid {
        flex-direction: column;
        gap: 12px;
    }
    .app__col {
        overflow: visible;
        flex: 0 0 auto !important;
        width: 100%;
        min-height: 0;
    }
    /* На мобилке правая колонка не «выезжает» — просто появляется ниже */
    .app__col--output {
        transform: none !important;
        opacity: 1 !important;
        flex: 0 0 auto !important;
        pointer-events: auto !important;
    }
    body:not(.has-output) .app__col--output { display: none; }
    .card--preview, .card--result { flex: 0 0 auto; }
    .card--wave { min-height: 160px; max-height: 240px; }
    .preview__video { max-height: 50vh; }
    .result__viewer { max-height: 55vh; min-height: 200px; }
    .empty-state { min-height: 160px; padding: 28px 20px; }
    /* На idle-экране (ничего нет) плейсхолдеры не должны быть огромными */
    body:not(.has-preview) #emptyStatePreview { min-height: 200px; }
}

/* Мобилки: тулбар вертикально, компактные отступы, предотвращение iOS-zoom на фокусе */
@media (max-width: 600px) {
    .app__header { flex-wrap: wrap; gap: 10px; }
    .app__brand { flex: 1 1 auto; min-width: 0; gap: 10px; }
    .app__brand-text h1 { font-size: 15px; }
    .app__brand-sub { display: none; }
    .app__logo { width: 36px; height: 36px; border-radius: 10px; }
    .app__logout span { display: none; }
    .app__logout { padding: 10px; }

    .toolbar {
        flex-direction: column;
        gap: 8px;
        padding: 8px;
        align-items: stretch;
    }
    .toolbar__drop {
        padding: 14px 14px;
        gap: 10px;
    }
    .toolbar__drop-sub { display: block; font-size: 11px; }
    .toolbar__divider { display: none; }
    .toolbar__record {
        width: 100%;
        justify-content: space-between;
        gap: 8px;
        padding: 2px 2px 4px;
        flex-wrap: wrap;
    }
    .toolbar__record .btn {
        flex: 1 1 auto;
    }
    .toolbar__record .record__timer {
        flex: 0 0 auto;
    }

    /* Кнопки превью и результата — в сетку, чтобы не налезали друг на друга */
    .preview__actions { gap: 6px; }
    .preview__actions .btn { flex: 1 1 calc(50% - 3px); min-width: 0; padding: 8px 10px; font-size: 13px; }
    .preview__actions .btn--danger-ghost { flex: 1 1 calc(50% - 3px); min-width: 0; }

    .result__head { gap: 8px; }
    .result__actions { width: 100%; gap: 6px; }
    .result__actions .btn { flex: 1 1 auto; padding: 8px 10px; font-size: 13px; }
    .result__actions .seg { width: 100%; justify-content: stretch; }
    .result__actions .seg__btn { flex: 1 1 50%; justify-content: center; padding: 7px 10px; }
    .result__viewer { font-size: 14px; }
    .summary { padding: 14px 14px; }
    .summary__title { font-size: 17px; }

    /* iOS/Safari зумит страницу при фокусе на input с font-size < 16px — предотвращаем */
    .result__search input,
    .field__input { font-size: 16px; }

    .modal__card { padding: 22px 20px 18px; }
    .modal__actions { gap: 8px; }
    .modal__actions .btn { min-width: 0; flex: 1 1 auto; }

    .bg__blob { filter: blur(70px); opacity: 0.45; }
    .drop-overlay__inner { padding: 22px 28px; }
    .drop-overlay__title { font-size: 15px; }
}

/* Совсем маленькие экраны — ещё плотнее */
@media (max-width: 380px) {
    .app { padding: 10px 10px 28px; }
    .app__brand-text h1 { font-size: 14px; }
    .toolbar__drop-title { font-size: 12px; }
    .toolbar__drop-sub { font-size: 10px; }
    .record__timer { font-size: 13px; }
}
