:root {
    font-family: -apple-system, BlinkMacSystemFont, "Hiragino Kaku Gothic ProN", "Noto Sans JP", system-ui, sans-serif;
    color: #17243c;
    background: #f4f7fc
}

* {
    box-sizing: border-box
}

body {
    margin: 0
}

button,
input,
textarea,
select {
    font: inherit
}

button {
    cursor: pointer
}

button:disabled {
    opacity: .48;
    cursor: default
}

.hidden {
    display: none !important
}

.wrap {
    max-width: 970px;
    margin: auto;
    padding: 16px 18px
}

.top {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    margin-bottom: 16px
}

.brand {
    color: inherit;
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 850;
    font-size: 22px;
    letter-spacing: -.05em
}

.logo {
    display: grid;
    place-items: center;
    width: 39px;
    height: 39px;
    background: #4c68ed;
    border-radius: 14px;
    color: white;
    box-shadow: 0 5px 15px #4c68ed33
}

.pill {
    font-size: 12px;
    color: #687792;
    background: #e8eef8;
    border-radius: 20px;
    padding: 7px 11px
}

.intro h1 {
    font-size: clamp(24px, 4vw, 32px);
    letter-spacing: -.04em;
    margin: 0 0 2px
}

.intro p {
    color: #77849b;
    margin: 0 0 8px;
    line-height: 1.7
}

.layout {
    display: grid;
    grid-template-columns: 340px minmax(0, 1fr);
    gap: 18px
}

.panel {
    background: #fff;
    border: 1px solid #e7ecf5;
    border-radius: 21px;
    padding: 23px;
    box-shadow: 0 5px 28px #25375908
}

.panel h2 {
    font-size: 18px;
    margin: 0 0 19px
}

.field {
    margin: 0 0 16px
}

.field label {
    display: block;
    font-size: 13px;
    font-weight: 700;
    margin-bottom: 7px;
    color: #3f4d66
}

.field input,
.field select {
    width: 100%;
    border: 1px solid #dfe5ef;
    background: #fbfcff;
    border-radius: 11px;
    padding: 11px 12px;
    outline: 0;
    min-height: 45px
}

.field input:focus,
.field select:focus,
#message:focus {
    border-color: #5676ec;
    box-shadow: 0 0 0 3px #5676ec19
}

.hint {
    font-size: 12px;
    color: #8590a5;
    margin-top: 7px
}

.primary {
    background: #4c67e9;
    color: #fff;
    border: 0;
    border-radius: 12px;
    padding: 12px 16px;
    font-weight: 750;
    min-height: 45px
}

.primary:hover {
    background: #3956df
}

.secondary {
    background: #f1f4fb;
    color: #52617a;
    border: 0;
    border-radius: 11px;
    padding: 10px 13px;
    font-weight: 650
}

.secondary:hover {
    background: #e8edfa
}

.full {
    width: 100%
}

.listheader {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 19px
}

.listheader h2 {
    margin: 0
}

.rooms {
    display: grid;
    gap: 10px
}

.room {
    display: flex;
    gap: 12px;
    align-items: center;
    border: 1px solid #e8edf5;
    border-radius: 14px;
    padding: 9px 14px;
    min-width: 0
}

.roomicon {
    width: 42px;
    height: 42px;
    flex: none;
    border-radius: 13px;
    display: grid;
    place-items: center;
    background: #eef1ff;
    color: #526be5;
    font-size: 21px
}

.roominfo {
    flex: 1;
    min-width: 0
}

.roomtitle {
    font-weight: 750;
    overflow-wrap: anywhere
}

.roommeta {
    font-size: 12px;
    color: #8390a4;
    margin-top: 5px
}

.enter {
    font-size: 13px;
    padding: 9px 12px;
    border: 0;
    border-radius: 10px;
    color: #4761da;
    background: #edf1ff;
    font-weight: 750
}

.enter:disabled {
    color: #9da9c5;
    background: #f0f2f7
}

.room > .secondary {
    font-size: 13px;
    padding: 9px 12px;
    border-radius: 10px;
    font-weight: 750
}

.empty {
    text-align: center;
    color: #8490a5;
    padding: 48px 12px;
    line-height: 1.8
}

.overlay {
    position: fixed;
    inset: 0;
    background: #14203965;
    display: grid;
    place-items: center;
    padding: 18px;
    z-index: 8
}

.dialog {
    width: min(100%, 390px);
    background: white;
    border-radius: 20px;
    padding: 24px;
    box-shadow: 0 22px 80px #09173740
}

.dialog h2 {
    margin: 0 0 18px;
    font-size: 21px
}

.dialogbtns {
    display: flex;
    gap: 9px
}

.dialogbtns>* {
    flex: 1
}

.error {
    color: #d63a52;
    font-size: 13px;
    min-height: 19px;
    margin-top: 10px
}

.chat-shell {
    height: min(760px, calc(100dvh - 60px));
    min-height: 410px;
    display: flex;
    flex-direction: column;
    background: white;
    border: 1px solid #e5eaf5;
    border-radius: 20px;
    box-shadow: 0 8px 35px #1f335314;
    overflow: hidden
}

.chat-top {
    display: flex;
    gap: 12px;
    align-items: center;
    padding: 15px 19px;
    border-bottom: 1px solid #e8edf5
}

.chat-head {
    flex: 1;
    min-width: 0
}

.chat-name {
    font-weight: 800;
    overflow-wrap: anywhere
}

.chat-sub {
    font-size: 12px;
    color: #7d8ba0;
    margin-top: 5px
}

.online {
    display: inline-block;
    width: 8px;
    height: 8px;
    background: #25bd86;
    border-radius: 50%;
    margin-right: 5px
}

.chat-actions {
    display: flex;
    gap: 6px
}

.messages {
    flex: 1;
    overflow-y: auto;
    overscroll-behavior: contain;
    padding: 18px;
    display: flex;
    flex-direction: column;
    gap: 15px;
    background: #f9fbfe
}

.bubble-line {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 5px;
    max-width: 86%
}

.bubble-line.mine {
    align-self: flex-end;
    align-items: flex-end
}

.who {
    color: #77859c;
    font-size: 12px;
    padding: 0 4px
}

.bubble {
    display: inline-block;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
    max-width: 100%;
    background: #fff;
    border: 1px solid #e7edf6;
    border-radius: 14px 14px 14px 4px;
    padding: 10px 13px;
    line-height: 1.65;
    font-size: 14px
}

.mine .bubble {
    background: #4c67e9;
    color: white;
    border-color: #4c67e9;
    border-radius: 14px 14px 4px 14px
}

.msgtime {
    font-size: 10px;
    color: #9aa7b8;
    padding: 0 4px
}

.composing {
    display: flex;
    align-items: flex-end;
    gap: 10px;
    padding: 13px;
    border-top: 1px solid #e7edf5
}

.composing textarea {
    flex: 1;
    border: 1px solid #dfe5ef;
    border-radius: 12px;
    outline: 0;
    resize: none;
    padding: 11px 12px;
    min-height: 44px;
    max-height: 135px;
    line-height: 1.5
}

.composing button {
    flex: none
}

.chat-bottom {
    color: #8995a9;
    font-size: 11px;
    text-align: center;
    padding: 0 10px 11px
}

.toast {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    background: #25334a;
    color: white;
    border-radius: 12px;
    padding: 10px 18px;
    box-shadow: 0 8px 28px #0002;
    z-index: 20;
    font-size: 13px;
    max-width: 90vw
}

.members {
    font-size: 12px;
    color: #8390a4;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 300px;
    margin-top: 4px
}

.sr {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0)
}

footer {
    text-align: center;
    font-size: 12px;
    color: #9ba5b5;
    margin-top: 16px
}

@media(max-width:760px) {
    .wrap {
        padding: 16px 12px
    }

    .top {
        margin-bottom: 21px
    }

    .layout {
        grid-template-columns: 1fr
    }

    .panel {
        padding: 19px
    }

    .chat-wrap {
        padding: 0
    }

    .chat-shell {
        height: 100dvh;
        min-height: 0;
        border: 0;
        border-radius: 0
    }

    .chat-top {
        padding: 12px
    }

    .chat-actions .secondary {
        padding: 9px
    }

    .brand {
        font-size: 19px
    }

    .intro h1 {
        font-size: 26px
    }

    .overlay {
        align-items: center
    }

    .chat-bottom {
        padding-bottom: max(8px, env(safe-area-inset-bottom))
    }

    .messages {
        padding: 12px
    }

    .bubble-line {
        max-width: 91%
    }
}

:root {
    color-scheme: light
}

.theme-toolbar {
    display: flex;
    justify-content: flex-end;
    max-width: 970px;
    margin: 0 auto;
    padding: 10px 18px
}

.theme-toggle {
    border: 1px solid #8794ac;
    padding: 8px 12px;
    border-radius: 20px;
    background: #fff;
    color: #263651;
    font-size: 12px
}

footer {
    padding-bottom: 24px
}

.danger {
    color: #b32443
}

.room {
    flex-wrap: wrap
}

.roominfo {
    flex-basis: 100px
}

.overlay {
    overflow-y: auto
}

.dialog {
    max-height: 100%;
    overflow-y: auto
}

:root[data-theme="dark"] {
    color-scheme: dark;
    color: #e6edf8;
    background: #111827
}

[data-theme="dark"] .panel,
[data-theme="dark"] .dialog,
[data-theme="dark"] .chat-shell {
    background: #1c2638;
    border-color: #35435b
}

[data-theme="dark"] .messages {
    background: #141e2f
}

[data-theme="dark"] .field input,
[data-theme="dark"] .field select,
[data-theme="dark"] textarea {
    background: #141e2f;
    color: #e6edf8;
    border-color: #465573
}

[data-theme="dark"] .field label {
    color: #cbd7ec
}

[data-theme="dark"] .secondary,
[data-theme="dark"] .pill,
[data-theme="dark"] .roomicon,
[data-theme="dark"] .enter,
[data-theme="dark"] .theme-toggle {
    background: #2c3a54;
    color: #d1dcff;
    border-color: #647393
}

[data-theme="dark"] .room,
[data-theme="dark"] .chat-top,
[data-theme="dark"] .composing {
    border-color: #35435b
}

[data-theme="dark"] .bubble {
    background: #26344b;
    border-color: #43516b
}

[data-theme="dark"] .mine .bubble {
    background: #4c67e9;
    border-color: #4c67e9
}

[data-theme="dark"] :is(.hint, .roommeta, .empty, .intro p, .chat-sub, .members, .who, .msgtime, .chat-bottom, footer) {
    color: #aebbd0
}

[data-theme="dark"] .danger,
[data-theme="dark"] .error {
    color: #ff9eaf
}

button:focus-visible {
    outline: 3px solid #7397ff;
    outline-offset: 3px
}

.ad-area {
    width: 100%;
    min-width: 0;
    max-width: 970px;
    margin: 16px auto 0;
    padding: 16px 0 0;
    border-top: 1px solid #dfe5ef;
    clear: both
}

.ad-label {
    text-align: center;
    font-size: 11px;
    color: #77849b;
    margin-bottom: 10px
}

[data-theme="dark"] .ad-area {
    border-color: #35435b
}

[data-theme="dark"] .ad-label {
    color: #aebbd0
}

@media(max-width:760px) {
    .theme-toolbar {
        padding: 8px 12px
    }
}

/* Keep the toolbar, conversation, ad and composer within one viewport. */
body.chatting {
    height: 100vh;
    height: 100dvh;
    display: flex;
    flex-direction: column;
    overflow: hidden
}

.chatting .theme-toolbar {
    width: 100%;
    flex: 0 0 auto
}

.chat-wrap {
    width: 100%;
    max-width: 970px;
    margin: 0 auto;
    padding: 0 18px 12px;
    min-height: 0
}

.chatting .chat-wrap {
    flex: 1;
    display: flex
}

.chatting .chat-shell {
    width: 100%;
    height: auto;
    min-height: 0;
    flex: 1
}

.chat-top,
.composing,
.chat-bottom {
    flex-shrink: 0
}

.messages {
    min-height: 0;
    min-width: 0;
    flex: 1 1 0
}

.messages>* {
    flex-shrink: 0
}

.composing textarea {
    min-width: 0
}

.chat-actions {
    flex-wrap: wrap;
    justify-content: flex-end;
    flex-shrink: 0
}

.chat-name {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap
}

.chat-ad {
    flex: 0 0 auto;
    margin: 0;
    max-width: none;
    padding: 8px 16px 12px
}

.chat-ad .ad-label {
    margin-bottom: 4px;
    font-size: 10px;
    line-height: 12px
}

.chat-ad .adsbygoogle {
    height: 90px
}

@media(max-width:760px) {
    .chat-wrap {
        padding: 0
    }

    .chat-top {
        gap: 8px;
        padding: 10px
    }

    .chat-top .roomicon {
        width: 32px;
        height: 32px
    }

    .chat-actions {
        gap: 4px
    }

    .chat-actions .secondary {
        padding: 8px;
        font-size: 12px
    }

    .chat-ad {
        padding: 6px 12px 10px
    }

    .chat-ad .adsbygoogle {
        height: 50px !important
    }

    .composing {
        padding: 10px;
        gap: 8px
    }
}

@media(max-height:500px) {
    .chat-ad .adsbygoogle {
        height: 50px !important
    }

    .chat-top {
        padding-top: 6px;
        padding-bottom: 6px
    }

    .chat-bottom {
        display: none
    }

    .theme-toolbar {
        padding-top: 4px;
        padding-bottom: 4px
    }
}

.chatting .theme-toolbar {
    display: none
}

.chat-actions .theme-toggle {
    font-weight: 650;
    border: 0;
    border-radius: 11px;
    padding: 10px 13px;
    background: #f1f4fb;
    color: #52617a;
    font-size: inherit
}

[data-theme="dark"] .chat-actions .theme-toggle {
    background: #2c3a54;
    color: #d1dcff
}

@media(max-width:760px) {
    .chat-top {
        flex-wrap: wrap
    }

    .chat-actions {
        width: 100%;
        justify-content: flex-end
    }

    .chat-actions .theme-toggle {
        padding: 8px;
        font-size: 12px
    }
}

.lobby-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    justify-content: flex-end
}

.top {
    flex-wrap: wrap
}

.lobby-actions button {
    font-size: 12px
}

@media(max-width:760px) {
    .rooms-panel {
        grid-row: 1
    }

    .create-panel {
        grid-row: 2
    }
}

.chat-actions .pill {
    align-self: center
}
.trip {
    display: inline-block;
    margin-left: 6px;
    font-family: monospace;
    font-weight: 700;
    color: #3956df;
    user-select: all
}

.who { overflow-wrap: anywhere; max-width: 100% }

[data-theme="dark"] .trip { color: #a8bbff }

.roomcreator { overflow-wrap: anywhere }

.room-pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-wrap: wrap;
    gap: 12px;
    margin-top: 18px;
    font-size: 12px
}


.room-items {
    display: contents
}

.rooms > .room,
.room-items > .room {
    min-height: 94px
}

.room-ad {
    display: block;
    height: 94px;
    overflow: hidden
}

.room-ad-label {
    font-size: 10px;
    line-height: 12px;
    margin-bottom: 2px;
    color: #77849b
}

[data-theme="dark"] .room-ad-label {
    color: #aebbd0
}

.listheader {
    flex-wrap: wrap;
    gap: 10px
}

.room-pagination-top {
    margin-top: 0;
    flex: 1;
    gap: 6px
}

.room-pagination-top .secondary {
    padding: 8px;
    font-size: 12px
}

@media (max-width: 480px) {
    .room-pagination-top {
        order: 1;
        flex-basis: 100%
    }

    .listheader #reload {
        margin-left: auto
    }
}


.admin-dialog { width: min(100%, 520px) }
.admin-dialog h3 { font-size: 15px; margin: 16px 0 8px }
.admin-users { display: grid; gap: 10px; margin: 16px 0 }
.admin-user { display: flex; align-items: center; justify-content: space-between; gap: 12px }
.admin-user-info { min-width: 0; overflow-wrap: anywhere; font-size: 13px }
.admin-user button { flex-shrink: 0; font-size: 12px }
.admin-dialog hr { border: 0; border-top: 1px solid #8794ac55; margin: 20px 0 }

.presence-notice {
    text-align: center;
    color: #77859c;
    font-size: 12px;
    line-height: 1.7;
    overflow-wrap: anywhere;
    padding: 3px 0
}

[data-theme="dark"] .presence-notice { color: #aebbd0 }

.lobby-hints {
    margin-top: 20px;
    line-height: 1.8
}

.lobby-hints ul {
    margin: 0;
    padding-left: 1.5em
}

.presence-mark {
    margin-left: 6px;
    font-size: 13px;
    white-space: nowrap
}
