:root {
  --bg: #f6f4ef;
  --surface: #ffffff;
  --ink: #1f2328;
  --muted: #6b6f76;
  --line: #e3e0d8;
  --accent: #1f4fd1;
  --accent-dark: #1a43b3;
  --accent-soft: #e3eafc;
  --accent-line: rgba(31, 79, 209, 0.35);  /* thin rule between senses */
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  font-family: "Noto Sans", system-ui, sans-serif;
}

.page {
  max-width: 720px;
  margin: 0 auto;
  padding: 12vh 20px 40px;
}

/* ---- Title ---- */
.brand {
  text-align: center;
  margin-bottom: 36px;
}
.brand h1 {
  margin: 0;
  font-size: clamp(2.2rem, 6vw, 3rem);
  font-weight: 700;
  letter-spacing: -0.02em;
}
.brand h1::after {               /* Amazigh-flag underline */
  content: "";
  display: block;
  width: 60px;
  height: 4px;
  margin: 14px auto 0;
  border-radius: 2px;
  background: linear-gradient(90deg,
    #1f4fd1 0 33%, #2e9e5b 33% 66%, #f2c230 66% 100%);
}
.tagline {
  margin: 12px 0 0;
  color: var(--muted);
}

/* ---- Kabyle letter keys ---- */
.letters {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 6px;
  margin-bottom: 14px;
}
.letters button {
  width: 42px;
  height: 42px;
  font-family: inherit;
  font-size: 1.15rem;
  font-weight: 500;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--line);
  border-bottom-width: 3px;
  border-radius: 8px;
  cursor: pointer;
  transition: color .15s, border-color .15s, transform .05s;
}
.letters button:hover {
  color: var(--accent);
  border-color: var(--accent);
}
.letters button:active { transform: translateY(2px); }

/* ---- Search bar ---- */
.search-bar {
  display: flex;
  align-items: center;
  padding: 6px 6px 6px 22px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 999px;
  box-shadow: 0 1px 2px rgba(0,0,0,.04), 0 10px 30px rgba(0,0,0,.06);
  transition: border-color .15s, box-shadow .15s;
}
.search-bar:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 4px var(--accent-soft);
}
.search-bar input {
  flex: 1;
  min-width: 0;
  padding: 10px 0;
  font-family: inherit;
  font-size: 1.1rem;
  color: var(--ink);
  background: transparent;
  border: none;
  outline: none;
}
.search-bar input::placeholder { color: var(--muted); }

.search-btn {
  flex: none;
  width: 48px;
  height: 48px;
  display: grid;
  place-items: center;
  color: #fff;
  background: var(--accent);
  border: none;
  border-radius: 50%;
  cursor: pointer;
  transition: background .15s;
}
.search-btn:hover { background: var(--accent-dark); }

/* ---- Language switch ---- */
.lang {
  display: flex;
  gap: 4px;
  width: fit-content;
  min-width: 0;
  margin: 22px auto 0;
  padding: 4px;
  background: #ebe8e0;
  border: none;
  border-radius: 999px;
}
.lang legend {                    /* hidden visually, kept for screen readers */
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}
.lang label {
  position: relative;
  padding: 8px 18px;
  font-size: .95rem;
  color: var(--muted);
  border-radius: 999px;
  cursor: pointer;
  transition: background .15s, color .15s;
}
.lang input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}
.lang label:has(input:checked) {
  color: var(--ink);
  font-weight: 500;
  background: var(--surface);
  box-shadow: 0 1px 3px rgba(0,0,0,.12);
}
.lang label:has(input:focus-visible) {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* ---- Results: entry header ---- */
.results {
  display: grid;
  gap: 16px;
  margin-top: 40px;
}
.entry {
  padding: 22px 26px 8px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
}
.entry-head {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 14px;
}
.headword {
  margin: 0;
  font-size: 2.2rem;
  font-weight: 700;
  line-height: 1.15;
  letter-spacing: -0.01em;
}
.pron {
  font-size: 1.05rem;
  color: var(--muted);
}
.pos {                            /* isem · noun */
  margin: 6px 0 0;
  font-weight: 700;
  font-style: italic;
}
.pos-en {
  font-weight: 400;
  font-style: normal;
  color: var(--muted);
}
.gram-line {                      /* fem. tasedda · pl. izmawen */
  margin: 6px 0 0;
  color: var(--muted);
  line-height: 1.6;
}
.gram-item:not(:first-child)::before { content: " · "; }
.gram-label { font-style: italic; }
.gram-value { color: var(--ink); }

/* ---- Senses ---- */
.senses { margin-top: 16px; }
.sense {
  padding: 16px 0 18px;
  border-top: 1px solid var(--accent-line);
}
.meaning {                        /* the translation */
  margin: 0;
  font-size: 1.25rem;
  font-weight: 500;
  color: var(--accent);
}
.meaning + .meaning,
.examples + .meaning { margin-top: 10px; }

.examples {
  display: grid;
  gap: 12px;
  margin: 12px 0 0;
  padding: 0;
  list-style: none;
}
.examples li {
  padding-left: 14px;
  border-left: 2px solid var(--line);
}
.ex {                             /* the example */
  margin: 0;
  font-style: italic;
}
.ex-trans {                       /* its translation, underneath */
  margin: 2px 0 0;
  color: var(--accent);
}

.expressions {
  margin-top: 16px;
  padding: 12px 16px;
  background: var(--bg);
  border-radius: 10px;
}
.expressions h3 {
  margin: 0 0 8px;
  font-size: .75rem;
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--muted);
}
.expressions .examples li {
  padding-left: 0;
  border-left: none;
}

/* ---- No results ---- */
.no-results {
  padding: 28px 24px;
  text-align: center;
  color: var(--muted);
  background: var(--surface);
  border: 1px dashed var(--line);
  border-radius: 14px;
}
.did-you-mean { margin-bottom: 22px; }
.did-you-mean p {
  margin: 0;
  color: var(--ink);
}
.suggestions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
  margin-top: 10px;
}
.suggestion {
  padding: 6px 14px;
  font-weight: 500;
  color: var(--accent);
  text-decoration: none;
  background: var(--accent-soft);
  border-radius: 999px;
  transition: background .15s, color .15s;
}
.suggestion:hover {
  color: #fff;
  background: var(--accent);
}
.not-yet {
  margin: 0;
  color: var(--ink);
}
.not-yet-note {
  margin: 6px 0 0;
  font-size: .9rem;
}

/* ---- Word family (same root) ---- */
.family {
  padding: 18px 24px 8px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-left: 4px solid var(--accent);
  border-radius: 14px;
}
.family h3 {
  margin: 0;
  font-size: .75rem;
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--muted);
}
.family .root {
  font-size: 1rem;
  letter-spacing: 0;
  text-transform: none;
  color: var(--ink);
}
.family .entry {               /* derived words: rows inside the block */
  padding: 16px 0 4px;
  border: none;
  border-top: 1px solid var(--line);
  border-radius: 0;
}
.family .entry:first-of-type { border-top: none; }
.family .headword { font-size: 1.5rem; }
.family .expressions h3 {      /* keep the label small inside the family block */
  margin: 0 0 8px;
}

.entry.match {                 /* the derived word the user searched */
  margin: 0 -12px;
  padding-left: 12px;
  padding-right: 12px;
  background: var(--accent-soft);
  border-radius: 10px;
}
.family-note {
  margin: 0;
  text-align: center;
  color: var(--muted);
}
.family-note strong { color: var(--ink); }

/* ---- Linked forms (izem → tasedda) ---- */
.form:not(:last-child)::after { content: ", "; }
.word-link {
  font-weight: 500;
  color: var(--accent);
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
}
.word-link:hover { text-decoration-thickness: 2px; }
