/* ── Variables ─────────────────────────────────────────────────────────────── */
:root {
    --bg:       #f7f4f0;
    --bg2:      #eeebe5;
    --surface:  #faf8f5;
    --border:   #dbd5cc;
    --text:     #1c1a17;
    --text-mid: #6b6459;
    --text-dim: #a09890;
    --white:    #fefcfa;
    --accent:   #888;
    --radius:   6px;
    --font-head:  'Fraunces', Georgia, serif;
    --font-body:  'Hanken Grotesk', system-ui, sans-serif;
}

/* ── Reset ─────────────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
a { color: inherit; text-decoration: none; }
button { cursor: pointer; border: none; background: none; font: inherit; }
input, textarea { font: inherit; }

/* ── Base ──────────────────────────────────────────────────────────────────── */
html { scroll-behavior: smooth; }

body {
    font-family: var(--font-body);
    font-weight: 400;
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    min-height: 100vh;
    position: relative;
}

/* Grain overlay */
body::after {
    content: '';
    position: fixed;
    inset: 0;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='300' height='300'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='300' height='300' filter='url(%23n)'/%3E%3C/svg%3E");
    opacity: 0.03;
    pointer-events: none;
    z-index: 9999;
}

main { min-height: 100vh; }

/* ── Layout ────────────────────────────────────────────────────────────────── */
.container {
    max-width: 1100px;
    margin: 0 auto;
    padding: 0 56px;
}

/* ── Typography helpers ────────────────────────────────────────────────────── */
.fraunces { font-family: var(--font-head); }

/* ── Back link ─────────────────────────────────────────────────────────────── */
.back-link {
    display: inline-block;
    font-size: 14px;
    font-weight: 500;
    color: var(--text-mid);
    margin-bottom: 40px;
    transition: color 0.15s;
}
.back-link:hover { color: var(--text); }

/* ── Buttons ───────────────────────────────────────────────────────────────── */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 10px 20px;
    border-radius: var(--radius);
    font-family: var(--font-body);
    font-size: 14px;
    font-weight: 500;
    transition: background 0.15s, color 0.15s, opacity 0.15s;
    white-space: nowrap;
}

.btn-ghost {
    background: transparent;
    border: 1.5px solid var(--border);
    color: var(--text-mid);
}
.btn-ghost:hover { border-color: var(--text-mid); color: var(--text); }

.btn-primary {
    background: var(--accent);
    color: var(--white);
    border: 1.5px solid transparent;
}
.btn-primary:hover { opacity: 0.88; }

.btn-nudge {
    width: 100%;
    padding: 18px 32px;
    font-size: 17px;
    font-weight: 500;
    background: var(--accent);
    color: var(--white);
    border-radius: var(--radius);
    transition: opacity 0.15s;
    letter-spacing: 0.01em;
}
.btn-nudge:hover:not(:disabled) { opacity: 0.88; }
.btn-nudge:disabled { opacity: 0.5; cursor: not-allowed; }

/* ── HOME PAGE ─────────────────────────────────────────────────────────────── */
.home {}

/* Hero */
.hero {
    padding: 100px 0 72px;
}

.hero-headline {
    font-family: var(--font-head);
    font-weight: 900;
    font-size: clamp(60px, 10vw, 120px);
    letter-spacing: -3px;
    line-height: 0.95;
    color: var(--text);
    max-width: 900px;
    margin-bottom: 28px;
}

.hero-sub {
    font-weight: 300;
    font-size: 18px;
    color: var(--text-mid);
    max-width: 480px;
    margin-bottom: 48px;
    line-height: 1.5;
}

/* Search */
.search-wrap { position: relative; max-width: 640px; }

.search-input {
    width: 100%;
    padding: 16px 20px;
    font-size: 16px;
    font-weight: 400;
    background: var(--surface);
    border: 1.5px solid var(--border);
    border-radius: var(--radius);
    color: var(--text);
    outline: none;
    transition: border-color 0.15s;
}
.search-input::placeholder { color: var(--text-dim); }
.search-input:focus { border-color: var(--text-mid); }
.search-input::-webkit-search-cancel-button { cursor: pointer; }

.search-results {
    list-style: none;
    margin-top: 8px;
    border: 1.5px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    background: var(--surface);
    max-width: 640px;
}

.search-result-item {
    display: flex;
    align-items: baseline;
    gap: 12px;
    padding: 14px 20px;
    border-bottom: 1px solid var(--border);
    cursor: pointer;
    transition: background 0.12s;
}
.search-result-item:last-child { border-bottom: none; }
.search-result-item:hover { background: var(--bg2); }

.search-result-title {
    font-size: 15px;
    font-weight: 500;
    color: var(--text);
    flex-shrink: 0;
}
.search-result-desc {
    font-size: 13px;
    color: var(--text-mid);
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.search-result-cat {
    font-size: 12px;
    color: var(--text-dim);
    flex-shrink: 0;
}

.search-empty {
    margin-top: 12px;
    font-size: 14px;
    color: var(--text-dim);
    max-width: 640px;
    padding: 16px 20px;
    background: var(--surface);
    border: 1.5px solid var(--border);
    border-radius: var(--radius);
}

/* Category list */
.categories {
    padding-bottom: 80px;
}

.cat-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 28px 0;
    border-bottom: 1.5px solid var(--border);
    cursor: pointer;
    position: relative;
    transition: padding-left 0.2s;
}
.cat-row::before {
    content: '';
    position: absolute;
    left: -8px;
    top: 0;
    bottom: 0;
    width: 4px;
    background: var(--accent);
    border-radius: 2px;
    opacity: 0;
    transition: opacity 0.2s, left 0.2s;
}
.cat-row:first-child { border-top: 1.5px solid var(--border); }
.cat-row:hover { padding-left: 16px; }
.cat-row:hover::before { opacity: 1; left: 0; }

.cat-row-left { display: flex; flex-direction: column; gap: 4px; }

.cat-name {
    font-family: var(--font-head);
    font-weight: 700;
    font-size: clamp(32px, 4vw, 56px);
    line-height: 1.1;
    color: var(--text);
    display: block;
}

.cat-desc {
    font-size: 13px;
    font-weight: 400;
    color: var(--text-mid);
    display: block;
}

.cat-count {
    font-size: 14px;
    font-weight: 400;
    color: var(--text-dim);
    flex-shrink: 0;
    margin-left: 32px;
}

/* ── CATEGORY PAGE ─────────────────────────────────────────────────────────── */
.category-page { padding: 80px 0; }

.page-heading {
    font-family: var(--font-head);
    font-weight: 900;
    font-size: clamp(48px, 7vw, 88px);
    letter-spacing: -2px;
    line-height: 0.95;
    color: var(--text);
    margin-bottom: 16px;
    border-left: 5px solid var(--accent);
    padding-left: 20px;
}

.page-tagline {
    font-size: 16px;
    font-weight: 300;
    color: var(--text-mid);
    margin-bottom: 56px;
    padding-left: 25px;
}

/* Prompt grid */
.prompt-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 24px;
}

.prompt-card {
    background: var(--surface);
    border: 1.5px solid var(--border);
    border-radius: 8px;
    padding: 28px 28px 24px;
    display: flex;
    flex-direction: column;
    gap: 20px;
    transition: border-color 0.15s, box-shadow 0.15s;
}
.prompt-card:hover {
    border-color: var(--accent);
    box-shadow: 0 4px 20px rgba(0,0,0,0.06);
}

.prompt-card-body { flex: 1; }

.prompt-card-title {
    font-family: var(--font-head);
    font-weight: 700;
    font-size: 18px;
    line-height: 1.25;
    color: var(--text);
    margin-bottom: 8px;
}

.prompt-card-desc {
    font-size: 13px;
    font-weight: 400;
    color: var(--text-mid);
    line-height: 1.5;
}

.prompt-card-actions {
    display: flex;
    gap: 10px;
    align-items: center;
}
.prompt-card-actions .btn-primary { flex: 1; }

.empty-state { font-size: 15px; color: var(--text-dim); margin-top: 40px; }

/* ── PROMPT PAGE ───────────────────────────────────────────────────────────── */
.prompt-page { padding: 80px 0; }

.prompt-heading {
    font-family: var(--font-head);
    font-weight: 900;
    font-size: clamp(36px, 5vw, 64px);
    letter-spacing: -1.5px;
    line-height: 1.05;
    color: var(--text);
    margin-bottom: 12px;
}

.prompt-desc {
    font-size: 15px;
    font-weight: 300;
    color: var(--text-mid);
    margin-bottom: 40px;
    max-width: 560px;
}

/* Steps */
.step {
    margin-bottom: 48px;
    padding-bottom: 48px;
    border-bottom: 1.5px solid var(--border);
}
.step:last-child { border-bottom: none; }

/* Fields */
.fields {
    display: flex;
    flex-direction: column;
    gap: 24px;
    margin-bottom: 40px;
}

.field-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.field-label {
    font-size: 13px;
    font-weight: 500;
    color: var(--text-mid);
    letter-spacing: 0.01em;
}

.field-input {
    width: 100%;
    padding: 12px 16px;
    font-size: 15px;
    background: var(--surface);
    border: 1.5px solid var(--border);
    border-radius: var(--radius);
    color: var(--text);
    outline: none;
    transition: border-color 0.15s;
    max-width: 640px;
}
.field-input:focus { border-color: var(--text-mid); }

/* Preview */
.preview-wrap {
    max-width: 720px;
}

.preview-label {
    display: block;
    font-size: 12px;
    font-weight: 500;
    color: var(--text-dim);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    margin-bottom: 10px;
}

.preview-box {
    background: var(--bg2);
    border: 1.5px solid var(--border);
    border-radius: var(--radius);
    padding: 20px 24px;
    font-size: 14px;
    color: var(--text-mid);
    line-height: 1.7;
    white-space: pre-wrap;
    word-break: break-word;
}

.preview-copy-btn {
    margin-top: 10px;
}

/* Response */
.response-box {
    background: var(--white);
    border: none;
    border-left: 3px solid var(--accent);
    border-radius: 0 8px 8px 0;
    padding: 28px 36px;
    font-size: 16px;
    line-height: 1.8;
    color: var(--text);
    min-height: 80px;
    max-width: 720px;
    word-break: break-word;
    box-shadow: 0 2px 20px rgba(0,0,0,0.05);
}
.response-box p { margin-bottom: 18px; }
.response-box p:last-child { margin-bottom: 0; }
.response-box h3 {
    font-family: var(--font-head);
    font-weight: 700;
    font-size: 19px;
    color: var(--text);
    margin: 28px 0 10px;
    line-height: 1.2;
}
.response-box h3:first-child { margin-top: 0; }
.response-box h4 {
    font-family: var(--font-head);
    font-weight: 700;
    font-size: 16px;
    color: var(--text);
    margin: 22px 0 8px;
}
.response-box h4:first-child { margin-top: 0; }
.response-box ul, .response-box ol {
    padding-left: 22px;
    margin-bottom: 18px;
}
.response-box li {
    margin-bottom: 8px;
    line-height: 1.7;
}
.response-box li:last-child { margin-bottom: 0; }
.response-box strong { font-weight: 600; }
.response-box em { font-style: italic; color: var(--text-mid); }

@keyframes blink {
    0%, 100% { opacity: 1; }
    50% { opacity: 0; }
}
.streaming-cursor {
    display: inline-block;
    animation: blink 1s step-start infinite;
    color: var(--text-mid);
    font-size: 14px;
    vertical-align: middle;
    margin-left: 2px;
}

/* Post-response */
.post-response {
    margin-top: 24px;
    display: flex;
    flex-direction: column;
    gap: 16px;
    max-width: 720px;
}

.post-response .btn-ghost { align-self: flex-start; }

/* Prompt details disclosure */
.prompt-details summary {
    font-size: 13px;
    font-weight: 500;
    color: var(--text-mid);
    cursor: pointer;
    user-select: none;
    transition: color 0.15s;
    list-style: none;
    display: flex;
    align-items: center;
    gap: 6px;
}
.prompt-details summary::-webkit-details-marker { display: none; }
.prompt-details summary::before {
    content: '▸';
    font-size: 11px;
    transition: transform 0.15s;
}
.prompt-details[open] summary::before { transform: rotate(90deg); }
.prompt-details summary:hover { color: var(--text); }

.prompt-used {
    margin-top: 12px;
    background: var(--bg2);
    border: 1.5px solid var(--border);
    border-radius: var(--radius);
    padding: 16px 20px;
    font-size: 13px;
    font-family: var(--font-body);
    color: var(--text-mid);
    white-space: pre-wrap;
    word-break: break-word;
    line-height: 1.65;
}

.try-another {
    font-size: 14px;
    font-weight: 500;
    color: var(--text-mid);
    transition: color 0.15s;
    align-self: flex-start;
}
.try-another:hover { color: var(--text); }

/* Error */
.error-message {
    background: #fdf0f0;
    border: 1.5px solid #e8c5c5;
    border-radius: var(--radius);
    padding: 14px 18px;
    font-size: 14px;
    color: #8b3333;
    margin-bottom: 20px;
    max-width: 640px;
}

/* Usage limit modal */
.limit-modal {
    position: fixed;
    inset: 0;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
}

.limit-modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(28, 26, 23, 0.4);
    backdrop-filter: blur(2px);
}

.limit-modal-box {
    position: relative;
    z-index: 1;
    background: var(--white);
    border: 1.5px solid var(--border);
    border-radius: 12px;
    padding: 40px 48px;
    max-width: 440px;
    width: 90%;
    text-align: center;
    box-shadow: 0 20px 60px rgba(0,0,0,0.15);
}

.limit-modal-box h3 {
    font-family: var(--font-head);
    font-weight: 700;
    font-size: 24px;
    color: var(--text);
    margin-bottom: 12px;
}

.limit-modal-box p {
    font-size: 15px;
    font-weight: 300;
    color: var(--text-mid);
    margin-bottom: 28px;
    line-height: 1.5;
}

.limit-modal-box .btn-primary {
    background: var(--text);
    color: var(--white);
    padding: 12px 32px;
    font-size: 15px;
}

/* ── RESPONSIVE ────────────────────────────────────────────────────────────── */
@media (max-width: 768px) {
    .container { padding: 0 24px; }

    .hero { padding: 60px 0 48px; }
    .hero-headline { letter-spacing: -1.5px; }
    .hero-sub { font-size: 16px; }

    .categories { padding-bottom: 48px; }
    .cat-row { padding: 20px 0; }

    .prompt-grid { grid-template-columns: 1fr; }

    .category-page { padding: 48px 0; }
    .prompt-page { padding: 48px 0; }

    .prompt-heading { letter-spacing: -0.5px; }

    .response-box { padding: 20px 20px; }
    .prompt-card { padding: 20px 20px 18px; }
    .limit-modal-box { padding: 28px 24px; }
}

@media (max-width: 480px) {
    .container { padding: 0 20px; }
    .cat-row:hover { padding-left: 0; }
    .prompt-card-actions { flex-direction: column; }
    .prompt-card-actions .btn { width: 100%; }
}

/* ── Blazor error UI — hidden ──────────────────────────────────────────────── */
#blazor-error-ui { display: none !important; }
