/* Inherit the site's typography, paper palette and dark-mode variables. */
#page-ai-math {
    padding-bottom: 4.5rem;
}

#ai-math-back-to-top {
    position: fixed;
    right: max(1.25rem, env(safe-area-inset-right));
    bottom: max(1.25rem, env(safe-area-inset-bottom));
    z-index: 40;
    display: grid;
    place-items: center;
    width: 48px;
    height: 48px;
    padding: 0;
    border: 1px solid var(--border-color);
    border-radius: 50%;
    background: var(--solid-surface);
    color: var(--link-color);
    box-shadow: 0 4px 16px var(--soft-shadow);
    cursor: pointer;
    transition: background-color 0.18s ease, border-color 0.18s ease, color 0.18s ease;
}

#ai-math-back-to-top[hidden] {
    display: none;
}

#ai-math-back-to-top:hover {
    border-color: var(--link-color);
    background: var(--surface-wash-strong);
    color: var(--link-hover);
}

#ai-math-back-to-top:focus-visible,
#ai-math-heading:focus-visible {
    outline: 2px solid var(--link-color);
    outline-offset: 4px;
}

@media (max-width: 700px) {
    #ai-math-back-to-top {
        right: max(0.75rem, env(safe-area-inset-right));
        bottom: max(0.75rem, env(safe-area-inset-bottom));
    }
}

@media (prefers-reduced-motion: reduce) {
    #ai-math-back-to-top {
        transition: none;
    }
}

#page-ai-math .ai-math-intro {
    max-width: 62ch;
    margin-bottom: 1.5rem;
}

#page-ai-math .ai-math-blogs {
    margin: 1.5rem 0;
    padding-bottom: 1.1rem;
    border-bottom: 1px solid var(--section-rule);
}

#page-ai-math .ai-math-blogs h3 {
    margin: 0 0 0.5rem;
    font-size: 1.34rem;
    line-height: 1.42;
}

#page-ai-math .ai-math-blog-list {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 18rem), 1fr));
    gap: 0.15rem 2rem;
    margin: 0;
    padding: 0;
    list-style: none;
}

#page-ai-math .ai-math-blog-list li {
    min-width: 0;
    margin: 0;
    padding: 0;
    font-size: 1.22rem;
    line-height: 1.5;
}

#page-ai-math .ai-math-blog-list a {
    display: flex;
    align-items: center;
    width: fit-content;
    max-width: 100%;
    min-height: 44px;
    padding-block: 0.4rem;
    color: var(--link-color);
    text-decoration: none;
    text-decoration-thickness: 1px;
    text-underline-offset: 0.18em;
    overflow-wrap: anywhere;
}

#page-ai-math .ai-math-blog-list a:hover {
    color: var(--link-hover);
    text-decoration: underline;
}

#page-ai-math .ai-math-blog-list a:focus-visible {
    outline: 2px solid var(--link-color);
    outline-offset: 3px;
    border-radius: 2px;
}

#page-ai-math .ai-math-seminar {
    box-sizing: border-box;
    width: 100%;
    margin: 1.5rem 0;
    padding: 1.1rem 1.25rem;
    border: 1px solid var(--section-rule);
    border-radius: 6px;
    background: var(--surface-wash);
}

#page-ai-math .ai-math-seminar-header,
#page-ai-math .ai-math-seminar-footer {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 0.35rem 1.25rem;
}

#page-ai-math .ai-math-seminar h3 {
    margin: 0;
    font-size: 1.3rem;
    line-height: 1.4;
}

#page-ai-math .ai-math-seminar-term {
    color: var(--secondary-text);
    font-family: var(--font-detail);
    font-size: 0.82rem;
    line-height: 1.6;
    white-space: nowrap;
}

#page-ai-math .ai-math-seminar-description {
    margin: 0.65rem 0 0.4rem;
    color: var(--secondary-text);
    font-size: 1rem;
    line-height: 1.6;
}

#page-ai-math .ai-math-seminar-meeting {
    margin: 0;
    color: var(--secondary-text);
    font-size: 0.94rem;
    line-height: 1.6;
}

#page-ai-math .ai-math-seminar-link {
    display: inline-flex;
    align-items: center;
    gap: 0.3em;
    min-height: 44px;
    max-width: 100%;
    color: var(--link-color);
    font-size: 0.96rem;
    line-height: 1.5;
    text-decoration: none;
    text-underline-offset: 0.18em;
    overflow-wrap: anywhere;
}

#page-ai-math .ai-math-seminar-link:hover {
    color: var(--link-hover);
    text-decoration: underline;
}

#page-ai-math .ai-math-seminar-link:focus-visible {
    outline: 2px solid var(--link-color);
    outline-offset: 3px;
    border-radius: 2px;
}

@media (max-width: 900px) {
    #page-ai-math .ai-math-seminar h3 {
        font-size: 1.2rem;
    }
}

@media (max-width: 480px) {
    #page-ai-math .ai-math-seminar {
        padding: 1rem;
    }
}

#page-ai-math .ai-math-controls {
    display: flex;
    align-items: flex-end;
    gap: 1.1rem;
    flex-wrap: wrap;
    margin: 1.8rem 0 0.8rem;
}

#page-ai-math .ai-math-search-label {
    flex: 1 1 15rem;
    min-width: 0;
}

#page-ai-math .ai-math-control-label {
    display: block;
    margin-bottom: 0.35rem;
    color: var(--secondary-text);
    font-size: 1rem;
}

#page-ai-math input,
#page-ai-math select {
    width: 100%;
    min-height: 48px;
    padding: 0.625rem 0.875rem;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    background: var(--bg-color);
    color: var(--text-color);
    font: inherit;
    font-size: 1.08rem;
    line-height: 1.4;
}

#page-ai-math input::placeholder {
    color: var(--secondary-text);
    opacity: 1;
}

#page-ai-math select {
    -webkit-appearance: none;
    appearance: none;
    width: 100%;
    padding-inline-end: 2.625rem;
    cursor: pointer;
}

#page-ai-math .ai-math-sort-label {
    flex: 0 0 auto;
    min-width: min(10.5rem, 100%);
    max-width: 100%;
}

#page-ai-math .ai-math-select-wrap {
    position: relative;
    display: block;
    color: var(--text-color);
}

#page-ai-math .ai-math-select-arrow {
    position: absolute;
    inset-inline-end: 0.875rem;
    top: 50%;
    width: 0.75rem;
    height: 0.5rem;
    transform: translateY(-50%);
    pointer-events: none;
}

#page-ai-math .ai-math-sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
    border: 0;
}

#page-ai-math select:focus-visible {
    outline: 2px solid var(--link-color);
    outline-offset: 3px;
}

#page-ai-math .ai-math-status-row {
    container: ai-math-status / inline-size;
    display: flex;
    align-items: baseline;
    justify-content: flex-start;
    flex-wrap: wrap;
    gap: 0.25rem 0.75rem;
    margin-bottom: 0.9rem;
}

#page-ai-math .ai-math-status-row p,
#page-ai-math .ai-math-date-note {
    margin: 0;
    color: var(--secondary-text);
    font-size: 0.98rem;
    line-height: 1.5;
}

#page-ai-math .ai-math-clear {
    margin-inline-start: auto;
    min-height: 44px;
    padding: 0.2rem 0;
    border: 0;
    background: none;
    color: var(--link-color);
    font: inherit;
    font-size: 1rem;
    text-decoration: underline;
    text-underline-offset: 0.16em;
    cursor: pointer;
}

#page-ai-math .ai-math-status-separator {
    align-self: center;
    color: var(--secondary-text);
    font-size: 0.7rem;
    line-height: 1;
}

@container ai-math-status (max-width: 24rem) {
    #page-ai-math .ai-math-status-separator {
        display: none;
    }

    #page-ai-math .ai-math-date-note {
        flex-basis: 100%;
        order: 1;
    }
}

@container ai-math-status (max-width: 28rem) {
    #page-ai-math .ai-math-status-row:has(.ai-math-clear:not([hidden])) .ai-math-status-separator {
        display: none;
    }

    #page-ai-math .ai-math-status-row:has(.ai-math-clear:not([hidden])) .ai-math-date-note {
        flex-basis: 100%;
        order: 1;
    }
}

#page-ai-math .ai-math-resource {
    padding: 1.2rem 0;
    border-top: 1px solid var(--section-rule);
}

#page-ai-math .ai-math-resource h3 {
    margin: 0 0 0.4rem;
    font-size: 1.34rem;
    font-weight: 600;
    line-height: 1.42;
    letter-spacing: -0.004em;
    overflow-wrap: anywhere;
}

#page-ai-math .ai-math-resource h3 a {
    color: var(--text-color);
    text-decoration: none;
}

#page-ai-math .ai-math-resource h3 a:hover {
    color: var(--link-color);
    text-decoration: underline;
}

#page-ai-math .ai-math-metadata {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: baseline;
    gap: 0.2rem 1.4rem;
    color: var(--secondary-text);
    font-size: 1.05rem;
    line-height: 1.48;
}

#page-ai-math .ai-math-authors {
    min-width: 0;
    overflow-wrap: anywhere;
}

#page-ai-math .ai-math-date {
    flex-shrink: 0;
    max-width: 100%;
    overflow-wrap: anywhere;
    font-size: 0.98rem;
    font-variant-numeric: tabular-nums;
}

#page-ai-math [hidden] {
    display: none !important;
}

body.dark-mode #page-ai-math input,
body.dark-mode #page-ai-math select {
    color-scheme: dark;
}

@media (max-width: 700px) {
    #page-ai-math .ai-math-controls {
        flex-wrap: wrap;
        gap: 0.8rem;
    }

    #page-ai-math .ai-math-search-label {
        flex-basis: 100%;
    }

    #page-ai-math .ai-math-metadata {
        flex-direction: column;
    }

    #page-ai-math .ai-math-resource h3 {
        font-size: 1.25rem;
    }

    #page-ai-math .ai-math-resource {
        padding: 1rem 0;
    }
}

@media print {
    #ai-math-back-to-top {
        display: none;
    }

    #page-ai-math {
        padding-bottom: 0;
    }

    #page-ai-math:not(.active-section),
    body:has(#page-ai-math.active-section) .page-section:not(.active-section) {
        display: none !important;
    }

    #page-ai-math .ai-math-controls,
    #page-ai-math .ai-math-clear {
        display: none;
    }

    #page-ai-math .ai-math-resource {
        break-inside: avoid;
    }
}

/* Preserve the platform arrow in Windows forced-colour accessibility modes. */
@media (forced-colors: active) {
    #page-ai-math select {
        -webkit-appearance: menulist;
        appearance: auto;
        padding-inline-end: 0.875rem;
    }

    #page-ai-math .ai-math-select-arrow {
        display: none;
    }
}
