:root {
    color-scheme: light;
    --bg: #f6f7f4;
    --panel: #ffffff;
    --panel-strong: #f0f3ef;
    --text: #1f2427;
    --muted: #687178;
    --border: #d8ded8;
    --accent: #d9573f;
    --accent-strong: #b63b28;
    --accent-soft: #ffe4dc;
    --tab-accent: #9b6cf2;
    --tab-accent-strong: #7c4fd8;
    --teal: #17736e;
    --warning: #d69b24;
    --shadow: 0 18px 55px rgba(38, 45, 50, .14);
}

:root[data-theme="dark"] {
    color-scheme: dark;
    --bg: #101315;
    --panel: #171b1d;
    --panel-strong: #202629;
    --text: #eef2ef;
    --muted: #9aa5a0;
    --border: #30383b;
    --accent: #ff7959;
    --accent-strong: #ff9a82;
    --accent-soft: #4a261e;
    --tab-accent: #c4a7ff;
    --tab-accent-strong: #a987f2;
    --teal: #65c7ba;
    --warning: #e5b247;
    --shadow: 0 20px 55px rgba(0, 0, 0, .34);
}

* {
    box-sizing: border-box;
}

html,
body {
    height: 100%;
    overflow: hidden;
}

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    letter-spacing: 0;
}

.login-shell {
    color-scheme: dark;
    --bg: #101315;
    --panel: #171b1d;
    --panel-strong: #202629;
    --text: #eef2ef;
    --muted: #9aa5a0;
    --border: #30383b;
    --accent: #9b6cf2;
    --accent-strong: #c4a7ff;
    --accent-soft: rgba(155, 108, 242, .16);
    --tab-accent: #c4a7ff;
    --tab-accent-strong: #a987f2;
    --teal: #65c7ba;
    --warning: #e5b247;
    --shadow: 0 20px 55px rgba(0, 0, 0, .38);
}

button,
input,
textarea {
    font: inherit;
}

button,
a {
    -webkit-tap-highlight-color: transparent;
}

svg {
    width: 20px;
    height: 20px;
}

.login-page {
    display: grid;
    min-height: 100vh;
    place-items: center;
    padding: 24px;
}

.login-card {
    width: min(420px, 100%);
    padding: 28px;
    background: color-mix(in srgb, var(--panel) 92%, #000);
    border: 1px solid var(--border);
    border-radius: 8px;
    box-shadow: var(--shadow);
}

.login-shell .primary-button {
    background: var(--tab-accent-strong);
    color: #111316;
}

.login-shell .primary-button:hover {
    background: var(--tab-accent);
}

.brand-lockup,
.sidebar-header {
    display: flex;
    align-items: center;
    gap: 2px;
}

.brand-mark {
    position: relative;
    display: inline-block;
    width: 50px;
    height: 54px;
    place-items: center;
    flex: 0 0 auto;
    overflow: visible;
    background: transparent;
    color: var(--panel);
    font-size: 14px;
    font-weight: 800;
}

.brand-mark canvas {
    display: block;
    width: 56px;
    height: 56px;
    margin: -1px 0 0 -1px;
}

.brand-fallback {
    position: absolute;
    inset: 0;
    display: grid;
    place-items: center;
    color: var(--tab-accent);
}

.brand-mark.has-zdog-logo .brand-fallback {
    display: none;
}

.brand-lockup h1,
.sidebar-header h1 {
    margin: 0;
    font-size: 20px;
    line-height: 1.1;
}

.brand-lockup p,
.sidebar-header p {
    margin: 4px 0 0;
    color: var(--muted);
    font-size: 13px;
}

.login-error {
    margin: 22px 0 0;
    padding: 10px 12px;
    border: 1px solid color-mix(in srgb, var(--accent) 36%, transparent);
    border-radius: 8px;
    background: var(--accent-soft);
    color: var(--accent-strong);
    font-size: 14px;
}

.field-label {
    display: grid;
    gap: 8px;
    margin-top: 18px;
    color: var(--muted);
    font-size: 13px;
    font-weight: 700;
}

.field-label input,
.field-label textarea,
.compact-input,
.project-name-input {
    width: 100%;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--panel-strong);
    color: var(--text);
    outline: none;
}

.field-label input,
.compact-input,
.project-name-input {
    min-height: 40px;
    padding: 9px 11px;
}

.field-label textarea {
    min-height: 100px;
    resize: vertical;
    padding: 11px;
}

.field-label input:focus,
.field-label textarea:focus,
.compact-input:focus,
.project-name-input:focus,
.original-text:focus,
.text-surface:focus {
    border-color: var(--teal);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--teal) 20%, transparent);
}

.primary-button,
.secondary-button {
    min-height: 40px;
    border: 0;
    border-radius: 8px;
    padding: 0 14px;
    cursor: pointer;
    font-weight: 800;
}

.primary-button {
    width: 100%;
    margin-top: 22px;
    background: var(--accent);
    color: #fff;
}

.primary-button:hover {
    background: var(--accent-strong);
}

.secondary-button {
    background: var(--panel-strong);
    color: var(--text);
    border: 1px solid var(--border);
}

.app {
    display: grid;
    grid-template-columns: 260px minmax(0, 1fr) 370px;
    height: 100vh;
    min-height: 100vh;
    overflow: hidden;
}

.left-sidebar,
.right-panel,
.center-pane {
    height: 100vh;
    min-height: 0;
}

.left-sidebar {
    display: grid;
    grid-template-rows: auto auto 1fr auto;
    gap: 18px;
    padding: 18px;
    background: var(--panel);
    border-right: 1px solid var(--border);
}

.project-toolbar,
.sidebar-footer,
.center-header,
.right-header,
.dialog-header,
.dialog-actions {
    display: flex;
    align-items: center;
}

.project-toolbar {
    justify-content: space-between;
}

.project-toolbar h2,
.right-header h2,
.dialog-header h2 {
    margin: 0;
    font-size: 15px;
}

.icon-button {
    display: inline-grid;
    width: 38px;
    height: 38px;
    place-items: center;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--panel-strong);
    color: var(--text);
    cursor: pointer;
    text-decoration: none;
}

.icon-button:hover {
    border-color: color-mix(in srgb, var(--teal) 45%, var(--border));
    color: var(--teal);
}

.icon-button svg path,
.icon-button svg circle {
    fill: none;
    stroke: currentColor;
    stroke-linecap: round;
    stroke-linejoin: round;
    stroke-width: 2;
}

.project-list {
    display: grid;
    align-content: start;
    gap: 8px;
    overflow: auto;
    padding-right: 2px;
}

.project-item {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 6px;
    align-items: center;
    min-height: 42px;
    border: 1px solid transparent;
    border-radius: 8px;
    background: transparent;
    color: var(--text);
}

.project-select {
    min-width: 0;
    height: 40px;
    padding: 0 10px;
    border: 0;
    background: transparent;
    color: inherit;
    text-align: left;
    cursor: pointer;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.project-delete {
    width: 32px;
    height: 32px;
    margin-right: 4px;
    opacity: .58;
}

.project-item.is-active {
    border-color: color-mix(in srgb, var(--teal) 46%, var(--border));
    background: color-mix(in srgb, var(--teal) 10%, var(--panel));
}

.sidebar-footer {
    justify-content: space-between;
    gap: 8px;
    padding-top: 12px;
    border-top: 1px solid var(--border);
}

.center-pane {
    position: relative;
    z-index: 1;
    display: grid;
    grid-template-rows: auto auto 1fr;
    min-width: 0;
    overflow: hidden;
    background: var(--bg);
}

.center-header {
    justify-content: space-between;
    gap: 16px;
    padding: 18px 22px 12px;
}

.project-name-input {
    max-width: 560px;
    border-color: transparent;
    background: transparent;
    padding-left: 0;
    font-size: 24px;
    font-weight: 800;
}

.save-status {
    flex: 0 0 auto;
    color: var(--muted);
    font-size: 12px;
    font-weight: 700;
}

.tabs {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 0 22px 14px;
    border-bottom: 1px solid var(--border);
}

.tab-button {
    min-width: 92px;
    height: 36px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--panel);
    color: var(--muted);
    cursor: pointer;
    font-weight: 800;
}

.tab-button.is-active {
    border-color: var(--tab-accent-strong);
    background: var(--tab-accent);
    color: #fff;
}

.project-audio-controls {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    margin-left: auto;
}

.select-all-button,
.generate-project-button,
.download-project-button,
.play-all-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    min-width: 96px;
    height: 36px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--panel);
    color: var(--text);
    cursor: pointer;
    font-weight: 800;
}

.select-all-button {
    min-width: 132px;
    color: var(--tab-accent-strong);
}

.select-all-button:hover:not(:disabled) {
    border-color: var(--tab-accent);
    background: color-mix(in srgb, var(--tab-accent) 12%, var(--panel));
}

.audio-divider {
    color: var(--muted);
    font-weight: 900;
    line-height: 1;
    user-select: none;
}

.generate-project-button:hover:not(:disabled) {
    border-color: var(--tab-accent);
    background: color-mix(in srgb, var(--tab-accent) 14%, var(--panel));
    color: var(--tab-accent-strong);
}

.download-project-button:hover:not(:disabled),
.play-all-button:hover:not(:disabled),
.play-all-button.is-playing {
    border-color: var(--teal);
    background: color-mix(in srgb, var(--teal) 12%, var(--panel));
    color: var(--teal);
}

.select-all-button:disabled,
.generate-project-button:disabled,
.download-project-button:disabled,
.play-all-button:disabled {
    cursor: not-allowed;
    opacity: .48;
}

.download-menu {
    position: relative;
}

.download-menu-list {
    position: absolute;
    z-index: 3;
    top: calc(100% + 6px);
    right: 0;
    min-width: 120px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--panel);
    box-shadow: 0 14px 34px rgba(0, 0, 0, .16);
    padding: 6px;
}

.download-menu-list[hidden] {
    display: none;
}

.download-menu-list a {
    display: flex;
    align-items: center;
    min-height: 34px;
    border-radius: 6px;
    padding: 0 10px;
    color: var(--text);
    font-size: 13px;
    font-weight: 800;
    text-decoration: none;
}

.download-menu-list a:hover {
    background: var(--panel-strong);
}

.generate-project-button svg,
.download-project-button svg,
.play-all-button svg,
.voice-play-button svg {
    width: 18px;
    height: 18px;
}

.generate-project-button svg path,
.download-project-button svg path,
.play-all-button svg path,
.voice-play-button svg path {
    fill: none;
    stroke: currentColor;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.play-all-button svg path,
.voice-play-button svg path {
    fill: currentColor;
    stroke: none;
}

.generate-project-button.is-loading,
.play-all-button.is-loading,
.voice-play-button.is-loading {
    cursor: wait;
    opacity: .7;
}

.generate-project-button.is-loading,
.play-all-button.is-loading {
    border-color: var(--tab-accent);
    background: color-mix(in srgb, var(--tab-accent) 16%, var(--panel));
    color: var(--tab-accent);
}

.voice-play-button.is-loading {
    position: relative;
    border-color: var(--tab-accent);
    color: transparent;
}

.voice-play-button.is-loading::after {
    content: "";
    position: absolute;
    width: 15px;
    height: 15px;
    border: 2px solid color-mix(in srgb, var(--tab-accent) 32%, transparent);
    border-top-color: var(--tab-accent);
    border-radius: 50%;
    animation: spin .8s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

.tab-panels {
    position: relative;
    min-width: 0;
    max-width: 100%;
    min-height: 0;
    overflow: hidden;
    padding: 18px 22px 22px;
}

.tab-panel {
    display: none;
    height: 100%;
}

.tab-panel.is-active {
    display: block;
}

.original-text,
.text-surface {
    width: 100%;
    height: calc(100vh - 154px);
    min-height: 420px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--panel);
    color: var(--text);
    outline: none;
    padding: 22px;
    overflow: auto;
    font-size: 18px;
    line-height: 1.65;
}

.original-text {
    resize: none;
}

.text-surface {
    white-space: pre-wrap;
    user-select: text;
}

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

.assignment-segment {
    border-radius: 4px;
    padding: 1px 3px;
    box-decoration-break: clone;
    -webkit-box-decoration-break: clone;
}

.assignment-segment.assigned {
    background: var(--voice-bg);
    border-bottom: 2px solid var(--voice-color);
}

.assignment-segment.is-selected {
    outline: 2px solid var(--voice-color);
    outline-offset: 2px;
}

.expression-surface .assignment-segment.assigned {
    cursor: pointer;
}

.expression-labels {
    display: inline-flex;
    flex-wrap: wrap;
    gap: 4px;
    margin-left: 6px;
    vertical-align: text-top;
    user-select: none;
}

.expression-label {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 0 3px 0 5px;
    border-radius: 4px;
    background: var(--panel-strong);
    color: var(--muted);
    font-size: .72em;
    font-weight: 800;
    line-height: 1.45;
}

.expression-label.is-editable {
    cursor: pointer;
}

.expression-label.is-editable:hover {
    color: var(--tab-accent-strong);
}

.expression-label.is-tag {
    color: #1f8f5f;
}

.expression-label.is-prompt {
    background: #050505;
    color: #ffffff;
}

.expression-label.is-pause {
    border: 1px solid var(--border);
    background: #ffffff;
    color: #1f2427;
}

.expression-label-remove {
    display: inline-grid;
    width: 15px;
    height: 15px;
    place-items: center;
    border: 0;
    border-radius: 50%;
    background: color-mix(in srgb, var(--muted) 16%, transparent);
    color: currentColor;
    cursor: pointer;
    font-size: 10px;
    font-weight: 900;
    line-height: 1;
    padding: 0;
}

.expression-label-remove:hover {
    background: var(--accent-soft);
    color: var(--accent-strong);
}

.expression-cursor {
    display: inline-block;
    width: 2px;
    height: 1.12em;
    margin: 0 1px;
    background: var(--tab-accent-strong);
    vertical-align: -0.14em;
    animation: cursor-blink 1s steps(2, start) infinite;
}

@keyframes cursor-blink {
    50% {
        opacity: 0;
    }
}

.right-panel {
    position: relative;
    z-index: 2;
    display: grid;
    grid-template-rows: auto 1fr;
    background: var(--panel);
    border-left: 1px solid var(--border);
    min-width: 0;
}

.right-header {
    gap: 12px;
    justify-content: space-between;
    padding: 18px;
    border-bottom: 1px solid var(--border);
}

.right-header h2 {
    flex: 0 0 auto;
}

.right-header .compact-input {
    max-width: 170px;
}

.voice-filter {
    display: grid;
    grid-template-columns: minmax(0, 170px) auto;
    gap: 8px;
    align-items: center;
}

.voice-filter[hidden] {
    display: none;
}

.clear-filter-button {
    width: 34px;
    height: 34px;
}

.right-content {
    min-height: 0;
    overflow: auto;
    padding: 14px;
}

.voice-list {
    display: grid;
    gap: 10px;
}

.panel-empty {
    border: 1px dashed var(--border);
    border-radius: 8px;
    padding: 16px;
    color: var(--muted);
    background: var(--panel-strong);
    font-size: 13px;
    font-weight: 700;
}

.panel-empty p {
    margin: 0 0 12px;
}

.inline-clear-button {
    min-height: 34px;
    padding: 0 12px;
}

.voice-card {
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--panel);
    overflow: hidden;
}

.voice-card-top {
    display: grid;
    grid-template-columns: 64px minmax(0, 1fr) auto;
    gap: 8px;
    align-items: center;
    background: color-mix(in srgb, var(--voice-color) 8%, transparent);
    padding-right: 10px;
}

.voice-card-top:hover {
    background: color-mix(in srgb, var(--voice-color) 14%, transparent);
}

.voice-card-main {
    width: 100%;
    min-height: 64px;
    padding: 12px 12px 12px 0;
    border: 0;
    background: transparent;
    color: var(--text);
    cursor: pointer;
    text-align: left;
}

.voice-play-button {
    width: 36px;
    height: 36px;
    background: color-mix(in srgb, var(--voice-color) 14%, var(--panel));
}

.voice-play-button.is-playing {
    border-color: var(--voice-color);
    color: var(--voice-color);
}

.voice-avatar-drop {
    position: relative;
    display: grid;
    width: 46px;
    height: 46px;
    place-items: center;
    margin-left: 12px;
    border: 2px dashed color-mix(in srgb, var(--voice-color) 60%, var(--border));
    border-radius: 50%;
    background: color-mix(in srgb, var(--voice-color) 18%, var(--panel));
    color: var(--text);
    cursor: copy;
    overflow: hidden;
}

.voice-avatar-drop.has-photo {
    border-style: solid;
}

.voice-avatar-drop.is-dragging {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 28%, transparent);
}

.voice-avatar-content {
    display: grid;
    width: 100%;
    height: 100%;
    place-items: center;
    font-size: 12px;
    font-weight: 900;
}

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

.voice-avatar-remove {
    position: absolute;
    inset: 0;
    display: grid;
    place-items: center;
    border: 0;
    border-radius: 50%;
    background: rgba(0, 0, 0, .58);
    color: #fff;
    cursor: pointer;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity .18s ease, visibility 0s linear .18s;
}

.voice-avatar-remove svg path {
    fill: none;
    stroke: currentColor;
    stroke-linecap: round;
    stroke-linejoin: round;
    stroke-width: 2.4;
}

.voice-avatar-drop.has-photo:hover .voice-avatar-remove {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
    transition-delay: 5s, 5s;
}

.voice-avatar-drop.has-photo.is-delete-visible .voice-avatar-remove {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
    transition-delay: 0s;
}

.voice-name-row {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 8px;
    min-width: 0;
}

.voice-name-row strong {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.native-description {
    flex: 0 0 auto;
    color: var(--muted);
    font-size: 12px;
    font-weight: 800;
}

.voice-description-shell {
    width: calc(100% - 20px);
    margin: 10px;
}

.voice-description-summary,
.voice-description-editor {
    width: 100%;
    padding: 10px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--panel-strong);
    color: var(--text);
    outline: none;
    font-size: 13px;
    line-height: 1.4;
}

.voice-description-summary {
    display: block;
    min-height: 38px;
    cursor: text;
    text-align: left;
    color: var(--muted);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.voice-description-summary:not(:empty) {
    color: var(--text);
}

.voice-description-editor {
    display: block;
    min-height: 72px;
    resize: vertical;
}

.voice-description-editor[hidden],
.voice-description-summary[hidden] {
    display: none;
}

.voice-description-shell.is-open .voice-description-editor {
    border-color: var(--teal);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--teal) 20%, transparent);
}

.voice-tags-shell {
    width: calc(100% - 20px);
    margin: 0 10px 10px;
}

.voice-tags-summary,
.voice-tags-editor {
    width: 100%;
    padding: 7px;
    border: 1px dashed var(--border);
    border-radius: 8px;
    background: transparent;
    color: var(--muted);
    outline: none;
    font-size: 13px;
    line-height: 1.4;
}

.voice-tags-summary {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    min-height: 36px;
    cursor: pointer;
    text-align: left;
}

.voice-tags-editor {
    display: block;
    min-height: 58px;
    resize: vertical;
    background: var(--panel-strong);
    color: var(--text);
    border-style: solid;
}

.voice-tags-editor[hidden],
.voice-tags-summary[hidden] {
    display: none;
}

.voice-tags-shell.is-open .voice-tags-editor {
    border-color: var(--teal);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--teal) 20%, transparent);
}

.tag-chip,
.expression-button {
    display: inline-flex;
    align-items: center;
    min-height: 28px;
    max-width: 100%;
    border-radius: 8px;
    font-size: 12px;
    font-weight: 800;
    overflow-wrap: anywhere;
}

.tag-chip {
    padding: 4px 8px;
    background: var(--panel-strong);
    color: var(--text);
}

.custom-expression-form {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 8px;
    margin-bottom: 12px;
}

.expression-list {
    display: grid;
    gap: 8px;
}

.expression-pause-control {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 72px auto;
    gap: 6px;
    align-items: center;
}

.expression-pause-control.is-active .expression-button {
    border-color: var(--accent);
    background: var(--accent-soft);
}

.expression-button {
    justify-content: space-between;
    width: 100%;
    min-height: 42px;
    border: 1px solid var(--border);
    padding: 8px 10px;
    background: var(--panel);
    color: var(--text);
    cursor: pointer;
    text-align: left;
}

.pause-duration-input {
    width: 72px;
    height: 42px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--panel);
    color: var(--text);
    font: inherit;
    font-size: 13px;
    font-weight: 800;
    text-align: center;
}

.pause-duration-input:focus {
    border-color: var(--tab-accent);
    outline: none;
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--tab-accent) 18%, transparent);
}

.pause-duration-suffix {
    color: var(--muted);
    font-size: 12px;
    font-weight: 900;
}

.expression-button:hover,
.expression-button.is-active {
    border-color: var(--accent);
    background: var(--accent-soft);
}

.expression-group {
    color: var(--muted);
    font-size: 11px;
    text-transform: uppercase;
}

.dialog-backdrop {
    position: fixed;
    inset: 0;
    z-index: 10;
    display: grid;
    place-items: center;
    padding: 20px;
    background: rgba(5, 8, 10, .46);
}

.dialog-backdrop[hidden] {
    display: none;
}

.dialog {
    width: min(520px, 100%);
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--panel);
    color: var(--text);
    box-shadow: var(--shadow);
    padding: 18px;
}

.compact-dialog {
    width: min(440px, 100%);
}

.dialog-header {
    justify-content: space-between;
    gap: 12px;
}

.dialog-copy {
    margin: 16px 0 0;
    color: var(--text);
    line-height: 1.5;
}

.dialog-note {
    min-height: 20px;
    margin: 12px 0 0;
    color: var(--muted);
    font-size: 13px;
}

.dialog-actions {
    justify-content: flex-end;
    gap: 10px;
    margin-top: 18px;
}

.dialog-actions .primary-button {
    width: auto;
    margin-top: 0;
}

@media (max-width: 1100px) {
    .app {
        grid-template-columns: 220px minmax(0, 1fr) 330px;
    }

    .right-header {
        align-items: stretch;
        flex-direction: column;
    }

    .right-header .compact-input {
        max-width: none;
    }

    .voice-filter {
        grid-template-columns: minmax(0, 1fr) auto;
    }
}

@media (max-width: 820px) {
    html,
    body {
        height: auto;
        overflow: auto;
    }

    .app {
        grid-template-columns: 1fr;
        height: auto;
        overflow: visible;
    }

    .left-sidebar,
    .right-panel,
    .center-pane {
        height: auto;
        min-height: auto;
    }

    .left-sidebar {
        border-right: 0;
        border-bottom: 1px solid var(--border);
    }

    .center-header {
        align-items: flex-start;
        flex-direction: column;
    }

    .tabs {
        overflow-x: auto;
    }

    .tab-button {
        flex: 1 0 110px;
    }

    .project-audio-controls {
        flex: 0 0 auto;
        margin-left: 0;
    }

    .original-text,
    .text-surface {
        height: 58vh;
        min-height: 360px;
        font-size: 16px;
    }

    .right-header {
        align-items: stretch;
        flex-direction: column;
    }

    .right-header .compact-input {
        max-width: none;
    }

    .right-panel {
        border-left: 0;
        border-top: 1px solid var(--border);
    }
}
