* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background: #1a1a2e;
    color: #eee;
    min-height: 100vh;
    display: flex;
    justify-content: center;
}

.container {
    width: 100%;
    max-width: 600px;
    padding: 16px;
    display: flex;
    flex-direction: column;
}

h1 {
    text-align: center;
    margin-bottom: 24px;
    font-size: 1.6rem;
    color: #4fc3f7;
}

.page {
    display: none;
    flex-direction: column;
    gap: 16px;
}

.page.active {
    display: flex;
}

.input-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

label {
    font-size: 0.95rem;
    color: #aaa;
}

input[type="text"],
input[type="password"] {
    padding: 16px 18px;
    border: none;
    border-radius: 12px;
    background: rgba(255,255,255,0.08);
    color: #fff;
    font-size: 1.15rem;
    transition: all 0.3s ease;
}

input[type="text"]:focus,
input[type="password"]:focus {
    outline: none;
    background: rgba(255,255,255,0.12);
    box-shadow: 0 0 0 3px rgba(79,195,247,0.2);
}

input[type="text"]::placeholder,
input[type="password"]::placeholder {
    color: #666;
}

.btn-primary {
    padding: 18px;
    border: none;
    border-radius: 12px;
    background: linear-gradient(135deg, #4fc3f7, #29b6f6);
    color: #fff;
    font-size: 1.25rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
}

.btn-primary:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(79,195,247,0.4);
}

.btn-primary:active:not(:disabled) {
    transform: translateY(0);
}

.btn-primary:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.status-msg {
    text-align: center;
    padding: 12px;
    border-radius: 8px;
    font-size: 0.95rem;
    min-height: 48px;
}

.status-msg.error {
    background: rgba(255,71,87,0.15);
    color: #ff4757;
}

.status-msg.success {
    background: rgba(79,195,247,0.15);
    color: #4fc3f7;
}

/* 控制页 — 竖屏全屏布局: 视频占满剩余空间, 工具栏贴底 */
#controlPage {
    min-height: calc(100vh - 32px);
}

.header-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 18px;
    background: rgba(0,0,0,0.3);
    border-radius: 12px;
}

#sessionStatus {
    font-size: 1.1rem;
    color: #aaa;
}

#sessionStatus.connected {
    color: #4fc3f7;
}

.btn-small {
    padding: 14px 24px;
    border: none;
    border-radius: 10px;
    background: rgba(255,71,87,0.2);
    color: #ff4757;
    font-size: 1.1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
}

.btn-small:hover {
    background: rgba(255,71,87,0.3);
}

#screen {
    width: 100%;
    aspect-ratio: 9 / 20.5;      /* 竖屏占位比例(手机屏), 有流后 object-fit 接管 */
    max-height: calc(100vh - 250px);
    background: #0a0a0f;
    border-radius: 12px;
    object-fit: contain;          /* 画面完整显示, 不裁剪不变形 */
    display: block;
    margin: 0 auto;
    touch-action: none;           /* 阻止浏览器手势干扰拖拽 */
}

.toolbar {
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding: 16px;
    background: rgba(0,0,0,0.3);
    border-radius: 12px;
    margin-top: auto;
}

.toolbar-row {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
}

.input-row {
    grid-template-columns: 1fr auto;
    gap: 12px;
}

.tool-btn {
    min-height: 64px;
    border: none;
    border-radius: 14px;
    background: rgba(255,255,255,0.08);
    color: #eee;
    font-size: 1.4rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    padding: 10px 4px;
}

.tool-btn:hover {
    background: rgba(255,255,255,0.15);
    transform: scale(1.03);
}

.tool-btn:active {
    transform: scale(0.96);
    background: rgba(79,195,247,0.25);
}

.send-btn {
    min-width: 120px;
    background: linear-gradient(135deg, #4fc3f7, #29b6f6);
    color: #fff;
    font-weight: 600;
}

.send-btn:hover {
    background: linear-gradient(135deg, #4fc3f7, #29b6f6);
}

#textInput {
    width: 100%;
    padding: 16px 18px;
    border: none;
    border-radius: 12px;
    background: rgba(255,255,255,0.08);
    color: #fff;
    font-size: 1.2rem;
}

#textInput:focus {
    outline: none;
    background: rgba(255,255,255,0.12);
}

.error-msg {
    text-align: center;
    padding: 12px;
    color: #ff4757;
    font-size: 0.9rem;
    display: none;
}

.error-msg.show {
    display: block;
}

/* 小屏进一步收紧 */
@media (max-width: 480px) {
    .container {
        padding: 12px;
    }

    h1 {
        font-size: 1.3rem;
    }

    #screen {
        max-height: calc(100vh - 240px);
    }

    .tool-btn {
        min-height: 60px;
        font-size: 1.25rem;
    }
}

/* 滚动条样式 */
::-webkit-scrollbar {
    width: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: rgba(255,255,255,0.2);
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: rgba(255,255,255,0.3);
}
