:root {
    --background: #eef3f8;
    --surface: #ffffff;
    --surface-muted: #f8fafc;
    --text: #172033;
    --text-muted: #64748b;
    --border: #d9e2ec;

    --primary: #1d4ed8;
    --primary-hover: #1e40af;

    --success: #16a34a;
    --warning: #d97706;
    --danger: #dc2626;
    --danger-hover: #b91c1c;

    --shadow:
        0 20px 50px rgba(15, 23, 42, 0.12);
}

* {
    box-sizing: border-box;
}

[hidden] {
    display: none !important;
}

html {
    min-height: 100%;
    background: var(--background);
}

body {
    min-height: 100vh;
    margin: 0;

    color: var(--text);
    background:
        radial-gradient(
            circle at top,
            #ffffff 0,
            var(--background) 48%
        );

    font-family:
        Inter,
        ui-sans-serif,
        system-ui,
        -apple-system,
        BlinkMacSystemFont,
        "Segoe UI",
        sans-serif;
}

button,
input,
select {
    font: inherit;
}

button {
    touch-action: manipulation;
}

.page-shell {
    min-height: 100vh;
    display: grid;
    place-items: center;

    padding: 24px;
}

.app-card {
    width: min(100%, 520px);

    padding: 32px;

    background: var(--surface);
    border: 1px solid rgba(217, 226, 236, 0.9);
    border-radius: 22px;

    box-shadow: var(--shadow);
}

.app-header {
    display: flex;
    align-items: center;
    gap: 16px;

    margin-bottom: 28px;
}

.brand-mark {
    width: 54px;
    height: 54px;

    display: grid;
    place-items: center;

    flex: 0 0 auto;

    color: #ffffff;
    background: var(--primary);
    border-radius: 16px;

    font-size: 1.55rem;
    font-weight: 800;
}

h1,
h2,
h3,
p {
    margin-top: 0;
}

h1 {
    margin-bottom: 3px;
    font-size: clamp(1.8rem, 5vw, 2.35rem);
    line-height: 1.1;
}

h2 {
    margin-bottom: 10px;
    font-size: 1.45rem;
}

.subtitle {
    margin-bottom: 0;
    color: var(--text-muted);
}

.form-group {
    margin-bottom: 20px;
}

label,
.field-caption {
    display: block;

    margin-bottom: 7px;

    color: #334155;
    font-size: 0.92rem;
    font-weight: 700;
}

input,
select {
    width: 100%;
    min-height: 48px;

    padding: 11px 13px;

    color: var(--text);
    background: var(--surface);

    border: 1px solid var(--border);
    border-radius: 10px;

    outline: none;
}

input:focus,
select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(29, 78, 216, 0.14);
}

.status {
    display: flex;
    align-items: center;
    gap: 9px;

    min-height: 44px;

    margin: 22px 0;
    padding: 11px 13px;

    background: var(--surface-muted);
    border: 1px solid var(--border);
    border-radius: 10px;

    font-weight: 700;
}

.status-dot {
    width: 10px;
    height: 10px;

    flex: 0 0 auto;

    background: var(--text-muted);
    border-radius: 999px;
}

.status-ready .status-dot {
    background: var(--primary);
}

.status-connecting .status-dot {
    background: var(--warning);
    animation: pulse 1.2s infinite;
}

.status-live .status-dot {
    background: var(--success);
    animation: pulse 1.5s infinite;
}

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

.status-ended .status-dot {
    background: var(--text-muted);
}

.primary-button,
.danger-button {
    width: 100%;
    min-height: 50px;

    padding: 12px 18px;

    color: #ffffff;
    border: 0;
    border-radius: 11px;

    font-weight: 800;
    cursor: pointer;

    transition:
        background 120ms ease,
        transform 120ms ease;
}

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

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

.danger-button {
    margin-top: 22px;
    background: var(--danger);
}

.danger-button:hover {
    background: var(--danger-hover);
}

.primary-button:active,
.danger-button:active {
    transform: translateY(1px);
}

.primary-button:disabled,
.danger-button:disabled {
    cursor: wait;
    opacity: 0.65;
}

.microphone-section {
    margin-top: 24px;
    padding: 18px;

    background: var(--surface-muted);
    border: 1px solid var(--border);
    border-radius: 12px;
}

.section-heading {
    display: flex;
    justify-content: space-between;
    gap: 12px;

    margin-bottom: 10px;

    color: #334155;
    font-size: 0.9rem;
    font-weight: 700;
}

.meter {
    height: 16px;

    overflow: hidden;

    background: #dbe4ee;
    border-radius: 999px;
}

.level {
    width: 0;
    height: 100%;

    background:
        linear-gradient(
            90deg,
            var(--primary),
            #38bdf8,
            var(--success)
        );

    border-radius: inherit;

    transition: width 50ms linear;
}

.live-session {
    margin-top: 24px;
    text-align: center;
}

.live-badge {
    width: max-content;

    display: flex;
    align-items: center;
    gap: 7px;

    margin: 0 auto 18px;
    padding: 6px 12px;

    color: #166534;
    background: #dcfce7;
    border-radius: 999px;

    font-size: 0.82rem;
    font-weight: 900;
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

.live-badge span {
    width: 8px;
    height: 8px;

    background: var(--success);
    border-radius: 999px;

    animation: pulse 1.5s infinite;
}

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

.session-code-card {
    margin: 24px 0;
    padding: 17px;

    background: var(--surface-muted);
    border: 1px solid var(--border);
    border-radius: 12px;
}

.session-code-card strong {
    display: block;

    margin-top: 4px;

    color: var(--primary);
    font-size: clamp(2rem, 10vw, 3.25rem);
    letter-spacing: 0.12em;
}

.qr-code {
    width: min(100%, 280px);
    height: auto;

    display: block;

    margin: 0 auto 17px;

    background: #ffffff;
    border: 12px solid #ffffff;
    border-radius: 14px;

    box-shadow: 0 8px 25px rgba(15, 23, 42, 0.12);
}

.join-instruction {
    margin-bottom: 6px;
    color: var(--text-muted);
}

.join-link {
    display: block;

    overflow-wrap: anywhere;

    color: var(--primary);
    font-weight: 700;
}

.viewer-count {
    display: flex;
    justify-content: space-between;
    align-items: center;

    margin-top: 24px;
    padding: 15px;

    background: var(--surface-muted);
    border: 1px solid var(--border);
    border-radius: 11px;
}

.viewer-count strong {
    font-size: 1.4rem;
}

.error-message {
    margin: 18px 0 0;
    padding: 12px 14px;

    color: #991b1b;
    background: #fee2e2;
    border: 1px solid #fecaca;
    border-radius: 10px;

    font-weight: 700;
}

.coming-soon {
    margin-top: 26px;
    padding: 20px;

    text-align: left;

    background: var(--surface-muted);
    border: 1px solid var(--border);
    border-radius: 12px;
}

.coming-soon h3 {
    margin-bottom: 8px;
}

.coming-soon p {
    margin-bottom: 0;
    color: var(--text-muted);
    line-height: 1.55;
}

.session-code-reference {
    color: var(--text-muted);
    font-family: ui-monospace, monospace;
}

.app-footer {
    margin-top: 30px;

    color: var(--text-muted);
    font-size: 0.78rem;
    text-align: center;
}

@keyframes pulse {
    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0.35;
    }
}

@media (max-width: 580px) {
    .page-shell {
        padding: 12px;
        place-items: start center;
    }

    .app-card {
        margin-top: 12px;
        padding: 23px 19px;
        border-radius: 17px;
    }

    .app-header {
        margin-bottom: 23px;
    }

    .brand-mark {
        width: 48px;
        height: 48px;
        border-radius: 14px;
    }
}

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        scroll-behavior: auto !important;
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}
