:root {
  color-scheme: light;
  --bg: #f5f7f8;
  --ink: #17212b;
  --muted: #66717d;
  --line: #d8e0e6;
  --panel: #ffffff;
  --panel-soft: #f0f4f7;
  --teal: #087f8c;
  --teal-dark: #075d66;
  --gold: #b7791f;
  --rose: #b83280;
  --shadow: 0 12px 36px rgba(19, 35, 51, 0.09);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  font-family: "Microsoft YaHei", "PingFang SC", system-ui, sans-serif;
}

button,
input,
select {
  font: inherit;
}

h1,
h2,
h3,
p {
  margin: 0;
}

h1 {
  font-size: clamp(24px, 3vw, 38px);
  line-height: 1.1;
}

h2 {
  font-size: 17px;
}

h3 {
  font-size: 15px;
}

.lex-shell {
  width: min(1720px, calc(100vw - 32px));
  margin: 0 auto;
  padding: 18px 0 28px;
}

.lex-topbar,
.top-actions,
.filters,
.panel-head,
.result-title,
.meta-line,
.lang-head {
  display: flex;
  align-items: center;
}

.lex-topbar {
  justify-content: space-between;
  gap: 16px;
  padding: 14px 0 18px;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--teal-dark);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
}

.top-actions,
.filters {
  gap: 8px;
  flex-wrap: wrap;
}

.toggle-line {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 39px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 12px;
  background: var(--panel);
  color: var(--ink);
  font-weight: 700;
}

.advanced-filters[hidden] {
  display: none;
}

.ghost,
.chip,
.primary {
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  text-decoration: none;
  cursor: pointer;
}

.ghost,
.chip {
  background: var(--panel);
}

.primary {
  border-color: var(--teal);
  background: var(--teal);
  color: #fff;
  font-weight: 800;
}

.primary:hover {
  background: var(--teal-dark);
}

.ghost {
  padding: 9px 12px;
}

.ghost.compact {
  padding: 6px 9px;
  font-size: 13px;
}

.chip {
  min-height: 39px;
  padding: 8px 12px;
}

.chip.active {
  border-color: var(--teal);
  background: #e8f6f7;
  color: var(--teal-dark);
  font-weight: 700;
}

.lex-search-band {
  grid-template-columns: minmax(260px, 1fr) auto;
}

.lex-search-band .filters,
.lex-search-band .status {
  grid-column: 1 / -1;
}

.search-band {
  display: grid;
  gap: 12px 18px;
  align-items: end;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

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

.search-actions {
  display: flex;
  align-items: end;
  gap: 10px;
  align-self: end;
}

.search-submit {
  min-height: 47px;
  width: 86px;
  padding: 10px 12px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  white-space: nowrap;
  font-weight: 800;
}

.search-box span {
  color: var(--muted);
  font-size: 13px;
}

.search-box input,
.advanced-filters input,
.advanced-filters select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  outline: none;
  background: #fbfcfd;
  color: var(--ink);
}

.search-box input,
.advanced-filters input,
.advanced-filters select {
  padding: 12px 13px;
}

.search-box input:focus,
.advanced-filters input:focus,
.advanced-filters select:focus {
  border-color: var(--teal);
  box-shadow: 0 0 0 3px rgba(8, 127, 140, 0.12);
}

.advanced-filters {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: minmax(420px, 1fr) 150px 150px;
  gap: 12px;
  align-items: end;
  border-top: 1px solid var(--line);
  padding-top: 12px;
}

.advanced-filters [hidden] {
  display: none;
}

.advanced-filters label {
  display: grid;
  gap: 6px;
}

.advanced-filters span {
  color: var(--muted);
  font-size: 12px;
}

.advanced-row-toggle,
.advanced-row {
  grid-column: 1 / -1;
}

.advanced-row-toggle {
  display: flex;
  align-items: center;
}

.plus-toggle {
  min-width: 108px;
  text-align: left;
}

.advanced-row {
  display: grid;
  grid-template-columns: minmax(220px, 360px) 92px minmax(120px, 180px);
  gap: 10px;
  align-items: end;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: color-mix(in srgb, var(--panel-soft) 62%, transparent);
}

.advanced-row[hidden] {
  display: none;
}

.sort-row {
  grid-template-columns: minmax(220px, 360px) 72px;
}

.sort-row select {
  padding-left: 0;
  padding-right: 0;
  font-size: 21px;
  font-weight: 900;
  text-align: center;
}

.status,
.muted,
.empty-state {
  color: var(--muted);
}

.status {
  grid-column: 1 / -1;
  font-size: 13px;
}

.lex-layout {
  display: grid;
  grid-template-columns: minmax(320px, 430px) minmax(0, 1fr);
  gap: 16px;
  margin-top: 16px;
  align-items: start;
}

.lex-layout[hidden] {
  display: none;
}

.result-panel,
.detail-panel {
  min-height: 280px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.result-panel {
  position: sticky;
  top: 12px;
  max-height: calc(100vh - 24px);
  overflow: hidden;
}

.panel-head {
  justify-content: space-between;
  gap: 12px;
  padding: 13px 14px;
  border-bottom: 1px solid var(--line);
}

.result-list {
  display: grid;
  gap: 8px;
  max-height: calc(100vh - 88px);
  overflow: auto;
  padding: 12px;
}

.result-item {
  display: grid;
  gap: 7px;
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 11px;
  background: #fbfcfd;
  color: var(--ink);
  text-align: left;
  cursor: pointer;
}

.result-item:hover,
.result-item.active {
  border-color: var(--teal);
  box-shadow: 0 7px 16px rgba(8, 127, 140, 0.12);
}

.result-row-main,
.result-title,
.detail-title-row {
  display: flex;
  align-items: center;
}

.thumb {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 42px;
  min-width: 42px;
  height: 42px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-soft);
}

.thumb.large {
  width: 58px;
  min-width: 58px;
  height: 58px;
}

.thumb img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.thumb.broken {
  display: none;
}

.title-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border: 2px solid rgba(255, 255, 255, 0.86);
  border-radius: 50%;
  color: #ffffff;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 13px;
  font-weight: 900;
  line-height: 1;
  text-shadow: 0 1px 1px rgba(20, 23, 28, 0.6);
  box-shadow: 0 1px 3px rgba(20, 23, 28, 0.3);
}

.thumb.large .title-icon {
  width: 38px;
  height: 38px;
  font-size: 17px;
}

.title-icon-green {
  background: linear-gradient(135deg, #8cd76c, #4aa83a);
}

.title-icon-blue {
  background: linear-gradient(135deg, #8ca5ff, #485cc8);
}

.title-icon-purple {
  background: linear-gradient(135deg, #b68dff, #7a45c8);
}

.title-icon-gold {
  background: linear-gradient(135deg, #f2c46a, #b16f21);
}

.title-icon-secondary {
  background: linear-gradient(135deg, #9b8cff, #6e4fc8);
}

.result-row-main {
  gap: 10px;
  min-width: 0;
}

.result-copy {
  display: grid;
  gap: 7px;
  min-width: 0;
  flex: 1;
}

.result-title {
  justify-content: space-between;
  gap: 10px;
}

.result-name {
  min-width: 0;
  overflow: hidden;
  font-weight: 800;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.type-badge,
.id-badge,
.missing-badge {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  border-radius: 8px;
  padding: 3px 7px;
  font-size: 12px;
  font-weight: 700;
}

.type-badge {
  background: #e8f6f7;
  color: var(--teal-dark);
}

.id-badge {
  background: var(--panel-soft);
  color: var(--muted);
}

.missing-badge {
  background: #fff3df;
  color: #8a570f;
}

.meta-line {
  gap: 7px;
  flex-wrap: wrap;
  font-size: 12px;
}

.subtext {
  overflow: hidden;
  color: var(--muted);
  font-size: 13px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.detail-view {
  padding: 16px;
}

.detail-head {
  display: grid;
  gap: 8px;
  margin-bottom: 14px;
}

.detail-title-row {
  gap: 12px;
}

.detail-head h2 {
  font-size: clamp(21px, 2vw, 30px);
}

.compare-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 14px;
}

.compare-grid.single {
  grid-template-columns: minmax(0, 1fr);
}

.lang-panel {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfd;
}

.lang-head {
  justify-content: space-between;
  gap: 10px;
  padding: 11px 12px;
  border-bottom: 1px solid var(--line);
}

.lang-body {
  display: grid;
  gap: 12px;
  padding: 12px;
}

.name-value {
  font-size: 19px;
  font-weight: 800;
  line-height: 1.35;
}

.desc-value,
.effect-list,
.kv-list {
  color: var(--ink);
  font-size: 14px;
  line-height: 1.65;
  white-space: pre-wrap;
}

.source-list {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  position: relative;
  color: var(--muted);
  font-size: 13px;
}

.source-list span {
  font-weight: 700;
}

.source-list a {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  border: 1px solid rgba(8, 127, 140, 0.22);
  border-radius: 8px;
  padding: 4px 9px;
  background: #e8f6f7;
  color: var(--teal-dark);
  font-weight: 700;
  text-decoration: none;
}

.source-list a:hover {
  border-color: var(--teal);
}

.source-help-button {
  width: 20px;
  height: 20px;
  min-width: 20px;
  border: 1px solid rgba(8, 127, 140, 0.28);
  border-radius: 50%;
  background: #f5fbfc;
  color: var(--teal-dark);
  font-size: 13px;
  font-weight: 900;
  line-height: 1;
  cursor: pointer;
}

.source-help-popover {
  position: absolute;
  z-index: 20;
  top: 30px;
  left: 0;
  max-width: min(360px, 92vw);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  background: var(--panel);
  color: var(--ink);
  box-shadow: 0 16px 30px rgba(12, 35, 45, 0.16);
  line-height: 1.65;
}

.source-help-popover a {
  display: inline;
  min-height: 0;
  border: 0;
  border-radius: 0;
  padding: 0;
  background: transparent;
  color: var(--teal-dark);
  text-decoration: underline;
}

.detail-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 10px;
}

.detail-action,
.load-more {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 34px;
  border: 1px solid rgba(8, 127, 140, 0.35);
  border-radius: 8px;
  padding: 7px 11px;
  background: #e8f6f7;
  color: var(--teal-dark);
  font-weight: 800;
  text-decoration: none;
  cursor: pointer;
}

.load-more {
  width: calc(100% - 20px);
  margin: 10px;
  font: inherit;
}

.status a {
  color: var(--teal-dark);
  font-weight: 800;
}

.kv-list {
  display: grid;
  gap: 6px;
}

.kv-list div {
  display: grid;
  grid-template-columns: 110px minmax(0, 1fr);
  gap: 10px;
  padding-top: 6px;
  border-top: 1px dashed var(--line);
}

.kv-list dt {
  color: var(--muted);
}

.kv-list dd {
  min-width: 0;
  margin: 0;
}

body.night-mode .search-band,
body.night-mode .result-panel,
body.night-mode .detail-panel {
  background: #0f2c33;
}

body.night-mode .result-item,
body.night-mode .lang-panel,
body.night-mode .thumb,
body.night-mode .search-box input,
body.night-mode .advanced-filters input,
body.night-mode .advanced-filters select,
body.night-mode .toggle-line {
  border-color: #2f6971;
  background: #12343b;
  color: #e9fffb;
}

body.night-mode .result-item.active,
body.night-mode .result-item:hover {
  border-color: #5fe0c7;
  box-shadow: 0 7px 16px rgba(95, 224, 199, 0.15);
}

body.night-mode .lang-head,
body.night-mode .panel-head,
body.night-mode .kv-list div,
body.night-mode .advanced-filters,
body.night-mode .advanced-row {
  border-color: #2f6971;
}

body.night-mode .advanced-row {
  background: rgba(18, 59, 67, 0.55);
}

body.night-mode .type-badge,
body.night-mode .chip.active {
  background: #173e46;
  color: #c5f3ef;
}

body.night-mode .source-list a {
  border-color: #2f6971;
  background: #173e46;
  color: #c5f3ef;
}

body.night-mode .source-help-button {
  border-color: #2f6971;
  background: #092932;
  color: #c5f3ef;
}

body.night-mode .source-help-popover {
  border-color: #2f6971;
  background: #0d2c35;
  color: #d8f7f3;
  box-shadow: 0 16px 30px rgba(0, 0, 0, 0.34);
}

body.night-mode .source-help-popover a {
  color: #c5f3ef;
}

body.night-mode .detail-action,
body.night-mode .load-more {
  border-color: #2f6971;
  background: #173e46;
  color: #c5f3ef;
}

body.night-mode .status a {
  color: #c5f3ef;
}

body.night-mode .id-badge {
  background: #092932;
  color: #9ac6c4;
}

body.night-mode .missing-badge {
  background: #423616;
  color: #ffdf7e;
}

@media (max-width: 1180px) {
  .lex-layout {
    grid-template-columns: minmax(280px, 380px) minmax(0, 1fr);
  }

  .advanced-filters {
    grid-template-columns: minmax(320px, 1fr) 150px 150px;
  }
}

@media (max-width: 820px) {
  .lex-shell {
    width: min(100% - 20px, 1720px);
    padding-top: 10px;
  }

  .lex-topbar,
  .lex-search-band,
  .lex-layout,
  .compare-grid {
    grid-template-columns: 1fr;
  }

  .lex-topbar {
    display: grid;
  }

  .filters {
    justify-content: stretch;
  }

  .search-actions {
    align-items: stretch;
  }

  .search-actions > * {
    flex: 1;
  }

  .filters .chip {
    flex: 1;
  }

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

  .result-panel {
    position: static;
    max-height: none;
  }

  .result-list {
    max-height: 48vh;
  }
}
