:root {
    color-scheme: light;
    --bg: #f3efe8;
    --bg-deep: #e8dfd3;
    --paper: rgba(255, 253, 250, 0.97);
    --paper-soft: rgba(250, 246, 240, 0.94);
    --ink: #211d19;
    --muted: #70665e;
    --line: rgba(33, 29, 25, 0.1);
    --line-strong: rgba(33, 29, 25, 0.16);
    --accent: #1e5d73;
    --accent-strong: #16485b;
    --accent-soft: rgba(30, 93, 115, 0.12);
    --olive: #6b7451;
    --success: #3e7b59;
    --danger: #9a5646;
    --danger-soft: rgba(154, 86, 70, 0.12);
    --shadow-xl: 0 28px 62px rgba(88, 72, 58, 0.14);
    --shadow-lg: 0 18px 32px rgba(88, 72, 58, 0.1);
    --shadow-sm: 0 10px 18px rgba(88, 72, 58, 0.08);
    --radius-2xl: 34px;
    --radius-xl: 24px;
    --radius-lg: 18px;
    --radius-md: 14px;
    --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", "Segoe UI", sans-serif;
    color: var(--ink);
    background:
        radial-gradient(circle at 12% 10%, rgba(255, 255, 255, 0.86), transparent 20%),
        radial-gradient(circle at 84% 16%, rgba(30, 93, 115, 0.08), transparent 18%),
        linear-gradient(180deg, #f8f5ef 0%, var(--bg) 40%, var(--bg-deep) 100%);
}

body::before {
    content: "";
    position: fixed;
    inset: 0;
    pointer-events: none;
    background:
        linear-gradient(180deg, rgba(255, 255, 255, 0.14), transparent 30%),
        repeating-linear-gradient(0deg, rgba(255, 255, 255, 0.04) 0, rgba(255, 255, 255, 0.04) 1px, transparent 1px, transparent 88px);
    mask-image: linear-gradient(180deg, rgba(0, 0, 0, 0.32), transparent 80%);
}

.hidden {
    display: none !important;
}

.shell {
    width: min(1460px, calc(100% - 40px));
    margin: 30px auto 50px;
    position: relative;
    z-index: 1;
}

.eyebrow {
    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(112, 102, 94, 0.84);
}

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

.mast,
.preview-card,
.summary-card,
.editor-panel,
.sidebar-card,
.notice,
.modal-panel {
    border: 1px solid var(--line);
    border-radius: var(--radius-2xl);
    background: var(--paper);
    box-shadow: var(--shadow-xl);
}

.mast {
    display: grid;
    gap: 18px;
    padding: 32px;
    margin-bottom: 24px;
    background:
        linear-gradient(180deg, rgba(255, 253, 250, 0.98) 0%, rgba(249, 245, 238, 0.96) 100%);
}

.mast-copy h1,
.panel-head h2,
.cluster-head h3,
.summary-card strong,
.sidebar-card strong {
    margin: 0;
    letter-spacing: -0.05em;
}

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

.lead,
.panel-copy,
.cluster-head p,
.form-note,
.summary-card p,
.sidebar-card p,
.notice {
    margin: 0;
    color: var(--muted);
    line-height: 1.72;
}

.lead {
    max-width: 68ch;
    font-size: 1.03rem;
}

.mast-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.mast-tags span {
    padding: 10px 14px;
    border-radius: 999px;
    border: 1px solid rgba(30, 93, 115, 0.12);
    background: rgba(30, 93, 115, 0.06);
    color: #355365;
    font-size: 0.89rem;
    font-weight: 800;
}

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

.preview-side,
.export-side {
    display: grid;
    gap: 16px;
}

.preview-card,
.summary-card,
.editor-panel,
.export-card,
.sidebar-card {
    padding: 24px;
}

.preview-card {
    background:
        linear-gradient(180deg, rgba(246, 250, 252, 0.96) 0%, rgba(245, 241, 235, 0.94) 100%);
}

.preview-note {
    display: grid;
    gap: 8px;
    padding: 18px;
    border-radius: 18px;
    border: 1px solid var(--line);
    background: rgba(255, 255, 255, 0.72);
    margin-bottom: 16px;
}

.preview-note strong {
    display: block;
    font-size: 1.16rem;
    line-height: 1.25;
    letter-spacing: -0.03em;
}

.panel-head {
    display: grid;
    gap: 8px;
    margin-bottom: 18px;
}

.panel-head h2 {
    font-size: 1.52rem;
    line-height: 1.06;
}

.paper-stage {
    padding: 18px;
    border-radius: 26px;
    background:
        linear-gradient(180deg, rgba(255, 255, 255, 0.4), rgba(247, 241, 233, 0.76));
    border: 1px dashed rgba(30, 93, 115, 0.18);
}

.paper-sheet {
    min-height: 430px;
    padding: 30px;
    border-radius: 22px;
    background:
        linear-gradient(180deg, #fffdfa 0%, #faf6ef 100%);
    box-shadow:
        inset 0 0 0 1px rgba(33, 29, 25, 0.06),
        0 18px 30px rgba(88, 72, 58, 0.08);
    display: grid;
    align-items: center;
    overflow: hidden;
}

.preview-box {
    display: grid;
    min-height: 280px;
    align-items: center;
    min-width: 0;
    overflow: hidden;
}

.preview-box table {
    width: 100%;
    max-width: 100%;
    table-layout: fixed;
}

.preview-box td,
.preview-box div,
.preview-box a {
    overflow-wrap: anywhere;
    word-break: break-word;
}

.preview-box td {
    vertical-align: top;
}

.summary-card strong {
    display: block;
    font-size: 1.58rem;
    margin-bottom: 8px;
}

.editor-panel {
    background:
        linear-gradient(180deg, rgba(255, 253, 250, 0.98) 0%, rgba(247, 243, 236, 0.96) 100%);
}

.head-actions {
    display: flex;
    justify-content: flex-end;
}

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

.cluster {
    display: grid;
    gap: 14px;
    padding: 20px;
    border-radius: 22px;
    border: 1px solid var(--line);
    background: rgba(255, 255, 255, 0.72);
    box-shadow: var(--shadow-sm);
}

.cluster-head {
    display: grid;
    gap: 6px;
}

.cluster-head h3 {
    font-size: 1.34rem;
    line-height: 1.08;
}

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

.field > span {
    font-size: 0.87rem;
    font-weight: 800;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: rgba(33, 29, 25, 0.82);
}

input,
textarea {
    width: 100%;
    border: 1px solid var(--line-strong);
    border-radius: 16px;
    padding: 15px 17px;
    font: inherit;
    color: var(--ink);
    background: rgba(255, 255, 255, 0.92);
    transition: border-color 180ms var(--ease), box-shadow 180ms var(--ease), transform 180ms var(--ease);
}

textarea {
    min-height: 120px;
    resize: vertical;
}

input::placeholder,
textarea::placeholder {
    color: rgba(112, 102, 94, 0.7);
}

input:focus,
textarea:focus {
    outline: none;
    border-color: rgba(30, 93, 115, 0.34);
    box-shadow: 0 0 0 4px rgba(30, 93, 115, 0.08);
    transform: translateY(-1px);
}

.editor-footer {
    display: grid;
    gap: 14px;
    padding-top: 6px;
}

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

button {
    min-height: 52px;
    padding: 0 22px;
    border: 0;
    border-radius: 999px;
    font: inherit;
    font-weight: 800;
    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);
}

#sig-copy-html {
    color: #f7fbff;
    background: linear-gradient(180deg, var(--accent) 0%, var(--accent-strong) 100%);
    box-shadow: 0 14px 28px rgba(22, 72, 91, 0.18);
}

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

.code-block {
    margin: 0;
    padding: 20px;
    min-height: 240px;
    border-radius: 18px;
    border: 1px solid var(--line);
    background: rgba(255, 255, 255, 0.84);
    color: #3b342c;
    font: 500 0.96rem/1.72 "SFMono-Regular", "SF Mono", "Menlo", monospace;
    white-space: pre-wrap;
    word-break: break-word;
}

.export-note-card strong {
    display: block;
    font-size: 1.34rem;
    line-height: 1.2;
    margin-bottom: 8px;
}

.notice {
    padding: 16px 18px;
    margin-top: 16px;
}

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

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

.modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(25, 22, 19, 0.5);
    backdrop-filter: blur(10px);
}

.modal-panel {
    position: relative;
    width: min(980px, 100%);
    max-height: min(88vh, 960px);
    overflow: auto;
    padding: 28px;
    background:
        linear-gradient(180deg, rgba(255, 253, 250, 0.99) 0%, rgba(246, 242, 236, 0.97) 100%);
}

.preview-modal-panel {
    width: min(1120px, 100%);
}

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

.modal-head h2 {
    font-size: 1.72rem;
    line-height: 1.04;
    margin: 0 0 8px;
    letter-spacing: -0.05em;
}

.modal-head p {
    max-width: 54ch;
}

.modal-actions {
    flex-shrink: 0;
}

.modal-code-block {
    min-height: 420px;
}

.modal-paper-stage {
    margin-top: 12px;
}

.modal-paper-sheet {
    min-height: 520px;
}

.sidebar-card {
    background:
        linear-gradient(180deg, rgba(255, 251, 246, 0.98) 0%, rgba(245, 239, 231, 0.96) 100%);
}

.sidebar-card .sidebar-title {
    font-size: 1.38rem;
    letter-spacing: -0.04em;
}

.sidebar-card .sidebar-copy,
.sidebar-card .sidebar-placeholder-note {
    color: var(--muted);
}

.sidebar-card .sidebar-ad-slot,
.sidebar-card .sidebar-ad-placeholder {
    min-height: 320px;
    margin-top: 16px;
    border: 1px solid var(--line);
    border-radius: 20px;
    background: rgba(255, 255, 255, 0.76);
}

.sidebar-card .sidebar-ad-placeholder {
    padding: 14px;
}

.sidebar-card .sidebar-ad-mock {
    min-height: 288px;
    display: grid;
    place-items: center;
    border-radius: 16px;
    background:
        radial-gradient(circle at center, rgba(30, 93, 115, 0.08), transparent 44%),
        linear-gradient(180deg, rgba(255, 255, 255, 0.32) 0%, rgba(246, 240, 232, 0.86) 100%);
}

.sidebar-card .sidebar-ad-badge {
    width: 158px;
    height: 158px;
    border-radius: 999px;
    display: grid;
    place-content: center;
    justify-items: center;
    gap: 2px;
    color: #f6fbff;
    background: linear-gradient(180deg, rgba(30, 93, 115, 0.98) 0%, rgba(22, 72, 91, 0.94) 100%);
    font-size: 1.7rem;
    font-weight: 900;
    letter-spacing: 0.08em;
}

@media (max-width: 1260px) {
    .stationery-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 760px) {
    .shell {
        width: min(100% - 20px, 100%);
        margin: 18px auto 28px;
    }

    .mast,
    .preview-card,
    .summary-card,
    .editor-panel,
    .sidebar-card {
        padding: 20px;
    }

    .paper-sheet {
        min-height: 320px;
        padding: 20px;
    }

    .code-block {
        min-height: 240px;
    }

    .modal-panel {
        padding: 22px;
    }

    .modal-head,
    .head-actions,
    .action-row {
        flex-direction: column;
        align-items: stretch;
    }

    button,
    .ghost-button,
    #sig-open-export,
    #sig-copy-html,
    #sig-sample,
    #sig-reset,
    #sig-close-export {
        width: 100%;
    }
}
