:root {
    --bg: #12141a;
    --panel: #1b1e26;
    --edge: #2b303c;
    --text: #e8eaf0;
    --muted: #8b93a7;
    --accent: #6ea8fe;
    --warn: #ffb457;
    --error: #ff6b6b;

    --measure: 34rem;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto,
        "Hiragino Kaku Gothic ProN", "Noto Sans JP", sans-serif;
    line-height: 1.5;
    /* Subtitles are read at a glance across a room or on a phone held at arm's
       length, so the baseline size is larger than a normal page would use. */
    font-size: 17px;
}

.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip-path: inset(50%);
}

/* ---------- join ---------- */

.join {
    max-width: var(--measure);
    margin: 0 auto;
    padding: 3rem 1rem 4rem;
}

.join h1 {
    margin: 0;
    font-size: 2rem;
    letter-spacing: -0.02em;
}

.tagline {
    margin: 0.25rem 0 2rem;
    color: var(--muted);
}

.join-form {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}

.join-form label {
    margin-top: 1.25rem;
    font-weight: 600;
}

.join-form input,
.join-form select {
    padding: 0.7rem 0.8rem;
    font-size: 1rem;
    font-family: inherit;
    color: var(--text);
    background: var(--panel);
    border: 1px solid var(--edge);
    border-radius: 8px;
}

.join-form input:focus-visible,
.join-form select:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 1px;
}

.hint {
    margin: 0;
    font-size: 0.85rem;
    color: var(--muted);
}

.join-form button {
    margin-top: 2rem;
    padding: 0.8rem;
    font-size: 1rem;
    font-weight: 600;
    font-family: inherit;
    color: #0e1117;
    background: var(--accent);
    border: 0;
    border-radius: 8px;
    cursor: pointer;
}

.error {
    padding: 0.7rem 0.9rem;
    color: var(--error);
    background: rgba(255, 107, 107, 0.1);
    border: 1px solid rgba(255, 107, 107, 0.35);
    border-radius: 8px;
}

/* ---------- room ---------- */

.room {
    display: flex;
    flex-direction: column;
    min-height: 100dvh;
    padding: env(safe-area-inset-top) 0 env(safe-area-inset-bottom);
}

.room-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    align-items: center;
    padding: 0.6rem 1rem;
    background: var(--panel);
    border-bottom: 1px solid var(--edge);
}

.status {
    flex: 1 1 auto;
    min-width: 6rem;
    font-size: 0.85rem;
    color: var(--muted);
}

.status[data-state="connected"] { color: #7ee2a8; }
.status[data-state="reconnecting"],
.status[data-state="waiting"] { color: var(--warn); }
.status[data-state="error"] { color: var(--error); }

.room-bar select,
.room-bar button {
    padding: 0.4rem 0.7rem;
    font-size: 0.85rem;
    font-family: inherit;
    color: var(--text);
    background: transparent;
    border: 1px solid var(--edge);
    border-radius: 6px;
    cursor: pointer;
}

.room-bar .leave {
    color: var(--error);
    border-color: rgba(255, 107, 107, 0.4);
}

.banner {
    margin: 0;
    padding: 0.6rem 1rem;
    color: var(--warn);
    background: rgba(255, 180, 87, 0.12);
    border-bottom: 1px solid rgba(255, 180, 87, 0.3);
}

.subtitles {
    display: flex;
    flex: 1 1 auto;
    flex-direction: column;
    gap: 1rem;
    padding: 1.25rem 1rem;
}

.lane-title {
    margin: 0 0 0.35rem;
    font-size: 0.8rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--muted);
}

/* The other person gets the room. Reading their subtitle is the entire point of
   the app; your own transcript is a correctness check, not the content. */
.lane-remote {
    flex: 1 1 auto;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
}

.lane-remote .line-final {
    font-size: clamp(1.35rem, 4.5vw, 2rem);
    font-weight: 500;
    line-height: 1.35;
}

.lane-local {
    padding-top: 0.75rem;
    border-top: 1px solid var(--edge);
}

.lane-local .line {
    font-size: 0.95rem;
    color: var(--muted);
}

.line {
    margin: 0 0 0.3rem;
    min-height: 1.4em;
}

/* Interim text is provisional and about to be replaced. Rendering it dimmer
   means a listener learns to read the firm line and treat the grey one as a
   preview, rather than watching words appear to change their mind. */
.line-interim {
    color: var(--muted);
    font-style: italic;
}

/* The original, shown while the translation is still in flight. */
.line-final.untranslated {
    color: var(--muted);
}

.line-original {
    font-size: 0.95rem;
    color: var(--muted);
}

/* ---------- latency HUD ---------- */

.hud {
    position: fixed;
    right: 1rem;
    bottom: 1rem;
    padding: 0.75rem 1rem;
    font-size: 0.8rem;
    background: rgba(27, 30, 38, 0.95);
    border: 1px solid var(--edge);
    border-radius: 8px;
}

.hud h2 {
    margin: 0 0 0.5rem;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--muted);
}

.hud dl {
    display: grid;
    grid-template-columns: auto auto;
    gap: 0.15rem 0.75rem;
    margin: 0;
}

.hud dt { color: var(--muted); }
.hud dd { margin: 0; font-variant-numeric: tabular-nums; }

@media (min-width: 40rem) {
    .subtitles {
        padding: 2rem;
    }
}
