:root {
  --bg: #f2f4f8;
  --card: #fff;
  --ink: #0f172a;
  --muted: #475569;
  --line: #eef1f5;
  --accent1: #e9eef7;
  --accent2: #dbe7ff;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  padding: 24px;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.55 system-ui, -apple-system, Segoe UI, Roboto, Arial;
}

/* Верхня навігація */
.topbar {
  position: static !important;
  z-index: 10;
  backdrop-filter: saturate(1.2) blur(8px);
  background: rgba(255, 255, 255, .7);
  border-bottom: 1px solid #e5e7eb;
}

.topbar-inner {
  max-width: 1100px;
  margin: 0 auto;
  display: flex;
  gap: 12px;
  align-items: center;
  padding: 8px 12px; /* reduced vertical padding */
  min-height: 40px;
}

/* ensure brand doesn't create extra vertical space */
.brand {
  font-weight: 700;
  line-height: 1;
  margin: 0;
  padding: 0;
}

nav a {
  display: inline-block;
  padding: 8px 10px;
  border-radius: 8px;
  text-decoration: none;
  color: #0f172a;
}

nav a.active,
nav a:hover {
  background: #eef2ff;
}

/* Основна частина */
main {
  margin: 24px auto;
  padding: 0 16px;
}

h1 {
  margin: 0 0 8px;
  font-size: 1.6rem;
}

h2 {
  margin: 24px 0 8px;
  font-size: 1.2rem;
}

/* Таблиці */
.table-wrap {
  overflow: auto;
  padding: 8px;
  background: #f6f8fb;
  border-radius: 12px;
}

.word-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  background: var(--card);
  border-radius: 12px;
  box-shadow: 0 6px 18px rgba(0, 0, 0, .06);
  font: 14px/1.5 system-ui, -apple-system, Segoe UI, Roboto, Arial;
}

.word-table th,
.word-table td {
  padding: 10px 14px;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
}

.word-table thead th {
  position: sticky;
  top: 0;
  z-index: 1;
  color: var(--ink);
  letter-spacing: .02em;
  text-align: left;
  background: linear-gradient(180deg, var(--accent1), var(--accent2));
  border-bottom: 1px solid #cbd5e1;
  text-transform: uppercase;
  font-size: .8rem;
}

.word-table tbody tr:nth-child(even) {
  background: #fafcff;
}

.word-table tbody tr:hover {
  background: #f1f6ff;
}

.word-table td:nth-child(1) {
  width: 48px;
  text-align: right;
  color: #334155;
}

.word-table td:nth-child(2) {
  font-weight: 600;
}

.word-table td:nth-child(3) {
  color: var(--muted);
}

.word-table td:nth-child(5) {
  font-style: italic;
}

.word-table td:nth-child(6) {
  color: var(--muted);
}

.word-table tr:last-child td {
  border-bottom: none;
}

/* Header controls */
/* Header controls */
/* Header controls */
.header-controls { 
  display: flex; 
  align-items: center; 
  gap: 8px; 
}

.icon-btn { 
  background: none; 
  border: 1px solid #ddd; 
  border-radius: 4px; 
  padding: 6px 8px; 
  cursor: pointer; 
  font-size: 16px;
  transition: background-color 0.2s;
}

.icon-btn:hover { 
  background: #f0f0f0; 
}

.status-text { 
  color: #666; 
  font-size: 0.8rem; 
  margin-left: 8px; 
}

/* Word interaction */
.word {
  cursor: pointer;
  text-decoration: underline dashed #bef264;
  text-underline-offset: 4px;
}

.learned { 
  text-decoration: line-through; 
  opacity: 0.6; 
}

.learn-btn {
  border: none;
  background: none;
  cursor: pointer;
  font-size: 1.1em;
  line-height: 1;
  margin: 0;
  padding: 4px 7px;
  border-radius: 6px;
  transition: background 0.12s;
}

.learn-btn.marked {
  background: #d1fae5;
  color: #065f46;
}

.german-example {
  cursor: pointer;
  text-decoration: underline dashed #bef264;
  text-underline-offset: 4px;
}

.noun-plural {
  cursor: pointer;
  text-decoration: underline dashed #bef264;
  text-underline-offset: 4px;
}

#hint { 
  color: #555; 
  font-size: 0.9rem; 
  margin-bottom: 10px; 
}

/* Мобільна адаптація */
@media (max-width: 720px) {
  body {
    padding: 10px;
  }
  .word-table {
    font-size: 13px;
  }
  .word-table th,
  .word-table td {
    padding: 8px 10px;
  }
  .word-table thead th {
    text-transform: none;
    font-size: .9rem;
  }
  .header-controls {
    gap: 4px;
  }
  .icon-btn {
    padding: 4px 6px;
    font-size: 14px;
  }
}

/* Progress bar in header */
.top-progress-wrap {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-left: 12px;
  min-width: 220px;
}

.top-progress {
  width: 180px;
  height: 10px;
  background: #eef1f5;
  border-radius: 999px;
  overflow: hidden;
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.5);
}

.top-progress > .fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #60a5fa, #3b82f6);
  transition: width 240ms ease;
}

#top-progress-text {
  font-size: 0.85rem;
  color: var(--muted);
  white-space: nowrap;
}

/* Compact header - reduce unused vertical space and let nav occupy space beside brand */
.topbar-inner {
  max-width: 1100px;
  margin: 0 auto;
  display: flex;
  gap: 12px;
  align-items: center;
  padding: 8px 12px; /* reduced vertical padding */
  min-height: 40px;
}

/* ensure brand doesn't create extra vertical space */
.brand {
  font-weight: 700;
  line-height: 1;
  margin: 0;
  padding: 0;
}

/* Mobile header / topbar compacting — overrides for small screens */
@media (max-width: 720px) {
  /* reduce overall page padding so header doesn't push content down */
  body {
    padding: 10px;
  }

  /* use two tight rows with min-content rows so height collapses to actual content */
  .topbar-inner {
    display: grid;
    grid-template-columns: auto 1fr auto;
    grid-template-rows: repeat(2, min-content);
    gap: 6px;              /* smaller gap */
    align-items: center;
    padding: 4px 8px;      /* even less padding on mobile */
    max-width: 100%;
  }

  /* brand in first row, left */
  .brand {
    grid-column: 1 / 2;
    grid-row: 1 / 2;
    font-size: 1rem;
    line-height: 1;
  }

  /* navigation occupies the rest of the first row and wraps horizontally */
  nav {
    grid-column: 2 / 4;
    grid-row: 1 / 2;
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    align-items: center;
    justify-content: flex-start;
    width: 100%;
    margin: 0;
  }

  nav a {
    padding: 6px 8px;
    font-size: 0.95rem;
    white-space: nowrap;
  }

  /* progress sits on the left of the second (compact) row */
  .top-progress-wrap {
    grid-column: 2 / 3;
    grid-row: 2 / 3;
    display: flex;
    align-items: center;
    gap: 8px;
    margin-left: 0;
    min-width: 120px;
    justify-self: start;
  }

  .top-progress {
    width: 140px;
    height: 8px;
  }

  .top-progress > .fill {
    transition: width 240ms ease;
  }

  #top-progress-text {
    font-size: 0.8rem;
    color: var(--muted);
    white-space: nowrap;
    max-width: 96px;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  /* controls (eye button, status) align to the right of second row */
  .header-controls {
    grid-column: 3 / 4;
    grid-row: 2 / 3;
    gap: 6px;
    align-items: center;
    justify-self: end;
  }

  .header-controls .status-text {
    display: none;
  }

  .icon-btn {
    padding: 4px 6px;
    font-size: 14px;
  }

  /* bring main content up closer to header */
  main {
    margin-top: 6px;
  }

  /* slightly more compact tables on mobile */
  .word-table {
    font-size: 13px;
  }

  .word-table th,
  .word-table td {
    padding: 8px 10px;
  }
}

/* responsive */
@media (max-width:720px) {
  .top-progress-wrap { min-width: 140px; gap: 8px; }
  .top-progress { width: 120px; height: 8px; }
  #top-progress-text { font-size: 0.8rem; }
}

/* Smaller progress bar on very small phones to avoid overlap with the eye button */
@media (max-width: 425px) {
  .top-progress-wrap {
    min-width: 0;
    gap: 6px;
    align-items: center;
  }

  /* make the bar narrower so it fits next to the eye button */
  .top-progress {
    width: 72px;
    height: 8px;
    flex: 0 0 72px;
  }

  /* shorten the text and make it able to shrink */
  #top-progress-text {
    font-size: 0.75rem;
    max-width: 66px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  /* ensure header controls (eye) stays visible and doesn't overlap */
  .header-controls {
    gap: 6px;
    z-index: 2;
  }

  /* slightly reduce nav link padding so header remains compact */
  nav a {
    padding: 6px 6px;
  }
}

@media (max-width: 375px) {
  .top-progress {
    width: 26px;
    height: 6px;
    flex: 0 0 26px;
  }
}