:root {
    color-scheme: light;

    --background: #f4f4f6;
    --surface: #ffffff;
    --surface-soft: #f7f7f9;
    --surface-selected: #f0f0f3;

    --text-primary: #101010;
    --text-secondary: #737378;
    --text-tertiary: #9a9aa1;

    --border: #e0e0e5;
    --border-strong: #cfcfd5;

    --success: #168253;
    --warning: #8a6a00;
    --danger: #c3261f;

    --black: #101010;
    --white: #ffffff;

    --radius-small: 12px;
    --radius-medium: 16px;
    --radius-large: 22px;

    --topbar-height: 70px;

    font-family:
        -apple-system,
        BlinkMacSystemFont,
        "Segoe UI",
        Roboto,
        Helvetica,
        Arial,
        sans-serif;
}


* {
    box-sizing: border-box;
}


html {
    width: 100%;
    min-height: 100%;

    margin: 0;

    background:
        var(--background);

    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
}


body {
    width: 100%;
    min-height: 100vh;
    min-height: 100dvh;

    margin: 0;

    background:
        var(--background);

    color:
        var(--text-primary);

    font-size: 16px;

    -webkit-font-smoothing:
        antialiased;

    overflow-x: hidden;
}


button,
input,
textarea {
    font: inherit;
}


button,
a {
    -webkit-tap-highlight-color:
        transparent;
}


button {
    touch-action:
        manipulation;
}


[hidden] {
    display:
        none !important;
}


/* ==================================================
   DASHBOARD TOP BAR
================================================== */

.app-topbar {
    position: fixed;

    z-index: 100;

    top: 0;
    right: 0;
    left: 0;

    min-height:
        calc(
            var(--topbar-height)
            + env(safe-area-inset-top)
        );

    padding-top:
        env(safe-area-inset-top);

    padding-right:
        max(
            12px,
            env(safe-area-inset-right)
        );

    padding-left:
        max(
            14px,
            env(safe-area-inset-left)
        );

    display: flex;

    align-items: center;
    justify-content: space-between;

    gap: 8px;

    background:
        rgba(
            255,
            255,
            255,
            0.96
        );

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

    backdrop-filter:
        blur(18px);

    -webkit-backdrop-filter:
        blur(18px);
}


.topbar-username {
    min-width: 0;

    flex: 1;

    overflow: hidden;

    color:
        var(--text-primary);

    font-size: 15px;
    font-weight: 700;

    text-overflow: ellipsis;

    white-space: nowrap;
}


.topbar-actions {
    display: flex;

    flex-shrink: 0;

    align-items: center;

    gap: 7px;
}


.topbar-button {
    appearance: none;

    min-height: 42px;

    padding:
        0
        12px;

    border: 0;

    border-radius:
        12px;

    cursor: pointer;

    font-size: 12px;
    font-weight: 700;

    white-space: nowrap;
}


.topbar-create-button {
    background:
        var(--black);

    color:
        var(--white);
}


.topbar-destroy-button {
    background:
        #ececef;

    color:
        var(--danger);
}


.topbar-button:disabled {
    cursor: default;

    opacity: 0.38;
}


/* ==================================================
   DASHBOARD
================================================== */

.dashboard-page {
    width: 100%;
    max-width: 720px;

    min-height: 100dvh;

    margin: 0 auto;

    padding-top:
        calc(
            var(--topbar-height)
            + env(safe-area-inset-top)
            + 26px
        );

    padding-right:
        max(
            14px,
            env(safe-area-inset-right)
        );

    padding-bottom:
        max(
            34px,
            env(safe-area-inset-bottom)
        );

    padding-left:
        max(
            14px,
            env(safe-area-inset-left)
        );
}


.dashboard-heading {
    padding:
        0
        4px
        18px;
}


.dashboard-heading h1 {
    margin: 0;

    font-size: 34px;
    line-height: 1;

    letter-spacing:
        -1.4px;
}


.dashboard-heading p {
    margin:
        10px
        0
        0;

    color:
        var(--text-secondary);

    font-size: 14px;
}


.dashboard-loading {
    padding:
        30px
        4px;

    color:
        var(--text-secondary);

    font-size: 14px;
}


/* ==================================================
   ROOM LIST
================================================== */

.room-list {
    display: flex;

    flex-direction: column;

    gap: 8px;
}


.room-list-item {
    display: grid;

    grid-template-columns:
        42px
        minmax(0, 1fr);

    width: 100%;

    min-height: 91px;

    overflow: hidden;

    background:
        var(--surface);

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

    border-radius:
        18px;

    transition:
        background
        120ms ease,
        border-color
        120ms ease;
}


.room-list-item.selected {
    background:
        var(--surface-selected);

    border-color:
        var(--border-strong);
}


.room-selector {
    appearance: none;

    display: flex;

    align-items: center;
    justify-content: center;

    width: 42px;

    padding: 0;

    border: 0;

    background:
        transparent;

    cursor: pointer;
}


.room-selector-circle {
    width: 19px;
    height: 19px;

    border:
        2px solid
        #b7b7bd;

    border-radius:
        50%;

    background:
        transparent;
}


.room-selector[
    aria-pressed="true"
]
.room-selector-circle {
    border:
        6px solid
        var(--black);
}


.room-open-button {
    appearance: none;

    display: block;

    min-width: 0;

    padding:
        14px
        14px
        14px
        2px;

    border: 0;

    background:
        transparent;

    color:
        inherit;

    text-align: left;

    cursor: pointer;
}


.room-item-main {
    min-width: 0;
}


.room-item-title-row {
    display: flex;

    align-items: center;
    justify-content: space-between;

    gap: 12px;
}


.room-item-title {
    min-width: 0;

    overflow: hidden;

    font-size: 16px;
    font-weight: 700;

    text-overflow: ellipsis;

    white-space: nowrap;
}


.room-item-time {
    flex-shrink: 0;

    color:
        var(--text-tertiary);

    font-size: 11px;
}


.room-item-preview-row {
    display: flex;

    align-items: center;
    justify-content: space-between;

    gap: 12px;

    margin-top: 5px;
}


.room-item-preview {
    min-width: 0;

    overflow: hidden;

    color:
        var(--text-secondary);

    font-size: 13px;

    text-overflow: ellipsis;

    white-space: nowrap;
}


.room-item-code {
    flex-shrink: 0;

    color:
        var(--text-tertiary);

    font-family:
        ui-monospace,
        SFMono-Regular,
        Menlo,
        monospace;

    font-size: 9px;
}


.room-item-status {
    display: block;

    margin-top: 7px;

    font-size: 11px;
    font-weight: 650;
}


.room-item-status.status-active {
    color:
        var(--success);
}


.room-item-status.status-waiting,
.room-item-status.status-claimed {
    color:
        var(--warning);
}


/* ==================================================
   EMPTY DASHBOARD
================================================== */

.empty-room-state {
    padding:
        72px
        22px;

    text-align: center;
}


.empty-room-icon {
    display: flex;

    align-items: center;
    justify-content: center;

    width: 54px;
    height: 54px;

    margin:
        0 auto
        20px;

    border-radius:
        50%;

    background:
        var(--surface);

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

    font-size: 27px;
    font-weight: 300;
}


.empty-room-state h2 {
    margin: 0;

    font-size: 19px;
}


.empty-room-state p {
    max-width: 270px;

    margin:
        9px auto
        0;

    color:
        var(--text-secondary);

    font-size: 14px;
    line-height: 1.5;
}


/* ==================================================
   CREATOR ROOM TOPBAR
================================================== */

.room-topbar {
    position: fixed;

    z-index: 100;

    top: 0;
    right: 0;
    left: 0;

    display: grid;

    grid-template-columns:
        1fr
        auto
        1fr;

    align-items: center;

    min-height:
        calc(
            58px
            + env(safe-area-inset-top)
        );

    padding-top:
        env(safe-area-inset-top);

    padding-right:
        max(
            14px,
            env(safe-area-inset-right)
        );

    padding-left:
        max(
            14px,
            env(safe-area-inset-left)
        );

    background:
        rgba(
            255,
            255,
            255,
            0.96
        );

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

    backdrop-filter:
        blur(18px);

    -webkit-backdrop-filter:
        blur(18px);
}


.room-back-button {
    justify-self: start;

    color:
        var(--text-primary);

    font-size: 15px;
    font-weight: 650;

    text-decoration: none;
}


.room-topbar-title {
    font-size: 15px;
}


.room-topbar-spacer {
    justify-self: end;

    width: 40px;
}


/* ==================================================
   CREATOR ROOM PAGE
================================================== */

.room-page {
    width: 100%;
    max-width: 720px;

    min-height: 100dvh;

    margin: 0 auto;

    padding-top:
        calc(
            58px
            + env(safe-area-inset-top)
            + 14px
        );

    padding-right:
        max(
            12px,
            env(safe-area-inset-right)
        );

    padding-bottom:
        max(
            24px,
            env(safe-area-inset-bottom)
        );

    padding-left:
        max(
            12px,
            env(safe-area-inset-left)
        );
}


.room-control-card {
    width: 100%;

    padding: 18px;

    background:
        var(--surface);

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

    border-radius:
        var(--radius-large);
}


.room-control-heading {
    display: flex;

    align-items: center;
    justify-content: space-between;

    gap: 12px;
}


.room-control-heading h1,
.room-error-card h1 {
    margin: 0;

    font-size: 20px;
}


.room-status {
    display: inline-block;

    margin-top: 6px;

    font-size: 13px;
    font-weight: 650;
}


[data-status="ok"] {
    color:
        var(--success);
}


[data-status="loading"] {
    color:
        var(--warning);
}


[data-status="error"] {
    color:
        var(--danger);
}


.room-loading {
    color:
        var(--text-secondary);

    font-size: 14px;
}


.invite-panel,
.approval-panel,
.active-panel {
    margin-top: 20px;

    padding-top: 18px;

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


.room-help-text {
    margin:
        0 0
        16px;

    color:
        var(--text-secondary);

    font-size: 14px;
    line-height: 1.5;
}


.room-secure-text {
    margin-bottom: 0;

    color:
        var(--success);
}


.room-field-label {
    display: block;

    margin-bottom: 7px;

    color:
        var(--text-secondary);

    font-size: 12px;
    font-weight: 600;
}


.room-link-input {
    width: 100%;

    min-height: 48px;

    padding:
        11px
        12px;

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

    border-radius:
        13px;

    outline: 0;

    background:
        var(--surface-soft);

    color:
        var(--text-primary);

    font-family:
        ui-monospace,
        SFMono-Regular,
        Menlo,
        monospace;

    font-size: 12px;

    text-overflow: ellipsis;
}


.room-action-button {
    appearance: none;

    width: 100%;

    min-height: 49px;

    margin-top: 10px;

    border: 0;

    border-radius:
        13px;

    cursor: pointer;

    font-size: 15px;
    font-weight: 700;
}


.room-action-button.primary {
    background:
        var(--black);

    color:
        var(--white);
}


.room-action-button.secondary {
    background:
        #ececef;

    color:
        var(--text-primary);
}


.room-action-button:disabled {
    opacity: 0.45;
}


.room-error-card {
    margin-top: 10px;
}


/* ==================================================
   GUEST PAGE
================================================== */

.page {
    width: 100%;
    max-width: 720px;

    min-height: 100dvh;

    margin: 0 auto;

    padding-top:
        max(
            16px,
            env(safe-area-inset-top)
        );

    padding-right:
        max(
            12px,
            env(safe-area-inset-right)
        );

    padding-bottom:
        max(
            26px,
            env(safe-area-inset-bottom)
        );

    padding-left:
        max(
            12px,
            env(safe-area-inset-left)
        );
}


.header {
    margin:
        26px
        4px;
}


.header h1 {
    margin: 0;

    font-size: 35px;
    line-height: 1;

    letter-spacing:
        -1.5px;
}


.header p {
    margin:
        12px
        0
        0;

    color:
        var(--text-secondary);

    font-size: 15px;
}


.card {
    width: 100%;

    padding: 19px;

    background:
        var(--surface);

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

    border-radius:
        var(--radius-large);
}


.card h2 {
    margin:
        0 0
        18px;

    font-size: 20px;
}


.status-row,
.detail-row {
    display: flex;

    flex-direction: column;

    gap: 4px;

    padding:
        12px
        0;
}


.detail-row {
    border-top:
        1px solid
        var(--border);
}


.label {
    color:
        var(--text-secondary);

    font-size: 14px;
}


.value {
    font-size: 16px;
    font-weight: 650;

    overflow-wrap: anywhere;
}


.notice {
    margin:
        14px
        0
        0;

    color:
        var(--text-secondary);

    font-size: 14px;
    line-height: 1.5;
}


.guest-buy-banner {
    display: flex;

    align-items: center;
    justify-content: center;

    width: 100%;

    min-height: 48px;

    padding:
        10px
        14px;

    background:
        var(--surface);

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

    border-radius:
        14px;

    color:
        var(--text-primary);

    text-align: center;
    text-decoration: none;

    font-size: 13px;
    font-weight: 700;
}


/* ==================================================
   CHAT
================================================== */

.chat-card {
    width: 100%;

    margin-top: 10px;

    overflow: hidden;

    background:
        var(--surface);

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

    border-radius:
        var(--radius-large);
}


.room-chat-card {
    margin-bottom:
        max(
            8px,
            env(safe-area-inset-bottom)
        );
}


.chat-header {
    padding:
        15px
        16px
        13px;

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


.chat-header h2 {
    margin:
        0 0
        3px;

    font-size: 17px;
}


.chat-security {
    font-size: 11px;
    font-weight: 650;
}


.chat-messages {
    display: flex;

    flex-direction: column;

    gap: 8px;

    width: 100%;

    min-height: 300px;

    height:
        min(
            56dvh,
            560px
        );

    padding:
        15px
        11px;

    overflow-y: auto;

    overscroll-behavior:
        contain;

    -webkit-overflow-scrolling:
        touch;

    background:
        #f7f7f9;
}


.chat-message-row {
    display: flex;

    width: 100%;
}


.chat-message-row.own {
    justify-content:
        flex-end;
}


.chat-message-row.peer {
    justify-content:
        flex-start;
}


.chat-message-bubble {
    display: flex;

    flex-direction: column;

    max-width: 82%;

    padding:
        9px
        11px
        6px;

    border-radius:
        17px;
}


.chat-message-row.own
.chat-message-bubble {
    background:
        var(--black);

    color:
        var(--white);

    border-bottom-right-radius:
        5px;
}


.chat-message-row.peer
.chat-message-bubble {
    background:
        var(--surface);

    color:
        var(--text-primary);

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

    border-bottom-left-radius:
        5px;
}


.chat-message-text {
    white-space:
        pre-wrap;

    overflow-wrap:
        anywhere;

    font-size: 15px;

    line-height: 1.4;
}


.chat-message-time {
    align-self:
        flex-end;

    margin-top: 3px;

    font-size: 9px;

    opacity: 0.58;
}


.chat-composer {
    position: sticky;

    bottom: 0;

    display: grid;

    grid-template-columns:
        minmax(0, 1fr)
        auto;

    align-items:
        end;

    gap: 7px;

    padding-top: 9px;

    padding-right:
        max(
            9px,
            env(safe-area-inset-right)
        );

    padding-bottom:
        max(
            9px,
            env(safe-area-inset-bottom)
        );

    padding-left:
        max(
            9px,
            env(safe-area-inset-left)
        );

    background:
        var(--surface);

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


.chat-input {
    width: 100%;

    min-height: 46px;
    max-height: 120px;

    resize: none;

    padding:
        11px
        13px;

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

    border-radius:
        16px;

    outline: 0;

    background:
        var(--surface-soft);

    color:
        var(--text-primary);

    font-size: 16px;
    line-height: 1.4;
}


.chat-input:focus {
    border-color:
        #9999a0;
}


.chat-input::placeholder {
    color:
        #99999f;
}


.chat-send-button {
    appearance: none;

    min-width: 65px;
    min-height: 46px;

    padding:
        0
        13px;

    border: 0;

    border-radius:
        15px;

    background:
        var(--black);

    color:
        var(--white);

    cursor: pointer;

    font-size: 14px;
    font-weight: 700;
}


.chat-send-button:disabled {
    opacity: 0.45;
}


/* ==================================================
   SMALL PHONES
================================================== */

@media (
    max-width: 360px
) {

    .topbar-button {
        padding:
            0
            8px;

        font-size: 11px;
    }


    .topbar-username {
        font-size: 13px;
    }


    .dashboard-page {
        padding-right: 10px;
        padding-left: 10px;
    }


    .room-item-code {
        display: none;
    }


    .chat-message-bubble {
        max-width: 87%;
    }

}


/* ==================================================
   TABLET / DESKTOP
================================================== */

@media (
    min-width: 700px
) {

    .app-topbar {
        right: 50%;

        left: 50%;

        width: 760px;

        max-width: 100%;

        transform:
            translateX(-50%);

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

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


    .dashboard-page {
        max-width: 760px;

        padding-right: 20px;
        padding-left: 20px;
    }


    .room-page,
    .page {
        max-width: 760px;
    }


    .room-list-item {
        min-height: 96px;
    }


    .chat-message-bubble {
        max-width: 70%;
    }


    .chat-messages {
        height: 520px;
    }


    .status-row,
    .detail-row {
        flex-direction: row;

        align-items: center;
        justify-content: space-between;

        gap: 20px;
    }

}


/* ==================================================
   REDUCED MOTION
================================================== */

@media (
    prefers-reduced-motion: reduce
) {

    *,
    *::before,
    *::after {
        transition:
            none !important;

        scroll-behavior:
            auto !important;
    }

}

/* ==================================================
   LOGIN
================================================== */

.login-page {
    display: flex;

    align-items: center;
    justify-content: center;

    width: 100%;
    min-height: 100vh;
    min-height: 100dvh;

    padding:
        max(
            18px,
            env(safe-area-inset-top)
        )
        max(
            14px,
            env(safe-area-inset-right)
        )
        max(
            18px,
            env(safe-area-inset-bottom)
        )
        max(
            14px,
            env(safe-area-inset-left)
        );
}


.login-card {
    width: 100%;
    max-width: 420px;

    padding: 24px;

    background:
        var(--surface);

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

    border-radius:
        var(--radius-large);
}


.login-brand {
    margin-bottom: 28px;
}


.login-brand h1 {
    margin: 0;

    font-size: 34px;
    line-height: 1;

    letter-spacing: -1.3px;
}


.login-brand p {
    margin:
        10px
        0
        0;

    color:
        var(--text-secondary);

    font-size: 14px;
}


.login-form {
    display: flex;

    flex-direction: column;

    gap: 9px;
}


.login-input {
    width: 100%;

    min-height: 50px;

    margin-bottom: 8px;

    padding:
        0
        14px;

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

    border-radius: 13px;

    outline: none;

    background:
        var(--surface-soft);

    color:
        var(--text-primary);

    font-size: 16px;
}


.login-input:focus {
    border-color: #8c8c93;
}


.login-error {
    margin:
        3px
        0;

    color:
        var(--danger);

    font-size: 13px;
}


.login-note {
    margin:
        18px
        0
        0;

    color:
        var(--text-tertiary);

    text-align: center;

    font-size: 12px;
}