:root {
    --bg-a: #051017;
    --bg-b: #102433;
    --bg-c: #1f3045;
    --card: rgba(7, 20, 32, 0.72);
    --line: rgba(161, 226, 255, 0.32);
    --text: #eaf8ff;
    --muted: #9bc2d6;
    --accent: #3ac8a2;
    --accent-2: #ffcc66;
    --danger: #ff6b6b;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    min-height: 100vh;
    font-family: "Space Grotesk", sans-serif;
    color: var(--text);
    background: radial-gradient(circle at 20% 0%, #254f6f 0%, transparent 35%),
        radial-gradient(circle at 100% 100%, #1e4d43 0%, transparent 30%),
        linear-gradient(135deg, var(--bg-a), var(--bg-b), var(--bg-c));
    overflow-x: hidden;
}

.bg-orb {
    position: fixed;
    border-radius: 999px;
    filter: blur(80px);
    opacity: 0.35;
    pointer-events: none;
}

.orb-1 {
    width: 340px;
    height: 340px;
    background: #46f4c5;
    top: -70px;
    right: -30px;
}

.orb-2 {
    width: 260px;
    height: 260px;
    background: #ffdb7a;
    left: -80px;
    bottom: 40px;
}

.app-shell {
    width: min(1040px, 92vw);
    margin: 0 auto;
    padding: 3rem 0 3.5rem;
    animation: riseIn 550ms ease;
}

.auth-shell {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 2rem 0;
}

.auth-panel {
    width: min(520px, 92vw);
    text-align: center;
}

.auth-actions {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 0.6rem;
    margin-top: 1rem;
}

.auth-button {
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.hero h1 {
    margin: 0.2rem 0;
    font-size: clamp(2rem, 5vw, 3.4rem);
    line-height: 1.05;
}

.eyebrow {
    margin: 0;
    font-family: "IBM Plex Mono", monospace;
    letter-spacing: 0.1em;
    font-size: 0.82rem;
    color: var(--accent-2);
}

.subtitle {
    margin-top: 0.6rem;
    color: var(--muted);
    max-width: 60ch;
}

.panel {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: 20px;
    backdrop-filter: blur(8px);
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.28);
    margin-top: 1.2rem;
    padding: 1.1rem;
}

.controls-grid {
    display: grid;
    grid-template-columns: minmax(260px, 1.5fr) minmax(180px, 1fr) minmax(250px, 1.3fr) auto;
    gap: 0.9rem;
    align-items: stretch;
}

.controls-grid>* {
    min-width: 0;
}

label {
    display: grid;
    gap: 0.4rem;
    font-size: 0.9rem;
    color: var(--muted);
}

.control-hint {
    font-size: 0.76rem;
    color: var(--muted);
    opacity: 0.95;
    overflow-wrap: anywhere;
}

select:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

input[type="text"] {
    border: 1px solid var(--line);
    background: rgba(0, 0, 0, 0.25);
    color: var(--text);
    border-radius: 10px;
    font-size: 1rem;
    padding: 0.7rem 0.75rem;
}

select {
    width: 100%;
    min-width: 0;
    border: 1px solid var(--line);
    background: rgba(0, 0, 0, 0.25);
    color: var(--text);
    border-radius: 10px;
    font-size: 1rem;
    padding: 0.7rem 0.75rem;
}

input[type="range"] {
    width: 100%;
}

#gainValue {
    font-family: "IBM Plex Mono", monospace;
    font-size: 0.8rem;
    color: var(--accent-2);
}

.toggle {
    align-self: center;
    display: flex;
    align-items: center;
    gap: 0.6rem;
    color: var(--text);
}

.play-control-group {
    display: grid;
    gap: 0.5rem;
    padding: 0.6rem 0.65rem;
    border: 1px solid rgba(161, 226, 255, 0.24);
    border-radius: 12px;
    background: rgba(0, 0, 0, 0.16);
    min-width: 0;
}

.source-control-group {
    display: grid;
    gap: 0.5rem;
    padding: 0.6rem 0.65rem;
    border: 1px solid rgba(161, 226, 255, 0.24);
    border-radius: 12px;
    background: rgba(0, 0, 0, 0.16);
    min-width: 0;
}

.gain-target-group {
    display: grid;
    gap: 0.5rem;
    padding: 0.6rem 0.65rem;
    border: 1px solid rgba(161, 226, 255, 0.24);
    border-radius: 12px;
    background: rgba(0, 0, 0, 0.16);
    min-width: 0;
}

.play-control-group .toggle {
    align-self: auto;
}

.output-device-within-play {
    gap: 0.3rem;
}

.output-device-within-play select {
    width: 100%;
}

.action-button,
.ghost {
    border: 0;
    border-radius: 12px;
    padding: 0.7rem 1rem;
    cursor: pointer;
    font-weight: 600;
    font-family: inherit;
}

.action-button {
    background: linear-gradient(90deg, #3ac8a2, #7bf2d0);
    color: #00332b;
    white-space: nowrap;
    align-self: stretch;
}

.action-button.stop {
    background: linear-gradient(90deg, #ff8f7a, #ff6b6b);
    color: #3a0d12;
}

.ghost {
    background: rgba(255, 255, 255, 0.08);
    color: var(--text);
}

.status {
    margin: 0.8rem 0 0;
    font-family: "IBM Plex Mono", monospace;
    font-size: 0.9rem;
}

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

.status.running {
    color: var(--accent);
}

.status.error {
    color: var(--danger);
}

.hidden {
    display: none;
}

.stream-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.stream-head h2 {
    margin: 0;
}

.transcript-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.9rem;
    margin-top: 0.8rem;
}

h3 {
    font-size: 0.95rem;
    color: var(--accent-2);
    margin-bottom: 0.5rem;
}

.article-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 0.6rem;
}

.article-head h3 {
    margin: 0;
}

.copy-button {
    padding: 0.35rem 0.65rem;
    border-radius: 8px;
    font-size: 0.78rem;
    font-weight: 600;
}

.stream-box {
    min-height: 220px;
    max-height: 44vh;
    overflow-y: auto;
    background: rgba(0, 0, 0, 0.25);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 10px;
    padding: 0.7rem;
    line-height: 1.52;
}

.line {
    padding: 0.35rem 0.4rem;
    border-radius: 8px;
    margin-bottom: 0.4rem;
    background: rgba(255, 255, 255, 0.04);
}

#sourceText .line {
    padding: 0;
    margin-bottom: 0;
    border-radius: 0;
    background: transparent;
}

#translatedText .line {
    padding: 0;
    margin-bottom: 0;
    border-radius: 0;
    background: transparent;
}

.debug-box {
    min-height: 140px;
    max-height: 32vh;
    overflow-y: auto;
    background: rgba(0, 0, 0, 0.42);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 10px;
    padding: 0.55rem;
    font-family: "IBM Plex Mono", monospace;
    font-size: 0.78rem;
    line-height: 1.4;
}

.debug-line {
    color: #c8ecff;
    white-space: pre-wrap;
    word-break: break-word;
    padding: 0.2rem 0;
    border-bottom: 1px dashed rgba(255, 255, 255, 0.09);
}

@keyframes riseIn {
    from {
        opacity: 0;
        transform: translateY(8px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@media (max-width: 860px) {

    .controls-grid,
    .transcript-grid {
        grid-template-columns: 1fr;
    }

    .app-shell {
        padding-top: 2rem;
    }

    .stream-box {
        min-height: 180px;
    }
}

@media (min-width: 861px) and (max-width: 1060px) {
    .controls-grid {
        grid-template-columns: 1fr 1fr;
    }

    .controls-grid .action-button {
        grid-column: 1 / -1;
    }
}