:root {
    --ink: #16343b;
    --muted: #617277;
    --paper: #f7f6f0;
    --panel: #ffffff;
    --line: #d9e1df;
    --teal: #087f8c;
    --teal-dark: #075b66;
    --yellow: #f3c969;
    --coral: #df7458;
    --shadow: 0 16px 40px rgba(22, 52, 59, .08);
}

* { box-sizing: border-box; }
html { background: var(--paper); color: var(--ink); font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; }
body { margin: 0; min-width: 320px; }
a { color: inherit; }
.shell { width: min(1120px, calc(100% - 40px)); margin: 0 auto; }
.site-header { border-bottom: 1px solid var(--line); background: rgba(247, 246, 240, .96); }
.header-inner, .footer-inner { min-height: 72px; display: flex; align-items: center; justify-content: space-between; gap: 24px; }
.brand { color: var(--ink); font-size: 1.05rem; font-weight: 850; letter-spacing: .14em; text-decoration: none; }
.top-nav { display: flex; align-items: center; gap: 24px; font-size: .9rem; color: var(--muted); }
.top-nav a { text-decoration: none; }
.top-nav a:hover, .text-link:hover, .back-link:hover { color: var(--teal-dark); }
.nav-admin { color: var(--teal-dark); }
.locale-switcher { display: inline-flex; align-items: center; gap: 7px; margin-left: 2px; }
.locale-switcher a { color: var(--muted); font-size: .72rem; font-weight: 800; letter-spacing: .04em; text-decoration: none; }
.locale-switcher a:hover, .locale-switcher a.is-active { color: var(--teal-dark); }
.site-main { padding: 0 0 72px; }
.hero { display: grid; grid-template-columns: .9fr 1.1fr; gap: clamp(32px, 7vw, 100px); align-items: center; padding-top: clamp(64px, 10vw, 120px); padding-bottom: 76px; }
.eyebrow { margin: 0 0 16px; color: var(--teal); font-size: .72rem; font-weight: 800; letter-spacing: .16em; text-transform: uppercase; }
h1, h2, p { margin-top: 0; }
h1 { max-width: 720px; margin-bottom: 20px; font-size: clamp(2.5rem, 5.2vw, 5rem); line-height: .98; letter-spacing: -.045em; }
h2 { margin-bottom: 0; font-size: clamp(1.5rem, 3vw, 2.2rem); letter-spacing: -.025em; }
.hero-lead { max-width: 480px; margin-bottom: 0; color: var(--muted); font-size: 1.08rem; line-height: 1.65; }
.generator-form, .filters-panel, .source-prompt, .result-panel { background: var(--panel); box-shadow: var(--shadow); }
.generator-form { padding: clamp(22px, 4vw, 40px); border-top: 4px solid var(--coral); }
.field-label, .select-wrap span { display: block; margin-bottom: 10px; color: var(--ink); font-size: .78rem; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; }
textarea, input, select { width: 100%; border: 1px solid var(--line); border-radius: 2px; background: #fcfcfa; color: var(--ink); font: inherit; outline: 0; }
textarea { min-height: 170px; padding: 16px; resize: vertical; line-height: 1.55; }
input, select { min-height: 46px; padding: 11px 13px; }
textarea:focus, input:focus, select:focus { border-color: var(--teal); box-shadow: 0 0 0 3px rgba(8, 127, 140, .12); }
.form-row { display: flex; align-items: end; gap: 16px; margin-top: 18px; }
.select-wrap { flex: 1; }
.mode-picker { display: flex; flex-wrap: wrap; gap: 16px; margin: 18px 0 0; padding: 0; border: 0; }
.mode-picker legend { width: 100%; margin-bottom: 6px; color: var(--ink); font-size: .78rem; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; }
.mode-picker label { color: var(--muted); font-size: .9rem; }
.mode-picker input { width: auto; min-height: 0; margin-right: 6px; accent-color: var(--teal); }
.mode-note { margin: 10px 0 0; color: var(--teal-dark); font-size: .84rem; }
.button { min-height: 46px; border: 1px solid transparent; border-radius: 2px; padding: 0 18px; cursor: pointer; font: inherit; font-size: .76rem; font-weight: 850; letter-spacing: .08em; transition: transform .15s ease, background .15s ease; }
.button:hover { transform: translateY(-1px); }
.button:disabled { cursor: wait; opacity: .65; transform: none; }
.button-primary { background: var(--teal); color: white; }
.button-primary:hover { background: var(--teal-dark); }
.button-secondary { border-color: var(--line); background: white; color: var(--ink); }
.button-secondary:hover { border-color: var(--teal); color: var(--teal-dark); }
.form-error { margin: 14px 0 0; color: #a33c2c; font-size: .9rem; }
.type-section { padding: 0 0 62px; }
.section-heading { display: flex; align-items: end; justify-content: space-between; gap: 24px; border-bottom: 1px solid var(--line); padding-bottom: 18px; }
.text-link, .back-link { color: var(--teal-dark); font-size: .9rem; font-weight: 750; text-decoration: none; }
.choice-grid { display: flex; flex-wrap: wrap; gap: 10px; padding-top: 20px; }
.choice-chip { border: 1px solid var(--line); border-radius: 999px; padding: 10px 14px; background: transparent; color: var(--ink); cursor: pointer; font: inherit; font-size: .86rem; }
.choice-chip:hover, .choice-chip.is-selected { border-color: var(--teal); background: var(--teal); color: white; }
.category-strip { display: flex; flex-wrap: wrap; gap: 0; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.category-strip a { padding: 16px 18px 16px 0; margin-right: 18px; color: var(--muted); font-size: .9rem; text-decoration: none; }
.category-strip a:hover { color: var(--teal-dark); }
.result-panel { margin-top: 48px; padding: clamp(22px, 4vw, 40px); border-left: 4px solid var(--yellow); }
.result-heading { display: flex; align-items: end; justify-content: space-between; gap: 24px; margin-bottom: 20px; }
.result-summary { display: flex; flex-wrap: wrap; justify-content: end; gap: 8px 14px; }
.result-meta, #browse-status { color: var(--muted); font-size: .82rem; }
.prompt-output { min-height: 220px; margin: 0; padding: 22px; overflow: auto; white-space: pre-wrap; border: 1px solid var(--line); background: #fbfbf8; color: var(--ink); font: .98rem/1.65 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }
.result-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 18px; }
.copy-status { min-height: 20px; margin: 12px 0 0; color: var(--teal-dark); font-size: .9rem; }
.page-intro { padding: 72px 0 42px; }
.page-intro h1 { font-size: clamp(2.5rem, 5vw, 4.5rem); }
.page-intro p:last-child { color: var(--muted); font-size: 1.05rem; }
.browse-layout { display: grid; grid-template-columns: 260px 1fr; gap: 38px; }
.filters-panel { align-self: start; padding: 22px; }
.filters-panel .field-label:not(:first-child) { margin-top: 22px; }
.browse-results { min-width: 0; }
.results-toolbar { display: flex; justify-content: space-between; gap: 14px; min-height: 58px; align-items: center; border-bottom: 1px solid var(--line); color: var(--ink); font-size: .9rem; }
.results-toolbar #browse-status { flex: 1; }
.browse-pagination { display: flex; justify-content: center; align-items: center; gap: 16px; padding: 28px 0 4px; }
.browse-pagination .button { min-height: 38px; padding: 0 14px; font-size: .7rem; }
.browse-pagination .is-disabled { pointer-events: none; opacity: .45; }
.prompt-list { display: grid; }
.prompt-item { display: grid; grid-template-columns: 170px 1fr 120px; gap: 18px; align-items: start; padding: 20px 0; border-bottom: 1px solid var(--line); text-decoration: none; }
.prompt-item:hover .item-prompt { color: var(--teal-dark); }
.item-category, .item-type { color: var(--muted); font-size: .78rem; line-height: 1.4; }
.item-type { text-align: right; }
.item-prompt { display: grid; gap: 6px; font-size: 1rem; line-height: 1.5; }
.item-prompt strong { font-size: 1rem; }
.item-prompt small { color: var(--muted); font-size: .9rem; line-height: 1.45; }
.empty-state { padding: 72px 0; }
.detail-layout { display: grid; grid-template-columns: minmax(0, 1fr) 280px; gap: 72px; padding-top: 72px; }
.detail-main { max-width: 760px; }
.back-link { display: inline-block; margin-bottom: 48px; }
.detail-main h1 { margin-bottom: 14px; font-size: clamp(2.4rem, 5vw, 4.5rem); }
.detail-description { color: var(--muted); line-height: 1.6; }
.source-prompt { margin: 30px 0; padding: 24px; border-left: 4px solid var(--yellow); font: 1rem/1.7 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; white-space: pre-wrap; }
.detail-section { margin-top: 30px; }
.detail-section .source-prompt { margin-top: 0; }
.detail-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.original-details { margin-top: 42px; border-top: 1px solid var(--line); padding-top: 18px; }
.original-details summary { cursor: pointer; color: var(--teal-dark); font-weight: 750; }
.source-prompt-original { margin-bottom: 0; border-left-color: var(--line); background: #f1f2ed; }
.visually-hidden { position: absolute !important; width: 1px !important; height: 1px !important; padding: 0 !important; margin: -1px !important; overflow: hidden !important; clip: rect(0, 0, 0, 0) !important; white-space: nowrap !important; border: 0 !important; }
.detail-side { border-top: 3px solid var(--teal); }
.side-block { display: grid; gap: 8px; padding: 20px 0; border-bottom: 1px solid var(--line); }
.side-label { color: var(--muted); font-size: .72rem; font-weight: 800; letter-spacing: .1em; text-transform: uppercase; }
.variable-list { margin: 0; padding-left: 18px; color: var(--muted); line-height: 1.7; }
.site-footer { border-top: 1px solid var(--line); color: var(--muted); font-size: .8rem; }
.footer-inner { min-height: 64px; }
.footer-inner a { text-decoration: none; }

/* Admin keeps the same visual language but stays dense for repeated work. */
.admin-shell { width: min(1240px, calc(100% - 40px)); margin: 0 auto; }
.admin-top { padding: 42px 0 30px; display: flex; justify-content: space-between; gap: 24px; align-items: end; }
.admin-top h1 { font-size: clamp(2rem, 4vw, 3.4rem); margin-bottom: 0; }
.admin-table-wrap { overflow-x: auto; background: white; box-shadow: var(--shadow); }
.admin-table { width: 100%; border-collapse: collapse; font-size: .87rem; }
.admin-table th, .admin-table td { padding: 13px 14px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
.admin-table th { color: var(--muted); font-size: .7rem; letter-spacing: .08em; text-transform: uppercase; }
.admin-form { max-width: 860px; padding: 30px; background: white; box-shadow: var(--shadow); }
.admin-form label { display: block; margin: 18px 0 8px; font-size: .76rem; font-weight: 800; text-transform: uppercase; }
.admin-form textarea { min-height: 130px; }
.admin-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 22px; }
.status-published { color: var(--teal-dark); }
.status-hidden { color: var(--coral); }
.login-box { max-width: 430px; margin: 96px auto; padding: 34px; background: white; box-shadow: var(--shadow); }
.login-box h1 { font-size: 2.5rem; }

/* The AI layer is shared by generation and protected admin actions. */
.ai-overlay { position: fixed; z-index: 1000; inset: 0; display: grid; place-items: center; padding: 20px; background: rgba(22, 52, 59, .5); }
.ai-overlay[hidden] { display: none; }
.ai-overlay__dialog { width: min(420px, 100%); padding: 34px 28px 28px; border-top: 4px solid var(--coral); background: var(--panel); box-shadow: 0 24px 70px rgba(22, 52, 59, .2); text-align: center; outline: 0; }
.ai-overlay__icon { margin-bottom: 12px; color: var(--yellow); font-size: 1.8rem; }
.ai-overlay__dialog h2 { margin-bottom: 18px; font-size: clamp(1.25rem, 4vw, 1.7rem); }
.ai-overlay__spinner { width: 38px; height: 38px; margin: 0 auto 22px; border: 3px solid var(--line); border-top-color: var(--teal); border-radius: 50%; animation: ai-spin .9s linear infinite; }
.ai-overlay__message { min-height: 48px; margin: 0; color: var(--ink); line-height: 1.5; }
.ai-overlay__progress { height: 5px; margin: 22px 0 16px; overflow: hidden; background: var(--line); }
.ai-overlay__progress span { display: block; width: 34%; height: 100%; background: var(--teal); animation: ai-progress 1.6s ease-in-out infinite; }
.ai-overlay__elapsed { margin: 0; color: var(--ink); font: 700 1.25rem/1.2 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }
.ai-overlay__secondary { margin: 12px 0 0; color: var(--muted); font-size: .86rem; line-height: 1.45; }
.ai-overlay__close { width: auto; margin-top: 22px; }
.ai-overlay.is-error .ai-overlay__icon { color: var(--coral); }
.ai-overlay.is-error .ai-overlay__spinner, .ai-overlay.is-error .ai-overlay__progress { display: none; }
@keyframes ai-spin { to { transform: rotate(360deg); } }
@keyframes ai-progress { 0% { transform: translateX(-125%); } 100% { transform: translateX(310%); } }
@media (prefers-reduced-motion: reduce) {
    .ai-overlay__spinner, .ai-overlay__progress span { animation: none; }
    .ai-overlay__progress span { width: 100%; }
    .button { transition: none; }
}

@media (max-width: 820px) {
    .hero, .browse-layout, .detail-layout { grid-template-columns: 1fr; }
    .hero { padding-top: 58px; gap: 42px; }
    .detail-side { order: -1; }
    .prompt-item { grid-template-columns: 1fr; gap: 6px; }
    .item-type { text-align: left; }
}
@media (max-width: 560px) {
    .shell, .admin-shell { width: min(100% - 28px, 1120px); }
    .header-inner { min-height: 62px; }
    .top-nav { gap: 12px; font-size: .78rem; }
    .top-nav .nav-admin { display: none; }
    .form-row { align-items: stretch; flex-direction: column; }
    .button { width: 100%; }
    .results-toolbar { flex-wrap: wrap; }
    .results-toolbar #browse-status { flex-basis: 100%; order: 3; }
    .browse-pagination { gap: 8px; justify-content: space-between; }
    .section-heading, .result-heading, .admin-top { align-items: start; flex-direction: column; }
    .category-strip a { padding-right: 10px; margin-right: 10px; }
    .result-actions { display: grid; grid-template-columns: 1fr 1fr; }
}
