:root {
    --tm-blue: #006eff;
    --tm-blue-hover: #0058d6;
    --tm-blue-light: #e8f1ff;
    --tm-blue-soft: #f2f7ff;
    --tm-text: #1d2129;
    --tm-text-secondary: #4e5969;
    --tm-text-tertiary: #86909c;
    --tm-border: #e5e6eb;
    --tm-bg: #f2f5fa;
    --tm-white: #ffffff;
    --tm-danger: #f53f3f;
    --tm-danger-light: #fff1f0;
    --tm-warning: #d25f00;
    --tm-warning-light: #fff7e8;
    --tile-bg: #16233a;
    --tile-bg-soft: #22344f;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    min-height: 100vh;
    background: linear-gradient(180deg, #e9f2ff 0, #f5f8fd 260px, #f5f8fd 100%);
    color: var(--tm-text);
    font-family: "PingFang SC", "Microsoft YaHei", "Segoe UI", system-ui, sans-serif;
    font-size: 14px;
}

.page {
    max-width: 1200px;
    margin: 0 auto;
    padding: 28px 24px 64px;
}

.header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding-bottom: 20px;
}

.brand {
    display: flex;
    align-items: center;
    gap: 12px;
}

.brand-logo {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border-radius: 10px;
    background: linear-gradient(135deg, #2b8bff, var(--tm-blue));
    color: #fff;
    font-size: 20px;
    font-weight: 600;
    box-shadow: 0 6px 14px rgba(0, 110, 255, 0.28);
}

.brand-text h1 {
    margin: 0;
    font-size: 20px;
    font-weight: 600;
    letter-spacing: 0.5px;
}

.subtitle {
    margin: 2px 0 0;
    color: var(--tm-text-tertiary);
    font-size: 12px;
}

.connection-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 5px 12px;
    border-radius: 999px;
    background: #f2f3f5;
    color: var(--tm-text-tertiary);
    font-size: 12px;
    white-space: nowrap;
}

.connection-badge::before {
    content: "";
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: currentColor;
}

.connection-badge[data-state="connecting"],
.connection-badge[data-state="reconnecting"] {
    background: var(--tm-warning-light);
    color: var(--tm-warning);
}

.connection-badge[data-state="connecting"]::before,
.connection-badge[data-state="reconnecting"]::before {
    animation: blink 1.2s ease-in-out infinite;
}

.connection-badge[data-state="connected"] {
    background: var(--tm-blue-light);
    color: var(--tm-blue);
}

.connection-badge[data-state="error"] {
    background: var(--tm-danger-light);
    color: var(--tm-danger);
}

.panel {
    margin-bottom: 20px;
    padding: 22px 24px;
    border-radius: 12px;
    background: var(--tm-white);
    border: 1px solid var(--tm-border);
    box-shadow: 0 4px 16px rgba(0, 40, 100, 0.06);
}

.join-panel .fields {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 16px 24px;
}

.field {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.field label {
    font-size: 13px;
    color: var(--tm-text-secondary);
}

.field input {
    padding: 10px 12px;
    border-radius: 6px;
    border: 1px solid #d9dee8;
    background: var(--tm-white);
    color: var(--tm-text);
    font-size: 14px;
    outline: none;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.field input::placeholder {
    color: #b6bcc8;
}

.field input:hover {
    border-color: #b7c4d8;
}

.field input:focus {
    border-color: var(--tm-blue);
    box-shadow: 0 0 0 3px rgba(0, 110, 255, 0.12);
}

.actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px;
}

.join-panel .actions {
    margin-top: 20px;
}

button {
    padding: 9px 20px;
    border-radius: 6px;
    border: 1px solid transparent;
    font-size: 14px;
    font-family: inherit;
    cursor: pointer;
    transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

button.primary {
    background: var(--tm-blue);
    color: #fff;
    font-weight: 500;
    box-shadow: 0 4px 12px rgba(0, 110, 255, 0.24);
}

button.primary:hover:not(:disabled) {
    background: var(--tm-blue-hover);
}

button.tool {
    background: var(--tm-white);
    border-color: #d9dee8;
    color: var(--tm-text-secondary);
    padding: 8px 16px;
}

button.tool:hover:not(:disabled) {
    border-color: var(--tm-blue);
    color: var(--tm-blue);
}

button.tool.active {
    background: var(--tm-blue-light);
    border-color: #b3d3ff;
    color: var(--tm-blue);
}

button.tool.danger {
    color: var(--tm-danger);
    border-color: #f7c6c6;
}

button.tool.danger:hover:not(:disabled) {
    background: var(--tm-danger-light);
    border-color: var(--tm-danger);
}

.hint {
    margin: 14px 0 0;
    font-size: 12px;
    color: var(--tm-text-tertiary);
}

.meeting-toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
}

.room-info {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 12px;
    min-width: 0;
}

.room-name {
    font-size: 16px;
    font-weight: 600;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.speaker-indicator {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 5px 12px;
    border-radius: 999px;
    background: #f2f3f5;
    color: var(--tm-text-tertiary);
    font-size: 12px;
    max-width: 100%;
    transition: background 0.2s ease, color 0.2s ease;
}

.speaker-indicator.active {
    background: var(--tm-blue-light);
    color: var(--tm-blue);
}

.speaker-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: currentColor;
    flex: none;
}

.speaker-indicator.active .speaker-dot {
    animation: blink 1s ease-in-out infinite;
}

.status {
    margin: 14px 0 0;
    font-size: 13px;
    color: var(--tm-text-tertiary);
}

.status.error {
    color: var(--tm-danger);
}

.videos {
    display: grid;
    grid-template-columns: repeat(auto-fill, min(100%, 340px));
    gap: 16px;
}

.video-card {
    position: relative;
    overflow: hidden;
    border-radius: 10px;
    aspect-ratio: 16 / 9;
    background: linear-gradient(160deg, var(--tile-bg-soft), var(--tile-bg));
    border: 2px solid transparent;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.video-card.speaking {
    border-color: var(--tm-blue);
    box-shadow: 0 0 0 4px rgba(0, 110, 255, 0.18), 0 10px 24px rgba(0, 40, 100, 0.18);
}

.video-card video {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
    background: transparent;
    transform: scaleX(1);
}

.video-card .avatar {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    display: flex;
    align-items: center;
    justify-content: center;
    width: 68px;
    height: 68px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.12);
    border: 1px solid rgba(255, 255, 255, 0.22);
    color: #eaf2ff;
    font-size: 26px;
    font-weight: 500;
    text-transform: uppercase;
    transition: box-shadow 0.2s ease, background 0.2s ease;
}

.video-card.has-video .avatar {
    display: none;
}

.video-card.speaking .avatar {
    background: rgba(0, 110, 255, 0.4);
    box-shadow: 0 0 0 6px rgba(0, 110, 255, 0.18);
}

.video-name {
    position: absolute;
    left: 12px;
    bottom: 12px;
    max-width: calc(100% - 24px);
    padding: 4px 10px;
    border-radius: 6px;
    background: rgba(10, 20, 36, 0.62);
    color: #f5f8ff;
    font-size: 12px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.speaking-badge {
    position: absolute;
    top: 12px;
    left: 12px;
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 3px 10px;
    border-radius: 999px;
    background: var(--tm-blue);
    color: #fff;
    font-size: 11px;
    opacity: 0;
    transform: translateY(-4px);
    transition: opacity 0.2s ease, transform 0.2s ease;
}

.speaking-badge::before {
    content: "";
    width: 5px;
    height: 5px;
    border-radius: 50%;
    background: #fff;
}

.video-card.speaking .speaking-badge {
    opacity: 1;
    transform: translateY(0);
    animation: badge-pulse 1.4s ease-in-out infinite;
}

.empty-hint {
    margin: 24px 0 0;
    text-align: center;
    font-size: 13px;
    color: var(--tm-text-tertiary);
}

.audios {
    display: none;
}

.toast {
    position: fixed;
    left: 50%;
    bottom: 32px;
    z-index: 100;
    display: flex;
    align-items: center;
    max-width: min(480px, calc(100vw - 32px));
    padding: 12px 18px;
    border-radius: 8px;
    border: 1px solid var(--tm-border);
    border-left: 4px solid var(--tm-blue);
    background: var(--tm-white);
    color: var(--tm-text);
    font-size: 14px;
    line-height: 1.5;
    box-shadow: 0 10px 28px rgba(0, 40, 100, 0.18);
    cursor: pointer;
    opacity: 0;
    transform: translate(-50%, 10px);
    transition: opacity 0.2s ease, transform 0.2s ease;
}

.toast[hidden] {
    display: none;
}

.toast.show {
    opacity: 1;
    transform: translate(-50%, 0);
}

.toast.error {
    border-left-color: var(--tm-danger);
}

.toast.info {
    border-left-color: var(--tm-blue);
}

.toast.success {
    border-left-color: #00b42a;
}

@keyframes blink {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.35;
    }
}

@keyframes badge-pulse {
    0%, 100% {
        box-shadow: 0 0 0 0 rgba(0, 110, 255, 0.35);
    }
    50% {
        box-shadow: 0 0 0 6px rgba(0, 110, 255, 0);
    }
}

@media (max-width: 640px) {
    .page {
        padding: 20px 16px 48px;
    }

    .join-panel .fields {
        grid-template-columns: 1fr;
    }

    .panel {
        padding: 18px;
    }

    .meeting-toolbar {
        flex-direction: column;
        align-items: flex-start;
    }

    .videos {
        grid-template-columns: repeat(auto-fill, min(100%, 340px));
    }

    .toast {
        bottom: 20px;
    }
}

.video-card.screen-share video {
    object-fit: contain;
    background: #0b1220;
}

.host-badge {
    position: absolute;
    top: 12px;
    right: 12px;
    padding: 4px 10px;
    border-radius: 6px;
    background: #fff1c2;
    color: #805500;
    font-size: 12px;
    font-weight: 600;
}

.host-badge[hidden] {
    display: none;
}

.video-card.screen-share {
    cursor: zoom-in;
}

.fullscreen-button {
    position: absolute;
    right: 12px;
    bottom: 12px;
    padding: 5px 10px;
    background: rgba(10, 20, 36, 0.8);
    color: #fff;
    font-size: 12px;
}

.fullscreen-button[hidden] {
    display: none;
}

.video-card.screen-share .video-name {
    max-width: calc(100% - 140px);
}

.video-card:fullscreen {
    width: 100vw;
    height: 100vh;
    aspect-ratio: auto;
    border: 0;
    border-radius: 0;
    cursor: default;
    background: #0b1220;
}

.video-card:fullscreen video {
    object-fit: contain;
}

.video-card:fullscreen .video-name {
    max-width: calc(100% - 190px);
}

.leave-dialog {
    width: min(480px, calc(100vw - 32px));
    padding: 24px;
    border: 1px solid var(--tm-border);
    border-radius: 12px;
    color: var(--tm-text);
    box-shadow: 0 16px 48px rgba(0, 40, 100, 0.2);
}
.leave-dialog::backdrop { background: rgba(10, 20, 36, 0.5); }
.leave-dialog h2 { margin: 0 0 16px; font-size: 20px; }
.leave-dialog p { line-height: 1.7; }
.leave-dialog select { max-width: 100%; padding: 8px; margin: 0 0 16px 8px; }
.leave-dialog .actions { justify-content: flex-end; margin-top: 20px; }

.connection-status { margin: 0 0 16px; }

.video-card:not(.has-video) video { visibility: hidden; }
.room-label { color: var(--tm-text-tertiary); font-size: 12px; }

.share-dialog { width: min(540px, calc(100vw - 32px)); }
.share-description { color: var(--tm-text-secondary); font-size: 13px; }
.share-dialog label { color: var(--tm-text-secondary); font-size: 13px; }
.share-dialog textarea {
    display: block;
    width: 100%;
    margin-top: 10px;
    padding: 14px;
    border: 1px solid var(--tm-border);
    border-radius: 8px;
    background: #f7f9fd;
    color: var(--tm-text);
    font-family: inherit;
    font-size: 13px;
    line-height: 1.8;
    resize: vertical;
}
