.topic-index {
    --index-ink: #243b45;
    --index-accent: #008aa3;
    --index-border: #dce5e8;
    color: var(--index-ink);
}

.topic-index [hidden], .index-preview[hidden] {
    display: none !important;
}

.topic-index__intro {
    max-width: 850px;
    margin-bottom: 28px;
    line-height: 1.8;
}

.topic-index__toolbar, .topic-index__toggles, .topic-index__search-row {
    display: flex;
    align-items: center;
    gap: 12px;
}

.topic-index__toolbar {
    justify-content: space-between;
    margin-bottom: 24px;
    flex-wrap: wrap;
}

.topic-index__text-button, .topic-index__search-toggle {
    border: 0;
    background: transparent;
    color: var(--index-accent);
    cursor: pointer;
    padding: 8px 0;
}

.topic-index__text-button {
    text-decoration: underline;
    text-underline-offset: 4px;
}

.topic-index__search-toggle {
    display: flex;
    align-items: center;
    gap: 8px;
}

.topic-index__search-toggle svg {
    width: 23px;
    height: 23px;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.8;
}

.topic-index__search {
    padding: 22px;
    margin-bottom: 24px;
    border: 1px solid var(--index-border);
    border-radius: 4px;
    background: #f6fafb;
}

.topic-index__search label {
    font-weight: 600;
}

.topic-index__search-row input {
    max-width: 650px;
}

.topic-index__search p {
    margin: 12px 0 0;
    font-size: 14px;
}

.topic-index__alphabet {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 30px;
}

.topic-index__alphabet a, .topic-index__alphabet span {
    display: grid;
    place-items: center;
    width: 36px;
    height: 40px;
    border: 1px solid var(--index-border);
    border-radius: 3px;
    font-weight: 600;
}

.topic-index__alphabet a:hover, .topic-index__alphabet a[aria-expanded="true"] {
    color: #fff;
    background: var(--index-accent);
    border-color: var(--index-accent);
}

.topic-index__alphabet span {
    color: #a5afb2;
    background: #f8fafb;
}

.index-letter {
    margin-bottom: 12px;
    border: 1px solid var(--index-border);
    border-radius: 4px;
    scroll-margin-top: 110px;
}

.index-letter > summary {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 16px 22px;
    background: #f6fafb;
    cursor: pointer;
    list-style: none;
}

.index-letter > summary::-webkit-details-marker {
    display: none;
}

.index-letter > summary::after {
    content: '+';
    margin-left: auto;
    font-size: 26px;
}

.index-letter[open] > summary::after {
    content: '−';
}

.index-letter > summary > span {
    font-size: 26px;
    font-weight: 600;
}

.index-letter > summary > small {
    color: #65777e;
}

.index-letter__topics {
    padding: 0 24px;
}

.index-topic {
    padding: 26px 0;
    border-bottom: 1px solid var(--index-border);
}

.index-topic:last-child {
    border-bottom: 0;
}

.index-topic__title {
    margin-bottom: 16px;
    font-size: 25px;
}

.index-topic__title a, .index-term__title a {
    color: var(--index-ink);
}

[data-topic-index] .index-topic__title a,
[data-topic-index] .index-term__title a,
[data-topic-index] .index-term__related a,
[data-topic-index] .index-topic__read {
    text-decoration: underline;
    text-underline-offset: 3px;
}

.index-topic a:hover {
    color: var(--index-accent);
}

.index-term--child {
    margin-top: 22px;
    margin-left: 20px;
    padding-left: 18px;
    border-left: 2px solid var(--index-border);
}

.index-term {
    scroll-margin-top: 110px;
}

.index-term__title {
    margin-bottom: 10px;
    font-size: 18px;
}

.index-term__aliases {
    margin-bottom: 10px;
    font-style: italic;
    white-space: pre-line;
}

.index-term__references {
    display: flex;
    flex-wrap: wrap;
    gap: 4px 6px;
}

.index-question-link {
    display: inline-block;
    padding: 3px 7px;
    border-radius: 3px;
    color: var(--index-accent);
    background: #edf7f8;
    font-size: 14px;
    line-height: 1.7;
}

.index-question-link:hover, .index-question-link:focus-visible {
    background: #d8eef2;
    text-decoration: underline;
}

.index-term__related {
    margin-top: 12px;
    font-size: 14px;
    white-space: pre-line;
}

.index-term__related span {
    display: inline-block;
    margin-right: 8px;
}

.index-topic__read {
    display: inline-block;
    margin-top: 18px;
    color: var(--index-accent);
    font-size: 14px;
}

.topic-index mark {
    color: #243b45;
    background: #ffe69b;
    border-radius: 2px;
    padding: 0;
}

.index-preview {
    position: fixed;
    z-index: 1100;
    width: min(580px, calc(100vw - 24px));
    max-height: min(620px, calc(100vh - 24px));
    display: flex;
    flex-direction: column;
    border: 1px solid #cbdde2;
    border-radius: 6px;
    background: #fff;
    color: #243b45;
    box-shadow: 0 16px 55px rgba(22, 46, 58, .25);
}

.index-preview__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 20px;
    border-bottom: 1px solid #dce5e8;
    gap: 16px;
}

.index-preview__header h2 {
    margin: 0;
    font-size: 20px;
}

.index-preview__close {
    border: 0;
    background: transparent;
    cursor: pointer;
    font-size: 30px;
    line-height: 1;
    padding: 4px 8px;
}

.index-preview__body {
    overflow: auto;
    overscroll-behavior: contain;
    padding: 20px;
    font-size: 16px;
    line-height: 1.8;
}

.index-preview__read {
    padding: 14px 20px;
    border-top: 1px solid #dce5e8;
    color: #008aa3;
}

.index-topic-reader__back {
    display: inline-block;
    margin-bottom: 24px;
    color: var(--index-accent);
}

.index-topic-reader.reader-mode {
    --index-ink: var(--reader-heading);
    --index-border: var(--reader-border);
}

.index-topic-reader[data-reader-theme="dark"] {
    --index-accent: #49c6db;
}

.index-topic-reader .index-question-link {
    background: var(--reader-surface-soft);
}

.index-topic-reader .index-question-link:hover,
.index-topic-reader .index-question-link:focus-visible {
    background: var(--reader-border);
}

.index-topic-reader .post-content,
.index-topic-reader .post-content ul,
.index-topic-reader .post-content ol {
    color: inherit;
    font-family: inherit;
    font-size: inherit;
    line-height: inherit;
}

.index-topic-reader__overview {
    margin-bottom: 32px;
    padding: 22px;
    border: 1px solid var(--index-border);
    background: var(--reader-surface-soft);
}

.index-topic-reader__overview > summary {
    margin-bottom: 16px;
    font-size: 20px;
    cursor: pointer;
}

.index-topic-reader__question {
    padding: 24px 0;
    border-top: 1px solid var(--index-border);
    scroll-margin-top: 110px;
}

.index-topic-reader__question > h2, .index-topic-reader__question > h3,
.index-topic-reader__question > h4, .index-topic-reader__question > h5,
.index-topic-reader__question > h6 {
    font-size: 22px;
}

.index-topic-reader__section {
    margin-top: 36px;
}

.index-topic-reader__heading {
    scroll-margin-top: 110px;
    margin-bottom: 24px;
}

@media (max-width: 600px) {
    .index-letter__topics { padding: 0 14px; }
    .index-term--child { margin-left: 8px; padding-left: 12px; }
    .topic-index__alphabet { gap: 4px; }
    .topic-index__alphabet a, .topic-index__alphabet span { width: 32px; }
    .topic-index__search, .index-topic-reader__overview { padding: 16px; }
}
