:root {
  color-scheme: light;
  --bg: #f7f8fb;
  --surface: #ffffff;
  --surface-muted: #f1f5f9;
  --border: #d7dde8;
  --text: #172033;
  --muted: #64748b;
  --accent: #2563eb;
  --shadow: 0 10px 26px rgba(15, 23, 42, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: "Segoe UI", "Microsoft YaHei", Arial, sans-serif;
}

button,
input,
select {
  font: inherit;
}

.app-shell {
  display: grid;
  grid-template-columns: 300px minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  border-right: 1px solid var(--border);
  background: #111827;
  color: #f8fafc;
  padding: 20px 16px;
}

.brand {
  display: flex;
  gap: 12px;
  align-items: center;
  margin-bottom: 12px;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: 8px;
  background: #38bdf8;
  color: #082f49;
  font-weight: 800;
}

.brand h1 {
  margin: 0;
  font-size: 20px;
  line-height: 1.2;
}

.brand p {
  margin: 4px 0 0;
  color: #cbd5e1;
  font-size: 13px;
}

.category-nav {
  display: grid;
  gap: 6px;
}

.side-link {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 36px;
  margin-bottom: 14px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 7px;
  color: #dbeafe;
  text-decoration: none;
  font-size: 14px;
  font-weight: 700;
}

.side-link:hover {
  background: rgba(255, 255, 255, 0.1);
}

.category-button {
  width: 100%;
  min-height: 42px;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: #e5e7eb;
  cursor: pointer;
  display: grid;
  grid-template-columns: 12px minmax(0, 1fr) auto;
  align-items: center;
  gap: 9px;
  padding: 8px 9px;
  text-align: left;
}

.category-button:hover,
.category-button.active {
  background: rgba(255, 255, 255, 0.11);
}

.swatch {
  width: 10px;
  height: 22px;
  border-radius: 3px;
}

.category-title {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.category-count {
  color: #cbd5e1;
  font-size: 12px;
}

.workspace {
  min-width: 0;
  padding: 18px;
}

.toolbar {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) 170px 150px auto;
  gap: 10px;
  align-items: end;
  margin-bottom: 14px;
}

.toolbar label {
  display: grid;
  gap: 5px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 650;
}

.toolbar input,
.toolbar select,
.toolbar button {
  height: 38px;
  border: 1px solid var(--border);
  border-radius: 7px;
  background: var(--surface);
  color: var(--text);
  padding: 0 10px;
}

.toolbar button {
  cursor: pointer;
  color: #1d4ed8;
  font-weight: 700;
}

.content-grid {
  display: grid;
  grid-template-columns: minmax(280px, 42%) minmax(0, 1fr);
  gap: 14px;
  height: calc(100vh - 88px);
  min-height: 560px;
}

.question-panel,
.detail-panel {
  min-height: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.panel-header {
  height: 54px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 14px;
  border-bottom: 1px solid var(--border);
}

.panel-header h2 {
  margin: 0;
  font-size: 16px;
}

#resultCount {
  color: var(--muted);
  font-size: 13px;
}

.question-list {
  height: calc(100% - 54px);
  overflow: auto;
  padding: 8px;
}

.question-item {
  display: grid;
  gap: 6px;
  width: 100%;
  border: 1px solid transparent;
  border-radius: 7px;
  background: transparent;
  color: var(--text);
  cursor: pointer;
  padding: 10px;
  text-align: left;
}

.question-item:hover,
.question-item.active {
  border-color: #bfdbfe;
  background: #eff6ff;
}

.question-meta {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  color: var(--muted);
  font-size: 12px;
}

.chip {
  display: inline-flex;
  align-items: center;
  height: 22px;
  border-radius: 999px;
  background: var(--surface-muted);
  color: #334155;
  padding: 0 8px;
  font-size: 12px;
}

.question-title {
  margin: 0;
  font-size: 14px;
  line-height: 1.42;
}

.detail-panel {
  overflow: auto;
  padding: 18px;
}

.detail-header {
  display: grid;
  gap: 9px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border);
}

.detail-header h2 {
  margin: 0;
  font-size: 22px;
  line-height: 1.3;
}

.question-zh {
  margin: 0;
  color: #475569;
  font-size: 15px;
}

.section {
  padding: 16px 0;
  border-bottom: 1px solid var(--border);
}

.section:last-child {
  border-bottom: 0;
}

.section h3 {
  margin: 0 0 9px;
  font-size: 15px;
}

.section h4 {
  margin: 16px 0 8px;
  font-size: 13px;
  color: #334155;
}

.section p {
  margin: 0 0 10px;
  line-height: 1.62;
}

.muted {
  color: var(--muted);
}

.answer-fr p {
  font-size: 15px;
}

.answer-zh p {
  color: #334155;
}

.bullet-list {
  margin: 0;
  padding-left: 20px;
}

.bullet-list li {
  margin: 6px 0;
  line-height: 1.5;
}

.empty-state {
  display: grid;
  place-content: center;
  min-height: 100%;
  color: var(--muted);
  text-align: center;
  padding: 24px;
}

.empty-state h2 {
  color: var(--text);
}

.source-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.material-summary {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-bottom: 4px;
}

.material-list {
  display: grid;
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.material-list li {
  border: 1px solid var(--border);
  border-radius: 7px;
  background: #fbfdff;
  padding: 9px;
}

.material-list strong {
  display: inline-block;
  margin-right: 8px;
  font-size: 13px;
}

.material-list em {
  color: var(--muted);
  font-size: 12px;
  font-style: normal;
}

.material-list p {
  margin: 6px 0 0;
  font-size: 14px;
}

.loc {
  display: inline-flex;
  align-items: center;
  height: 20px;
  margin-right: 8px;
  border-radius: 5px;
  background: #e0f2fe;
  color: #075985;
  padding: 0 6px;
  font-size: 12px;
  font-weight: 700;
}

.vocab-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
  gap: 8px;
}

.vocab-card {
  display: grid;
  gap: 4px;
  border: 1px solid var(--border);
  border-radius: 7px;
  background: #fbfdff;
  padding: 9px;
}

.vocab-card strong {
  font-size: 14px;
}

.vocab-card span,
.vocab-card small {
  color: var(--muted);
  font-size: 12px;
}

.materials-page {
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
  padding: 22px 0 40px;
}

.materials-hero {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 18px;
}

.materials-hero h1 {
  margin: 2px 0 6px;
  font-size: 34px;
}

.materials-hero p {
  margin: 0;
  color: var(--muted);
}

.eyebrow {
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0;
}

.nav-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 108px;
  height: 38px;
  border: 1px solid var(--border);
  border-radius: 7px;
  background: var(--surface);
  color: #1d4ed8;
  text-decoration: none;
  font-weight: 800;
}

.materials-toolbar {
  display: grid;
  grid-template-columns: minmax(260px, 1fr) auto;
  gap: 12px;
  align-items: end;
  margin-bottom: 14px;
}

.materials-toolbar label {
  display: grid;
  gap: 5px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.materials-toolbar input {
  height: 40px;
  border: 1px solid var(--border);
  border-radius: 7px;
  background: var(--surface);
  color: var(--text);
  padding: 0 10px;
}

.segmented {
  display: inline-flex;
  height: 40px;
  border: 1px solid var(--border);
  border-radius: 7px;
  background: var(--surface);
  overflow: hidden;
}

.segmented button {
  min-width: 82px;
  border: 0;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-weight: 800;
}

.segmented button.active {
  background: #dbeafe;
  color: #1d4ed8;
}

.materials-content {
  display: grid;
  gap: 14px;
}

.custom-materials-panel {
  display: grid;
  gap: 12px;
  margin-bottom: 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
  padding: 14px;
}

.custom-materials-panel > header {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: start;
}

.custom-materials-panel h2 {
  margin: 0 0 4px;
  font-size: 18px;
}

.custom-materials-panel p {
  margin: 0;
  color: var(--muted);
}

.custom-materials-panel header button,
.custom-form button,
.custom-actions button {
  height: 34px;
  border: 1px solid var(--border);
  border-radius: 7px;
  background: #ffffff;
  color: #1d4ed8;
  cursor: pointer;
  padding: 0 10px;
  font-weight: 800;
}

.custom-materials-panel button:disabled {
  cursor: wait;
  opacity: 0.62;
}

.custom-form {
  display: grid;
  grid-template-columns: 110px minmax(190px, 1.2fr) minmax(160px, 0.9fr) minmax(140px, 0.7fr);
  gap: 10px;
  align-items: end;
}

.custom-form label {
  display: grid;
  gap: 5px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.custom-form input,
.custom-form select {
  height: 38px;
  border: 1px solid var(--border);
  border-radius: 7px;
  background: #ffffff;
  color: var(--text);
  padding: 0 10px;
}

.custom-form .wide-field {
  grid-column: 1 / -2;
}

.custom-list {
  display: grid;
  gap: 8px;
}

.custom-empty {
  padding: 3px 0;
}

.custom-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: start;
  border: 1px solid var(--border);
  border-radius: 7px;
  background: #fbfdff;
  padding: 10px;
}

.custom-item-head {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}

.custom-item strong {
  font-size: 15px;
}

.custom-item p {
  margin: 6px 0 0;
  color: #334155;
}

.custom-item small {
  display: block;
  margin-top: 5px;
  color: var(--muted);
  line-height: 1.45;
}

.custom-actions {
  display: flex;
  gap: 6px;
}

.material-group {
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.material-group > header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  background: #fbfdff;
}

.material-group h2 {
  margin: 0 0 4px;
  font-size: 18px;
}

.material-group header p {
  margin: 0;
  color: var(--muted);
}

.count-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 34px;
  height: 26px;
  border-radius: 999px;
  background: #e0f2fe;
  color: #075985;
  padding: 0 9px;
  font-size: 12px;
  font-weight: 800;
}

.material-card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 10px;
  padding: 12px;
}

.material-card {
  display: grid;
  gap: 8px;
  align-content: start;
  border: 1px solid var(--border);
  border-radius: 7px;
  background: #ffffff;
  padding: 11px;
}

.material-card.compact {
  gap: 6px;
}

.material-card-head {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  align-items: start;
}

.material-card h3 {
  margin: 0;
  font-size: 15px;
  line-height: 1.35;
}

.material-card p {
  margin: 0;
  color: var(--muted);
  line-height: 1.45;
}

.variant-list {
  display: grid;
  gap: 5px;
}

.variant-list span {
  display: block;
  border-left: 3px solid #bfdbfe;
  background: #eff6ff;
  padding: 6px 8px;
  font-size: 13px;
  line-height: 1.45;
}

.occurrence-details {
  border-top: 1px solid var(--border);
  padding-top: 7px;
}

.occurrence-details summary {
  color: #1d4ed8;
  cursor: pointer;
  font-size: 13px;
  font-weight: 800;
}

.occurrence-details ul {
  display: grid;
  gap: 6px;
  margin: 8px 0 0;
  padding: 0;
  list-style: none;
}

.occurrence-details li {
  display: grid;
  gap: 4px;
  font-size: 13px;
  line-height: 1.45;
}

@media (max-width: 980px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    border-right: 0;
    border-bottom: 1px solid var(--border);
  }

  .category-nav {
    grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  }

  .toolbar,
  .content-grid {
    grid-template-columns: 1fr;
  }

  .content-grid {
    height: auto;
  }

  .question-list {
    max-height: 440px;
  }

  .materials-hero,
  .materials-toolbar {
    grid-template-columns: 1fr;
    align-items: stretch;
  }

  .materials-hero {
    display: grid;
  }

  .custom-form {
    grid-template-columns: 1fr;
  }

  .custom-form .wide-field {
    grid-column: auto;
  }

  .custom-item {
    grid-template-columns: 1fr;
  }
}
