/* ===== Reset & Base ===== */
* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

:root {
    --primary: #3B82F6;
    --primary-dark: #2563EB;
    --primary-light: #EFF6FF;
    --danger: #EF4444;
    --danger-light: #FEE2E2;
    --success: #22C55E;
    --warning: #F59E0B;
    --text-primary: #1F2937;
    --text-secondary: #6B7280;
    --text-tertiary: #9CA3AF;
    --bg-page: #F9FAFB;
    --bg-card: #FFFFFF;
    --border: #E5E7EB;
    --border-light: #F3F4F6;
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --shadow: 0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
    --shadow-md: 0 4px 6px rgba(0,0,0,0.05), 0 2px 4px rgba(0,0,0,0.04);
    --tab-height: 56px;
}

html, body {
    height: 100%;
    overscroll-behavior-y: contain;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", "Segoe UI", Roboto, sans-serif;
    background: var(--bg-page);
    color: var(--text-primary);
    font-size: 14px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

#app {
    max-width: 480px;
    margin: 0 auto;
    min-height: 100vh;
    position: relative;
    background: var(--bg-page);
}

/* ===== Pages ===== */
.page {
    display: none;
    min-height: 100vh;
    padding-bottom: calc(var(--tab-height) + env(safe-area-inset-bottom) + 16px);
}

.page.active { display: block; }

.sub-page { padding-bottom: 32px; }

.page-header {
    padding: 20px 16px 12px;
}

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

.page-header p {
    font-size: 13px;
    color: var(--text-secondary);
    margin-top: 4px;
}

.page-body { padding: 0 16px; }

/* ===== Sub Navigation ===== */
.sub-nav {
    display: flex;
    align-items: center;
    padding: 12px 16px;
    background: var(--bg-card);
    border-bottom: 1px solid var(--border-light);
    position: sticky;
    top: 0;
    z-index: 50;
    padding-top: calc(12px + env(safe-area-inset-top));
}

.back-btn {
    background: none;
    border: none;
    padding: 4px;
    color: var(--text-primary);
    cursor: pointer;
    display: flex;
    align-items: center;
    margin-right: 8px;
}

.sub-title {
    font-size: 17px;
    font-weight: 600;
}

/* ===== Tab Bar ===== */
.tab-bar {
    position: fixed;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 100%;
    max-width: 480px;
    height: calc(var(--tab-height) + env(safe-area-inset-bottom));
    background: var(--bg-card);
    border-top: 1px solid var(--border-light);
    display: flex;
    z-index: 100;
    padding-bottom: env(safe-area-inset-bottom);
}

.tab-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    color: var(--text-tertiary);
    cursor: pointer;
    transition: color 0.2s;
    padding-top: 6px;
}

.tab-item.active { color: var(--primary); }
.tab-item span { font-size: 11px; font-weight: 500; }

/* ===== Buttons ===== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 10px 20px;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s;
    text-align: center;
    line-height: 1.4;
}

.btn:active { transform: scale(0.97); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }

.btn-primary {
    background: var(--primary);
    color: #fff;
}

.btn-primary:active { background: var(--primary-dark); }

.btn-outline {
    background: var(--bg-card);
    border: 1px solid var(--border);
    color: var(--text-secondary);
}

.btn-danger {
    background: var(--danger-light);
    color: var(--danger);
    border: 1px solid transparent;
}

.btn-block { display: flex; width: 100%; }

.btn-sm { padding: 6px 14px; font-size: 13px; }

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

.form-group label {
    display: block;
    font-size: 13px;
    color: var(--text-secondary);
    margin-bottom: 6px;
    font-weight: 500;
}

.form-group input,
.form-group textarea,
.form-group select {
    width: 100%;
    padding: 12px 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 14px;
    color: var(--text-primary);
    background: var(--bg-card);
    outline: none;
    transition: border-color 0.2s;
    font-family: inherit;
}

.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus {
    border-color: var(--primary);
}

.form-group textarea { resize: vertical; min-height: 60px; }

.file-check-list {
    max-height: 220px;
    overflow-y: auto;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--bg-card);
}

.file-check-option {
    display: flex !important;
    align-items: center;
    gap: 10px;
    margin: 0 !important;
    padding: 11px 12px;
    border-bottom: 1px solid var(--border-light);
    color: var(--text-primary) !important;
    cursor: pointer;
}

.file-check-option:last-child { border-bottom: 0; }

.file-check-option input {
    width: 18px !important;
    height: 18px;
    flex: 0 0 18px;
    padding: 0 !important;
}

.file-check-name {
    min-width: 0;
    overflow-wrap: anywhere;
}

.file-check-empty {
    padding: 18px 12px;
    text-align: center;
    color: var(--text-tertiary);
    font-size: 13px;
}

.code-binding-options {
    display: grid;
    gap: 8px;
}

.code-binding-option {
    display: flex !important;
    align-items: flex-start;
    gap: 10px;
    margin: 0 !important;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--bg-card);
    cursor: pointer;
}

.code-binding-option.selected {
    border-color: var(--primary);
    background: var(--primary-light);
}

.code-binding-option.disabled {
    opacity: .55;
    cursor: not-allowed;
}

.code-binding-option input {
    width: 18px !important;
    height: 18px;
    flex: 0 0 18px;
    margin-top: 1px;
    padding: 0 !important;
}

.code-binding-option span {
    display: grid;
    gap: 2px;
    min-width: 0;
}

.code-binding-option strong { color: var(--text-primary); font-size: 13px; }
.code-binding-option small,
.form-hint { color: var(--text-tertiary); font-size: 12px; line-height: 1.45; }
.form-hint { margin-top: 6px; }

/* ===== Cards ===== */
.card {
    background: var(--bg-card);
    border-radius: var(--radius-md);
    padding: 16px;
    margin-bottom: 12px;
    box-shadow: var(--shadow);
}

/* ===== Empty State ===== */
.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-tertiary);
}

.empty-state svg {
    margin-bottom: 12px;
    opacity: 0.3;
}

.empty-state .empty-text { font-size: 14px; }
.empty-state .empty-hint { font-size: 12px; margin-top: 6px; color: var(--text-tertiary); }

/* ===== File Item (Home) ===== */
.file-item {
    background: var(--bg-card);
    border-radius: var(--radius-md);
    padding: 14px;
    margin-bottom: 10px;
    box-shadow: var(--shadow);
}

.file-item .file-name {
    font-size: 14px;
    font-weight: 600;
    margin-bottom: 6px;
    word-break: break-all;
    color: var(--text-primary);
}

.file-item .file-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    font-size: 12px;
    color: var(--text-tertiary);
    margin-bottom: 10px;
}

.file-item .file-meta .meta-tag {
    display: inline-flex;
    align-items: center;
    gap: 3px;
}

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

.file-item .file-actions .btn {
    flex: 1;
    padding: 8px;
    font-size: 13px;
}

/* ===== Redeem Card (Discover) ===== */
.redeem-card {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    padding: 32px 24px;
    text-align: center;
    box-shadow: var(--shadow);
}

.redeem-icon {
    width: 72px;
    height: 72px;
    margin: 0 auto 16px;
    background: var(--primary-light);
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--primary);
}

.redeem-card h2 {
    font-size: 20px;
    font-weight: 700;
    margin-bottom: 8px;
}

.redeem-subtitle {
    font-size: 13px;
    color: var(--text-secondary);
    margin-bottom: 24px;
}

.redeem-card .form-group { text-align: left; }

.redeem-card .form-group input {
    text-align: center;
    text-transform: uppercase;
    letter-spacing: 3px;
    font-size: 16px;
    font-weight: 600;
}

/* ===== Profile ===== */
.profile-card {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    padding: 24px 16px;
    text-align: center;
    box-shadow: var(--shadow);
    margin-bottom: 16px;
}

.profile-avatar {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    background: var(--primary);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 26px;
    font-weight: 700;
    margin: 0 auto 12px;
}

.profile-username {
    font-size: 17px;
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.profile-email {
    font-size: 13px;
    color: var(--text-tertiary);
    margin-top: 4px;
}

.badge {
    display: inline-block;
    padding: 2px 10px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 500;
}

.badge-admin { background: #FEF3C7; color: #D97706; }
.badge-developer { background: var(--primary-light); color: var(--primary); }
.badge-user { background: #DCFCE7; color: #16A34A; }

/* ===== Menu List ===== */
.menu-list {
    background: var(--bg-card);
    border-radius: var(--radius-md);
    overflow: hidden;
    box-shadow: var(--shadow);
}

.menu-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 16px;
    border-bottom: 1px solid var(--border-light);
    cursor: pointer;
    transition: background 0.15s;
}

.menu-item:last-child { border-bottom: none; }
.menu-item:active { background: var(--border-light); }

.menu-item .menu-left {
    display: flex;
    align-items: center;
    gap: 12px;
}

.menu-item .menu-icon {
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--primary);
}

.menu-item .menu-icon.danger { color: var(--danger); }

.menu-item .menu-label { font-size: 14px; font-weight: 500; }

.menu-item .menu-arrow { color: var(--text-tertiary); }

/* ===== Search Bar ===== */
.search-bar {
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 10px 12px;
    margin-bottom: 12px;
    color: var(--text-tertiary);
}

.search-bar input {
    flex: 1;
    border: none;
    outline: none;
    font-size: 14px;
    background: transparent;
    color: var(--text-primary);
}

/* ===== Action Row ===== */
.action-row {
    display: flex;
    gap: 8px;
    margin-bottom: 12px;
}

.action-row .btn { flex: 1; }

/* ===== Bulk Code Actions ===== */
.bulk-code-toolbar {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
    background: var(--bg-card);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-md);
    padding: 10px 12px;
    margin-bottom: 12px;
}

.bulk-code-select-all {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    color: var(--text-secondary);
    font-size: 13px;
    cursor: pointer;
    white-space: nowrap;
}

.bulk-code-select-all input,
.code-select-checkbox {
    width: 17px;
    height: 17px;
    margin: 0;
    accent-color: var(--primary);
    flex-shrink: 0;
}

.bulk-code-count {
    color: var(--text-tertiary);
    font-size: 12px;
    white-space: nowrap;
}

.bulk-code-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-left: auto;
}

.bulk-code-actions .btn { flex: none; }
.bulk-code-actions .btn:disabled { cursor: not-allowed; opacity: .5; }

/* ===== Code Item ===== */
.code-item {
    background: var(--bg-card);
    border-radius: var(--radius-md);
    padding: 14px;
    margin-bottom: 10px;
    box-shadow: var(--shadow);
}

.code-item .code-header {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
}

.code-select-wrap {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
    cursor: pointer;
}

.code-item .code-text {
    min-width: 0;
    font-family: "SF Mono", "Cascadia Code", Consolas, monospace;
    font-size: 16px;
    font-weight: 700;
    letter-spacing: 2px;
    color: var(--primary);
}

.code-item .code-actions {
    display: flex;
    gap: 6px;
}

.code-item .code-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    font-size: 12px;
    color: var(--text-tertiary);
}

.code-file-summary {
    max-width: 100%;
    overflow-wrap: anywhere;
}

.code-item .code-status {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 11px;
    font-weight: 500;
}

.code-status-active { background: #DCFCE7; color: #16A34A; }
.code-status-disabled { background: #FEE2E2; color: #DC2626; }
.code-status-expired { background: #F3F4F6; color: #6B7280; }

.copy-btn {
    background: var(--border-light);
    border: none;
    padding: 4px 10px;
    border-radius: 6px;
    font-size: 12px;
    color: var(--text-secondary);
    cursor: pointer;
}

.copy-btn:active { background: var(--border); }

/* ===== Stats Grid (Admin) ===== */
.stats-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin-bottom: 16px;
}

.stat-card {
    background: var(--bg-card);
    border-radius: var(--radius-md);
    padding: 16px;
    box-shadow: var(--shadow);
    text-align: center;
}

.stat-card .stat-value {
    font-size: 28px;
    font-weight: 700;
    color: var(--primary);
}

.stat-card .stat-label {
    font-size: 12px;
    color: var(--text-secondary);
    margin-top: 4px;
}

/* ===== Tab Switcher ===== */
.tab-switcher {
    display: flex;
    background: var(--border-light);
    border-radius: var(--radius-sm);
    padding: 3px;
    margin-bottom: 14px;
}

.tab-switch {
    flex: 1;
    padding: 8px;
    border: none;
    background: none;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.2s;
}

.tab-switch.active {
    background: var(--bg-card);
    color: var(--primary);
    box-shadow: var(--shadow);
}

/* ===== User Item (Admin) ===== */
.user-item {
    background: var(--bg-card);
    border-radius: var(--radius-md);
    padding: 14px;
    margin-bottom: 10px;
    box-shadow: var(--shadow);
}

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

.user-item .user-name {
    font-size: 15px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 8px;
}

.user-item .user-email {
    font-size: 12px;
    color: var(--text-tertiary);
}

.user-item .user-actions {
    display: flex;
    gap: 6px;
    margin-top: 10px;
}

.user-item .user-actions .btn {
    flex: 1;
    padding: 6px;
    font-size: 12px;
}

/* ===== Upload Area ===== */
.upload-area {
    border: 2px dashed var(--border);
    border-radius: var(--radius-md);
    padding: 36px 20px;
    text-align: center;
    margin-bottom: 16px;
    cursor: pointer;
    transition: all 0.2s;
    color: var(--text-tertiary);
}

.upload-area:hover, .upload-area.dragover {
    border-color: var(--primary);
    background: var(--primary-light);
    color: var(--primary);
}

.upload-text {
    font-size: 14px;
    margin-top: 10px;
}

.file-info-box {
    background: var(--primary-light);
    border-radius: var(--radius-sm);
    padding: 12px 14px;
    margin-bottom: 16px;
    font-size: 13px;
    color: var(--text-primary);
}

.file-info-box .file-info-name { font-weight: 600; }
.file-info-box .file-info-size { color: var(--text-secondary); margin-top: 2px; }

.transfer-progress {
    min-height: 48px;
    margin-bottom: 16px;
    padding: 10px 12px;
    border: 1px solid var(--border-light);
    border-radius: var(--radius-sm);
    background: var(--bg-card);
}

.transfer-progress[hidden] { display: none; }

.transfer-progress-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    min-width: 0;
    margin-bottom: 8px;
    font-size: 12px;
    color: var(--text-secondary);
}

.transfer-progress-header span:first-child {
    min-width: 0;
    overflow-wrap: anywhere;
}

.transfer-progress-header span:last-child {
    flex-shrink: 0;
    font-variant-numeric: tabular-nums;
}

.transfer-progress-track {
    position: relative;
    height: 7px;
    overflow: hidden;
    border-radius: 4px;
    background: var(--border-light);
}

.transfer-progress-fill {
    width: 0;
    height: 100%;
    border-radius: inherit;
    background: var(--primary);
    transition: width 0.15s linear;
}

.transfer-progress.indeterminate .transfer-progress-fill {
    width: 36%;
    animation: transfer-progress-slide 1.1s ease-in-out infinite;
}

.cloud-target-field { margin-top: 14px; }

.admin-files-more {
    display: flex;
    justify-content: center;
    padding: 8px 0 4px;
}

/* ===== Admin file push ===== */
.admin-tip-card {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    background: var(--primary-light);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-md);
    padding: 12px 14px;
    margin-bottom: 14px;
    color: var(--text-secondary);
    font-size: 12px;
    line-height: 1.55;
}

.admin-tip-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 auto;
    color: var(--primary);
    margin-top: 1px;
}

.admin-tip-text { min-width: 0; }

.push-file-card {
    display: flex;
    align-items: center;
    gap: 12px;
    background: var(--primary-light);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-md);
    padding: 14px;
    margin-bottom: 18px;
}

.push-file-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    flex: 0 0 auto;
    border-radius: var(--radius-md);
    background: var(--primary);
    color: #fff;
}

.push-file-info { flex: 1; min-width: 0; }
.push-file-name { color: var(--text-primary); font-size: 14px; font-weight: 700; overflow-wrap: anywhere; }
.push-file-meta { color: var(--text-secondary); font-size: 12px; margin-top: 2px; }

.push-selected-bar {
    min-height: 18px;
    margin-top: 8px;
    color: var(--text-secondary);
    font-size: 12px;
}

.push-user-list {
    max-height: 260px;
    margin-top: 4px;
    overflow-y: auto;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--bg-card);
}

.push-user-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    border-bottom: 1px solid var(--border-light);
    cursor: pointer;
    transition: background .15s;
}

.push-user-item:last-child { border-bottom: none; }
.push-user-item:hover { background: var(--primary-light); }
.push-user-item.selected { background: var(--primary-light); }
.push-user-item.disabled { cursor: not-allowed; opacity: .58; }
.push-user-item input[type="checkbox"] { width: 18px; height: 18px; flex: 0 0 auto; accent-color: var(--primary); }

.push-user-avatar {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    flex: 0 0 auto;
    border-radius: 50%;
    background: var(--primary);
    color: #fff;
    font-size: 15px;
    font-weight: 700;
}

.push-user-detail { flex: 1; min-width: 0; }
.push-user-name { color: var(--text-primary); font-size: 14px; font-weight: 600; overflow-wrap: anywhere; }
.push-user-email { color: var(--text-tertiary); font-size: 12px; overflow-wrap: anywhere; }
.push-user-status { color: var(--danger); font-size: 11px; font-weight: 500; }

/* ===== Notification file attachment ===== */
.notif-file-attach {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-top: 10px;
    padding: 10px;
    border: 1px solid var(--border-light);
    border-radius: var(--radius-sm);
    background: var(--primary-light);
}

.notif-file-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 38px;
    flex: 0 0 auto;
    border-radius: var(--radius-sm);
    background: var(--primary);
    color: #fff;
}

.notif-file-info { flex: 1; min-width: 0; }
.notif-file-name { color: var(--text-primary); font-size: 13px; font-weight: 700; overflow-wrap: anywhere; }
.notif-file-size { color: var(--text-secondary); font-size: 11px; margin-top: 1px; }

@keyframes transfer-progress-slide {
    from { transform: translateX(-110%); }
    to { transform: translateX(290%); }
}

/* ===== Hint Box ===== */
.hint-box {
    background: #FFFBEB;
    border: 1px solid #FDE68A;
    border-radius: var(--radius-sm);
    padding: 12px;
    font-size: 13px;
    color: #92400E;
    margin-bottom: 14px;
}

.hint-title { font-weight: 600; margin-bottom: 4px; }

/* ===== Import Modal ===== */
.import-file-display {
    text-align: center;
    padding: 20px 0;
}

.import-file-icon {
    color: var(--primary);
    margin-bottom: 10px;
}

.import-filename {
    font-size: 15px;
    font-weight: 600;
    margin-bottom: 4px;
    word-break: break-all;
}

.import-size { font-size: 13px; color: var(--text-tertiary); }

/* ===== Modal ===== */
.modal-mask {
    display: none;
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.5);
    z-index: 1000;
    justify-content: center;
    align-items: center;
    padding: 20px;
}

.modal-mask.show { display: flex; }

.modal {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    width: 100%;
    max-width: 380px;
    padding: 24px;
    max-height: 85vh;
    overflow-y: auto;
}

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

.modal-header h3 { font-size: 18px; font-weight: 700; }

.modal-close-btn {
    background: none;
    border: none;
    padding: 4px;
    color: var(--text-tertiary);
    cursor: pointer;
    display: flex;
}

.code-input-row {
    display: flex;
    gap: 10px;
    align-items: stretch;
}

.code-input-row input {
    flex: 1;
    min-width: 0;
}

.code-input-row .btn {
    white-space: nowrap;
    flex-shrink: 0;
}

.code-input-row .btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.auth-hint {
    text-align: center;
    margin-top: 14px;
    font-size: 12px;
    color: var(--text-tertiary);
}

/* ===== Toast ===== */
.toast {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(0,0,0,0.8);
    color: #fff;
    padding: 12px 24px;
    border-radius: var(--radius-sm);
    font-size: 14px;
    z-index: 2000;
    opacity: 0;
    transition: opacity 0.25s;
    pointer-events: none;
    white-space: nowrap;
    max-width: 90vw;
}

.toast.show { opacity: 1; }

/* ===== Loading ===== */
.loading-spinner {
    display: inline-block;
    width: 16px;
    height: 16px;
    border: 2px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

.loading-center {
    text-align: center;
    padding: 40px;
    color: var(--text-tertiary);
}

/* ===== Header Row (bell button) ===== */
.header-row {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
}

.bell-btn {
    position: relative;
    background: none;
    border: none;
    padding: 4px;
    color: var(--text-secondary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

.bell-badge {
    position: absolute;
    top: -2px;
    right: -2px;
    min-width: 16px;
    height: 16px;
    border-radius: 8px;
    background: var(--danger);
    color: #fff;
    font-size: 10px;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 4px;
}

/* ===== Notification List ===== */
.notif-item {
    padding: 14px 0;
    border-bottom: 1px solid var(--border-light);
    cursor: pointer;
}

.notif-item:last-child { border-bottom: none; }

.notif-item.unread {
    background: var(--primary-light);
    margin: 0 -24px;
    padding: 14px 24px;
}

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

.notif-item .notif-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
}

.notif-item .notif-time {
    font-size: 11px;
    color: var(--text-tertiary);
}

.notif-item .notif-content {
    font-size: 13px;
    color: var(--text-secondary);
    line-height: 1.5;
}

.notif-item .unread-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--danger);
    display: inline-block;
    margin-right: 6px;
    vertical-align: middle;
}

.notif-actions {
    display: flex;
    justify-content: flex-end;
    margin-top: 12px;
}

/* ===== Cloud Storage ===== */
.quota-bar-card {
    background: var(--bg-card);
    border-radius: var(--radius-md);
    padding: 16px;
    margin-bottom: 14px;
    box-shadow: var(--shadow);
}

.quota-bar-header {
    display: flex;
    justify-content: space-between;
    font-size: 13px;
    color: var(--text-secondary);
    margin-bottom: 8px;
}

.quota-bar-header .quota-used {
    font-weight: 600;
    color: var(--text-primary);
}

.quota-bar-track {
    width: 100%;
    height: 8px;
    background: var(--border-light);
    border-radius: 4px;
    overflow: hidden;
}

.quota-bar-fill {
    height: 100%;
    background: var(--primary);
    border-radius: 4px;
    transition: width 0.3s;
}

.quota-bar-fill.full {
    background: var(--danger);
}

.cloud-file-item {
    background: var(--bg-card);
    border-radius: var(--radius-md);
    padding: 14px;
    margin-bottom: 10px;
    box-shadow: var(--shadow);
}

.cloud-file-item .cloud-file-name {
    font-size: 14px;
    font-weight: 600;
    margin-bottom: 6px;
    word-break: break-all;
}

.cloud-file-item .cloud-file-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    font-size: 12px;
    color: var(--text-tertiary);
    margin-bottom: 10px;
}

.cloud-file-item .cloud-file-actions {
    display: flex;
    gap: 8px;
}

.cloud-file-item .cloud-file-actions .btn {
    flex: 1;
    padding: 8px;
    font-size: 13px;
}

/* ===== About Page ===== */
.admin-setting-card {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    background: var(--bg-card);
    border-radius: var(--radius-md);
    padding: 14px 16px;
    margin-bottom: 14px;
    box-shadow: var(--shadow);
}

.admin-setting-title { font-size: 14px; font-weight: 600; }
.admin-setting-desc { margin-top: 4px; color: var(--text-tertiary); font-size: 12px; line-height: 1.5; }
.setting-inline-control { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }
.setting-inline-control input { width: 76px; padding: 8px 10px; }
.switch { position: relative; display: inline-block; width: 44px; height: 24px; flex-shrink: 0; }
.switch input { width: 0; height: 0; opacity: 0; }
.slider { position: absolute; inset: 0; cursor: pointer; background: var(--border); border-radius: 24px; transition: .2s; }
.slider::before { content: ''; position: absolute; width: 18px; height: 18px; left: 3px; top: 3px; background: #fff; border-radius: 50%; transition: .2s; box-shadow: 0 1px 3px rgba(0,0,0,.2); }
.switch input:checked + .slider { background: var(--primary); }
.switch input:checked + .slider::before { transform: translateX(20px); }

.about-card {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    padding: 40px 24px;
    text-align: center;
    box-shadow: var(--shadow);
    margin-bottom: 16px;
}

.about-logo {
    width: 72px;
    height: 72px;
    border-radius: var(--radius-lg);
    display: flex;
    align-items: center;
    justify-content: center;
    object-fit: cover;
    margin: 0 auto 16px;
}

.about-name {
    font-size: 22px;
    font-weight: 700;
    margin-bottom: 4px;
}

.about-version {
    font-size: 13px;
    color: var(--text-tertiary);
    margin-bottom: 12px;
}

.about-desc {
    font-size: 13px;
    color: var(--text-secondary);
    line-height: 1.6;
}

.about-update-actions {
    display: flex;
    justify-content: center;
    margin-top: 18px;
}

.about-section {
    background: var(--bg-card);
    border-radius: var(--radius-md);
    padding: 16px;
    box-shadow: var(--shadow);
}

.about-section-title {
    font-size: 15px;
    font-weight: 600;
    margin-bottom: 14px;
}

.about-item {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    font-size: 13px;
    color: var(--text-secondary);
    line-height: 1.6;
    margin-bottom: 10px;
}

.about-item:last-child { margin-bottom: 0; }

.about-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--primary);
    flex-shrink: 0;
    margin-top: 7px;
}

/* ===== Author Name in File List ===== */
.file-author {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    color: var(--primary);
    font-weight: 500;
}

/* ===== Profile Edit Icon ===== */
.profile-edit-btn {
    background: var(--border-light);
    border: none;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-tertiary);
    cursor: pointer;
    margin-left: 8px;
}

.profile-edit-btn:active {
    background: var(--border);
}

/* ===== Visual refresh =====
   Keep the existing component contract intact while giving the app a clearer
   brand language, stronger hierarchy, and a more deliberate desktop shell. */
:root {
    --primary: #0F7185;
    --primary-dark: #0A5263;
    --primary-light: #E5F5F7;
    --accent: #F2A33A;
    --accent-light: #FFF4E4;
    --danger: #C94B36;
    --danger-light: #FDE9E4;
    --success: #218B73;
    --warning: #C98221;
    --text-primary: #16323A;
    --text-secondary: #5B7379;
    --text-tertiary: #8BA0A5;
    --bg-page: #F3F7F8;
    --bg-card: #FFFFFF;
    --border: #D7E3E6;
    --border-light: #EAF1F2;
    --radius-sm: 10px;
    --radius-md: 16px;
    --radius-lg: 22px;
    --shadow: 0 2px 7px rgba(22, 50, 58, .05), 0 1px 2px rgba(22, 50, 58, .04);
    --shadow-md: 0 12px 30px rgba(22, 50, 58, .10), 0 2px 6px rgba(22, 50, 58, .06);
    --tab-height: 62px;
}

html { background: #E8EFF1; }

body {
    background: #E8EFF1;
    color: var(--text-primary);
    letter-spacing: 0;
    overflow-x: hidden;
}

button, input, textarea, select { font: inherit; }

:focus-visible {
    outline: 3px solid rgba(15, 113, 133, .28);
    outline-offset: 2px;
}

#app {
    background: var(--bg-page);
    border-left: 1px solid rgba(22, 50, 58, .04);
    border-right: 1px solid rgba(22, 50, 58, .04);
}

.page {
    background: var(--bg-page);
}

.page-header {
    padding: 24px 20px 16px;
}

.page-header h1 {
    font-size: 26px;
    line-height: 1.2;
    letter-spacing: -.01em;
}

.page-header p {
    color: var(--text-secondary);
    margin-top: 6px;
}

.page-body { padding: 0 20px; }

.sub-nav {
    padding-left: 20px;
    padding-right: 20px;
    background: rgba(255, 255, 255, .94);
    border-bottom-color: var(--border-light);
    box-shadow: 0 1px 0 rgba(22, 50, 58, .02);
    backdrop-filter: blur(12px);
}

.back-btn {
    width: 36px;
    height: 36px;
    margin-right: 8px;
    border-radius: 12px;
    color: var(--text-secondary);
    justify-content: center;
    transition: background .18s, color .18s;
}

.back-btn:hover, .back-btn:focus-visible {
    background: var(--primary-light);
    color: var(--primary);
    outline: none;
}

.sub-title { font-size: 18px; letter-spacing: -.01em; }

.tab-bar {
    height: calc(var(--tab-height) + env(safe-area-inset-bottom));
    background: rgba(255, 255, 255, .96);
    border-top: 1px solid rgba(215, 227, 230, .9);
    box-shadow: 0 -10px 28px rgba(22, 50, 58, .07);
    backdrop-filter: blur(16px);
}

.tab-item {
    gap: 3px;
    padding-top: 7px;
    color: var(--text-tertiary);
    transition: color .18s, transform .18s;
}

.tab-item svg { transition: background .18s, color .18s, transform .18s; }
.tab-item.active { color: var(--primary); }
.tab-item.active svg {
    width: 34px;
    height: 34px;
    padding: 6px;
    border-radius: 12px;
    background: var(--primary-light);
    transform: translateY(-1px);
}
.tab-item span { font-size: 11px; font-weight: 600; }

.btn {
    min-height: 42px;
    padding: 10px 18px;
    border-radius: 11px;
    font-weight: 600;
    box-shadow: 0 1px 1px rgba(22, 50, 58, .03);
    transition: transform .15s, background .18s, border-color .18s, box-shadow .18s, color .18s;
}

.btn:hover:not(:disabled) { box-shadow: 0 5px 12px rgba(22, 50, 58, .10); }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--primary-dark); }
.btn-primary:focus-visible, .btn-outline:focus-visible, .btn-danger:focus-visible {
    outline: 3px solid rgba(15, 113, 133, .20);
    outline-offset: 2px;
}
.btn-outline {
    background: #fff;
    border-color: var(--border);
    color: var(--text-secondary);
}
.btn-outline:hover:not(:disabled) {
    color: var(--primary);
    border-color: rgba(15, 113, 133, .45);
    background: var(--primary-light);
}
.btn-danger {
    background: var(--danger-light);
    color: var(--danger);
}
.btn-danger:hover:not(:disabled) { background: #F9D7D0; }
.btn-sm { min-height: 36px; padding: 7px 13px; font-size: 13px; }

.form-group { margin-bottom: 18px; }

.form-group label {
    color: var(--text-secondary);
    font-size: 12px;
    letter-spacing: .02em;
    margin-bottom: 7px;
}

.form-group input,
.form-group textarea,
.form-group select {
    min-height: 46px;
    padding: 11px 13px;
    border-color: var(--border);
    border-radius: 11px;
    background: #FCFEFE;
    box-shadow: inset 0 1px 2px rgba(22, 50, 58, .02);
}

.form-group input::placeholder,
.form-group textarea::placeholder,
.search-bar input::placeholder { color: #A3B2B6; }

.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus,
.search-bar:focus-within {
    border-color: rgba(15, 113, 133, .62);
    box-shadow: 0 0 0 3px rgba(15, 113, 133, .12);
}

.card,
.file-item,
.cloud-file-item,
.code-item,
.user-item,
.stat-card,
.quota-bar-card,
.admin-setting-card,
.about-card,
.about-section,
.profile-card,
.menu-list,
.redeem-card {
    border: 1px solid var(--border-light);
    box-shadow: var(--shadow);
}

.card { padding: 18px; border-radius: var(--radius-md); }

.empty-state { padding: 72px 20px; }
.empty-state svg { color: var(--primary); opacity: .35; }
.empty-state .empty-text { color: var(--text-secondary); font-weight: 600; }

.file-item,
.cloud-file-item,
.code-item,
.user-item {
    padding: 16px;
    border-radius: var(--radius-md);
    transition: transform .18s, box-shadow .18s, border-color .18s;
}

.file-item:hover,
.cloud-file-item:hover,
.code-item:hover,
.user-item:hover {
    transform: translateY(-1px);
    border-color: #C7DDE1;
    box-shadow: var(--shadow-md);
}

.file-item .file-name,
.cloud-file-item .cloud-file-name { font-size: 15px; letter-spacing: -.01em; }
.file-item .file-meta,
.cloud-file-item .cloud-file-meta,
.code-item .code-meta { color: var(--text-tertiary); }
.file-item .file-actions .btn,
.cloud-file-item .cloud-file-actions .btn { min-height: 38px; }

.redeem-card {
    padding: 36px 24px 28px;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
}

.redeem-icon {
    width: 78px;
    height: 78px;
    margin-bottom: 18px;
    border-radius: 22px;
    background: var(--primary-light);
    color: var(--primary);
    box-shadow: inset 0 0 0 1px rgba(15, 113, 133, .08);
}

.redeem-card h2 { font-size: 21px; letter-spacing: -.01em; }
.redeem-subtitle { color: var(--text-secondary); margin-bottom: 26px; }
.redeem-card .form-group input { background: #F9FCFC; }

.profile-card {
    padding: 28px 20px 24px;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    position: relative;
    overflow: hidden;
}

.profile-card::before {
    content: '';
    display: block;
    height: 4px;
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    background: var(--primary);
}

.profile-avatar {
    width: 68px;
    height: 68px;
    background: var(--primary);
    box-shadow: 0 0 0 6px var(--primary-light), 0 8px 18px rgba(15, 113, 133, .22);
}

.profile-username { margin-top: 4px; font-size: 18px; }
.profile-email { color: var(--text-secondary); }

.badge { padding: 3px 10px; font-weight: 600; }
.badge-admin { background: var(--accent-light); color: #A76713; }
.badge-developer { background: var(--primary-light); color: var(--primary); }
.badge-user { background: #E3F4EC; color: #1C7A62; }

.menu-list { border-radius: var(--radius-md); }
.menu-item { padding: 15px 16px; border-bottom-color: var(--border-light); }
.menu-item:hover { background: #F8FBFB; }
.menu-item .menu-left { gap: 13px; }
.menu-item .menu-icon {
    width: 34px;
    height: 34px;
    border-radius: 11px;
    background: var(--primary-light);
    color: var(--primary);
}
.menu-item .menu-icon.danger { background: var(--danger-light); color: var(--danger); }
.menu-item .menu-label { font-size: 14px; color: var(--text-primary); }
.menu-item .menu-arrow { color: #A3B2B6; }

.search-bar {
    min-height: 44px;
    border-color: var(--border);
    border-radius: 12px;
    background: #FCFEFE;
    color: var(--text-tertiary);
    box-shadow: inset 0 1px 2px rgba(22, 50, 58, .02);
}

.action-row { gap: 9px; margin-bottom: 14px; }
.action-row { flex-wrap: wrap; }
.action-row .btn { flex: 1 1 140px; min-width: 0; }

.bulk-code-toolbar {
    border-color: var(--border-light);
    border-radius: 13px;
    background: #FBFDFD;
    padding: 11px 13px;
}

.code-item .code-text { color: var(--primary); letter-spacing: 1.5px; }
.code-status-active { background: #E3F4EC; color: #1C7A62; }
.code-status-disabled { background: var(--danger-light); color: var(--danger); }
.code-status-expired { background: #EFF3F4; color: var(--text-secondary); }
.copy-btn { background: var(--primary-light); color: var(--primary); border-radius: 8px; font-weight: 600; }
.copy-btn:hover { background: #D4ECEF; }

.stats-grid { gap: 12px; }
.stat-card { padding: 18px 14px; border-radius: var(--radius-md); }
.stat-card .stat-value { color: var(--primary); font-size: 30px; }
.stat-card .stat-label { color: var(--text-secondary); }

.tab-switcher {
    background: #E7EFF0;
    border-radius: 12px;
    padding: 4px;
}
.tab-switch { min-height: 36px; padding: 8px 7px; border-radius: 9px; color: var(--text-secondary); }
.tab-switch.active { color: var(--primary); box-shadow: 0 2px 6px rgba(22, 50, 58, .08); }

.upload-area {
    border-color: #C8DADD;
    border-radius: var(--radius-md);
    background: rgba(255,255,255,.5);
    padding: 42px 20px;
    color: var(--text-tertiary);
}
.upload-area:hover, .upload-area.dragover { background: var(--primary-light); border-color: var(--primary); }
.upload-area svg { color: var(--primary); opacity: .85; }
.upload-text { color: var(--text-secondary); font-weight: 500; }
.file-info-box { background: var(--primary-light); border: 1px solid #CDE8EB; border-radius: 11px; }

.user-item .user-actions {
    flex-wrap: wrap;
    min-width: 0;
}

.user-item .user-actions .btn {
    flex: 1 1 120px;
    min-width: 0;
}

.transfer-progress { border-color: var(--border-light); border-radius: 11px; background: #FBFDFD; }
.transfer-progress-track { background: #E6EFF0; }
.transfer-progress-fill { background: var(--primary); }

.hint-box { background: var(--accent-light); border-color: #F5D39F; color: #8B5E18; border-radius: 11px; }

.quota-bar-card { border-radius: var(--radius-md); }
.quota-bar-track { background: #E6EFF0; height: 9px; }
.quota-bar-fill { background: var(--primary); }
.quota-bar-fill.full { background: var(--danger); }

.admin-setting-card { border-radius: var(--radius-md); padding: 16px; }
.admin-setting-title { font-size: 14px; }
.admin-setting-desc { color: var(--text-secondary); }
.slider { background: #C7D6D9; }
.switch input:checked + .slider { background: var(--primary); }

.about-card { padding: 42px 24px; border-radius: var(--radius-lg); box-shadow: var(--shadow-md); }
.about-logo { border-radius: 20px; box-shadow: 0 8px 20px rgba(15, 113, 133, .16); }
.about-name { font-size: 23px; }
.about-version { color: var(--text-secondary); }
.about-section { border-radius: var(--radius-md); }
.about-dot { background: var(--accent); }

.bell-btn {
    width: 40px;
    height: 40px;
    border-radius: 13px;
    color: var(--text-secondary);
    background: rgba(255,255,255,.72);
    border: 1px solid var(--border-light);
    box-shadow: var(--shadow);
}
.bell-btn:hover { color: var(--primary); background: var(--primary-light); }
.bell-badge { background: var(--accent); }

.modal-mask {
    background: rgba(17, 42, 49, .64);
    backdrop-filter: blur(7px);
    padding: 20px;
    overscroll-behavior: contain;
}

.modal {
    border: 1px solid rgba(255,255,255,.55);
    border-radius: 24px;
    padding: 28px;
    box-shadow: 0 24px 70px rgba(10, 43, 52, .26), 0 4px 18px rgba(10, 43, 52, .14);
    animation: modal-in .22s ease-out;
}

@keyframes modal-in {
    from { opacity: 0; transform: translateY(10px) scale(.98); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

.modal-header { margin-bottom: 22px; }
.modal-header h3 { font-size: 19px; letter-spacing: -.01em; }
.modal-close-btn { width: 32px; height: 32px; border-radius: 10px; justify-content: center; }
.modal-close-btn:hover { background: var(--border-light); color: var(--text-primary); }

#login-modal .modal { max-width: 420px; }
#login-modal .modal::before {
    content: '';
    display: block;
    width: 52px;
    height: 52px;
    margin-bottom: 15px;
    border-radius: 16px;
    background: url('../images/themekiy-icon.png') center / cover no-repeat;
    box-shadow: 0 8px 18px rgba(15, 113, 133, .14);
}
#login-modal .modal-header { margin-bottom: 20px; }
#login-modal .modal-header h3 { font-size: 23px; }
#login-modal .tab-switcher { margin-bottom: 22px !important; }
#login-modal .auth-hint { color: var(--text-tertiary); }

.toast {
    background: rgba(22, 50, 58, .94);
    border: 1px solid rgba(255,255,255,.12);
    border-radius: 12px;
    box-shadow: 0 12px 34px rgba(10, 43, 52, .22);
}

.loading-spinner { border-color: #D8E8EA; border-top-color: var(--primary); }

@media (min-width: 601px) {
    body { padding: 16px 0; }
    #app {
        max-width: 720px;
        min-height: calc(100vh - 32px);
        border-radius: 28px;
        box-shadow: 0 18px 60px rgba(22, 50, 58, .12), 0 0 0 1px rgba(22, 50, 58, .04);
        overflow: hidden;
    }
    .page { min-height: calc(100vh - 32px); }
    .tab-bar {
        bottom: 28px;
        width: min(640px, calc(100% - 48px));
        max-width: 640px;
        height: 66px;
        border: 1px solid rgba(215, 227, 230, .95);
        border-radius: 20px;
    }
    .stats-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}

@media (max-width: 600px) {
    body { background: var(--bg-page); }
    #app { max-width: 100%; border: 0; }
    .page-header { padding-top: calc(22px + env(safe-area-inset-top)); }
    .modal { padding: 24px 20px; }
    .modal-mask { align-items: center; padding: max(20px, env(safe-area-inset-top)) max(20px, env(safe-area-inset-right)) max(20px, env(safe-area-inset-bottom)); }
    .user-item .user-actions .btn { flex-basis: calc(50% - 4px); }
    .code-input-row { flex-wrap: wrap; }
    .code-input-row input { flex: 1 1 150px; }
    .code-input-row .btn { flex: 1 1 118px; }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: .01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: .01ms !important;
        scroll-behavior: auto !important;
    }
}
