:root {
  --bg: #f6f1e8;
  --bg-card: #fffcf7;
  --ink: #1f1a14;
  --muted: #6b5f52;
  --accent: #8b3a2a;
  --accent-soft: #d4a574;
  --line: #e2d6c4;
  --shadow: 0 10px 30px rgba(47, 34, 22, 0.08);
  --radius: 14px;
  --font-display: "Crimson Pro", Georgia, serif;
  --font-ui: "Source Sans 3", system-ui, sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font-ui);
  color: var(--ink);
  background:
    radial-gradient(circle at top right, rgba(212, 165, 116, 0.25), transparent 40%),
    linear-gradient(180deg, #faf6ef 0%, var(--bg) 100%);
}

.wrap {
  width: min(980px, calc(100% - 2rem));
  margin: 0 auto;
}

.site-header {
  border-bottom: 1px solid var(--line);
  background: rgba(255, 252, 247, 0.92);
  backdrop-filter: blur(8px);
  position: sticky;
  top: 0;
  z-index: 10;
}

.header-inner {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  padding: 1rem 0;
  flex-wrap: wrap;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.85rem;
}

.brand-mark {
  width: 48px;
  height: 48px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 1.2rem;
  color: #fff;
  background: linear-gradient(135deg, var(--accent), #b85c38);
  box-shadow: var(--shadow);
}

.brand h1 {
  margin: 0;
  font-family: var(--font-display);
  font-size: 1.65rem;
  font-weight: 600;
}

.tagline {
  margin: 0.15rem 0 0;
  color: var(--muted);
  font-size: 0.92rem;
}

.tabs {
  display: flex;
  gap: 0.35rem;
  background: #efe5d6;
  padding: 0.25rem;
  border-radius: 999px;
}

.tab {
  border: 0;
  background: transparent;
  padding: 0.55rem 1rem;
  border-radius: 999px;
  font: inherit;
  cursor: pointer;
  color: var(--muted);
}

.tab.active {
  background: var(--bg-card);
  color: var(--accent);
  font-weight: 600;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
}

main {
  padding: 1.5rem 0 4rem;
}

.view[hidden] { display: none !important; }

.search-panel,
.browse-toolbar,
.intro-toolbar {
  background: var(--bg-card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1rem;
  box-shadow: var(--shadow);
}

.search-row {
  display: flex;
  gap: 0.75rem;
}

#query {
  flex: 1;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0.85rem 1rem;
  font: inherit;
  font-size: 1.05rem;
  background: #fff;
}

.controls {
  display: flex;
  gap: 1rem;
  margin-top: 0.85rem;
  flex-wrap: wrap;
}

label {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  font-size: 0.85rem;
  color: var(--muted);
}

select {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0.45rem 0.6rem;
  font: inherit;
  background: #fff;
  min-width: 180px;
}

.btn {
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 10px;
  padding: 0.65rem 1rem;
  font: inherit;
  cursor: pointer;
}

.btn.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  font-weight: 600;
}

.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.meta-line {
  margin: 1rem 0 0.5rem;
  color: var(--muted);
  font-size: 0.92rem;
}

.results-list {
  list-style: none;
  padding: 0;
  margin: 0.75rem 0 0;
  display: grid;
  gap: 0.65rem;
}

.result-card {
  background: var(--bg-card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1rem 1.1rem;
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.result-card:hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow);
}

.result-head {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  align-items: baseline;
  flex-wrap: wrap;
}

.word-pair {
  display: flex;
  gap: 0.75rem;
  align-items: baseline;
  flex-wrap: wrap;
}

.word-pair .it {
  font-family: var(--font-display);
  font-size: 1.35rem;
  font-weight: 600;
}

.word-pair .arrow {
  color: var(--accent-soft);
}

.word-pair .bs {
  font-family: var(--font-display);
  font-size: 1.25rem;
  color: var(--accent);
}

.badge {
  font-size: 0.75rem;
  padding: 0.2rem 0.55rem;
  border-radius: 999px;
  background: #efe5d6;
  color: var(--muted);
  white-space: nowrap;
}

.desc {
  margin: 0.55rem 0 0;
  color: var(--muted);
  line-height: 1.5;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.letter-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin-top: 0.75rem;
}

.letter-btn {
  border: 1px solid var(--line);
  background: #fff;
  width: 2rem;
  height: 2rem;
  border-radius: 8px;
  cursor: pointer;
  font: inherit;
}

.letter-btn.active {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

.pager {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 1rem;
  margin-top: 1rem;
}

.intro-content {
  margin-top: 1rem;
  display: grid;
  gap: 1rem;
}

.intro-section {
  background: var(--bg-card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1.2rem 1.3rem;
  box-shadow: var(--shadow);
}

.intro-section h2 {
  margin: 0 0 0.75rem;
  font-family: var(--font-display);
  color: var(--accent);
}

.intro-section p {
  margin: 0 0 0.75rem;
  line-height: 1.65;
  white-space: pre-wrap;
}

.detail-panel {
  position: fixed;
  top: 0;
  right: 0;
  width: min(420px, 100%);
  height: 100vh;
  background: var(--bg-card);
  border-left: 1px solid var(--line);
  box-shadow: -8px 0 24px rgba(0, 0, 0, 0.08);
  padding: 1.25rem;
  overflow-y: auto;
  z-index: 20;
}

.detail-panel[hidden] { display: none; }

.icon-btn {
  border: 0;
  background: transparent;
  font-size: 1.6rem;
  line-height: 1;
  cursor: pointer;
  float: right;
  color: var(--muted);
}

.detail-word {
  font-family: var(--font-display);
  font-size: 2rem;
  margin: 0.5rem 0 0.25rem;
  color: var(--accent);
}

.detail-sub {
  font-family: var(--font-display);
  font-size: 1.35rem;
  margin: 0 0 1rem;
}

.detail-block {
  margin: 1rem 0;
  line-height: 1.6;
}

.detail-block h3 {
  margin: 0 0 0.35rem;
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
}

.empty {
  padding: 2rem;
  text-align: center;
  color: var(--muted);
  background: var(--bg-card);
  border: 1px dashed var(--line);
  border-radius: var(--radius);
}

.site-footer {
  border-top: 1px solid var(--line);
  padding: 1rem 0 2rem;
  color: var(--muted);
  font-size: 0.88rem;
}

@media (max-width: 640px) {
  .search-row { flex-direction: column; }
  .detail-panel { width: 100%; }
}
