:root {
  --navy: #1a2b4a;
  --navy-light: #2a4068;
  --accent: #1f9d8f;
  --accent-dark: #167a6f;
  --bg: #f4f6f9;
  --card-bg: #ffffff;
  --text: #232b38;
  --text-muted: #5f6b7c;
  --border: #e2e6ed;
  --beginner: #2f9e44;
  --intermediate: #e8893a;
  --advanced: #d24a4a;
  --shadow: 0 1px 3px rgba(26, 43, 74, 0.08), 0 4px 12px rgba(26, 43, 74, 0.06);
  --radius: 12px;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: "Hiragino Kaku Gothic ProN", "Hiragino Sans", "Yu Gothic",
    "Meiryo", system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.75;
  -webkit-font-smoothing: antialiased;
}

/* ===== Header ===== */
.site-header {
  background: linear-gradient(135deg, var(--navy) 0%, var(--navy-light) 100%);
  color: #fff;
  padding: 3rem 1.25rem 2.75rem;
}

.header-inner {
  max-width: 820px;
  margin: 0 auto;
}

.site-title {
  font-size: 1.95rem;
  font-weight: 700;
  letter-spacing: 0.02em;
}

.site-title::before {
  content: "";
  display: inline-block;
  width: 6px;
  height: 1.5rem;
  background: var(--accent);
  border-radius: 3px;
  margin-right: 0.6rem;
  vertical-align: -0.15rem;
}

.site-tagline {
  margin-top: 0.65rem;
  font-size: 0.98rem;
  color: #c7d2e3;
}

/* ===== Layout ===== */
.container {
  max-width: 820px;
  margin: 0 auto;
  padding: 1.75rem 1.25rem 3rem;
}

/* ===== Controls ===== */
.controls {
  position: sticky;
  top: 0;
  z-index: 10;
  background: var(--bg);
  padding: 1rem 0 0.85rem;
  margin: -1.75rem 0 0.5rem;
}

.search-box {
  position: relative;
  display: flex;
  align-items: center;
}

.search-icon {
  position: absolute;
  left: 1rem;
  font-size: 0.95rem;
  opacity: 0.7;
  pointer-events: none;
}

.search-input {
  width: 100%;
  padding: 0.85rem 1rem 0.85rem 2.65rem;
  font-size: 1rem;
  font-family: inherit;
  color: var(--text);
  background: var(--card-bg);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  transition: border-color 0.15s ease;
}

.search-input:focus {
  outline: none;
  border-color: var(--accent);
}

.category-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 0.85rem;
}

.filter-chip {
  padding: 0.4rem 0.95rem;
  font-size: 0.88rem;
  font-family: inherit;
  color: var(--text-muted);
  background: var(--card-bg);
  border: 1.5px solid var(--border);
  border-radius: 999px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.filter-chip:hover {
  border-color: var(--accent);
  color: var(--accent-dark);
}

.filter-chip.active {
  background: var(--navy);
  border-color: var(--navy);
  color: #fff;
}

/* ===== Pickup ===== */
.pickup {
  margin-bottom: 1.2rem;
}

.pickup-label {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 0.55rem;
}

.pickup-label::before {
  content: "★";
  color: var(--accent);
  margin-right: 0.35rem;
}

.pickup-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.pickup-chip {
  font-size: 0.85rem;
  font-family: inherit;
  color: var(--navy);
  background: var(--card-bg);
  border: 1.5px solid var(--border);
  border-radius: 8px;
  padding: 0.4rem 0.85rem;
  cursor: pointer;
  box-shadow: var(--shadow);
  transition: border-color 0.15s ease, color 0.15s ease;
}

.pickup-chip:hover {
  border-color: var(--accent);
  color: var(--accent-dark);
}

/* ===== Result count ===== */
.result-count {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 0.85rem;
}

/* ===== Term cards ===== */
.term-list {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
}

.term-card {
  background: var(--card-bg);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
  transition: border-color 0.15s ease;
}

.term-card.open {
  border-color: var(--accent);
}

.term-card.flash {
  animation: flash 1.4s ease;
}

@keyframes flash {
  0%,
  100% {
    box-shadow: var(--shadow);
  }
  20% {
    box-shadow: 0 0 0 3px rgba(31, 157, 143, 0.35);
  }
}

.term-header {
  width: 100%;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  padding: 1.05rem 1.2rem;
  background: none;
  border: none;
  font-family: inherit;
  text-align: left;
  cursor: pointer;
}

.term-header-main {
  flex: 1;
  min-width: 0;
}

.term-title-row {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.term-name {
  font-size: 1.18rem;
  font-weight: 700;
  color: var(--navy);
}

.term-reading {
  font-size: 0.78rem;
  color: var(--text-muted);
}

.term-short {
  margin-top: 0.4rem;
  font-size: 0.92rem;
  color: var(--text-muted);
}

.term-side {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 0.45rem;
  flex-shrink: 0;
}

.badges {
  display: flex;
  gap: 0.35rem;
}

.badge {
  font-size: 0.72rem;
  font-weight: 600;
  padding: 0.18rem 0.6rem;
  border-radius: 999px;
  white-space: nowrap;
}

.badge-category {
  background: #eef1f6;
  color: var(--navy-light);
}

.badge-difficulty {
  color: #fff;
}

.badge-difficulty.beginner {
  background: var(--beginner);
}
.badge-difficulty.intermediate {
  background: var(--intermediate);
}
.badge-difficulty.advanced {
  background: var(--advanced);
}

.toggle-icon {
  font-size: 1.1rem;
  color: var(--text-muted);
  transition: transform 0.2s ease;
  line-height: 1;
}

.term-card.open .toggle-icon {
  transform: rotate(45deg);
}

/* ===== Term detail ===== */
.term-detail {
  padding: 0 1.2rem 1.25rem;
  border-top: 1px solid var(--border);
  margin-top: -0.15rem;
}

.term-fullname {
  font-size: 0.84rem;
  color: var(--accent-dark);
  font-weight: 600;
  padding-top: 1rem;
}

.term-description {
  font-size: 0.95rem;
  padding-top: 0.85rem;
}

.related-block {
  margin-top: 1.1rem;
}

.related-label {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 0.5rem;
}

.related-links {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
}

.related-link {
  font-size: 0.85rem;
  font-family: inherit;
  color: var(--accent-dark);
  background: #e8f5f3;
  border: none;
  padding: 0.32rem 0.8rem;
  border-radius: 999px;
  cursor: pointer;
  transition: background 0.15s ease;
}

.related-link:hover {
  background: #d3ece8;
}

.related-link::before {
  content: "→ ";
}

/* ===== No result ===== */
.no-result {
  text-align: center;
  color: var(--text-muted);
  padding: 2.5rem 1rem;
  font-size: 0.95rem;
}

/* ===== Footer ===== */
.site-footer {
  background: var(--navy);
  color: #b9c4d6;
  text-align: center;
  padding: 1.75rem 1.25rem;
  font-size: 0.83rem;
}

.disclaimer {
  margin-top: 0.4rem;
  color: #8492a8;
  font-size: 0.78rem;
}

/* ===== Highlight (search match) ===== */
mark {
  background: #fff2b8;
  color: inherit;
  padding: 0 0.1em;
  border-radius: 3px;
}

/* ===== Responsive ===== */
@media (max-width: 540px) {
  .site-title {
    font-size: 1.6rem;
  }
  .term-header {
    flex-direction: column;
  }
  .term-side {
    flex-direction: row;
    align-items: center;
    align-self: flex-start;
    order: -1;
  }
}
