/* Chord Dictionary */
.chord-dictionary-page {
    max-width: 1360px;
    --diagram-tone-fill: var(--chord-control);
    --diagram-tone-text: #fffaf2;
    --diagram-root-fill: var(--gold-light);
    --diagram-root-text: #2b211a;
    --diagram-root-ring: color-mix(in srgb, var(--gold-light) 35%, transparent);
    --diagram-third-fill: #9f6b45;
    --diagram-third-text: #fffaf2;
    --diagram-third-ring: rgba(159, 107, 69, 0.24);
    --diagram-fifth-fill: #7f8970;
    --diagram-fifth-text: #fffaf2;
    --diagram-fifth-ring: rgba(127, 137, 112, 0.24);
    --diagram-seventh-fill: #9a6472;
    --diagram-seventh-text: #fffaf2;
    --diagram-seventh-ring: rgba(154, 100, 114, 0.24);
    --diagram-extension-fill: #6f7964;
    --diagram-extension-text: #fffaf2;
    --diagram-extension-ring: rgba(111, 121, 100, 0.22);
    --diagram-open-tone-background: color-mix(in srgb, var(--chord-control) 16%, transparent);
    --diagram-open-tone-border: color-mix(in srgb, var(--chord-control) 38%, transparent);
    --diagram-grid-line: color-mix(in srgb, var(--text-subtle) 62%, transparent);
}

.dictionary-heading {
    max-width: 820px;
    margin-bottom: 30px;
}

.dictionary-workspace {
    display: grid;
    grid-template-columns: minmax(330px, 0.72fr) minmax(560px, 1.28fr);
    align-items: start;
    gap: 24px;
}

.dictionary-browser,
.dictionary-detail {
    color: var(--text);
    background: var(--panel-background);
    border: 1px solid var(--border-soft);
    border-radius: var(--radius);
    box-shadow: 0 10px 26px var(--shadow-color);
}

.dictionary-browser {
    padding: 22px;
    border-left: 4px solid var(--teal);
}

.dictionary-detail {
    position: static;
    padding: 24px;
}

.chord-dictionary-page .dictionary-browser::before,
.chord-dictionary-page .dictionary-detail::before,
.chord-dictionary-page .chord-shape-card::before {
    display: none;
}

.dictionary-browser-heading,
.dictionary-detail-heading,
.dictionary-category-heading,
.dictionary-shape-heading,
.chord-shape-card-heading {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 18px;
}

.dictionary-browser-heading h2,
.dictionary-detail-heading h2 {
    margin: 2px 0 0;
    color: var(--gold-light);
    font-size: 25px;
}

.dictionary-kicker {
    margin: 0;
    color: var(--teal);
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.dictionary-search {
    display: grid;
    flex: 0 1 260px;
    gap: 6px;
    color: var(--text-body);
    font-size: 13px;
    font-weight: 600;
}

.dictionary-search input {
    width: 100%;
    min-height: 40px;
    box-sizing: border-box;
    padding: 8px 11px;
    color: var(--control-text);
    background: var(--control-background);
    border: 1px solid var(--border-soft);
    border-radius: 6px;
    font: inherit;
}

.dictionary-search input:focus {
    border-color: var(--teal);
    outline: 3px solid var(--focus-ring);
}

.dictionary-root-field {
    margin: 22px 0 0;
    padding: 0;
    border: 0;
}

.dictionary-root-field legend {
    margin-bottom: 9px;
    color: var(--text-body);
    font-size: 14px;
    font-weight: 600;
}

.dictionary-root-grid {
    display: grid;
    grid-template-columns: repeat(6, minmax(42px, 1fr));
    gap: 6px;
}

.dictionary-root-grid button,
.dictionary-quality-button {
    color: var(--text-body);
    background: var(--control-background);
    border: 1px solid var(--border-soft);
    border-radius: 6px;
    font: inherit;
    cursor: pointer;
    transition:
        color 0.18s ease,
        background-color 0.18s ease,
        border-color 0.18s ease,
        transform 0.18s ease;
}

.dictionary-root-grid button {
    min-height: 38px;
    padding: 7px;
    font-weight: 700;
}

.dictionary-root-grid button:hover,
.dictionary-quality-button:hover {
    color: var(--secondary-hover-text);
    background: var(--secondary-hover-background);
    border-color: var(--hover-border);
    transform: translateY(-1px);
}

.dictionary-root-grid button.is-selected,
.dictionary-quality-button.is-selected {
    color: var(--chord-accent-text);
    background: var(--chord-accent);
    border-color: var(--chord-accent);
}

.dictionary-root-grid button:focus-visible,
.dictionary-quality-button:focus-visible,
.dictionary-play-button:focus-visible,
.dictionary-search input:focus-visible {
    outline: 3px solid var(--focus-ring);
    outline-offset: 3px;
}

.dictionary-categories {
    display: grid;
    gap: 20px;
    margin-top: 26px;
}

.dictionary-category {
    padding-top: 18px;
    border-top: 1px solid var(--divider-color);
}

.dictionary-category-heading {
    margin-bottom: 11px;
}

.dictionary-category-heading h3,
.dictionary-shape-heading h3 {
    margin: 0;
    color: var(--text-strong);
    font-size: 17px;
}

.dictionary-category-heading p,
.dictionary-shape-heading p {
    margin: 4px 0 0;
    color: var(--text-subtle);
    font-size: 13px;
}

.dictionary-category-heading > span,
.dictionary-shape-heading > span {
    display: inline-grid;
    min-width: 28px;
    height: 28px;
    place-items: center;
    color: var(--teal);
    background: var(--soft-background);
    border: 1px solid var(--border-soft);
    border-radius: 999px;
    font-size: 12px;
    font-weight: 700;
}

.dictionary-quality-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 7px;
}

.dictionary-quality-button {
    display: grid;
    gap: 3px;
    min-height: 58px;
    padding: 9px 10px;
    text-align: left;
}

.dictionary-quality-button strong {
    font-size: 13px;
}

.dictionary-quality-button span {
    color: var(--text-subtle);
    font-size: 11px;
}

.dictionary-quality-button.is-selected span {
    color: color-mix(in srgb, var(--chord-accent-text) 72%, transparent);
}

.dictionary-detail-heading {
    padding-bottom: 18px;
    border-bottom: 1px solid var(--divider-color);
}

.dictionary-detail-heading p:not(.dictionary-kicker) {
    max-width: 420px;
    margin: 7px 0 0;
    color: var(--copy-text);
    line-height: 1.62;
}

.dictionary-play-button {
    display: inline-flex;
    flex: 0 0 auto;
    align-items: center;
    justify-content: center;
    gap: 7px;
    min-height: 40px;
    padding: 8px 14px;
    color: var(--primary-button-text);
    background: var(--primary-button-background);
    border: 1px solid var(--primary-button-background);
    border-radius: 999px;
    font: inherit;
    font-size: 13px;
    font-weight: 700;
    cursor: pointer;
}

.dictionary-play-button:hover {
    color: var(--primary-button-hover-text);
    background: var(--primary-button-hover-background);
    border-color: var(--primary-button-hover-background);
    transform: translateY(-1px);
}

.dictionary-play-button:disabled {
    cursor: wait;
    opacity: 0.72;
}

.dictionary-facts {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 8px;
    margin: 18px 0 22px;
}

.dictionary-facts div {
    min-width: 0;
    padding: 11px;
    background: var(--subpanel-background);
    border: 1px solid var(--border-soft);
    border-radius: 6px;
}

.dictionary-facts dt {
    color: var(--text-subtle);
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
}

.dictionary-facts dd {
    overflow-wrap: anywhere;
    margin: 5px 0 0;
    color: var(--gold-light);
    font-size: 14px;
    font-weight: 700;
}

.dictionary-related-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 9px;
    margin: -4px 0 22px;
}

.dictionary-related-actions a {
    display: inline-flex;
    align-items: center;
    min-height: 36px;
    padding: 8px 12px;
    color: var(--secondary-button-text);
    background: var(--secondary-button-background);
    border: 1px solid var(--secondary-button-border);
    border-radius: 999px;
    font-size: 13px;
    font-weight: 800;
    text-decoration: none;
    transition: transform 0.18s ease, background-color 0.18s ease, border-color 0.18s ease;
}

.dictionary-related-actions a:hover {
    color: var(--secondary-hover-text);
    background: var(--secondary-hover-background);
    border-color: var(--hover-border);
    transform: translateY(-1px);
}

.dictionary-shape-heading {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(240px, 340px);
    align-items: end;
    gap: 14px;
    margin-bottom: 12px;
}

.dictionary-shape-heading > span {
    display: block;
    min-width: 0;
    height: auto;
    padding: 8px 12px;
    place-items: initial;
    color: var(--teal);
    background: var(--soft-background);
    border: 1px solid var(--border-soft);
    border-radius: 999px;
    font-size: 12px;
    font-weight: 800;
    line-height: 1.25;
    text-align: left;
}

.dictionary-position-filter {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 7px;
    margin-bottom: 14px;
    padding: 10px 12px;
    background: var(--soft-background);
    border: 1px solid var(--border-soft);
    border-radius: 7px;
}

.dictionary-root-string-filter,
.dictionary-triad-filter {
    margin-top: -7px;
}

.dictionary-position-filter > span {
    margin-right: 3px;
    color: var(--text-body);
    font-size: 13px;
    font-weight: 700;
}

.dictionary-position-filter button {
    min-height: 34px;
    padding: 6px 11px;
    color: var(--secondary-button-text);
    background: var(--secondary-button-background);
    border: 1px solid var(--secondary-button-border);
    border-radius: 999px;
    font: inherit;
    font-size: 12px;
    font-weight: 700;
    cursor: pointer;
}

.dictionary-position-filter button:hover {
    color: var(--secondary-hover-text);
    background: var(--secondary-hover-background);
    border-color: var(--hover-border);
}

.dictionary-position-filter button.is-selected {
    color: var(--chord-accent-text);
    background: var(--chord-accent);
    border-color: var(--chord-accent);
}

.dictionary-position-filter button:focus-visible {
    outline: 3px solid var(--focus-ring);
    outline-offset: 2px;
}

.dictionary-shape-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 12px;
}

.dictionary-shape-grid.is-flipping-shapes .chord-shape-card {
    will-change: transform, opacity;
}

.chord-shape-card {
    min-width: 0;
    padding: 12px 10px 11px;
    background: var(--subpanel-background);
    border: 1px solid var(--border-soft);
    border-radius: 7px;
}

.chord-shape-card-heading {
    align-items: center;
    margin-bottom: 10px;
}

.chord-shape-card-heading > div {
    display: grid;
    gap: 2px;
}

.chord-shape-card-heading span,
.chord-shape-card-heading small {
    color: var(--text-subtle);
    font-size: 12px;
    line-height: 1.35;
}

.chord-shape-card-heading strong {
    color: var(--text-strong);
    font-size: 14px;
    letter-spacing: 0.04em;
}

.chord-diagram {
    max-width: 200px;
    margin: 0 auto;
}

.diagram-status-row,
.diagram-string-names {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    text-align: center;
}

.diagram-status-row {
    align-items: end;
    min-height: 34px;
    color: var(--text-body);
    font-size: 12px;
    font-weight: 700;
}

.diagram-string-status {
    display: grid;
    justify-items: center;
    min-width: 0;
    min-height: 28px;
    color: var(--text-subtle);
}

.diagram-string-status.is-muted {
    align-content: end;
    color: var(--text-body);
}

.diagram-string-status.is-open {
    align-content: center;
    gap: 1px;
}

.diagram-string-status.is-open span {
    font-size: 10px;
    line-height: 1;
}

.diagram-string-status strong {
    display: grid;
    place-items: center;
    min-width: 20px;
    height: 17px;
    padding: 0 4px;
    color: var(--text-body);
    background: var(--diagram-open-tone-background);
    border: 1px solid var(--diagram-open-tone-border);
    border-radius: 999px;
    font-size: 10px;
    line-height: 1;
    transition:
        color 0.24s ease,
        background-color 0.24s ease,
        border-color 0.24s ease,
        box-shadow 0.24s ease;
}

.diagram-string-status.is-root strong {
    color: var(--diagram-root-text);
    background: var(--diagram-root-fill);
    border-color: color-mix(in srgb, var(--diagram-root-fill) 70%, var(--diagram-tone-fill));
}

.diagram-string-status strong[data-tone-family="root"],
.diagram-finger[data-tone-family="root"] {
    color: var(--diagram-root-text);
    background: var(--diagram-root-fill);
}

.diagram-string-status strong[data-tone-family="third"],
.diagram-finger[data-tone-family="third"] {
    color: var(--diagram-third-text);
    background: var(--diagram-third-fill);
}

.diagram-string-status strong[data-tone-family="fifth"],
.diagram-finger[data-tone-family="fifth"] {
    color: var(--diagram-fifth-text);
    background: var(--diagram-fifth-fill);
}

.diagram-string-status strong[data-tone-family="seventh"],
.diagram-finger[data-tone-family="seventh"] {
    color: var(--diagram-seventh-text);
    background: var(--diagram-seventh-fill);
}

.diagram-string-status strong[data-tone-family="extension"],
.diagram-finger[data-tone-family="extension"] {
    color: var(--diagram-extension-text);
    background: var(--diagram-extension-fill);
}

.diagram-string-status strong[data-tone-family="root"] {
    border-color: color-mix(in srgb, var(--diagram-root-fill) 70%, var(--diagram-tone-fill));
    box-shadow: 0 2px 5px var(--diagram-root-ring);
}

.diagram-string-status strong[data-tone-family="third"] {
    border-color: color-mix(in srgb, var(--diagram-third-fill) 72%, var(--diagram-open-tone-border));
    box-shadow: 0 2px 5px var(--diagram-third-ring);
}

.diagram-string-status strong[data-tone-family="fifth"] {
    border-color: color-mix(in srgb, var(--diagram-fifth-fill) 72%, var(--diagram-open-tone-border));
    box-shadow: 0 2px 5px var(--diagram-fifth-ring);
}

.diagram-string-status strong[data-tone-family="seventh"] {
    border-color: color-mix(in srgb, var(--diagram-seventh-fill) 72%, var(--diagram-open-tone-border));
    box-shadow: 0 2px 5px var(--diagram-seventh-ring);
}

.diagram-string-status strong[data-tone-family="extension"] {
    border-color: color-mix(in srgb, var(--diagram-extension-fill) 72%, var(--diagram-open-tone-border));
    box-shadow: 0 2px 5px var(--diagram-extension-ring);
}

.diagram-string-names {
    margin-top: 7px;
    color: var(--text-subtle);
    font-size: 11px;
    font-weight: 600;
}

.diagram-neck {
    position: relative;
    width: calc(100% - 8px);
    height: 174px;
    margin: 0 auto;
}

.diagram-string-line,
.diagram-fret-line {
    position: absolute;
    display: block;
    background: var(--diagram-grid-line);
    will-change: transform, opacity;
}

.diagram-string-line {
    top: 0;
    bottom: 0;
    width: 1px;
}

.diagram-fret-line {
    left: 0;
    right: 0;
    height: 1px;
}

.diagram-fret-line.is-nut {
    height: 3px;
    background: var(--gold-light);
}

.diagram-finger {
    position: absolute;
    z-index: 2;
    display: grid;
    place-items: center;
    min-width: 25px;
    height: 25px;
    padding: 0 4px;
    background: var(--diagram-tone-fill);
    border: 2px solid var(--panel-background);
    border-radius: 999px;
    box-shadow: 0 2px 6px var(--shadow-color);
    color: var(--diagram-tone-text);
    font-size: 10px;
    font-weight: 800;
    line-height: 1;
    transform: translate(-50%, -50%);
    will-change: transform, opacity, box-shadow;
    transition:
        background-color 0.24s ease,
        border-color 0.24s ease,
        box-shadow 0.24s ease,
        color 0.24s ease;
}

.diagram-finger.is-root {
    background: var(--diagram-root-fill);
    border-color: var(--diagram-tone-fill);
    color: var(--diagram-root-text);
    box-shadow:
        0 0 0 2px var(--diagram-root-ring),
        0 3px 8px var(--shadow-color);
}

.diagram-finger[data-tone-family="root"] {
    border-color: var(--diagram-tone-fill);
    box-shadow:
        0 0 0 2px var(--diagram-root-ring),
        0 3px 8px var(--shadow-color);
}

.diagram-finger[data-tone-family="third"] {
    border-color: color-mix(in srgb, var(--diagram-third-fill) 62%, var(--panel-background));
    box-shadow:
        0 0 0 2px var(--diagram-third-ring),
        0 3px 8px var(--shadow-color);
}

.diagram-finger[data-tone-family="fifth"] {
    border-color: color-mix(in srgb, var(--diagram-fifth-fill) 62%, var(--panel-background));
    box-shadow:
        0 0 0 2px var(--diagram-fifth-ring),
        0 3px 8px var(--shadow-color);
}

.diagram-finger[data-tone-family="seventh"] {
    border-color: color-mix(in srgb, var(--diagram-seventh-fill) 62%, var(--panel-background));
    box-shadow:
        0 0 0 2px var(--diagram-seventh-ring),
        0 3px 8px var(--shadow-color);
}

.diagram-finger[data-tone-family="extension"] {
    border-color: color-mix(in srgb, var(--diagram-extension-fill) 62%, var(--panel-background));
    box-shadow:
        0 0 0 2px var(--diagram-extension-ring),
        0 3px 8px var(--shadow-color);
}

.diagram-base-fret {
    position: absolute;
    right: calc(100% + 7px);
    top: -1px;
    color: var(--text-body);
    font-size: 12px;
    font-weight: 700;
}

.dictionary-empty {
    grid-column: 1 / -1;
    display: grid;
    gap: 5px;
    padding: 18px;
    color: var(--text-body);
    background: var(--subpanel-background);
    border: 1px dashed var(--border-soft);
    border-radius: 7px;
}

.dictionary-empty span {
    color: var(--text-subtle);
    font-size: 13px;
}

.dictionary-pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 14px;
    margin-top: 18px;
}

.dictionary-pagination[hidden] {
    display: none;
}

.dictionary-pagination span {
    min-width: 92px;
    color: var(--text-subtle);
    font-size: 12px;
    font-weight: 700;
    text-align: center;
}

.dictionary-pagination button {
    min-height: 42px;
    padding: 9px 18px;
    color: var(--secondary-button-text);
    background: var(--secondary-button-background);
    border: 1px solid var(--secondary-button-border);
    border-radius: 999px;
    font: inherit;
    font-size: 13px;
    font-weight: 700;
    cursor: pointer;
    transition:
        color 0.18s ease,
        background-color 0.18s ease,
        border-color 0.18s ease,
        transform 0.18s ease;
}

.dictionary-pagination button:hover:not(:disabled) {
    color: var(--secondary-hover-text);
    background: var(--secondary-hover-background);
    border-color: var(--hover-border);
    transform: translateY(-1px);
}

.dictionary-pagination button:focus-visible {
    outline: 3px solid var(--focus-ring);
    outline-offset: 3px;
}

.dictionary-pagination button:disabled {
    cursor: not-allowed;
    opacity: 0.42;
}

html[data-theme="light"] .dictionary-browser,
html[data-theme="light"] .dictionary-detail,
html[data-theme="light"] .chord-shape-card,
html[data-theme="light"] .dictionary-facts div {
    border-color: rgba(88, 72, 58, 0.24);
}

html[data-theme="light"] .chord-dictionary-page {
    --diagram-tone-fill: #9a6843;
    --diagram-tone-text: #fffaf2;
    --diagram-root-fill: #2d7b76;
    --diagram-root-text: #fffdf8;
    --diagram-root-ring: rgba(45, 123, 118, 0.22);
    --diagram-third-fill: #9d6a3d;
    --diagram-third-text: #fffaf2;
    --diagram-third-ring: rgba(157, 106, 61, 0.2);
    --diagram-fifth-fill: #b88b56;
    --diagram-fifth-text: #fffaf2;
    --diagram-fifth-ring: rgba(184, 139, 86, 0.22);
    --diagram-seventh-fill: #b06b7a;
    --diagram-seventh-text: #fffaf2;
    --diagram-seventh-ring: rgba(176, 107, 122, 0.18);
    --diagram-extension-fill: #7a8c74;
    --diagram-extension-text: #fffaf2;
    --diagram-extension-ring: rgba(122, 140, 116, 0.2);
    --diagram-open-tone-background: #f2e5d6;
    --diagram-open-tone-border: rgba(154, 104, 67, 0.26);
    --diagram-grid-line: rgba(93, 82, 72, 0.5);
}

html[data-theme="light"] .chord-shape-card {
    background: #f7f0e7;
}

html[data-theme="light"] .diagram-string-status.is-root strong {
    box-shadow: 0 2px 5px rgba(45, 123, 118, 0.16);
}

@media (max-width: 1120px) {
    .dictionary-workspace {
        grid-template-columns: 1fr;
    }

    .dictionary-quality-grid {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }
}

@media (max-width: 680px) {
    .chord-dictionary-page {
        padding-inline: 16px;
    }

    .dictionary-browser,
    .dictionary-detail {
        padding: 18px;
    }

    .dictionary-browser-heading,
    .dictionary-detail-heading {
        flex-direction: column;
    }

    .dictionary-shape-heading {
        grid-template-columns: 1fr;
    }

    .dictionary-search,
    .dictionary-play-button {
        width: 100%;
    }

    .dictionary-root-grid {
        grid-template-columns: repeat(4, 1fr);
    }

    .dictionary-quality-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .dictionary-facts {
        grid-template-columns: 1fr;
    }

    .dictionary-shape-grid {
        grid-template-columns: 1fr;
    }

    .chord-shape-card {
        display: grid;
        grid-template-columns: minmax(120px, 0.72fr) minmax(150px, 1fr);
        align-items: center;
        gap: 12px;
    }

    .chord-shape-card-heading {
        align-items: flex-start;
        flex-direction: column;
        margin: 0;
    }
}

@media (max-width: 420px) {
    .chord-shape-card {
        display: block;
    }

    .chord-shape-card-heading {
        margin-bottom: 10px;
    }
}
