* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; font-family: "Nunito", system-ui, sans-serif; color: #1f2937; background: #f3f4f6; }
body { display: flex; flex-direction: column; min-height: 100vh; }

.menu-header {
  display: grid; grid-template-columns: 1fr auto auto; align-items: center; gap: 24px;
  padding: 20px 32px;
  background: #fff;
  border-bottom: 1px solid #e5e7eb;
}
.menu-header h1 { margin: 0; font-size: 22px; font-weight: 800; }
.beta-badge {
  display: inline-block; vertical-align: middle;
  margin-left: 6px;
  padding: 2px 8px;
  font-size: 10px; font-weight: 800; letter-spacing: 0.06em; text-transform: uppercase;
  background: #ede9fe; color: #6d28d9;
  border-radius: 999px;
}

.user-area { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.user-area .username { font-weight: 700; }
.user-area .admin-badge {
  display: inline-block; padding: 2px 8px; margin-left: 6px;
  font-size: 11px; font-weight: 700;
  border-radius: 999px; background: #fef3c7; color: #92400e;
}
.user-area .small { font-size: 12px; }
.overall-stats { display: flex; gap: 18px; }
.overall-stats .stat { display: flex; flex-direction: column; align-items: center; gap: 2px; }
.overall-stats .num { font-size: 22px; font-weight: 800; color: #2563eb; line-height: 1; }
.overall-stats .stat.streak .num { color: #ea580c; }
.overall-stats .stat.perfect .num { color: #16a34a; }
.overall-stats .stat.today .num { color: #7c3aed; }
.overall-stats .lbl { font-size: 11px; color: #6b7280; text-transform: lowercase; }
.annotator-link {
  padding: 8px 14px; border: 1px solid #d1d5db; background: #fff; border-radius: 6px;
  text-decoration: none; color: #1f2937; font: inherit; font-size: 14px;
}
.annotator-link:hover { background: #f9fafb; }

.menu-main { flex: 1; display: flex; flex-direction: column; }

/* Chat-invite banner between header and tabs */
.chat-callout {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 32px;
  background: linear-gradient(90deg, #0088cc 0%, #229ED9 100%);
  color: #fff; text-decoration: none;
  font-size: 14px; line-height: 1.3;
  transition: background 0.15s, filter 0.15s;
}
.chat-callout:hover { filter: brightness(1.08); }
.chat-callout .chat-emoji { font-size: 20px; flex-shrink: 0; }
.chat-callout .chat-text { flex: 1; min-width: 0; }
.chat-callout .chat-text b { font-weight: 800; }
.chat-callout .chat-cta {
  flex-shrink: 0;
  background: rgba(255, 255, 255, 0.22);
  padding: 5px 12px; border-radius: 999px;
  font-size: 12px; font-weight: 700; white-space: nowrap;
}
@media (max-width: 600px) {
  .chat-callout { padding: 8px 16px; gap: 8px; font-size: 13px; }
  .chat-callout .chat-text { font-size: 12px; }
  .chat-callout .chat-cta { padding: 4px 10px; font-size: 11px; }
}

/* Tabs (Cards / Words) */
.menu-tabs {
  display: flex; gap: 0;
  padding: 0 32px;
  background: #fff;
  border-bottom: 1px solid #e5e7eb;
  position: sticky; top: 0; z-index: 5;
}
.menu-tabs .tab {
  padding: 12px 18px;
  background: transparent; border: 0;
  font: inherit; font-size: 15px; font-weight: 600; color: #6b7280;
  cursor: pointer;
  border-bottom: 3px solid transparent;
  margin-bottom: -1px;
  transition: color 0.15s, border-color 0.15s;
}
.menu-tabs .tab:hover { color: #1f2937; }
.menu-tabs .tab.active {
  color: #2563eb;
  border-bottom-color: #2563eb;
}
.tab-pane.hidden { display: none; }

/* Tiny pill that hangs off a tab label to show overdue-word count. */
.menu-tabs .tab .tab-badge {
  display: inline-flex; align-items: center; justify-content: center;
  margin-left: 6px; min-width: 18px; height: 18px;
  padding: 0 5px; border-radius: 999px;
  background: #ea580c; color: #fff;
  font-size: 11px; font-weight: 800; line-height: 1;
}
.menu-tabs .tab .tab-badge.hidden { display: none; }

/* "Повторение" tab — list + start button. */
.review-tab-content { padding: 24px 32px; max-width: 720px; margin: 0 auto; }
.review-tab-content .review-empty {
  padding: 40px 16px; text-align: center; color: #4b5563;
}
.review-tab-content .review-empty .emoji { font-size: 40px; display: block; margin-bottom: 12px; }
.review-tab-content .review-empty h3 { margin: 0 0 6px; font-size: 18px; color: #1f2937; }
.review-tab-content .review-empty .muted { font-size: 14px; color: #6b7280; }

.review-tab-content .review-summary-box {
  background: linear-gradient(135deg, #fff7ed 0%, #ffedd5 100%);
  border: 1px solid #fed7aa; border-radius: 12px;
  padding: 20px 24px; margin-bottom: 16px;
}
.review-tab-content .review-summary-box h2 {
  margin: 0 0 6px; font-size: 22px; font-weight: 800; color: #c2410c;
}
.review-tab-content .review-summary-box .review-sub {
  margin: 0 0 14px; font-size: 14px; color: #6b7280;
}
.review-tab-content .review-freshness {
  display: inline-flex; align-items: center; gap: 8px;
  margin: 0 0 14px; padding: 6px 12px;
  background: #fff; border: 1px solid #fed7aa; border-radius: 8px;
  font-size: 13px; color: #4b5563;
}
.review-tab-content .review-freshness-icon { font-size: 14px; }
.review-tab-content .review-freshness-text b {
  font-weight: 800; color: #ea580c; font-variant-numeric: tabular-nums;
}
.review-tab-content .review-freshness .muted { color: #9ca3af; font-weight: 500; }
.review-mode-switch {
  display: inline-flex; gap: 0;
  margin: 0 0 14px;
  border: 1px solid #fed7aa; border-radius: 999px;
  background: #fff;
  padding: 3px;
}
.review-mode-switch .review-mode-btn {
  padding: 7px 14px;
  background: transparent; border: 0; border-radius: 999px;
  font: inherit; font-size: 13px; font-weight: 700; color: #9a3412;
  cursor: pointer; transition: background 0.15s, color 0.15s;
}
.review-mode-switch .review-mode-btn:hover:not(.active) { background: #fff7ed; }
.review-mode-switch .review-mode-btn.active {
  background: linear-gradient(90deg, #f97316 0%, #ea580c 100%);
  color: #fff;
}

/* Pickers for total words + words-per-round. Compact pill buttons next to
   the mode switch. Disabled state means "more than the queue contains". */
.review-pickers {
  display: flex; flex-direction: column; gap: 8px;
  margin: 0 0 14px;
}
.review-picker { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.review-picker .picker-label {
  font-size: 13px; font-weight: 600; color: #6b7280;
  min-width: 110px;
}
.review-picker .picker-row { display: inline-flex; gap: 4px; flex-wrap: wrap; }
.review-picker .picker-btn {
  min-width: 36px; padding: 5px 10px;
  background: #fff; border: 1px solid #e5e7eb; border-radius: 8px;
  font: inherit; font-size: 13px; font-weight: 700; color: #4b5563;
  cursor: pointer; transition: background 0.12s, border-color 0.12s, color 0.12s;
}
.review-picker .picker-btn:hover:not(.active):not(.disabled) {
  background: #fff7ed; border-color: #fed7aa;
}
.review-picker .picker-btn.active {
  background: #fed7aa; border-color: #fb923c; color: #9a3412;
}
.review-picker .picker-btn.disabled {
  opacity: 0.4; cursor: not-allowed;
}
.review-tab-content .review-start-btn {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 10px 22px;
  background: linear-gradient(90deg, #f97316 0%, #ea580c 100%);
  color: #fff; border: 0; border-radius: 999px;
  font: inherit; font-size: 15px; font-weight: 700;
  cursor: pointer; transition: filter 0.15s;
}
.review-tab-content .review-start-btn:hover { filter: brightness(1.08); }

.review-tab-content .review-list {
  list-style: none; padding: 0; margin: 8px 0 0;
  border: 1px solid #e5e7eb; border-radius: 10px; background: #fff;
}
.review-tab-content .review-list li {
  display: flex; align-items: baseline; gap: 12px;
  padding: 10px 14px; border-bottom: 1px solid #f3f4f6;
}
.review-tab-content .review-list li:last-child { border-bottom: 0; }
.review-tab-content .review-list .gr {
  font-weight: 700; color: #15803d; min-width: 0; flex: 1;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.review-tab-content .review-list .meta {
  font-size: 12px; color: #6b7280; font-variant-numeric: tabular-nums;
  flex-shrink: 0; white-space: nowrap;
}
.review-tab-content .review-list-title {
  margin: 18px 0 6px; font-size: 13px; font-weight: 700;
  color: #6b7280; text-transform: uppercase; letter-spacing: 0.04em;
}
.review-tab-content .review-list-more {
  font-weight: 500; text-transform: none; letter-spacing: 0; color: #9ca3af;
}

/* Funnel — distribution of words by best_streak. Collapsible <details> so
   users can hide it once they've seen it. Each row colour-codes the bucket. */
.srs-funnel {
  margin: 20px 0 4px;
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 12px;
  padding: 0;
}
.srs-funnel-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 16px;
  font-size: 13px; font-weight: 700; color: #4b5563;
  text-transform: uppercase; letter-spacing: 0.04em;
  cursor: pointer; user-select: none;
  list-style: none;
}
.srs-funnel-head::-webkit-details-marker { display: none; }
.srs-funnel-head::after {
  content: '▾'; color: #9ca3af; font-size: 14px;
  transition: transform 0.15s;
}
.srs-funnel[open] .srs-funnel-head::after { transform: rotate(180deg); }
.srs-funnel-total {
  font-size: 12px; font-weight: 600; color: #6b7280;
  text-transform: none; letter-spacing: 0;
}
.srs-funnel-body { padding: 4px 16px 16px; }
.srs-funnel-row {
  display: grid;
  grid-template-columns: 180px 1fr 200px;
  gap: 14px;
  align-items: center;
  padding: 7px 0;
}
.srs-funnel-row.is-empty { opacity: 0.45; }
.srs-funnel-meta { display: flex; flex-direction: column; gap: 1px; }
.srs-funnel-key {
  font-size: 10px; font-weight: 700; color: #9ca3af;
  text-transform: uppercase; letter-spacing: 0.05em;
}
.srs-funnel-label { font-size: 14px; font-weight: 700; color: #1f2937; }
.srs-funnel-bar-wrap {
  position: relative; height: 22px;
  background: #f3f4f6; border-radius: 6px;
  overflow: hidden;
}
.srs-funnel-bar {
  height: 100%; min-width: 4px;
  background: linear-gradient(90deg, #f97316 0%, #ea580c 100%);
  border-radius: 6px;
  transition: width 0.3s;
}
.srs-funnel-count {
  position: absolute; right: 8px; top: 50%; transform: translateY(-50%);
  font-size: 12px; font-weight: 800; color: #1f2937;
  font-variant-numeric: tabular-nums;
  text-shadow: 0 0 6px #fff, 0 0 6px #fff;
}
.srs-funnel-desc { font-size: 12px; color: #6b7280; }
.srs-funnel-foot {
  margin-top: 10px; padding-top: 10px;
  border-top: 1px dashed #e5e7eb;
  font-size: 12px; color: #6b7280; font-style: italic;
}

/* Bucket colour grading — red→orange for unsteady, green→blue for mastered. */
.srs-funnel-row[data-bucket="0"]   .srs-funnel-bar { background: linear-gradient(90deg, #ef4444, #dc2626); }
.srs-funnel-row[data-bucket="1"]   .srs-funnel-bar { background: linear-gradient(90deg, #f97316, #ea580c); }
.srs-funnel-row[data-bucket="2"]   .srs-funnel-bar { background: linear-gradient(90deg, #f59e0b, #d97706); }
.srs-funnel-row[data-bucket="3"]   .srs-funnel-bar { background: linear-gradient(90deg, #84cc16, #65a30d); }
.srs-funnel-row[data-bucket="4–5"] .srs-funnel-bar { background: linear-gradient(90deg, #10b981, #059669); }
.srs-funnel-row[data-bucket="6+"]  .srs-funnel-bar { background: linear-gradient(90deg, #06b6d4, #0891b2); }

@media (max-width: 600px) {
  .srs-funnel-row {
    grid-template-columns: 1fr;
    gap: 4px;
    padding: 10px 0;
  }
  .srs-funnel-desc { font-size: 11px; }
}

@media (max-width: 600px) {
  .review-tab-content { padding: 16px; }
  .review-tab-content .review-summary-box { padding: 16px; }
  .review-tab-content .review-summary-box h2 { font-size: 19px; }
}

/* «Мой прогресс» tab */
.stats-content { padding: 16px 32px 32px; max-width: 1100px; margin: 0 auto; }
.stats-summary {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px; margin-bottom: 20px;
}
.stats-card {
  background: #fff; border: 1px solid #e5e7eb; border-radius: 12px;
  padding: 14px 18px;
  display: flex; flex-direction: column; gap: 4px;
  position: relative; overflow: hidden;
}
.stats-card .num {
  font-size: 32px; font-weight: 800; line-height: 1;
  font-variant-numeric: tabular-nums;
  color: #2563eb;
}
.stats-card .lbl { font-size: 12px; color: #6b7280; text-transform: lowercase; }
.stats-card .sub { font-size: 11px; color: #4b5563; margin-top: 4px; line-height: 1.4; }
.stats-card .sub .muted { color: #9ca3af; }
.stats-card.today   .num { color: #7c3aed; }
.stats-card.acc     .num { color: #16a34a; }
.stats-card.streak  .num { color: #ea580c; }
.stats-card.learned .num { color: #2563eb; }

.stats-section {
  background: #fff; border: 1px solid #e5e7eb; border-radius: 12px;
  padding: 16px 20px; margin-bottom: 16px;
}
.stats-section h3 {
  margin: 0 0 12px; font-size: 14px; font-weight: 800; color: #1f2937;
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
}
.stats-section h3 .legend {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 11px; font-weight: 600; color: #6b7280;
}
.stats-section h3 .hint { font-weight: 500; color: #9ca3af; font-size: 11px; }
.stats-section h3 .legend .dot {
  display: inline-block; width: 8px; height: 8px; border-radius: 999px;
}
.stats-section h3 .legend .dot.ok  { background: #16a34a; }
.stats-section h3 .legend .dot.err { background: #dc2626; }

/* Heatmap */
.hm-wrap { display: flex; flex-direction: column; gap: 8px; }
.heatmap { max-width: 100%; height: auto; }
.heatmap .hm-month { font: 10px Nunito, sans-serif; fill: #6b7280; }
.heatmap .hm   { fill: #ebedf0; cursor: pointer; }
.heatmap .hm-0 { fill: #ebedf0; }
.heatmap .hm-1 { fill: #c6f6d5; }
.heatmap .hm-2 { fill: #68d391; }
.heatmap .hm-3 { fill: #2f855a; }
.heatmap .hm-4 { fill: #1c4532; }
.hm-legend {
  display: flex; align-items: center; gap: 4px;
  font-size: 11px; color: #6b7280;
}
.hm-legend .hm-sw { display: inline-block; width: 12px; height: 12px; border-radius: 2px; }
.hm-legend .hm-0 { background: #ebedf0; }
.hm-legend .hm-1 { background: #c6f6d5; }
.hm-legend .hm-2 { background: #68d391; }
.hm-legend .hm-3 { background: #2f855a; }
.hm-legend .hm-4 { background: #1c4532; }

/* Charts (bar + line) */
.chart { width: 100%; height: auto; max-height: 220px; }
.chart .grid { stroke: #f3f4f6; stroke-width: 1; }
.chart .ax-lbl { font: 10px Nunito, sans-serif; fill: #6b7280; }
.chart .bar-ok  { fill: #16a34a; }
.chart .bar-err { fill: #dc2626; }
.chart .line { fill: none; stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }

/* Records */
.stats-section.records ul { list-style: none; padding: 0; margin: 0; }
.stats-section.records li {
  padding: 6px 0; border-bottom: 1px dashed #f3f4f6;
  font-size: 14px; color: #1f2937;
}
.stats-section.records li:last-child { border-bottom: 0; }
.stats-section.records .muted { color: #9ca3af; font-size: 12px; }

/* Table */
.stats-table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 13px; }
.stats-table th, .stats-table td {
  padding: 7px 12px; text-align: left;
  border-bottom: 1px solid #f3f4f6;
}
.stats-table th {
  font-size: 11px; font-weight: 700; text-transform: uppercase; color: #4b5563;
  background: #f9fafb;
}
.stats-table .num { text-align: right; font-variant-numeric: tabular-nums; }
.stats-table tr.empty td { color: #9ca3af; }
.stats-table tr:last-child td { border-bottom: 0; }
.stats-table .accuracy.good { color: #15803d; font-weight: 700; }
.stats-table .accuracy.mid  { color: #d97706; font-weight: 700; }
.stats-table .accuracy.bad  { color: #dc2626; font-weight: 700; }
.stats-table .delta-cell { text-align: right; }

.delta {
  display: inline-block;
  padding: 1px 7px; border-radius: 999px;
  font-size: 11px; font-weight: 700;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.delta.up   { background: #dcfce7; color: #15803d; }
.delta.down { background: #fee2e2; color: #b91c1c; }
.delta.same { background: #f3f4f6; color: #6b7280; }

@media (max-width: 700px) {
  .stats-content { padding: 12px 16px 24px; }
  .stats-summary { grid-template-columns: 1fr 1fr; }
  .stats-card .num { font-size: 26px; }
  .stats-section { padding: 12px 14px; }
  .stats-table { font-size: 12px; }
  .stats-table th, .stats-table td { padding: 6px 8px; }
}

/* Words list view */
.words-summary {
  display: flex; gap: 10px;
  padding: 16px 32px 0;
  flex-wrap: wrap;
}
.words-summary .ws-card {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  background: #fff; border: 1px solid #e5e7eb; border-radius: 10px;
  padding: 8px 16px; min-width: 110px;
}
.words-summary .ws-card .ws-num {
  font-size: 22px; font-weight: 800; color: #2563eb;
  font-variant-numeric: tabular-nums; line-height: 1;
}
.words-summary .ws-card .ws-lbl {
  font-size: 11px; color: #6b7280; margin-top: 4px; white-space: nowrap;
}
.words-summary .ws-card.learned  .ws-num { color: #16a34a; }
.words-summary .ws-card.learning .ws-num { color: #d97706; }
.words-summary .ws-card.new      .ws-num { color: #6b7280; }

.words-toolbar {
  display: flex; gap: 10px; padding: 12px 32px 0; align-items: center; flex-wrap: wrap;
}
.words-toolbar input[type="search"] {
  flex: 1; min-width: 220px;
  padding: 8px 12px; border: 1px solid #d1d5db; border-radius: 8px;
  font: inherit; font-size: 14px;
}
.words-toolbar .phrase-toggle {
  display: flex; align-items: center; gap: 6px;
  font-size: 13px; color: #4b5563; cursor: pointer;
  padding: 6px 10px; border: 1px solid #d1d5db; border-radius: 8px;
  background: #fff;
  user-select: none; white-space: nowrap;
}
.words-toolbar .phrase-toggle input { margin: 0; }
.words-toolbar .phrase-toggle:has(input:not(:checked)) {
  background: #f3f4f6; color: #6b7280;
}
.words-sort {
  display: flex; flex-wrap: wrap; gap: 6px;
}
.words-sort .sort-btn {
  padding: 7px 12px;
  border: 1px solid #d1d5db; border-radius: 999px;
  background: #fff; color: #4b5563;
  font: inherit; font-size: 12px; font-weight: 600;
  cursor: pointer;
  transition: all 0.12s;
  white-space: nowrap;
}
.words-sort .sort-btn:hover { background: #f9fafb; color: #1f2937; }
.words-sort .sort-btn.active {
  background: #2563eb; color: #fff; border-color: #2563eb;
}

.words-list {
  padding: 12px 32px 24px;
  display: grid; gap: 6px;
}
.word-row {
  background: #fff; border: 1px solid #e5e7eb; border-radius: 10px;
  padding: 10px 14px;
  display: grid;
  grid-template-columns: minmax(0, 2fr) minmax(0, 2fr) minmax(0, 3fr) auto auto;
  gap: 12px; align-items: center;
}
.word-row.learned { border-left: 4px solid #16a34a; }
.word-row.learning { border-left: 4px solid #f59e0b; }
.word-row.started { border-left: 4px solid #2563eb; }
.word-row.new { border-left: 4px solid #d1d5db; }

.word-row .word-gr { font-weight: 800; font-size: 16px; color: #15803d; }
.word-row .word-ru { color: #1f2937; font-weight: 500; }
.word-row .kind-tag {
  display: inline-block;
  margin-left: 8px;
  padding: 1px 7px;
  font-size: 10px; font-weight: 700; letter-spacing: 0.02em;
  background: #ede9fe; color: #6d28d9;
  border-radius: 999px;
  vertical-align: middle;
}
/* Inline 🔊 next to each Greek word — understated, brightens on hover. */
.word-row .audio-btn.speak-word {
  appearance: none; -webkit-appearance: none;
  background: none; border: 0; padding: 0 4px; margin: 0;
  font: inherit; font-size: 12px; line-height: 1;
  cursor: pointer; color: inherit;
  opacity: 0.4;
  transition: opacity 0.12s;
  vertical-align: middle;
}
.word-row .audio-btn.speak-word:hover { opacity: 1; }
.word-row .audio-btn.speak-word:focus { outline: none; }
.word-row .audio-btn.speak-word:focus-visible { outline: 1px dotted #9ca3af; outline-offset: 2px; opacity: 1; }
/* No Greek voice on this device → hide all speaker affordances. */
body.no-voice .audio-btn,
body.no-voice .target-speak,
body.no-voice .sr-speak,
body.no-voice .sr-audio-toggle { display: none !important; }
.word-row.is-phrase .word-gr { font-weight: 600; font-size: 14px; }
.word-row .word-en {
  color: #6b7280; font-size: 12px; display: block; margin-top: 2px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.word-row .word-cards { display: flex; flex-wrap: wrap; gap: 4px; }
.word-row .word-card-link {
  display: inline-block; padding: 2px 8px;
  background: #f3f4f6; color: #4b5563; text-decoration: none;
  border-radius: 999px; font-size: 11px; font-weight: 600;
  border: 1px solid transparent;
  transition: all 0.12s;
}
.word-row .word-card-link:hover { background: #dbeafe; color: #1d4ed8; border-color: #93c5fd; }
.word-row .word-card-link.unann { opacity: 0.6; }
.word-row .word-card-link.card-learned { background: #dcfce7; color: #15803d; }
.word-row .word-card-link.card-learning { background: #fef3c7; color: #92400e; }

.word-row .word-counts {
  display: flex; gap: 8px;
  font-variant-numeric: tabular-nums; font-size: 13px;
  white-space: nowrap;
}
.word-row .word-counts .ok { color: #16a34a; font-weight: 600; }
.word-row .word-counts .err { color: #dc2626; font-weight: 600; }

.word-row .word-status {
  font-size: 12px; font-weight: 700;
  white-space: nowrap;
  padding: 4px 10px; border-radius: 999px;
  text-align: center; min-width: 90px;
}
.word-row.learned  .word-status { background: #dcfce7; color: #15803d; }
.word-row.learning .word-status { background: #fef3c7; color: #92400e; }
.word-row.started  .word-status { background: #dbeafe; color: #1d4ed8; }
.word-row.new      .word-status { background: #f3f4f6; color: #6b7280; }

@media (max-width: 800px) {
  .menu-tabs { padding: 0 16px; }
  .words-summary { padding: 12px 16px 0; gap: 6px; }
  .words-summary .ws-card { flex: 1; min-width: 0; padding: 6px 8px; }
  .words-summary .ws-card .ws-num { font-size: 18px; }
  .words-summary .ws-card .ws-lbl { font-size: 10px; }
  .words-toolbar { padding: 8px 16px 0; }
  .words-list { padding: 12px 16px 24px; }
  .word-row {
    grid-template-columns: 1fr 1fr;
    grid-template-rows: auto auto auto;
    gap: 6px;
  }
  .word-row .word-cards { grid-column: 1 / -1; }
  .word-row .word-counts { grid-column: 1; }
  .word-row .word-status { grid-column: 2; justify-self: end; }
}
.cards-toolbar {
  display: flex; gap: 10px; padding: 16px 32px 0; align-items: center; flex-wrap: wrap;
}

.menu-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
  padding: 16px 32px 24px;
}

.tile {
  background: #fff; border-radius: 12px; overflow: hidden;
  border: 1px solid #e5e7eb;
  cursor: pointer; text-decoration: none; color: inherit;
  display: flex; flex-direction: column;
  transition: transform 0.12s, box-shadow 0.12s;
  position: relative;
}
.tile:hover { transform: translateY(-2px); box-shadow: 0 6px 18px rgba(0,0,0,0.08); }
.tile.disabled { opacity: 0.6; }
.tile.disabled:hover { transform: none; box-shadow: none; }

.tile.unannotated .thumb { filter: grayscale(1); opacity: 0.65; }
.tile.unannotated .title { color: #6b7280; }
.tile.unannotated:hover .thumb { filter: grayscale(0.5); opacity: 0.85; }

.tile .thumb {
  width: 100%; aspect-ratio: 3/2; background: #f3f4f6;
  object-fit: cover; object-position: center;
  display: block;
}
.tile .body {
  padding: 10px 14px;
  display: flex; flex-direction: column; gap: 4px;
}
.tile .title { font-weight: 700; font-size: 15px; }
.tile .meta { font-size: 12px; color: #6b7280; display: flex; gap: 12px; flex-wrap: wrap; }
.tile .meta .item-count::before { content: ""; }

/* Top-left corner overlays — favorite star + popularity / record bubble
   share a flex row so they sit side-by-side regardless of which is present. */
.tile .tile-tl {
  position: absolute; top: 8px; left: 8px;
  display: flex; align-items: center; gap: 6px;
  z-index: 2;
}

/* Favorite-star button. Filled gold when set, hollow gray otherwise. */
.tile .fav-star {
  width: 28px; height: 28px;
  display: flex; align-items: center; justify-content: center;
  background: rgba(255, 255, 255, 0.95);
  border-radius: 999px;
  font-size: 17px;
  line-height: 1;
  cursor: pointer;
  color: #9ca3af;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12);
  transition: color 0.15s, transform 0.1s, background 0.15s;
  user-select: none;
  flex-shrink: 0;
}
.tile .fav-star:hover  { color: #f59e0b; transform: scale(1.08); }
.tile .fav-star:active { transform: scale(0.92); }
.tile .fav-star.is-fav { color: #f59e0b; }
.tile .fav-star.busy   { opacity: 0.5; cursor: wait; }
.tile .fav-star:focus-visible {
  outline: 2px solid #2563eb;
  outline-offset: 2px;
}

/* Total-plays-across-all-users bubble. Gets a golden tint + trophy when
   the current user holds the lifetime record for this card. */
.tile .pop-bubble {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 4px 10px;
  background: rgba(255, 255, 255, 0.95);
  color: #1f2937;
  border-radius: 999px;
  font-size: 12px; font-weight: 700;
  font-variant-numeric: tabular-nums;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.08);
  pointer-events: none;
}
.tile .pop-bubble .ico    { font-size: 12px; line-height: 1; }
.tile .pop-bubble .trophy { font-size: 14px; line-height: 1; }
.tile .pop-bubble.is-record {
  background: linear-gradient(135deg, #fef3c7 0%, #fde68a 100%);
  color: #78350f;
  box-shadow: 0 1px 3px rgba(180, 83, 9, 0.25);
}
.tile .badge {
  position: absolute; top: 8px; right: 8px;
  padding: 4px 10px; border-radius: 999px; font-size: 11px; font-weight: 700;
  background: rgba(255,255,255,0.95);
}
.tile .badge.unmarked { background: #fef3c7; color: #92400e; }
.tile .badge.unplayed { background: #e5e7eb; color: #4b5563; }
.tile .badge.played   { background: #dbeafe; color: #1d4ed8; }
.tile .badge.perfect  { background: #dcfce7; color: #15803d; }

.tile .stats-row { font-size: 12px; color: #4b5563; display: flex; gap: 12px; margin-top: 2px; }
.tile .stats-row .ok { color: #15803d; font-weight: 600; }
.tile .stats-row .err { color: #dc2626; }

/* «🏆 Лидер дня» plaque — shows fastest play of the day on the tile */
.tile .tile-leader {
  display: flex; align-items: center; gap: 6px;
  margin-top: 4px; padding: 4px 8px;
  background: linear-gradient(90deg, #fef3c7 0%, #fde68a 100%);
  border-radius: 6px;
  font-size: 11px; font-weight: 600;
  color: #92400e;
  font-variant-numeric: tabular-nums;
  overflow: hidden;
}
.tile .tile-leader .tl-ico { font-size: 13px; flex-shrink: 0; }
.tile .tile-leader .tl-name {
  flex: 1; min-width: 0; font-weight: 800;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.tile .tile-leader .tl-time { font-weight: 700; }
.tile .tile-leader .tl-err { color: #b91c1c; font-weight: 700; }

/* Learning-progress bar on each tile (best-streak / 3) */
.tile .learn-progress {
  display: flex; align-items: center; gap: 8px;
  margin-top: 6px;
}
.tile .learn-bar {
  flex: 1; height: 8px;
  background: #e5e7eb; border-radius: 999px;
  overflow: hidden;
}
.tile .learn-fill {
  height: 100%; background: #2563eb;
  transition: width 0.3s ease-out;
}
.tile .learn-pct {
  font-size: 11px; font-weight: 700; color: #4b5563;
  font-variant-numeric: tabular-nums;
  min-width: 30px; text-align: right;
}
.tile .learn-progress.complete .learn-fill { background: #16a34a; }
.tile .learn-progress.complete .learn-pct { color: #15803d; }

.link-btn {
  background: none; border: 0; color: #6b7280; font: inherit; font-size: 13px;
  cursor: pointer; text-decoration: underline;
  padding: 0;
}
.link-btn:hover { color: #2563eb; }

/* Leaderboard */
.leaderboard {
  padding: 12px 32px 32px;
}
.leaderboard h2 { margin: 0; font-size: 18px; font-weight: 800; }
.leaderboard-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; flex-wrap: wrap; margin-bottom: 12px;
}
.lb-tabs { display: flex; gap: 6px; }
.lb-tabs .lb-tab {
  padding: 6px 14px; border-radius: 999px;
  border: 1px solid #d1d5db; background: #fff;
  font: inherit; font-size: 12px; font-weight: 700;
  color: #4b5563; cursor: pointer;
  transition: all 0.12s;
}
.lb-tabs .lb-tab:hover { background: #f9fafb; color: #1f2937; }
.lb-tabs .lb-tab.active { background: #2563eb; border-color: #2563eb; color: #fff; }
.leaderboard-table {
  width: 100%;
  background: #fff; border: 1px solid #e5e7eb; border-radius: 10px;
  border-collapse: separate; border-spacing: 0;
  overflow: hidden;
}
.leaderboard-table th, .leaderboard-table td {
  padding: 10px 14px; text-align: left;
  border-bottom: 1px solid #f3f4f6;
  font-size: 14px;
}
.leaderboard-table th { background: #f9fafb; font-weight: 700; color: #4b5563; font-size: 12px; text-transform: uppercase; }
.leaderboard-table tr:last-child td { border-bottom: 0; }
.leaderboard-table .rank { width: 40px; color: #6b7280; font-weight: 700; }
.leaderboard-table .num { text-align: right; font-variant-numeric: tabular-nums; }
.leaderboard-table tr.me td { background: #dbeafe; font-weight: 600; }
.leaderboard-table tr.me .rank { color: #1d4ed8; }
.leaderboard-table .actions { width: 32px; text-align: right; }
.leaderboard-table .del-user {
  background: transparent; border: 1px solid transparent;
  color: #9ca3af; font-size: 18px; line-height: 1;
  width: 24px; height: 24px;
  border-radius: 6px; cursor: pointer;
  padding: 0;
  transition: all 0.12s;
}
.leaderboard-table .del-user:hover {
  background: #fee2e2; color: #dc2626; border-color: #fecaca;
}
.leaderboard-table .del-user:disabled { opacity: 0.4; cursor: wait; }
.leaderboard-table .admin-badge {
  display: inline-block; padding: 1px 6px; margin-left: 4px;
  font-size: 10px; font-weight: 700; border-radius: 999px;
  background: #fef3c7; color: #92400e; vertical-align: middle;
}
.muted { color: #6b7280; font-size: 14px; }

.site-footer {
  padding: 16px 32px 24px;
  text-align: center;
  font-size: 13px;
  color: #6b7280;
}
.site-footer a { color: #2563eb; text-decoration: none; font-weight: 600; }
.site-footer a:hover { text-decoration: underline; }
.site-footer .footer-sep { color: #d1d5db; }
.site-footer .footer-report {
  font-size: 13px; color: #6b7280; text-decoration: none; font-weight: 600;
}
.site-footer .footer-report:hover { color: #92400e; text-decoration: underline; }

/* Login modal */
.modal {
  position: fixed; inset: 0; background: rgba(0,0,0,0.55);
  display: flex; align-items: center; justify-content: center;
  z-index: 100;
  padding: 16px;
}
.modal.hidden { display: none; }
.modal-card {
  background: #fff; border-radius: 12px; padding: 28px 32px;
  min-width: 340px; max-width: 460px;
  box-shadow: 0 12px 48px rgba(0,0,0,0.2);
  display: flex; flex-direction: column; gap: 12px;
}
.modal-card h2 { margin: 0; font-size: 20px; }
.modal-card .muted { font-size: 13px; line-height: 1.5; margin: 0; }
.modal-card input {
  padding: 10px 14px; border: 1px solid #d1d5db; border-radius: 8px;
  font: inherit; font-size: 15px;
}
.modal-card input:focus { outline: 2px solid #2563eb; outline-offset: -1px; border-color: #2563eb; }
.modal-card .error { color: #dc2626; font-size: 13px; min-height: 18px; }
.modal-card .modal-buttons { display: flex; justify-content: flex-end; gap: 8px; margin-top: 4px; }
.modal-card .modal-buttons button {
  padding: 10px 20px; border: 0; border-radius: 8px; cursor: pointer; font: inherit; font-weight: 700;
}
.modal-card .primary { background: #2563eb; color: #fff; }
.modal-card .primary:hover { background: #1d4ed8; }
.hidden { display: none; }

/* Admin page */
.admin-page { background: #f3f4f6; }
.admin-main {
  display: flex; align-items: center; justify-content: center;
  min-height: 100vh; padding: 16px;
}
.admin-card {
  background: #fff; border-radius: 12px; padding: 32px;
  min-width: 360px; max-width: 460px;
  box-shadow: 0 12px 48px rgba(0,0,0,0.1);
  display: flex; flex-direction: column; gap: 12px;
}
.admin-card h1 { margin: 0; font-size: 22px; }
.admin-card .muted { font-size: 13px; line-height: 1.5; margin: 0; }
.admin-card input {
  padding: 10px 14px; border: 1px solid #d1d5db; border-radius: 8px;
  font: inherit; font-size: 15px;
}
.admin-card input:focus { outline: 2px solid #2563eb; outline-offset: -1px; border-color: #2563eb; }
.admin-card .error { color: #dc2626; font-size: 13px; min-height: 18px; }
.admin-card .modal-buttons { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-top: 4px; }
.admin-card .modal-buttons button {
  padding: 10px 20px; border: 0; border-radius: 8px; cursor: pointer; font: inherit; font-weight: 700;
}
.admin-card .primary { background: #2563eb; color: #fff; }
.admin-card .primary:hover { background: #1d4ed8; }

@media (max-width: 700px) {
  .menu-header { grid-template-columns: 1fr; padding: 16px; gap: 12px; }
  .overall-stats { justify-self: start; flex-wrap: wrap; }
  .cards-toolbar { padding: 12px 16px 0; }
  .menu-grid { padding: 12px 16px 24px; gap: 12px; }
  .leaderboard { padding: 12px 16px 24px; }
  .leaderboard-table th, .leaderboard-table td { padding: 8px 10px; font-size: 13px; }
}
