/* ========== 重置与 CSS 变量 ========== */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

:root {
    --bg-primary: #fdfaf6;
    --bg-card: rgba(255, 255, 255, 0.85);
    --bg-input: rgba(255, 255, 255, 0.9);
    --bg-hover: #f1f2f5;
    --text-primary: #1d1d1f;
    --text-secondary: #515154;
    --text-muted: #86868b;
    --accent: #ff9f0a;
    --accent-hover: #f09200;
    --accent-light: rgba(255, 159, 10, 0.1);
    --accent-glow: rgba(255, 159, 10, 0.25);
    --grad-start: #ffb703;
    --grad-end: #fb8500;
    --success: #34c759;
    --success-light: rgba(52, 199, 89, 0.1);
    --error: #ff3b30;
    --error-light: rgba(255, 59, 48, 0.1);
    --border: rgba(0, 0, 0, 0.06);
    --border-accent: rgba(255, 159, 10, 0.4);
    --radius-sm: 12px;
    --radius: 16px;
    --radius-lg: 24px;
    --shadow: 0 10px 40px rgba(0, 0, 0, 0.04);
    --shadow-accent: 0 8px 24px rgba(251, 133, 0, 0.25);
    --transition: 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
    --safe-top: env(safe-area-inset-top, 0px);
    --safe-bottom: env(safe-area-inset-bottom, 0px);
    --safe-left: env(safe-area-inset-left, 0px);
    --safe-right: env(safe-area-inset-right, 0px);
}

html {
    font-size: 16px;
    -webkit-text-size-adjust: 100%;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'PingFang SC', 'Helvetica Neue', sans-serif;
    background-color: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100dvh;
    padding: calc(var(--safe-top) + 24px) calc(var(--safe-right) + 16px) calc(var(--safe-bottom) + 32px) calc(var(--safe-left) + 16px);
    overscroll-behavior-y: contain;
    position: relative;
    z-index: 0;
}

/* 动态背景光效 */
body::before, body::after {
    content: '';
    position: fixed;
    border-radius: 50%;
    z-index: -1;
    filter: blur(80px);
    opacity: 0.6;
    pointer-events: none;
}
body::before {
    top: -10%; left: -10%;
    width: 300px; height: 300px;
    background: rgba(255, 183, 3, 0.3);
}
body::after {
    bottom: -10%; right: -10%;
    width: 400px; height: 400px;
    background: rgba(251, 133, 0, 0.15);
}

.container {
    width: 100%;
    max-width: 480px;
    margin: 0 auto;
}

/* ========== 头部 ========== */
.header {
    text-align: center;
    margin-bottom: 32px;
    animation: fadeIn 0.6s ease-out;
}

.logo {
    display: inline-flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 8px;
}

.logo-mark {
    width: 44px;
    height: 44px;
    border-radius: 14px;
    background: linear-gradient(135deg, var(--grad-start), var(--grad-end));
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: var(--shadow-accent);
    flex-shrink: 0;
}

.logo h1 {
    font-size: 26px;
    font-weight: 800;
    color: var(--text-primary);
    letter-spacing: -0.5px;
}

.subtitle {
    color: var(--text-secondary);
    font-size: 14px;
    font-weight: 500;
}

/* ========== 使用步骤 ========== */
.steps-section {
    display: flex;
    align-items: center;
    background: var(--bg-card);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid rgba(255,255,255,0.5);
    border-radius: var(--radius);
    padding: 16px 12px;
    margin-bottom: 24px;
    box-shadow: var(--shadow);
}

.step {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    flex: 1;
    text-align: center;
}

.step-num {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: var(--accent-light);
    color: var(--accent);
    font-size: 13px;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
}

.step-text {
    font-size: 11px;
    color: var(--text-secondary);
    line-height: 1.5;
    font-weight: 500;
}

.step-arrow {
    color: #c5c5c5;
    padding: 0 4px;
}

/* ========== 输入区域 ========== */
.input-section {
    margin-bottom: 32px;
    animation: slideUp 0.5s ease-out;
}

.input-group {
    display: flex;
    align-items: center;
    background: var(--bg-input);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid var(--border);
    border-radius: 100px;
    overflow: hidden;
    margin-bottom: 16px;
    height: 56px;
    box-shadow: inset 0 2px 4px rgba(0,0,0,0.02), var(--shadow);
    transition: all var(--transition);
}

.input-group:focus-within {
    border-color: var(--border-accent);
    box-shadow: 0 0 0 4px var(--accent-glow), var(--shadow);
}

.input-group input {
    flex: 1;
    height: 100%;
    padding: 0 24px;
    background: transparent;
    border: none;
    outline: none;
    color: var(--text-primary);
    font-size: 15px;
    font-weight: 500;
    min-width: 0;
}

.input-group input::placeholder {
    color: var(--text-muted);
    font-weight: 400;
}

.btn-clear {
    padding: 0 20px;
    height: 100%;
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: color var(--transition);
}
.btn-clear:hover { color: var(--text-primary); }

.action-row {
    display: flex;
    justify-content: space-between;
    gap: 16px;
}

.btn-paste {
    flex: 1;
    height: 52px;
    background: rgba(255, 255, 255, 0.7);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid var(--border);
    border-radius: 100px;
    color: var(--text-primary);
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition);
    box-shadow: 0 2px 8px rgba(0,0,0,0.02);
}

.btn-paste:active {
    transform: scale(0.97);
    background: rgba(255,255,255,0.9);
}

.btn-parse {
    flex: 1;
    height: 52px;
    background: linear-gradient(135deg, var(--grad-start), var(--grad-end));
    border: none;
    border-radius: 100px;
    color: #fff;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition);
    box-shadow: var(--shadow-accent);
}

.btn-parse:active:not(:disabled) {
    transform: scale(0.97);
    box-shadow: 0 4px 12px rgba(251, 133, 0, 0.2);
}

.btn-parse:disabled {
    opacity: 0.7;
    filter: grayscale(20%);
    box-shadow: none;
}

.btn-parse-content {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.spinner {
    animation: spin 0.9s linear infinite;
    flex-shrink: 0;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ========== 进度条 ========== */
.progress-section {
    margin-bottom: 24px;
    animation: fadeIn 0.3s ease;
}

.progress-bar {
    height: 6px;
    background: rgba(0,0,0,0.04);
    border-radius: 99px;
    overflow: hidden;
    margin-bottom: 8px;
}

.progress-fill {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, var(--grad-start), var(--grad-end));
    border-radius: 99px;
    transition: width 0.4s ease;
    position: relative;
}
.progress-fill::after {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.4), transparent);
    animation: shimmer 1.4s infinite;
}
@keyframes shimmer {
    0% { transform: translateX(-100%); }
    100% { transform: translateX(100%); }
}

.progress-meta {
    display: flex;
    justify-content: space-between;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
}

/* ========== 结果区域 ========== */
.result-section {
    animation: slideUp 0.4s cubic-bezier(0.2, 0.8, 0.2, 1) forwards;
    margin-bottom: 32px;
}

.result-card {
    background: var(--bg-card);
    backdrop-filter: blur(24px);
    -webkit-backdrop-filter: blur(24px);
    border: 1px solid rgba(255,255,255,0.6);
    border-radius: var(--radius-lg);
    overflow: hidden;
    box-shadow: var(--shadow);
}

.tabs {
    display: flex;
    border-bottom: 1px solid var(--border);
    background: rgba(255,255,255,0.4);
}

.tab {
    flex: 1;
    text-align: center;
    padding: 16px 0;
    font-size: 15px;
    font-weight: 500;
    color: var(--text-muted);
    cursor: pointer;
    position: relative;
    user-select: none;
    transition: color 0.2s;
}

.tab.active {
    color: var(--text-primary);
    font-weight: 600;
}

.tab.active::after {
    content: '';
    position: absolute;
    bottom: -1px;
    left: 30%;
    right: 30%;
    height: 3px;
    border-radius: 3px 3px 0 0;
    background: var(--accent);
}

.video-wrapper {
    width: 100%;
    background: #000;
    max-height: 85vw;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
}

.video-wrapper video {
    width: 100%;
    max-height: 85vw;
    display: block;
    object-fit: contain;
}

.video-duration {
    position: absolute;
    bottom: 12px;
    right: 12px;
    background: rgba(0,0,0,0.6);
    backdrop-filter: blur(4px);
    padding: 4px 8px;
    border-radius: 6px;
    color: #fff;
    font-size: 12px;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
}

.image-wrapper {
    width: 100%;
    background: repeating-conic-gradient(#f0f0f0 0% 25%, transparent 0% 50%) 50% / 20px 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    min-height: 250px;
}

.image-wrapper img {
    max-width: 100%;
    max-height: 70vw;
    border-radius: var(--radius-sm);
    box-shadow: 0 8px 24px rgba(0,0,0,0.15);
}

.text-wrapper {
    padding: 24px;
    font-size: 15px;
    color: var(--text-primary);
    line-height: 1.6;
    background: rgba(255,255,255,0.5);
    min-height: 150px;
}

.video-meta {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: 12px;
    padding: 16px 20px 0;
}

.file-size {
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
    background: rgba(0,0,0,0.03);
    padding: 4px 10px;
    border-radius: 6px;
}

.resolution-select {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    font-weight: 600;
    color: var(--accent);
    background: var(--accent-light);
    padding: 4px 10px;
    border-radius: 6px;
}

.action-buttons {
    padding: 20px;
    display: flex;
    gap: 16px;
    flex-direction: row;
}

.btn-download {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    height: 52px;
    background: linear-gradient(135deg, var(--grad-start), var(--grad-end));
    border-radius: 100px;
    color: #fff;
    font-size: 16px;
    font-weight: 600;
    text-decoration: none;
    user-select: none;
    transition: all var(--transition);
    box-shadow: var(--shadow-accent);
}

.btn-download:active {
    transform: scale(0.97);
    box-shadow: 0 4px 12px rgba(251, 133, 0, 0.2);
}

.btn-copy {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    height: 52px;
    background: rgba(255,255,255,0.8);
    border: 2px solid var(--accent);
    border-radius: 100px;
    color: var(--accent);
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    user-select: none;
    transition: all var(--transition);
}

.btn-copy:active {
    transform: scale(0.97);
    background: var(--accent-light);
}

/* ========== 错误提示 ========== */
.error-section {
    animation: fadeIn 0.3s ease;
}

.error-card {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 16px;
    background: #fff0f0;
    border-left: 4px solid var(--error);
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow);
}

.error-icon-wrap {
    color: var(--error);
    margin-top: 2px;
}

.error-body {
    flex: 1;
}

.error-body p {
    font-size: 14px;
    font-weight: 500;
    color: #c92a2a;
    line-height: 1.5;
    margin-bottom: 12px;
}

.btn-retry {
    display: inline-flex;
    align-items: center;
    height: 36px;
    padding: 0 16px;
    background: #ffe3e3;
    border: none;
    border-radius: 6px;
    color: var(--error);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition);
}
.btn-retry:active { background: #ffc9c9; transform: scale(0.97); }

/* ========== Toast ========== */
.toast-container {
    position: fixed;
    bottom: calc(var(--safe-bottom) + 32px);
    left: 50%;
    transform: translateX(-50%);
    z-index: 9999;
    display: flex;
    flex-direction: column-reverse;
    gap: 12px;
    pointer-events: none;
}

.toast {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 14px 20px;
    background: rgba(20, 20, 20, 0.85);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid rgba(255,255,255,0.1);
    border-radius: 100px;
    color: #fff;
    font-size: 14px;
    font-weight: 600;
    box-shadow: 0 12px 32px rgba(0,0,0,0.2);
    animation: toastIn 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
    white-space: nowrap;
}

.toast.toast-success { color: var(--success); }
.toast.toast-error { color: var(--error); }
.toast.toast-info { color: #fff; }

.toast.toast-out {
    animation: toastOut 0.3s ease forwards;
}

@keyframes toastIn {
    from { opacity: 0; transform: translateY(20px) scale(0.9); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes toastOut {
    from { opacity: 1; transform: translateY(0) scale(1); }
    to   { opacity: 0; transform: translateY(10px) scale(0.9); }
}

/* ========== 页脚 ========== */
.footer {
    text-align: center;
    margin-top: 40px;
    padding-bottom: 20px;
}
.footer p {
    font-size: 12px;
    color: var(--text-muted);
    font-weight: 500;
}
.footer a {
    color: var(--text-muted);
    text-decoration: none;
}
.footer a:hover {
    text-decoration: underline;
}

/* ========== 动画 ========== */
@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes slideUp {
    from { opacity: 0; transform: translateY(24px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* ========== 模式切换 ========== */
.mode-switch {
    display: flex;
    gap: 8px;
    background: rgba(255, 255, 255, 0.6);
    border: 1px solid rgba(0, 0, 0, 0.06);
    border-radius: 100px;
    padding: 6px;
    margin: 0 auto 20px;
    max-width: 360px;
}
.mode-tab {
    flex: 1;
    border: none;
    background: transparent;
    border-radius: 100px;
    padding: 10px 0;
    font-size: 15px;
    font-weight: 600;
    color: #515154;
    cursor: pointer;
}
.mode-tab.active {
    background: linear-gradient(135deg, #ffb703, #fb8500);
    color: #fff;
    box-shadow: 0 6px 18px rgba(251, 133, 0, 0.25);
}

/* ========== 图片去水印 ========== */
.img-upload {
    border: 2px dashed #b9bfca;
    border-radius: 16px;
    background: rgba(255, 255, 255, 0.7);
    padding: 48px 16px;
    text-align: center;
    cursor: pointer;
}
.img-upload.dragover { border-color: #fb8500; background: rgba(251, 133, 0, 0.06); }
.img-upload-title { font-weight: 700; color: #1d1d1f; }
.img-upload-hint { font-size: 13px; color: #86868b; margin-top: 6px; }

.img-canvas-wrap {
    position: relative;
    width: 100%;
    background: #000;
    border-radius: 14px;
    overflow: hidden;
    display: flex;
    justify-content: center;
}
.img-canvas {
    position: relative;
    max-width: 100%;
    max-height: 60vh;
    display: block;
    touch-action: none;
}
.img-canvas-wrap .img-canvas + .img-canvas {
    position: absolute;
    left: 50%;
    top: 0;
    transform: translateX(-50%);
}

/* 画布 loading 遮罩 */
.img-canvas-overlay {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.45);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 14px;
    z-index: 10;
    animation: fadeIn 0.25s ease;
}
.img-canvas-spinner {
    width: 40px;
    height: 40px;
    border: 4px solid rgba(255, 255, 255, 0.2);
    border-top-color: var(--grad-start);
    border-right-color: var(--grad-end);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}
.img-canvas-overlay-text {
    color: rgba(255, 255, 255, 0.9);
    font-size: 14px;
    font-weight: 600;
    letter-spacing: 0.5px;
}

.img-toolbar {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
    justify-content: center;
    margin: 12px 0;
}
.img-tool {
    border: 1px solid rgba(0, 0, 0, 0.08);
    background: rgba(255, 255, 255, 0.8);
    border-radius: 100px;
    padding: 8px 16px;
    font-size: 14px;
    font-weight: 600;
    color: #1d1d1f;
    cursor: pointer;
}
.img-tool.active { background: #fb8500; color: #fff; border-color: #fb8500; }
.img-brush-size { display: flex; align-items: center; gap: 8px; font-size: 13px; color: #515154; }

/* 去水印质量切换 */
.img-quality-switch {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    justify-content: center;
    margin: 4px 0 8px;
}
.img-quality-label {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-secondary);
}
.img-quality-options {
    display: flex;
    gap: 0;
    background: rgba(0, 0, 0, 0.04);
    border-radius: 100px;
    padding: 3px;
    border: 1px solid var(--border);
}
.img-quality-opt {
    border: none;
    background: transparent;
    border-radius: 100px;
    padding: 7px 18px;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-muted);
    cursor: pointer;
    transition: all 0.25s cubic-bezier(0.25, 0.8, 0.25, 1);
    display: inline-flex;
    align-items: center;
    gap: 4px;
    white-space: nowrap;
}
.img-quality-opt .img-quality-icon {
    font-size: 13px;
}
.img-quality-opt.active {
    background: linear-gradient(135deg, var(--grad-start), var(--grad-end));
    color: #fff;
    box-shadow: 0 4px 12px rgba(251, 133, 0, 0.25);
}
.img-quality-opt:not(.active):hover {
    color: var(--text-primary);
    background: rgba(0, 0, 0, 0.04);
}
.img-quality-hint {
    width: 100%;
    text-align: center;
    font-size: 12px;
    color: var(--text-muted);
    min-height: 16px;
    transition: opacity 0.2s;
}

.img-compare { display: flex; gap: 10px; }
.img-compare-item { flex: 1; text-align: center; }
.img-compare-item .label { display: block; font-size: 12px; color: #86868b; margin-bottom: 6px; }
.img-compare-item img { width: 100%; border-radius: 10px; background: #000; }
