:root {
    color-scheme: light;
    --color-primary: #2563eb;
    --color-primary-hover: #1d4ed8;
    --color-primary-soft: rgba(37, 99, 235, 0.12);
    --color-accent: #f97316;
    --color-bg: #eef4ff;
    --color-bg-secondary: #f8fbff;
    --color-surface: rgba(255, 255, 255, 0.82);
    --color-surface-soft: rgba(241, 245, 249, 0.8);
    --color-input-bg: rgba(255, 255, 255, 0.92);
    --color-border: rgba(148, 163, 184, 0.22);
    --color-text: #10203a;
    --color-text-muted: #5f718c;
    --color-success: #0f766e;
    --color-error: #dc2626;
    --shadow-card: 0 24px 80px rgba(15, 23, 42, 0.12);
    --shadow-soft: 0 10px 30px rgba(15, 23, 42, 0.08);
    --backdrop-blur: 18px;
    --radius-xl: 24px;
    --radius-lg: 18px;
    --radius-md: 14px;
}

body[data-theme="dark"] {
    color-scheme: dark;
    --color-primary: #60a5fa;
    --color-primary-hover: #3b82f6;
    --color-primary-soft: rgba(96, 165, 250, 0.16);
    --color-accent: #f59e0b;
    --color-bg: #06111f;
    --color-bg-secondary: #0a1629;
    --color-surface: rgba(9, 18, 34, 0.72);
    --color-surface-soft: rgba(12, 24, 46, 0.86);
    --color-input-bg: rgba(10, 23, 43, 0.92);
    --color-border: rgba(148, 163, 184, 0.18);
    --color-text: #eff6ff;
    --color-text-muted: #93a5c3;
    --shadow-card: 0 24px 90px rgba(2, 8, 23, 0.45);
    --shadow-soft: 0 14px 36px rgba(2, 8, 23, 0.34);
}

* {
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
}

body {
    position: relative;
    margin: 0;
    background: var(--color-bg);
    color: var(--color-text);
    font-family: "Inter", "PingFang SC", "Microsoft YaHei", "Noto Sans SC", sans-serif;
    line-height: 1.6;
    transition: background-color 220ms ease, color 220ms ease;
}

body::before,
body::after {
    content: "";
    position: fixed;
    inset: auto;
    width: 420px;
    height: 420px;
    border-radius: 999px;
    pointer-events: none;
    filter: blur(60px);
    opacity: 0.55;
    z-index: 0;
}

body::before {
    top: -140px;
    right: -90px;
    background: rgba(96, 165, 250, 0.22);
}

body::after {
    left: -120px;
    bottom: -180px;
    background: rgba(249, 115, 22, 0.16);
}

button,
input,
select,
textarea {
    font: inherit;
}

button {
    cursor: pointer;
}

img {
    max-width: 100%;
    display: block;
}

.page-shell {
    position: relative;
    z-index: 1;
    max-width: 1280px;
    margin: 0 auto;
    padding: 32px 24px 56px;
}

.card {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-xl);
    padding: 28px;
    box-shadow: var(--shadow-card);
    backdrop-filter: blur(var(--backdrop-blur));
}

.hero {
    display: grid;
    grid-template-columns: minmax(0, 1.15fr) minmax(280px, 0.85fr);
    gap: 24px;
    margin-bottom: 24px;
}

.hero__content {
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.hero__toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 8px;
}

.eyebrow {
    margin: 0;
    color: var(--color-primary);
    font-size: 13px;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.theme-toggle {
    min-height: 40px;
    padding: 8px 14px;
    border: 1px solid var(--color-border);
    border-radius: 999px;
    background: var(--color-surface-soft);
    color: var(--color-text);
    font-size: 13px;
    font-weight: 700;
    letter-spacing: 0.02em;
    transition: transform 180ms ease, border-color 180ms ease, background-color 180ms ease;
}

.theme-toggle:hover {
    transform: translateY(-1px);
}

h1,
h2,
h3,
p {
    margin-top: 0;
}

h1 {
    margin-bottom: 16px;
    font-size: clamp(2rem, 4vw, 3.4rem);
    line-height: 1.1;
    letter-spacing: -0.03em;
}

h2 {
    margin-bottom: 10px;
    font-size: 1.45rem;
    line-height: 1.25;
}

h3 {
    margin-bottom: 6px;
    font-size: 1.05rem;
    line-height: 1.35;
}

.hero__lead,
.section-desc,
.panel-section__header p,
.metric-card p,
.field-hint,
.field-hint-card,
.list-plain,
.copy-feedback {
    color: var(--color-text-muted);
}

.hero__lead {
    max-width: 46ch;
    margin-bottom: 18px;
    font-size: 1.02rem;
}

.hero__pills,
.guide-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
}

.pill,
.tag {
    display: inline-flex;
    align-items: center;
    min-height: 40px;
    padding: 8px 14px;
    border: 1px solid var(--color-border);
    border-radius: 999px;
    background: var(--color-surface-soft);
    color: var(--color-text);
    font-size: 13px;
    font-weight: 700;
}

.hero__metrics {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 14px;
}

.metric-card {
    min-height: 154px;
    padding: 20px;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    background: var(--color-surface-soft);
    box-shadow: var(--shadow-soft);
}

.metric-card strong {
    display: block;
    margin-bottom: 8px;
    color: var(--color-primary);
    font-size: 2rem;
    line-height: 1;
}

.metric-card span {
    display: block;
    margin-bottom: 8px;
    font-size: 14px;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.metric-card p {
    margin-bottom: 0;
    font-size: 13px;
    line-height: 1.5;
}

.workspace {
    display: grid;
    grid-template-columns: minmax(0, 1.16fr) minmax(320px, 0.84fr);
    gap: 24px;
    align-items: start;
}

.form-card,
.guide-card,
.result-card {
    background:
        linear-gradient(180deg, rgba(255, 255, 255, 0.03), rgba(255, 255, 255, 0)),
        var(--color-surface);
}

.form-card form,
.sidebar {
    display: grid;
    gap: 20px;
}

.section-heading {
    margin-bottom: 8px;
}

.section-heading--compact {
    margin-bottom: 16px;
}

.field-required {
    color: var(--color-accent);
    font-weight: 700;
}

.panel-section {
    display: grid;
    gap: 16px;
    padding-top: 20px;
    border-top: 1px solid var(--color-border);
}

.panel-section:first-of-type {
    padding-top: 0;
    border-top: 0;
}

.panel-section__header {
    display: flex;
    gap: 16px;
    align-items: flex-start;
}

.panel-section__header p,
.section-desc,
.field-hint,
.field-hint-card,
.metric-card p,
.list-plain,
.copy-feedback {
    margin-bottom: 0;
}

.step-index {
    display: inline-grid;
    flex-shrink: 0;
    place-items: center;
    width: 42px;
    height: 42px;
    border-radius: 999px;
    background: var(--color-primary-soft);
    color: var(--color-primary);
    font-size: 14px;
    font-weight: 800;
}

.form-grid {
    display: grid;
    gap: 16px;
}

.form-grid--triple {
    grid-template-columns: repeat(3, minmax(0, 1fr));
}

.form-grid--double {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.field,
.field-group {
    display: grid;
    gap: 8px;
}

.field label,
.field-label,
.field-group legend {
    padding: 0;
    color: var(--color-text);
    font-size: 14px;
    font-weight: 700;
}

.field-group {
    border: 0;
    margin: 0;
}

.field-group legend {
    margin-bottom: 8px;
}

.field--hint-box {
    align-content: start;
}

.field-hint-card {
    display: flex;
    align-items: center;
    min-height: 56px;
    padding: 14px 16px;
    border: 1px dashed var(--color-border);
    border-radius: var(--radius-md);
    background: var(--color-surface-soft);
    font-size: 14px;
}

input,
select {
    width: 100%;
    min-height: 52px;
    padding: 14px 16px;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    background: var(--color-input-bg);
    color: var(--color-text);
    font-size: 16px;
    font-variant-numeric: tabular-nums;
    transition: border-color 180ms ease, box-shadow 180ms ease, background-color 180ms ease, color 180ms ease;
}

input::placeholder {
    color: rgba(148, 163, 184, 0.85);
}

select:disabled,
button:disabled {
    cursor: not-allowed;
}

select:disabled {
    background: var(--color-surface-soft);
    color: #94a3b8;
}

input:focus-visible,
select:focus-visible,
.button:focus-visible,
.theme-toggle:focus-visible,
.choice-card input:focus-visible + span {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.14);
}

.choice-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
}

.choice-card {
    position: relative;
}

.choice-card input {
    position: absolute;
    inset: 0;
    opacity: 0;
    margin: 0;
}

.choice-card span {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 52px;
    padding: 12px 16px;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    background: var(--color-input-bg);
    color: var(--color-text);
    font-weight: 700;
    transition: border-color 180ms ease, background-color 180ms ease, color 180ms ease;
}

.choice-card input:checked + span {
    border-color: var(--color-primary);
    background: var(--color-primary-soft);
    color: var(--color-primary);
}

.notice {
    border-radius: 16px;
    padding: 16px 18px;
}

.notice[hidden] {
    display: none;
}

.notice--error {
    border: 1px solid rgba(248, 113, 113, 0.28);
    background: rgba(127, 29, 29, 0.12);
    color: #fca5a5;
}

.notice__title {
    margin-bottom: 8px;
    font-weight: 800;
}

.notice ul {
    margin: 0;
    padding-left: 18px;
    display: grid;
    gap: 6px;
}

.form-actions {
    display: flex;
    gap: 12px;
    align-items: stretch;
}

.button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    min-height: 56px;
    padding: 14px 18px;
    border: 1px solid transparent;
    border-radius: 16px;
    transition: background-color 180ms ease, border-color 180ms ease, color 180ms ease, transform 180ms ease, box-shadow 180ms ease;
}

.button:hover:not(:disabled) {
    transform: translateY(-1px);
    box-shadow: var(--shadow-soft);
}

.button--primary {
    flex: 1;
    flex-direction: column;
    align-items: flex-start;
    background: var(--color-primary);
    color: #ffffff;
}

.button--primary:hover:not(:disabled),
.button--primary.is-loading {
    background: var(--color-primary-hover);
}

.button__text {
    font-size: 16px;
    font-weight: 700;
}

.button__hint {
    color: rgba(255, 255, 255, 0.82);
    font-size: 13px;
    font-weight: 500;
}

.button--secondary,
.button--ghost {
    background: var(--color-input-bg);
    color: var(--color-text);
    border-color: var(--color-border);
}

.button--secondary {
    min-width: 146px;
}

.button--ghost {
    min-width: 116px;
    background: var(--color-surface-soft);
    color: var(--color-primary);
}

.button:disabled {
    opacity: 0.64;
    transform: none;
}

.guide-card,
.result-card {
    gap: 18px;
}

.list-plain {
    padding-left: 20px;
    display: grid;
    gap: 10px;
}

.result-card__header {
    display: flex;
    gap: 16px;
    align-items: flex-start;
    justify-content: space-between;
    margin-bottom: 18px;
}

.summary-grid {
    margin: 0 0 20px;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
}

.summary-grid div {
    padding: 16px;
    border: 1px solid var(--color-border);
    border-radius: 16px;
    background: var(--color-surface-soft);
}

dt {
    margin-bottom: 8px;
    color: var(--color-text-muted);
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

dd {
    margin: 0;
    color: var(--color-text);
    font-weight: 700;
    line-height: 1.65;
    font-variant-numeric: tabular-nums;
}

.result-output {
    margin: 0;
    min-height: 340px;
    max-height: 540px;
    overflow: auto;
    padding: 20px;
    border: 1px solid var(--color-border);
    border-radius: 18px;
    background: var(--color-surface-soft);
    color: var(--color-text);
    font-size: 14px;
    line-height: 1.75;
    white-space: pre-wrap;
    word-break: break-word;
    font-family: "Consolas", "SFMono-Regular", "Cascadia Code", "Microsoft YaHei UI Mono", monospace;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04);
}

.copy-feedback {
    min-height: 22px;
    margin-top: 14px;
    font-size: 14px;
}

.copy-feedback[data-state="success"] {
    color: var(--color-success);
}

.copy-feedback[data-state="info"] {
    color: var(--color-primary);
}

.copy-feedback[data-state="error"] {
    color: var(--color-error);
}

@media (max-width: 1100px) {
    .hero,
    .workspace {
        grid-template-columns: 1fr;
    }

    .hero__metrics {
        grid-template-columns: repeat(4, minmax(0, 1fr));
    }
}

@media (max-width: 768px) {
    .page-shell {
        padding: 16px 12px calc(92px + env(safe-area-inset-bottom, 0px));
    }

    .card {
        padding: 18px;
        border-radius: 20px;
    }

    h1 {
        font-size: clamp(1.8rem, 9vw, 2.4rem);
    }

    .hero__toolbar {
        align-items: flex-start;
    }

    .hero__lead {
        margin-bottom: 14px;
        font-size: 0.95rem;
    }

    .hero__pills {
        gap: 8px;
    }

    .hero__metrics,
    .form-grid--triple,
    .form-grid--double,
    .summary-grid,
    .choice-grid {
        grid-template-columns: 1fr;
    }

    .sidebar {
        gap: 16px;
    }

    .result-card {
        order: -1;
    }

    .form-actions,
    .result-card__header {
        flex-direction: column;
    }

    .form-actions {
        position: sticky;
        bottom: 12px;
        z-index: 5;
        padding: 10px;
        border: 1px solid var(--color-border);
        border-radius: 18px;
        background: var(--color-surface);
        backdrop-filter: blur(var(--backdrop-blur));
        box-shadow: var(--shadow-card);
    }

    .button--primary {
        align-items: center;
        text-align: center;
    }

    .button,
    .theme-toggle {
        min-height: 50px;
    }

    .button--secondary,
    .button--ghost {
        width: 100%;
    }

    .summary-grid div,
    .metric-card {
        padding: 14px;
    }

    .result-output {
        min-height: 260px;
        max-height: 420px;
        padding: 16px;
    }
}

@media (max-width: 480px) {
    .hero__metrics {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .metric-card strong {
        font-size: 1.5rem;
    }

    .metric-card span,
    .metric-card p,
    .pill,
    .tag,
    .field-hint-card,
    .section-desc,
    .panel-section__header p {
        font-size: 12px;
    }
}

@media (prefers-reduced-motion: reduce) {
    html {
        scroll-behavior: auto;
    }

    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}
