.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.4);
    backdrop-filter: blur(8px);
    z-index: 5000;
    display: none;
    justify-content: center;
    align-items: center;
    opacity: 0;
    transition: opacity 0.3s;
}

.modal-overlay.active { display: flex; opacity: 1; }

.modal {
    background: linear-gradient(180deg, rgba(255,255,255,0.98), rgba(250,248,245,0.96));
    border: 1px solid rgba(255,255,255,0.7);
    border-radius: 20px;
    padding: 0;
    max-width: 600px;
    width: 90%;
    max-height: min(86vh, 920px);
    overflow: hidden;
    /* Warm-ink lift so the panel reads as raised off the blurred page. Dark
       theme has its own shadow in base.css. */
    box-shadow: 0 34px 80px -20px rgba(60, 40, 30, 0.4), 0 2px 8px rgba(60, 40, 30, 0.06);
    transform: scale(0.9) translateY(20px);
    transition: transform 0.3s cubic-bezier(0.4,0,0.2,1);
    display: flex;
    flex-direction: column;
}

.modal-overlay.active .modal { transform: scale(1) translateY(0); }

.modal-header {
    padding: 24px 28px 16px;
    border-bottom: 1px solid rgba(0,0,0,0.06);
    background: linear-gradient(135deg, rgba(255,255,255,0.98), rgba(253,235,208,0.6) 42%, rgba(232,224,240,0.56));
    display: flex;
    align-items: center;
    gap: 14px;
    position: relative;
}

.modal-header::after {
    content: '';
    position: absolute;
    left: 28px;
    right: 28px;
    bottom: 0;
    height: 1px;
    background: linear-gradient(90deg, rgba(178, 58, 72,0.14), rgba(133,193,233,0.22), rgba(184,169,201,0.12));
}

.modal-avatar {
    width: 56px;
    height: 56px;
    display: flex;
    flex-shrink: 0;
}

.modal-avatar-icon {
    width: 100%;
    height: 100%;
    border-radius: 14px;
}

.modal-avatar-icon[data-icon='brand'] {
    border-radius: 50%;
    font-size: 18px;
}

.modal-title { font-family: var(--font-serif); font-size: 24px; font-weight: 600; letter-spacing: -0.015em; color: var(--text); }
.modal-subtitle { font-size: 13px; color: var(--text-muted); margin-top: 4px; }
.modal-body {
    padding: 24px 28px 28px;
    overflow-y: auto;
    flex: 1 1 auto;
    min-height: 0;
    display: flex;
    flex-direction: column;
    gap: 14px;
    background: linear-gradient(180deg, rgba(255,255,255,0.95), rgba(250,248,245,0.9));
}

/* Editorial sections: numbered serif heads on hairline rules, no cards. Wine
   is the one accent, as on the entrance; the numbering echoes the canvas's
   "01 / AI SYSTEMS" labels. */
.modal-body {
    counter-reset: modal-section;
}

.modal-section {
    counter-increment: modal-section;
    position: relative;
    padding: 18px 0 20px;
    border-top: 1px solid var(--hairline);
}

.modal-section:first-child {
    padding-top: 2px;
    border-top: 0;
}

.modal-section-intro {
    counter-increment: none;
}

.modal-section-title {
    display: flex;
    align-items: baseline;
    gap: 12px;
    margin: 0 0 8px;
    color: var(--text);
    font-family: var(--font-serif);
    font-size: 19px;
    font-weight: 600;
    letter-spacing: -0.01em;
}

.modal-section-title::before {
    content: counter(modal-section, decimal-leading-zero);
    font-family: var(--font-mono);
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.08em;
    color: var(--accent);
}

.modal-lead {
    font-size: 15px;
    line-height: 1.7;
    color: var(--text);
    font-weight: 500;
}

.modal-section p,
.modal-section li {
    font-size: 14px;
    color: var(--text-secondary);
    line-height: 1.72;
    margin-bottom: 8px;
}

.modal-section p:last-child,
.modal-section li:last-child {
    margin-bottom: 0;
}

.modal-section ul {
    list-style: none;
    padding-left: 0;
    margin: 4px 0 0;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.modal-section li {
    position: relative;
    padding-left: 18px;
}

.modal-section li::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0.86em;
    width: 7px;
    height: 7px;
    border-radius: 999px;
    background: var(--accent);
    transform: translateY(-50%);
}

.modal-section p strong,
.modal-section li strong {
    color: var(--text);
    font-weight: 700;
    box-shadow: inset 0 -0.45em 0 rgba(255,214,165,0.45);
}

.modal-body a {
    color: var(--pink-dark);
    text-decoration: none;
    font-weight: 600;
    word-break: break-word;
    text-decoration-color: rgba(178, 58, 72,0.36);
    text-underline-offset: 0.18em;
}

.modal-body a:hover {
    text-decoration: underline;
}

.modal-link-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-top: 4px;
}

.modal-link-list p {
    margin-bottom: 0;
    padding: 10px 12px;
    border-radius: 14px;
    background: rgba(255,255,255,0.72);
    border: 1px solid rgba(0,0,0,0.05);
}

.modal-stack {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.modal-stack-pill {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 11px;
    border-radius: 999px;
    border: 1px solid var(--tone-border);
    background:
        linear-gradient(180deg, rgba(255, 255, 255, 0.84), rgba(255, 255, 255, 0.48)),
        var(--tone-bg);
    color: var(--tone-text);
    font-size: 11px;
    font-weight: 700;
    box-shadow: 0 6px 18px rgba(88,93,122,0.06);
}

/* Experience case studies use visual breakdowns instead of repeating resume
   bullets. The wash and accent inherit the existing canvas palette. */
.modal-story-flow {
    --story-accent: var(--pink-dark);
    --story-wash: var(--pink-light);
    display: grid;
    grid-template-columns: repeat(7, minmax(0, 1fr));
    align-items: center;
    gap: 7px;
    margin: 4px 0 2px;
    padding: 10px;
    border: 1px solid var(--hairline-soft);
    border-radius: 14px;
    background: linear-gradient(135deg, var(--story-wash), var(--surface-sunken));
}

.modal-story-flow-mint {
    --story-accent: var(--mint-dark);
    --story-wash: var(--mint);
}

.modal-story-flow-lilac {
    --story-accent: var(--lavender-dark);
    --story-wash: var(--lavender);
}

.modal-story-flow span {
    min-width: 0;
    padding: 7px 5px;
    border: 1px solid var(--hairline-soft);
    border-radius: 9px;
    background: var(--card-bg);
    color: var(--story-accent);
    font-size: 10px;
    font-weight: 800;
    line-height: 1.25;
    text-align: center;
}

.modal-story-flow i {
    color: var(--text-muted);
    font-size: 12px;
    font-style: normal;
    text-align: center;
}

.modal-story-grid {
    --story-accent: var(--pink-dark);
    --story-wash: var(--pink-light);
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 8px;
    margin: 4px 0 2px;
}

.modal-story-grid-amber {
    --story-accent: var(--peach-dark);
    --story-wash: var(--peach);
}

.modal-story-grid > div {
    min-width: 0;
    padding: 11px 10px;
    border: 1px solid var(--hairline-soft);
    border-radius: 14px;
    background: linear-gradient(160deg, var(--story-wash), var(--card-bg));
}

.modal-story-grid span {
    display: block;
    margin-bottom: 7px;
    color: var(--story-accent);
    font-size: 9px;
    font-weight: 800;
    letter-spacing: 0.1em;
}

.modal-story-grid strong {
    display: block;
    margin-bottom: 5px;
    color: var(--text);
    font-size: 12px;
}

.modal-story-grid p {
    margin: 0;
    font-size: 11px;
    line-height: 1.55;
}

.modal[data-modal-variant='logic'] {
    max-width: 680px;
}

.modal[data-modal-variant='logic'] .modal-header {
    background:
        linear-gradient(135deg, rgba(217, 138, 147, 0.22), rgba(214, 234, 248, 0.5) 48%, rgba(212, 245, 224, 0.46)),
        rgba(255, 255, 255, 0.96);
}

.modal-body[data-modal-variant='logic'] {
    gap: 12px;
}

.modal-body[data-modal-variant='logic'] .modal-section {
    border-radius: 16px;
    box-shadow: 0 12px 28px rgba(88, 93, 122, 0.055);
}

.logic-snapshot {
    display: grid;
    gap: 8px;
    padding: 16px;
    border: 1px solid rgba(178, 58, 72, 0.16);
    border-radius: 16px;
    background:
        linear-gradient(135deg, rgba(217, 138, 147, 0.12), rgba(133, 193, 233, 0.14)),
        rgba(255, 255, 255, 0.68);
}

.logic-snapshot span,
.logic-rule-grid span {
    color: var(--pink-dark);
    font-size: 10px;
    font-weight: 800;
    letter-spacing: 0.12em;
    text-transform: uppercase;
}

.logic-snapshot strong {
    color: var(--text);
    font-size: 18px;
    line-height: 1.35;
}

.logic-snapshot p {
    margin: 0;
}

.logic-rule-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 10px;
    margin-top: 12px;
}

.logic-rule-grid div {
    padding: 12px;
    border: 1px solid rgba(0, 0, 0, 0.06);
    border-radius: 14px;
    background: rgba(255, 255, 255, 0.7);
}

.logic-rule-grid strong {
    display: block;
    margin-top: 6px;
    color: var(--text);
    font-size: 12.5px;
    line-height: 1.35;
}

/* In-flow, not absolute — absolute let the title run underneath on narrow screens. */
.modal-header-actions {
    display: flex;
    align-items: center;
    flex: 0 0 auto;
    align-self: flex-start;
    gap: 2px;
    margin-left: auto;
}

.modal-heading {
    min-width: 0;
}

.modal-permalink,
.modal-close {
    position: relative;
    width: 32px;
    height: 32px;
    border-radius: var(--r-sm);
    border: none;
    background: transparent;
    cursor: pointer;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.16s ease, color 0.16s ease;
}

.modal-tags {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    padding: 18px 28px 24px;
    border-top: 1px solid rgba(0,0,0,0.06);
    flex: 0 0 auto;
    background: linear-gradient(180deg, rgba(255,255,255,0), rgba(250,248,245,0.9));
}

@media (max-width: 767px) {
    .modal {
        width: 94%;
        max-height: 90vh;
        border-radius: 18px;
    }

    .modal-header {
        padding: 20px 20px 14px;
        gap: 12px;
    }

    .modal-avatar {
        width: 48px;
        height: 48px;
    }

    .modal-title {
        font-size: 18px;
    }

    .modal-subtitle {
        font-size: 12px;
        line-height: 1.5;
        max-width: calc(100vw - 120px);
    }

    .modal-body {
        padding: 20px 20px 24px;
        gap: 12px;
    }

    .modal-tags {
        padding: 14px 20px 20px;
    }

    .modal-section {
        padding: 16px 16px 16px 18px;
        border-radius: 16px;
    }

    .modal-section-title {
        padding: 6px 10px;
        font-size: 10px;
    }

    .modal-lead,
    .modal-section p,
    .modal-section li {
        font-size: 13px;
        line-height: 1.78;
    }

    .modal-link-list p {
        padding: 9px 11px;
        border-radius: 12px;
    }

    .modal-story-flow {
        grid-template-columns: 1fr;
    }

    .modal-story-flow i {
        transform: rotate(90deg);
    }

    .modal-story-grid {
        grid-template-columns: 1fr;
    }

    .logic-rule-grid {
        grid-template-columns: 1fr;
    }

    .logic-snapshot {
        padding: 14px;
    }

    .logic-snapshot strong {
        font-size: 16px;
    }
}

.modal-permalink .ui-icon,
.modal-close .ui-icon {
    width: 16px;
    height: 16px;
}

/* The link icon swaps to a check for a beat after copying. */
.modal-permalink-done {
    position: absolute;
    opacity: 0;
}

.modal-permalink[data-copy-state='copied'] {
    color: var(--accent-strong);
}

.modal-permalink[data-copy-state='copied'] .ui-icon:first-child {
    opacity: 0;
}

.modal-permalink[data-copy-state='copied'] .modal-permalink-done {
    opacity: 1;
}

.modal-permalink:hover,
.modal-close:hover {
    background: var(--surface-hover);
    color: var(--text);
}

.modal-permalink:focus-visible,
.modal-close:focus-visible {
    outline: 2px solid var(--ring);
    outline-offset: 2px;
}

/* About opens with YC and the three public figures from the entrance, so the
   profile has a face and numbers before its prose. */
.profile-hero {
    display: grid;
    grid-template-columns: 96px minmax(0, 1fr);
    align-items: end;
    gap: 22px;
    padding-bottom: 6px;
}

.profile-portrait {
    width: 96px;
    height: 168px;
    object-fit: contain;
    object-position: bottom;
}

.profile-figures {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    margin: 0;
    border-block: 1px solid var(--hairline);
}

.profile-figures div {
    display: flex;
    flex-direction: column-reverse;
    justify-content: flex-end;
    gap: 4px;
    padding: 14px 16px;
}

.profile-figures div + div { border-left: 1px solid var(--hairline-soft); }
.profile-figures div:first-child { padding-left: 0; }

.profile-figures dd {
    margin: 0;
    font-family: var(--font-serif);
    font-size: 30px;
    font-weight: 600;
    line-height: 1.1;
    letter-spacing: -0.02em;
    color: var(--accent-strong);
}

.profile-figures dt {
    font-size: 12.5px;
    color: var(--text-muted);
    word-break: keep-all;
}

body[data-theme='dark'] .profile-figures dd { color: var(--pink); }

/* Contact: availability first, then one row of real actions; the detailed
   list stays below for anyone who wants the raw addresses. */
.contact-status {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    font-weight: 600;
    color: var(--text);
}

.contact-status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #3F9A6B;
    box-shadow: 0 0 0 4px rgba(63, 154, 107, 0.16);
}

.contact-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin: 4px 0 6px;
}

.contact-action {
    display: inline-flex;
    align-items: center;
    padding: 10px 16px;
    border: 1px solid var(--hairline);
    border-radius: 999px;
    font-size: 14px;
    font-weight: 600;
    color: var(--text);
    text-decoration: none;
    background: var(--surface-solid);
    transition: border-color 0.16s ease, background-color 0.16s ease;
}

.contact-action:hover { border-color: var(--accent); }

.contact-action.is-primary {
    border-color: var(--accent);
    background: var(--accent);
    color: #fff;
}

.contact-action.is-primary:hover { background: var(--accent-strong); }

/* On a phone the three figures need the full width, so YC steps aside. */
@media (max-width: 520px) {
    .profile-hero { grid-template-columns: minmax(0, 1fr); }
    .profile-portrait { display: none; }
    .profile-figures div { padding: 12px 10px; }
    .profile-figures dd { font-size: 24px; }
}
