/* ============================================================
   BoostedAudio —— 客户端外壳
   完全自包含（不依赖任何外部 css 框架）。
   ============================================================ */

*,
*::before,
*::after {
    box-sizing: border-box;
}

:root {
    --bg: #0d1016;
    --surface: #141922;
    --surface-2: #1a202b;
    --surface-3: #212836;
    --line: rgba(255, 255, 255, 0.07);
    --line-strong: rgba(255, 255, 255, 0.12);
    --text: #e8edf6;
    --text-dim: #93a0b6;
    --text-muted: #67738a;
    --accent: #4f8cff;
    --accent-2: #205295;
    --ok: #35d07f;
    --warn: #f5a524;
    --danger: #ff5d6c;
    --radius: 16px;
    --radius-sm: 10px;
    --shadow: 0 18px 48px rgba(0, 0, 0, 0.45);
    --sidebar: 244px;
    /* 原生控件（<select> 弹层、滚动条等）也跟随深色调色板 */
    color-scheme: dark;
}

html,
body {
    height: 100%;
}

body {
    margin: 0;
    font-family: "Inter", "Segoe UI", "PingFang SC", "Microsoft YaHei", system-ui, -apple-system, sans-serif;
    color: var(--text);
    background: var(--bg);
    overflow: hidden;
    -webkit-font-smoothing: antialiased;
}

body::before {
    content: "";
    position: fixed;
    inset: 0;
    background-image: var(--bg-image);
    background-size: cover;
    background-position: center;
    opacity: calc(var(--bg-opacity, 0.8) * 0.55);
    filter: blur(2px);
    z-index: 0;
}

body::after {
    content: "";
    position: fixed;
    inset: 0;
    background:
        radial-gradient(1100px 600px at 12% -10%, rgba(79, 140, 255, 0.16), transparent 60%),
        radial-gradient(900px 500px at 100% 0%, rgba(32, 82, 149, 0.22), transparent 55%),
        linear-gradient(180deg, rgba(13, 16, 22, 0.86), rgba(13, 16, 22, 0.97));
    z-index: 0;
}

.hidden {
    display: none !important;
}

.muted {
    color: var(--text-dim);
}

/* ---------------------------------------------------------------- 滚动条 */

* {
    scrollbar-width: thin;
    scrollbar-color: rgba(255, 255, 255, 0.16) transparent;
}

*::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

*::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.14);
    border-radius: 8px;
}

*::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.22);
}

*::-webkit-scrollbar-track {
    background: transparent;
}

/* ---------------------------------------------------------------- 连接页 */

.connect {
    position: fixed;
    inset: 0;
    z-index: 90;
    display: grid;
    place-items: center;
    backdrop-filter: blur(10px);
    background: rgba(9, 12, 17, 0.72);
    cursor: pointer;
    transition: opacity 0.25s ease;
}

.connect-card {
    width: min(420px, 88vw);
    padding: 34px 30px;
    text-align: center;
    background: linear-gradient(180deg, rgba(26, 32, 43, 0.95), rgba(20, 25, 34, 0.95));
    border: 1px solid var(--line-strong);
    border-radius: 22px;
    box-shadow: var(--shadow);
}

.connect-logo {
    width: 64px;
    height: 64px;
    margin: 0 auto 18px;
    display: grid;
    place-items: center;
    font-size: 28px;
    border-radius: 20px;
    background: linear-gradient(135deg, var(--accent), var(--accent-2));
    box-shadow: 0 12px 30px rgba(79, 140, 255, 0.35);
}

.connect h1 {
    margin: 0 0 8px;
    font-size: 20px;
    font-weight: 650;
    letter-spacing: 0.2px;
}

.connect-hint {
    margin: 0 0 22px;
    font-size: 13px;
    color: var(--text-dim);
    line-height: 1.6;
}

/* ---------------------------------------------------------------- 主框架 */

.app {
    position: relative;
    z-index: 1;
    display: grid;
    grid-template-columns: var(--sidebar) 1fr;
    height: 100vh;
}

.sidebar {
    display: flex;
    flex-direction: column;
    gap: 18px;
    padding: 22px 16px;
    background: rgba(18, 22, 30, 0.72);
    border-right: 1px solid var(--line);
    backdrop-filter: blur(18px);
}

.brand {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 0 6px;
}

.brand-mark {
    width: 30px;
    height: 30px;
    display: grid;
    place-items: center;
    border-radius: 10px;
    font-size: 15px;
    color: #fff;
    background: linear-gradient(135deg, var(--accent), var(--accent-2));
}

.brand-name {
    font-size: 15px;
    font-weight: 650;
    letter-spacing: 0.2px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.nav {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    font: inherit;
    font-size: 13.5px;
    color: var(--text-dim);
    background: transparent;
    border: 0;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: background 0.16s ease, color 0.16s ease;
}

.nav-item svg {
    width: 18px;
    height: 18px;
    flex: none;
}

.nav-item:hover {
    color: var(--text);
    background: rgba(255, 255, 255, 0.05);
}

.nav-item.active {
    color: #fff;
    background: linear-gradient(90deg, rgba(79, 140, 255, 0.24), rgba(79, 140, 255, 0.06));
    box-shadow: inset 0 0 0 1px rgba(79, 140, 255, 0.35);
}

.me {
    margin-top: auto;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid var(--line);
    border-radius: var(--radius);
}

.me-avatar {
    position: relative;
    width: 40px;
    height: 40px;
    flex: none;
}

.me-avatar img {
    width: 40px;
    height: 40px;
    border-radius: 12px;
    object-fit: cover;
    background: var(--surface-3);
}

.halo {
    position: absolute;
    inset: -4px;
    border-radius: 14px;
    box-shadow: 0 0 0 2px var(--ok), 0 0 18px rgba(53, 208, 127, 0.55);
    animation: haloPulse 1.2s ease-in-out infinite;
}

@keyframes haloPulse {
    0%, 100% { opacity: 0.55; }
    50% { opacity: 1; }
}

.me-meta {
    min-width: 0;
    flex: 1;
}

.me-name {
    font-size: 13px;
    font-weight: 600;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
}

.status {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 11.5px;
    color: var(--text-dim);
}

.status .dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--danger);
    box-shadow: 0 0 0 3px rgba(255, 93, 108, 0.16);
}

.status.online .dot {
    background: var(--ok);
    box-shadow: 0 0 0 3px rgba(53, 208, 127, 0.16);
}

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

/* 工作室署名：连接页与侧边栏各一处，点击跳转官网 */
.studio {
    display: inline-block;
    margin-top: 14px;
    padding: 6px 10px;
    font-size: 11.5px;
    color: var(--text-muted);
    text-decoration: none;
    border-radius: 99px;
    transition: color 0.16s ease, background 0.16s ease;
}

.studio:hover {
    color: var(--text);
    background: rgba(255, 255, 255, 0.07);
}

.side-studio {
    margin-top: 10px;
    text-align: center;
}

/* ---------------------------------------------------------------- 按钮与输入框 */

.icon-btn {
    width: 34px;
    height: 34px;
    display: grid;
    place-items: center;
    color: var(--text-dim);
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--line);
    border-radius: 10px;
    cursor: pointer;
    transition: color 0.16s ease, background 0.16s ease, border-color 0.16s ease;
}

.icon-btn svg {
    width: 17px;
    height: 17px;
}

.icon-btn:hover {
    color: #fff;
    background: rgba(255, 255, 255, 0.1);
    border-color: var(--line-strong);
}

.icon-btn.danger {
    color: var(--danger);
}

.icon-btn.active {
    color: #fff;
    background: linear-gradient(135deg, var(--accent), var(--accent-2));
    border-color: transparent;
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 9px 16px;
    font: inherit;
    font-size: 13px;
    font-weight: 600;
    color: var(--text);
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid var(--line);
    border-radius: 10px;
    cursor: pointer;
    transition: background 0.16s ease, border-color 0.16s ease, transform 0.1s ease;
}

.btn:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: var(--line-strong);
}

.btn:active {
    transform: translateY(1px);
}

.btn.primary {
    color: #fff;
    background: linear-gradient(135deg, var(--accent), var(--accent-2));
    border-color: transparent;
    box-shadow: 0 10px 24px rgba(79, 140, 255, 0.3);
}

.btn.primary:hover {
    filter: brightness(1.08);
}

.btn.ghost {
    background: transparent;
}

.btn.small {
    padding: 6px 11px;
    font-size: 12px;
}

.input,
.select {
    width: 100%;
    padding: 10px 12px;
    font: inherit;
    font-size: 13px;
    color: var(--text);
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--line);
    border-radius: 10px;
    outline: none;
    transition: border-color 0.16s ease, background 0.16s ease;
}

.input::placeholder {
    color: var(--text-muted);
}

.input:focus,
.select:focus {
    border-color: rgba(79, 140, 255, 0.55);
    background: rgba(255, 255, 255, 0.07);
}

.select {
    appearance: none;
    cursor: pointer;
    /* 给下面画出的下拉箭头留出位置：appearance: none 之后原生箭头就不见了 */
    padding-right: 32px;
    background-image: url("data:image/svg+xml;charset=utf8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2393a0b6' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 10px center;
    background-size: 13px;
    color-scheme: dark;
}

/*
 * 下拉列表本身是原生控件：不显式指定颜色时，选项会用系统调色板绘制，
 * 在深色面板上文字就看不清了（麦克风选择框就是明显的一例）。
 * chrome / edge / firefox 都认这两个属性。
 */
.select option,
.select optgroup {
    color: var(--text);
    background-color: var(--surface-2);
}

.select option:checked,
.select option:hover {
    color: #fff;
    background-color: var(--accent-2);
}

.range {
    -webkit-appearance: none;
    appearance: none;
    width: 100%;
    height: 4px;
    border-radius: 99px;
    background: rgba(255, 255, 255, 0.14);
    outline: none;
    cursor: pointer;
}

.range::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: var(--accent);
    border: 2px solid #0d1016;
    box-shadow: 0 0 0 3px rgba(79, 140, 255, 0.22);
    transition: transform 0.12s ease;
}

.range::-webkit-slider-thumb:hover {
    transform: scale(1.15);
}

.range::-moz-range-thumb {
    width: 14px;
    height: 14px;
    border: 2px solid #0d1016;
    border-radius: 50%;
    background: var(--accent);
}

/* ---------------------------------------------------------------- 主区域 / 视图 */

.main {
    display: flex;
    flex-direction: column;
    min-width: 0;
    height: 100vh;
    overflow: hidden;
}

.view {
    display: flex;
    flex-direction: column;
    gap: 18px;
    padding: 26px 30px 30px;
    height: 100%;
    overflow: auto;
}

.view-head {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 18px;
    flex-wrap: wrap;
}

.view-head h2 {
    margin: 0;
    font-size: 19px;
    font-weight: 650;
    letter-spacing: 0.2px;
}

.view-sub {
    margin: 4px 0 0;
    font-size: 12.5px;
    color: var(--text-dim);
}

.head-actions {
    display: flex;
    align-items: center;
    gap: 10px;
}

.search {
    position: relative;
    width: 220px;
}

.search svg {
    position: absolute;
    left: 11px;
    top: 50%;
    width: 15px;
    height: 15px;
    transform: translateY(-50%);
    color: var(--text-muted);
    pointer-events: none;
}

.search .input {
    padding-left: 33px;
}

/* ---------------------------------------------------------------- 对端卡片 */

.banner {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 16px;
    font-size: 13px;
    color: #ffd7db;
    background: rgba(255, 93, 108, 0.12);
    border: 1px solid rgba(255, 93, 108, 0.3);
    border-radius: var(--radius-sm);
}

.peer-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 12px;
    align-content: start;
}

.peer {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 14px;
    background: rgba(255, 255, 255, 0.035);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    transition: border-color 0.16s ease, background 0.16s ease, transform 0.16s ease;
}

.peer:hover {
    background: rgba(255, 255, 255, 0.06);
    border-color: var(--line-strong);
    transform: translateY(-1px);
}

.peer .logo {
    width: 42px;
    height: 42px;
    flex: none;
    border-radius: 12px;
    object-fit: cover;
    background: var(--surface-3);
}

.peer-info {
    min-width: 0;
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 7px;
}

.peer-name {
    font-size: 13px;
    font-weight: 600;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
}

.peer-actions {
    display: flex;
    gap: 4px;
}

.empty {
    display: grid;
    place-items: center;
    gap: 10px;
    padding: 46px 20px;
    text-align: center;
    color: var(--text-muted);
    font-size: 13px;
    border: 1px dashed var(--line-strong);
    border-radius: var(--radius);
}

.empty svg {
    width: 30px;
    height: 30px;
    opacity: 0.6;
}

/* ---------------------------------------------------------------- 弹窗 */

.modal {
    position: fixed;
    inset: 0;
    z-index: 80;
    display: grid;
    place-items: center;
    padding: 24px;
    background: rgba(8, 10, 14, 0.66);
    backdrop-filter: blur(6px);
}

.card {
    width: min(520px, 92vw);
    max-height: 86vh;
    overflow: auto;
    padding: 24px;
    background: linear-gradient(180deg, rgba(27, 33, 45, 0.98), rgba(20, 25, 34, 0.98));
    border: 1px solid var(--line-strong);
    border-radius: 20px;
    box-shadow: var(--shadow);
}

.card-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 20px;
}

.card-title {
    margin: 0;
    font-size: 17px;
    font-weight: 650;
}

.card-sub {
    margin: 4px 0 0;
    font-size: 12.5px;
    color: var(--text-dim);
}

.field {
    margin-bottom: 18px;
}

.field:last-child {
    margin-bottom: 0;
}

.field-label {
    display: block;
    margin-bottom: 8px;
    font-size: 12.5px;
    font-weight: 600;
    color: var(--text-dim);
}

.field-hint {
    margin: 7px 0 0;
    font-size: 11.5px;
    line-height: 1.55;
    color: var(--text-muted);
}

.switch {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    padding: 11px 13px;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid var(--line);
    border-radius: 10px;
}

.switch-label {
    font-size: 13px;
}

.switch input {
    width: 38px;
    height: 22px;
    appearance: none;
    background: rgba(255, 255, 255, 0.16);
    border-radius: 99px;
    position: relative;
    cursor: pointer;
    transition: background 0.18s ease;
    flex: none;
}

.switch input::after {
    content: "";
    position: absolute;
    top: 3px;
    left: 3px;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: #fff;
    transition: transform 0.18s ease;
}

.switch input:checked {
    background: var(--accent);
}

.switch input:checked::after {
    transform: translateX(16px);
}

/* ---------------------------------------------------------------- 提示条 */

.toasts {
    position: fixed;
    right: 22px;
    bottom: 22px;
    z-index: 95;
    display: flex;
    flex-direction: column;
    gap: 10px;
    max-width: 360px;
}

.toast {
    padding: 12px 16px;
    font-size: 12.5px;
    line-height: 1.5;
    color: var(--text);
    background: rgba(27, 33, 45, 0.97);
    border: 1px solid var(--line-strong);
    border-left: 3px solid var(--accent);
    border-radius: 10px;
    box-shadow: var(--shadow);
    animation: toastIn 0.2s ease;
}

.toast.error {
    border-left-color: var(--danger);
}

.toast.ok {
    border-left-color: var(--ok);
}

.toast.invite {
    display: flex;
    flex-direction: column;
    gap: 10px;
    border-left-color: var(--warn);
}

.toast-actions {
    display: flex;
    gap: 8px;
}

@keyframes toastIn {
    from {
        opacity: 0;
        transform: translateY(8px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ---------------------------------------------------------------- 诊断浮层（?debug=1） */

.ba-debug {
    position: fixed;
    right: 16px;
    bottom: 16px;
    z-index: 60;
    max-width: 340px;
    padding: 10px 12px;
    border: 1px solid var(--line-strong);
    border-radius: var(--radius-sm);
    background: rgba(10, 14, 20, 0.9);
    box-shadow: var(--shadow);
    backdrop-filter: blur(8px);
    font-size: 12px;
}

.ba-debug.collapsed .ba-debug-body {
    display: none;
}

.ba-debug-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 6px;
    color: var(--text-dim);
    font-weight: 600;
}

.ba-debug-close {
    border: 0;
    background: transparent;
    color: var(--text-dim);
    font-size: 15px;
    line-height: 1;
    cursor: pointer;
}

.ba-debug-body {
    margin: 0;
    max-height: 40vh;
    overflow: auto;
    font-family: ui-monospace, "Cascadia Code", Consolas, monospace;
    font-size: 11px;
    line-height: 1.5;
    color: var(--text);
    white-space: pre-wrap;
}

/* ---------------------------------------------------------------- 响应式 */

@media (max-width: 860px) {
    .app {
        grid-template-columns: 1fr;
        grid-template-rows: auto 1fr;
    }

    .sidebar {
        flex-direction: row;
        align-items: center;
        gap: 12px;
        padding: 12px 14px;
        border-right: 0;
        border-bottom: 1px solid var(--line);
    }

    .brand-name {
        display: none;
    }

    .nav {
        flex-direction: row;
    }

    .nav-item span {
        display: none;
    }

    .me {
        margin-top: 0;
        margin-left: auto;
        padding: 6px 8px;
    }

    .me-meta {
        display: none;
    }

    /* 窄屏下侧边栏变成顶栏，侧边署名会挤占空间（连接页那一处仍然保留） */
    .side-studio {
        display: none;
    }

    .view {
        padding: 18px;
    }

    .search {
        width: 100%;
    }
}
