:root {
    --bg: #060608;
    --bg-soft: rgba(14, 14, 18, 0.84);
    --panel: rgba(16, 16, 20, 0.82);
    --panel-strong: rgba(20, 20, 24, 0.96);
    --text: #f5f7fb;
    --text-soft: #d6d9e3;
    --text-muted: #9097aa;
    --stroke: rgba(255, 255, 255, 0.08);
    --accent: #f59e0b;
    --accent-2: #fde68a;
    --success: #34d399;
    --warning: #fbbf24;
    --danger: #fb7185;
    --shadow: 0 26px 60px rgba(0, 0, 0, 0.42);
    --radius-xl: 30px;
    --radius-lg: 22px;
    --radius-md: 16px;
    --radius-sm: 12px;
    --blur: 18px;
    --caption-scale: 1;
    --caption-bg: rgba(3, 3, 4, 0.68);
    --caption-text: #ffffff;
    --caption-shadow: 0 12px 32px rgba(0, 0, 0, 0.42);
    --blob-a: rgba(255, 191, 36, 0.16);
    --blob-b: rgba(245, 158, 11, 0.1);
    color-scheme: dark;
}

html[data-theme="kallu-bhai"] {
    --bg: #050505;
    --bg-soft: rgba(10, 10, 11, 0.92);
    --panel: rgba(14, 14, 15, 0.86);
    --panel-strong: rgba(18, 18, 19, 0.98);
    --text: #f7f7f8;
    --text-soft: #d6d6da;
    --text-muted: #8d8d96;
    --stroke: rgba(255, 255, 255, 0.07);
    --accent: #f59e0b;
    --accent-2: #fcd34d;
    --blob-a: rgba(245, 158, 11, 0.18);
    --blob-b: rgba(255, 255, 255, 0.05);
}

html[data-theme="obsidian"] {
    --bg: #07101d;
    --bg-soft: rgba(11, 17, 31, 0.72);
    --panel: rgba(11, 17, 31, 0.68);
    --panel-strong: rgba(14, 22, 38, 0.9);
    --text: #f8fbff;
    --text-soft: #c8d2e3;
    --text-muted: #92a0b7;
    --stroke: rgba(255, 255, 255, 0.12);
    --accent: #ff6b6b;
    --accent-2: #ff9a62;
    --blob-a: rgba(255, 107, 107, 0.24);
    --blob-b: rgba(124, 92, 255, 0.16);
}

html[data-theme="aurora"] {
    --bg: #07141a;
    --bg-soft: rgba(7, 20, 26, 0.74);
    --panel: rgba(8, 22, 31, 0.74);
    --panel-strong: rgba(10, 26, 35, 0.96);
    --text: #f7ffff;
    --text-soft: #c7f0ef;
    --text-muted: #8bc3c0;
    --stroke: rgba(157, 255, 236, 0.14);
    --accent: #57d3c8;
    --accent-2: #8bf0ff;
    --blob-a: rgba(87, 211, 200, 0.2);
    --blob-b: rgba(116, 154, 255, 0.16);
}

html[data-theme="orchid"] {
    --bg: #130c1d;
    --bg-soft: rgba(19, 12, 29, 0.78);
    --panel: rgba(25, 17, 39, 0.76);
    --panel-strong: rgba(30, 20, 46, 0.96);
    --text: #fff8ff;
    --text-soft: #f2d7ff;
    --text-muted: #cfadea;
    --stroke: rgba(255, 189, 250, 0.14);
    --accent: #cb6dff;
    --accent-2: #ff7fd0;
    --blob-a: rgba(203, 109, 255, 0.22);
    --blob-b: rgba(255, 127, 208, 0.14);
}

html[data-theme="paperlight"] {
    --bg: #f6f7fb;
    --bg-soft: rgba(255, 255, 255, 0.9);
    --panel: rgba(255, 255, 255, 0.9);
    --panel-strong: rgba(255, 255, 255, 0.98);
    --text: #111827;
    --text-soft: #334155;
    --text-muted: #64748b;
    --stroke: rgba(15, 23, 42, 0.08);
    --accent: #2563eb;
    --accent-2: #8b5cf6;
    --success: #059669;
    --warning: #ca8a04;
    --danger: #dc2626;
    --shadow: 0 22px 48px rgba(15, 23, 42, 0.08);
    --caption-bg: rgba(10, 14, 24, 0.78);
    --blob-a: rgba(37, 99, 235, 0.12);
    --blob-b: rgba(139, 92, 246, 0.08);
    color-scheme: light;
}

* {
    box-sizing: border-box;
}

html,
body {
    margin: 0;
    min-height: 100%;
}

body {
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    background:
        radial-gradient(circle at top left, rgba(255, 255, 255, 0.04), transparent 24%),
        radial-gradient(circle at bottom right, rgba(255, 255, 255, 0.03), transparent 28%),
        var(--bg);
    color: var(--text);
    line-height: 1.5;
    position: relative;
    overflow-x: hidden;
}

button,
input,
select,
textarea {
    font: inherit;
}

button {
    cursor: pointer;
}

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

a {
    color: inherit;
}

.blob {
    position: fixed;
    border-radius: 999px;
    filter: blur(60px);
    pointer-events: none;
    z-index: 0;
    opacity: 0.95;
    animation: drift 18s ease-in-out infinite alternate;
}

.blob-a {
    inset: -4rem auto auto -5rem;
    width: 18rem;
    height: 18rem;
    background: var(--blob-a);
}

.blob-b {
    inset: auto -7rem -4rem auto;
    width: 24rem;
    height: 24rem;
    background: var(--blob-b);
    animation-duration: 24s;
}

@keyframes drift {
    from { transform: translate3d(0, 0, 0) scale(1); }
    to { transform: translate3d(1rem, -1rem, 0) scale(1.08); }
}

.hidden {
    display: none !important;
}

.app-shell {
    position: relative;
    z-index: 1;
    width: min(1600px, calc(100% - 2rem));
    margin: 0 auto;
    padding: 1rem 0 2rem;
}

.glass-card {
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.06), transparent 18%), var(--panel);
    border: 1px solid var(--stroke);
    backdrop-filter: blur(var(--blur));
    -webkit-backdrop-filter: blur(var(--blur));
    box-shadow: var(--shadow);
}

.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1.25rem;
    border-radius: var(--radius-xl);
    padding: 1.05rem 1.2rem;
    margin-bottom: 1rem;
    animation: rise-in 450ms ease;
}

.brand-wrap {
    display: flex;
    align-items: center;
    gap: 1rem;
    min-width: 0;
}

.brand-mark {
    width: 4rem;
    height: 4rem;
    padding: 0.4rem;
    border-radius: 1.3rem;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--stroke);
    flex-shrink: 0;
}

.brand-mark img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.brand-copy h1,
.panel-head h2,
.stack-head h3,
.dialog-head h2 {
    margin: 0;
    letter-spacing: -0.03em;
}

.brand-copy h1 {
    font-size: clamp(1.9rem, 2.3vw, 2.8rem);
}

.tagline {
    margin: 0.25rem 0 0;
    color: var(--accent);
    font-weight: 700;
}

.eyebrow-chip,
.live-badge,
.timer-pill,
.stat-pill,
.mini-label,
.section-kicker,
.mini-pill {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    font-size: 0.78rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.live-badge,
.timer-pill,
.stat-pill,
.mini-pill {
    padding: 0.45rem 0.72rem;
    border-radius: 999px;
    border: 1px solid var(--stroke);
    background: rgba(255, 255, 255, 0.04);
    color: var(--text-soft);
}

.section-kicker,
.mini-label {
    color: var(--accent);
    margin-bottom: 0.2rem;
}

.topbar-actions {
    display: flex;
    align-items: center;
    gap: 0.9rem;
    flex-wrap: wrap;
    justify-content: flex-end;
}

.dot {
    width: 0.55rem;
    height: 0.55rem;
    border-radius: 50%;
    background: var(--success);
    box-shadow: 0 0 0 0 rgba(52, 211, 153, 0.38);
    animation: pulse 1.8s infinite;
}

@keyframes pulse {
    0% { box-shadow: 0 0 0 0 rgba(52, 211, 153, 0.38); }
    70% { box-shadow: 0 0 0 0.7rem rgba(52, 211, 153, 0); }
    100% { box-shadow: 0 0 0 0 rgba(52, 211, 153, 0); }
}

.workspace-switcher {
    display: none;
    gap: 0.5rem;
    padding: 0.55rem;
    margin-bottom: 1rem;
    border-radius: 999px;
}

.workspace-chip,
.segmented-button {
    border: 0;
    border-radius: 999px;
    background: transparent;
    color: var(--text-soft);
    padding: 0.72rem 1rem;
    font-weight: 700;
}

.workspace-chip.is-active,
.segmented-button.is-active {
    background: linear-gradient(135deg, color-mix(in srgb, var(--accent) 34%, white 0%), color-mix(in srgb, var(--accent-2) 16%, white 0%));
    color: #fff;
}

.dashboard-grid {
    display: grid;
    grid-template-columns: 1.04fr 1.18fr 0.88fr;
    gap: 1.15rem;
    align-items: start;
}

.panel {
    border-radius: var(--radius-xl);
    padding: 1.1rem;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.panel-scroll,
.editor-scroll {
    min-width: 0;
}

.panel-head,
.stack-head,
.dialog-head,
.split-head,
.usage-chart-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;
}

.sticky-head {
    position: sticky;
    top: 0.45rem;
    z-index: 6;
    padding-bottom: 0.8rem;
    background: linear-gradient(180deg, var(--panel-strong) 0%, rgba(0, 0, 0, 0) 100%);
    backdrop-filter: blur(10px);
}

.panel-note,
.preset-description,
.fine-print,
.empty-state,
#selectedAudioMeta,
.video-label,
.transcript-box,
.summary-card span,
.dialog-copy,
.warning-text,
.usage-chart-head span {
    color: var(--text-muted);
}

.warning-text {
    margin: 0.4rem 0 0;
}

h3,
h4,
p {
    margin-top: 0;
}

.uploader,
.stack-card,
.selected-audio,
.summary-card,
.transport-card,
.segment-card,
.transcript-box,
.tracker-card,
.tracker-block {
    background: rgba(255, 255, 255, 0.035);
    border: 1px solid var(--stroke);
    border-radius: var(--radius-lg);
}

.uploader,
.selected-audio,
.stack-card,
.transport-card,
.transcript-box,
.tracker-block {
    padding: 1rem;
}

.uploader {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    min-height: 120px;
    transition: transform 180ms ease, border-color 180ms ease, background 180ms ease;
}

.uploader.is-dragover {
    transform: translateY(-2px);
    border-color: color-mix(in srgb, var(--accent) 30%, white 5%);
    background: rgba(255, 255, 255, 0.08);
}

.uploader-copy {
    display: flex;
    align-items: center;
    gap: 0.9rem;
    min-width: 0;
}

.icon-badge,
.button-icon,
.icon-only {
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.icon-badge {
    width: 3rem;
    height: 3rem;
    border-radius: 1rem;
    color: var(--accent);
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid var(--stroke);
    flex-shrink: 0;
}

.icon-badge svg,
.button-icon svg,
.icon-only svg {
    width: 1.2rem;
    height: 1.2rem;
    fill: currentColor;
}

.selected-audio {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
}

.field-grid {
    display: grid;
    gap: 0.9rem;
}

.two-up {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.three-up {
    grid-template-columns: repeat(3, minmax(0, 1fr));
}

.compact-grid {
    margin-top: 0.9rem;
}

.field {
    display: flex;
    flex-direction: column;
    gap: 0.45rem;
    min-width: 0;
}

.compact-field {
    min-width: 170px;
}

.field > span {
    font-size: 0.92rem;
    font-weight: 600;
    color: var(--text-soft);
}

input[type="text"],
input[type="number"],
input[type="password"],
select,
textarea {
    width: 100%;
    border-radius: 0.95rem;
    border: 1px solid rgba(255, 255, 255, 0.12);
    background: rgba(8, 8, 12, 0.5);
    color: var(--text);
    padding: 0.85rem 0.95rem;
    outline: none;
    transition: border-color 180ms ease, box-shadow 180ms ease, background 180ms ease;
}

html[data-theme="paperlight"] input[type="text"],
html[data-theme="paperlight"] input[type="number"],
html[data-theme="paperlight"] input[type="password"],
html[data-theme="paperlight"] select,
html[data-theme="paperlight"] textarea {
    background: rgba(248, 250, 252, 0.96);
}

textarea {
    min-height: 110px;
    resize: vertical;
}

input[type="text"]:focus,
input[type="number"]:focus,
input[type="password"]:focus,
select:focus,
textarea:focus {
    border-color: color-mix(in srgb, var(--accent) 42%, white 0%);
    box-shadow: 0 0 0 0.18rem color-mix(in srgb, var(--accent) 18%, transparent 82%);
}

input[type="range"] {
    width: 100%;
    accent-color: var(--accent);
}

.field strong {
    color: var(--text);
    font-size: 0.95rem;
}

.action-field {
    justify-content: flex-end;
}

.primary-button,
.secondary-button,
.ghost-button,
.hero-button,
.icon-only {
    border: 0;
    border-radius: 1rem;
    padding: 0.85rem 1rem;
    font-weight: 700;
    color: var(--text);
    transition: transform 160ms ease, box-shadow 160ms ease, background 160ms ease, opacity 160ms ease;
}

.primary-button,
.hero-button {
    background: linear-gradient(135deg, var(--accent), var(--accent-2));
    box-shadow: 0 14px 30px color-mix(in srgb, var(--accent) 28%, transparent 72%);
}

.secondary-button {
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid var(--stroke);
}

.ghost-button,
.icon-only {
    background: transparent;
    border: 1px solid var(--stroke);
}

.ghost-button.danger {
    color: var(--danger);
}

.hero-button {
    width: 100%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.7rem;
    padding-block: 1rem;
}

.icon-only {
    width: 3rem;
    height: 3rem;
    padding: 0;
}

.primary-button:hover,
.secondary-button:hover,
.ghost-button:hover,
.hero-button:hover,
.icon-only:hover {
    transform: translateY(-1px);
}

button:disabled {
    opacity: 0.55;
    cursor: not-allowed;
    transform: none !important;
}

.inline-actions,
.editor-actions,
.recorder-actions,
.transport-actions,
.dialog-actions {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    flex-wrap: wrap;
}

.recorder-card .live-badge.is-recording {
    color: var(--danger);
    border-color: color-mix(in srgb, var(--danger) 35%, transparent 65%);
    background: color-mix(in srgb, var(--danger) 14%, transparent 86%);
}

.segmented {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    padding: 0.35rem;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid var(--stroke);
    flex-wrap: wrap;
}

.dimension-pill {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 3.1rem;
    border-radius: 1rem;
    border: 1px solid var(--stroke);
    background: rgba(255, 255, 255, 0.04);
    color: var(--text-soft);
    font-weight: 700;
    padding: 0 0.9rem;
}

.summary-grid,
.tracker-grid {
    display: grid;
    gap: 0.8rem;
}

.summary-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
}

.tracker-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.summary-card,
.tracker-card {
    padding: 0.9rem 1rem;
}

.summary-card strong,
.tracker-card strong {
    display: block;
    margin-top: 0.3rem;
    font-size: 1rem;
}

.transcript-box {
    min-height: 140px;
    max-height: 180px;
    overflow: auto;
    white-space: pre-wrap;
}

.editor-tools {
    display: flex;
    gap: 0.65rem;
    flex-wrap: wrap;
    margin-top: 1rem;
}

.segment-list {
    display: flex;
    flex-direction: column;
    gap: 0.85rem;
    margin-top: 1rem;
}

.segment-card {
    padding: 0.95rem;
    animation: rise-in 280ms ease;
}

.segment-top {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 0.75rem;
}

.segment-index {
    font-size: 0.88rem;
    font-weight: 800;
    color: var(--accent);
    min-width: 3.4rem;
}

.segment-time-pair {
    display: grid;
    grid-template-columns: repeat(2, minmax(120px, 1fr));
    gap: 0.6rem;
    flex: 1 1 auto;
}

.segment-time-pair label {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    font-size: 0.82rem;
    color: var(--text-soft);
}

.segment-actions {
    display: flex;
    align-items: center;
    gap: 0.45rem;
    flex-wrap: wrap;
}

.segment-actions button {
    border-radius: 0.8rem;
    padding: 0.6rem 0.75rem;
    border: 1px solid var(--stroke);
    background: rgba(255, 255, 255, 0.04);
    color: var(--text-soft);
    font-weight: 700;
}

.phone-stage {
    display: grid;
    place-items: center;
}

.phone-shell {
    position: relative;
    width: min(100%, 300px);
    aspect-ratio: 9 / 16;
    padding: 0.72rem;
    border-radius: 2.4rem;
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.16), rgba(255, 255, 255, 0.03));
    border: 1px solid rgba(255, 255, 255, 0.14);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.12), 0 24px 40px rgba(0, 0, 0, 0.28);
    overflow: hidden;
    transition: width 220ms ease, aspect-ratio 220ms ease, border-radius 220ms ease;
}

.phone-shell.landscape {
    width: min(100%, 390px);
    aspect-ratio: 16 / 9;
    border-radius: 1.8rem;
}

.phone-shell.custom {
    width: min(100%, 360px);
    border-radius: 1.8rem;
}

.phone-notch {
    position: absolute;
    inset: 0.45rem 50% auto auto;
    transform: translateX(50%);
    width: 30%;
    height: 1.25rem;
    border-radius: 0 0 0.9rem 0.9rem;
    background: rgba(0, 0, 0, 0.38);
    z-index: 4;
}

.phone-shell.landscape .phone-notch,
.phone-shell.custom .phone-notch {
    width: 22%;
    height: 0.8rem;
}

.phone-video-bg {
    position: absolute;
    inset: 0.72rem;
    border-radius: 1.8rem;
    background:
        radial-gradient(circle at 18% 18%, rgba(255, 255, 255, 0.18), transparent 34%),
        radial-gradient(circle at 78% 22%, rgba(255, 255, 255, 0.1), transparent 26%),
        linear-gradient(145deg, rgba(245, 158, 11, 0.26), rgba(60, 60, 72, 0.52) 44%, rgba(8, 8, 12, 0.94));
    overflow: hidden;
}

.video-flares {
    position: absolute;
    inset: auto -10% -18% auto;
    width: 70%;
    aspect-ratio: 1;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(255, 255, 255, 0.24), transparent 66%);
    filter: blur(14px);
}

.video-label {
    position: absolute;
    top: 1rem;
    left: 1rem;
    padding: 0.42rem 0.7rem;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.12);
    font-weight: 700;
}

.caption-safe-zone {
    position: absolute;
    inset: 0.72rem;
    display: flex;
    align-items: flex-end;
    justify-content: center;
    padding: 1rem 0.8rem 1.25rem;
    z-index: 3;
}

.caption-bubble {
    width: min(100%, 100% - 1rem);
    max-width: 92%;
    border-radius: 1.2rem;
    padding: 0.75rem 0.95rem;
    color: var(--caption-text);
    text-align: center;
    box-shadow: var(--caption-shadow);
    transform: translateZ(0);
    transition: background 180ms ease, transform 180ms ease;
}

.caption-bubble.skin-classic {
    background: rgba(8, 10, 16, 0.84);
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.caption-bubble.skin-glass {
    background: var(--caption-bg);
    border: 1px solid rgba(255, 255, 255, 0.14);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
}

.caption-bubble.skin-focus {
    background: linear-gradient(180deg, rgba(0, 0, 0, 0.78), rgba(0, 0, 0, 0.92));
    border: 1px solid rgba(255, 255, 255, 0.08);
}

#captionLines {
    display: flex;
    flex-direction: column;
    gap: 0.18rem;
    font-size: calc(1rem * var(--caption-scale));
    font-weight: 800;
    letter-spacing: -0.02em;
    line-height: 1.18;
}

.caption-line {
    animation: caption-up 180ms ease;
}

.caption-line.is-karaoke-line {
    color: rgba(255, 255, 255, 0.96);
    text-shadow: 0 0 18px rgba(255, 255, 255, 0.12);
}

.caption-word {
    display: inline-block;
    color: rgba(255, 255, 255, 0.42);
    transition: color 110ms ease, transform 110ms ease, text-shadow 110ms ease;
    margin-right: 0.22em;
}

.caption-word.is-past,
.caption-word.is-active {
    color: #ffffff;
}

.caption-word.is-active {
    transform: translateY(-1px);
    text-shadow: 0 0 16px rgba(255, 255, 255, 0.22), 0 0 22px color-mix(in srgb, var(--accent) 35%, transparent 65%);
}

.caption-placeholder {
    margin: 0;
    font-size: calc(0.95rem * var(--caption-scale));
    color: rgba(255, 255, 255, 0.84);
    font-weight: 700;
}

@keyframes caption-up {
    from { opacity: 0; transform: translateY(6px); }
    to { opacity: 1; transform: translateY(0); }
}

.transport-card {
    margin-top: 1rem;
}

#audioPreview {
    width: 100%;
    margin-top: 0.85rem;
}

.tracker-block {
    margin-top: 1rem;
}

.usage-chart-wrap {
    margin-top: 1rem;
}

.usage-chart {
    display: grid;
    grid-template-columns: repeat(7, minmax(0, 1fr));
    gap: 0.6rem;
    align-items: end;
    min-height: 150px;
}

.usage-bar {
    display: flex;
    flex-direction: column;
    gap: 0.45rem;
    align-items: center;
    justify-content: flex-end;
    min-width: 0;
}

.usage-bar-track {
    width: 100%;
    min-height: 92px;
    display: flex;
    align-items: flex-end;
    justify-content: center;
    padding: 0.25rem;
    border-radius: 1rem;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid var(--stroke);
}

.usage-bar-fill {
    width: 100%;
    border-radius: 999px;
    background: linear-gradient(180deg, var(--accent), var(--accent-2));
    min-height: 0.25rem;
}

.usage-bar strong,
.usage-bar span {
    font-size: 0.75rem;
    color: var(--text-muted);
    text-align: center;
}

.app-dialog {
    width: min(760px, calc(100% - 1.2rem));
    border: 1px solid var(--stroke);
    background: var(--panel-strong);
    color: var(--text);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow);
    padding: 0;
}

.small-dialog {
    width: min(480px, calc(100% - 1.2rem));
}

.app-dialog::backdrop {
    background: rgba(2, 8, 23, 0.76);
    backdrop-filter: blur(8px);
}

.dialog-form {
    padding: 1rem;
}

.dialog-copy {
    margin: 0.2rem 0 1rem;
}

.dialog-actions {
    justify-content: flex-end;
    margin-top: 1rem;
}

.dialog-error {
    color: var(--danger);
    font-weight: 600;
    margin: 0.6rem 0 0;
}

.toast-stack {
    position: fixed;
    right: 1rem;
    bottom: 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.7rem;
    z-index: 30;
    width: min(100vw - 2rem, 360px);
}

.toast {
    border-radius: 1.1rem;
    padding: 0.85rem 1rem;
    border: 1px solid var(--stroke);
    background: var(--panel-strong);
    box-shadow: var(--shadow);
    animation: toast-in 180ms ease;
}

.toast strong {
    display: block;
    margin-bottom: 0.15rem;
}

.toast p {
    margin: 0;
    color: var(--text-soft);
    font-size: 0.94rem;
}

.toast.is-success {
    border-color: color-mix(in srgb, var(--success) 32%, transparent 68%);
}

.toast.is-warning {
    border-color: color-mix(in srgb, var(--warning) 32%, transparent 68%);
}

.toast.is-error {
    border-color: color-mix(in srgb, var(--danger) 32%, transparent 68%);
}

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

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

@media (min-width: 1025px) {
    .panel {
        max-height: calc(100vh - 7.35rem);
        min-height: calc(100vh - 7.35rem);
        overflow: hidden;
    }

    .panel-scroll,
    .editor-scroll {
        overflow: auto;
        padding-right: 0.2rem;
    }

    .editor-scroll {
        padding-bottom: 0.2rem;
    }
}

@media (max-width: 1280px) {
    .dashboard-grid {
        grid-template-columns: 1fr 1fr;
    }

    .preview-panel {
        grid-column: 1 / -1;
    }

    .preview-scroll {
        display: grid;
        grid-template-columns: minmax(280px, 360px) minmax(0, 1fr);
        gap: 1rem;
        align-items: start;
    }

    .tracker-block {
        margin-top: 0;
    }
}

@media (max-width: 1024px) {
    .app-shell {
        width: min(100% - 1rem, 100%);
    }

    .workspace-switcher {
        display: inline-flex;
    }

    .dashboard-grid {
        grid-template-columns: 1fr;
    }

    [data-workspace-panel] {
        display: none;
    }

    [data-workspace-panel].is-active {
        display: flex;
    }

    .panel {
        max-height: none;
        overflow: visible;
    }

    .preview-scroll {
        display: block;
    }
}

@media (max-width: 900px) {
    .topbar {
        flex-direction: column;
        align-items: stretch;
    }

    .topbar-actions {
        justify-content: flex-start;
    }

    .two-up,
    .three-up,
    .summary-grid,
    .tracker-grid,
    .preview-scroll {
        grid-template-columns: 1fr;
    }

    .uploader,
    .selected-audio,
    .segment-top,
    .panel-head,
    .stack-head,
    .dialog-head,
    .split-head,
    .usage-chart-head {
        flex-direction: column;
        align-items: stretch;
    }

    .segment-time-pair {
        grid-template-columns: 1fr 1fr;
        width: 100%;
    }
}

@media (max-width: 640px) {
    .app-shell {
        width: calc(100% - 0.8rem);
    }

    .panel,
    .topbar,
    .dialog-form {
        padding: 0.95rem;
    }

    .brand-copy h1 {
        font-size: 1.7rem;
    }

    .brand-wrap {
        align-items: flex-start;
    }

    .brand-mark {
        width: 3.5rem;
        height: 3.5rem;
    }

    .segment-time-pair {
        grid-template-columns: 1fr;
    }

    .phone-shell {
        width: min(100%, 276px);
    }

    .phone-shell.landscape {
        width: min(100%, 330px);
    }

    .phone-shell.custom {
        width: min(100%, 320px);
    }

    .usage-chart {
        gap: 0.4rem;
    }

    .toast-stack {
        left: 0.8rem;
        right: 0.8rem;
        width: auto;
    }
}
