*,
*::before,
*::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary: #4f46e5;
    --primary-hover: #4338ca;
    --bg: #f8fafc;
    --surface: #ffffff;
    --border: #e2e8f0;
    --text: #1e293b;
    --text-secondary: #64748b;
    --danger: #ef4444;
    --star: #f59e0b;
    --radius: 12px;
    --shadow: 0 1px 3px rgba(0, 0, 0, 0.08), 0 1px 2px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 10px 25px rgba(0, 0, 0, 0.08);
}

/* ==================== 深色模式 ==================== */
[data-theme="dark"] {
    --primary: #818cf8;
    --primary-hover: #6366f1;
    --bg: #0f172a;
    --surface: #1e293b;
    --border: #334155;
    --text: #f1f5f9;
    --text-secondary: #94a3b8;
    --danger: #f87171;
    --star: #fbbf24;
    --shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
    --shadow-lg: 0 10px 25px rgba(0, 0, 0, 0.3);
}

[data-theme="dark"] .panel textarea {
    background: var(--bg);
    color: var(--text);
}

[data-theme="dark"] .lang-select-wrap select {
    color: var(--text);
}

[data-theme="dark"] .auth-error {
    background: #1c1917;
    border-color: #7f1d1d;
}

[data-theme="dark"] .ocr-preview {
    border-color: var(--border);
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Noto Sans SC", sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    padding-top: 56px;
}

/* ==================== 顶部导航栏 ==================== */
.user-bar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 56px;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 1rem;
    z-index: 100;
    box-shadow: var(--shadow);
}

.logo {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--primary);
    text-decoration: none;
}

.nav-right {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

#auth-area, #user-area {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.nav-link {
    padding: 0.4rem 0.85rem;
    border-radius: 6px;
    font-size: 0.85rem;
    color: var(--text-secondary);
    text-decoration: none;
    transition: all 0.2s;
}

.nav-link:hover {
    background: var(--bg);
    color: var(--primary);
}

.username {
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text);
}

.logout-btn {
    background: none;
    border: none;
    cursor: pointer;
    font-family: inherit;
}

/* ==================== 用户下拉菜单 ==================== */
.user-dropdown-wrap {
    position: relative;
}

.user-dropdown-toggle {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 0.3rem 0.6rem;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--surface);
    cursor: pointer;
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text);
    font-family: inherit;
    transition: all 0.2s;
}

.user-dropdown-toggle:hover {
    border-color: var(--primary);
    color: var(--primary);
}

.user-dropdown-toggle .ud-arrow {
    font-size: 0.6rem;
    transition: transform 0.2s;
}

.user-dropdown-wrap.open .ud-arrow {
    transform: rotate(180deg);
}

.user-dropdown {
    display: none;
    position: absolute;
    top: calc(100% + 6px);
    right: 0;
    min-width: 220px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 10px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
    z-index: 200;
    overflow: hidden;
}

[data-theme="dark"] .user-dropdown {
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
}

.user-dropdown-wrap.open .user-dropdown {
    display: block;
}

.ud-header {
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--border);
}

.ud-username {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text);
}

.ud-meta {
    font-size: 0.72rem;
    color: var(--text-secondary);
    margin-top: 2px;
}

.ud-menu {
    padding: 0.4rem 0;
    list-style: none;
}

.ud-menu li a,
.ud-menu li button {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    padding: 0.55rem 1rem;
    border: none;
    background: none;
    font-size: 0.85rem;
    color: var(--text);
    text-decoration: none;
    cursor: pointer;
    font-family: inherit;
    transition: background 0.15s;
}

.ud-menu li a:hover,
.ud-menu li button:hover {
    background: var(--bg);
    color: var(--primary);
}

.ud-menu li svg {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
    stroke: currentColor;
    fill: none;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.ud-divider {
    height: 1px;
    background: var(--border);
    margin: 0.25rem 0;
}

/* ==================== 主容器 ==================== */
.container {
    max-width: 900px;
    margin: 0 auto;
    padding: 1.25rem 1rem 2rem;
}

/* ==================== 翻译器 ==================== */
.translator {
    background: var(--surface);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    padding: 1.25rem;
}

/* Language bar */
.lang-bar {
    display: flex;
    align-items: flex-end;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.lang-select-wrap {
    flex: 1;
    min-width: 0;
}

.lang-select-wrap label {
    display: block;
    font-size: 0.75rem;
    color: var(--text-secondary);
    margin-bottom: 0.2rem;
    font-weight: 500;
}

.lang-select-wrap select {
    width: 100%;
    padding: 0.55rem 0.5rem;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 0.9rem;
    background: var(--bg);
    color: var(--text);
    cursor: pointer;
    transition: border-color 0.2s;
    -webkit-appearance: none;
}

.lang-select-wrap select:focus {
    outline: none;
    border-color: var(--primary);
}

.swap-btn {
    width: 38px;
    height: 38px;
    border: 1px solid var(--border);
    border-radius: 50%;
    background: var(--bg);
    font-size: 1.1rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    flex-shrink: 0;
}

.swap-btn:hover {
    background: var(--primary);
    color: #fff;
    border-color: var(--primary);
}

/* Text panels */
.text-panels {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.75rem;
    margin-bottom: 1rem;
}

.panel {
    display: flex;
    flex-direction: column;
}

.panel textarea,
.result-area {
    width: 100%;
    min-height: 160px;
    padding: 0.75rem;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 1rem;
    line-height: 1.6;
    resize: vertical;
    font-family: inherit;
    transition: border-color 0.2s;
}

.panel textarea:focus {
    outline: none;
    border-color: var(--primary);
}

.result-area {
    background: var(--bg);
    color: var(--text);
    overflow-y: auto;
    white-space: pre-wrap;
    word-wrap: break-word;
}

.result-area.placeholder {
    color: var(--text-secondary);
}

.panel-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-top: 0.3rem;
    padding: 0 0.15rem;
    font-size: 0.75rem;
    color: var(--text-secondary);
}

.panel-actions {
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.action-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    background: none;
    border: 1px solid var(--border);
    font-size: 0.8rem;
    cursor: pointer;
    padding: 0.35rem 0.65rem;
    border-radius: 6px;
    color: var(--text-secondary);
    transition: all 0.2s;
    font-family: inherit;
    -webkit-tap-highlight-color: transparent;
}

.action-btn:hover {
    background: var(--bg);
    color: var(--primary);
    border-color: var(--primary);
}

.copy-btn {
    padding: 0.4rem 0.85rem;
    font-size: 0.85rem;
    background: var(--bg);
}

.copy-btn:hover {
    background: var(--primary);
    color: #fff;
    border-color: var(--primary);
}

.copy-btn:hover svg {
    stroke: #fff;
}

/* OCR image preview */
.ocr-preview {
    position: relative;
    margin-bottom: 0.5rem;
    border-radius: 8px;
    overflow: hidden;
    border: 1px solid var(--border);
    background: #000;
}

.ocr-preview img {
    width: 100%;
    max-height: 200px;
    object-fit: contain;
    display: block;
}

.ocr-close {
    position: absolute;
    top: 0.35rem;
    right: 0.35rem;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    border: none;
    background: rgba(0, 0, 0, 0.6);
    color: #fff;
    font-size: 1rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
}

.ocr-close:hover {
    background: rgba(0, 0, 0, 0.85);
}

.ocr-progress {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: rgba(0, 0, 0, 0.7);
    padding: 0.5rem 0.75rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.ocr-progress-bar {
    flex: 1;
    height: 4px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 2px;
    overflow: hidden;
}

.ocr-bar {
    height: 100%;
    width: 0%;
    background: var(--primary);
    border-radius: 2px;
    transition: width 0.3s;
}

#ocr-status-text {
    font-size: 0.7rem;
    color: #fff;
    white-space: nowrap;
}

/* TTS button */
.tts-btn.speaking {
    color: var(--primary);
    border-color: var(--primary);
    background: rgba(79, 70, 229, 0.08);
}

/* Voice input */
.voice-btn.recording {
    color: var(--danger);
    border-color: var(--danger);
    animation: pulse 1.5s infinite;
}

.voice-btn.recording svg {
    stroke: var(--danger);
}

@keyframes pulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.3); }
    50% { box-shadow: 0 0 0 6px rgba(239, 68, 68, 0); }
}

.voice-unsupported {
    display: none !important;
}

/* Translate button */
.translate-btn {
    width: 100%;
    padding: 0.75rem;
    background: var(--primary);
    color: #fff;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    letter-spacing: 0.5px;
    transition: background 0.2s;
    -webkit-tap-highlight-color: transparent;
}

.translate-btn:hover {
    background: var(--primary-hover);
}

.translate-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

/* Loading animation */
.loading::after {
    content: "";
    display: inline-block;
    width: 14px;
    height: 14px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top-color: #fff;
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
    vertical-align: middle;
    margin-left: 0.5rem;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* ==================== 翻译历史 ==================== */
.history-section {
    margin-top: 1.25rem;
    background: var(--surface);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 1.25rem;
}

.history-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 0.75rem;
}

.history-header h2 {
    font-size: 1rem;
    color: var(--text-secondary);
}

#history-list {
    list-style: none;
}

#history-list li {
    padding: 0.65rem 0;
    border-bottom: 1px solid var(--border);
    font-size: 0.85rem;
    line-height: 1.5;
    display: flex;
    align-items: flex-start;
    gap: 0.5rem;
}

#history-list li:last-child {
    border-bottom: none;
}

.history-content {
    flex: 1;
    min-width: 0;
}

.history-source {
    color: var(--text-secondary);
    display: block;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.history-arrow {
    color: var(--primary);
    margin: 0 0.25rem;
}

.history-result {
    font-weight: 500;
    display: block;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.history-meta {
    font-size: 0.7rem;
    color: var(--text-secondary);
    margin-top: 0.15rem;
}

.history-delete {
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 0.2rem;
    font-size: 0.8rem;
    opacity: 0;
    transition: all 0.2s;
    flex-shrink: 0;
}

#history-list li:hover .history-delete {
    opacity: 1;
}

.history-delete:hover {
    color: var(--danger);
}

.clear-history-btn {
    padding: 0.3rem 0.75rem;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--surface);
    color: var(--text-secondary);
    font-size: 0.8rem;
    cursor: pointer;
    transition: all 0.2s;
}

.clear-history-btn:hover {
    border-color: var(--danger);
    color: var(--danger);
}

/* Pagination */
.pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.25rem;
    margin-top: 0.75rem;
}

.pagination button {
    padding: 0.3rem 0.65rem;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--surface);
    color: var(--text-secondary);
    font-size: 0.8rem;
    cursor: pointer;
    transition: all 0.15s;
}

.pagination button:hover {
    border-color: var(--primary);
    color: var(--primary);
}

.pagination button.active {
    background: var(--primary);
    color: #fff;
    border-color: var(--primary);
}

.pagination button:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

/* ==================== 深色模式切换按钮 ==================== */
.theme-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border: 1px solid var(--border);
    border-radius: 50%;
    background: var(--bg);
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.2s;
    flex-shrink: 0;
}

.theme-toggle:hover {
    background: var(--primary);
    color: #fff;
    border-color: var(--primary);
}

.theme-toggle:hover svg {
    stroke: #fff;
}

/* ==================== 收藏按钮 ==================== */
.fav-btn {
    padding: 0.4rem 0.85rem;
    font-size: 0.85rem;
    background: var(--bg);
}

.fav-btn:hover {
    color: var(--star);
    border-color: var(--star);
}

.fav-btn.favorited {
    color: var(--star);
    border-color: var(--star);
    background: rgba(245, 158, 11, 0.08);
}

.fav-btn.favorited svg {
    fill: var(--star);
    stroke: var(--star);
}

/* ==================== 选项卡 ==================== */
.tabs-section {
    margin-top: 1.25rem;
    background: var(--surface);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 1.25rem;
}

.tabs-bar {
    display: flex;
    gap: 0;
    border-bottom: 2px solid var(--border);
    margin-bottom: 0.75rem;
}

.tab-btn {
    padding: 0.5rem 1.25rem;
    border: none;
    background: none;
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--text-secondary);
    cursor: pointer;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    transition: all 0.2s;
    font-family: inherit;
}

.tab-btn:hover {
    color: var(--primary);
}

.tab-btn.active {
    color: var(--primary);
    border-bottom-color: var(--primary);
}

.tab-panel {
    display: none;
}

.tab-panel.active {
    display: block;
}

.panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 0.75rem;
    gap: 0.5rem;
}

/* ==================== 收藏夹分类 ==================== */
.fav-categories {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
    flex: 1;
    min-width: 0;
}

.fav-cat-btn {
    padding: 0.25rem 0.7rem;
    border: 1px solid var(--border);
    border-radius: 999px;
    background: var(--bg);
    color: var(--text-secondary);
    font-size: 0.75rem;
    cursor: pointer;
    transition: all 0.2s;
    font-family: inherit;
    white-space: nowrap;
}

.fav-cat-btn:hover {
    border-color: var(--primary);
    color: var(--primary);
}

.fav-cat-btn.active {
    background: var(--primary);
    color: #fff;
    border-color: var(--primary);
}

/* ==================== 收藏列表 ==================== */
#favorites-list {
    list-style: none;
}

#favorites-list li {
    padding: 0.65rem 0;
    border-bottom: 1px solid var(--border);
    font-size: 0.85rem;
    line-height: 1.5;
    display: flex;
    align-items: flex-start;
    gap: 0.5rem;
}

#favorites-list li:last-child {
    border-bottom: none;
}

.fav-item-content {
    flex: 1;
    min-width: 0;
}

.fav-item-source {
    color: var(--text-secondary);
    display: block;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.fav-item-result {
    font-weight: 500;
    display: block;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.fav-item-meta {
    font-size: 0.7rem;
    color: var(--text-secondary);
    margin-top: 0.15rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.fav-item-cat {
    display: inline-flex;
    align-items: center;
    padding: 0.1rem 0.45rem;
    border-radius: 999px;
    background: rgba(79, 70, 229, 0.08);
    color: var(--primary);
    font-size: 0.65rem;
    cursor: pointer;
}

.fav-item-cat:hover {
    background: rgba(79, 70, 229, 0.15);
}

.fav-item-actions {
    display: flex;
    gap: 0.25rem;
    flex-shrink: 0;
}

.fav-item-actions button {
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 0.2rem;
    font-size: 0.8rem;
    opacity: 0;
    transition: all 0.2s;
}

#favorites-list li:hover .fav-item-actions button {
    opacity: 1;
}

.fav-item-actions button:hover {
    color: var(--danger);
}

/* 历史列表中的收藏按钮 */
.history-fav-btn {
    background: none;
    border: none;
    cursor: pointer;
    padding: 0.2rem;
    color: var(--text-secondary);
    opacity: 0;
    transition: all 0.2s;
    flex-shrink: 0;
}

#history-list li:hover .history-fav-btn {
    opacity: 1;
}

.history-fav-btn:hover {
    color: var(--star);
}

.history-fav-btn svg {
    width: 14px;
    height: 14px;
}

/* ==================== 弹窗 ==================== */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 200;
}

.modal-card {
    background: var(--surface);
    border-radius: var(--radius);
    padding: 1.5rem;
    width: 90%;
    max-width: 380px;
    box-shadow: var(--shadow-lg);
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1rem;
}

.modal-header h3 {
    font-size: 1rem;
    color: var(--text);
}

.modal-close {
    background: none;
    border: none;
    font-size: 1.3rem;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 0;
    line-height: 1;
}

.modal-close:hover {
    color: var(--text);
}

.modal-input {
    width: 100%;
    padding: 0.6rem 0.75rem;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 0.9rem;
    font-family: inherit;
    margin-bottom: 0.75rem;
    background: var(--bg);
    color: var(--text);
    transition: border-color 0.2s;
}

.modal-input:focus {
    outline: none;
    border-color: var(--primary);
}

.cat-suggestions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.3rem;
    margin-bottom: 0.75rem;
}

.cat-suggestions .fav-cat-btn {
    font-size: 0.7rem;
    padding: 0.2rem 0.6rem;
}

/* ==================== 认证页面 ==================== */
.auth-card {
    max-width: 400px;
    margin: 3rem auto;
    background: var(--surface);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    padding: 2rem 1.5rem;
}

.auth-title {
    text-align: center;
    font-size: 1.5rem;
    color: var(--primary);
    margin-bottom: 1.5rem;
}

.auth-error {
    background: #fef2f2;
    color: var(--danger);
    padding: 0.6rem 0.85rem;
    border-radius: 8px;
    font-size: 0.85rem;
    margin-bottom: 1rem;
    border: 1px solid #fecaca;
}

.auth-form .form-group {
    margin-bottom: 1rem;
}

.auth-form label {
    display: block;
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-bottom: 0.3rem;
    font-weight: 500;
}

.auth-form input {
    width: 100%;
    padding: 0.7rem 0.85rem;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 1rem;
    font-family: inherit;
    transition: border-color 0.2s;
}

.auth-form input:focus {
    outline: none;
    border-color: var(--primary);
}

.auth-submit-btn {
    width: 100%;
    padding: 0.75rem;
    background: var(--primary);
    color: #fff;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    margin-top: 0.5rem;
    transition: background 0.2s;
}

.auth-submit-btn:hover {
    background: var(--primary-hover);
}

.auth-switch {
    text-align: center;
    margin-top: 1.25rem;
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.auth-switch a {
    color: var(--primary);
    text-decoration: none;
    font-weight: 500;
}

.auth-switch a:hover {
    text-decoration: underline;
}

/* ==================== 移动端适配 ==================== */
@media (max-width: 640px) {
    body {
        padding-top: 48px;
    }

    .user-bar {
        height: 48px;
        padding: 0 0.75rem;
    }

    .logo {
        font-size: 1rem;
    }

    .container {
        padding: 0.75rem 0.5rem 1.5rem;
    }

    .translator {
        padding: 1rem;
        border-radius: 8px;
    }

    .lang-bar {
        gap: 0.35rem;
    }

    .lang-select-wrap select {
        padding: 0.5rem 0.35rem;
        font-size: 0.8rem;
    }

    .swap-btn {
        width: 34px;
        height: 34px;
        font-size: 1rem;
    }

    .text-panels {
        grid-template-columns: 1fr;
        gap: 0.5rem;
    }

    .panel textarea,
    .result-area {
        min-height: 120px;
        font-size: 0.95rem;
    }

    .translate-btn {
        padding: 0.7rem;
        font-size: 0.95rem;
    }

    .tabs-section {
        padding: 1rem;
        border-radius: 8px;
    }

    #history-list li {
        font-size: 0.8rem;
    }

    .history-delete {
        opacity: 1;
    }

    .history-fav-btn {
        opacity: 1;
    }

    #favorites-list li {
        font-size: 0.8rem;
    }

    .fav-item-actions button {
        opacity: 1;
    }

    .theme-toggle {
        width: 32px;
        height: 32px;
    }

    .tab-btn {
        padding: 0.4rem 0.85rem;
        font-size: 0.85rem;
    }

    /* 认证页面移动端 */
    .auth-card {
        margin: 1.5rem auto;
        padding: 1.5rem 1rem;
        border-radius: 8px;
    }

    .auth-title {
        font-size: 1.25rem;
    }
}

@media (max-width: 360px) {
    .lang-select-wrap label {
        display: none;
    }

    .lang-select-wrap select {
        font-size: 0.75rem;
    }
}

/* ==================== PWA: Safe Area (notch/刘海屏) ==================== */

@supports (padding-top: env(safe-area-inset-top)) {
    .user-bar {
        padding-top: env(safe-area-inset-top);
    }
    body {
        padding-bottom: env(safe-area-inset-bottom);
    }
}

/* ==================== PWA: Install Banner ==================== */

.pwa-install-banner {
    position: fixed;
    bottom: -80px;
    left: 0;
    right: 0;
    z-index: 9999;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    padding-bottom: calc(0.75rem + env(safe-area-inset-bottom, 0px));
    background: var(--surface);
    border-top: 1px solid var(--border);
    box-shadow: 0 -4px 12px rgba(0,0,0,0.1);
    transition: bottom 0.3s ease;
}

.pwa-install-banner.show {
    bottom: 0;
}

.pwa-install-text {
    flex: 1;
    font-size: 0.85rem;
    color: var(--text);
}

.pwa-install-btn {
    padding: 0.45rem 1.2rem;
    background: var(--primary);
    color: white;
    border: none;
    border-radius: 6px;
    font-size: 0.85rem;
    cursor: pointer;
    white-space: nowrap;
}

.pwa-install-btn:active {
    opacity: 0.85;
}

.pwa-install-dismiss {
    background: none;
    border: none;
    font-size: 1.2rem;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 0.2rem 0.4rem;
}

/* ==================== PWA: Offline Indicator ==================== */

.offline-indicator {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 10000;
    text-align: center;
    padding: 0.4rem 1rem;
    padding-top: calc(0.4rem + env(safe-area-inset-top, 0px));
    background: #f59e0b;
    color: #1e293b;
    font-size: 0.8rem;
    font-weight: 500;
}

/* ==================== PWA: Standalone mode ==================== */

@media (display-mode: standalone) {
    .user-bar {
        padding-top: env(safe-area-inset-top, 0px);
    }
}
