:root {
    --site-ink: #17233a;
    --site-muted: #64748b;
    --site-primary: #2563eb;
    --site-primary-dark: #1d4ed8;
    --site-accent: #f97316;
    --site-surface: rgba(255, 255, 255, 0.94);
    --site-border: rgba(148, 163, 184, 0.24);
    --site-shadow: 0 14px 34px rgba(15, 23, 42, 0.08);
    --site-shadow-hover: 0 18px 42px rgba(15, 23, 42, 0.12);
}

html {
    background: #f4f7fb;
    -webkit-text-size-adjust: 100%;
}

body {
    min-height: 100dvh;
    color: var(--site-ink);
    background:
        radial-gradient(circle at 100% 0, rgba(191, 219, 254, 0.55), transparent 28rem),
        radial-gradient(circle at 0 52%, rgba(224, 231, 255, 0.42), transparent 32rem),
        #f4f7fb;
    font-family: "PingFang SC", "Microsoft YaHei", "Noto Sans CJK SC", system-ui, sans-serif;
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
}

::selection {
    color: #fff;
    background: #3b82f6;
}

button,
a,
input,
textarea {
    -webkit-tap-highlight-color: transparent;
}

a {
    text-underline-offset: 0.18em;
}

a:focus-visible,
button:focus-visible,
input:focus-visible,
textarea:focus-visible {
    outline: 3px solid rgba(59, 130, 246, 0.34);
    outline-offset: 2px;
}

/* 补齐各页面共用的轻量工具类，避免二级页出现静默布局退化。 */
.items-start { align-items: flex-start; }
.gap-2 { gap: 0.5rem; }
.mt-4 { margin-top: 1rem; }
.mb-3 { margin-bottom: 0.75rem; }
.pb-2 { padding-bottom: 0.5rem; }
.pb-4 { padding-bottom: 1rem; }
.pt-6 { padding-top: 1.5rem; }
.text-xl { font-size: 1.25rem; }
.border-t { border-top: 1px solid #e5e7eb; }

.app-container {
    min-height: 100dvh;
    isolation: isolate;
}

.sidebar-active {
    overflow: hidden;
}

.sidebar {
    position: sticky;
    top: 0;
    align-self: flex-start;
    width: 16rem;
    height: 100dvh;
    overflow-y: auto;
    overscroll-behavior: contain;
    background: rgba(255, 255, 255, 0.86);
    border-right: 1px solid var(--site-border);
    box-shadow: 12px 0 30px rgba(15, 23, 42, 0.035);
    backdrop-filter: blur(18px);
    -webkit-backdrop-filter: blur(18px);
}

.sidebar::-webkit-scrollbar {
    width: 7px;
}

.sidebar::-webkit-scrollbar-thumb {
    background: rgba(148, 163, 184, 0.45);
    border: 2px solid transparent;
    border-radius: 999px;
    background-clip: padding-box;
}

.logo-container {
    min-height: 86px;
    padding: 1.25rem 1.1rem;
    border-bottom: 1px solid rgba(226, 232, 240, 0.88);
}

.logo {
    border-radius: 0.75rem;
    box-shadow: 0 7px 16px rgba(37, 99, 235, 0.2);
}

.brand-name {
    color: var(--site-accent);
    letter-spacing: 0.02em;
}

.nav-item {
    position: relative;
    min-height: 48px;
    margin: 0.3rem 0.65rem;
    padding: 0.75rem 0.9rem;
    border: 1px solid transparent;
    border-radius: 0.8rem;
    color: #526076;
    font-weight: 600;
    transition: color 0.2s ease, background-color 0.2s ease, border-color 0.2s ease, transform 0.2s ease, box-shadow 0.2s ease;
}

.nav-item:hover {
    color: var(--site-primary-dark);
    background: rgba(239, 246, 255, 0.9);
    border-color: rgba(191, 219, 254, 0.9);
    transform: translateX(2px);
}

.nav-item.active {
    color: #fff;
    background: linear-gradient(135deg, #3b82f6, #2563eb);
    border-color: rgba(37, 99, 235, 0.86);
    box-shadow: 0 8px 18px rgba(37, 99, 235, 0.2);
}

.nav-icon {
    opacity: 0.9;
}

.mobile-header {
    background: rgba(255, 255, 255, 0.88);
    border-bottom-color: rgba(226, 232, 240, 0.88);
    box-shadow: 0 1px 0 rgba(255, 255, 255, 0.8), 0 10px 26px rgba(15, 23, 42, 0.045);
    backdrop-filter: blur(18px);
    -webkit-backdrop-filter: blur(18px);
}

.menu-toggle {
    color: #334155;
    border: 1px solid rgba(203, 213, 225, 0.82);
    border-radius: 0.75rem;
    background: rgba(255, 255, 255, 0.9);
    box-shadow: 0 2px 6px rgba(15, 23, 42, 0.06);
}

.menu-toggle:hover {
    color: var(--site-primary-dark);
    background: #eff6ff;
    border-color: #bfdbfe;
}

.mobile-overlay {
    background: rgba(15, 23, 42, 0.44);
    backdrop-filter: blur(2px);
    -webkit-backdrop-filter: blur(2px);
}

.main-content {
    min-width: 0;
    padding: clamp(1.5rem, 3vw, 2.5rem) !important;
}

.main-content > header,
.hero-header {
    position: relative;
    overflow: hidden;
    margin-bottom: clamp(1.25rem, 2.3vw, 2rem) !important;
    padding: clamp(1.3rem, 2.6vw, 2rem);
    border: 1px solid rgba(219, 234, 254, 0.9);
    border-radius: 1.35rem;
    background: linear-gradient(130deg, rgba(255, 255, 255, 0.97), rgba(239, 246, 255, 0.92));
    box-shadow: var(--site-shadow);
}

.main-content > header::after,
.hero-header::after {
    position: absolute;
    right: -4.5rem;
    bottom: -5.8rem;
    width: 13rem;
    height: 13rem;
    border: 1.3rem solid rgba(147, 197, 253, 0.17);
    border-radius: 50%;
    content: "";
    pointer-events: none;
}

.main-content > header > *,
.hero-header > * {
    position: relative;
    z-index: 1;
}

.main-content > header h1,
.hero-title-row h1 {
    color: #172554;
    letter-spacing: -0.025em;
}

.main-content > header p {
    max-width: 48rem;
    color: #526076;
}

.shadow-md {
    box-shadow: var(--site-shadow);
}

.rounded-lg {
    border-radius: 1rem;
}

.control-panel,
.preview-card,
.main-content > article,
.main-content > .bg-white,
.main-content > .max-w-4xl > .bg-white,
#instructions,
#contact {
    border: 1px solid var(--site-border);
    border-radius: 1.1rem !important;
    box-shadow: var(--site-shadow);
}

.control-panel {
    background: linear-gradient(155deg, rgba(255, 255, 255, 0.98), rgba(241, 245, 249, 0.94));
}

.control-panel h2,
.content-section h2 {
    color: #172554;
}

.control-panel input,
.control-panel textarea,
.table-field-input {
    border-color: #cbd5e1;
    background: rgba(255, 255, 255, 0.96);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.7), 0 1px 2px rgba(15, 23, 42, 0.03);
    transition: border-color 0.2s ease, box-shadow 0.2s ease, background-color 0.2s ease;
}

.control-panel input:hover,
.control-panel textarea:hover,
.table-field-input:hover {
    border-color: #94a3b8;
}

.control-panel input:focus,
.control-panel textarea:focus,
.table-field-input:focus {
    border-color: #3b82f6;
    background: #fff;
    box-shadow: 0 0 0 4px rgba(59, 130, 246, 0.13);
}

.table-row-card {
    border-color: rgba(203, 213, 225, 0.88);
    box-shadow: 0 4px 10px rgba(15, 23, 42, 0.035);
}

.table-row-card:hover {
    transform: translateY(-1px);
    box-shadow: 0 10px 20px rgba(15, 23, 42, 0.07);
}

.control-panel button,
.section-action,
.back-action {
    box-shadow: 0 8px 18px rgba(37, 99, 235, 0.16);
}

.control-panel button {
    transition: transform 0.2s ease, box-shadow 0.2s ease, filter 0.2s ease;
}

.control-panel button:hover {
    transform: translateY(-1px);
    box-shadow: 0 12px 24px rgba(37, 99, 235, 0.22);
    filter: saturate(1.05);
}

.control-panel button:active,
.section-action:active,
.back-action:active {
    transform: translateY(0) scale(0.985);
}

.preview-card {
    padding: 0.9rem;
    background: rgba(255, 255, 255, 0.97);
}

.preview-toolbar {
    padding: 0.2rem 0.15rem 0.6rem;
    color: #526076;
}

.preview-wrapper {
    border: 1px solid rgba(203, 213, 225, 0.8);
    border-radius: 0.8rem;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.85);
}

.preview-zoom-controls {
    border-color: rgba(191, 219, 254, 0.9);
    background: #eff6ff;
}

.preview-zoom-button {
    min-width: 38px;
    border: 1px solid rgba(203, 213, 225, 0.86);
    transition: color 0.2s ease, background-color 0.2s ease, border-color 0.2s ease, transform 0.2s ease;
}

.preview-zoom-button:not(:disabled):hover {
    color: var(--site-primary-dark);
    border-color: #93c5fd;
    background: #eff6ff;
}

.preview-zoom-button:not(:disabled):active {
    transform: scale(0.96);
}

.hero-feature-button,
.section-action,
.back-action {
    border-color: #bfdbfe;
    transition: transform 0.2s ease, box-shadow 0.2s ease, background-color 0.2s ease, border-color 0.2s ease, color 0.2s ease;
}

.section-action:hover,
.back-action:hover {
    transform: translateY(-1px);
    box-shadow: 0 12px 22px rgba(37, 99, 235, 0.18);
}

.main-content > article {
    background: var(--site-surface);
}

.main-content article .prose {
    max-width: 72ch;
}

.content-section {
    scroll-margin-top: 5.5rem;
}

.content-section h2 {
    border-bottom-color: #dbeafe;
}

.content-section .bg-gray-50,
.main-content .bg-blue-50,
.main-content .bg-green-50,
.main-content .bg-purple-50,
.main-content .bg-orange-50 {
    border: 1px solid rgba(203, 213, 225, 0.52);
    box-shadow: 0 5px 14px rgba(15, 23, 42, 0.04);
}

.contact-card {
    border-radius: 1rem;
}

.main-content img.w-48 {
    padding: 0.4rem;
    border-radius: 0.9rem;
    background: #fff;
    box-shadow: 0 10px 22px rgba(15, 23, 42, 0.08);
}

.back-link-wrap {
    align-items: center;
}

footer {
    color: #64748b;
}

/* 页脚导航改为清晰、紧凑的操作入口。 */
footer p.mt-2 {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    gap: 0.55rem;
    margin-top: 0.8rem;
    font-size: 0;
    line-height: 1;
}

footer p.mt-2 a {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 2.5rem;
    padding: 0 0.9rem;
    border: 1px solid rgba(147, 197, 253, 0.78);
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.82);
    box-shadow: 0 4px 10px rgba(15, 23, 42, 0.055);
    color: #2563eb;
    font-size: 0.8125rem;
    font-weight: 700;
    line-height: 1;
    text-decoration: none !important;
    transition: transform 0.2s ease, color 0.2s ease, border-color 0.2s ease, background-color 0.2s ease, box-shadow 0.2s ease;
}

footer p.mt-2 a:hover {
    border-color: #60a5fa;
    background: #eff6ff;
    box-shadow: 0 8px 16px rgba(37, 99, 235, 0.14);
    color: #1d4ed8;
    text-decoration: none !important;
    transform: translateY(-1px);
}

/* 页面与操作按钮的视觉层级 */
.control-panel {
    position: relative;
    overflow: hidden;
    border-top: 3px solid rgba(59, 130, 246, 0.82);
    box-shadow: 0 18px 38px rgba(15, 23, 42, 0.09), 0 2px 7px rgba(37, 99, 235, 0.06);
}

.control-panel::after {
    position: absolute;
    top: -5rem;
    right: -5rem;
    width: 12rem;
    height: 12rem;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(191, 219, 254, 0.32), transparent 68%);
    content: "";
    pointer-events: none;
}

.control-panel > * {
    position: relative;
    z-index: 1;
}

.control-panel h2 {
    letter-spacing: 0.01em;
}

.control-panel input,
.control-panel textarea,
.table-field-input {
    border-radius: 0.75rem;
}

.preview-card {
    border-top: 3px solid rgba(125, 211, 252, 0.75);
    box-shadow: 0 18px 38px rgba(15, 23, 42, 0.09), 0 2px 7px rgba(14, 165, 233, 0.05);
}

.preview-toolbar {
    padding: 0.55rem;
    border: 1px solid rgba(219, 234, 254, 0.96);
    border-radius: 0.85rem;
    background: linear-gradient(135deg, rgba(248, 250, 252, 0.92), rgba(239, 246, 255, 0.88));
}

.preview-zoom-controls {
    padding: 0.3rem;
    border-color: rgba(147, 197, 253, 0.72);
    border-radius: 0.75rem;
    background: rgba(219, 234, 254, 0.76);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.75);
}

.preview-zoom-button {
    border-color: transparent;
    border-radius: 0.6rem;
    background: transparent;
    box-shadow: none;
}

.preview-zoom-reset {
    color: #1d4ed8;
    background: #fff;
    box-shadow: 0 3px 8px rgba(37, 99, 235, 0.11);
}

.preview-zoom-button:not(:disabled):hover {
    border-color: transparent;
    background: rgba(255, 255, 255, 0.78);
}

.download-actions > button {
    position: relative;
    isolation: isolate;
    min-height: 3.5rem;
    overflow: hidden;
    border: 1px solid rgba(30, 64, 175, 0.68) !important;
    border-radius: 0.9rem !important;
    background: linear-gradient(135deg, #3b82f6 0%, #2563eb 52%, #1e40af 100%) !important;
    box-shadow: 0 13px 24px rgba(37, 99, 235, 0.28), inset 0 1px 0 rgba(255, 255, 255, 0.24) !important;
    letter-spacing: 0.035em;
}

.download-actions > button > * {
    position: relative;
    z-index: 1;
}

.download-actions > button::after {
    position: absolute;
    inset: 0;
    z-index: 0;
    background: linear-gradient(112deg, transparent 28%, rgba(255, 255, 255, 0.3) 48%, transparent 68%);
    content: "";
    opacity: 0;
    pointer-events: none;
    transform: translateX(-120%);
    transition: transform 0.45s ease, opacity 0.2s ease;
}

.download-actions > button:not(:disabled):hover {
    background: linear-gradient(135deg, #60a5fa 0%, #2563eb 48%, #1e3a8a 100%) !important;
    box-shadow: 0 16px 28px rgba(37, 99, 235, 0.34), inset 0 1px 0 rgba(255, 255, 255, 0.28) !important;
    transform: translateY(-2px) !important;
}

.download-actions > button:not(:disabled):hover::after {
    opacity: 1;
    transform: translateX(120%);
}

.control-panel button:disabled {
    cursor: not-allowed;
    filter: grayscale(0.2);
    opacity: 0.62;
    transform: none;
}

.section-action,
.back-action {
    border-radius: 0.85rem;
    background: linear-gradient(135deg, #fff, #eff6ff);
    box-shadow: 0 8px 18px rgba(37, 99, 235, 0.11), inset 0 1px 0 rgba(255, 255, 255, 0.82);
}

.section-action:hover,
.back-action:hover {
    background: linear-gradient(135deg, #fff, #dbeafe);
}

.menu-toggle:active,
.preview-zoom-button:not(:disabled):active {
    transform: scale(0.95);
}

.menu-toggle {
    display: inline-grid;
    flex: 0 0 44px;
    width: 44px;
    height: 44px;
    place-items: center;
}

.main-content a.inline-block.bg-blue-600.text-white {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 3.5rem;
    border: 1px solid rgba(30, 64, 175, 0.68);
    border-radius: 0.9rem;
    background: linear-gradient(135deg, #3b82f6 0%, #2563eb 52%, #1e40af 100%) !important;
    box-shadow: 0 13px 24px rgba(37, 99, 235, 0.28), inset 0 1px 0 rgba(255, 255, 255, 0.24);
    letter-spacing: 0.035em;
    transition: transform 0.2s ease, box-shadow 0.2s ease, filter 0.2s ease;
}

@media (hover: hover) {
    .main-content a.inline-block.bg-blue-600.text-white:hover {
        background: linear-gradient(135deg, #60a5fa 0%, #2563eb 48%, #1e3a8a 100%) !important;
        box-shadow: 0 16px 28px rgba(37, 99, 235, 0.34), inset 0 1px 0 rgba(255, 255, 255, 0.28);
        transform: translateY(-2px);
    }
}

@media (max-width: 768px) {
    .sidebar {
        position: fixed;
        top: 0;
        left: 0;
        z-index: 50;
        width: min(280px, 86vw);
        max-width: 86vw;
        height: 100dvh;
        padding-top: env(safe-area-inset-top);
        border-right: 1px solid rgba(226, 232, 240, 0.86);
        box-shadow: 20px 0 48px rgba(15, 23, 42, 0.22);
    }

    .mobile-header {
        position: sticky;
        top: 0;
        z-index: 35;
        min-height: 60px;
        padding-top: max(0.75rem, env(safe-area-inset-top));
        padding-right: 0.85rem;
        padding-left: 0.85rem;
    }

    .main-content {
        padding: 1rem 0.85rem max(1.75rem, env(safe-area-inset-bottom)) !important;
    }

    .main-content > header,
    .hero-header {
        margin-bottom: 1rem !important;
        padding: 1.15rem;
        border-radius: 1.05rem;
    }

    .main-content > header h1,
    .hero-title-row h1 {
        font-size: clamp(1.38rem, 6vw, 1.75rem) !important;
        line-height: 1.25;
    }

    .main-content > header p {
        margin-bottom: 0 !important;
        font-size: 0.9rem;
        line-height: 1.65;
    }

    .hero-title-row {
        gap: 0.8rem;
    }

    .hero-feature-button {
        min-height: 46px;
    }

    .control-panel,
    .preview-card,
    .main-content > article,
    .main-content > .bg-white,
    .main-content > .max-w-4xl > .bg-white,
    #instructions,
    #contact {
        border-radius: 0.95rem !important;
    }

    .control-panel {
        padding: 1rem;
    }

    .control-panel input,
    .control-panel textarea,
    .table-field-input {
        font-size: 16px;
    }

    .preview-section {
        position: static !important;
        top: auto;
    }

    .preview-card {
        padding: 0.55rem;
    }

    .preview-toolbar {
        gap: 0.55rem;
        padding: 0.1rem 0.1rem 0.55rem;
    }

    .preview-hint {
        font-size: 0.76rem;
        line-height: 1.45;
    }

    .preview-zoom-button {
        min-width: 44px;
        height: 44px;
    }

    .preview-zoom-reset {
        min-width: 4.25rem;
    }

    .preview-wrapper {
        max-height: none;
        overflow: hidden;
    }

    .preview-wrapper.is-zoomed {
        overflow: auto;
    }

    .download-actions {
        border-top: 1px solid rgba(191, 219, 254, 0.82);
        box-shadow: 0 -12px 24px rgba(248, 250, 252, 0.82);
    }

    .download-actions > button {
        min-height: 3.6rem;
        font-size: 1rem;
    }

    .section-action,
    .back-action {
        min-height: 3.25rem;
        border-radius: 0.8rem;
    }

    .main-content a.inline-block.bg-blue-600.text-white {
        width: 100%;
    }

    footer p.mt-2 a {
        min-height: 2.75rem;
        padding: 0 1rem;
        font-size: 0.875rem;
    }

    .main-content > .max-w-4xl > .bg-white,
    .main-content > .bg-white,
    .main-content > article {
        padding: 1.15rem !important;
    }

    .main-content article .prose {
        max-width: none;
    }

    .main-content article .content-section {
        margin-bottom: 1.75rem;
    }

    .main-content article .content-section h2 {
        font-size: 1.25rem;
        line-height: 1.4;
    }

    .main-content article .flex.gap-4 {
        gap: 0.8rem;
    }

    .main-content img.w-48 {
        width: min(12rem, 72vw);
        height: auto;
    }

    .back-link-wrap {
        margin-top: 1.25rem;
        margin-bottom: 1.5rem;
    }

    footer {
        padding-bottom: max(1.25rem, env(safe-area-inset-bottom));
        line-height: 1.65;
    }
}

@media (max-width: 480px) {
    .logo-container {
        min-height: 76px;
    }

    .nav-item {
        min-height: 46px;
        margin: 0.22rem 0.45rem;
    }

    .hero-title-row {
        align-items: stretch;
    }

    .hero-feature-button {
        width: 100%;
        justify-content: space-between;
    }

    .main-content .bg-blue-50,
    .main-content .bg-green-50,
    .main-content .bg-purple-50,
    .main-content .bg-orange-50 {
        padding: 1rem;
    }
}

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