* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background: #f5f5f5;
    color: #333;
    line-height: 1.6;
    min-height: 100vh;
}

/* Navbar */
.navbar {
    background: #1a1a2e;
    color: #fff;
    padding: 0 20px;
    height: 56px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 100;
}

.navbar .brand {
    color: #fff;
    text-decoration: none;
    font-size: 18px;
    font-weight: 600;
}

.nav-links {
    display: flex;
    align-items: center;
    gap: 16px;
}

.nav-links a {
    color: #ccc;
    text-decoration: none;
    font-size: 14px;
    transition: color 0.2s;
}

.nav-links a:hover {
    color: #fff;
}

.nav-links .username {
    font-size: 14px;
    color: #7c83fd;
    font-weight: 500;
}

/* Container */
.container {
    max-width: 960px;
    margin: 0 auto;
    padding: 24px 16px;
}

/* Auth pages */
.auth-page {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: calc(100vh - 56px);
}

.auth-card {
    background: #fff;
    border-radius: 12px;
    padding: 32px;
    width: 100%;
    max-width: 380px;
    box-shadow: 0 2px 12px rgba(0,0,0,0.08);
}

.auth-card h2 {
    text-align: center;
    margin-bottom: 24px;
    font-size: 24px;
}

.auth-link {
    text-align: center;
    margin-top: 16px;
    font-size: 14px;
    color: #666;
}

.auth-link a {
    color: #7c83fd;
    text-decoration: none;
}

/* Forms */
.form-group {
    margin-bottom: 16px;
}

.form-group input {
    width: 100%;
    padding: 13px 14px;
    border: 1px solid #ddd;
    border-radius: 8px;
    font-size: 16px;
    transition: border-color 0.2s;
    outline: none;
    -webkit-appearance: none;
    appearance: none;
}

.form-group input:focus {
    border-color: #7c83fd;
}

.form-group input::placeholder {
    color: #bbb;
    font-size: 15px;
}

/* Code input + button row */
.code-group {
    display: flex;
    gap: 8px;
    align-items: stretch;
}

.code-group input {
    flex: 1;
    min-width: 0;
    text-align: center;
    font-size: 18px;
    letter-spacing: 4px;
}

.btn-code {
    white-space: nowrap;
    flex-shrink: 0;
    background: #f5f5ff;
    color: #7c83fd;
    border: 1px solid #7c83fd;
    border-radius: 8px;
    padding: 0 14px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    min-width: 100px;
}

.btn-code:hover {
    background: #7c83fd;
    color: #fff;
}

.btn-code:disabled {
    background: #f0f0f0;
    border-color: #ddd;
    color: #999;
    cursor: not-allowed;
}

/* Buttons */
.btn {
    display: inline-block;
    padding: 10px 20px;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    cursor: pointer;
    text-decoration: none;
    transition: opacity 0.2s;
}

.btn:hover {
    opacity: 0.9;
}

.btn-primary {
    background: #7c83fd;
    color: #fff;
}

.btn-block {
    width: 100%;
    padding: 12px;
    font-size: 16px;
}

.btn-sm {
    padding: 6px 12px;
    font-size: 13px;
    background: #f0f0f0;
    color: #333;
}

.btn-danger {
    background: #ff4757;
    color: #fff;
}

/* Dashboard */
.dashboard-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
}

.dashboard-header h2 {
    font-size: 22px;
}

.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: #999;
}

.empty-state p {
    margin-bottom: 16px;
    font-size: 16px;
}

/* Video grid */
.video-grid {
    display: grid;
    gap: 16px;
}

.video-card {
    background: #fff;
    border-radius: 10px;
    padding: 16px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 1px 4px rgba(0,0,0,0.06);
}

.video-card-body h3 {
    font-size: 16px;
    margin-bottom: 6px;
}

.video-card-body h3 a {
    color: #333;
    text-decoration: none;
}

.video-card-body h3 a:hover {
    color: #7c83fd;
}

.video-meta {
    display: flex;
    gap: 16px;
    font-size: 13px;
    color: #888;
}

.video-card-actions {
    display: flex;
    gap: 8px;
    flex-shrink: 0;
}

/* Upload area */
.upload-area {
    background: #fff;
    border: 2px dashed #ddd;
    border-radius: 12px;
    padding: 60px 20px;
    text-align: center;
    cursor: pointer;
    transition: border-color 0.2s;
    margin-top: 24px;
}

.upload-area:hover {
    border-color: #7c83fd;
}

.upload-icon {
    margin-bottom: 12px;
}

.upload-text {
    font-size: 16px;
    color: #666;
}

.upload-hint {
    font-size: 13px;
    color: #999;
    margin-top: 8px;
}

.upload-progress {
    padding: 20px;
}

.progress-bar {
    background: #eee;
    border-radius: 10px;
    height: 12px;
    overflow: hidden;
    margin-bottom: 12px;
}

.progress-fill {
    background: #7c83fd;
    height: 100%;
    width: 0%;
    border-radius: 10px;
    transition: width 0.3s;
}

.progress-text {
    font-size: 15px;
    color: #666;
}

.progress-filename {
    font-size: 13px;
    color: #999;
    margin-top: 4px;
}

/* Player */
.player-container {
    background: #000;
    border-radius: 12px;
    overflow: hidden;
    margin-bottom: 16px;
}

.video-player {
    width: 100%;
    display: block;
    max-height: 70vh;
    background: #000;
}

.video-detail {
    background: #fff;
    border-radius: 10px;
    padding: 20px;
    box-shadow: 0 1px 4px rgba(0,0,0,0.06);
}

.video-detail h2 {
    font-size: 18px;
    margin-bottom: 12px;
    word-break: break-all;
}

.video-info {
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
    font-size: 14px;
    color: #666;
}

/* Balance */
.balance-card {
    background: linear-gradient(135deg, #7c83fd, #6c63ff);
    color: #fff;
    border-radius: 12px;
    padding: 20px 24px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    box-shadow: 0 4px 12px rgba(124, 131, 253, 0.3);
}

.balance-label {
    font-size: 15px;
    opacity: 0.9;
}

.balance-amount {
    font-size: 28px;
    font-weight: 700;
}

.balance-amount::after {
    content: ' 元';
    font-size: 16px;
    font-weight: 400;
    opacity: 0.8;
}

/* Billing */
.billing-controls {
    display: flex;
    gap: 12px;
    align-items: center;
    margin-bottom: 24px;
    margin-top: 16px;
}

.billing-controls input[type="month"] {
    padding: 10px 14px;
    border: 1px solid #ddd;
    border-radius: 8px;
    font-size: 15px;
    outline: none;
}

.billing-controls input[type="month"]:focus {
    border-color: #7c83fd;
}

.billing-card {
    background: #fff;
    border-radius: 10px;
    padding: 24px;
    box-shadow: 0 1px 4px rgba(0,0,0,0.06);
}

.billing-card h3 {
    margin-bottom: 16px;
    font-size: 18px;
}

.billing-table {
    width: 100%;
    border-collapse: collapse;
}

.billing-table td {
    padding: 12px 0;
    border-bottom: 1px solid #f0f0f0;
    font-size: 15px;
}

.billing-table td.right {
    text-align: right;
    font-weight: 500;
}

.billing-table .total-row td {
    border-bottom: none;
    font-size: 17px;
    font-weight: 600;
    padding-top: 16px;
    color: #7c83fd;
}

/* Modal */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.6);
    z-index: 200;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
}

.modal-content {
    background: #fff;
    border-radius: 16px;
    padding: 32px 24px 24px;
    max-width: 320px;
    width: 100%;
    text-align: center;
    box-shadow: 0 20px 60px rgba(0,0,0,0.3);
    position: relative;
}

.qr-code {
    display: flex;
    justify-content: center;
    margin-bottom: 4px;
}

.qr-code img, .qr-code canvas {
    border-radius: 8px;
    max-width: 100%;
}

.qr-actions {
    margin-top: 4px;
}

.btn-back {
    background: #f0f0f0;
    color: #666;
    margin-top: 8px;
}

.btn-back:hover {
    background: #e0e0e0;
}

.qr-hint {
    font-size: 13px;
    color: #999;
    margin: 8px 0 16px;
    text-align: center;
}

/* Mobile */
@media (max-width: 600px) {
    .container {
        padding: 16px 12px;
    }

    .auth-card {
        max-width: 100%;
        padding: 24px 20px;
        margin: 0 4px;
        border-radius: 10px;
    }

    .auth-card h2 {
        font-size: 20px;
        margin-bottom: 20px;
    }

    .form-group input {
        padding: 14px;
        font-size: 16px;
    }

    .btn {
        padding: 14px 20px;
        font-size: 16px;
        min-height: 48px;
    }

    .btn-sm {
        padding: 10px 16px;
        min-height: 40px;
        font-size: 14px;
    }

    .video-card {
        flex-direction: column;
        align-items: stretch;
        gap: 12px;
        padding: 14px 16px;
    }

    .video-card-body h3 {
        font-size: 15px;
    }

    .video-meta {
        flex-wrap: wrap;
        gap: 8px;
    }

    .video-card-actions {
        width: 100%;
        display: flex;
        gap: 8px;
    }

    .video-card-actions .btn {
        flex: 1;
        text-align: center;
    }

    .video-info {
        flex-direction: column;
        gap: 6px;
    }

    .nav-links {
        gap: 8px;
        font-size: 0;
    }

    .nav-links a,
    .nav-links .username {
        font-size: 13px;
    }

    .dashboard-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 12px;
    }

    .dashboard-header .btn {
        width: 100%;
        text-align: center;
    }

    .upload-area {
        padding: 40px 16px;
        margin-top: 16px;
    }

    .video-player {
        max-height: 50vh;
    }

    .player-container {
        border-radius: 8px;
        margin: 0 -12px;
    }

    .video-detail {
        padding: 16px;
        border-radius: 8px;
    }

    .billing-controls {
        flex-direction: column;
        align-items: stretch;
    }

    .billing-controls input[type="month"] {
        text-align: center;
        font-size: 16px;
        padding: 12px;
    }

    .billing-card {
        padding: 16px;
    }

    .billing-table td {
        font-size: 14px;
        padding: 10px 0;
    }

    .code-group {
        gap: 6px;
    }

    .btn-code {
        min-width: 90px;
        padding: 0 10px;
        font-size: 13px;
    }

    .balance-card {
        padding: 16px;
    }

    .balance-amount {
        font-size: 22px;
    }

    .modal-content {
        padding: 24px 16px 20px;
        max-width: 280px;
    }

    .modal-content h3 {
        font-size: 15px;
    }

    .qr-code img, .qr-code canvas {
        width: 160px;
        height: 160px;
    }
}

/* iPhone SE and very small screens */
@media (max-width: 375px) {
    .nav-links a,
    .nav-links .username {
        font-size: 12px;
    }

    .nav-links {
        gap: 6px;
    }

    .btn-code {
        min-width: 80px;
        font-size: 12px;
    }
}
