:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --ink: #1c2024;
  --muted: #6b7280;
  --line: #e6e8eb;
  --accent: #8a1c2b;       /* Latvian flag carmine red */
  --accent-soft: #f7e9eb;
  --hl: #a834f9;           /* highlighted Latvian fragment */
  --ending: #c0182a;       /* inflected ending */
  --radius: 12px;
  --maxw: 860px;
  --shadow: 0 1px 2px rgba(0,0,0,.04), 0 6px 24px rgba(0,0,0,.05);
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: #ffffff;
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-size: 17px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* ----------------------------- topbar ---------------------------- */

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  backdrop-filter: saturate(180%) blur(8px);
}
.topbar-inner {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 0 20px;
  height: 60px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: var(--ink);
  font-weight: 700;
}
.brand-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  background: var(--accent);
  color: #fff;
  border-radius: 9px;
  font-size: 15px;
  letter-spacing: .5px;
}
.brand-text { font-size: 17px; }

.lang-switch {
  display: inline-flex;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 3px;
}
.lang-switch button,
.lang-switch a {
  border: 0;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  padding: 5px 12px;
  border-radius: 999px;
  cursor: pointer;
  text-decoration: none;
  transition: background .15s, color .15s;
}
.lang-switch button:hover,
.lang-switch a:hover { color: var(--ink); }
.lang-switch button.active,
.lang-switch a.active {
  background: var(--accent);
  color: #fff;
}

/* top-bar search */
.topbar-right { display: flex; align-items: center; gap: 12px; }
.search-form { display: flex; }
.search-form input {
  font: inherit;
  font-size: 14px;
  width: 190px;
  max-width: 38vw;
  padding: 7px 13px;
  color: var(--ink);
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 999px;
  outline: none;
  transition: border-color .15s, background .15s;
}
.search-form input::placeholder { color: var(--muted); }
.search-form input:focus { border-color: var(--accent); background: #fff; }
.search-q { color: var(--muted); font-weight: 600; }

@media (max-width: 560px) {
  .search-form input { width: 130px; }
}

/* ------------------------------ page ----------------------------- */

.page {
  flex: 1;
  width: 100%;
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 28px 20px 64px;
}
.loading { color: var(--muted); }
.error {
  background: var(--accent-soft);
  color: var(--accent);
  padding: 16px;
  border-radius: var(--radius);
}

.crumbs {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  font-size: 14px;
  color: var(--muted);
  margin-bottom: 14px;
}
.crumb { color: var(--muted); text-decoration: none; }
.crumb:hover { color: var(--accent); }
.crumb.current { color: var(--ink); font-weight: 600; }
.crumb-sep { color: #c2c6cc; }

.page-title {
  font-size: 30px;
  line-height: 1.2;
  margin: 0 0 18px;
  letter-spacing: -.01em;
}

/* ------------------------------ home ----------------------------- */

.hero {
  padding: 12px 0 4px;
}
.hero-kicker {
  margin: 0 0 10px;
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .14em;
  color: var(--accent);
}
.hero-title {
  font-size: 38px;
  line-height: 1.1;
  letter-spacing: -.02em;
  margin: 0 0 12px;
}
.hero-tagline {
  font-size: 18px;
  color: #4b5158;
  margin: 0;
  max-width: 60ch;
}

.section-hint {
  margin: 30px 2px 14px;
  font-size: 13px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .07em;
  color: var(--muted);
}

.home-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  gap: 6px;
}
.home-card {
  --card-color: var(--accent);
  display: flex;
  gap: 15px;
  align-items: flex-start;
  background: transparent;
  border-radius: 14px;
  padding: 16px;
  text-decoration: none;
  color: var(--ink);
  transition: background .15s, transform .15s, box-shadow .15s;
}
.home-card:hover {
  background: var(--surface);
  transform: translateY(-2px);
  box-shadow: 0 1px 2px rgba(0,0,0,.04), 0 12px 28px rgba(0,0,0,.07);
}
.home-card:hover .home-card-title { color: var(--card-color); }
.home-card-icon {
  flex: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-top: 2px;
  transition: transform .15s;
}
.home-card:hover .home-card-icon { transform: scale(1.12) rotate(-4deg); }
.home-card-icon svg { width: 30px; height: 30px; }
.home-card-body { display: flex; flex-direction: column; gap: 4px; }
.home-card-title { font-size: 20px; font-weight: 700; letter-spacing: -.01em; }
.home-card-desc { font-size: 14px; line-height: 1.45; color: var(--muted); }

/* bonus link to the signs page */
.bonus-card {
  display: flex;
  gap: 15px;
  align-items: center;
  margin-top: 28px;
  padding: 16px;
  border-top: 1px solid var(--line);
  text-decoration: none;
  color: var(--ink);
  transition: transform .15s;
}
.bonus-card:hover { transform: translateX(3px); }
.bonus-card:hover .home-card-title { color: var(--accent); }
.bonus-kicker {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .12em;
  color: var(--accent);
  margin-bottom: 2px;
}

/* --------------------------- signs page -------------------------- */

.signs-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 6px;
  margin: 14px 0 8px;
}
.sign-item {
  display: flex;
  gap: 15px;
  align-items: flex-start;
  padding: 14px 16px;
  border-radius: 14px;
  transition: background .15s;
}
.sign-item:hover { background: var(--surface); box-shadow: 0 1px 2px rgba(0,0,0,.04), 0 12px 28px rgba(0,0,0,.07); }
.sign-item .home-card-icon { margin-top: 2px; }
.sign-item .home-card-icon svg { width: 34px; height: 34px; }
.sign-body { display: flex; flex-direction: column; gap: 3px; }
.sign-name { font-size: 18px; font-weight: 700; }
.sign-meaning { font-size: 14px; line-height: 1.5; color: var(--muted); }
.sign-note { margin-top: 18px; font-size: 13px; color: var(--muted); font-style: italic; }

.content > * + * { margin-top: 4px; }

.block-text { margin: 0 0 14px; }
.block-text.latvian { font-style: italic; color: #33373c; }

.block-title {
  font-size: 21px;
  margin: 30px 0 12px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--line);
}
.block-subtitle {
  font-size: 16px;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--muted);
  margin: 22px 0 10px;
}
.block-divider {
  border: 0;
  border-top: 1px solid var(--line);
  margin: 26px 0;
}
.block-link { margin: 12px 0; }
.inline-link {
  color: var(--accent);
  font-weight: 600;
  text-decoration: none;
}
.inline-link:hover { text-decoration: underline; }

/* highlighted Latvian fragment and inflected ending */
.hl { color: var(--hl); font-weight: 600; font-style: normal; }
.word { white-space: nowrap; }
.ending { color: var(--ending); font-weight: 700; }

/* --------------------------- pair lists -------------------------- */

.pair-list {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  margin: 12px 0;
  box-shadow: var(--shadow);
}
.pair {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  padding: 11px 16px;
  align-items: baseline;
}
.pair-three { grid-template-columns: 1fr 1fr 1.2fr; }
.pair + .pair { border-top: 1px solid var(--line); }
.pair-lv {
  font-weight: 600;
  color: var(--ink);
}
.pair-lv .latvian, .pair-lv { font-style: normal; }
.pair-tr { color: var(--muted); }

/* a stand-alone translation pair (single row) also gets the card look */
.content > .pair {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  margin: 12px 0;
  box-shadow: var(--shadow);
}

.examples-block { margin: 14px 0; }

/* ----------------------------- tables ---------------------------- */

.table-wrap { margin: 16px 0; }
.table-scroll {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.data-table {
  border-collapse: collapse;
  width: 100%;
  background: var(--surface);
  font-size: 15.5px;
}
.data-table th, .data-table td {
  padding: 10px 14px;
  text-align: left;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}
.data-table thead th {
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 700;
  font-size: 13.5px;
  text-transform: uppercase;
  letter-spacing: .04em;
}
.data-table tbody tr:last-child td { border-bottom: 0; }
.data-table tbody td:first-child { font-weight: 600; }
.data-table tbody tr:hover td { background: #fafbfc; }

/* ---------------------------- alphabet --------------------------- */

.alphabet-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(64px, 1fr));
  gap: 10px;
  margin: 16px 0;
}
.letter {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 12px 6px;
  text-align: center;
  box-shadow: var(--shadow);
}
.letter-up {
  display: block;
  font-size: 22px;
  font-weight: 700;
}
.letter-low {
  display: block;
  font-size: 14px;
  color: var(--muted);
}

/* --------------------- nav tiles (title + desc) ------------------ */

.nav-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 6px;
  margin: 14px 0;
}
.nav-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin: 14px 0;
}
.nav-card {
  display: flex;
  gap: 15px;
  align-items: flex-start;
  padding: 16px;
  border-radius: 14px;
  background: transparent;
  text-decoration: none;
  color: var(--ink);
  transition: background .15s, transform .15s, box-shadow .15s;
}
.nav-card:hover {
  background: var(--surface);
  transform: translateY(-2px);
  box-shadow: 0 1px 2px rgba(0,0,0,.04), 0 12px 28px rgba(0,0,0,.07);
}
.nav-card:hover .nav-card-title { color: var(--card-color, var(--accent)); }
.nav-card .home-card-icon { margin-top: 1px; }
.nav-card:hover .home-card-icon { transform: scale(1.12) rotate(-4deg); }
.nav-card-body { display: flex; flex-direction: column; gap: 4px; }
.nav-card-title { font-size: 19px; font-weight: 700; letter-spacing: -.01em; }
.nav-card-desc {
  font-size: 14px;
  line-height: 1.45;
  color: var(--muted);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* ----------------------------- buttons --------------------------- */

.btn-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 6px;
  margin: 14px 0;
}
.btn-grid.tiny {
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
}
.btn-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin: 14px 0;
}
.btn {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  background: transparent;
  border-radius: 14px;
  padding: 15px 16px;
  text-decoration: none;
  color: var(--ink);
  font-weight: 700;
  transition: background .15s, transform .15s, box-shadow .15s, color .15s;
}
.btn::after {
  content: '→';
  color: var(--accent);
  margin-left: 10px;
  transition: transform .15s;
}
.btn:hover {
  background: var(--surface);
  transform: translateY(-2px);
  color: var(--accent);
  box-shadow: 0 1px 2px rgba(0,0,0,.04), 0 12px 28px rgba(0,0,0,.07);
}
.btn:hover::after { transform: translateX(3px); }
.btn-grid.tiny .btn { padding: 12px 14px; font-size: 15px; }

.small-btn-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 6px;
  margin: 14px 0;
}
.small-btn {
  display: flex;
  flex-direction: column;
  gap: 2px;
  background: transparent;
  border-radius: 14px;
  padding: 14px 16px;
  text-decoration: none;
  color: var(--ink);
  transition: background .15s, transform .15s, box-shadow .15s;
}
.small-btn:hover {
  background: var(--surface);
  transform: translateY(-2px);
  box-shadow: 0 1px 2px rgba(0,0,0,.04), 0 12px 28px rgba(0,0,0,.07);
}
.small-btn:hover .small-btn-word { color: var(--accent); }
.small-btn-word { font-size: 19px; font-weight: 700; transition: color .15s; }
.small-btn-gloss { color: var(--ink); }
.small-btn-sub { font-size: 13px; color: var(--muted); }

/* ----------------------------- footer ---------------------------- */

.footer {
  border-top: 1px solid var(--line);
  background: var(--surface);
}
.footer-inner {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 20px;
  color: var(--muted);
  font-size: 14px;
}

/* ---------------------------- responsive ------------------------- */

@media (max-width: 560px) {
  body { font-size: 16px; }
  .page-title { font-size: 25px; }
  .pair { grid-template-columns: 1fr; gap: 2px; }
  .pair-three { grid-template-columns: 1fr 1fr; }
  .pair-three .pair-tr { grid-column: 1 / -1; }
  .brand-text { display: none; }
}
