:root {
    color-scheme: light dark;
    --bg: #111315;
    --panel: #1a1d20;
    --panel2: #22262a;
    --text: #f4f4f4;
    --muted: #a8afb6;
    --border: #343a40;
    --accent: #ececec;
    --accent-text: #111315;
    --danger: #e46b6b;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family:
        Inter,
        system-ui,
        -apple-system,
        BlinkMacSystemFont,
        "Segoe UI",
        sans-serif;
    background: var(--bg);
    color: var(--text);
}

.page {
    width: min(1050px, calc(100% - 32px));
    margin: 0 auto;
    padding: 42px 0 70px;
}

.header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 24px;
    margin-bottom: 40px;
}

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

h1 {
    margin-bottom: 8px;
}

.header p,
.card p,
.muted {
    color: var(--muted);
}

.rooms {
    display: grid;
    grid-template-columns:
        repeat(auto-fit, minmax(240px, 1fr));
    gap: 18px;
}

.card,
.center-card {
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 18px;
}

.card {
    padding: 24px;
}

.center-card {
    width: min(520px, 100%);
    margin: 40px auto;
    padding: 30px;
}

.center-card.wide {
    width: min(760px, 100%);
}

.type {
    display: inline-block;
    margin-bottom: 16px;
    color: var(--muted);
    font-size: 13px;
    text-transform: uppercase;
    letter-spacing: .08em;
}

form {
    display: grid;
    gap: 12px;
}

label {
    margin-top: 6px;
    color: var(--muted);
    font-size: 14px;
}

input {
    width: 100%;
    padding: 14px 15px;
    border: 1px solid var(--border);
    border-radius: 11px;
    background: var(--panel2);
    color: var(--text);
    font-size: 16px;
    outline: none;
}

input:focus {
    border-color: #777f87;
}

button,
.button,
.small-button {
    border: 0;
    border-radius: 11px;
    background: var(--accent);
    color: var(--accent-text);
    padding: 13px 18px;
    font: inherit;
    font-weight: 650;
    cursor: pointer;
    text-decoration: none;
    text-align: center;
}

form button {
    margin-top: 10px;
}

.small-button {
    display: inline-block;
    padding: 10px 14px;
}

.secondary {
    background: var(--panel2);
    color: var(--text);
    border: 1px solid var(--border);
}

.link,
.back {
    color: var(--muted);
    text-decoration: none;
}

.card .link {
    display: block;
    margin-top: 18px;
    font-size: 14px;
}

.back {
    display: block;
    margin-bottom: 28px;
}

.error {
    margin: 16px 0;
    padding: 12px 14px;
    border: 1px solid var(--danger);
    border-radius: 10px;
}

.preview-placeholder {
    min-height: 320px;
    margin: 24px 0;
    border-radius: 16px;
    background: #090a0b;
    display: grid;
    place-items: center;
    text-align: center;
    padding: 25px;
}

.preview-placeholder p {
    color: var(--muted);
    margin: 8px 0 0;
}

.device-row {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
    margin-bottom: 20px;
}

.device-row > div {
    padding: 13px;
    background: var(--panel2);
    border-radius: 10px;
    text-align: center;
}

button:disabled {
    opacity: .45;
    cursor: not-allowed;
}

@media (max-width: 600px) {
    .page {
        width: min(100% - 20px, 1050px);
        padding-top: 20px;
    }

    .header {
        align-items: flex-start;
    }

    .center-card {
        margin: 10px auto;
        padding: 22px;
    }

    .device-row {
        grid-template-columns: 1fr;
    }

    .preview-placeholder {
        min-height: 230px;
    }
}

/* ===== Wideokonferencja ===== */

.meeting-shell {
    width: 100%;
}

.meeting-header {
    height: 54px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
}

.meeting-header .type {
    margin: 0 10px 0 0;
}

.host-badge {
    display: inline-block;
    margin-left: 10px;
    padding: 4px 8px;
    border-radius: 7px;
    background: var(--panel2);
    color: var(--muted);
    font-size: 12px;
}

.meeting-back {
    color: var(--muted);
    text-decoration: none;
}

#jitsi-container {
    width: 100%;
    height: calc(100vh - 145px);
    min-height: 520px;
    overflow: hidden;
    border-radius: 16px;
    background: #000;
}

#jitsi-container iframe {
    display: block;
    width: 100% !important;
    height: 100% !important;
    border: 0;
}

@media (max-width: 600px) {
    .meeting-shell {
        width: calc(100% + 20px);
        margin-left: -10px;
    }

    .meeting-header {
        padding: 0 12px;
    }

    #jitsi-container {
        height: calc(100vh - 75px);
        min-height: 0;
        border-radius: 0;
    }
}

/* ===== AA Meeting layout v2 ===== */

.meeting-shell {
    width: auto;
    margin: 0;
    position: fixed;
    inset: 0;
    display: grid;
    grid-template-rows: 54px 1fr;
    background: #0e1012;
    z-index: 100;
}

.meeting-header {
    height: 54px;
    margin: 0;
    padding: 0 18px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    background: #15181b;
    border-bottom: 1px solid #2b3035;
}

.meeting-title {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
}

.meeting-room-name {
    font-size: 16px;
    font-weight: 650;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.host-badge {
    flex: 0 0 auto;
    margin: 0;
    padding: 4px 8px;
    border-radius: 7px;
    background: #252a2f;
    color: #b8bec4;
    font-size: 12px;
}

.meeting-back {
    flex: 0 0 auto;
    color: #b8bec4;
    text-decoration: none;
    font-size: 14px;
}

#jitsi-container {
    position: relative;
    width: 100%;
    height: 100%;
    min-height: 0;
    overflow: hidden;
    border-radius: 0;
    background: #000;
}

#jitsi-container iframe {
    position: absolute;
    inset: 0;
    display: block;
    width: 100% !important;
    height: 100% !important;
    border: 0 !important;
}

@media (max-width: 600px) {

    .meeting-shell {
        grid-template-rows: 48px 1fr;
    }

    .meeting-header {
        height: 48px;
        padding: 0 12px;
    }

    .meeting-room-name {
        font-size: 15px;
    }

    .host-badge {
        font-size: 11px;
    }
}

/* ===== Custom prejoin ===== */

.prejoin-page {
    min-height: calc(100vh - 100px);
    display: grid;
    place-items: center;
}

.prejoin-card {
    width: min(1000px, 100%);
    display: grid;
    grid-template-columns: 1.45fr 1fr;
    gap: 22px;
}

.prejoin-video {
    position: relative;
    aspect-ratio: 16 / 9;
    overflow: hidden;
    border-radius: 18px;
    background: #050607;
}

.prejoin-video video {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transform: scaleX(-1);
}

.prejoin-name {
    position: absolute;
    left: 14px;
    bottom: 14px;

    padding: 7px 10px;
    border-radius: 8px;

    background: rgba(0, 0, 0, .55);
    color: white;

    font-size: 14px;
}

.camera-off {
    position: absolute;
    inset: 0;

    display: none;
    place-items: center;

    color: var(--muted);
}

.prejoin-panel {
    padding: 28px;

    background: var(--panel);

    border: 1px solid var(--border);
    border-radius: 18px;
}

.device-setting {
    margin: 18px 0;
}

.device-setting label,
.background-section > label {
    display: block;
    margin-bottom: 7px;
}

.device-setting select {
    width: 100%;

    padding: 12px;

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

    background: var(--panel2);
    color: var(--text);
}

.mic-test {
    margin: 20px 0;
}

.mic-label {
    margin-bottom: 8px;
    color: var(--muted);
    font-size: 14px;
}

.mic-meter {
    height: 9px;
    overflow: hidden;

    border-radius: 20px;
    background: #33383d;
}

#micLevel {
    width: 3%;
    height: 100%;
    background: #eee;
    transition: width .08s linear;
}

.background-options {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;

    margin-top: 8px;
}

.background-option {
    padding: 10px;

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

    border: 1px solid var(--border);
}

.background-option.active {
    background: var(--accent);
    color: var(--accent-text);
}

.prejoin-join {
    display: block;
    margin-top: 24px;
}

@media (max-width: 800px) {

    .prejoin-card {
        grid-template-columns: 1fr;
    }

    .prejoin-panel {
        padding: 20px;
    }

    .background-options {
        grid-template-columns: 1fr;
    }
}
