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

:root {
    /* 色彩 */
    --xhs-red: #ff2442;
    --xhs-red-light: #ff6b81;
    --xhs-red-bg: rgba(255, 36, 66, 0.05);
    --xhs-gray: #f8f8f8;
    --xhs-gray-dark: #e8e8e8;
    --xhs-text: #333333;
    --xhs-text-light: #999999;
    --xhs-success: #00c853;
    --xhs-disabled: #cccccc;
    --xhs-border: #f0f0f0;
    --xhs-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);

    /* 字体 */
    --font-title: 24px;
    --font-subtitle: 14px;
    --font-input: 16px;
    --font-hint: 13px;
    --font-card-title: 15px;
    --font-card-desc: 13px;
    --font-btn: 16px;

    /* 动画 */
    --transition-fast: 200ms;
    --transition-normal: 300ms;
    --transition-smooth: cubic-bezier(0.4, 0, 0.2, 1);

    /* Z-index 层级 */
    --z-header: 100;
    --z-dropdown: 200;
    --z-modal-overlay: 1000;
    --z-modal-dialog: 1100;
    --z-toast: 2000;

    /* 间距系统（8px 基准） */
    --space-1: 4px;
    --space-2: 8px;
    --space-3: 12px;
    --space-4: 16px;
    --space-5: 20px;
    --space-6: 24px;
    --space-8: 32px;

    /* 圆角系统 */
    --radius-sm: 4px;
    --radius-md: 8px;
    --radius-lg: 12px;
    --radius-xl: 16px;
    --radius-full: 9999px;

    /* 阴影系统 */
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.15);
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "PingFang SC", sans-serif;
    background: var(--xhs-gray);
    color: var(--xhs-text);
    line-height: 1.5;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Header */
.header {
    background: #fff;
    height: 56px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 16px;
    position: sticky;
    top: 0;
    z-index: 100;
    border-bottom: 1px solid var(--xhs-border);
}

/* Header placeholder for layout balance */
.header-placeholder {
    width: 100px;
}

.header-back {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    border-radius: 50%;
    transition: background var(--transition-fast);
    text-decoration: none;
    color: var(--xhs-text);
}

.header-back:hover {
    background: var(--xhs-gray);
}

.header-title {
    font-size: 17px;
    font-weight: 600;
    color: var(--xhs-text);
}

.header-link, .header-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    background: var(--xhs-red);
    color: #fff;
    border: none;
    border-radius: 20px;
    font-size: 14px;
    font-weight: 600;
    text-decoration: none;
    cursor: pointer;
    transition: opacity 0.2s;
}

.header-link:hover, .header-btn:hover {
    opacity: 0.9;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 12px;
}

/* Footer */
.app-footer {
    margin-top: auto;
    padding: 12px 16px;
    background: #fff;
    border-top: 1px solid var(--xhs-border);
}

.footer-container {
    max-width: 1200px;
    margin: 0 auto;
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: center;
    gap: 6px;
}

.footer-copyright {
    font-size: 13px;
    color: #ccc;
    margin: 0;
}

.footer-divider {
    font-size: 13px;
    color: #ccc;
    margin: 0;
}

.footer-btn {
    color: var(--xhs-red);
    font-size: 13px;
    text-decoration: none;
    cursor: pointer;
    white-space: nowrap;
    transition: all 0.2s;
}

.footer-btn:hover {
    color: var(--xhs-red-light);
    text-decoration: underline;
}

/* Container */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 12px 8px;
}

.page-wrapper {
    max-width: 600px;
    margin: 0 auto;
    padding: 20px 16px;
}

/* Form */
.form {
    display: flex;
    flex-direction: column;
    gap: 24px;
}

/* Hero Section */
.hero-section {
    text-align: center;
    padding: 20px 0;
}

.hero-title {
    font-size: 28px;
    font-weight: 700;
    color: var(--xhs-text);
    margin-bottom: 8px;
}

.hero-subtitle {
    font-size: 14px;
    color: var(--xhs-text-light);
}

/* Input Section */
.input-section {
    background: #fff;
    border-radius: 16px;
    padding: 20px;
}

.focus-input-wrapper {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.focus-input {
    width: 100%;
    border: none;
    outline: none;
    font-size: var(--font-input);
    resize: none;
    font-family: inherit;
}

.input-hint {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--xhs-text-light);
    font-size: var(--font-hint);
}

.hint-icon {
    font-size: 16px;
}

/* Mode Section */
.mode-section {
    background: #fff;
    border-radius: 16px;
    padding: 20px;
}

.mode-cards {
    display: flex;
    gap: 12px;
    margin-bottom: 16px;
}

.mode-card {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px;
    border: 2px solid var(--xhs-gray);
    border-radius: 12px;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.mode-card:hover {
    border-color: var(--xhs-red-light);
}

.mode-card.active {
    border-color: var(--xhs-red);
    background: var(--xhs-red-bg);
}

.mode-radio {
    font-size: 20px;
    color: var(--xhs-red);
}

.mode-title {
    font-weight: 600;
    color: var(--xhs-text);
}

.mode-desc {
    font-size: 12px;
    color: var(--xhs-text-light);
}

.reference-input-wrapper {
    margin-top: 12px;
}

.form-input {
    width: 100%;
    padding: 12px 16px;
    border: 1px solid var(--xhs-border);
    border-radius: 8px;
    font-size: var(--font-input);
    outline: none;
}

.form-input:focus {
    border-color: var(--xhs-red);
}

/* Advanced Section */
.advanced-section {
    background: #fff;
    border-radius: 16px;
    overflow: hidden;
}

.advanced-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px 20px;
    cursor: pointer;
    user-select: none;
}

.advanced-icon {
    font-size: 18px;
}

.advanced-label {
    flex: 1;
    font-weight: 600;
    color: var(--xhs-text);
}

.advanced-arrow {
    transition: transform var(--transition-normal);
}

.advanced-section.expanded .advanced-arrow {
    transform: rotate(180deg);
}

.advanced-content {
    display: none;
    padding: 0 20px 20px;
}

.advanced-section.expanded .advanced-content {
    display: block;
}

.slider-item {
    margin-bottom: 16px;
}

.slider-row {
    display: flex;
    justify-content: space-between;
    margin-bottom: 8px;
}

.slider-label {
    font-size: 14px;
    color: var(--xhs-text);
}

.slider-value {
    font-weight: 600;
    color: var(--xhs-red);
}

.slider {
    width: 100%;
    height: 4px;
    background: var(--xhs-gray-dark);
    border-radius: 2px;
    outline: none;
    -webkit-appearance: none;
}

.slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 20px;
    height: 20px;
    background: var(--xhs-red);
    border-radius: 50%;
    cursor: pointer;
}

/* Submit Button */
.submit-btn {
    width: 100%;
    padding: 16px;
    background: var(--xhs-red);
    color: #fff;
    border: none;
    border-radius: 12px;
    font-size: var(--font-btn);
    font-weight: 600;
    cursor: pointer;
    transition: opacity var(--transition-fast);
}

.submit-btn:hover {
    opacity: 0.9;
}

/* Waterfall Grid */
.waterfall {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
    gap: 8px;
}

/* Note Card */
.note-card {
    background: #fff;
    border-radius: 8px;
    overflow: hidden;
    cursor: pointer;
    transition: all 0.2s ease;
    position: relative;
}

.note-delete {
    position: absolute;
    top: 8px;
    right: 8px;
    width: 28px;
    height: 28px;
    background: rgba(0, 0, 0, 0.5);
    border: none;
    border-radius: 50%;
    color: #fff;
    cursor: pointer;
    opacity: 0;
    transition: opacity 0.2s, background 0.2s;
    z-index: 10;
}

.note-delete:hover {
    background: var(--xhs-red);
}

.note-card:hover .note-delete {
    opacity: 1;
}

.note-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.note-cover {
    width: 100%;
    aspect-ratio: 3 / 4;
    object-fit: cover;
    background: var(--xhs-gray-dark);
}

.note-info {
    padding: 10px 12px;
}

.note-title {
    font-size: 14px;
    font-weight: 500;
    color: var(--xhs-text);
    margin-bottom: 8px;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    line-height: 1.4;
}

.note-meta {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.note-date {
    font-size: 11px;
    color: var(--xhs-text-light);
}

/* Empty State */
.empty-state {
    text-align: center;
    padding: 100px 20px;
    color: var(--xhs-text-light);
}

.empty-state-icon {
    width: 80px;
    height: 80px;
    margin: 0 auto 20px;
    background: var(--xhs-gray);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 36px;
}

.empty-state h3 {
    font-size: 16px;
    color: var(--xhs-text);
    margin-bottom: 8px;
}

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

/* Detail Page Styles */
.detail-container {
    display: grid;
    grid-template-columns: 80px 1fr 320px;
    gap: 16px;
    max-width: 1400px;
    margin: 16px auto;
    min-height: calc(100vh - 72px);
}

.thumbnail-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.thumbnail-item {
    width: 100%;
    aspect-ratio: 3 / 4;
    border-radius: 8px;
    overflow: hidden;
    cursor: pointer;
    border: 2px solid transparent;
    transition: all var(--transition-fast);
    position: relative;
}

.thumbnail-item.active {
    border-color: var(--xhs-red);
}

.thumbnail-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.main-image-area {
    display: flex;
    align-items: center;
    justify-content: center;
    background: #fff;
    border-radius: 12px;
    padding: 20px;
}

.main-image {
    max-width: 100%;
    max-height: 70vh;
    border-radius: 8px;
}

.content-area {
    background: #fff;
    border-radius: 12px;
    padding: 24px;
}

.note-detail-title {
    font-size: 20px;
    font-weight: 700;
    color: var(--xhs-text);
    margin-bottom: 16px;
    line-height: 1.4;
}

.note-detail-content {
    font-size: 15px;
    line-height: 1.8;
    color: var(--xhs-text);
    white-space: pre-wrap;
    margin-bottom: 20px;
}

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

.note-tag {
    color: var(--xhs-red);
    font-size: 14px;
}

/* Skeleton */
.skeleton {
    background: linear-gradient(90deg, var(--xhs-gray) 25%, var(--xhs-gray-dark) 50%, var(--xhs-gray) 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
}

@keyframes shimmer {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

.skeleton-text {
    height: 16px;
    border-radius: 4px;
    margin-bottom: 8px;
}

.skeleton-title {
    height: 24px;
    width: 80%;
    border-radius: 6px;
    margin-bottom: 16px;
}

/* Progress Bar */
.progress-bar {
    height: 4px;
    background: var(--xhs-gray-dark);
    border-radius: 2px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: var(--xhs-red);
    transition: width 0.3s ease;
}

/* Steps */
.steps-list {
    margin-bottom: 20px;
}

.step-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 0;
    border-bottom: 1px solid var(--xhs-border);
}

.step-icon {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
}

.step-icon.pending {
    background: var(--xhs-gray);
    color: var(--xhs-text-light);
}

.step-icon.running {
    background: var(--xhs-red-bg);
    color: var(--xhs-red);
}

.step-icon.done {
    background: var(--xhs-success);
    color: #fff;
}

.step-text {
    flex: 1;
    font-size: 14px;
}

.step-percent {
    font-size: 12px;
    color: var(--xhs-text-light);
}

/* Responsive */
@media (max-width: 1024px) {
    .detail-container {
        grid-template-columns: 1fr;
    }

    .thumbnail-list {
        flex-direction: row;
        overflow-x: auto;
    }

    .thumbnail-item {
        width: 80px;
    }
}

@media (max-width: 768px) {
    .waterfall {
        grid-template-columns: repeat(2, 1fr);
    }

    .hero-title {
        font-size: 24px;
    }
}

/* ========== Icons ========== */
.xhs-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.xhs-icon svg {
    width: 100%;
    height: 100%;
}

/* 行内图标（与文字对齐） */
.inline-icon {
    display: inline-flex;
    vertical-align: middle;
    margin-right: 4px;
}

/* ========== Dialog Component ========== */
/* Dialog Overlay */
.dialog-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: var(--z-modal-overlay);
    animation: dialogFadeIn 0.15s ease-out;
}

@keyframes dialogFadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* Dialog */
.dialog-dialog {
    background: #fff;
    border-radius: 12px;
    min-width: 360px;
    max-width: 480px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.2);
    animation: dialogSlideIn 0.2s ease-out;
}

@keyframes dialogSlideIn {
    from {
        opacity: 0;
        transform: translateY(-20px) scale(0.95);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.dialog-dialog.dialog-error {
    border-top: 4px solid var(--xhs-red);
}

.dialog-dialog.dialog-success {
    border-top: 4px solid var(--xhs-success);
}

.dialog-dialog.dialog-info {
    border-top: 4px solid var(--xhs-red);
}

/* Dialog Header */
.dialog-header {
    padding: 16px 20px;
    border-bottom: 1px solid var(--xhs-border);
}

.dialog-title {
    margin: 0;
    font-size: 18px;
    font-weight: 600;
    color: var(--xhs-text);
}

/* Dialog Body */
.dialog-body {
    padding: 20px;
}

.dialog-body p {
    margin: 0;
    font-size: 15px;
    line-height: 1.6;
    color: var(--xhs-text);
}

/* Dialog Footer */
.dialog-footer {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    padding: 16px 20px;
    background: var(--xhs-gray);
    border-radius: 0 0 12px 12px;
}

.dialog-footer .btn-primary,
.dialog-footer .btn-secondary {
    padding: 8px 20px;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.dialog-footer .btn-secondary {
    background: #fff;
    color: var(--xhs-text);
    border: 1px solid var(--xhs-border);
}

.dialog-footer .btn-secondary:hover {
    background: var(--xhs-gray);
}

.dialog-footer .btn-primary {
    background: var(--xhs-red);
    color: #fff;
    border: none;
}

.dialog-footer .btn-primary:hover {
    opacity: 0.9;
}

/* ========== Focus Visible States ========== */

/* Hide outline for mouse users, keep for keyboard */
*:focus:not(:focus-visible) {
    outline: none;
}

/* Header */
.header-back:focus-visible {
    outline: 2px solid var(--xhs-red);
    outline-offset: 2px;
    border-radius: 50%;
}

.header-link:focus-visible,
.header-btn:focus-visible {
    outline: 2px solid var(--xhs-red);
    outline-offset: 2px;
}

/* Footer */
.footer-btn:focus-visible {
    outline: 2px solid var(--xhs-red);
    outline-offset: 2px;
    border-radius: 4px;
}

/* Form Elements */
.form-input:focus-visible {
    outline: 2px solid var(--xhs-red);
    outline-offset: 1px;
}

.focus-input:focus-visible {
    outline: 2px solid var(--xhs-red);
    outline-offset: 1px;
}

/* Buttons */
.submit-btn:focus-visible {
    outline: 2px solid var(--xhs-red);
    outline-offset: 2px;
}

.login-btn:focus-visible {
    outline: 2px solid var(--xhs-red);
    outline-offset: 2px;
}

/* Mode Cards */
.mode-card:focus-visible {
    outline: 2px solid var(--xhs-red);
    outline-offset: 2px;
}

/* Note Card */
.note-card:focus-visible {
    outline: 2px solid var(--xhs-red);
    outline-offset: -2px;
}

.note-delete:focus-visible {
    outline: 2px solid var(--xhs-red);
    outline-offset: 2px;
}

/* Dialog Buttons */
.btn-primary:focus-visible,
.btn-secondary:focus-visible {
    outline: 2px solid var(--xhs-red);
    outline-offset: 2px;
}

/* Modal */
.modal-close:focus-visible {
    outline: 2px solid var(--xhs-red);
    outline-offset: 2px;
}

/* ========== Accessibility: Reduced Motion ========== */

/* 尊重用户动画偏好设置 */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
}

/* 支持动画的用户使用平滑过渡 */
@media (prefers-reduced-motion: no-preference) {
    html {
        scroll-behavior: smooth;
    }
}
