:root {
  color-scheme: light;
  --bg: #f4f1e8;
  --bg-lift: #fbf9f2;
  --ink: #17151c;
  --muted: #6d6876;
  --subtle: #8a8792;
  --fig: #65507e;
  --fig-deep: #45355d;
  --fig-soft: rgba(101, 80, 126, 0.11);
  --chartreuse: #b8cd58;
  --chartreuse-soft: rgba(184, 205, 88, 0.24);
  --bluegray: #536879;
  --paper: rgba(255, 255, 255, 0.74);
  --paper-strong: #fffefa;
  --line: rgba(69, 53, 93, 0.16);
  --line-strong: rgba(69, 53, 93, 0.28);
  --shadow: 0 18px 42px rgba(38, 31, 45, 0.11);
  --shadow-soft: 0 7px 18px rgba(38, 31, 45, 0.055);
  --radius: 16px;
  --radius-small: 12px;
  --radius-pill: 999px;
}

:root.dark-mode,
body.dark-mode {
  color-scheme: dark;
  --bg: #15131a;
  --bg-lift: #1d1a24;
  --ink: #f4f0f7;
  --muted: #bbb3c4;
  --subtle: #9f96aa;
  --fig: #b7a0dc;
  --fig-deep: #d4c4ef;
  --fig-soft: rgba(183, 160, 220, 0.15);
  --chartreuse: #c8dc73;
  --chartreuse-soft: rgba(200, 220, 115, 0.18);
  --bluegray: #b1c0cb;
  --paper: rgba(31, 28, 38, 0.82);
  --paper-strong: #27222f;
  --line: rgba(212, 196, 239, 0.18);
  --line-strong: rgba(212, 196, 239, 0.34);
  --shadow-soft: 0 10px 24px rgba(0, 0, 0, 0.22);
}

* {
  box-sizing: border-box;
}

html {
  height: 100%;
  background: var(--bg);
}

body {
  height: 100%;
  margin: 0;
  overflow: hidden;
  color: var(--ink);
  background:
    linear-gradient(135deg, rgba(184, 205, 88, 0.12), transparent 28%),
    linear-gradient(220deg, rgba(101, 80, 126, 0.12), transparent 34%),
    var(--bg);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

body.dark-mode {
  background:
    linear-gradient(135deg, rgba(200, 220, 115, 0.08), transparent 30%),
    linear-gradient(220deg, rgba(183, 160, 220, 0.12), transparent 36%),
    var(--bg);
}

button,
input,
select {
  font: inherit;
}

button,
select {
  cursor: pointer;
}

.app-shell {
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr) auto;
  gap: 18px;
  width: min(1440px, calc(100vw - 112px));
  height: 100svh;
  margin: 0 auto;
  padding: 34px 0 26px;
  overflow: visible;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 13px;
  min-width: 0;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  border: 1px solid rgba(184, 205, 88, 0.6);
  border-radius: 18px;
  background: linear-gradient(145deg, var(--fig), var(--fig-deep));
  color: #fffbea;
  box-shadow: var(--shadow-soft);
  font-size: 26px;
  font-weight: 850;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  color: var(--ink);
  font-size: clamp(28px, 4vw, 42px);
  line-height: 0.98;
  letter-spacing: 0;
}

.brand p,
.panel-heading p,
.entry-detail p {
  color: var(--muted);
  font-size: 14px;
  line-height: 1.45;
}

.stat-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}

.stat-strip span {
  padding: 7px 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.45);
  color: var(--bluegray);
  font-size: 12px;
  font-weight: 760;
}

.stat-strip strong {
  color: var(--fig-deep);
}

.search-panel,
.results-panel,
.detail-panel {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--paper);
  box-shadow: 0 1px 0 rgba(38, 31, 45, 0.04), 0 10px 24px rgba(38, 31, 45, 0.045);
  backdrop-filter: blur(18px);
}

.search-panel {
  position: relative;
  z-index: 70;
  display: grid;
  grid-template-columns: minmax(260px, 1fr) auto;
  gap: 10px;
  padding: 10px;
}

.search-panel:has(.filter-menu:not([hidden])) {
  z-index: 200;
}

.search-box {
  display: grid;
  gap: 5px;
}

label span,
.filter-field > span {
  color: var(--bluegray);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

input,
select,
button {
  height: 40px;
  border: 1px solid var(--line);
  border-radius: var(--radius-pill);
  background: rgba(255, 255, 255, 0.8);
  color: var(--ink);
}

input {
  width: 100%;
  padding: 0 14px;
  border-color: rgba(101, 80, 126, 0.22);
  background: var(--paper-strong);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.42);
  font-size: 16px;
}

.dark-mode input {
  background: rgba(39, 34, 47, 0.92);
  color: var(--ink);
  border-color: var(--line-strong);
}

input::placeholder {
  color: #9b98a1;
}

select {
  width: 100%;
  min-width: 118px;
  padding: 0 30px 0 10px;
  appearance: none;
  border-color: rgba(69, 53, 93, 0.18);
  background-color: rgba(255, 254, 250, 0.88);
  background-image:
    linear-gradient(45deg, transparent 50%, var(--fig) 50%),
    linear-gradient(135deg, var(--fig) 50%, transparent 50%);
  background-position:
    calc(100% - 16px) 17px,
    calc(100% - 11px) 17px;
  background-size: 5px 5px;
  background-repeat: no-repeat;
  font-size: 13px;
  font-weight: 680;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.48), 0 5px 14px rgba(38, 31, 45, 0.04);
}

.dark-mode select {
  background-color: rgba(39, 34, 47, 0.92);
  color: var(--ink);
}

select option {
  background: #fffefa;
  color: var(--ink);
  font-weight: 650;
}

button {
  padding: 0 13px;
  color: var(--fig);
  font-size: 13px;
  font-weight: 780;
  transition: border-color 0.16s ease, background-color 0.16s ease, color 0.16s ease, transform 0.16s ease;
}

button:hover,
select:hover,
input:hover {
  border-color: var(--line-strong);
}

button:focus-visible,
select:focus-visible,
input:focus-visible {
  outline: 2px solid rgba(184, 205, 88, 0.58);
  outline-offset: 2px;
}

.mode-control {
  align-self: end;
  display: grid;
  grid-template-columns: repeat(4, auto);
  gap: 4px;
  padding: 5px;
  border: 1px solid var(--line);
  border-radius: 22px;
  background: rgba(255, 255, 255, 0.48);
}

.dark-mode .mode-control {
  background: rgba(39, 34, 47, 0.72);
}

.mode-button {
  min-width: 72px;
  height: 34px;
  border: 0;
  border-radius: 17px;
  background: transparent;
}

.mode-button.is-active {
  background: var(--fig);
  color: #fffdf5;
  box-shadow: 0 7px 18px rgba(69, 53, 93, 0.18);
}

.filters {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: repeat(4, minmax(120px, 1fr));
  gap: 9px;
}

.filters label,
.filter-field {
  display: grid;
  gap: 5px;
}

.filter-field {
  position: relative;
  z-index: 20;
}

.filter-field:has(.filter-menu:not([hidden])) {
  z-index: 80;
}

.filter-button {
  position: relative;
  width: 100%;
  padding: 0 34px 0 12px;
  overflow: hidden;
  background: rgba(255, 254, 250, 0.88);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.48), 0 5px 14px rgba(38, 31, 45, 0.04);
  text-align: left;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.filter-button::after {
  content: "";
  position: absolute;
  top: 50%;
  right: 15px;
  width: 0;
  height: 0;
  border-left: 5px solid transparent;
  border-right: 5px solid transparent;
  border-top: 6px solid var(--fig);
  transform: translateY(-35%);
}

.dark-mode .filter-button {
  background: rgba(39, 34, 47, 0.92);
}

.filter-menu {
  position: absolute;
  top: calc(100% + 7px);
  left: 0;
  z-index: 100;
  display: grid;
  gap: 3px;
  width: min(260px, 92vw);
  max-height: 280px;
  overflow-y: auto;
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 254, 250, 0.98);
  box-shadow: 0 18px 42px rgba(38, 31, 45, 0.14);
  backdrop-filter: blur(36px) saturate(1.2);
}

.filter-menu.lesson-grid {
  width: min(350px, 92vw);
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.filter-menu.pos-menu {
  right: 0;
  left: auto;
  width: min(360px, calc(100vw - 32px));
}

.filter-menu[hidden] {
  display: none;
}

.dark-mode .filter-menu {
  background: rgba(31, 28, 38, 0.97);
  box-shadow: 0 20px 48px rgba(0, 0, 0, 0.34);
}

.filter-menu .filter-option {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
  min-height: 26px;
  padding: 4px 7px;
  border-radius: 10px;
  color: var(--ink);
  font-size: 12px;
  font-weight: 760;
  line-height: 1.12;
}

.filter-menu .filter-option:hover {
  background: var(--fig-soft);
}

.filter-menu .filter-option input {
  flex: 0 0 auto;
  width: 15px;
  min-width: 15px;
  height: 15px;
  margin: 0;
  padding: 0;
  border-radius: 4px;
  background: transparent;
  box-shadow: none;
  font-size: initial;
  line-height: normal;
  accent-color: var(--fig);
}

.filter-menu .filter-option span {
  color: inherit;
  font-size: inherit;
  font-weight: inherit;
  letter-spacing: 0;
  text-transform: none;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.filter-option-all {
  font-weight: 830;
}

.lesson-grid .filter-option-all {
  grid-column: 1 / -1;
}

.lesson-grid .filter-option:not(.filter-option-all) {
  justify-content: flex-start;
  min-height: 28px;
  padding: 5px 6px;
}

.filter-group {
  display: grid;
  gap: 4px;
  padding: 5px 2px 3px;
  border-top: 1px solid var(--line);
}

.filter-group-title {
  padding: 0 5px;
  color: var(--bluegray);
  font-size: 10px;
  font-weight: 850;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.filter-group-options {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 3px;
}

.pos-menu .filter-option {
  padding-inline: 5px;
}

.workspace {
  --results-fr: 0.5fr;
  --detail-fr: 0.5fr;
  display: grid;
  grid-template-columns: minmax(0, var(--results-fr)) 6px minmax(0, var(--detail-fr));
  gap: 4px;
  min-height: 0;
  overflow: visible;
  padding-bottom: 2px;
}

.panel-resizer {
  align-self: stretch;
  border-radius: var(--radius-pill);
  cursor: col-resize;
  position: relative;
}

.panel-resizer::before {
  content: "";
  position: absolute;
  inset: 28px 1px;
  border-radius: var(--radius-pill);
  background: rgba(83, 104, 121, 0.14);
  transition: background 0.16s ease;
}

.panel-resizer:hover::before,
.panel-resizer:focus-visible::before,
.workspace.is-resizing .panel-resizer::before {
  background: var(--chartreuse);
}

.results-panel,
.detail-panel {
  min-height: 0;
  min-width: 0;
  overflow: hidden;
}

.results-panel {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  container-type: inline-size;
}

.detail-panel {
  display: grid;
}

.panel-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
}

.panel-heading h2,
.entry-detail h2 {
  color: var(--ink);
  font-size: 18px;
  line-height: 1.2;
}

.quiet-button {
  width: auto;
  background: rgba(101, 80, 126, 0.08);
}

.dark-mode .quiet-button {
  background: rgba(183, 160, 220, 0.1);
}

.results-list {
  height: 100%;
  min-height: 0;
  overflow: auto;
  padding: 8px;
}

.result-row {
  position: relative;
  display: grid;
  grid-template-columns: minmax(140px, 1fr) minmax(130px, 0.86fr) max-content;
  align-items: center;
  gap: 14px;
  width: 100%;
  height: auto;
  min-height: 74px;
  margin: 0 0 8px;
  padding: 12px 13px;
  border: 1px solid rgba(69, 53, 93, 0.13);
  border-radius: var(--radius);
  background: rgba(255, 254, 250, 0.9);
  box-shadow: 0 6px 18px rgba(38, 31, 45, 0.045);
  color: inherit;
  text-align: left;
  overflow: hidden;
}

.dark-mode .result-row {
  background: rgba(39, 34, 47, 0.9);
}

.result-row:hover,
.result-row.is-selected {
  border-color: rgba(101, 80, 126, 0.26);
  background: rgba(255, 254, 250, 0.98);
  box-shadow: 0 7px 20px rgba(38, 31, 45, 0.06);
  transform: none;
}

.dark-mode .result-row:hover,
.dark-mode .result-row.is-selected {
  background: rgba(48, 42, 58, 0.98);
}

.result-row.is-selected {
  background: rgba(101, 80, 126, 0.055);
  box-shadow: inset 0 0 0 2px rgba(101, 80, 126, 0.22), 0 7px 20px rgba(38, 31, 45, 0.055);
}

.dark-mode .result-row.is-selected {
  background: rgba(183, 160, 220, 0.12);
  box-shadow: inset 0 0 0 2px rgba(183, 160, 220, 0.28), 0 8px 22px rgba(0, 0, 0, 0.22);
}

.term-block {
  display: grid;
  gap: 4px;
  min-width: 0;
}

.term {
  font-size: clamp(17px, 1.7vw, 19px);
  font-weight: 850;
  line-height: 1.14;
  overflow-wrap: anywhere;
}

.cn {
  align-self: center;
  color: #2f2b36;
  font-size: clamp(14px, 1.45vw, 16px);
  line-height: 1.34;
  font-weight: 700;
  overflow-wrap: anywhere;
}

.dark-mode .cn {
  color: #f1edf5;
}

.meta-line,
.badges,
.linked-line {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 5px;
}

.result-row > .badges {
  justify-content: flex-end;
  min-width: 0;
  max-width: 100%;
}

.meta-line {
  color: var(--subtle);
  font-size: 12px;
  font-weight: 720;
}

.badge {
  display: inline-flex;
  align-items: center;
  height: 22px;
  min-width: 38px;
  padding: 0 7px;
  border: 1px solid rgba(83, 104, 121, 0.22);
  border-radius: 7px;
  background: rgba(83, 104, 121, 0.08);
  color: var(--bluegray);
  font-size: 11px;
  font-weight: 820;
  white-space: nowrap;
  flex: 0 0 auto;
  justify-content: center;
}

.ipa {
  font-family: "Times New Roman", Times, serif;
  font-weight: 600;
}

.badge.lesson-plus {
  min-width: 48px;
  border-color: rgba(184, 205, 88, 0.58);
  background: var(--chartreuse-soft);
  color: #596916;
}

.dark-mode .badge {
  border-color: rgba(177, 192, 203, 0.28);
  background: rgba(177, 192, 203, 0.1);
}

.badge.h-aspire {
  border-color: rgba(101, 80, 126, 0.28);
  background: var(--fig-soft);
  color: var(--fig-deep);
}

.badge.warning {
  border-color: rgba(160, 100, 70, 0.26);
  background: rgba(160, 100, 70, 0.1);
  color: #7c4a30;
}

.linked-line {
  margin-top: 5px;
  padding-left: 9px;
  border-left: 3px solid var(--chartreuse);
  color: var(--fig-deep);
  font-size: 13px;
  font-weight: 720;
}

.detail-panel {
  position: relative;
  background: rgba(255, 254, 250, 0.82);
  border-color: rgba(101, 80, 126, 0.22);
}

.dark-mode .detail-panel {
  background: rgba(31, 28, 38, 0.9);
  border-color: rgba(212, 196, 239, 0.18);
}

.entry-detail {
  display: grid;
  align-content: start;
  gap: 10px;
  height: 100%;
  min-height: 0;
  overflow: auto;
  padding: 14px 16px 14px 20px;
}

.entry-detail.empty {
  align-content: center;
}

.detail-kicker {
  color: var(--fig);
  font-size: 12px;
  font-weight: 850;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.detail-title {
  position: sticky;
  top: -14px;
  z-index: 5;
  display: grid;
  gap: 7px;
  margin: -14px -16px 0 -20px;
  padding: 14px 16px 12px 20px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 254, 250, 0.94);
  backdrop-filter: blur(18px);
}

.dark-mode .detail-title {
  background: rgba(31, 28, 38, 0.96);
}

.detail-title h2 {
  font-size: 27px;
}

.detail-section {
  display: grid;
  gap: 6px;
  padding-top: 10px;
  border-top: 1px solid var(--line);
}

.detail-section h3 {
  margin: 0;
  color: var(--bluegray);
  font-size: 12px;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.raw-data-section,
.conjugation-section {
  gap: 8px;
}

.raw-data-section summary,
.conjugation-section > summary {
  width: max-content;
  color: var(--bluegray);
  font-size: 12px;
  font-weight: 850;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  cursor: pointer;
}

.raw-data-grid {
  display: grid;
  gap: 10px;
}

.raw-data-grid > div {
  display: grid;
  gap: 6px;
}

.tense-card summary {
  cursor: pointer;
}

.conjugation-toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  justify-content: space-between;
  min-width: 0;
  margin-bottom: 8px;
}

.conjugation-meta {
  min-width: 0;
  color: var(--muted);
  font-size: 12px;
  font-weight: 760;
  line-height: 1.45;
}

.conjugation-expand {
  flex: 0 0 auto;
  width: auto;
  height: auto;
  padding: 0 0 1px;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: var(--fig-deep);
  font-size: 12px;
  font-weight: 850;
  text-decoration: underline;
  text-decoration-thickness: 2px;
  text-underline-offset: 3px;
}

.conjugation-expand:hover,
.conjugation-expand:focus-visible {
  color: var(--chartreuse);
}

.tense-list {
  display: grid;
  gap: 7px;
}

.tense-card {
  border: 1px solid var(--line);
  border-radius: var(--radius-small);
  background: rgba(255, 254, 250, 0.54);
  overflow: hidden;
}

.tense-card.has-match {
  border-color: rgba(184, 205, 88, 0.7);
}

.dark-mode .tense-card {
  background: rgba(21, 19, 26, 0.34);
}

.tense-card summary {
  padding: 8px 10px;
  color: var(--fig-deep);
  font-size: 13px;
  font-weight: 850;
}

.conjugation-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}

.conjugation-table th,
.conjugation-table td {
  padding: 7px 10px;
  border-top: 1px solid var(--line);
  vertical-align: top;
}

.conjugation-table th {
  width: 54px;
  color: var(--bluegray);
  font-weight: 820;
  text-align: left;
}

.conjugation-table td {
  color: var(--ink);
  font-weight: 680;
}

.conjugation-table small {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 650;
  line-height: 1.35;
}

.conjugation-table tr.is-conjugation-match td,
.conjugation-table tr.is-conjugation-match th {
  background: var(--chartreuse-soft);
}

.conjugation-table tr.is-conjugation-match td span {
  color: var(--fig-deep);
  font-weight: 850;
}

.raw-cell {
  margin: 0;
  padding: 11px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(244, 241, 232, 0.65);
  color: #292531;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12px;
  line-height: 1.5;
  white-space: pre-wrap;
}

.dark-mode .raw-cell {
  background: rgba(21, 19, 26, 0.72);
  color: #f2edf6;
}

.linked-detail {
  display: grid;
  gap: 7px;
}

.linked-card {
  display: grid;
  gap: 3px;
  padding: 9px;
  border: 1px solid rgba(184, 205, 88, 0.45);
  border-radius: var(--radius);
  background: rgba(184, 205, 88, 0.12);
}

.dark-mode .linked-card {
  background: rgba(200, 220, 115, 0.1);
}

.linked-card strong {
  color: var(--fig-deep);
}

.empty-state {
  display: grid;
  place-items: center;
  min-height: 260px;
  color: var(--muted);
  text-align: center;
}

mark {
  border-radius: 4px;
  background: var(--chartreuse-soft);
  color: inherit;
}

.app-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 34px;
  color: var(--muted);
  font-size: 12px;
}

.footer-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.footer-button {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  min-width: 34px;
  min-height: 34px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 254, 250, 0.62);
  color: var(--fig);
  font-size: 18px;
  font-weight: 850;
  line-height: 1;
  text-decoration: none;
  box-shadow: 0 5px 14px rgba(38, 31, 45, 0.05);
}

.dark-mode .footer-button {
  background: rgba(39, 34, 47, 0.72);
}

.footer-button:hover,
.home-button:hover {
  background: var(--fig);
  color: var(--bg);
}

.home-icon {
  width: 17px;
  height: 17px;
  background: currentColor;
  -webkit-mask: url("data:image/svg+xml,%3Csvg width='20' height='20' viewBox='0 0 24 24' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' stroke='black' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M3 11.5L12 4l9 7.5'/%3E%3Cpath d='M5.5 10.5V20h13v-9.5'/%3E%3Cpath d='M9.5 20v-6h5v6'/%3E%3C/g%3E%3C/svg%3E") center / contain no-repeat;
  mask: url("data:image/svg+xml,%3Csvg width='20' height='20' viewBox='0 0 24 24' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' stroke='black' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M3 11.5L12 4l9 7.5'/%3E%3Cpath d='M5.5 10.5V20h13v-9.5'/%3E%3Cpath d='M9.5 20v-6h5v6'/%3E%3C/g%3E%3C/svg%3E") center / contain no-repeat;
}

.footer-meta {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 720;
}

@media (max-width: 980px) {
  .app-shell {
    width: min(100vw - 40px, 780px);
    padding: 24px 0 16px;
  }

  .topbar,
  .search-panel {
    grid-template-columns: 1fr;
  }

  .topbar {
    align-items: flex-start;
  }

  .stat-strip {
    justify-content: flex-start;
  }

  .mode-control,
  .filters {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .workspace {
    grid-template-columns: 1fr;
    gap: 14px;
  }

  .panel-resizer {
    display: none;
  }

  .results-list,
  .entry-detail {
    height: auto;
    max-height: none;
    min-height: 0;
  }

  .result-row {
    grid-template-columns: 1fr;
  }

  .result-row > .badges {
    justify-content: flex-start;
  }

  body {
    overflow: auto;
  }

  .app-shell {
    height: auto;
    min-height: 100svh;
    overflow: visible;
  }

  .workspace {
    overflow: visible;
  }
}

@container (max-width: 700px) {
  .result-row {
    grid-template-columns: minmax(140px, 1fr) max-content;
    gap: 8px;
  }

  .result-row > .term-block {
    grid-column: 1;
  }

  .result-row > .cn {
    grid-column: 1;
    align-self: start;
  }

  .result-row > .badges {
    grid-column: 2;
    grid-row: 1 / span 2;
    align-self: center;
    justify-content: flex-end;
  }
}

@container (max-width: 430px) {
  .result-row {
    grid-template-columns: 1fr;
  }

  .result-row > .badges {
    grid-column: 1;
    grid-row: auto;
    justify-content: flex-start;
  }
}

@media (max-width: 560px) {
  .app-shell {
    width: min(100vw - 28px, 780px);
  }

  .filters {
    grid-template-columns: 1fr;
  }

  .mode-button {
    width: 100%;
  }
}
