/* ---- base ---- */
* { box-sizing: border-box; }
:root {
  --bg: #f2f4f7;
  --card: #ffffff;
  --border: #d9dfe7;
  --text: #1c2733;
  --muted: #5b6b7c;
  --primary: #17579c;
  --primary-dark: #10406f;
  --primary-soft: #e8f0fa;
  --green: #2e7d32;
  --green-soft: #e6f4e8;
  --red: #c62828;
  --red-soft: #fdecea;
  --radius: 10px;
  --shadow: 0 1px 3px rgba(16, 30, 50, 0.08);
}
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Segoe UI", "Helvetica Neue", Arial, sans-serif;
  font-size: 16px;
  line-height: 1.55;
}
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
img { max-width: 100%; }
button { font-family: inherit; }

.container { max-width: 980px; margin: 0 auto; padding: 0 16px; }

/* ---- header ---- */
.site-header {
  background: var(--primary);
  color: #fff;
  box-shadow: var(--shadow);
}
.site-header .container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
  padding-top: 12px;
  padding-bottom: 12px;
}
.site-title { font-size: 1.25rem; font-weight: 700; color: #fff; }
.site-title:hover { text-decoration: none; }
.site-nav { display: flex; gap: 4px; flex-wrap: wrap; }
.site-nav a {
  color: #dce9f7;
  padding: 6px 12px;
  border-radius: 6px;
  font-weight: 500;
}
.site-nav a:hover { background: rgba(255, 255, 255, 0.12); color: #fff; text-decoration: none; }
.site-nav a.active { background: rgba(255, 255, 255, 0.18); color: #fff; }

main { padding: 24px 0 40px; }

/* ---- generic card ---- */
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
}

/* ---- home ---- */
.hero { text-align: center; padding: 28px 0 8px; }
.hero h1 { margin: 0 0 8px; font-size: 1.7rem; }
.hero p { margin: 0 auto; max-width: 640px; color: var(--muted); }
.home-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 18px;
  margin-top: 26px;
}
.home-card { display: block; padding: 26px 22px; text-align: center; transition: box-shadow 0.15s, transform 0.15s; }
.home-card:hover { text-decoration: none; box-shadow: 0 4px 14px rgba(16, 30, 50, 0.13); transform: translateY(-2px); }
.home-card .emoji { font-size: 2.4rem; display: block; margin-bottom: 10px; }
.home-card h2 { margin: 0 0 8px; font-size: 1.25rem; color: var(--primary); }
.home-card p { margin: 0; color: var(--muted); font-size: 0.95rem; }
.home-stats { margin-top: 26px; text-align: center; color: var(--muted); font-size: 0.9rem; }

/* ---- toolbar / controls ---- */
.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 12px 18px;
  align-items: flex-end;
  margin-bottom: 18px;
}
.field { display: flex; flex-direction: column; gap: 4px; }
.field > label { font-size: 0.8rem; font-weight: 600; color: var(--muted); }
.field select, .field input[type="text"], .field input[type="search"], .field input[type="number"] {
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fff;
  font-size: 0.95rem;
  color: var(--text);
  min-width: 130px;
}
.field select:focus, .field input:focus { outline: 2px solid var(--primary-soft); border-color: var(--primary); }

.seg { display: inline-flex; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; background: #fff; }
.seg button {
  border: 0;
  background: transparent;
  padding: 8px 14px;
  font-size: 0.95rem;
  cursor: pointer;
  color: var(--muted);
}
.seg button + button { border-inline-start: 1px solid var(--border); }
.seg button.on { background: var(--primary); color: #fff; }

.btn {
  display: inline-block;
  border: 1px solid var(--border);
  background: #fff;
  color: var(--text);
  border-radius: 8px;
  padding: 9px 18px;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.12s;
}
.btn:hover { background: #f2f6fb; }
.btn.primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn.primary:hover { background: var(--primary-dark); }
.btn.danger { color: var(--red); border-color: #eec6c6; }
.btn.danger:hover { background: var(--red-soft); }
.btn:disabled { opacity: 0.45; cursor: default; }

/* ---- quiz ---- */
.quiz-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 14px;
  align-items: center;
  color: var(--muted);
  font-size: 0.9rem;
  margin-bottom: 10px;
}
.chip {
  display: inline-block;
  background: var(--primary-soft);
  color: var(--primary);
  border-radius: 999px;
  padding: 2px 12px;
  font-size: 0.82rem;
  font-weight: 600;
}
.chip.lic { background: #eef2f6; color: var(--muted); }
.q-text { font-size: 1.15rem; font-weight: 600; margin: 4px 0 14px; }
.q-image { text-align: center; margin: 0 0 16px; }
.q-image img {
  max-height: 260px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fff;
}
.answers { display: flex; flex-direction: column; gap: 10px; }
.answer {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  width: 100%;
  text-align: start;
  background: #fff;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  padding: 12px 14px;
  font-size: 1rem;
  cursor: pointer;
  transition: border-color 0.12s, background 0.12s;
}
.answer:hover:not(:disabled) { border-color: var(--primary); background: #f7fafd; }
.answer .idx {
  flex: 0 0 auto;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  border: 1.5px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--muted);
  background: #fff;
}
.answer.selected { border-color: var(--primary); background: var(--primary-soft); }
.answer.selected .idx { border-color: var(--primary); background: var(--primary); color: #fff; }
.answer.correct { border-color: var(--green); background: var(--green-soft); }
.answer.correct .idx { border-color: var(--green); background: var(--green); color: #fff; }
.answer.wrong { border-color: var(--red); background: var(--red-soft); }
.answer.wrong .idx { border-color: var(--red); background: var(--red); color: #fff; }
.answer:disabled { cursor: default; color: var(--text); opacity: 1; }

.feedback { margin-top: 14px; padding: 12px 14px; border-radius: 8px; font-weight: 600; }
.feedback.good { background: var(--green-soft); color: var(--green); }
.feedback.bad { background: var(--red-soft); color: var(--red); }
.feedback.info { background: var(--primary-soft); color: var(--primary); font-weight: 500; }

.quiz-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  justify-content: space-between;
  margin-top: 18px;
}
.quiz-nav .group { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }

.scorebar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 22px;
  align-items: center;
  margin-top: 16px;
  padding: 12px 16px;
  font-size: 0.92rem;
  color: var(--muted);
}
.scorebar b { color: var(--text); }
.scorebar .ok b { color: var(--green); }
.scorebar .bad b { color: var(--red); }

.jump { display: flex; align-items: center; gap: 6px; }
.jump input { width: 84px; padding: 7px 8px; border: 1px solid var(--border); border-radius: 8px; font-size: 0.92rem; }

.empty-note { text-align: center; color: var(--muted); padding: 40px 0; }

/* ---- signs ---- */
.signs-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(168px, 1fr));
  gap: 14px;
  margin-top: 16px;
}
.sign-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 12px;
  text-align: center;
  cursor: pointer;
  transition: box-shadow 0.15s, transform 0.15s;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.sign-card:hover { box-shadow: 0 4px 14px rgba(16, 30, 50, 0.14); transform: translateY(-2px); }
.sign-card .imgwrap {
  height: 110px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.sign-card img { max-height: 105px; max-width: 100%; object-fit: contain; }
.sign-card .num { font-weight: 700; color: var(--primary); font-size: 0.95rem; }
.sign-card .name {
  font-size: 0.83rem;
  color: var(--muted);
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}
.signs-count { color: var(--muted); font-size: 0.9rem; margin-top: 12px; }

.group-chips { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 4px; }
.gchip {
  border: 1px solid var(--border);
  background: #fff;
  border-radius: 999px;
  padding: 6px 14px;
  font-size: 0.88rem;
  cursor: pointer;
  color: var(--muted);
}
.gchip:hover { border-color: var(--primary); color: var(--primary); }
.gchip.on { background: var(--primary); border-color: var(--primary); color: #fff; }

/* modal */
.modal-back {
  position: fixed;
  inset: 0;
  background: rgba(15, 25, 40, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 18px;
  z-index: 50;
}
.modal {
  background: #fff;
  border-radius: 12px;
  max-width: 520px;
  width: 100%;
  max-height: 88vh;
  overflow-y: auto;
  padding: 22px;
  position: relative;
  text-align: center;
}
.modal .close {
  position: absolute;
  top: 10px;
  inset-inline-start: 10px;
  border: 0;
  background: #f0f2f5;
  border-radius: 50%;
  width: 34px;
  height: 34px;
  font-size: 1rem;
  cursor: pointer;
  color: var(--muted);
}
.modal .close:hover { background: #e2e6ea; }
.modal img { max-height: 300px; object-fit: contain; margin: 6px auto 14px; }
.modal .num { color: var(--primary); font-weight: 700; font-size: 1.1rem; }
.modal .group { color: var(--muted); font-size: 0.85rem; margin-bottom: 8px; }
.modal .desc { text-align: start; }
.hidden { display: none !important; }

/* ---- footer ---- */
.site-footer {
  border-top: 1px solid var(--border);
  background: #fff;
  padding: 18px 0 26px;
  color: var(--muted);
  font-size: 0.82rem;
}
.site-footer p { margin: 4px 0; }

@media (max-width: 560px) {
  .q-text { font-size: 1.05rem; }
  .toolbar { gap: 10px; }
  .field select { min-width: 108px; }
}
