* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    background: #1a1a2e;
    color: #fff;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    overflow: hidden;
    height: 100vh;
    display: flex;
    flex-direction: column;
}

.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 16px;
    background: #16213e;
    flex-shrink: 0;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 12px;
}

.header-btn {
    background: #0f3460;
    color: #4ecca3;
    border: 1px solid #4ecca3;
    border-radius: 4px;
    padding: 3px 10px;
    font-size: 13px;
    cursor: pointer;
}

.header-btn:hover {
    background: #4ecca3;
    color: #000;
}

.layout-btn {
    background: #0f3460;
    color: #4ecca3;
    border: 1px solid #4ecca3;
    border-radius: 4px;
    padding: 3px 10px;
    font-size: 13px;
    cursor: pointer;
}

.layout-btn:hover {
    background: #4ecca3;
    color: #000;
}

.layout-wrapper {
    position: relative;
}

.layout-panel {
    display: none;
    position: absolute;
    top: 100%;
    right: 0;
    background: #16213e;
    border: 1px solid #0f3460;
    border-radius: 4px;
    z-index: 100;
    flex-direction: column;
    gap: 2px;
    padding: 4px;
    margin-top: 4px;
}

.layout-item {
    padding: 6px 16px;
    color: #fff;
    font-size: 13px;
    cursor: pointer;
    border-radius: 3px;
    text-align: center;
}

.layout-item:hover {
    background: #0f3460;
    color: #4ecca3;
}

.title {
    font-size: 18px;
    font-weight: 600;
}

.status {
    font-size: 12px;
    padding: 2px 8px;
    border-radius: 10px;
}

.status.connected {
    background: #0f3460;
    color: #4ecca3;
}

.status.disconnected {
    background: #5c0e0e;
    color: #e94560;
}

.grid {
    flex: 1;
    display: grid;
    grid-template-columns: 1fr 1fr;
    grid-template-rows: 1fr 1fr;
    gap: 2px;
    padding: 2px;
    overflow: hidden;
}

.cell {
    position: relative;
    background: #000;
    border-radius: 4px;
    overflow: hidden;
}

.cell.empty-cell {
    background: #1a1a1a;
    border: 1px dashed #444;
    display: flex;
    align-items: center;
    justify-content: center;
}

.cell.empty-cell::after {
    content: '空位';
    color: #555;
    font-size: 14px;
}

.cell.empty-cell:has(.server-status)::after {
    content: '';
}


.cell.drag-over {
    border: 2px solid #4ecca3;
    opacity: 0.7;
}

.cell video {
    width: 100%;
    height: 100%;
    object-fit: fill;
    background: #000;
    pointer-events: none;
}

.cell .label {
    position: absolute;
    bottom: 6px;
    left: 6px;
    background: rgba(0, 0, 0, 0.6);
    color: #fff;
    font-size: 13px;
    padding: 2px 8px;
    border-radius: 4px;
    z-index: 2;
}

.cell .btn-close {
    position: absolute;
    bottom: 6px;
    right: 6px;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    border: none;
    cursor: pointer;
    z-index: 3;
    /* background: rgba(233, 69, 96, 0.85); */
    background: rgba(0, 0, 0, 0.6);
    color: #fff;
    font-size: 16px;
    display: none;
    align-items: center;
    justify-content: center;
}

.cell .btn-close:hover {
    /* background: #e94560; */
}

.cell .btn-mute {
    position: absolute;
    bottom: 6px;
    right: 42px;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    border: none;
    cursor: pointer;
    z-index: 3;
    display: none;
    align-items: center;
    justify-content: center;
    font-size: 14px;
}

.cell .btn-mute.muted {
    background: rgba(0, 0, 0, 0.6);
    color: #888;
}

.cell .btn-mute.unmuted {
    background: #4ecca3;
    color: #000;
}

.cell .btn-quality {
    position: absolute;
    bottom: 6px;
    right: 80px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    z-index: 3;
    background: rgba(0, 0, 0, 0.6);
    color: #fff;
    font-size: 12px;
    padding: 4px 8px;
}

.cell .btn-quality:hover {
    background: rgba(78, 204, 163, 0.8);
}

.cell .codec-tag {
    position: absolute;
    top: 6px;
    left: 6px;
    font-size: 11px;
    padding: 2px 6px;
    border-radius: 4px;
    z-index: 2;
    display: none;
    background: rgba(0, 0, 0, 0.6);
    color: #fff;
}

.cell .codec-tag.h265 {
    /* background: rgba(233, 69, 96, 0.8); */
    /* color: #fff; */
}

.cell .codec-tag.h264 {
    /* background: rgba(78, 204, 163, 0.8); */
    /* color: #000; */
}

.cell .center-btn {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 3;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
}

.cell .center-btn .play-icon {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    background: rgba(78, 204, 163, 0.2);
    border: 2px solid #4ecca3;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.cell .center-btn .play-icon:hover {
    background: rgba(78, 204, 163, 0.4);
    transform: scale(1.1);
}

.cell .center-btn .play-icon::before {
    content: '';
    width: 0;
    height: 0;
    border-left: 20px solid #4ecca3;
    border-top: 12px solid transparent;
    border-bottom: 12px solid transparent;
    margin-left: 4px;
}

.cell .center-btn .center-text {
    color: #888;
    font-size: 14px;
}

.cell .center-btn.connecting .play-icon {
    border-color: #e9c46a;
    animation: pulse 1s infinite;
}

.cell .center-btn.connecting .play-icon::before {
    border-left-color: #e9c46a;
}

.cell .center-btn.connecting .center-text {
    color: #e9c46a;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.4; }
}

.footer {
    padding: 4px 16px;
    background: #16213e;
    font-size: 12px;
    color: #888;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-shrink: 0;
}
.footer-server {
    display: flex;
    gap: 12px;
    color: #aaa;
}
.footer-server span {
    white-space: nowrap;
}
.footer-btns {
    display: flex;
    gap: 8px;
}
.footer-btn {
    background: #1a1a2e;
    color: #4ecca3;
    border: 1px solid #4ecca3;
    border-radius: 4px;
    padding: 2px 10px;
    font-size: 12px;
    cursor: pointer;
    transition: all 0.2s;
}
.footer-btn:hover {
    background: #4ecca3;
    color: #0f0f0f;
}
.footer-btn:active {
    transform: scale(0.95);
}

/* ---------- 登录页 ---------- */
.login-wrap {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
}
.login-box {
    background: #16213e;
    border-radius: 8px;
    padding: 40px 30px;
    width: 320px;
    text-align: center;
}
.login-box h2 {
    color: #4ecca3;
    margin-bottom: 30px;
    font-size: 22px;
}
.login-box input {
    width: 100%;
    padding: 10px 14px;
    margin-bottom: 16px;
    background: #1a1a2e;
    border: 1px solid #333;
    border-radius: 4px;
    color: #fff;
    font-size: 15px;
}
.login-box input:focus {
    border-color: #4ecca3;
    outline: none;
}
.login-box button {
    width: 100%;
    padding: 10px;
    background: #4ecca3;
    color: #000;
    border: none;
    border-radius: 4px;
    font-size: 16px;
    cursor: pointer;
    font-weight: bold;
}
.login-box button:hover {
    opacity: 0.9;
}
#login-error {
    color: #e74c3c;
    margin-top: 12px;
    font-size: 14px;
}
