:root {
  --bg: #f4f7fb;
  --surface: #ffffff;
  --text: #1f2937;
  --muted: #6b7280;
  --accent: #0b6e4f;
  --accent-dark: #085a40;
  --border: #dbe3ef;
  --ad-bg: #eef2f7;
  --shadow: 0 8px 24px rgba(15, 23, 42, 0.08);
  --radius: 12px;
  --font: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: var(--font);
  color: var(--text);
  background: linear-gradient(180deg, #e8f3ee 0%, var(--bg) 220px);
  line-height: 1.6;
}

a {
  color: var(--accent);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

.layout {
  width: min(1100px, calc(100% - 2rem));
  margin: 0 auto;
  display: grid;
  grid-template-columns: 1fr 260px;
  grid-template-areas:
    "header header"
    "main sidebar"
    "footer footer";
  gap: 1.25rem;
  padding: 1rem 0 2rem;
}

.header {
  grid-area: header;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1rem 1.25rem;
}

.topmenu {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem 1.25rem;
  margin-bottom: 0.75rem;
}

.topmenu a {
  font-weight: 600;
}

.main {
  grid-area: main;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.5rem;
}

.sidebar {
  grid-area: sidebar;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.footer {
  grid-area: footer;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
}

.footer__grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 1rem;
}

.hero h1 {
  margin: 0 0 0.5rem;
  font-size: clamp(1.5rem, 3vw, 2rem);
  text-align: center;
}

.hero__subtitle {
  text-align: center;
  color: var(--muted);
  margin: 0;
}

.search-section {
  margin: 1.5rem 0;
  text-align: center;
}

.search_form {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  justify-content: center;
  margin-bottom: 0.75rem;
}

.translate_input {
  width: min(100%, 360px);
  padding: 0.85rem 1rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  font-size: 1rem;
}

.translate_button {
  padding: 0.85rem 1.4rem;
  border: 0;
  border-radius: 999px;
  background: var(--accent);
  color: #fff;
  font-weight: 700;
  cursor: pointer;
}

.translate_button:hover {
  background: var(--accent-dark);
}

.keyboard-hint,
.example,
.content-block {
  color: var(--muted);
}

.letter-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin: 1rem 0 1.5rem;
}

.letter-nav__link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 2rem;
  height: 2rem;
  padding: 0 0.5rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #f8fafc;
  font-weight: 700;
}

.letter-nav__link.is-active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.words_list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem 0.75rem;
  line-height: 1.9;
}

.words_list a {
  white-space: nowrap;
}

.search_results {
  padding: 0.75rem 0;
  border-bottom: 1px solid var(--border);
}

.word-page h1 {
  font-size: 1.25rem;
}

.similar-words h2 {
  font-size: 1.1rem;
  margin-top: 1.5rem;
}

.sidebar-box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
}

.sidebar-box__title {
  margin: 0 0 0.75rem;
  font-size: 1rem;
}

.sidebar-links {
  margin: 0;
  padding-left: 1.1rem;
}

.ad-slot {
  margin: 0.75rem 0;
  min-height: 90px;
}

.ad-slot--placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--ad-bg);
  border: 1px dashed var(--border);
  color: var(--muted);
  font-size: 0.85rem;
  border-radius: 8px;
}

.empty-state {
  padding: 1rem;
  background: #fff8e6;
  border: 1px solid #f2d98b;
  border-radius: 8px;
}

.breadcrumbs ol {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  list-style: none;
  margin: 0 0 1rem;
  padding: 0;
  font-size: 0.9rem;
  color: var(--muted);
}

.breadcrumbs li:not(:last-child)::after {
  content: "›";
  margin-left: 0.35rem;
  color: var(--border);
}

.pagination {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-top: 1.5rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
}

.pagination a {
  font-weight: 600;
}

.guide-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 1rem;
  margin: 1.25rem 0;
}

.guide-card {
  display: block;
  padding: 1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: #f8fafc;
}

.guide-card:hover {
  border-color: var(--accent);
  text-decoration: none;
}

.guide-card p {
  margin: 0.5rem 0 0;
  font-size: 0.9rem;
  color: var(--muted);
}

.guide-section {
  margin-top: 2rem;
}

.guide-note {
  color: var(--muted);
}

.table-wrap {
  overflow-x: auto;
  margin: 1rem 0;
}

.guide-table {
  width: 100%;
  border-collapse: collapse;
}

.guide-table th,
.guide-table td {
  padding: 0.65rem 0.85rem;
  border: 1px solid var(--border);
  text-align: left;
}

.guide-table th {
  background: #eef2f7;
}

.guide-table tbody tr:nth-child(even) {
  background: #fafbfc;
}

.muted {
  color: var(--muted);
  font-size: 0.9rem;
}

.names-filter {
  margin: 1rem 0;
}

.names-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 0.75rem;
}

.name-card {
  padding: 0.85rem 1rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fafbfc;
}

.name-card__title {
  font-weight: 700;
  font-size: 1.05rem;
}

.name-card__meaning {
  margin: 0.35rem 0 0;
  font-size: 0.9rem;
  color: var(--muted);
  font-style: italic;
}

.guide-source {
  margin-top: 1.5rem;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}

@media (max-width: 860px) {
  .layout {
    grid-template-columns: 1fr;
    grid-template-areas:
      "header"
      "main"
      "sidebar"
      "footer";
  }
}
