@import url('https://fonts.googleapis.com/css2?family=Inter+Tight:wght@200;400&family=Inter:wght@400;500;700&display=swap');

:root {
    color-scheme: dark;
    --color-bg-primary: #000000;
    --color-bg-surface: rgba(255,255,255,0.04);
    --color-text-primary: #FFFFFF;
    --color-text-secondary: #A8A0B8;
    --color-accent: #D2BEFF;
    --color-accent-dim: rgba(210,190,255,0.15);
    --color-accent-border: rgba(210,190,255,0.25);
    --color-border: rgba(255,255,255,0.08);
    --color-muted: #8E80A2;
    --color-disabled: #595164;
    --ease: cubic-bezier(0.16, 1, 0.3, 1);
}

* { margin: 0; padding: 0; box-sizing: border-box; }
[hidden] { display: none !important; }

html, body {
    min-height: 100%;
    height: 100dvh;
}

body {
    background: var(--color-bg-primary);
    color: var(--color-text-primary);
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    font-weight: 400;
    padding: 0;
    overflow: hidden;
}

/* ── Main container ── */
.container {
    width: 100%;
    max-width: 800px;
    margin: 0 auto;
    height: 100dvh;
    padding: 20px 16px 12px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* ── Header ── */
.header {
    margin-bottom: 16px;
    flex-shrink: 0;
}
.header .title {
    font-family: 'Inter Tight', sans-serif;
    font-size: 20px;
    font-weight: 400;
    color: var(--color-text-primary);
    letter-spacing: -0.3px;
}
.header .subtitle {
    font-size: 14px;
    color: var(--color-text-secondary);
    font-weight: 400;
}
.header a {
    color: var(--color-text-secondary) !important;
    font-size: 14px !important;
    text-decoration: none !important;
    margin-top: 4px !important;
    display: inline-block !important;
    transition: color 250ms var(--ease);
}
.header a:hover {
    color: var(--color-accent) !important;
}

/* ── Status bar ── */
.status {
    padding: 10px 14px;
    border: 1px solid var(--color-border);
    border-radius: 10px;
    text-align: center;
    font-size: 14px;
    font-weight: 400;
    margin-bottom: 0;
    background: var(--color-bg-surface);
}
.status.connected {
    border-color: var(--color-accent-border);
    color: var(--color-accent);
}
.status.disconnected {
    border-color: rgba(255,150,150,0.2);
    color: #FF9696;
}

/* ── Watch view ── */
#watchView {
    display: flex;
    flex-direction: column;
    flex: 1 1 0;
    min-height: 0;
}

/* ── Controls row ── */
.watch-controls {
    display: flex;
    align-items: stretch;
    gap: 8px;
    margin-bottom: 12px;
    flex-shrink: 0;
}

.inline-language-select {
    border: 1px solid var(--color-accent-border);
    background: var(--color-bg-surface);
    color: var(--color-accent);
    border-radius: 9999px;
    padding: 8px 14px;
    min-height: 38px;
    font-size: 14px;
    font-family: 'Inter', sans-serif;
    outline: none;
    transition: border-color 250ms var(--ease);
}
.inline-language-select:focus {
    border-color: var(--color-accent);
}

.secondary-btn {
    border: 1px solid var(--color-accent-border);
    background: var(--color-accent-dim);
    color: var(--color-accent);
    border-radius: 9999px;
    padding: 8px 20px;
    font-size: 14px;
    font-weight: 400;
    font-family: 'Inter', sans-serif;
    cursor: pointer;
    transition: all 250ms var(--ease);
    white-space: nowrap;
}
.secondary-btn:hover {
    background: rgba(210,190,255,0.22);
    border-color: var(--color-accent);
}
.secondary-btn:disabled {
    opacity: 0.35;
    cursor: default;
}

/* ── Subtitle area ── */
.subtitle-box {
    border-radius: 14px;
    background: var(--color-bg-surface);
    border: 1px solid var(--color-border);
    display: flex;
    flex-direction: column;
    flex: 1 1 0;
    min-height: 0;
    overflow: hidden;
}
.subtitle-box h2 {
    margin: 0 0 8px 0;
    font-family: 'Inter Tight', sans-serif;
    font-size: 15px;
    color: var(--color-accent);
    font-weight: 400;
}

.subtitle-container {
    width: 100%;
    flex: 1 1 0;
    min-height: 0;
    height: auto;
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    gap: 10px;
    border: var(--subtitle-border-width) var(--subtitle-border-style) var(--color-border);
    border-radius: 14px;
    overflow-y: auto;
    overflow-x: hidden;
    background: transparent;
    padding: 16px;
}

.subtitle-line {
    flex: 0 0 auto;
    font-size: clamp(15px, calc(var(--subtitle-font-size) * 0.45), 26px);
    line-height: clamp(1.3, var(--subtitle-line-height), 1.6);
    color: var(--color-text-primary);
    font-weight: 400;
    text-align: left;
    font-family: var(--subtitle-font-family);
    min-height: 1.3em;
    white-space: normal;
    word-break: break-word;
}

.subtitle-container::-webkit-scrollbar {
    width: 6px;
}
.subtitle-container::-webkit-scrollbar-track {
    background: transparent;
}
.subtitle-container::-webkit-scrollbar-thumb {
    background: rgba(210,190,255,0.2);
    border-radius: 999px;
}
.subtitle-container::-webkit-scrollbar-thumb:hover {
    background: rgba(210,190,255,0.35);
}

/* ── Language selection view ── */
.lang-select-view {
    display: flex;
    flex-direction: column;
    flex: 1 1 0;
    min-height: 0;
    overflow: hidden;
}
.lang-select-view h2 {
    font-family: 'Inter Tight', sans-serif;
    font-size: 20px;
    font-weight: 400;
    margin-bottom: 6px;
    color: var(--color-text-primary);
}
.lang-select-view p {
    color: var(--color-text-secondary);
    font-size: 14px;
    margin-bottom: 16px;
}

.language-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 10px;
    flex: 1 1 0;
    min-height: 0;
    overflow-y: auto;
    overflow-x: hidden;
    padding-right: 8px;
    scrollbar-gutter: stable;
}

.lang-btn {
    width: 100%;
    text-align: left;
    border: 1px solid var(--color-border);
    background: var(--color-bg-surface);
    color: var(--color-text-primary);
    border-radius: 12px;
    padding: 14px 16px;
    font-size: 15px;
    font-weight: 400;
    font-family: 'Inter', sans-serif;
    cursor: pointer;
    transition: all 250ms var(--ease);
}
.lang-btn:hover {
    background: var(--color-accent-dim);
    border-color: var(--color-accent-border);
}
.lang-btn:active {
    transform: scale(0.98);
}
.lang-btn.lang-source {
    border-color: var(--color-accent-border);
    background: var(--color-accent-dim);
    color: var(--color-accent);
}
.lang-btn.lang-source:hover {
    background: rgba(210,190,255,0.22);
}

/* ── Footer ── */
.watch-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 0 0;
    margin-top: auto;
    flex-shrink: 0;
}
.watch-footer__logo svg {
    height: 26px;
    width: auto;
    opacity: 0.65;
}
.watch-footer__sponsor {
    display: flex;
    align-items: center;
    gap: 8px;
}
.watch-footer__sponsor-label {
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    color: var(--color-disabled);
    font-weight: 400;
}
.watch-footer__sponsor-logo {
    height: 22px;
    width: auto;
    opacity: 0.75;
}

/* ── Room list (watch_rooms) ── */
.room-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-top: 20px;
}
.room-card {
    display: block;
    padding: 18px 20px;
    background: var(--color-bg-surface);
    border: 1px solid var(--color-border);
    border-radius: 12px;
    color: var(--color-text-primary);
    text-decoration: none;
    font-family: 'Inter', sans-serif;
    font-size: 18px;
    font-weight: 400;
    transition: all 250ms var(--ease);
}
.room-card:hover {
    background: var(--color-accent-dim);
    border-color: var(--color-accent-border);
}
.empty-message {
    color: var(--color-disabled);
    text-align: center;
    margin-top: 48px;
    font-size: 15px;
}

/* ── Responsive ── */
@media (min-width: 520px) {
    .language-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
    .container {
        padding: 24px 24px 16px;
    }
}

@media (max-width: 400px) {
    .header .title {
        font-size: 17px;
    }
    .subtitle-line {
        font-size: clamp(14px, calc(var(--subtitle-font-size) * 0.4), 22px);
    }
    .watch-footer__sponsor-label {
        font-size: 9px;
    }
}
