:root {
    color-scheme: light;
    --bg: #edf3ff;
    --bg-deep: #dce7fb;
    --panel: rgba(255, 255, 255, 0.95);
    --panel-soft: rgba(248, 251, 255, 0.92);
    --ink: #11243c;
    --muted: #617188;
    --line: rgba(17, 36, 60, 0.1);
    --line-strong: rgba(17, 36, 60, 0.16);
    --accent: #2f6de4;
    --accent-strong: #1b4fae;
    --accent-soft: rgba(47, 109, 228, 0.12);
    --success: #24795b;
    --warn: #936b1f;
    --danger: #9b4a41;
    --danger-soft: rgba(155, 74, 65, 0.12);
    --shadow-lg: 0 26px 56px rgba(31, 59, 108, 0.16);
    --shadow-md: 0 16px 32px rgba(31, 59, 108, 0.11);
    --shadow-sm: 0 10px 20px rgba(31, 59, 108, 0.08);
    --radius-xl: 34px;
    --radius-lg: 24px;
    --radius-md: 18px;
    --radius-sm: 12px;
    --ease: cubic-bezier(0.22, 1, 0.36, 1);
}

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

html,
body {
    min-height: 100%;
    margin: 0;
}

body {
    font-family: "Manrope", "Avenir Next", "Segoe UI", sans-serif;
    color: var(--ink);
    background:
        radial-gradient(circle at 14% 10%, rgba(255, 255, 255, 0.9), transparent 20%),
        radial-gradient(circle at 82% 16%, rgba(47, 109, 228, 0.08), transparent 24%),
        linear-gradient(180deg, #f4f8ff 0%, var(--bg) 45%, var(--bg-deep) 100%);
}

body::before {
    content: "";
    position: fixed;
    inset: 0;
    pointer-events: none;
    background-image:
        linear-gradient(rgba(47, 109, 228, 0.04) 1px, transparent 1px),
        linear-gradient(90deg, rgba(47, 109, 228, 0.04) 1px, transparent 1px);
    background-size: 40px 40px;
    mask-image: linear-gradient(180deg, rgba(0, 0, 0, 0.28), transparent 78%);
}

body.is-modal-open {
    overflow: hidden;
}

body.app-ready .spec-cover,
body.app-ready .protocol-grid,
body.app-ready .notice {
    animation: riseSoft 620ms var(--ease) both;
}

body.app-ready .protocol-grid {
    animation-delay: 90ms;
}

body.app-ready .notice {
    animation-delay: 140ms;
}

.hidden {
    display: none !important;
}

.shell {
    width: min(1480px, calc(100% - 44px));
    margin: 0 auto;
    padding: 36px 0 52px;
}

.shell > .notice {
    margin-bottom: 24px;
}

.eyebrow,
.meta-label {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 10px;
    font-size: 0.75rem;
    font-weight: 800;
    line-height: 1;
    letter-spacing: 0.18em;
    text-transform: uppercase;
    color: rgba(97, 113, 136, 0.84);
}

.eyebrow::before {
    content: "";
    width: 18px;
    height: 1px;
    background: currentColor;
    opacity: 0.65;
}

.spec-cover,
.rail-card,
.protocol-sheet,
.annex-card,
.notice,
.modal-panel {
    border: 1px solid var(--line);
    box-shadow: var(--shadow-lg);
}

.spec-cover {
    display: grid;
    grid-template-columns: minmax(0, 1.08fr) 380px;
    gap: 24px;
    padding: 30px;
    margin-bottom: 24px;
    border-radius: var(--radius-xl);
    background:
        linear-gradient(135deg, rgba(255, 255, 255, 0.92) 0%, rgba(245, 250, 255, 0.9) 100%);
    position: relative;
    overflow: hidden;
}

.spec-cover::after {
    content: "";
    position: absolute;
    inset: 20px;
    border: 1px dashed rgba(47, 109, 228, 0.18);
    border-radius: calc(var(--radius-xl) - 8px);
    pointer-events: none;
}

.cover-copy,
.cover-meta {
    position: relative;
    z-index: 1;
}

.cover-copy h1,
.sheet-banner h2,
.block-head h3,
.annex-card h2,
.rail-card h2,
.modal-head h2,
.result-head h3 {
    margin: 0;
    letter-spacing: -0.05em;
}

.cover-copy h1 {
    font-size: 30px;
    line-height: 1;
}

.lead {
    margin: 18px 0 0;
    font-size: 1.02rem;
    line-height: 1.76;
    color: var(--muted);
}

.cover-meta {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
    align-content: start;
}

.meta-chip {
    padding: 16px 18px;
    border-radius: 18px;
    border: 1px solid var(--line);
    background: rgba(255, 255, 255, 0.72);
    box-shadow: var(--shadow-sm);
}

.meta-chip-wide {
    grid-column: 1 / -1;
}

.meta-chip strong {
    display: block;
    font-size: 1rem;
    line-height: 1.48;
}

.notice {
    border-radius: 22px;
    padding: 18px 20px;
    background: rgba(255, 249, 236, 0.96);
}

.warning {
    color: var(--warn);
}

.success {
    color: var(--success);
    background: rgba(233, 247, 242, 0.96);
}

.error {
    color: var(--danger);
    background: var(--danger-soft);
}

.protocol-grid {
    display: grid;
    grid-template-columns: 250px minmax(0, 1fr) 320px;
    gap: 22px;
    align-items: start;
}

.guide-rail,
.annex-rail {
    display: grid;
    gap: 16px;
}

.rail-card,
.annex-card {
    padding: 22px;
    border-radius: 26px;
    background: rgba(255, 255, 255, 0.84);
}

.rail-card-accent {
    background: linear-gradient(180deg, rgba(47, 109, 228, 0.94) 0%, rgba(27, 79, 174, 0.96) 100%);
    border-color: rgba(255, 255, 255, 0.08);
    color: #f4f8ff;
}

.rail-card-accent .eyebrow,
.rail-card-accent li,
.rail-card-accent h2,
.rail-card-accent p {
    color: inherit;
}

.rail-card h2,
.annex-card h2 {
    font-size: 1.45rem;
    line-height: 1.08;
    margin-bottom: 12px;
}

.rail-list,
.note-list {
    display: grid;
    gap: 10px;
    margin: 0;
    padding-left: 18px;
}

.rail-list li,
.sheet-banner p,
.block-head p,
.form-note,
.mode-note,
.summary-note,
textarea::placeholder,
input[type="text"]::placeholder {
    color: var(--muted);
}

.rail-list li,
.sheet-banner p,
.block-head p,
.summary-note,
.annex-card p {
    line-height: 1.7;
}

.rail-card-accent .eyebrow,
.rail-card-accent .rail-list li,
.rail-card-accent h2,
.rail-card-accent p {
    color: #f4f8ff;
}

.protocol-sheet {
    padding: 26px;
    border-radius: 34px;
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.96) 0%, rgba(246, 250, 255, 0.94) 100%);
}

.sheet-banner {
    display: flex;
    justify-content: space-between;
    gap: 18px;
    align-items: flex-start;
    padding-bottom: 20px;
    margin-bottom: 22px;
    border-bottom: 1px solid var(--line);
}

.sheet-banner h2 {
    font-size: 1.98rem;
}

.refiner-form {
    display: grid;
    gap: 18px;
}

.protocol-block {
    padding: 22px;
    border-radius: 24px;
    border: 1px solid var(--line);
    background: rgba(255, 255, 255, 0.74);
    box-shadow: var(--shadow-sm);
}

.protocol-block-primary {
    background:
        linear-gradient(180deg, rgba(47, 109, 228, 0.08) 0%, rgba(255, 255, 255, 0.78) 100%);
}

.block-head {
    margin-bottom: 16px;
}

.block-head h3 {
    font-size: 1.32rem;
    margin-bottom: 6px;
}

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

.field {
    display: grid;
    gap: 10px;
}

.field + .field {
    margin-top: 16px;
}

.field > span {
    font-size: 0.94rem;
    font-weight: 800;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: rgba(17, 36, 60, 0.82);
}

input[type="text"],
select,
textarea {
    width: 100%;
    border: 1px solid var(--line-strong);
    border-radius: 16px;
    background: rgba(255, 255, 255, 0.94);
    color: var(--ink);
    font: inherit;
    transition: border-color 180ms var(--ease), box-shadow 180ms var(--ease), background 180ms var(--ease), transform 180ms var(--ease);
}

input[type="text"],
select {
    min-height: 56px;
    padding: 16px 18px;
    font-size: 1rem;
    font-weight: 700;
}

textarea {
    min-height: 140px;
    padding: 18px;
    resize: vertical;
    font-size: 1rem;
    line-height: 1.68;
}

.field-xl textarea {
    min-height: 224px;
}

input[type="text"]:focus,
select:focus,
textarea:focus {
    outline: none;
    border-color: rgba(47, 109, 228, 0.42);
    box-shadow: 0 0 0 4px rgba(47, 109, 228, 0.1);
    background: #ffffff;
    transform: translateY(-1px);
}

select {
    appearance: none;
    padding-right: 48px;
    background-image:
        linear-gradient(45deg, transparent 50%, rgba(17, 36, 60, 0.7) 50%),
        linear-gradient(135deg, rgba(17, 36, 60, 0.7) 50%, transparent 50%);
    background-position:
        calc(100% - 24px) calc(50% - 3px),
        calc(100% - 16px) calc(50% - 3px);
    background-size: 8px 8px, 8px 8px;
    background-repeat: no-repeat;
}

.sheet-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 18px;
}

.action-row {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
}

button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 54px;
    padding: 0 22px;
    border: 0;
    border-radius: 999px;
    font: inherit;
    font-weight: 800;
    letter-spacing: -0.02em;
    cursor: pointer;
    transition: transform 180ms var(--ease), box-shadow 180ms var(--ease), background 180ms var(--ease), opacity 180ms var(--ease);
}

button:hover:not(:disabled) {
    transform: translateY(-1px);
}

button:active:not(:disabled) {
    transform: translateY(0);
}

button:disabled {
    opacity: 0.52;
    cursor: not-allowed;
}

#refine-button,
.copy-button {
    color: #f7fbff;
    background: linear-gradient(180deg, var(--accent) 0%, var(--accent-strong) 100%);
    box-shadow: 0 16px 30px rgba(27, 79, 174, 0.2);
}

.ghost-button {
    color: var(--ink);
    background: rgba(255, 255, 255, 0.82);
    border: 1px solid var(--line);
}

.form-note {
    margin: 0;
    font-size: 0.94rem;
    line-height: 1.6;
}

.summary-grid {
    display: grid;
    gap: 14px;
    margin: 0 0 16px;
}

.summary-grid div {
    padding-bottom: 12px;
    border-bottom: 1px solid var(--line);
}

.summary-grid dt {
    margin-bottom: 6px;
    font-size: 0.77rem;
    font-weight: 800;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: rgba(97, 113, 136, 0.82);
}

.summary-grid dd {
    margin: 0;
    font-size: 1rem;
    font-weight: 700;
    line-height: 1.5;
}

.summary-note {
    margin: 0;
}

.ad-panel {
    padding: 0;
    overflow: hidden;
}

.ad-copy {
    padding: 20px 20px 14px;
}

.ad-copy h2 {
    margin: 0 0 8px;
    font-size: 1.34rem;
}

.ad-copy p {
    margin: 0;
}

.ad-slot,
.ad-placeholder {
    min-height: 360px;
    margin: 0 16px 16px;
    border: 1px solid var(--line);
    border-radius: 20px;
    background: rgba(248, 251, 255, 0.9);
}

.ad-placeholder {
    padding: 14px;
}

.ad-mockup {
    min-height: 328px;
    border-radius: 16px;
    display: grid;
    place-items: center;
    background:
        linear-gradient(180deg, rgba(255, 255, 255, 0.44) 0%, rgba(238, 245, 255, 0.92) 100%);
}

.ad-badge {
    width: 166px;
    height: 166px;
    border-radius: 999px;
    display: grid;
    place-content: center;
    justify-items: center;
    gap: 2px;
    color: #f7fbff;
    background: linear-gradient(180deg, rgba(47, 109, 228, 0.96) 0%, rgba(27, 79, 174, 0.96) 100%);
    font-size: 1.8rem;
    font-weight: 900;
    letter-spacing: 0.08em;
}

.modal {
    position: fixed;
    inset: 0;
    display: grid;
    place-items: center;
    padding: 24px;
    z-index: 30;
}

.modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(18, 30, 47, 0.56);
    backdrop-filter: blur(10px);
}

.modal-panel {
    position: relative;
    width: min(1040px, 100%);
    max-height: min(88vh, 980px);
    overflow: auto;
    padding: 28px;
    border-radius: 28px;
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.98) 0%, rgba(244, 248, 255, 0.96) 100%);
}

.modal-head {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 18px;
    margin-bottom: 22px;
}

.modal-head h2 {
    font-size: 1.88rem;
    margin-bottom: 8px;
}

.modal-head p {
    margin: 0;
    max-width: 54ch;
    line-height: 1.72;
    color: var(--muted);
}

.result-stack {
    display: grid;
    gap: 16px;
}

.result-card {
    padding: 22px;
    border: 1px solid var(--line);
    border-radius: 22px;
    background: rgba(255, 255, 255, 0.82);
    box-shadow: var(--shadow-sm);
}

.result-card-primary {
    background: linear-gradient(180deg, rgba(47, 109, 228, 0.08) 0%, rgba(255, 255, 255, 0.9) 100%);
}

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

.result-head h3 {
    font-size: 1.24rem;
}

.result-copy {
    margin: 0;
    white-space: pre-wrap;
    word-break: break-word;
    font-family: "SFMono-Regular", Consolas, monospace;
    font-size: 0.95rem;
    line-height: 1.72;
    color: var(--ink);
}

.note-list li,
.result-copy {
    color: var(--muted);
}

.copy-button.is-copied {
    background: linear-gradient(180deg, #24795b 0%, #18523d 100%);
}

.notice.is-visible,
.result-stack.is-entering,
.modal.is-visible .modal-panel {
    animation: riseSoft 360ms var(--ease) both;
}

@keyframes riseSoft {
    from {
        opacity: 0;
        transform: translateY(16px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@media (max-width: 1320px) {
    .protocol-grid,
    .spec-cover,
    .protocol-columns {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 760px) {
    .shell {
        width: min(100% - 20px, 100%);
        padding: 18px 0 30px;
    }

    .spec-cover,
    .protocol-sheet,
    .rail-card,
    .annex-card,
    .modal-panel {
        padding: 22px;
    }

    .protocol-block {
        padding: 18px;
    }

    .sheet-banner,
    .sheet-footer,
    .modal-head,
    .result-head {
        flex-direction: column;
        align-items: stretch;
    }

    .action-row,
    button,
    .ghost-button,
    #refine-button,
    .copy-button {
        width: 100%;
    }

    .ad-slot,
    .ad-placeholder {
        min-height: 300px;
    }
}
