/* ============================
   设计令牌 — 基于 Apple 设计系统，搭配深红色点缀
   ============================ */
:root {
    --bg-page: #F7F8FA;
    --bg-card: #FFFFFF;
    --bg-card-hover: #FAFBFC;
    --bg-subtle: #F0F1F3;
    --bg-input: #F7F8FA;

    --text-primary: #1D1D1F;
    --text-secondary: #6E6E73;
    --text-tertiary: #AEAEB2;
    --text-on-primary: #FFFFFF;

    --border-default: #E5E5EA;
    --border-light: #F0F1F3;
    --border-focus: #8B2020;

    --primary: #8B2020;
    --primary-hover: #7A1C1C;
    --primary-active: #6A1818;
    --primary-subtle: rgba(139, 32, 32, 0.08);

    --accent-red: #8B2020;
    --accent-red-subtle: rgba(139, 32, 32, 0.06);

    --success: #34C759;
    --success-bg: #E8F9ED;
    --error: #FF3B30;
    --error-bg: #FFECEA;
    --warning: #FF9500;
    --warning-bg: #FFF6E5;

    --shadow-sm: 0 1px 2px rgba(0,0,0,0.04), 0 1px 3px -1px rgba(0,0,0,0.04);
    --shadow-md: 0 4px 8px -2px rgba(0,0,0,0.06), 0 2px 4px -2px rgba(0,0,0,0.04);
    --shadow-lg: 0 12px 32px -8px rgba(0,0,0,0.08), 0 4px 8px -4px rgba(0,0,0,0.04);
    --shadow-xl: 0 20px 48px -12px rgba(0,0,0,0.10);

    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 20px;
    --radius-full: 9999px;

    --font-family: 'DM Sans', 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    --fs-display: 34px;
    --fs-title: 22px;
    --fs-body: 16px;
    --fs-caption: 13px;
    --fs-small: 12px;
    --lh-tight: 1.2;
    --lh-normal: 1.5;
    --fw-medium: 500;
    --fw-semibold: 600;
    --fw-bold: 700;

    --space-xs: 4px;
    --space-sm: 8px;
    --space-md: 16px;
    --space-lg: 24px;
    --space-xl: 32px;
    --space-2xl: 48px;
    --space-3xl: 64px;

    --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
    --ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
    --duration-fast: 150ms;
    --duration-normal: 250ms;
    --duration-slow: 400ms;
}

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

html {
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
}

body {
    font-family: var(--font-family);
    font-size: var(--fs-body);
    line-height: var(--lh-normal);
    color: var(--text-primary);
    background: var(--bg-page);
    min-height: 100vh;
    overflow-x: hidden;
}

body::before {
    content: '';
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: radial-gradient(ellipse 80% 50% at 50% -20%, rgba(44, 111, 206, 0.03), transparent),
                radial-gradient(ellipse 60% 40% at 80% 100%, rgba(139, 32, 32, 0.02), transparent);
    pointer-events: none;
    z-index: 0;
}

.accent-bar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 2px;
    background: linear-gradient(90deg, transparent 5%, var(--accent-red) 30%, var(--accent-red) 70%, transparent 95%);
    z-index: 1000;
}

.back-home {
    position: fixed;
    top: 14px;
    left: 20px;
    z-index: 999;
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 6px 14px;
    font-family: var(--font-family);
    font-size: var(--fs-small);
    font-weight: var(--fw-medium);
    color: var(--text-secondary);
    text-decoration: none;
    background: rgba(255,255,255,0.85);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-full);
    transition: all var(--duration-fast) var(--ease-out);
}

.back-home:hover {
    color: var(--primary);
    border-color: var(--primary);
    background: var(--bg-card);
    box-shadow: var(--shadow-sm);
}

.back-home svg {
    width: 14px;
    height: 14px;
    flex-shrink: 0;
}

/* 联系客服（固定右上角） */
.contact-service {
    position: fixed;
    top: 16px;
    right: 16px;
    z-index: 100;
}

.contact-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    border: none;
    border-radius: var(--radius-full);
    background: var(--bg-card);
    color: var(--text-secondary);
    font-size: var(--fs-caption);
    font-family: var(--font-family);
    cursor: pointer;
    transition: all var(--duration-fast) var(--ease-out);
    box-shadow: var(--shadow-sm);
}

.contact-btn:hover {
    color: var(--primary);
    box-shadow: var(--shadow-md);
}

.contact-dropdown {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    width: 160px;
    background: var(--bg-card);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    padding: 12px;
    text-align: center;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-4px);
    transition: all var(--duration-fast) var(--ease-out);
    pointer-events: none;
}

.contact-service:hover .contact-dropdown,
.contact-service.open .contact-dropdown {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
    pointer-events: auto;
}

.contact-dropdown img {
    width: 100%;
    border-radius: var(--radius-md);
    display: block;
}

.qr-hint {
    margin-top: 8px;
    font-size: 11px;
    color: var(--text-tertiary);
    line-height: 1.3;
}

.qr-sub {
    margin-top: 4px;
    font-size: 10px;
    color: var(--text-tertiary);
    letter-spacing: 0.05em;
}

.container {
    position: relative;
    z-index: 1;
    width: 100%;
    max-width: 960px;
    margin: 0 auto;
    padding: var(--space-3xl) var(--space-xl) var(--space-2xl);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--space-xl);
}

/* Toast */
.toast-container {
    position: fixed;
    top: 24px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 9999;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--space-sm);
    pointer-events: none;
    width: max-content;
    max-width: 90%;
}

.toast {
    pointer-events: auto;
    padding: 12px 20px;
    border-radius: var(--radius-full);
    font-size: var(--fs-caption);
    font-weight: var(--fw-medium);
    box-shadow: var(--shadow-lg);
    opacity: 0;
    transform: translateY(-12px) scale(0.96);
    animation: toastIn var(--duration-normal) var(--ease-out) forwards;
    white-space: nowrap;
    max-width: 90vw;
    text-align: center;
}

.toast.removing {
    animation: toastOut var(--duration-fast) ease-in forwards;
}

.toast--error { background: var(--error); color: #fff; }
.toast--success { background: var(--success); color: #fff; }
.toast--warning { background: var(--warning); color: #fff; }
.toast--info { background: var(--bg-card); color: var(--text-primary); border: 1px solid var(--border-default); }

@keyframes toastIn {
    to { opacity: 1; transform: translateY(0) scale(1); }
}
@keyframes toastOut {
    to { opacity: 0; transform: translateY(-8px) scale(0.96); }
}

/* Header */
.header {
    text-align: center;
    animation: fadeUp 0.6s var(--ease-out) both;
}

.header h1 {
    font-size: var(--fs-display);
    font-weight: var(--fw-bold);
    letter-spacing: -0.02em;
    line-height: var(--lh-tight);
    color: var(--text-primary);
    margin-bottom: var(--space-sm);
}

.header h1::after {
    content: '';
    display: block;
    width: 32px;
    height: 2px;
    background: var(--accent-red);
    margin: var(--space-md) auto 0;
    border-radius: 1px;
}

.header p {
    font-size: var(--fs-body);
    color: var(--text-secondary);
    margin-top: var(--space-md);
    letter-spacing: 0.01em;
    max-width: 680px;
}

/* Input Card */
.input-card {
    width: 100%;
    padding: var(--space-xl);
    background: var(--bg-card);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-sm);
    display: flex;
    flex-direction: column;
    gap: var(--space-md);
    animation: fadeUp 0.6s var(--ease-out) 0.1s both;
}

.url-input-wrap {
    position: relative;
    display: flex;
    align-items: center;
}

.url-input-icon {
    position: absolute;
    left: 16px;
    color: var(--text-tertiary);
    pointer-events: none;
}

.url-input {
    width: 100%;
    padding: 14px 16px 14px 48px;
    font-family: var(--font-family);
    font-size: var(--fs-body);
    color: var(--text-primary);
    background: var(--bg-input);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-md);
    outline: none;
    transition: all var(--duration-fast) var(--ease-out);
}

.url-input:hover {
    border-color: var(--border-focus);
}

.url-input:focus {
    border-color: var(--border-focus);
    box-shadow: 0 0 0 3px rgba(139, 32, 32, 0.1);
    background: var(--bg-card);
}

.url-input::placeholder {
    color: var(--text-tertiary);
}

.input-hint {
    text-align: center;
    font-size: var(--fs-small);
    color: var(--text-tertiary);
}

/* Convert Button */
.convert-btn {
    width: 100%;
    padding: 14px 32px;
    font-family: var(--font-family);
    font-size: var(--fs-body);
    font-weight: var(--fw-semibold);
    color: var(--text-on-primary);
    background: var(--primary);
    border: none;
    border-radius: var(--radius-full);
    cursor: pointer;
    transition: all var(--duration-normal) var(--ease-out);
    box-shadow: 0 2px 8px rgba(139, 32, 32, 0.20);
    position: relative;
    overflow: hidden;
}

.convert-btn:hover:not(:disabled) {
    background: var(--primary-hover);
    box-shadow: 0 4px 16px rgba(139, 32, 32, 0.25);
    transform: translateY(-1px);
}

.convert-btn:active:not(:disabled) {
    background: var(--primary-active);
    transform: translateY(0);
    box-shadow: 0 1px 4px rgba(139, 32, 32, 0.15);
}

.convert-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    box-shadow: none;
}

.convert-btn .btn-content {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-sm);
    transition: opacity var(--duration-fast);
}

.convert-btn .btn-spinner {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity var(--duration-fast);
}

.convert-btn.loading .btn-content { opacity: 0; }
.convert-btn.loading .btn-spinner { opacity: 1; }

.spinner {
    width: 20px;
    height: 20px;
    border: 2px solid rgba(255,255,255,0.3);
    border-top-color: #fff;
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
}

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

/* Result Section */
.result-section {
    width: 100%;
    animation: fadeUp 0.5s var(--ease-out) both;
}

.result-card {
    background: var(--bg-card);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-md);
    padding: var(--space-xl);
    display: flex;
    gap: var(--space-lg);
    align-items: stretch;
}

.result-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: var(--space-md);
    min-width: 0;
}

.result-url-group {
    display: flex;
    flex-direction: column;
    gap: var(--space-sm);
}

.result-label {
    font-size: var(--fs-caption);
    font-weight: var(--fw-medium);
    color: var(--text-secondary);
}

.short-url-wrap {
    display: flex;
    gap: var(--space-sm);
    align-items: center;
}

.short-url-input {
    flex: 1;
    min-width: 0;
    padding: 12px 16px;
    font-family: var(--font-family);
    font-size: var(--fs-body);
    font-weight: var(--fw-semibold);
    color: var(--primary);
    background: var(--primary-subtle);
    border: 1px solid rgba(139, 32, 32, 0.12);
    border-radius: var(--radius-md);
    outline: none;
    text-overflow: ellipsis;
}

.icon-btn {
    width: 42px;
    height: 42px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--border-default);
    border-radius: var(--radius-md);
    background: var(--bg-card);
    color: var(--text-secondary);
    cursor: pointer;
    transition: all var(--duration-fast) var(--ease-out);
    flex-shrink: 0;
    text-decoration: none;
}

.icon-btn:hover {
    border-color: var(--primary);
    color: var(--primary);
    background: var(--primary-subtle);
}

.icon-btn.copied {
    border-color: var(--success);
    color: var(--success);
    background: var(--success-bg);
}

.result-meta {
    display: flex;
    flex-direction: column;
    gap: var(--space-sm);
    padding-top: var(--space-sm);
    border-top: 1px solid var(--border-light);
}

.meta-item {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    font-size: var(--fs-caption);
}

.meta-label {
    color: var(--text-secondary);
    flex-shrink: 0;
}

.meta-link {
    color: var(--primary);
    text-decoration: none;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 100%;
}

.meta-link:hover {
    text-decoration: underline;
}

.meta-value {
    color: var(--text-primary);
    font-weight: var(--fw-medium);
}

.result-qr {
    width: 140px;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--space-sm);
    padding-left: var(--space-lg);
    border-left: 1px solid var(--border-light);
}

.result-qr canvas {
    width: 140px;
    height: 140px;
    border-radius: var(--radius-sm);
}

.qr-actions {
    width: 100%;
    display: flex;
    justify-content: center;
}

.qr-download-btn {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 6px 12px;
    font-family: var(--font-family);
    font-size: var(--fs-small);
    font-weight: var(--fw-medium);
    color: var(--primary);
    background: var(--primary-subtle);
    border: 1px solid rgba(139, 32, 32, 0.12);
    border-radius: var(--radius-full);
    cursor: pointer;
    transition: all var(--duration-fast) var(--ease-out);
    white-space: nowrap;
}

.qr-download-btn:hover {
    background: rgba(139, 32, 32, 0.14);
    border-color: var(--primary);
}

.qr-download-btn svg {
    flex-shrink: 0;
}

/* History */
.history-section {
    width: 100%;
    animation: fadeUp 0.5s var(--ease-out) both;
}

.history-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: var(--space-md);
}

.history-title {
    font-size: var(--fs-title);
    font-weight: var(--fw-semibold);
    letter-spacing: -0.01em;
}

.text-btn {
    font-family: var(--font-family);
    font-size: var(--fs-caption);
    font-weight: var(--fw-medium);
    color: var(--text-tertiary);
    background: transparent;
    border: none;
    cursor: pointer;
    transition: color var(--duration-fast);
}

.text-btn:hover {
    color: var(--primary);
}

.history-list {
    display: flex;
    flex-direction: column;
    gap: var(--space-sm);
}

.history-item {
    display: flex;
    align-items: center;
    gap: var(--space-md);
    padding: var(--space-md) var(--space-lg);
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    transition: all var(--duration-fast) var(--ease-out);
}

.history-item:hover {
    box-shadow: var(--shadow-md);
    transform: translateY(-1px);
}

.history-info {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.history-short {
    font-size: var(--fs-body);
    font-weight: var(--fw-semibold);
    color: var(--primary);
    text-decoration: none;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.history-short:hover {
    text-decoration: underline;
}

.history-long {
    font-size: var(--fs-small);
    color: var(--text-tertiary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.history-actions {
    display: flex;
    gap: var(--space-xs);
    flex-shrink: 0;
}

.history-actions .icon-btn {
    width: 34px;
    height: 34px;
    border-radius: var(--radius-sm);
}

.history-actions .icon-btn.remove-history:hover {
    border-color: var(--error);
    color: var(--error);
    background: var(--error-bg);
}

/* SEO 长尾关键词：视觉隐藏，仅搜索引擎可见 */
.seo-keywords {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
    pointer-events: none;
}

/* Features */
.features-section {
    width: 100%;
    align-self: stretch;
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: var(--space-md);
    animation: fadeUp 0.6s var(--ease-out) 0.2s both;
}

.feature-card {
    min-width: 0;
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    padding: var(--space-xl);
    box-shadow: var(--shadow-sm);
    text-align: center;
    transition: all var(--duration-fast) var(--ease-out);
}

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

.feature-icon {
    width: 52px;
    height: 52px;
    margin: 0 auto var(--space-md);
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--primary-subtle);
    color: var(--primary);
    border-radius: var(--radius-md);
}

.feature-card h3 {
    font-size: var(--fs-title);
    font-weight: var(--fw-semibold);
    margin-bottom: var(--space-xs);
}

.feature-card p {
    font-size: var(--fs-body);
    color: var(--text-secondary);
    line-height: 1.5;
}

/* Footer */
.footer {
    width: 100%;
    text-align: center;
    padding-top: var(--space-xl);
    border-top: 1px solid var(--border-light);
    animation: fadeUp 0.6s var(--ease-out) 0.3s both;
}

.footer p {
    font-size: var(--fs-small);
    color: var(--text-tertiary);
}

/* 累计统计 */
.convert-stats {
    text-align: center;
    font-size: var(--fs-small);
    color: var(--text-tertiary);
    animation: fadeUp 0.6s var(--ease-out) 0.3s both;
}

.convert-stats strong {
    color: var(--primary);
    font-weight: var(--fw-semibold);
    font-variant-numeric: tabular-nums;
}

/* Animations */
@keyframes fadeUp {
    from {
        opacity: 0;
        transform: translateY(12px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes fadeScale {
    from {
        opacity: 0;
        transform: scale(0.97);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

/* Responsive */
@media (max-width: 640px) {
    .container {
        padding: var(--space-2xl) var(--space-md) var(--space-xl);
        gap: var(--space-md);
    }

    .header h1 {
        font-size: 24px;
    }

    .input-card {
        padding: var(--space-lg);
    }

    .result-card {
        flex-direction: column;
        padding: var(--space-lg);
    }

    .result-qr {
        width: 100%;
        padding-left: 0;
        padding-top: var(--space-lg);
        border-left: none;
        border-top: 1px solid var(--border-light);
    }

    .short-url-wrap {
        flex-wrap: wrap;
    }

    .short-url-input {
        width: 100%;
        order: -1;
    }

    .features-section {
        grid-template-columns: 1fr;
    }

    .history-item {
        flex-direction: column;
        align-items: flex-start;
        gap: var(--space-sm);
    }

    .history-actions {
        width: 100%;
        justify-content: flex-end;
    }

    .back-home {
        top: 8px;
        left: 8px;
        padding: 4px 8px;
        font-size: 11px;
        gap: 3px;
    }
    .back-home svg {
        width: 12px;
        height: 12px;
    }

    .contact-service {
        top: 8px;
        right: 8px;
    }
    .contact-btn {
        padding: 4px 8px;
        font-size: 11px;
        gap: 3px;
    }
    .contact-btn svg {
        width: 12px;
        height: 12px;
    }
    .contact-dropdown {
        width: 140px;
        padding: 10px;
    }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        transition-duration: 0.01ms !important;
    }
}
