:root {
    --blue: #1261d8;
    --blue-dark: #0d4eaf;
    --blue-soft: #eaf2ff;
    --ink: #172033;
    --muted: #687287;
    --line: #dce2eb;
    --surface: #ffffff;
    --panel: #eef1f5;
    font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html, body { width: 100%; height: 100%; margin: 0; overflow: hidden; }
body { background: var(--panel); color: var(--ink); }
button { font: inherit; }
button:focus-visible { outline: 3px solid rgba(18, 97, 216, 0.28); outline-offset: 3px; }

.app-header {
    position: fixed;
    inset: 0 0 auto 0;
    height: 10vh;
    min-height: 68px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 24px;
    padding: 0 clamp(18px, 3vw, 48px);
    background: rgba(255, 255, 255, 0.97);
    border-bottom: 1px solid rgba(23, 32, 51, 0.08);
    box-shadow: 0 3px 18px rgba(24, 43, 77, 0.06);
    z-index: 20;
}

.brand, .header-actions, .local-note { display: flex; align-items: center; }
.brand { gap: 16px; min-width: 0; }
.brand-mark { color: var(--blue); font-size: 21px; font-weight: 800; letter-spacing: 0.11em; }
.brand-divider { width: 1px; height: 28px; background: var(--line); }
.brand-page { color: #4d586d; font-size: 15px; font-weight: 650; white-space: nowrap; }
.header-actions { gap: 20px; }
.local-note { gap: 8px; color: var(--muted); font-size: 12px; }
.local-note svg { width: 17px; height: 17px; fill: #2d8a5c; }
.header-button {
    border: 1px solid #cbd5e3;
    border-radius: 9px;
    padding: 9px 15px;
    color: #344158;
    background: #fff;
    font-weight: 650;
    cursor: pointer;
}
.header-button:hover { border-color: #9eb3d0; background: #f7f9fc; }

.viewer {
    position: fixed;
    top: max(10vh, 68px);
    right: 0;
    bottom: 30vh;
    left: 0;
    overflow: hidden;
    background: linear-gradient(180deg, #0e2c68 0%, #3869a4 48%, #d2e1fc 100%);
}
#renderCanvas { display: block; width: 100%; height: 100%; outline: none; touch-action: none; }
.scene-info {
    position: absolute;
    top: 14px;
    left: clamp(14px, 2vw, 28px);
    display: flex;
    align-items: center;
    gap: 12px;
    width: min(430px, calc(100% - 104px));
    min-height: 58px;
    padding: 10px 16px;
    border: 1px solid rgba(255, 255, 255, 0.55);
    border-radius: 11px;
    background: rgba(255, 255, 255, 0.82);
    box-shadow: 0 8px 26px rgba(10, 32, 70, 0.12);
    backdrop-filter: blur(12px);
    z-index: 4;
}
.scene-info-icon {
    display: grid;
    place-items: center;
    width: 36px;
    height: 36px;
    flex: 0 0 auto;
    border-radius: 50%;
    background: var(--blue-soft);
}
.scene-info-icon svg { width: 20px; fill: var(--blue); }
.scene-info strong, .scene-info span { display: block; }
.scene-info strong { margin-bottom: 2px; font-size: 13px; }
.scene-info span { overflow: hidden; color: var(--muted); font-size: 11px; text-overflow: ellipsis; white-space: nowrap; }

.empty-state, .loading, .drop-overlay {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-direction: column;
}
.empty-state { padding: 80px 20px 20px; text-align: center; z-index: 3; }
.empty-state[hidden], .loading[hidden], .drop-overlay[hidden] { display: none; }
.drop-icon {
    display: grid;
    place-items: center;
    width: 68px;
    height: 68px;
    margin-bottom: 16px;
    border: 1px solid rgba(255,255,255,.55);
    border-radius: 18px;
    background: rgba(255,255,255,.2);
    box-shadow: inset 0 1px 0 rgba(255,255,255,.45);
    backdrop-filter: blur(10px);
}
.drop-icon svg { width: 31px; fill: #fff; }
.empty-state h1 { margin: 0 0 7px; color: #fff; font-size: clamp(24px, 3vw, 36px); letter-spacing: -0.03em; text-shadow: 0 2px 16px rgba(6, 28, 64, .2); }
.empty-state p { margin: 0 0 20px; color: rgba(255,255,255,.86); font-size: 14px; }
.primary-button {
    padding: 11px 20px;
    border: 0;
    border-radius: 9px;
    background: #fff;
    color: var(--blue-dark);
    box-shadow: 0 8px 22px rgba(6, 29, 67, .18);
    font-weight: 750;
    cursor: pointer;
}
.primary-button:hover { transform: translateY(-1px); }
.loading { gap: 13px; color: #fff; background: rgba(12, 39, 83, .32); backdrop-filter: blur(5px); z-index: 8; }
.spinner { width: 34px; height: 34px; border: 3px solid rgba(255,255,255,.3); border-top-color: #fff; border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.drop-overlay { padding: 18px; background: rgba(8, 31, 70, .7); z-index: 10; }
.drop-overlay-card {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    gap: 13px;
    width: 100%;
    height: 100%;
    border: 3px dashed rgba(255,255,255,.72);
    border-radius: 20px;
    color: #fff;
    font-size: 22px;
}
.drop-overlay-card svg { width: 46px; fill: #fff; }
.view-actions { position: absolute; right: 18px; bottom: 18px; z-index: 5; }
.pill-button {
    display: flex;
    align-items: center;
    gap: 8px;
    height: 40px;
    padding: 0 16px 0 12px;
    border: 1px solid rgba(255,255,255,.52);
    border-radius: 20px;
    background: rgba(255,255,255,.82);
    box-shadow: 0 7px 18px rgba(11, 34, 70, .14);
    color: #35445d;
    font-size: 13px;
    font-weight: 650;
    cursor: pointer;
    backdrop-filter: blur(10px);
}
.pill-button:hover:not(:disabled) { background: #fff; }
.pill-button svg { width: 18px; fill: currentColor; }
.pill-button:disabled { opacity: .45; cursor: default; }

.control-panel {
    position: fixed;
    right: 0;
    bottom: 0;
    left: 0;
    height: 30vh;
    min-height: 190px;
    padding: 20px clamp(20px, 4vw, 64px);
    background: #edf0f4;
    border-top: 1px solid rgba(23, 32, 51, .09);
    z-index: 15;
}
.control-content {
    width: min(1120px, 100%);
    height: 100%;
    margin: 0 auto;
    display: grid;
    grid-template-columns: minmax(200px, .8fr) minmax(380px, 1.3fr) minmax(210px, .72fr);
    align-items: center;
    gap: clamp(22px, 4vw, 58px);
}
.eyebrow { color: var(--blue); font-size: 10px; font-weight: 800; letter-spacing: .13em; text-transform: uppercase; }
.control-heading h2 { margin: 5px 0 5px; font-size: clamp(19px, 2vw, 25px); letter-spacing: -.025em; }
.control-heading p { margin: 0; color: var(--muted); font-size: 12px; line-height: 1.45; }
.voice-options { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.voice-card {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 0;
    padding: 13px;
    border: 1px solid #d1d9e5;
    border-radius: 12px;
    color: var(--ink);
    background: rgba(255,255,255,.7);
    text-align: left;
    cursor: pointer;
}
.voice-card:hover { border-color: #aebbd0; background: #fff; }
.voice-card.selected { border-color: var(--blue); background: #fff; box-shadow: 0 0 0 2px rgba(18,97,216,.1); }
.voice-avatar { display: grid; place-items: center; width: 40px; height: 40px; flex: 0 0 auto; border-radius: 50%; color: #fff; background: linear-gradient(145deg, #4b86d8, #174d9f); font-weight: 800; }
.voice-card[data-voice="male"] .voice-avatar { background: linear-gradient(145deg, #65738b, #2c374b); }
.voice-copy { min-width: 0; flex: 1; }
.voice-copy strong, .voice-copy small { display: block; }
.voice-copy strong { font-size: 13px; }
.voice-copy small { margin-top: 3px; color: var(--muted); font-size: 10px; }
.radio-dot { width: 16px; height: 16px; flex: 0 0 auto; border: 1.5px solid #aab5c7; border-radius: 50%; }
.voice-card.selected .radio-dot { border: 5px solid var(--blue); }
.playback-actions { display: flex; align-items: stretch; flex-direction: column; gap: 9px; }
.play-button {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 9px;
    min-height: 46px;
    padding: 10px 18px;
    border: 0;
    border-radius: 10px;
    color: #fff;
    background: var(--blue);
    box-shadow: 0 8px 20px rgba(18, 97, 216, .22);
    font-weight: 750;
    cursor: pointer;
}
.play-button:hover:not(:disabled) { background: var(--blue-dark); }
.play-button:disabled { color: #8b95a8; background: #d8dde5; box-shadow: none; cursor: default; }
.play-button svg { width: 19px; fill: currentColor; }
.stop-icon { display: none; }
.play-button.playing .play-icon { display: none; }
.play-button.playing .stop-icon { display: block; }
.status { min-height: 16px; overflow: hidden; color: var(--muted); font-size: 10px; text-align: center; text-overflow: ellipsis; white-space: nowrap; }
.status.error { color: #b42318; }
.status.success { color: #24734d; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }

@media (max-width: 980px) {
    .local-note { display: none; }
    .control-content { grid-template-columns: 1fr 1.5fr; gap: 20px; }
    .control-heading { display: none; }
}

@media (max-width: 600px) {
    .app-header { height: 68px; padding: 0 14px; }
    .brand { gap: 10px; }
    .brand-divider { height: 22px; }
    .brand-page { font-size: 13px; }
    .header-button { padding: 8px 10px; font-size: 12px; }
    .viewer { top: 68px; bottom: 38vh; }
    .control-panel { height: 38vh; min-height: 240px; padding: 16px; }
    .control-content { grid-template-columns: 1fr; align-content: center; gap: 14px; }
    .voice-card { padding: 10px; }
    .voice-avatar { width: 34px; height: 34px; }
    .scene-info { width: calc(100% - 78px); padding: 8px 11px; }
    .empty-state { padding-top: 72px; }
}
