:root {
  /* 护眼色系 */
  --bg-primary: #f0f5ef;          /* 淡绿护眼底色 */
  --bg-secondary: #e8f0e6;        /* 稍深护眼底色 */
  --bg-card: #ffffff;             /* 卡片白色 */
  --bg-modal-overlay: rgba(0,0,0,0.4);
  --bg-video-overlay: rgba(0,0,0,0.85);
  
  --text-primary: #2c3e2d;        /* 深绿灰主文字 */
  --text-secondary: #6b7f6c;      /* 中绿灰副文字 */
  --text-muted: #9aab9b;          /* 浅灰提示文字 */
  
  --accent-primary: #4a9d5b;      /* 主绿色 */
  --accent-primary-hover: #3d8a4e;
  --accent-danger: #e74c3c;
  --accent-danger-hover: #c0392b;
  
  --status-queued: #5dade2;       /* 排队中 - 柔蓝 */
  --status-processing: #f39c12;   /* 处理中 - 橙 */
  --status-done: #27ae60;         /* 完成 - 绿 */
  --status-failed: #e74c3c;       /* 失败 - 红 */
  
  --gender-male: #5dade2;
  --gender-female: #e88dac;
  
  --shadow-card: 0 2px 12px rgba(0,0,0,0.06);
  --shadow-card-hover: 0 4px 20px rgba(0,0,0,0.1);
  --shadow-modal: 0 8px 32px rgba(0,0,0,0.15);
  --shadow-nav: 0 1px 3px rgba(0,0,0,0.05);
  
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 20px;
  
  --transition: all 0.25s ease;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    -webkit-tap-highlight-color: transparent;
}

html {
    scroll-behavior: smooth;
}

body {
    background-color: var(--bg-primary);
    color: var(--text-primary);
    font-family: 'Noto Sans SC', sans-serif;
    min-height: 100vh;
    line-height: 1.5;
}

/* Typography */
h1, h2, h3, h4, h5, h6 {
    color: var(--text-primary);
    font-weight: 700;
}

a {
    text-decoration: none;
    color: inherit;
}

/* Login Page Specific */
.login-body {
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 20px;
}

.login-container {
    width: 100%;
    max-width: 400px;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.login-card {
    background: var(--bg-card);
    border-radius: var(--radius-xl);
    padding: 40px 30px;
    box-shadow: var(--shadow-card);
    position: relative;
    overflow: hidden;
}

.login-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 6px;
    background: linear-gradient(90deg, var(--accent-primary), #81c784);
}

.login-header {
    text-align: center;
    margin-bottom: 32px;
}

.login-header .app-icon {
    font-size: 48px;
    margin-bottom: 12px;
}

.login-header h1 {
    font-size: 24px;
    color: var(--text-primary);
}

.login-form {
    display: flex;
    flex-direction: column;
}

.login-btn {
    width: 100%;
}

.login-footer {
    text-align: center;
    color: var(--text-muted);
    font-size: 14px;
}

/* App Navbar */
.navbar {
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: var(--shadow-nav);
    padding: env(safe-area-inset-top) 0 0 0; /* iOS safe area */
}

.nav-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 12px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    height: 60px;
}

.nav-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 700;
    font-size: 18px;
    color: var(--text-primary);
}

.app-icon {
    font-size: 24px;
}

/* Main Content */
.main-content {
    max-width: 1200px;
    margin: 0 auto;
    padding: 24px 20px;
    padding-bottom: calc(24px + env(safe-area-inset-bottom));
}

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

.content-header h2 {
    font-size: 20px;
}

/* Tasks Grid */
.tasks-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 16px;
}

@media (min-width: 768px) {
    .tasks-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 20px;
    }
}

@media (min-width: 1024px) {
    .tasks-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: 24px;
    }
}

/* Empty State */
.empty-state {
    grid-column: 1 / -1;
    text-align: center;
    padding: 60px 20px;
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    color: var(--text-muted);
}
.empty-icon {
    font-size: 48px;
    margin-bottom: 16px;
    opacity: 0.5;
}

/* Task Card */
.task-card {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    padding: 20px;
    box-shadow: var(--shadow-card);
    transition: var(--transition);
    position: relative;
    display: flex;
    flex-direction: column;
    height: 100%;
}

.task-card:hover {
    box-shadow: var(--shadow-card-hover);
    transform: translateY(-2px);
}

.card-close-btn {
    position: absolute;
    top: 12px;
    right: 12px;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: rgba(0,0,0,0.05);
    border: none;
    color: var(--text-secondary);
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    transition: var(--transition);
    font-size: 16px;
    line-height: 1;
    z-index: 2;
}

.card-close-btn:hover {
    background: var(--accent-danger);
    color: white;
}

/* Mobile: always show close button, Desktop: show on hover */
@media (min-width: 768px) {
    .card-close-btn { opacity: 0; }
    .task-card:hover .card-close-btn { opacity: 1; }
}

.card-header {
    display: flex;
    align-items: flex-start;
    padding-right: 28px;
    margin-bottom: 12px;
}

.card-title {
    font-size: 18px;
    font-weight: 700;
    word-break: break-all;
    line-height: 1.3;
}

.card-body {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-bottom: 16px;
}

.badges {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.badge {
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 500;
}

.badge-gender.male {
    background-color: rgba(93, 173, 226, 0.15);
    color: #2980b9;
}
.badge-gender.female {
    background-color: rgba(232, 141, 172, 0.15);
    color: #c0392b;
}

.badge-status {
    color: white;
}
.status-queued { background-color: var(--status-queued); }
.status-processing { 
    background-color: var(--status-processing); 
    animation: pulse 2s infinite;
}
.status-done { background-color: var(--status-done); }
.status-failed { background-color: var(--status-failed); }

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

.card-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: auto;
}

.created-time {
    font-size: 12px;
    color: var(--text-muted);
}

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

.btn-icon {
    background: var(--bg-secondary);
    border: none;
    padding: 6px 12px;
    border-radius: var(--radius-sm);
    font-size: 13px;
    cursor: pointer;
    color: var(--text-primary);
    transition: var(--transition);
    display: flex;
    align-items: center;
    gap: 4px;
}
.btn-icon:hover {
    background: #dce6db;
}

/* Buttons */
.btn-primary, .btn-secondary, .btn-danger, .btn-outline {
    border: none;
    border-radius: var(--radius-md);
    padding: 10px 20px;
    font-size: 15px;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 44px; /* Touch target */
    font-family: inherit;
}

.btn-primary {
    background-color: var(--accent-primary);
    color: white;
}
.btn-primary:hover { background-color: var(--accent-primary-hover); }
.btn-primary:disabled {
    background-color: var(--text-muted);
    cursor: not-allowed;
}

.btn-secondary {
    background-color: var(--bg-secondary);
    color: var(--text-primary);
}
.btn-secondary:hover { background-color: #dce6db; }

.btn-danger {
    background-color: var(--accent-danger);
    color: white;
}
.btn-danger:hover { background-color: var(--accent-danger-hover); }

.btn-outline {
    background-color: transparent;
    border: 1px solid var(--accent-primary);
    color: var(--accent-primary);
}
.btn-outline:hover {
    background-color: var(--accent-primary);
    color: white;
}

/* Forms */
.form-group {
    margin-bottom: 20px;
}
.form-group label {
    display: block;
    margin-bottom: 8px;
    font-size: 14px;
    font-weight: 500;
    color: var(--text-secondary);
}

input[type="text"],
input[type="password"],
input[type="url"] {
    width: 100%;
    padding: 12px 16px;
    border: 1px solid #dce6db;
    border-radius: var(--radius-md);
    font-size: 15px;
    font-family: inherit;
    transition: var(--transition);
    background-color: #fafdfa;
    color: var(--text-primary);
}

input:focus {
    outline: none;
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 3px rgba(74, 157, 91, 0.1);
}

input::placeholder {
    color: var(--text-muted);
}

/* Custom Radio Buttons */
.radio-group {
    display: flex;
    gap: 12px;
}

.radio-label {
    flex: 1;
    position: relative;
    cursor: pointer;
}

.radio-label input {
    position: absolute;
    opacity: 0;
    cursor: pointer;
}

.radio-custom {
    display: block;
    text-align: center;
    padding: 10px;
    background: var(--bg-secondary);
    border: 2px solid transparent;
    border-radius: var(--radius-md);
    transition: var(--transition);
    font-weight: 500;
}

.radio-label input:checked ~ .radio-custom.male {
    background: rgba(93, 173, 226, 0.1);
    border-color: var(--gender-male);
    color: #2980b9;
}

.radio-label input:checked ~ .radio-custom.female {
    background: rgba(232, 141, 172, 0.1);
    border-color: var(--gender-female);
    color: #c0392b;
}

/* Modals */
.modal-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background-color: var(--bg-modal-overlay);
    backdrop-filter: blur(3px);
    -webkit-backdrop-filter: blur(3px);
    display: flex;
    justify-content: center;
    align-items: flex-end; /* Mobile default */
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transition: var(--transition);
}

.modal-overlay.active {
    opacity: 1;
    visibility: visible;
}

.modal-card {
    background: var(--bg-card);
    width: 100%;
    max-width: 500px;
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    padding: 24px;
    box-shadow: var(--shadow-modal);
    transform: translateY(100%);
    transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    position: relative;
    max-height: 90vh;
    overflow-y: auto;
}

.modal-sm {
    max-width: 400px;
}

.modal-overlay.active .modal-card {
    transform: translateY(0);
}

@media (min-width: 768px) {
    .modal-overlay {
        align-items: center;
    }
    .modal-card {
        border-radius: var(--radius-lg);
        transform: scale(0.9);
        opacity: 0;
    }
    .modal-overlay.active .modal-card {
        transform: scale(1);
        opacity: 1;
    }
}

.modal-header {
    margin-bottom: 20px;
}
.modal-header h3 {
    font-size: 18px;
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    margin-top: 24px;
}
.modal-footer button {
    flex: 1;
}
@media (min-width: 768px) {
    .modal-footer button {
        flex: none;
    }
}

/* Modal Loading State */
.modal-loading {
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(255, 255, 255, 0.8);
    backdrop-filter: blur(2px);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    border-radius: inherit;
    z-index: 10;
    opacity: 0;
    visibility: hidden;
    transition: var(--transition);
}
.modal-loading.active {
    opacity: 1;
    visibility: visible;
}

.spinner {
    width: 40px;
    height: 40px;
    border: 4px solid var(--bg-secondary);
    border-top: 4px solid var(--accent-primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 12px;
}
@keyframes spin { 0% { transform: rotate(0deg); } 100% { transform: rotate(360deg); } }

/* Video Preview Modal */
.video-modal-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background-color: var(--bg-video-overlay);
    backdrop-filter: blur(5px);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 2000;
    opacity: 0;
    visibility: hidden;
    transition: var(--transition);
}
.video-modal-overlay.active {
    opacity: 1;
    visibility: visible;
}

.video-modal-container {
    width: 100%;
    max-width: 800px;
    padding: 20px;
    position: relative;
}

#preview-video {
    width: 100%;
    max-height: 80vh;
    border-radius: var(--radius-md);
    background: #000;
    box-shadow: var(--shadow-modal);
}

.video-close-btn {
    position: absolute;
    top: -30px;
    right: 20px;
    background: transparent;
    border: none;
    color: white;
    font-size: 32px;
    cursor: pointer;
    line-height: 1;
    opacity: 0.8;
}
.video-close-btn:hover {
    opacity: 1;
}
@media (min-width: 768px) {
    .video-close-btn {
        top: 20px;
        right: -30px;
    }
}

/* Toast Notifications */
#toast-container {
    position: fixed;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 3000;
    display: flex;
    flex-direction: column;
    gap: 10px;
    pointer-events: none;
}

.toast {
    padding: 12px 24px;
    border-radius: var(--radius-lg);
    color: white;
    font-size: 14px;
    font-weight: 500;
    box-shadow: var(--shadow-modal);
    transform: translateY(-20px);
    opacity: 0;
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}
.toast.show {
    transform: translateY(0);
    opacity: 1;
}

.toast.success { background-color: var(--status-done); }
.toast.error { background-color: var(--status-failed); }

/* Flash messages for login */
.flash-messages { margin-bottom: 20px; }
.flash-message {
    padding: 10px 14px;
    border-radius: var(--radius-sm);
    font-size: 14px;
    margin-bottom: 8px;
}
.flash-message.error { background: #fadbd8; color: #c0392b; border: 1px solid #f5b7b1; }
.flash-message.success { background: #d4efdf; color: #1e8449; border: 1px solid #a9dfbf; }
