:root {
    --ink: #10213d;
    --muted: #66738a;
    --line: #dce2eb;
    --canvas: #f4f6fa;
    --surface: #ffffff;
    --blue: #3568e8;
    --blue-dark: #2453c5;
    --blue-soft: #edf2ff;
    --green: #109b68;
    --green-soft: #e9f8f1;
    --red: #c64242;
    --red-soft: #fff0f0;
    --shadow: 0 12px 36px rgba(28, 44, 77, .07);
}

* { box-sizing: border-box; }
html { font-size: 16px; background: var(--canvas); }
body { margin: 0; min-width: 320px; color: var(--ink); background: var(--canvas); font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; -webkit-font-smoothing: antialiased; }
button, textarea, select { font: inherit; }
button { -webkit-tap-highlight-color: transparent; }
.app-shell { min-height: 100vh; display: flex; flex-direction: column; }

.workspace { width: min(1180px, calc(100% - 40px)); margin: 0 auto; flex: 1; padding: 54px 0 64px; }
.intro { width: 100%; }
.eyebrow, .step-label { margin: 0 0 9px; color: var(--blue); font-size: .82rem; font-weight: 800; letter-spacing: .13em; }
.intro h1 { margin: 0; font-size: clamp(2rem,4vw,3.15rem); line-height: 1.08; letter-spacing: -.045em; font-weight: 780; }
.intro > p:last-child { margin: 17px 0 0; max-width: 640px; color: var(--muted); font-size: 1.05rem; line-height: 1.65; }
.product-type-filter { width: min(100%, 430px); margin-top: 28px; display: grid; gap: 8px; }
.product-type-filter label { color: #263750; font-size: .96rem; font-weight: 750; }
.product-type-filter select { min-height: 50px; }
.product-type-filter select[aria-invalid="true"] { border-color: var(--red); background-color: #fffafa; }

.flow-strip { display: flex; align-items: center; width: min(690px,100%); margin: 38px 0 30px; }
.flow-step { display: flex; align-items: center; gap: 9px; flex: 0 0 auto; color: #8590a1; font-size: .9rem; }
.flow-step span { width: 27px; height: 27px; display: grid; place-items: center; color: #748096; background: #e7eaf0; border-radius: 50%; font-size: .85rem; font-weight: 800; }
.flow-step.is-active { color: var(--ink); }
.flow-step.is-active span { color: white; background: var(--blue); box-shadow: 0 4px 10px rgba(53,104,232,.2); }
.flow-step.is-complete { color: #08744d; }
.flow-step.is-complete span { color: white; background: var(--green); box-shadow: 0 4px 10px rgba(16,155,104,.18); }
.flow-line { height: 1px; flex: 1; min-width: 24px; margin: 0 13px; background: #d8dee8; }
.flow-line.is-complete { background: var(--green); }

.editor-grid { display: grid; grid-template-columns: minmax(0,1.15fr) minmax(350px,.85fr); gap: 24px; align-items: start; }
.form-card, .result-card { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow); overflow: hidden; }
.card-heading { min-height: 83px; padding: 21px 24px; display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid #e4e8ef; }
.card-heading h2 { margin: 0; font-size: 1.2rem; letter-spacing: -.02em; }
.card-heading .step-label { margin-bottom: 5px; font-size: .74rem; }
.field-count { padding: 5px 9px; color: #68768d; background: #f0f2f6; border-radius: 999px; font-size: .8rem; font-weight: 700; }

.field-stack { padding: 24px; display: grid; gap: 22px; }
.field-label-row { position: relative; z-index: 1; margin-bottom: 9px; display: flex; justify-content: space-between; gap: 12px; align-items: baseline; }
.field-group:focus-within .field-label-row, .field-group:hover .field-label-row { z-index: 2; }
.field-label-row label { font-size: .96rem; font-weight: 750; }
.required-marker { margin-left: 5px; padding: 2px 6px; color: #a43434; background: var(--red-soft); border-radius: 999px; font-size: .67rem; font-weight: 800; letter-spacing: .025em; text-transform: uppercase; vertical-align: 1px; }
.field-meta { display: flex; align-items: center; gap: 7px; }
.field-kind { color: #8993a5; font-size: .81rem; }
.schema-help { position: relative; display: inline-flex; }
.schema-help-button { width: 19px; height: 19px; padding: 0; display: grid; place-items: center; color: #667892; background: #f3f6fb; border: 1px solid #ccd5e2; border-radius: 50%; font-size: .78rem; font-weight: 800; line-height: 1; cursor: pointer; }
.schema-help-button:hover, .schema-help-button:focus-visible, .schema-help-button.is-open { color: white; background: var(--blue); border-color: var(--blue); outline: none; }
.schema-tooltip { position: absolute; z-index: 20; top: calc(100% + 9px); right: 0; width: min(390px, calc(100vw - 52px)); max-height: min(560px, 75vh); padding: 13px 14px; overflow: auto; visibility: hidden; opacity: 0; transform: translateY(-3px); color: #dce6ff; background: #15233b; border: 1px solid #2b3d5a; border-radius: 8px; box-shadow: 0 12px 28px rgba(16,33,61,.2); pointer-events: auto; user-select: text; transition: opacity .14s, transform .14s, visibility .14s; }
.schema-tooltip::before { position: absolute; top: -5px; right: 5px; width: 9px; height: 9px; content: ""; background: #15233b; border-top: 1px solid #2b3d5a; border-left: 1px solid #2b3d5a; transform: rotate(45deg); }
.schema-tooltip.opens-upward { top: auto; bottom: calc(100% + 9px); }
.schema-tooltip.opens-upward::before { top: auto; bottom: -5px; border-top: 0; border-right: 1px solid #2b3d5a; border-bottom: 1px solid #2b3d5a; border-left: 0; }
.schema-tooltip-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 7px; }
.schema-tooltip strong { display: block; color: white; font-size: .8rem; letter-spacing: .07em; text-transform: uppercase; }
.schema-tooltip code { display: block; overflow-wrap: anywhere; white-space: pre-wrap; color: #dce6ff; font: .77rem/1.5 "Cascadia Code", Consolas, monospace; }
.schema-tooltip.is-open { visibility: visible; opacity: 1; transform: translateY(0); }
.schema-close-button { width: 23px; height: 23px; padding: 0; display: grid; place-items: center; color: #b8c5d9; background: transparent; border: 1px solid #52617a; border-radius: 5px; font-size: 1rem; line-height: 1; cursor: pointer; }
.schema-close-button:hover, .schema-close-button:focus-visible { color: white; border-color: #91a2bd; outline: none; }
.schema-copy-button { width: 100%; margin-top: 11px; padding: 7px 10px; color: white; background: #2b58c5; border: 1px solid #4874dd; border-radius: 6px; font-size: .79rem; font-weight: 750; cursor: pointer; user-select: none; }
.schema-copy-button:hover, .schema-copy-button:focus-visible { background: var(--blue); outline: 2px solid rgba(255,255,255,.28); outline-offset: 1px; }
.field-guidance { margin: -2px 0 9px; color: #7a8799; font-size: .82rem; line-height: 1.48; }
textarea { width: 100%; min-height: 172px; padding: 13px 14px; resize: vertical; color: #263750; background: #fbfcfe; border: 1px solid #d6dce7; border-radius: 8px; outline: none; font: .88rem/1.55 "Cascadia Code", Consolas, monospace; tab-size: 2; transition: border-color .15s, box-shadow .15s, background .15s; }
textarea::placeholder { color: #a4adbb; }
textarea:hover { border-color: #b7c0ce; }
textarea:focus { background: white; border-color: var(--blue); box-shadow: 0 0 0 3px rgba(53,104,232,.11); }
select { width: 100%; min-height: 48px; padding: 0 42px 0 14px; color: #263750; background-color: #fbfcfe; border: 1px solid #d6dce7; border-radius: 8px; outline: none; cursor: pointer; transition: border-color .15s, box-shadow .15s, background .15s; }
select:hover { border-color: #b7c0ce; }
select:focus { background-color: white; border-color: var(--blue); box-shadow: 0 0 0 3px rgba(53,104,232,.11); }
.field-group.has-error select { border-color: var(--red); background-color: #fffafa; }
.field-group.has-error textarea { border-color: var(--red); background: #fffafa; }
.field-error { margin: 8px 0 0; display: flex; gap: 7px; align-items: flex-start; color: var(--red); font-size: .85rem; font-weight: 650; line-height: 1.45; }
.field-error span { width: 16px; height: 16px; flex: 0 0 16px; display: grid; place-items: center; color: white; background: var(--red); border-radius: 50%; font-size: .71rem; }

.format-note { margin: 24px 24px 0; padding: 14px 15px; display: flex; align-items: flex-start; gap: 12px; color: #41506a; background: #f5f8ff; border: 1px solid #dae3fa; border-radius: 9px; }
.format-note-icon { width: 34px; height: 34px; flex: 0 0 34px; display: grid; place-items: center; color: var(--blue); background: white; border: 1px solid #d9e2f7; border-radius: 8px; font: 700 .8rem/1 "Cascadia Code", Consolas, monospace; }
.format-note strong { display: block; margin: 1px 0 4px; color: #263955; font-size: .88rem; }
.format-note p { margin: 0; color: #728097; font-size: .82rem; line-height: 1.5; }
.format-note code { padding: 1px 4px; color: #334c7c; background: #e7edfb; border-radius: 3px; font-size: .78rem; }

.form-actions { margin: 0 24px 24px; display: grid; gap: 16px; }
.generate-button { width: 100%; min-height: 49px; margin: 0; display: flex; align-items: center; justify-content: center; gap: 9px; color: white; background: var(--blue); border: 0; border-radius: 8px; font-weight: 750; cursor: pointer; box-shadow: 0 7px 16px rgba(53,104,232,.19); transition: transform .15s, background .15s, box-shadow .15s; }
.generate-button svg { width: 19px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.generate-button:hover { background: var(--blue-dark); box-shadow: 0 9px 19px rgba(53,104,232,.25); transform: translateY(-1px); }
.generate-button:active { transform: translateY(0); }
.generate-button:focus-visible, .copy-button:focus-visible { outline: 3px solid rgba(53,104,232,.27); outline-offset: 2px; }

.result-card { position: sticky; top: 24px; min-height: 570px; max-height: calc(100vh - 48px); overflow: auto; }
.result-badge { display: flex; align-items: center; gap: 7px; padding: 6px 9px; border-radius: 999px; font-size: .79rem; font-weight: 750; }
.result-badge span { width: 6px; height: 6px; border-radius: 50%; }
.result-badge.success { color: #08744d; background: var(--green-soft); }
.result-badge.success span { background: var(--green); }
.result-badge.error { color: #a43434; background: var(--red-soft); }
.result-badge.error span { background: var(--red); }
.empty-state { min-height: 378px; padding: 45px 40px 24px; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; }
.empty-icon { width: 62px; height: 62px; display: grid; place-items: center; color: #8190aa; background: #f1f4f8; border: 1px solid #e2e7ef; border-radius: 16px; transform: rotate(-2deg); }
.empty-icon svg { width: 30px; fill: none; stroke: currentColor; stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; }
.empty-state h3 { margin: 22px 0 8px; font-size: 1rem; }
.empty-state p { max-width: 280px; margin: 0; color: #8490a2; font-size: .92rem; line-height: 1.55; }

.issue-summary, .success-summary { margin: 24px 24px 18px; padding: 16px; display: flex; align-items: flex-start; gap: 12px; border-radius: 9px; }
.issue-summary { background: var(--red-soft); border: 1px solid #f2cdcd; }
.success-summary { background: var(--green-soft); border: 1px solid #c9eadc; }
.issue-icon, .success-summary svg { width: 25px; height: 25px; flex: 0 0 25px; display: grid; place-items: center; border-radius: 50%; }
.issue-icon { color: white; background: var(--red); font-size: .9rem; font-weight: 850; }
.success-summary svg { padding: 4px; color: white; background: var(--green); fill: none; stroke: currentColor; stroke-width: 2.3; }
.issue-summary h3, .success-summary h3 { margin: 1px 0 4px; font-size: .98rem; }
.issue-summary p, .success-summary p { margin: 0; color: #66748a; font-size: .85rem; line-height: 1.45; }
.issue-list { margin: 0; padding: 0 24px; list-style: none; display: grid; gap: 9px; }
.issue-list li { padding: 12px 13px; display: grid; gap: 3px; background: #fafbfc; border: 1px solid #e3e7ed; border-radius: 7px; }
.issue-list strong { font-size: .86rem; }
.issue-list span { color: #768195; font-size: .82rem; }

.output-list { padding: 0 24px; display: grid; gap: 10px; }
.output-item { overflow: hidden; background: #fbfcfe; border: 1px solid #dfe4ec; border-radius: 9px; }
.output-item > summary { min-height: 54px; padding: 11px 13px; display: flex; align-items: center; justify-content: space-between; gap: 12px; cursor: pointer; list-style: none; }
.output-item > summary::-webkit-details-marker { display: none; }
.output-item > summary > span { display: grid; gap: 3px; }
.output-item > summary strong { color: #263750; font-size: .88rem; }
.output-item > summary small { color: #8792a4; font-size: .76rem; }
.output-item > summary svg { width: 18px; flex: 0 0 18px; fill: none; stroke: #78859a; stroke-width: 1.8; transition: transform .18s; }
.output-item[open] > summary svg { transform: rotate(180deg); }
.output-body { padding: 13px; border-top: 1px solid #e3e7ed; background: white; }
.code-toolbar { display: flex; align-items: center; justify-content: space-between; }
.code-toolbar > span { color: #738096; font-size: .8rem; font-weight: 800; letter-spacing: .09em; }
.copy-button { padding: 7px 10px; display: flex; align-items: center; gap: 6px; color: var(--blue); background: transparent; border: 1px solid #cfd8ec; border-radius: 7px; font-size: .82rem; font-weight: 750; cursor: pointer; }
.copy-button:hover { background: var(--blue-soft); border-color: #aebfe8; }
.copy-button svg { width: 14px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.code-output { height: 220px; margin: 10px 0 0; padding: 14px; overflow: auto; white-space: pre-wrap; word-break: break-word; color: #dce6ff; background: #15233b; border-radius: 8px; font: .78rem/1.58 "Cascadia Code", Consolas, monospace; scrollbar-color: #52617a #15233b; }
.preview-panel { margin-top: 10px; border: 1px solid #e1e5eb; border-radius: 8px; }
.preview-panel > summary { padding: 10px 12px; color: #65738a; font-size: .82rem; font-weight: 700; cursor: pointer; }
.shopify-preview { max-height: 420px; padding: 22px; overflow: auto; background: white; border-top: 1px solid #e7eaf0; }
.shopify-preview .bf-rich { min-width: 0; }
.shopify-preview .bf-rich .josh-faq__inner { padding: 24px 0 40px; }

.combined-output { margin: 18px 24px 24px; padding: 14px; display: flex; align-items: center; justify-content: space-between; gap: 16px; background: #f6f8fc; border: 1px solid #e0e5ee; border-radius: 9px; }
.combined-output strong { display: block; margin-bottom: 3px; color: #2b3c57; font-size: .85rem; }
.combined-output p { margin: 0; color: #7a879a; font-size: .78rem; line-height: 1.4; }
.combined-copy { flex: 0 0 auto; background: white; }

.admin-page { min-height: 100vh; padding: clamp(28px, 6vw, 72px) 20px; background: var(--canvas); }
.admin-panel { width: min(880px, 100%); margin: 0 auto; overflow: hidden; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow); }
.admin-heading { padding: 26px 28px; display: flex; align-items: flex-start; justify-content: space-between; gap: 24px; border-bottom: 1px solid #e4e8ef; }
.admin-heading h1 { margin: 0; font-size: clamp(1.65rem, 4vw, 2.2rem); letter-spacing: -.035em; }
.admin-heading p:last-child { margin: 9px 0 0; color: var(--muted); line-height: 1.55; }
.admin-count { flex: 0 0 auto; padding: 7px 11px; color: #08744d; background: var(--green-soft); border-radius: 999px; font-size: .82rem; font-weight: 750; }
.rule-create-panel { padding: 26px 28px 22px; background: #fbfcfe; border-bottom: 1px solid #e4e8ef; }
.rule-create-panel > label { display: block; margin-bottom: 9px; color: #263750; font-size: .92rem; font-weight: 750; }
.rule-create-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 10px; }
.rule-create-row input { min-height: 47px; padding: 0 13px; color: #263750; background: white; border: 1px solid #d6dce7; border-radius: 8px; outline: none; }
.rule-create-row input:focus { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(53,104,232,.11); }
.admin-primary-button { min-height: 47px; padding: 0 19px; color: white; background: var(--blue); border: 0; border-radius: 8px; font-weight: 750; cursor: pointer; }
.admin-primary-button:hover { background: var(--blue-dark); }
.admin-primary-button:disabled, .admin-delete-button:disabled { cursor: wait; opacity: .55; }
.rule-help { margin: 8px 0 0; color: #7a8799; font-size: .8rem; }
.admin-message { margin: 20px 28px 0; padding: 12px 14px; border: 1px solid; border-radius: 8px; font-size: .86rem; font-weight: 650; }
.admin-message.is-success { color: #08744d; background: var(--green-soft); border-color: #c9eadc; }
.admin-message.is-error { color: #a43434; background: var(--red-soft); border-color: #f2cdcd; }
.rule-list { padding: 26px 28px 30px; }
.rule-list-heading { margin-bottom: 14px; display: flex; align-items: baseline; justify-content: space-between; gap: 16px; }
.rule-list-heading h2 { margin: 0; font-size: 1.05rem; }
.rule-list-heading span { color: #8993a5; font-size: .82rem; }
.rule-table { display: grid; gap: 9px; }
.rule-row { min-height: 68px; padding: 12px 14px; display: grid; grid-template-columns: minmax(0, 1fr) auto auto; align-items: center; gap: 18px; background: #fbfcfe; border: 1px solid #dfe4ec; border-radius: 9px; }
.rule-row.is-disabled { opacity: .66; }
.rule-name { min-width: 0; display: grid; gap: 4px; }
.rule-name strong { overflow: hidden; text-overflow: ellipsis; color: #263750; font-size: .91rem; }
.rule-name span { color: #8792a4; font-size: .76rem; }
.rule-toggle { display: flex; align-items: center; gap: 7px; color: #52617a; cursor: pointer; }
.rule-toggle input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.rule-toggle > span { width: 36px; height: 21px; padding: 2px; background: #b6bfcc; border-radius: 999px; transition: background .15s; }
.rule-toggle > span::after { width: 17px; height: 17px; display: block; content: ""; background: white; border-radius: 50%; box-shadow: 0 1px 3px rgba(16,33,61,.25); transition: transform .15s; }
.rule-toggle input:checked + span { background: var(--green); }
.rule-toggle input:checked + span::after { transform: translateX(15px); }
.rule-toggle input:focus-visible + span { outline: 3px solid rgba(53,104,232,.27); outline-offset: 2px; }
.rule-toggle em { min-width: 52px; font-size: .78rem; font-style: normal; font-weight: 700; }
.admin-delete-button { padding: 7px 10px; color: var(--red); background: white; border: 1px solid #edcaca; border-radius: 7px; font-size: .8rem; font-weight: 700; cursor: pointer; }
.admin-delete-button:hover { background: var(--red-soft); }
.admin-empty-state { padding: 34px 20px; color: var(--muted); text-align: center; background: #fbfcfe; border: 1px dashed #ccd5e2; border-radius: 9px; }
.admin-empty-state strong { color: var(--ink); }
.admin-empty-state p { margin: 7px 0 0; font-size: .86rem; }
.admin-access-denied { padding: 40px; text-align: center; }
.admin-access-denied h1 { margin: 0; }
.admin-access-denied p { margin: 10px 0 0; color: var(--muted); }

#blazor-error-ui { display: none; position: fixed; z-index: 1000; right: 20px; bottom: 20px; padding: 14px 42px 14px 18px; color: white; background: #a92f2f; border-radius: 8px; box-shadow: var(--shadow); }
#blazor-error-ui .reload { margin-left: 8px; color: white; font-weight: 700; }
#blazor-error-ui .dismiss { position: absolute; right: 13px; cursor: pointer; }

@media (max-width: 860px) {
    .editor-grid { grid-template-columns: 1fr; }
    .result-card { position: static; min-height: 500px; max-height: none; }
}
@media (max-width: 600px) {
    .workspace { width: min(100% - 24px,1180px); padding: 36px 0 48px; }
    .intro h1 { font-size: 2.05rem; }
    .intro > p:last-child { font-size: 1rem; }
    .product-type-filter { width: 100%; margin-top: 22px; }
    .flow-step strong { display: none; }
    .flow-line { margin: 0 8px; }
    .card-heading { padding: 18px; }
    .field-stack { padding: 18px; }
    .format-note { margin: 18px 18px 0; }
    .form-actions { margin: 0 18px 18px; }
    .field-label-row { align-items: flex-start; }
    .field-meta { max-width: 55%; text-align: right; }
    .issue-summary, .success-summary { margin-left: 18px; margin-right: 18px; }
    .issue-list, .output-list { padding: 0 18px; }
    .combined-output { margin-left: 18px; margin-right: 18px; align-items: flex-start; flex-direction: column; }
    .shopify-preview { padding: 16px; }
    .admin-page { padding: 16px 12px; }
    .admin-heading, .rule-create-panel, .rule-list { padding-left: 18px; padding-right: 18px; }
    .admin-heading { flex-direction: column; gap: 14px; }
    .rule-create-row { grid-template-columns: 1fr; }
    .rule-row { grid-template-columns: minmax(0, 1fr) auto; gap: 12px; }
    .rule-name { grid-column: 1 / -1; }
}
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { scroll-behavior: auto !important; transition: none !important; } }
