@font-face {
    font-family: "Vazirmatn";
    src: url("vendor/fonts/arabic-wght-normal.woff2") format("woff2");
    font-weight: 100 900;
    font-display: swap;
    unicode-range: U+0600-06FF, U+0750-077F, U+0870-088E, U+0890-0891, U+0898-08E1, U+08E3-08FF, U+200C-200E, U+2010-2011, U+204F, U+2E41, U+FB50-FDFF, U+FE70-FEFF, U+1EC71-1ECB4, U+1EE00-1EEBB;
}

@font-face {
    font-family: "Vazirmatn";
    src: url("vendor/fonts/latin-wght-normal.woff2") format("woff2");
    font-weight: 100 900;
    font-display: swap;
    unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+2074, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

:root {
    --bg: #101114;
    --surface: #1b1c20;
    --surface-high: #24262c;
    --surface-higher: #2c2f36;
    --text: #f2f3f7;
    --muted: #b7bbc8;
    --dim: #858b9b;
    --outline: #383c46;
    --primary: #8ab4f8;
    --primary-ink: #082042;
    --primary-soft: rgba(138, 180, 248, 0.16);
    --teal: #80cbc4;
    --amber: #f4c430;
    --danger: #ffb4ab;
    --danger-soft: rgba(255, 180, 171, 0.14);
    --ok: #9bd89f;
    --shadow-1: 0 1px 2px rgba(4, 8, 20, .42), 0 1px 3px rgba(4, 8, 20, .26);
    --shadow-2: 0 10px 28px rgba(4, 8, 20, .34), 0 2px 8px rgba(4, 8, 20, .24);
    --shadow-3: 0 22px 50px rgba(4, 8, 20, .46), 0 8px 22px rgba(4, 8, 20, .28);
    --radius: 10px;
    --radius-sm: 7px;
    --radius-lg: 16px;
    --ease-out: cubic-bezier(0.23, 1, 0.32, 1);
    --ease-in-out: cubic-bezier(0.77, 0, 0.175, 1);
}

* {
    box-sizing: border-box;
}

html,
body {
    margin: 0;
    min-height: 100%;
    background: var(--bg);
    color: var(--text);
    font-family: "Vazirmatn", Tahoma, "Segoe UI", Arial, sans-serif;
}

body {
    min-height: 100dvh;
}

button,
input {
    font: inherit;
}

button {
    border: 0;
    cursor: pointer;
}

button:disabled,
input:disabled {
    cursor: not-allowed;
    opacity: 0.56;
}

button:focus-visible,
.text-input:focus-visible,
.code-input:focus-visible,
.role-card:focus-within {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
}

.app {
    min-height: 100dvh;
    display: grid;
    grid-template-rows: auto 1fr;
    background:
        url("data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' width='140' height='140'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='.8' numOctaves='2' stitchTiles='stitch'/><feColorMatrix type='saturate' values='0'/></filter><rect width='140' height='140' filter='url(%23n)' opacity='.045'/></svg>"),
        radial-gradient(circle at top left, rgba(138, 180, 248, .12), transparent 34rem),
        radial-gradient(circle at bottom right, rgba(128, 203, 196, .08), transparent 30rem),
        var(--bg);
}

.topbar {
    border-bottom: 1px solid rgba(255, 255, 255, .08);
    background: rgba(16, 17, 20, .82);
    backdrop-filter: blur(18px);
}

.topbar-inner {
    width: min(1040px, calc(100% - 32px));
    min-height: 52px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 6px;
}

.brand,
.network-pill,
.status-line,
.control-group,
.participant-name-row,
.request-actions {
    display: flex;
    align-items: center;
}

.brand {
    gap: 6px;
    min-width: 0;
}

.brand-icon {
    width: 32px;
    height: 32px;
    display: inline-grid;
    place-items: center;
    border-radius: 6px;
    color: var(--primary-ink);
    background: var(--primary);
    box-shadow: var(--shadow-1);
    flex: 0 0 auto;
}

.brand h1 {
    margin: 0;
    font-size: 14px;
    line-height: 1.35;
    font-weight: 800;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.network-pill {
    gap: 8px;
    min-height: 28px;
    padding: 4px 8px;
    border: 1px solid rgba(255, 255, 255, .08);
    border-radius: 999px;
    color: var(--muted);
    background: rgba(255, 255, 255, .04);
    font-size: 12px;
    white-space: nowrap;
}

main {
    width: min(1040px, calc(100% - 32px));
    margin: 0 auto;
    padding: 16px 0 24px;
}

.workspace {
    display: grid;
    grid-template-columns: minmax(0, 1.02fr) minmax(330px, .98fr);
    gap: 12px;
    align-items: start;
}

.surface {
    position: relative;
    overflow: hidden;
    border: 1px solid rgba(255, 255, 255, .08);
    border-radius: var(--radius-lg);
    background: color-mix(in srgb, var(--surface) 92%, white 8%);
    box-shadow: var(--shadow-2);
}

.surface-header {
    padding: 12px 14px 8px;
    border-bottom: 1px solid rgba(255, 255, 255, .08);
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 8px;
}

.surface-title {
    margin: 0;
    font-size: 15px;
    line-height: 1.5;
    font-weight: 800;
}

.surface-subtitle {
    margin: 4px 0 0;
    color: var(--muted);
    font-size: 12px;
    line-height: 1.8;
}

.surface-body {
    padding: 10px;
}

.identity-row {
    display: grid;
    grid-template-columns: 1fr 1.5fr;
    gap: 8px;
    align-items: end;
    margin-bottom: 10px;
}

.field {
    display: grid;
    gap: 5px;
    min-width: 0;
}

.field label,
.label {
    color: var(--muted);
    font-size: 12px;
    font-weight: 800;
}

.text-input,
.code-input {
    width: 100%;
    min-width: 0;
    height: 40px;
    border: 1px solid var(--outline);
    border-radius: var(--radius);
    padding: 0 10px;
    color: var(--text);
    background: rgba(255, 255, 255, .05);
    outline: 0;
    transition: border-color .16s ease, background .16s ease, box-shadow .16s ease;
}

.code-input {
    direction: ltr;
    text-align: center;
    font-family: ui-monospace, SFMono-Regular, Consolas, "Liberation Mono", monospace;
    font-weight: 900;
    letter-spacing: .06em;
}

.text-input::placeholder,
.code-input::placeholder {
    color: #6d7484;
}

.text-input:focus,
.code-input:focus {
    border-color: var(--primary);
    background: rgba(138, 180, 248, .08);
    box-shadow: 0 0 0 3px rgba(138, 180, 248, .14);
}

.role-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
}

.role-card {
    position: relative;
    overflow: hidden;
    min-height: 10px;
    display: grid;
    gap: 14px;
    align-content: space-between;
    border: 1px solid rgba(255, 255, 255, .08);
    border-radius: var(--radius);
    padding: 10px;
    background: var(--surface-high);
    box-shadow: var(--shadow-1);
    transition: background .16s ease, box-shadow .16s ease, transform .16s ease;
}

.role-card:hover {
    background: var(--surface-higher);
    box-shadow: var(--shadow-2);
}

.role-card h2 {
    margin: 0;
    font-size: 16px;
    line-height: 1.45;
    font-weight: 900;
}

.role-card p {
    margin: 3px 0 0;
    color: var(--dim);
    font-size: 12px;
    line-height: 1.8;
}

.field-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 8px;
    align-items: end;
}

.btn {
    position: relative;
    overflow: hidden;
    min-height: 36px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 0 10px;
    border-radius: var(--radius);
    font-weight: 900;
    white-space: nowrap;
    color: var(--text);
    background: rgba(255, 255, 255, .08);
    box-shadow: var(--shadow-1);
    transition: transform .14s var(--ease-out), background .16s ease, box-shadow .16s ease, color .16s ease;
    user-select: none;
}

.btn:hover:not(:disabled) {
    background: rgba(255, 255, 255, .12);
    box-shadow: var(--shadow-2);
}

.btn:active:not(:disabled) {
    transform: scale(0.97);
}

.btn-primary {
    color: var(--primary-ink);
    background: var(--primary);
}

.btn-primary:hover:not(:disabled) {
    background: color-mix(in srgb, var(--primary) 86%, white 14%);
}

.btn-secondary {
    color: var(--text);
    background: rgba(255, 255, 255, .09);
    border: 1px solid rgba(255, 255, 255, .08);
}

.btn-danger {
    color: var(--danger);
    background: var(--danger-soft);
    border: 1px solid rgba(255, 180, 171, .26);
}

.btn-accept {
    color: #072713;
    background: var(--ok);
}

.btn-warn {
    color: var(--amber);
    background: rgba(244, 196, 48, .14);
    border: 1px solid rgba(244, 196, 48, .28);
}

.btn-compact {
    min-height: 32px;
    padding: 0 12px;
    font-size: 12px;
}

.btn-icon {
    min-height: 30px;
    height: 30px;
    min-width: 30px;
    width: 30px;
    padding: 0;
    border-radius: 6px;
}

.btn-icon svg {
    width: 14px !important;
    height: 14px !important;
}

.btn svg,
.brand-icon svg,
.network-pill svg,
.status-dot svg,
.empty-state svg {
    width: 18px;
    height: 18px;
    stroke-width: 2.2;
}

.session {
    margin-top: 10px;
    border: 1px solid rgba(255, 255, 255, .08);
    border-radius: var(--radius);
    overflow: hidden;
    background: rgba(255, 255, 255, .04);
}

.session-top {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 10px;
    align-items: center;
    padding: 12px 14px;
    border-bottom: 1px solid rgba(255, 255, 255, .08);
}

.code-box {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}

.session-actions {
    display: flex;
    gap: 6px;
    flex-shrink: 0;
}

.host-code {
    direction: ltr;
    text-align: right;
    color: var(--primary);
    font-family: ui-monospace, SFMono-Regular, Consolas, "Liberation Mono", monospace;
    font-size: clamp(26px, 6vw, 32px);
    line-height: 1.1;
    font-weight: 950;
    letter-spacing: .1em;
    word-break: break-word;
    font-variant-numeric: tabular-nums;
}

.session-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    justify-content: flex-end;
}

.status-area {
    padding: 8px 10px 10px;
}

.status-line {
    gap: 6px;
    min-height: 24px;
    color: var(--muted);
    font-size: 13px;
    line-height: 1.7;
}

.status-dot {
    width: 28px;
    height: 28px;
    display: inline-grid;
    place-items: center;
    border-radius: 999px;
    color: var(--primary);
    background: var(--primary-soft);
    flex: 0 0 auto;
}

.status-line[data-state="error"] .status-dot {
    color: var(--danger);
    background: var(--danger-soft);
}

.status-line[data-state="success"] .status-dot {
    color: var(--ok);
    background: rgba(155, 216, 159, .14);
}

.ban-wrap {
    margin-top: 10px;
    border: 1px solid rgba(255, 180, 171, .28);
    border-radius: var(--radius);
    overflow: hidden;
    background: rgba(255, 180, 171, .06);
}

.ban-wrap-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 10px;
    border-bottom: 1px solid rgba(255, 180, 171, .18);
    background: rgba(255, 180, 171, .08);
}

.ban-wrap-title {
    font-size: 12px;
    font-weight: 800;
    color: var(--danger);
}

.ban-list {
    display: grid;
    gap: 0;
}

.ban-entry {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 8px 10px;
    border-bottom: 1px solid rgba(255, 180, 171, .10);
    font-size: 13px;
}

.ban-entry:last-child {
    border-bottom: none;
}

.ban-entry-name {
    color: var(--muted);
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.participant-actions {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 6px;
    flex-shrink: 0;
}

.host-controls {
    display: flex;
    gap: 4px;
}

audio {
    display: none !important;
}

.call-panel {
    min-height: 400px;
    display: grid;
    grid-template-rows: auto auto 1fr auto auto;
    grid-template-areas:
        "header"
        "requests"
        "participants"
        "chatlog"
        "controlbar";
}

.call-panel .surface-header {
    grid-area: header;
}

.call-panel .request-list {
    grid-area: requests;
}

.request-list {
    display: grid;
    gap: 6px;
    padding: 10px 12px 0;
}

.request-card {
    position: relative;
    overflow: hidden;
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 8px;
    align-items: center;
    border: 1px solid rgba(138, 180, 248, .22);
    border-radius: var(--radius);
    padding: 10px;
    background: rgba(138, 180, 248, .1);
    box-shadow: var(--shadow-1);
}

.request-name,
.participant-title {
    margin: 0;
    font-size: 14px;
    line-height: 1.45;
    font-weight: 900;
}

.participant-main {
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
}

.participant-main .participant-meta {
    margin: 0;
    flex: 0 0 auto;
}

.request-meta,
.participant-meta {
    margin: 4px 0 0;
    color: var(--muted);
    font-size: 12px;
    line-height: 1.65;
    overflow-wrap: anywhere;
}

.request-actions {
    gap: 8px;
    flex-wrap: wrap;
    justify-content: flex-end;
}

.participants {
    grid-area: participants;
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 12px;
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
}

.participant {
    position: relative;
    overflow: hidden;
    display: grid;
    grid-template-columns: 36px minmax(0, 1fr) auto;
    gap: 8px;
    align-items: center;
    border: 1px solid rgba(255, 255, 255, .08);
    border-radius: var(--radius);
    padding: 12px;
    background: var(--surface-high);
    box-shadow: var(--shadow-1);
}

.avatar {
    width: 36px;
    height: 36px;
    display: grid;
    place-items: center;
    border-radius: var(--radius);
    font-weight: 950;
    flex: 0 0 auto;
}

.participant-name-row {
    gap: 8px;
    min-width: 0;
}

.participant-title {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.participant-meta {
    direction: ltr;
    text-align: right;
}

.voice-indicator {
    width: 60px;
    height: 10px;
    padding: 2px;
    border: 1px solid rgba(255, 255, 255, .12);
    border-radius: 999px;
    background: rgba(255, 255, 255, .08);
    overflow: hidden;
    flex: 0 0 auto;
}

.voice-level {
    width: 100%;
    height: 100%;
    border-radius: inherit;
    background: linear-gradient(90deg, var(--teal), var(--amber));
    transform: scaleX(0);
    transform-origin: left center;
    transition: transform .09s linear;
    will-change: transform;
}

.participant .avatar {
    transition: box-shadow .2s var(--ease-out);
}

.participant.speaking .avatar {
    box-shadow: 0 0 0 2px var(--ok, #81c995), 0 0 14px color-mix(in srgb, var(--ok, #81c995) 45%, transparent);
}

.badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    min-height: 24px;
    padding: 3px 8px;
    border-radius: 999px;
    color: var(--primary);
    background: var(--primary-soft);
    font-size: 12px;
    font-weight: 900;
    white-space: nowrap;
}

.badge.waiting {
    color: var(--amber);
    background: rgba(244, 196, 48, .14);
}

.badge.muted {
    color: var(--danger);
    background: var(--danger-soft);
}

.host-meta {
    color: var(--danger);
    font-weight: 800;
}

.badge svg {
    width: 12px;
    height: 12px;
    stroke-width: 2.5;
}

.empty-state {
    flex: 1;
    min-height: 120px;
    display: grid;
    place-items: center;
    border: 1px dashed rgba(255, 255, 255, .14);
    border-radius: var(--radius);
    color: var(--dim);
    background: rgba(255, 255, 255, .03);
    text-align: center;
    padding: 16px;
}

.empty-state svg {
    width: 38px;
    height: 38px;
    margin-bottom: 10px;
    color: var(--dim);
}

.empty-state p {
    margin: 0;
    font-size: 13px;
    line-height: 1.8;
}

.control-bar {
    grid-area: controlbar;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 10px 12px;
    border-top: 1px solid rgba(255, 255, 255, .08);
    background: rgba(255, 255, 255, .02);
    flex-wrap: wrap;
    min-height: 60px;
}

.control-group {
    gap: 8px;
    flex-wrap: wrap;
}

.chat-log {
    grid-area: chatlog;
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding: 0 12px 8px;
    max-height: 160px;
    overflow-y: auto;
}

.chat-log:empty {
    display: none;
}

.chat-msg {
    padding: 8px 10px;
    border-radius: var(--radius-sm);
    background: var(--surface-high);
    font-size: 12px;
    line-height: 1.7;
    overflow-wrap: anywhere;
    transition: opacity .4s var(--ease-out);
}

.chat-msg.self {
    background: var(--primary-soft);
}

.chat-msg.fade-out {
    opacity: 0;
}

.chat-msg-name {
    color: var(--primary);
    font-weight: 800;
    white-space: nowrap;
}

.chat-msg-name::after {
    content: ": ";
}

.chat-form {
    display: flex;
    gap: 8px;
    flex: 1;
    min-width: 160px;
}

.chat-input {
    flex: 1;
}

.chat-form .btn {
    height: 40px;
    min-height: 40px;
    align-self: center;
}

.toast-region {
    position: fixed;
    z-index: 20;
    inset: auto 16px 16px auto;
    width: min(360px, calc(100% - 32px));
    display: grid;
    gap: 8px;
    pointer-events: none;
}

.toast {
    padding: 10px 12px;
    border-radius: var(--radius);
    color: var(--text);
    background: var(--surface-higher);
    box-shadow: var(--shadow-3);
    line-height: 1.7;
    font-size: 13px;
    pointer-events: auto;
    transition: opacity .28s var(--ease-out), transform .28s var(--ease-out);
}

@starting-style {
    .toast {
        opacity: 0;
        transform: translateY(8px) scale(.98);
    }
}

.ripple-effect {
    position: absolute;
    border-radius: 999px;
    background: rgba(255, 255, 255, .25);
    pointer-events: none;
    transform: scale(0);
    animation: ripple 560ms ease-out;
}

.hidden {
    display: none !important;
}

.spinner {
    display: inline-block;
    width: 18px;
    height: 18px;
    border: 2px solid rgba(255, 255, 255, .2);
    border-top-color: var(--primary);
    border-radius: 999px;
    animation: spin 1s linear infinite;
    flex: 0 0 auto;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

@keyframes ripple {
    to {
        opacity: 0;
        transform: scale(2.8);
    }
}

@keyframes cardIn {
    from {
        opacity: 0;
        transform: translateY(8px) scale(.98);
    }
}

.participant,
.request-card {
    animation: cardIn .26s var(--ease-out) backwards;
}

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

    .participant,
    .request-card,
    .toast {
        animation: none;
    }

    .btn:active:not(:disabled) {
        transform: none;
    }

    .ripple-effect {
        display: none;
    }

    .participant.speaking .avatar {
        box-shadow: 0 0 0 2px var(--ok, #81c995);
    }

    *,
    *::before,
    *::after {
        transition-duration: .08s !important;
    }
}

@media (max-width: 900px) {

    .workspace,
    .role-grid,
    .identity-row {
        grid-template-columns: 1fr;
    }

    .call-panel {
        min-height: 430px;
    }
}

@media (max-width: 620px) {

    .topbar-inner,
    main {
        width: min(100% - 20px, 1040px);
    }

    main {
        padding-top: 12px;
    }

    .network-pill {
        display: none;
    }

    .surface-header,
    .surface-body,
    .participants {
        padding-left: 12px;
        padding-right: 12px;
    }

    .session-top,
    .request-card,
    .field-row {
        grid-template-columns: 1fr;
    }

    .participant {
        grid-template-columns: 36px 1fr;
        grid-template-areas:
            "actions actions"
            "avatar main";
        row-gap: 6px;
    }

    .participant .avatar {
        grid-area: avatar;
    }

    .participant-main {
        grid-area: main;
    }

    .participant-actions {
        grid-area: actions;
    }

    .session-actions,
    .request-actions,
    .control-bar,
    .control-group {
        justify-content: stretch;
    }

    .btn {
        width: 100%;
    }

    .chat-form .btn {
        width: auto;
    }

    .host-code {
        font-size: 24px;
    }

    .host-controls {
        justify-content: flex-start;
    }
}
