:root {
  --bg: #f8fafc;
  --bg-soft: #eef2f7;
  --surface: rgba(255, 255, 255, 0.88);
  --surface-solid: #ffffff;
  --text: #0f172a;
  --muted: #64748b;
  --border: #d9e1ec;
  --accent: #2563eb;
  --accent-soft: #dbeafe;
  --shadow: 0 18px 60px rgba(15, 23, 42, 0.08);
  --radius-lg: 28px;
  --radius-md: 20px;
}

:root.dark {
  --bg: #020617;
  --bg-soft: #0f172a;
  --surface: rgba(255, 255, 255, 0.07);
  --surface-solid: #0f172a;
  --text: #e2e8f0;
  --muted: #94a3b8;
  --border: rgba(255, 255, 255, 0.12);
  --accent: #93c5fd;
  --accent-soft: rgba(59, 130, 246, 0.16);
  --shadow: 0 18px 60px rgba(0, 0, 0, 0.26);
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  min-height: 100vh;
  margin: 0;
  background:
    radial-gradient(circle at top left, rgba(59, 130, 246, 0.13), transparent 30rem),
    linear-gradient(180deg, var(--bg) 0%, var(--surface-solid) 46%, var(--bg) 100%);
  color: var(--text);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
}

button,
input {
  font: inherit;
}

button {
  cursor: pointer;
}

a {
  color: inherit;
  text-decoration: none;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.site-header,
.site-footer,
#homeIntro,
#app,
.term-view {
  width: min(100% - 32px, 1280px);
  margin-inline: auto;
}

.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 20px 0 12px;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand,
.theme-toggle {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  border-radius: 999px;
  font-size: 14px;
  font-weight: 700;
}

.brand-mark {
  display: grid;
  width: 38px;
  height: 38px;
  place-items: center;
  border: 1px solid var(--border);
  border-radius: 13px;
  background: var(--surface);
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.06);
}

.updated-at {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  font-weight: 500;
}

.theme-toggle {
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  padding: 10px 14px;
}

.hero {
  max-width: 880px;
  margin: 54px auto 0;
  text-align: center;
}

.pill {
  display: inline-flex;
  gap: 4px;
  align-items: center;
  margin: 0 0 20px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  padding: 8px 14px;
  color: var(--muted);
  font-size: 14px;
  font-weight: 700;
  box-shadow: 0 10px 30px rgba(15, 23, 42, 0.05);
}

.hero h1 {
  margin: 0;
  font-size: clamp(42px, 7vw, 76px);
  line-height: 0.96;
  letter-spacing: 0;
}

.hero p:last-child {
  max-width: 720px;
  margin: 24px auto 0;
  color: var(--muted);
  font-size: 18px;
  line-height: 1.7;
}

.search-panel {
  width: min(100% - 32px, 760px);
  max-width: 760px;
  margin: 42px auto 0;
  border: 1px solid var(--border);
  border-radius: 32px;
  background: var(--surface);
  padding: 12px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(16px);
}

#searchInput {
  width: 100%;
  height: 64px;
  border: 1px solid transparent;
  border-radius: 23px;
  outline: none;
  background: var(--bg-soft);
  color: var(--text);
  padding: 0 20px;
  font-size: 16px;
}

#searchInput:focus {
  border-color: var(--accent);
  background: var(--surface-solid);
  box-shadow: 0 0 0 4px var(--accent-soft);
}

.layout {
  display: grid;
  grid-template-columns: 272px 1fr;
  gap: 22px;
  margin-top: 34px;
  padding-bottom: 80px;
}

.filters,
.empty-state,
.term-card,
.term-detail {
  border: 1px solid var(--border);
  background: var(--surface);
  box-shadow: 0 8px 28px rgba(15, 23, 42, 0.05);
  backdrop-filter: blur(16px);
}

.filters {
  position: sticky;
  top: 16px;
  height: fit-content;
  border-radius: var(--radius-lg);
  padding: 18px;
}

.filters-title,
.results-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
}

.filters h2,
.results-header h2 {
  margin: 0;
  font-size: 24px;
  letter-spacing: 0;
}

.filters-title button,
.results-actions button,
.back-link {
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 14px;
  font-weight: 700;
}

.filters-title button:hover,
.results-actions button:hover,
.back-link:hover {
  color: var(--accent);
}

.results-actions {
  text-align: right;
}

.filter-group {
  margin-top: 24px;
}

.filter-group p {
  margin: 0 0 12px;
  color: var(--muted);
  font-size: 14px;
  font-weight: 800;
}

.button-list,
.letter-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.button-list {
  flex-direction: column;
}

.filter-button,
.letter-button {
  border: 0;
  border-radius: 999px;
  background: var(--bg-soft);
  color: var(--text);
  font-size: 14px;
  font-weight: 700;
  transition:
    transform 160ms ease,
    background 160ms ease,
    color 160ms ease;
}

.filter-button {
  width: 100%;
  padding: 10px 12px;
  text-align: left;
}

.letter-button {
  min-width: 40px;
  padding: 10px 12px;
}

.filter-button:hover,
.letter-button:hover {
  color: var(--accent);
  transform: translateY(-1px);
}

.filter-button:disabled,
.letter-button:disabled {
  cursor: not-allowed;
  opacity: 0.38;
  transform: none;
}

.filter-button:disabled:hover,
.letter-button:disabled:hover {
  color: var(--text);
}

.filter-button.active,
.letter-button.active {
  background: var(--text);
  color: var(--surface-solid);
}

:root.dark .filter-button.active,
:root.dark .letter-button.active {
  background: #e2e8f0;
  color: #0f172a;
}

.results-header {
  margin-bottom: 18px;
}

.results-header p {
  margin: 5px 0 0;
  color: var(--muted);
  font-size: 14px;
}

.cards-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
}

.term-card {
  display: block;
  min-height: 236px;
  border-radius: var(--radius-lg);
  padding: 22px;
  transition:
    transform 160ms ease,
    border-color 160ms ease,
    box-shadow 160ms ease;
}

.term-card:hover {
  transform: translateY(-2px);
  border-color: var(--accent);
  box-shadow: var(--shadow);
}

.card-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.category {
  display: inline-flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  margin: 0;
  color: var(--accent);
  font-size: 14px;
  font-weight: 800;
}

.term-card h3 {
  margin: 9px 0 4px;
  font-size: 21px;
  line-height: 1.2;
}

.english,
.definition,
.meta,
.source-list {
  color: var(--muted);
}

.english {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0;
  font-size: 14px;
  font-weight: 400;
}

.english-flag {
  font-size: 13px;
  line-height: 1;
}

.new-badge {
  display: inline-flex;
  align-items: center;
  width: fit-content;
  border-radius: 999px;
  background: #dcfce7;
  padding: 4px 8px;
  color: #166534;
  font-size: 11px;
  font-weight: 900;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

:root.dark .new-badge {
  background: rgba(34, 197, 94, 0.18);
  color: #86efac;
}

.definition {
  margin: 18px 0 0;
  display: -webkit-box;
  overflow: hidden;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 4;
  font-size: 14px;
  line-height: 1.65;
}

.empty-state {
  grid-column: 1 / -1;
  border-style: dashed;
  border-radius: var(--radius-lg);
  padding: 36px;
  text-align: center;
}

.empty-state h3 {
  margin: 0 0 8px;
}

.empty-state p {
  margin: 0;
  color: var(--muted);
}

.term-view {
  padding: 44px 0 80px;
}

.term-detail {
  max-width: 900px;
  margin: 28px auto 0;
  border-radius: 32px;
  padding: 38px;
}

.term-title-row {
  display: flex;
  justify-content: space-between;
  gap: 18px;
}

.term-detail h1 {
  margin: 12px 0 8px;
  font-size: clamp(38px, 7vw, 68px);
  line-height: 0.98;
}

.term-meta-list {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 12px;
}

.term-meta-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  width: fit-content;
  padding: 0;
  color: var(--muted);
  font-size: 13px;
  font-weight: 400;
}

.term-meta-chip strong,
.term-meta-chip a {
  color: var(--muted);
  font-weight: 400;
}

.term-meta-chip a {
  text-decoration: underline;
  text-decoration-color: transparent;
  text-underline-offset: 3px;
  transition:
    color 160ms ease,
    text-decoration-color 160ms ease;
}

.term-meta-chip a:hover {
  color: var(--accent);
  text-decoration-color: currentColor;
}

.chip {
  display: inline-flex;
  width: fit-content;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  padding: 7px 11px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

a.chip {
  transition:
    border-color 160ms ease,
    color 160ms ease,
    background 160ms ease;
}

a.chip:hover {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent);
}

.detail-section {
  max-width: 760px;
  margin-top: 32px;
}

.detail-section h2 {
  margin: 0 0 10px;
  color: var(--muted);
  font-size: 12px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.detail-section p {
  margin: 0;
  color: var(--text);
  font-size: 17px;
  font-weight: 500;
  line-height: 1.65;
}

.example-box {
  border-left: 2px solid var(--border);
  border-radius: 0;
  background: transparent;
  padding: 2px 0 2px 18px;
}

.example-box p {
  color: var(--muted);
  font-size: 16px;
  font-weight: 500;
}

.chip-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.case-study-card {
  display: flex;
  flex-direction: column;
  gap: 10px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--surface-solid);
  padding: 18px 20px;
  color: var(--text);
  transition:
    border-color 160ms ease,
    box-shadow 160ms ease,
    transform 160ms ease;
}

.case-study-card:hover {
  border-color: var(--accent);
  box-shadow: 0 10px 28px rgba(15, 23, 42, 0.08);
  transform: translateY(-1px);
}

.case-study-title {
  font-size: 17px;
  font-weight: 500;
  line-height: 1.35;
}

.case-study-description,
.case-study-url {
  color: var(--muted);
  font-size: 14px;
  line-height: 1.45;
}

.case-study-url {
  display: flex;
  align-items: center;
  gap: 9px;
  color: var(--text);
  overflow-wrap: anywhere;
}

.related-grid {
  max-width: 900px;
  margin: 28px auto 0;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

.site-footer {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  border-top: 1px solid var(--border);
  padding: 28px 0;
  color: var(--muted);
  font-size: 14px;
}

.site-footer p {
  margin: 0;
}

@media (max-width: 1040px) {
  .layout {
    grid-template-columns: 1fr;
  }

  .filters {
    position: static;
  }

  .button-list {
    flex-direction: row;
  }

  .filter-button {
    width: fit-content;
  }

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

@media (max-width: 680px) {
  .site-header,
  .site-footer,
  #homeIntro,
  #app,
  .term-view {
    width: min(100% - 24px, 1280px);
  }

  .site-header,
  .site-footer {
    align-items: flex-start;
    flex-direction: column;
    gap: 14px;
  }

  .brand {
    max-width: 100%;
  }

  .brand > span:last-child {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .header-actions {
    align-self: stretch;
    justify-content: space-between;
    width: 100%;
  }

  .updated-at {
    max-width: 56%;
    line-height: 1.35;
  }

  .theme-toggle {
    flex: 0 0 auto;
  }

  .hero {
    margin-top: 30px;
    text-align: left;
  }

  .pill {
    margin-bottom: 16px;
  }

  .hero h1 {
    font-size: clamp(38px, 15vw, 56px);
    line-height: 1;
  }

  .hero p:last-child {
    margin-top: 18px;
    font-size: 16px;
    line-height: 1.55;
  }

  .search-panel {
    margin-top: 28px;
    border-radius: 24px;
    padding: 8px;
  }

  #searchInput {
    height: 58px;
    border-radius: 18px;
  }

  .layout {
    gap: 18px;
    margin-top: 24px;
    padding-bottom: 56px;
  }

  .filters {
    border-radius: 22px;
    padding: 16px;
  }

  .filters-title,
  .results-header {
    align-items: flex-start;
  }

  .results-actions {
    justify-items: start;
    text-align: left;
  }

  .button-list,
  .letter-list {
    gap: 7px;
  }

  .filter-button,
  .letter-button {
    padding: 9px 11px;
    font-size: 13px;
  }

  .cards-grid,
  .related-grid {
    grid-template-columns: 1fr;
  }

  .term-card {
    min-height: 0;
    border-radius: 22px;
    padding: 18px;
  }

  .term-card h3 {
    font-size: 20px;
  }

  .results-header,
  .term-title-row {
    align-items: flex-start;
    flex-direction: column;
  }

  .term-view {
    padding: 28px 0 56px;
  }

  .term-detail {
    margin-top: 20px;
    border-radius: 24px;
    padding: 22px;
  }

  .term-detail h1 {
    font-size: clamp(38px, 14vw, 52px);
  }

  .detail-section {
    margin-top: 28px;
  }

  .detail-section p {
    font-size: 16px;
  }

  .case-study-card {
    border-radius: 12px;
    padding: 16px;
  }

  .case-study-title {
    font-size: 16px;
  }

  .case-study-url {
    font-size: 13px;
  }
}

@media (max-width: 380px) {
  .brand > span:last-child {
    max-width: 210px;
  }

  .updated-at {
    max-width: 50%;
    font-size: 12px;
  }

  .theme-toggle {
    padding: 9px 12px;
  }

  .hero h1,
  .term-detail h1 {
    font-size: 38px;
  }
}
