:root {
  --cream: #fbf7f2;
  --warm: #fff4e7;
  --line: #e0d5c8;
  --ink: #263238;
  --muted: #816e61;
  --accent: #c47b52;
  --green: #28796f;
  --navy: #30315f;
  --gold: #f8a72b;
  --white: #fff;
  --shadow: 0 18px 38px rgba(61, 43, 31, 0.1);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background:
    radial-gradient(circle at 14% 14%, rgba(248, 167, 43, 0.14), transparent 24%),
    radial-gradient(circle at 88% 8%, rgba(40, 121, 111, 0.1), transparent 20%),
    var(--cream);
  color: var(--ink);
  font-family: "M PLUS Rounded 1c", "Hiragino Maru Gothic ProN", "Hiragino Sans", "Yu Gothic", system-ui, sans-serif;
  line-height: 1.8;
}

a {
  color: inherit;
}

.site-header {
  min-height: 68px;
  padding: 0 24px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.92);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  position: sticky;
  top: 0;
  z-index: 10;
}

.brand,
.site-header a {
  text-decoration: none;
  font-weight: 800;
}

.site-header nav {
  display: flex;
  gap: 18px;
  color: var(--muted);
  font-size: 0.9rem;
}

main {
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
}

.glossary-hero {
  padding: 54px 0 30px;
  max-width: 760px;
}

.kicker {
  margin: 0 0 10px;
  color: var(--green);
  font-size: 0.78rem;
  font-weight: 900;
  letter-spacing: 0.08em;
}

h1 {
  margin: 0 0 16px;
  color: var(--navy);
  font-family: "M PLUS Rounded 1c", "Hiragino Maru Gothic ProN", "Yu Gothic", system-ui, sans-serif;
  font-weight: 800;
  font-size: clamp(2rem, 4.2vw, 3.45rem);
  line-height: 1.25;
}

.lead {
  max-width: 720px;
  margin: 0;
  color: var(--muted);
}

.hero-shout-image {
  display: block;
  width: min(100%, 540px);
  height: auto;
  margin: 24px 0 0;
}

.tools {
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--white);
  padding: 18px;
  box-shadow: 0 10px 24px rgba(61, 43, 31, 0.06);
}

.search-box {
  display: grid;
  gap: 8px;
  color: var(--muted);
  font-size: 0.88rem;
  font-weight: 800;
}

.search-box input {
  width: 100%;
  min-height: 48px;
  border: 2px solid var(--line);
  border-radius: 14px;
  padding: 0 14px;
  font-size: 1rem;
}

.search-box input:focus {
  outline: 3px solid rgba(40, 121, 111, 0.18);
  border-color: var(--green);
}

.kana-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 14px;
}

.kana-tabs button {
  border: 1px solid rgba(40, 121, 111, 0.25);
  border-radius: 999px;
  background: var(--cream);
  color: var(--green);
  padding: 8px 14px;
  font-weight: 900;
  cursor: pointer;
}

.kana-tabs button.is-active {
  background: var(--green);
  color: var(--white);
}

.glossary-layout {
  display: grid;
  grid-template-columns: 350px minmax(0, 1fr);
  gap: 22px;
  padding: 26px 0 70px;
  align-items: start;
}

.term-list,
.term-detail {
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--white);
  box-shadow: var(--shadow);
}

.term-list {
  position: sticky;
  top: 88px;
  overflow: hidden;
}

#termList {
  max-height: calc(100vh - 176px);
  overflow-y: auto;
  overscroll-behavior: contain;
}

.list-head {
  border-bottom: 1px solid var(--line);
  padding: 16px 18px;
  display: flex;
  justify-content: space-between;
  gap: 12px;
}

.list-head span {
  color: var(--muted);
  font-size: 0.82rem;
}

.term-button {
  width: 100%;
  border: 0;
  border-bottom: 1px solid var(--line);
  background: var(--white);
  padding: 16px 18px;
  text-align: left;
  cursor: pointer;
  transition: background 0.16s ease, padding-left 0.16s ease;
}

.term-button:hover,
.term-button.is-active {
  background: #fff4e7;
  padding-left: 24px;
}

.term-button strong {
  display: block;
  color: var(--navy);
  font-size: 1.05rem;
  font-weight: 800;
}

.term-button small {
  color: var(--muted);
}

.mobile-back {
  display: none;
}

.term-detail {
  min-height: 620px;
  padding: 30px;
  position: sticky;
  top: 88px;
  max-height: calc(100vh - 112px);
  overflow-y: auto;
}

.term-detail.is-focused {
  animation: detail-focus 1.2s ease;
}

@keyframes detail-focus {
  0% {
    box-shadow: 0 0 0 0 rgba(248, 167, 43, 0.5), var(--shadow);
  }
  100% {
    box-shadow: 0 0 0 14px rgba(248, 167, 43, 0), var(--shadow);
  }
}

.term-anchor {
  display: block;
  position: relative;
  top: -104px;
  visibility: hidden;
}

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

.detail-kana {
  color: var(--green);
  font-weight: 900;
  letter-spacing: 0.08em;
}

.term-detail h2 {
  margin: 4px 0 8px;
  color: var(--navy);
  font-family: "M PLUS Rounded 1c", "Hiragino Maru Gothic ProN", "Yu Gothic", system-ui, sans-serif;
  font-weight: 800;
  font-size: clamp(1.7rem, 3.5vw, 2.65rem);
  line-height: 1.25;
}

.reading {
  margin: 0 0 24px;
  color: var(--muted);
  font-weight: 800;
}

.chapi-panel {
  position: relative;
  border: 3px solid rgba(48, 49, 95, 0.82);
  border-radius: 18px;
  padding: 34px 30px 30px 108px;
  background: #fffdf9;
  box-shadow: 8px 8px 0 rgba(248, 167, 43, 0.16);
}

.chapi-panel::after {
  content: "";
  position: absolute;
  left: 24px;
  top: 28px;
  width: 58px;
  height: 58px;
  border: 4px solid var(--gold);
  border-radius: 50%;
  background: var(--warm) url("assets/chapikin-teacher.png") center / cover no-repeat;
}

.speaker {
  position: relative;
  z-index: 1;
  display: flex;
  width: fit-content;
  align-items: center;
  gap: 8px;
  margin-bottom: 18px;
  border-radius: 999px;
  background: rgba(248, 167, 43, 0.16);
  color: #a76709;
  padding: 7px 13px;
  font-size: 0.86rem;
  font-weight: 900;
}

.speaker::before {
  content: "チャピ筋";
  color: var(--navy);
}

.chapi-body {
  white-space: pre-line;
  color: var(--navy);
  font-size: 1.02rem;
  font-weight: 500;
}

.related {
  margin-top: 28px;
  border: 1px solid #eadccc;
  border-radius: 16px;
  background: #fff8ef;
  padding: 18px 20px 8px;
}

.related h3 {
  margin: 0 0 8px;
  color: #8f684d;
  font-size: 1.02rem;
}

.related a {
  display: flex;
  align-items: center;
  gap: 8px;
  border-top: 1px solid #eadccc;
  padding: 12px 0;
  color: var(--navy);
  font-weight: 800;
  text-decoration: none;
}

.related a::before {
  content: "読む";
  flex: 0 0 auto;
  border-radius: 999px;
  background: rgba(196, 123, 82, 0.14);
  color: #8f684d;
  padding: 2px 8px;
  font-size: 0.72rem;
  font-weight: 900;
}

@media (max-width: 860px) {
  .site-header nav {
    display: none;
  }

  .glossary-hero,
  .glossary-layout {
    grid-template-columns: 1fr;
  }

  .term-list {
    position: static;
  }

  #termList {
    max-height: none;
    overflow: visible;
  }

  .hero-shout-image {
    width: min(100%, 700px);
    margin-top: 18px;
  }


  .term-button {
    position: relative;
    padding: 14px 42px 14px 16px;
  }

  .term-button::after {
    content: ">";
    position: absolute;
    right: 18px;
    top: 50%;
    color: var(--muted);
    font-weight: 900;
    transform: translateY(-50%);
  }

  .term-button:hover,
  .term-button.is-active {
    padding-left: 16px;
  }

  .term-button small {
    display: none;
  }

  .term-detail {
    min-height: auto;
    padding: 18px;
    position: static;
    max-height: none;
    overflow: visible;
    scroll-margin-top: 80px;
  }

  .mobile-back {
    display: inline-flex;
    margin-bottom: 16px;
    border: 1px solid #eadccc;
    border-radius: 999px;
    background: #fff8ef;
    color: #8f684d;
    padding: 8px 13px;
    font-size: 0.84rem;
    font-weight: 800;
    text-decoration: none;
  }

  .chapi-panel {
    padding: 94px 18px 22px;
    box-shadow: 5px 5px 0 rgba(248, 167, 43, 0.16);
  }

  .chapi-panel::after {
    left: 20px;
    top: 22px;
  }

  .chapi-body {
    font-size: 0.96rem;
    line-height: 1.9;
    font-weight: 500;
  }

  .related {
    padding: 16px;
  }

  .related a {
    align-items: flex-start;
    flex-direction: column;
    gap: 6px;
    line-height: 1.65;
  }
}
