:root {
    --lex-bg: #14161d;
    --lex-panel: #1c202a;
    --lex-border: #373d4f;
    --lex-text: #f0f2f8;
    --lex-muted: #b3bbce;
    --lex-accent: #c3adff;
}

body { background: var(--lex-bg); color: var(--lex-text); }
a { color: var(--lex-accent); }
a:hover { color: #dfd2ff; }
:focus-visible { outline: 2px solid var(--lex-accent); outline-offset: 3px; }
[hidden] { display: none !important; }

.lex-shell { width: min(100% - 2rem, 70rem); margin: auto; padding: 1.5rem 0 calc(4rem + var(--speech-player-space, 0px)); }
.lex-top { min-height: 2.25rem; display: flex; align-items: center; justify-content: space-between; gap: 1rem; }
.lex-top a { text-decoration: none; }
.lex-top-actions { display: flex; align-items: center; gap: .5rem; }
.lex-top-actions form { display: flex; margin: 0; }
.lex-top-actions form button { width: 100%; white-space: nowrap; }
.settings-link { display: inline-flex; align-items: center; justify-content: center; padding: .25rem; width: auto; height: auto; border: 0; }
.settings-link svg { display: block; flex-shrink: 0; }
.automated-task-row { display: flex; align-items: center; flex-wrap: wrap; gap: .5rem 1rem; }
.automated-task-row > .dictionary-title { flex: 1; min-width: 8rem; text-align: left; }
.settings-link[aria-current="page"] { background: #352851; }
.lex-hero { padding: clamp(2rem, 5vw, 3.5rem) 0 1.75rem; }
.lex-hero h1 { font-size: clamp(2.25rem, 7vw, 4.5rem); letter-spacing: -.05em; line-height: 1.02; margin: .3rem 0 .75rem; }
.lex-hero > p:last-child { color: var(--lex-muted); font-size: clamp(1rem, 2vw, 1.2rem); margin-bottom: 0; }
.eyebrow { margin: 0 0 .4rem; color: var(--lex-accent); font-size: .78rem; font-weight: 650; letter-spacing: .1em; overflow-wrap: anywhere; }
.panel { background: var(--lex-panel); border: 1px solid var(--lex-border); border-radius: 1rem; padding: clamp(1rem, 3vw, 1.5rem); min-width: 0; }
.panel h2, .reader h2, .section-heading h2 { font-size: 1.45rem; }
.panel h3 { font-size: 1.22rem; overflow-wrap: anywhere; }
.work-grid { display: grid; gap: 1rem; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.app-directory { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fit, minmax(min(100%, 24rem), 1fr)); }
.app-tile { display: flex; align-items: flex-start; gap: 1rem; text-decoration: none; color: var(--lex-text); max-width: 39rem; }
.app-tile:hover { border-color: var(--lex-accent); color: var(--lex-text); }
.app-tile p { color: var(--lex-muted); margin: 0; }
.app-mark { background: #31264c; color: var(--lex-accent); border-radius: .65rem; flex: 0 0 auto; font-size: 1.3rem; font-weight: 650; padding: .45rem .65rem; }
.app-arrow { color: var(--lex-accent); margin-left: auto; }

.lex-tabs { display: flex; flex-wrap: wrap; gap: .35rem; border-bottom: 1px solid var(--lex-border); padding-bottom: .6rem; }
.lex-tabs a { border-radius: .5rem; color: var(--lex-muted); padding: .5rem .7rem; text-decoration: none; }
.lex-tabs a:hover { color: var(--lex-text); background: var(--lex-panel); }
.lex-tabs a[aria-current] { color: #f1e8ff; background: #352851; }
.lex-tabs [role="tab"] { border: 0; border-radius: .5rem; color: var(--lex-muted); background: transparent; padding: .4rem .65rem; }
.lex-tabs [role="tab"]:hover, .lex-tabs [aria-selected="true"] { color: #f1e8ff; background: #352851; }
.dictionary-word-links { display: flex; flex-wrap: wrap; gap: .25rem .8rem; margin: 0; padding: 0; list-style: none; overflow-wrap: anywhere; }
.lex-notice { min-height: 1.5rem; margin: .6rem 0; color: var(--lex-accent); overflow-wrap: anywhere; }
.lex-notice:empty { display: none; }
.lex-notice.is-error, .dialog-error { color: #ffadb8; }
.dialog-error:empty { display: none; }
.button-row { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem; }
.search-language-group { min-width: 0; margin: 0; }
.search-language-choices { display: flex; flex-wrap: wrap; gap: .25rem; }
.search-language-choices label, .language-default { display: inline-flex; align-items: center; gap: .35rem; cursor: pointer; }
.search-language-choices label { border: 1px solid transparent; border-radius: .45rem; padding: .25rem .45rem; }
.search-language-choices label:has(input:checked) { color: var(--lex-accent); }
.search-language-choices label:hover { border-color: var(--lex-border); }
#manage-languages { border-color: transparent; }
.search-language-choices input, .language-default input { accent-color: var(--lex-accent); }
.language-picker { width: auto; flex: 1 1 12rem; }
.ai-provider-picker { width: auto; max-width: 100%; }
.language-order { padding: 0; list-style: none; max-height: 17rem; overflow: auto; }
.language-row { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: .5rem; padding: .5rem .2rem; border-top: 1px solid var(--lex-border); }
.btn-accent { --bs-btn-color: #1d1230; --bs-btn-bg: #c3adff; --bs-btn-border-color: #c3adff; --bs-btn-hover-color: #1d1230; --bs-btn-hover-bg: #d8c9ff; --bs-btn-hover-border-color: #d8c9ff; --bs-btn-active-color: #1d1230; --bs-btn-active-bg: #bca2ff; --bs-btn-active-border-color: #bca2ff; --bs-btn-disabled-color: #1d1230; --bs-btn-disabled-bg: #c3adff; --bs-btn-disabled-border-color: #c3adff; }
.form-control, .form-select { background-color: var(--lex-bg); border-color: #555e75; }
.form-control:focus, .form-select:focus { background-color: var(--lex-bg); border-color: var(--lex-accent); box-shadow: 0 0 0 .2rem #c3adff35; }

.reader { margin-top: 2rem; }
.reader-hint, .empty-state, .form-text { color: var(--lex-muted); }
.empty-state { border: 1px dashed var(--lex-border); border-radius: .75rem; padding: 1.25rem; margin: 0; }
.stack { display: grid; gap: .8rem; }
#dictionary-recent-title { font-size: 1rem; }
.dictionary-titles { display: flex; flex-wrap: wrap; align-items: baseline; gap: .5rem 1rem; }
.dictionary-title { max-width: 100%; padding: .15rem 0; border: 0; background: transparent; color: var(--lex-accent); font: inherit; text-align: left; overflow-wrap: anywhere; }
.dictionary-title:hover { color: #dfd2ff; text-decoration: underline; }
.dictionary-clickable { cursor: pointer; }
.dictionary-word-tabs-bar { min-width: 0; }
.dictionary-word-tabs { position: relative; isolation: isolate; min-width: 0; flex-wrap: wrap; align-items: flex-end; overflow: visible; gap: .25rem 0; border-bottom: 1px solid var(--lex-border); padding: .3rem .15rem 0 .4rem; }
.dictionary-word-tabs .word-tab-item { --tab-surface: #171a22; --tab-edge: var(--lex-border); position: relative; z-index: 0; flex: 0 1 auto; min-width: 0; max-width: min(16rem, 100%); height: 1.85rem; margin-left: -.35rem; border-radius: .3rem 0 0 0; clip-path: polygon(0 0, calc(100% - 1.07rem) 0, 100% 100%, 0 100%); background: var(--tab-edge); transform: translateY(.15rem); }
.dictionary-word-tabs .word-tab-item::before { content: ''; position: absolute; z-index: -1; inset: 1px 1px 0; clip-path: inherit; background: var(--tab-surface); pointer-events: none; }
.dictionary-word-tabs .word-tab-item:first-child { margin-left: 0; }
.dictionary-word-tabs .word-tab-item:hover { --tab-edge: var(--lex-accent); }
.dictionary-word-tabs .word-tab-item.is-active { --tab-surface: var(--lex-panel); --tab-edge: var(--lex-accent); z-index: 2; transform: none; }
.dictionary-word-tabs .word-tab-item.is-active::before { top: 2px; }
.dictionary-word-tabs .word-tab-item [role="tab"] { display: block; width: 100%; height: 100%; padding: .15rem 1.25rem .15rem .4rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; border: 0; border-radius: 0; background: transparent; color: var(--lex-muted); text-align: left; }
.dictionary-word-tabs .word-tab-item [role="tab"][aria-selected="true"] { color: #f1e8ff; }
.word-tabs-menu { position: relative; }
.word-tabs-menu-toggle { width: 2rem; height: 2rem; list-style: none; cursor: pointer; }
.word-tabs-menu-toggle::-webkit-details-marker { display: none; }
.word-tabs-menu-toggle::marker { content: ''; }
.word-tabs-menu-items { position: absolute; top: calc(100% + .3rem); right: 0; z-index: 10; width: 12rem; padding: .3rem; border: 1px solid var(--lex-border); border-radius: .5rem; background: var(--lex-panel); box-shadow: 0 .5rem 1.5rem #0005; }
.word-tabs-menu-items button { display: block; width: 100%; padding: .5rem .65rem; border: 0; border-radius: .3rem; background: transparent; color: var(--lex-text); text-align: left; }
.word-tabs-menu-items button:hover:not(:disabled), .word-tabs-menu-items button:focus-visible { background: var(--lex-border); }
.word-tabs-menu-items button:disabled { opacity: .45; }
.text-title-row { min-width: 0; }
.text-titles { display: flex; flex-wrap: wrap; align-items: baseline; gap: .25rem 1rem; }
.text-titles .text-title-row { display: contents; }
.text-titles .text-title-row > .dictionary-title { max-width: 100%; }
.text-titles .text-inline-content { flex: 0 0 100%; min-width: 0; }
.text-inline-content { margin-top: 0; padding: .25rem 0; border-top: 1px solid var(--lex-border); border-bottom: 1px solid var(--lex-border); }
.text-inline-content .library-entry > details { margin-top: 0; }
.text-inline-content .library-entry > details > summary { display: none; }
.text-tools-menu { flex: 0 0 100%; min-width: 0; }
.text-options-toggle { min-width: 2.25rem; }
.text-header-controls { display: inline-flex; align-items: center; align-self: center; gap: .2rem; margin-left: auto; flex-shrink: 0; }
.text-header-controls > button { display: inline-flex; align-items: center; justify-content: center; width: 2rem; min-width: 2rem; height: 2rem; min-height: 2rem; padding: 0; border: 0; background: transparent; color: var(--lex-text); font-size: 1.15rem; line-height: 1; }
.text-header-controls > button:hover { background: var(--lex-border); color: var(--lex-text); }
.passage-body, .source-context { white-space: pre-wrap; overflow-wrap: anywhere; line-height: 1.65; }
.passage-body, .source-context, .reading-content, .dictionary-word-links { font-size: var(--reading-font-size, 1rem); }
.text-entry-summary { display: flex; align-items: center; justify-content: space-between; gap: 1rem; }
.text-entry-summary > span:first-child::before { content: "▸ "; }
details[open] > .text-entry-summary > span:first-child::before { content: "▾ "; }
.reading-size-controls { display: inline-flex; align-items: center; gap: .5rem; flex-shrink: 0; }
.reading-size-controls output { min-width: 3rem; text-align: center; color: var(--lex-muted); font-size: .85rem; }
.reader-passage { user-select: text; }
#settings-view .form-switch .form-check-input {
    width: 2.65rem;
    height: 1.5rem;
    margin-top: 0;
    border-radius: 1rem;
    border-color: #8c96aa;
    background-color: #4a5367;
    background-image: radial-gradient(circle at center, #fff 0 62%, transparent 65%);
    background-size: 1.1rem 1.1rem;
    background-repeat: no-repeat;
    background-position: left .12rem center;
    cursor: pointer;
    touch-action: pan-y;
    transition: background-position .15s ease-in-out, background-color .15s ease-in-out;
}
#settings-view .form-switch .form-check-input:checked {
    background-color: #0d6efd;
    border-color: #0d6efd;
    background-position: right .12rem center;
}
#settings-view .form-switch { display: flex; align-items: center; gap: .65rem; }
#settings-view .form-switch .form-check-input.switch-dragging { transition: none; cursor: grabbing; }
.reader-passage, [data-dictionary-text] { -webkit-touch-callout: none; }
.selection-tools button { -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
::highlight(vocabulary-speaking) { background-color: #594878; color: #f5eeff; }
.speech-voice-picker { width: min(100%, 24rem); }
.speech-player {
    position: fixed;
    z-index: 20;
    left: 50%;
    bottom: max(.5rem, env(safe-area-inset-bottom));
    transform: translateX(-50%);
    width: min(100% - 1rem, 70rem);
    max-height: 45dvh;
    overflow: auto;
    padding: .8rem 1rem;
    box-shadow: 0 -.3rem 1.5rem #0006;
}
.reader-passage::selection, .reader-passage *::selection { color: #1d1230; background: var(--lex-accent); }
.passage { min-width: 0; }
.reader-markdown { white-space: normal; overflow-x: auto; }
.text-markdown-block { display: contents; }
.reader-markdown > :last-child { margin-bottom: 0; }
.reader-markdown h1, .reader-markdown h2 { font-size: 1.4rem; }
.reader-markdown h3, .reader-markdown h4, .reader-markdown h5, .reader-markdown h6 { font-size: 1.12rem; }
.reader-markdown pre { padding: .75rem; border: 1px solid var(--lex-border); border-radius: .45rem; background: var(--lex-bg); }
.reader-markdown blockquote { padding-left: .75rem; border-left: 2px solid var(--lex-accent); color: var(--lex-muted); }
.reader-markdown table { margin-bottom: 1rem; }
.reader-markdown th, .reader-markdown td { padding: .35rem .6rem; border: 1px solid var(--lex-border); }
.reader-markdown img { max-width: 100%; height: auto; }
.selection-tools {
    position: fixed;
    z-index: 21;
    left: 50%;
    transform: translateX(-50%);
    bottom: calc(.5rem + var(--speech-player-space, 0px));
    width: min(100% - 2rem, 68rem);
    max-height: min(16rem, calc(100dvh - var(--speech-player-space, 0px) - 2rem));
    overflow: auto;
    padding: .8rem;
    border: 1px solid #8870bb;
    border-radius: .65rem;
    background: #302641;
}
.selection-preview { color: #e6d8ff; overflow-wrap: anywhere; margin-bottom: .5rem; }
.section-heading { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: .65rem; }
.section-heading h2 { margin: 0; }
.category-nav { display: grid; gap: .6rem; margin-top: 1rem; padding: .75rem; border: 1px solid var(--lex-border); border-radius: .65rem; background: var(--lex-panel); }
.category-nav-heading { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .65rem; }
.dictionary-nav { margin-top: 0; }
.dictionary-nav .category-trail > li:first-child { font-weight: 650; }
.category-trail, .category-children { display: flex; flex-wrap: wrap; align-items: center; gap: .45rem .65rem; margin: 0; padding: 0; list-style: none; overflow-wrap: anywhere; }
.category-trail li + li::before { content: "›"; margin-right: .65rem; color: var(--lex-muted); }
.category-trail [aria-current] { font-weight: 650; }
.category-children a { display: block; padding: .22rem .55rem; border: 1px solid var(--lex-border); border-radius: .45rem; text-decoration: none; }
.category-children a:hover { border-color: var(--lex-accent); }
.entry-category-tree { max-height: 15rem; overflow: auto; padding: .45rem; border: 1px solid var(--lex-border); border-radius: .5rem; }
.entry-category-tree ul { list-style: none; margin: 0; padding-left: 0; }
.entry-category-tree ul ul { margin-left: .7rem; padding-left: .7rem; border-left: 1px solid var(--lex-border); }
.entry-category-row { display: flex; align-items: center; gap: .35rem; min-height: 2rem; }
.entry-category-row label { display: flex; align-items: baseline; gap: .45rem; overflow-wrap: anywhere; cursor: pointer; }
.entry-category-row label:has(:checked) { color: var(--lex-accent); }
.entry-category-row input { accent-color: var(--lex-accent); }
.entry-category-toggle { flex: 0 0 1.6rem; color: var(--lex-text); }
.library-filters { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 15rem), 1fr)); gap: .75rem; margin: .35rem 0 1rem; }
.library-filters label { color: var(--lex-muted); min-width: 0; }
.library-search { position: relative; min-width: 0; }
.library-search-icon { position: absolute; left: .8rem; top: 50%; transform: translateY(-50%); width: 1.1rem; height: 1.1rem; color: var(--lex-muted); pointer-events: none; }
.library-search .form-control { padding-left: 2.5rem; }
.offline-summary { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .75rem; }
.app-update-banner { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .75rem; border-color: var(--lex-accent); }
.app-update-banner > div { min-width: 0; overflow-wrap: anywhere; }
.offline-badge { padding: .25rem .7rem; border: 1px solid var(--lex-border); border-radius: 2rem; color: var(--lex-accent); }
.offline-progress { display: block; width: 100%; height: 1rem; accent-color: var(--lex-accent); }
.offline-section-choice { display: inline-flex; align-items: center; gap: .35rem; }
.library-entry details { margin-top: .85rem; }
.dictionary-entry { padding: .65rem 1rem; }
.dictionary-entry > details { margin-top: 0; }
.dictionary-entry > details > summary { margin-bottom: 0; }
.dictionary-entry > details[open] > summary { margin-bottom: .65rem; }
.dictionary-entry summary h3 { display: inline; margin: 0; font-size: 1.05rem; }
.library-entry summary { color: var(--lex-accent); cursor: pointer; margin-bottom: .65rem; }
.library-entry li { overflow-wrap: anywhere; }
.source-context { border-left: 2px solid var(--lex-border); padding-left: .75rem; margin: 0; color: var(--lex-muted); }

dialog { max-width: min(38rem, 100% - 1.25rem); width: 100%; max-height: calc(100% - 1.25rem); overflow: auto; background: var(--lex-panel); border: 1px solid #555e75; border-radius: 1rem; padding: clamp(1rem, 4vw, 1.65rem); color: var(--lex-text); }
dialog::backdrop { background: #090a10c9; }
#dictionary-read-dialog { max-height: calc(100dvh - 1.25rem); overflow: hidden; }
#dictionary-read-dialog[open] { display: flex; flex-direction: column; }
#dictionary-read-dialog > :not(#dictionary-read-content) { flex-shrink: 0; }
#dictionary-read-content { min-height: 0; overflow-y: auto; overflow-x: hidden; overscroll-behavior: contain; scrollbar-gutter: stable; }
dialog h2 { font-size: 1.4rem; margin-bottom: 1rem; }
.entry-close {
    display: grid;
    place-items: center;
    flex: 0 0 2rem;
    min-height: 2rem;
    padding: 0;
    border: 0;
    border-radius: .4rem;
    background: transparent;
    color: var(--lex-text);
    font-size: 1.65rem;
    line-height: 1;
}
.entry-close:hover { background: var(--lex-border); }

html:not(.studio-pwa) [data-pwa-only] { display: none !important; }
.detailed-search-word { display: inline-flex; align-items: center; gap: .4rem; border: 1px solid var(--lex-border); border-radius: .6rem; padding: .2rem .4rem .2rem .65rem; overflow-wrap: anywhere; }
.detailed-search-word button { border: 0; padding: .05rem .35rem; font-size: 1.2rem; }

@media (max-width: 42rem) {
    .work-grid { grid-template-columns: 1fr; }
    .lex-shell { width: min(100% - 1.25rem, 70rem); }
    .lex-tabs { gap: .15rem; }
    .lex-tabs a { padding: .5rem .6rem; }
}

.text-tr-toggle { border: 0; padding: 0 .2rem; background: transparent; color: #2196f3; font-size: 1.1rem; line-height: 1.3; vertical-align: middle; cursor: pointer; }
.text-tr-toggle:hover { color: #64b5f6; }
.text-tr-toggle:focus-visible { outline: 2px solid #2196f3; outline-offset: 2px; border-radius: 50%; }
.text-tr > [data-tr-content][hidden] { display: none !important; }
.text-tr > [data-tr-content] > :first-child { margin-top: 0; }
.text-tr > [data-tr-content] > :last-child { margin-bottom: 0; }
.text-header-controls > .text-tr-all { width: auto; min-width: 0; padding: .15rem .3rem; font-size: .78rem; white-space: nowrap; }
.text-header-controls { flex-wrap: wrap; }

.text-src > [data-tr-content][hidden] { display: none !important; }
.text-src > [data-tr-content] > :first-child { margin-top: 0; }
.text-src > [data-tr-content] > :last-child { margin-bottom: 0; }
.text-src > .text-tr-toggle { display: inline-flex; align-items: center; vertical-align: middle; }

.text-tr > .text-tr-toggle { margin-right: .39ch; }

