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

:root {
    --bg: #e8f4fc;
    --surface: #ffffff;
    --accent: #4a90d9;
    --accent-hover: #3a7ac0;
    --text: #2c3e50;
    --text-muted: #7f8c9b;
    --border: #dce6ef;
    --radius: 12px;
    --shadow: 0 2px 12px rgba(0,0,0,.04);
    --font: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
}

body {
    font-family: var(--font);
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    line-height: 1.6;
}

/* ===== Screen System ===== */
.screen { display: none; flex-direction: column; min-height: 100vh; }
.screen.active { display: flex; }

/* ===== Login Screen ===== */
#screen-login {
    align-items: center; justify-content: center; padding: 40px 20px;
    background: linear-gradient(135deg, #dceefb 0%, #e8f4fc 50%, #f0f6fb 100%);
}
.login-card {
    background: #fff; border-radius: 20px; padding: 44px 36px;
    max-width: 420px; width: 100%; text-align: center;
    box-shadow: 0 8px 40px rgba(0,0,0,.06);
}
.logo { font-size: 3.5rem; margin-bottom: 8px; }
.login-card h1 { font-size: 1.5rem; font-weight: 700; margin-bottom: 6px; }
.subtitle { font-size: .9rem; color: var(--text-muted); margin-bottom: 28px; }
.login-form { display: flex; flex-direction: column; gap: 12px; }
.login-form input {
    padding: 12px 16px; font-size: .95rem; font-family: var(--font);
    border: 2px solid var(--border); border-radius: var(--radius);
    outline: none; transition: border-color .2s; background: #fafbfc;
}
.login-form input:focus { border-color: var(--accent); }
.btn-main {
    padding: 12px; font-size: 1rem; font-family: var(--font);
    background: var(--accent); color: #fff; border: none;
    border-radius: var(--radius); cursor: pointer; font-weight: 600;
    transition: all .15s;
}
.btn-main:hover { background: var(--accent-hover); }
.btn-main:disabled { opacity: .5; cursor: not-allowed; }
.login-hint { font-size: .8rem; color: var(--text-muted); margin-top: 12px; }
.login-hint strong { color: var(--accent); }
.error-msg { color: #e55; font-size: .85rem; min-height: 20px; margin-top: 8px; }

/* ===== Header ===== */
header {
    background: #fff; border-bottom: 1px solid var(--border);
    padding: 12px 24px; display: flex; align-items: center;
    justify-content: space-between; flex-wrap: wrap; gap: 12px;
    box-shadow: var(--shadow);
}
.header-left h1 { font-size: 1.2rem; font-weight: 600; }
.header-right { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }

.points-badge {
    display: flex; align-items: center; gap: 4px;
    background: #f0f7fd; border: 2px solid var(--accent);
    border-radius: 24px; padding: 5px 14px;
    font-size: .9rem; font-weight: 600;
}
.points-icon { font-size: 1.1rem; }
.btn-recharge {
    padding: 6px 16px; font-size: .85rem; font-family: var(--font);
    background: linear-gradient(135deg, #f9a825, #f57f17);
    color: #fff; border: none; border-radius: 20px;
    cursor: pointer; font-weight: 600; transition: all .15s;
}
.btn-recharge:hover { transform: scale(1.04); }
.user-name { font-size: .85rem; color: var(--text-muted); }
.btn-logout {
    padding: 5px 12px; font-size: .8rem; font-family: var(--font);
    background: none; border: 1px solid var(--border);
    border-radius: var(--radius); cursor: pointer;
    color: var(--text-muted); transition: all .15s;
}
.btn-logout:hover { background: #f5f5f5; }

/* ===== Main ===== */
main {
    flex: 1; max-width: 800px; width: 100%;
    margin: 0 auto; padding: 28px 16px;
}

/* ===== Mode Tabs ===== */
.mode-tabs {
    display: flex; gap: 8px; margin-bottom: 14px;
}
.mode-tab {
    padding: 7px 18px; font-size: .88rem; font-family: var(--font);
    border: 2px solid var(--border); background: #f8fafc;
    border-radius: 20px; cursor: pointer; transition: all .15s;
    color: var(--text-muted);
}
.mode-tab:hover { border-color: var(--accent); }
.mode-tab.active { background: var(--accent); color: #fff; border-color: var(--accent); }

/* Upload area */
.upload-area { margin-bottom: 12px; }
.upload-label {
    display: block; padding: 32px; text-align: center;
    border: 2px dashed var(--border); border-radius: var(--radius);
    cursor: pointer; transition: all .15s; color: var(--text-muted);
}
.upload-label:hover { border-color: var(--accent); background: #f5f9fd; }
.image-preview { text-align: center; margin-top: 8px; }
.image-preview img { max-width: 200px; max-height: 150px; border-radius: 8px; }

/* ===== Generate Section ===== */
.generate-section {
    background: #fff; border-radius: 16px; padding: 28px;
    box-shadow: var(--shadow); margin-bottom: 28px;
}
.generate-section h2 { font-size: 1.1rem; margin-bottom: 14px; }
.generate-section textarea {
    width: 100%; height: 120px; padding: 14px;
    font-size: .95rem; font-family: var(--font);
    border: 2px solid var(--border); border-radius: var(--radius);
    outline: none; resize: vertical; transition: border-color .2s;
    background: #fafbfc;
}
.generate-section textarea:focus { border-color: var(--accent); }
.btn-generate {
    margin-top: 14px; width: 100%;
}
.cost-tag { font-weight: 400; font-size: .85rem; opacity: .8; }
.generate-status {
    text-align: center; margin-top: 12px;
    font-size: .95rem; min-height: 24px;
}
.generate-status.loading { color: var(--accent); animation: pulse 1.2s ease-in-out infinite; }
.generate-status.success { color: #4a8; }
.generate-status.error { color: #e55; }

@keyframes pulse {
    0%,100% { opacity: 1; }
    50% { opacity: .5; }
}

/* ===== Video List ===== */
.videos-section h2 { font-size: 1.1rem; margin-bottom: 14px; }
.video-list { display: flex; flex-direction: column; gap: 14px; }
.video-card {
    background: #fff; border-radius: 14px; padding: 18px;
    box-shadow: var(--shadow); display: flex; gap: 16px;
    align-items: flex-start;
}
.video-thumb {
    width: 180px; height: 100px; border-radius: 10px;
    background: #e0ecf6; flex-shrink: 0;
    display: flex; align-items: center; justify-content: center;
    overflow: hidden; position: relative;
}
.video-thumb video {
    width: 100%; height: 100%; object-fit: cover;
}
.video-thumb .play-icon {
    position: absolute; font-size: 2rem; color: rgba(255,255,255,.9);
    pointer-events: none;
}
.video-info { flex: 1; min-width: 0; }
.video-desc {
    font-size: .9rem; line-height: 1.5; margin-bottom: 6px;
    display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
    overflow: hidden;
}
.video-meta { font-size: .78rem; color: var(--text-muted); }
.video-author { font-weight: 600; color: var(--accent); }

.empty-msg {
    text-align: center; padding: 40px; color: var(--text-muted);
    font-size: .95rem; background: #fff; border-radius: 14px;
}

/* ===== Recharge Modal ===== */
.modal { display: none; position: fixed; inset: 0; z-index: 200; }
.modal.show { display: flex; align-items: center; justify-content: center; }
.modal::before { content: ''; position: absolute; inset: 0; background: rgba(0,0,0,.2); }
.modal-content {
    position: relative; background: #fff; border-radius: 18px;
    padding: 28px; width: 90%; max-width: 460px;
    box-shadow: 0 12px 48px rgba(0,0,0,.1);
}
.modal-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 18px; }
.modal-header h2 { font-size: 1.2rem; }
.modal-close {
    width: 32px; height: 32px; border-radius: 50%;
    border: 1px solid var(--border); background: #fff;
    font-size: 1.1rem; cursor: pointer; display: flex;
    align-items: center; justify-content: center;
}
.modal-close:hover { background: #f5f5f5; }

.recharge-options { display: flex; flex-direction: column; gap: 10px; margin-bottom: 14px; }
.recharge-card {
    padding: 16px; border: 2px solid var(--border);
    border-radius: 12px; cursor: pointer; text-align: center;
    transition: all .15s;
}
.recharge-card:hover { border-color: var(--accent); background: #f5f9fd; }
.recharge-amount { font-size: 1.2rem; font-weight: 700; }
.recharge-price { font-size: .8rem; color: var(--text-muted); }
.recharge-hint { text-align: center; font-size: .78rem; color: var(--text-muted); }

/* ===== Responsive ===== */
@media (max-width: 640px) {
    header { padding: 10px 14px; }
    .header-left h1 { font-size: 1rem; }
    .generate-section { padding: 18px; }
    .video-card { flex-direction: column; }
    .video-thumb { width: 100%; height: 160px; }
    .login-card { padding: 28px 20px; }
}
