:root {
  color-scheme: light dark;
  --text: light-dark(#202123, #f1f1f3);
  --surface: light-dark(#fff, #171719);
  --surface-result: light-dark(#fafafa, #1d1d20);
  --surface-hover: light-dark(#eeeeef, #303034);
  --placeholder: light-dark(#696a70, #a5a5af);
  --focus: light-dark(#525252, #bdbdbd);
  --success: light-dark(#26744b, #83d9a5);
  --danger-text: light-dark(#a02538, #ff9eac);
  --gpu-text: light-dark(#6e4600, #ffdf91);
  --gpu-surface: light-dark(#fff2c8, #4b3617);
  --action: light-dark(#202123, #fff);
  --action-text: light-dark(#fff, #202123);
  --action-hover: light-dark(#3b3c40, #d7d7dc);
  --action-disabled: light-dark(#68696d, #898990);
  --action-divider: light-dark(#ffffff38, #0003);
  --action-overlay: light-dark(#ffffff20, #0002);
  font-family: system-ui, "Yu Gothic UI", sans-serif;
  color: var(--text);
  background: var(--surface);
  --surface-muted: light-dark(#f7f7f8, #232326);
  --border: light-dark(#dedee1, #434348);
  --text-muted: light-dark(#595a60, #b4b4bc);
  --control-radius: 10px;
  font-size: 16px;
  line-height: 1.55;
}

:root[data-theme="light"] { color-scheme: light; }
:root[data-theme="dark"] { color-scheme: dark; }

* { box-sizing: border-box; }
body { margin: 0; }
a { color: inherit; text-underline-offset: .18em; }
button, select, textarea, input { font: inherit; color: inherit; }
button, select, input {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--control-radius);
  padding: .5rem .75rem;
  min-height: 42px;
}
button { cursor: pointer; }
button:disabled, select:disabled { opacity: .55; cursor: default; }
button:not(:disabled):hover { background: var(--surface-hover); }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 3px; }
textarea:focus, input[type="text"]:focus, input:not([type]):focus { outline: none; }
textarea {
  width: 100%;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 8px;
  padding: .5rem;
  resize: none;
}
textarea::placeholder, input::placeholder { color: var(--placeholder); }

.app-layout { display: grid; grid-template-columns: var(--sidebar-width, 14rem) minmax(0, 1fr); min-height: 100dvh; }
#mobile-sidebar-toggle, #mobile-new-translation, .mobile-title { display: none; }
.sidebar { position: sticky; top: 0; display: flex; flex-direction: column; height: 100dvh; background: var(--surface-muted); border-inline-end: 1px solid var(--border); padding: 1.25rem .75rem; }
#sidebar-resize { position: absolute; z-index: 2; inset-block: 0; inset-inline-end: -6px; width: 12px; cursor: col-resize; touch-action: none; }
#sidebar-resize:focus-visible { outline: none; }
#sidebar-resize:is(:hover, :focus-visible, [data-dragging])::after {
  content: "";
  position: absolute;
  inset-block: 0;
  inset-inline-start: calc(50% - 1px);
  border-inline-start: 2px solid var(--focus);
  opacity: .35;
}
#sidebar-resize:focus-visible::after { opacity: .65; }
@media (forced-colors: active) {
  #sidebar-resize:focus-visible::after { opacity: 1; }
}
.brand { display: inline-block; margin: 0 .65rem 1.25rem; text-decoration: none; font-size: 1.125rem; font-weight: 700; }
.sidebar-nav { display: grid; gap: .25rem; }
.sidebar-nav button { display: flex; align-items: center; gap: .65rem; text-align: start; background: transparent; border-color: transparent; }
#new-translation { margin-bottom: .35rem; }
.sidebar-nav svg { width: 1.15rem; height: 1.15rem; flex: none; fill: none; stroke: currentColor; stroke-width: 1.65; stroke-linecap: round; stroke-linejoin: round; }
main { --main-block-space: 2rem; display: flex; flex-direction: column; justify-content: center; width: min(100%, 72rem); min-height: 100dvh; margin-inline: auto; padding: var(--main-block-space) clamp(1rem, 3.5vw, 3rem) .75rem; }
.dialog-header, .actions {
  display: flex;
  align-items: center;
  gap: .6rem;
}
.pane-strip { position: relative; }
#pane-navigation button {
  position: absolute;
  z-index: 2;
  top: 50%;
  transform: translateY(-50%);
  display: grid;
  place-items: center;
  width: 46px;
  height: 46px;
  padding: 0;
  box-shadow: 0 2px 8px #20212312;
}
#pane-navigation svg { display: block; width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
#pane-previous { inset-inline-start: -16px; }
#pane-next { inset-inline-end: -16px; }
:root[dir="rtl"] #pane-navigation svg { transform: scaleX(-1); }
#pane-navigation button:disabled { visibility: hidden; }
.device-note, #status { font-size: .8rem; color: var(--text-muted); }
.translation-messages {
  display: grid;
  align-content: start;
  min-height: var(--main-block-space);
  overflow-wrap: anywhere;
}
.translation-messages > p { margin: .5rem 0 0; }
#status:empty, #feedback:empty { display: none; }
.workspace { border: 1px solid var(--border); border-radius: 22px; background: var(--surface); box-shadow: 0 4px 18px #2021230a; }
.panes {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: 50%;
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  scroll-behavior: smooth;
  scrollbar-width: none;
  border-radius: 21px;
}
.panes::-webkit-scrollbar { display: none; }
@media (prefers-reduced-motion: reduce) {
  .panes { scroll-behavior: auto; }
}
.pane { display: flex; flex-direction: column; gap: .7rem; padding: 1rem; min-height: min(22rem, var(--pane-limit, 60dvh)); max-height: var(--pane-limit, 60dvh); }
.pane { scroll-snap-align: start; }
.pane > label { font-size: .875rem; font-weight: 650; }
.pane > textarea { field-sizing: content; flex: 1 1 auto; min-height: 0; overflow-y: auto; }
.result { border-inline-start: 1px solid var(--border); background: var(--surface-result); }
:root[dir="rtl"] .pane textarea:placeholder-shown { text-align: right; }
.actions { justify-content: flex-end; }
.source-actions { justify-content: flex-start; flex-wrap: wrap; }
.actions span { color: var(--text-muted); font-size: .85rem; margin-inline-end: auto; }
.result .actions { flex-wrap: wrap; }
.primary { color: var(--action-text); background: var(--action); border-color: var(--action); padding-inline: 1.4rem; }
.primary:not(:disabled):hover { background: var(--action-hover); }
details { font-size: .9rem; }
summary { cursor: pointer; border-radius: var(--control-radius); }
.context-control summary, .translation-settings summary {
  display: flex;
  align-items: center;
  gap: .5rem;
  list-style: none;
}
.context-control summary { width: fit-content; color: var(--text-muted); }
.context-control summary { padding: .3rem 0; }
.context-add-icon::before { content: "＋"; }
.context-control[open] .context-add-icon::before { content: "−"; }
.context-add-icon { width: 1em; text-align: center; }
.context-control textarea { margin-top: .5rem; border-color: var(--border); }
.translation-settings { position: relative; }
.translation-settings summary { width: 2.5rem; height: 2.5rem; justify-content: center; }
.translation-settings summary:hover, .translation-settings[open] summary { background: var(--surface-muted); }
.translation-settings svg { width: 1.25rem; height: 1.25rem; fill: none; stroke: currentColor; stroke-width: 1.65; stroke-linecap: round; }
.model-picker { position: relative; flex: none; max-width: 100%; }
.composer-model { display: flex; align-items: center; gap: .4rem; min-height: 2.5rem; padding: .35rem .65rem; list-style: none; }
.composer-model:hover, .model-picker[open] .composer-model { background: var(--surface-muted); }
.composer-model svg { width: 1rem; height: 1rem; fill: none; stroke: currentColor; stroke-width: 1.65; stroke-linecap: round; stroke-linejoin: round; }
.composer-model .model-switch-spinner { display: none; width: 1rem; height: 1rem; margin: 0; border: 2px solid transparent; border-top-color: currentColor; border-right-color: currentColor; border-radius: 50%; animation: button-spin .75s linear infinite; }
.composer-model[aria-busy="true"] > svg { display: none; }
.composer-model[aria-busy="true"] .model-switch-spinner { display: block; }
.model-panel { position: absolute; bottom: calc(100% + .4rem); inset-inline-start: 0; z-index: 1; width: min(19rem, calc(100vw - 6rem)); padding: .75rem; border: 1px solid var(--border); border-radius: 16px; background: var(--surface); box-shadow: 0 6px 20px #20212320; }
.model-panel-header { display: grid; grid-template-columns: 2.25rem minmax(0, 1fr) 2.25rem; align-items: center; gap: .35rem; text-align: center; }
#open-model-manager { display: flex; align-items: center; justify-content: center; gap: .45rem; min-height: 36px; padding: 0 .25rem; border: 0; background: transparent; }
#open-model-manager svg { width: .85rem; height: .85rem; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.gpu-toggle { display: grid; place-items: center; min-height: 36px; padding: 0; border-color: transparent; color: var(--text-muted); }
.gpu-badge, .actions .gpu-badge { display: inline-block; margin: 0; padding: .1rem .3rem; border: 1px solid currentColor; border-radius: .3rem; color: inherit; font-size: .7rem; font-weight: 750; line-height: 1.15; }
.gpu-toggle[aria-pressed="true"] .gpu-badge, .actions #model-gpu-indicator { color: var(--gpu-text); background: var(--gpu-surface); }
#model-gpu-indicator[hidden] { display: none; }
.model-scale { --model-thumb-size: 1.6rem; direction: ltr; margin: .65rem .15rem 0; }
#model { appearance: none; display: block; width: 100%; min-height: 1.75rem; margin: 0; padding: 0; border: 0; border-radius: 999px; background: linear-gradient(to right, #3676df var(--model-progress, 0%), var(--surface-muted) var(--model-progress, 0%)); cursor: pointer; }
#model::-webkit-slider-thumb { appearance: none; box-sizing: border-box; width: var(--model-thumb-size); height: var(--model-thumb-size); border-radius: 50%; border: 1px solid var(--border); background: #fff; box-shadow: 0 1px 4px #20212330; }
#model::-moz-range-thumb { box-sizing: border-box; width: var(--model-thumb-size); height: var(--model-thumb-size); border-radius: 50%; border: 1px solid var(--border); background: #fff; box-shadow: 0 1px 4px #20212330; }
#model:disabled { cursor: default; }
.model-ticks { position: relative; min-height: 1.2rem; margin: .25rem calc(var(--model-thumb-size) / 2) 0; color: var(--text-muted); font-size: .75rem; }
.actions .model-ticks span { position: absolute; left: var(--tick-position); transform: translateX(-50%); margin: 0; font-size: inherit; white-space: nowrap; }
#stage-model { width: 100%; margin-top: .45rem; font-size: .8rem; }
.model-panel .device-note { margin: .5rem 0 0; text-align: center; }
.actions #model-label { color: inherit; margin: 0; font-size: inherit; overflow-wrap: anywhere; }
.settings-panel { position: fixed; z-index: 3; overflow-y: auto; padding: .75rem; border: 1px solid var(--border); border-radius: 12px; background: var(--surface); box-shadow: 0 6px 20px #20212320; }
.settings-panel select { min-width: 0; width: 100%; }
.glossary-picker { min-width: 0; margin: 0; padding: 0; border: 0; }
#glossary-choices { max-height: 10rem; overflow: auto; color: var(--text-muted); }
#new-glossary { margin-top: .4rem; }
.source-actions .translate-control { margin-inline-start: auto; }
.retranslate-control { max-width: 100%; border-radius: 999px; overflow-wrap: anywhere; }
.loading-button { position: relative; }
#tooltip {
  position: fixed;
  inset: auto;
  max-width: min(24rem, calc(100% - 1rem));
  margin: 0;
  border: 0;
  padding: .25rem .5rem;
  border-radius: 6px;
  background: #202123;
  color: white;
  box-shadow: 0 2px 8px #0003;
  font: 600 .75rem/1.4 system-ui, sans-serif;
  overflow: visible;
  overflow-wrap: anywhere;
}
#tooltip::after {
  content: "";
  position: absolute;
  inset: 100% 0 auto;
  height: 6px;
}
#tooltip[data-below]::after { inset: auto 0 100%; }
.loading-button .loading-label { color: inherit; font-size: inherit; margin: 0; }
.loading-button[aria-busy="true"] .loading-label { opacity: 0; }
.loading-button .loading-spinner { display: none; }
.loading-button[aria-busy="true"] .loading-spinner {
  display: block;
  position: absolute;
  inset: 0;
  width: 1rem;
  height: 1rem;
  margin: auto;
  border: 2px solid transparent;
  border-top-color: currentColor;
  border-right-color: currentColor;
  color: inherit;
  border-radius: 50%;
  animation: button-spin .75s linear infinite;
}
@keyframes button-spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) {
  .composer-model .model-switch-spinner { animation: none; }
  .loading-button[aria-busy="true"] .loading-spinner { animation: none; }
}
.retranslate-control { display: flex; border: 1px solid transparent; background: var(--action); color: var(--action-text); }
.retranslate-control[hidden] { display: none; }
.retranslate-control:has(button:first-child:disabled):not(:has(#stop-translation:not([hidden]))) { background: var(--action-disabled); }
.retranslate-control button { border: 0; border-radius: 999px 0 0 999px; padding-inline: 1rem; background: transparent; }
.translate-control { position: relative; }
.translate-main { display: grid; }
.translate-main:has(#stop-translation:not([hidden])) #translate { visibility: hidden; }
.translate-control:has(#stop-translation:not([hidden])) #translate-language { visibility: hidden; }
#stop-translation:not([hidden]) {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: .4rem;
  padding: 0;
  border-radius: 999px;
  color: inherit;
}
#stop-translation .stop-spinner {
  flex: none;
  width: 1rem;
  height: 1rem;
  margin: 0;
  border: 2px solid currentColor;
  border-top-color: transparent;
  border-radius: 50%;
  color: inherit;
  animation: button-spin .75s linear infinite;
}
@media (prefers-reduced-motion: reduce) {
  #stop-translation .stop-spinner { animation: none; }
}
.retranslate-control button:disabled { opacity: 1; }
.retranslate-control .retranslate-picker {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: .2rem;
  min-width: 2.9rem;
  padding-inline: .45rem;
  border-left: 1px solid var(--action-divider);
  border-radius: 0 999px 999px 0;
  color: inherit;
}
.retranslate-control button:not(:disabled):hover { background: var(--action-overlay); }
.retranslate-picker svg { fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.language-icon { width: 1.05rem; height: 1.05rem; }
.language-chevron { width: .7rem; height: .7rem; }
#retranslate-menu { position: fixed; inset: auto; margin: 0; padding: .4rem; border: 1px solid var(--border); border-radius: 12px; background: var(--surface); color: inherit; box-shadow: 0 6px 20px #20212320; overflow: hidden; }
#retranslate-menu:popover-open { display: flex; flex-direction: column; }
#retranslate-menu-title { margin: .25rem .5rem .35rem; color: var(--text-muted); font-size: .8rem; font-weight: 650; }
#retranslate-options { overflow-y: auto; }
#retranslate-options button { display: block; width: 100%; min-height: 34px; padding: .3rem .5rem; border: 0; text-align: start; font-size: .875rem; }
.copy-result { display: grid; place-items: center; width: 42px; padding: 0; border: 0; background: transparent; }
.copy-result[hidden] { visibility: hidden; }
.copy-result:not(:disabled):hover { background: var(--surface-muted); }
.copy-result svg { width: 1.2rem; height: 1.2rem; fill: none; stroke: currentColor; stroke-width: 1.65; }
.copy-result:not(.copied) .copy-check, .copy-result.copied svg:not(.copy-check) { display: none; }
.options { display: grid; gap: .4rem; margin-top: .65rem; }
.options textarea { border-color: var(--border); }
#glossary-dialog { width: min(64rem, calc(100% - 2rem)); padding: 0; }
.glossary-header { align-items: start; padding: 1.25rem; border-bottom: 1px solid var(--border); }
.glossary-header p { margin: .3rem 0 0; color: var(--text-muted); font-size: .875rem; }
#glossary-workspace { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 3fr); }
#glossary-workspace :is(h3, h4) { margin: 0; font-size: 1rem; }
.glossary-library, .glossary-editor { min-width: 0; padding: 1.25rem; overflow-wrap: anywhere; }
.glossary-editor { border-inline-start: 1px solid var(--border); }
.glossary-heading { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .5rem; }
.glossary-meta, .glossary-choice small { color: var(--text-muted); font-size: .85rem; }
.glossary-meta:empty { display: none; }
.glossary-choice { display: flex; align-items: center; gap: .5rem; border-bottom: 1px solid var(--border); }
.glossary-choice label { display: flex; flex: 1; min-width: 0; align-items: center; gap: .5rem; padding: .55rem .25rem; cursor: pointer; overflow-wrap: anywhere; }
.glossary-choice label:hover { background: var(--surface-muted); }
.glossary-choice small { display: block; }
.glossary-choice button { flex-shrink: 0; }
.glossary-choice button[aria-current] { border-color: var(--focus); background: var(--surface-muted); }
.glossary-file-actions { display: flex; flex-wrap: wrap; gap: .35rem; margin-top: 1rem; }
#glossary-form { margin-top: 1rem; }
#glossary-form > label { display: block; margin-bottom: .25rem; font-size: .875rem; font-weight: 650; }
#glossary-name { width: 100%; }
.glossary-term-heading { margin-top: 1rem; }
#glossary { display: grid; gap: .65rem; margin-block: .6rem .75rem; }
.glossary-row { min-width: 0; margin: 0; padding: .75rem; border: 1px solid var(--border); border-radius: 12px; }
.glossary-row:focus-within { border-color: var(--focus); }
.glossary-row legend { padding-inline: .25rem; color: var(--text-muted); font-size: .8rem; }
.glossary-term-pair { display: grid; grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr); gap: .5rem; align-items: end; }
.term-direction { color: var(--text-muted); line-height: 44px; }
:root[dir="rtl"] .term-direction { transform: scaleX(-1); }
.glossary-term-pair label { display: grid; gap: .2rem; font-size: .875rem; color: var(--text-muted); }
.glossary-row input[type="text"] { min-width: 0; width: 100%; min-height: 44px; }
.term-actions, .glossary-editor-footer, .glossary-save-actions { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem; }
.term-actions { margin-top: .55rem; font-size: .875rem; }
.term-actions label { display: flex; align-items: center; gap: .25rem; cursor: pointer; }
.glossary-choice input, .term-actions input { min-height: 0; margin: 0; }
.term-actions button { margin-inline-start: auto; color: var(--danger-text); }
.glossary-editor-footer { margin-top: 1rem; padding-top: .8rem; border-top: 1px solid var(--border); }
.glossary-save-actions { margin-inline-start: auto; justify-content: end; }
#save-glossary { min-width: 6rem; }
#delete-glossary:not(:disabled) { color: var(--danger-text); }
#feedback { color: var(--text-muted); }
.error { color: var(--danger-text) !important; }
dialog {
  background: var(--surface);
  width: min(36rem, calc(100% - 2rem));
  max-height: calc(100% - 2rem);
  padding: 1.25rem;
  border: 1px solid var(--border);
  border-radius: 18px;
  color: inherit;
}
dialog:focus-visible { outline: none; }
dialog::backdrop { background: #0006; }
#native-language-dialog { width: min(28rem, calc(100% - 2rem)); }
#native-language-title { margin: 0 0 1rem; font-size: 1.25rem; }
#native-language-title:focus, #manager-title:focus { outline: none; }
#manager-title { font-size: 1.25rem; }
.model-catalog { margin-top: 1rem; }
.model-catalog h3, .browser-model-storage > h3 { margin: 0; font-size: .95rem; font-weight: 600; }
.model-catalog p, .browser-model-storage > p { margin: .25rem 0 .65rem; color: var(--text-muted); font-size: .875rem; }
.model-license { color: var(--text-muted); font-size: .8rem; }
.model-license { margin: .85rem 0 0; }
#download-feedback { margin: .4rem 0; font-size: .875rem; }
#download-feedback:empty { display: none; }
.language-setting-note { padding: .8rem 1rem; border-radius: 12px; background: var(--surface-muted); font-size: .875rem; }
.language-setting-note p { margin: .25rem 0 0; color: var(--text-muted); }
#native-language-form { margin-top: 1rem; }
#native-language-form label { font-weight: 600; }
#native-language-form select + label { margin-top: .5rem; }
#native-language-form .actions { justify-content: flex-end; margin-top: .65rem; padding-top: .85rem; border-top: 1px solid var(--border); }
#native-language-feedback { margin: .25rem 0 0; font-size: .875rem; }
#native-language-feedback:empty { display: none; }
#confirm-action { width: min(26rem, calc(100% - 2rem)); }
#confirm-title { margin: 0; font-size: 1.125rem; }
#confirm-title:focus { outline: none; }
#confirm-description { color: var(--text-muted); overflow-wrap: anywhere; white-space: pre-line; }
button.danger { color: white; background: #a02538; border-color: #a02538; }
button.danger:not(:disabled):hover { background: #821d2d; }
.dialog-header { justify-content: space-between; }
.dialog-header h2 { margin: 0; }
.close-button { display: grid; place-items: center; min-width: 42px; padding: 0; }
.close-button span { font-size: 1.4rem; line-height: 1; }
#close-history-edit { justify-self: end; }
.sidebar-history { display: flex; flex-direction: column; min-height: 0; margin-top: 1.4rem; }
.sidebar-footer { display: flex; justify-content: space-between; align-items: center; gap: .5rem; flex-shrink: 0; margin-top: auto; padding: .75rem .65rem 0; color: var(--text-muted); font-size: .75rem; }
#theme-toggle { min-width: 44px; min-height: 44px; padding: 0; background: transparent; font-size: 1.25rem; }
#theme-toggle:hover { background: var(--surface-hover); }
.history-heading { position: relative; display: flex; align-items: center; gap: .25rem; margin-block-end: .4rem; margin-inline: .65rem .25rem; }
.sidebar-history h2 { margin: 0; margin-inline-end: auto; font-size: .8rem; color: var(--text-muted); }
.browser-model-storage { display: grid; grid-template-columns: minmax(0, 1fr); gap: .4rem; overflow-wrap: anywhere; }
#choose-model-file { justify-self: start; font-size: .875rem; }
.history-heading > button:not([hidden]) { display: grid; place-items: center; width: 30px; min-height: 30px; padding: 0; border: 0; background: transparent; color: var(--text-muted); }
#history-edit-menu:not([hidden]) { position: absolute; top: calc(100% + .25rem); inset-inline-end: 0; z-index: 3; display: grid; min-width: max-content; padding: .25rem; border: 1px solid var(--border); border-radius: 10px; background: var(--surface); box-shadow: 0 4px 14px #20212320; }
#history-edit-menu button { border: 0; min-height: 34px; text-align: start; font-size: .85rem; }
#delete-all-history { color: var(--danger-text); }
.history-heading button:not(:disabled):hover, #edit-history[aria-pressed="true"] { background: var(--surface-hover); }
.history-heading svg { width: 17px; height: 17px; fill: none; stroke: currentColor; stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round; }
#history-feedback { margin: 0 .65rem .4rem; color: var(--text-muted); font-size: .8rem; }
#history-feedback:empty { display: none; }
#history-list { list-style: none; margin: 0; padding: .2rem; overflow-y: auto; }
.history-entry { display: grid; grid-template-columns: minmax(0, 1fr); align-items: center; border-radius: 9px; }
#history-list[data-editing] .history-entry { grid-template-columns: auto minmax(0, 1fr); }
.history-select { display: none; min-height: 0; margin: 0 0 0 .6rem; cursor: pointer; }
#history-list[data-editing] .history-select { display: block; }
.history-entry:hover, .history-entry:focus-within { background: var(--surface-hover); }
.history-entry button { border: 0; background: transparent; min-height: 36px; font-size: .85rem; }
.history-restore { min-width: 0; text-align: start; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.model-row { display: flex; justify-content: space-between; gap: .6rem; align-items: center; padding: .75rem 0; border-top: 1px solid var(--border); }
.model-row-unavailable .model-row-details { color: var(--text-muted); }
.model-row small { display: block; color: var(--text-muted); }
.model-row small[hidden] { display: none; }
.model-download, .model-installed { width: 42px; text-align: center; }
.model-row-actions { display: flex; align-items: center; gap: .25rem; }
.model-recommendation { margin-inline-end: .5rem; padding: .15rem .4rem; border-radius: 5px; background: var(--surface-muted); font-size: .75rem; font-weight: 650; white-space: nowrap; }
.model-download, .model-delete { width: 42px; padding: 0; }
.model-delete { border-color: transparent; color: var(--text-muted); }
.model-delete:not(:disabled):hover { color: var(--danger-text); }
.model-download svg, .model-delete svg { display: block; width: 1.2rem; height: 1.2rem; margin: auto; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.model-installed:not([hidden]) { display: grid; place-items: center; min-height: 42px; color: var(--success); font-weight: 700; }
.model-row-details { display: grid; grid-template-columns: minmax(0, 10.5rem) auto; align-items: baseline; column-gap: .65rem; min-width: 0; }
.model-row-details span { white-space: nowrap; color: var(--text-muted); font-size: .85rem; }
.model-row-details small, .model-row-details progress { grid-column: 1 / -1; }
.model-row progress { display: block; width: min(100%, 10rem); }
.model-row progress[hidden] { display: none; }
.model-row button { flex-shrink: 0; }

@media (max-width: 640px) {
  main { --main-block-space: 4rem; }
  .pane { min-height: 0; }
  .pane > textarea { min-height: calc(3lh + 1rem + 2px); }
  .app-layout { grid-template-columns: minmax(0, 1fr); align-content: start; }
  .sidebar { position: static; height: auto; padding: .75rem 1.5rem 1rem; border-inline-end: 0; border-bottom: 1px solid var(--border); }
  #sidebar-resize { display: none; }
  .brand { margin: 0 .5rem .5rem; font-size: 1.375rem; }
  .sidebar-nav button { min-height: 44px; padding: .25rem .5rem; gap: .85rem; font-size: 1.0625rem; }
  .sidebar-nav svg { width: 1.375rem; height: 1.375rem; }
  .sidebar-history { margin: 1rem .5rem 0; padding-top: .75rem; border-top: 1px solid var(--border); }
  .history-heading { margin-inline: 0; }
  .sidebar-history h2, #history-feedback, #history-edit-menu button { font-size: .9375rem; }
  #history-feedback { margin-inline: 0; }
  #history-list { padding-inline: 0; }
  .history-entry button { min-height: 48px; padding-inline: 0; font-size: 1.0625rem; }
  .sidebar-footer { padding-inline: .5rem; }
  #mobile-sidebar-toggle, #mobile-new-translation { position: absolute; top: .75rem; left: 1rem; z-index: 12; display: grid; place-items: center; width: 42px; padding: 0; border: 0; background: transparent; }
  #mobile-new-translation { right: 1rem; left: auto; }
  #mobile-sidebar-toggle[aria-expanded="false"] {
    grid-template-columns: 42px minmax(0, auto);
    gap: .5rem;
    width: max-content;
    max-width: calc(100% - 2.5rem - 42px);
    direction: ltr;
  }
  .mobile-title {
    align-content: center;
    min-height: 42px;
    display: block;
    font-weight: 700;
    line-height: 1.2;
    overflow-wrap: anywhere;
  }
  #mobile-sidebar-toggle svg, #mobile-new-translation svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
  #mobile-sidebar-toggle[aria-expanded="true"] .mobile-title,
  #mobile-sidebar-toggle[aria-expanded="true"] ~ #mobile-new-translation { display: none; }
  .app-layout:has(#mobile-sidebar-toggle[aria-expanded="true"])::before {
    content: "";
    position: fixed;
    inset: 0;
    z-index: 10;
    background: #0006;
  }
  #mobile-sidebar-toggle[aria-expanded="true"] ~ .sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 11;
    width: min(19.5rem, calc(100% - 3rem));
    height: 100dvh;
    padding-top: 4rem;
  }
  #mobile-sidebar-toggle[aria-expanded="false"] ~ .sidebar { display: none; }
  .model-row-details { grid-template-columns: minmax(0, 1fr); }
}

@media (width < 740px) {
  #glossary-workspace { grid-template-columns: minmax(0, 1fr); }
  .glossary-editor { border-inline-start: 0; border-top: 1px solid var(--border); }
}

@media (width < 1000px) {
  .panes { grid-auto-columns: 100%; }
  .result { border-inline-start: 0; }
}

@media (width <= 480px) {
  #glossary-dialog { width: calc(100% - 1rem); max-height: calc(100% - 1rem); }
  .glossary-header, .glossary-library, .glossary-editor { padding-inline: .85rem; }
  .glossary-row { padding: .55rem; }
  .glossary-term-pair { grid-template-columns: auto minmax(0, 1fr); }
  .glossary-term-pair label { grid-column: 2; }
  :root .term-direction { grid-area: 1 / 1 / 3; align-self: center; transform: rotate(90deg); }
}
