*, *::before, *::after { box-sizing: border-box; }

body {
  font-family: Georgia, 'Times New Roman', serif;
  max-width: 780px;
  margin: 40px auto;
  padding: 0 24px 90px;
  background: #f8f7f4;
  color: #1a1a1a;
  line-height: 1.9;
}

@media (max-width: 600px) {
  body { margin: 16px auto; padding: 0 14px 110px; }
}

/* ---------- шапка ---------- */

header.site {
  border-bottom: 2px solid #d0cdc7;
  padding-bottom: 10px;
  margin-bottom: 6px;
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 4px 16px;
}

header.site h1 {
  font-size: 1.35rem;
  font-weight: normal;
  margin: 0;
  color: #222;
  letter-spacing: 0.02em;
}

nav.site a {
  color: #3d5a80;
  text-decoration: none;
  font-size: 0.9rem;
  margin-left: 14px;
}

nav.site a.active { color: #1a1a1a; border-bottom: 1px solid #b0aaa0; }
nav.site a:hover { text-decoration: underline; }

#progress {
  font-size: 0.82rem;
  color: #999;
  margin-bottom: 18px;
}

/* ---------- фильтр ---------- */

#filter-bar {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
  margin-bottom: 14px;
  font-size: 0.88rem;
  color: #777;
}

#filter-bar select {
  font-family: inherit;
  font-size: 0.9rem;
  padding: 4px 8px;
  border: 1px solid #ccc;
  border-radius: 5px;
  background: #fff;
  color: #333;
}

/* ---------- вопросы ---------- */

#quiz-container { list-style: none; padding: 0; margin: 0; }

.q-row {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 0 3px;
  margin: 10px 0;
  padding: 6px 0;
  border-bottom: 1px solid #ebe9e4;
}

.q-num {
  min-width: 26px;
  font-size: 0.8rem;
  color: #bbb;
  flex-shrink: 0;
  padding-top: 1px;
}

.q-part { white-space: pre-wrap; }

.answer-input {
  border: none;
  border-bottom: 2px solid #b0aaa0;
  background: transparent;
  font-size: 1rem;
  font-family: inherit;
  color: #111;
  padding: 0 3px 1px;
  outline: none;
  min-width: 52px;
  transition: border-color 0.15s;
  vertical-align: baseline;
}

.answer-input:focus { border-bottom-color: #555; }

.answer-input.correct {
  border-bottom-color: #43a047;
  color: #2e7d32;
  background: #f0faf0;
  border-radius: 3px 3px 0 0;
}

.answer-input.almost {
  border-bottom-color: #f9a825;
  color: #8d6e00;
  background: #fffbea;
  border-radius: 3px 3px 0 0;
}

.answer-input.wrong {
  border-bottom-color: #e53935;
  color: #b71c1c;
  background: #fff5f5;
  border-radius: 3px 3px 0 0;
}

.fix-note {
  font-size: 0.82rem;
  color: #8d6e00;
  margin-left: 4px;
}

.tip-slot {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  flex-shrink: 0;
  margin-left: 6px;
}

.tip-btn {
  display: none;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #e53935;
  color: #fff;
  font-size: 0.72rem;
  font-weight: bold;
  border: none;
  cursor: default;
  position: relative;
  line-height: 20px;
  text-align: center;
  padding: 0;
  flex-shrink: 0;
}

.tip-btn.show { display: inline-block; }

.tip-btn:hover::after, .tip-btn.open::after {
  content: attr(data-tip);
  position: absolute;
  left: 28px;
  top: 50%;
  transform: translateY(-50%);
  background: #222;
  color: #fff;
  padding: 5px 11px;
  border-radius: 5px;
  font-size: 0.88rem;
  font-family: Georgia, serif;
  white-space: nowrap;
  z-index: 200;
  pointer-events: none;
}

@media (max-width: 600px) {
  .tip-btn:hover::after, .tip-btn.open::after {
    left: auto; right: 28px; white-space: normal; min-width: 180px;
  }
}

/* ---------- футер и кнопки ---------- */

#footer {
  margin-top: 32px;
  display: flex;
  gap: 12px;
  align-items: center;
  flex-wrap: wrap;
}

.btn {
  padding: 10px 26px;
  background: #3d5a80;
  color: #fff;
  border: none;
  border-radius: 6px;
  font-size: 0.97rem;
  font-family: inherit;
  cursor: pointer;
  transition: background 0.15s;
}

.btn:hover:not(:disabled) { background: #2c4770; }
.btn:disabled { background: #aaa; cursor: default; }

.btn-ghost {
  padding: 10px 18px;
  background: transparent;
  color: #aaa;
  border: 1px solid #ccc;
  border-radius: 6px;
  font-size: 0.88rem;
  font-family: inherit;
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s;
}

.btn-ghost:hover { color: #e53935; border-color: #e53935; }

#done-msg {
  display: none;
  padding: 22px 28px;
  background: #e8f5e9;
  border-radius: 8px;
  color: #2e7d32;
  font-size: 1.05rem;
  margin-bottom: 20px;
}

/* ---------- панель диакритики ---------- */

#diacritics {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  display: none;
  justify-content: center;
  gap: 8px;
  padding: 10px 12px calc(10px + env(safe-area-inset-bottom));
  background: rgba(248, 247, 244, 0.96);
  border-top: 1px solid #d0cdc7;
  z-index: 300;
}

#diacritics.show { display: flex; }

#diacritics button {
  min-width: 46px;
  padding: 8px 0;
  font-size: 1.15rem;
  font-family: inherit;
  background: #fff;
  border: 1px solid #c9c4bb;
  border-radius: 8px;
  color: #333;
  cursor: pointer;
}

#diacritics button:active { background: #ece9e2; }

/* ---------- оверлей входа ---------- */

.overlay {
  position: fixed;
  inset: 0;
  background: rgba(248, 247, 244, 0.97);
  z-index: 500;
  display: none;
  align-items: flex-start;
  justify-content: center;
  padding: 12vh 20px 20px;
}

.overlay.show { display: flex; }

.login-card {
  width: 100%;
  max-width: 380px;
  background: #fff;
  border: 1px solid #e0ddd6;
  border-radius: 10px;
  padding: 28px 30px 26px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.07);
}

.login-card h2 {
  font-size: 1.15rem;
  font-weight: normal;
  margin: 0 0 4px;
}

.login-card p { font-size: 0.88rem; color: #888; line-height: 1.6; margin: 0 0 16px; }

.login-card input {
  width: 100%;
  font-family: inherit;
  font-size: 1.05rem;
  padding: 9px 12px;
  border: 1px solid #ccc;
  border-radius: 6px;
  margin-bottom: 12px;
  outline: none;
}

.login-card input:focus { border-color: #3d5a80; }

.login-card .btn { width: 100%; }

.login-error {
  color: #b71c1c;
  font-size: 0.85rem;
  min-height: 1.4em;
  margin: 6px 0 0;
}

.login-hint { font-size: 0.82rem; color: #999; margin-top: 12px; }
.login-hint a { color: #3d5a80; cursor: pointer; }

/* ---------- пасхалка: диплом ---------- */

#egg-overlay {
  position: fixed;
  inset: 0;
  background: rgba(5, 5, 20, 0.92);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  animation: eggFadeIn 0.6s ease forwards;
}

@keyframes eggFadeIn { to { opacity: 1; } }

#fw-canvas { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }

#diploma {
  position: relative;
  z-index: 2;
  transform: scale(0.1) rotate(-8deg);
  opacity: 0;
  animation: diplomaPop 0.7s 0.5s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

@keyframes diplomaPop { to { transform: scale(1) rotate(0deg); opacity: 1; } }

.dip-outer {
  background: #fdf6e3;
  border: 4px double #b8960c;
  padding: 6px;
  border-radius: 3px;
  box-shadow: 0 0 0 1px #e6c84a, 0 30px 80px rgba(0,0,0,0.7), inset 0 0 40px rgba(200,160,0,0.06);
}

.dip-inner {
  border: 1px solid #d4a50a;
  padding: 32px 44px 28px;
  text-align: center;
  min-width: 300px;
  max-width: 480px;
  background: repeating-linear-gradient(45deg, transparent, transparent 40px,
    rgba(200,160,0,0.03) 40px, rgba(200,160,0,0.03) 41px);
}

.dip-ornament { color: #c9a227; font-size: 1rem; letter-spacing: 10px; margin-bottom: 6px; opacity: 0.7; }

.dip-title {
  font-size: 1.9rem;
  letter-spacing: 14px;
  color: #4a2c00;
  font-weight: normal;
  margin: 0 0 4px;
  text-shadow: 1px 1px 0 rgba(200,160,0,0.3);
}

.dip-rule { border: none; border-top: 1px solid #d4a50a; margin: 10px auto; width: 80%; opacity: 0.5; }
.dip-confirms { font-size: 0.78rem; color: #888; font-style: italic; margin: 8px 0 14px; letter-spacing: 0.04em; }

.dip-rank {
  font-size: 1.55rem;
  color: #7a1010;
  margin: 4px 0 12px;
  line-height: 1.3;
  text-shadow: 1px 1px 3px rgba(0,0,0,0.1);
}

.dip-stats { font-size: 0.8rem; color: #999; margin-bottom: 18px; line-height: 1.6; }
.dip-stats strong { color: #666; }

.kolo { display: flex; justify-content: center; gap: 2px; font-size: 1.55rem; margin: 14px 0 10px; line-height: 1; }
.kolo span { display: inline-block; animation: koloBob 0.45s ease-in-out infinite alternate; }
.kolo span:nth-child(even) { animation-direction: alternate-reverse; }
.kolo span:nth-child(3n) { animation-duration: 0.55s; }

@keyframes koloBob {
  from { transform: translateY(0) scaleX(1); }
  to { transform: translateY(-7px) scaleX(0.95); }
}

.dip-quote { font-size: 1.05rem; color: #4a2c00; font-style: italic; margin: 6px 0 18px; letter-spacing: 0.03em; }
.dip-bottom { display: flex; align-items: center; justify-content: space-between; margin-top: 6px; }

.dip-seal {
  width: 52px; height: 52px; border-radius: 50%;
  background: radial-gradient(circle at 40% 35%, #e6c84a, #8b6514);
  display: flex; align-items: center; justify-content: center;
  font-size: 1.4rem;
  box-shadow: 0 2px 8px rgba(0,0,0,0.35), inset 0 1px 0 rgba(255,255,255,0.3);
  animation: sealSpin 8s linear infinite;
}

@keyframes sealSpin { from { filter: hue-rotate(0deg); } to { filter: hue-rotate(40deg); } }

.dip-date { font-size: 0.75rem; color: #aaa; text-align: right; line-height: 1.5; }

.dip-close {
  display: block;
  margin: 20px auto 0;
  padding: 9px 28px;
  background: #3d5a80;
  color: #fff;
  border: none;
  border-radius: 5px;
  cursor: pointer;
  font-family: inherit;
  font-size: 0.9rem;
}

.dip-close:hover { background: #2c4770; }

.dip-inner::before, .dip-inner::after {
  content: '✦';
  display: block;
  color: #d4a50a;
  font-size: 0.85rem;
  opacity: 0.6;
}
.dip-inner::after { margin-top: 16px; }

/* ---------- статистика ---------- */

table.stats {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.92rem;
  margin: 14px 0 26px;
}

table.stats th, table.stats td {
  text-align: left;
  padding: 7px 10px;
  border-bottom: 1px solid #ebe9e4;
}

table.stats th { font-weight: normal; color: #999; font-size: 0.8rem; }

.pct-bar {
  position: relative;
  background: #ece9e2;
  border-radius: 4px;
  height: 14px;
  min-width: 120px;
  overflow: hidden;
}

.pct-bar > span {
  position: absolute;
  inset: 0 auto 0 0;
  background: #7d9c6f;
  border-radius: 4px;
}

.stat-cards { display: flex; gap: 14px; flex-wrap: wrap; margin: 18px 0; }

.stat-card {
  flex: 1 1 130px;
  background: #fff;
  border: 1px solid #e0ddd6;
  border-radius: 8px;
  padding: 14px 16px;
}

.stat-card .num { font-size: 1.6rem; color: #3d5a80; }
.stat-card .lbl { font-size: 0.78rem; color: #999; }

/* ---------- настройки ---------- */

.settings-block {
  background: #fff;
  border: 1px solid #e0ddd6;
  border-radius: 8px;
  padding: 18px 22px;
  margin: 16px 0;
}

.settings-block h3 { font-size: 1rem; font-weight: normal; margin: 0 0 6px; }
.settings-block p.hint { font-size: 0.83rem; color: #999; margin: 0 0 12px; line-height: 1.6; }

.intervals-list { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

.intervals-list input {
  width: 64px;
  font-family: inherit;
  font-size: 0.95rem;
  padding: 6px 8px;
  border: 1px solid #ccc;
  border-radius: 6px;
  text-align: center;
}

.intervals-list button.rm {
  border: none; background: transparent; color: #bbb; cursor: pointer; font-size: 1rem;
}
.intervals-list button.rm:hover { color: #e53935; }

.radio-row { display: flex; flex-direction: column; gap: 6px; font-size: 0.92rem; }
.radio-row label { display: flex; gap: 8px; align-items: baseline; cursor: pointer; }

input.batch {
  width: 72px;
  font-family: inherit;
  font-size: 0.95rem;
  padding: 6px 8px;
  border: 1px solid #ccc;
  border-radius: 6px;
  text-align: center;
}

.save-note { font-size: 0.85rem; color: #43a047; min-height: 1.3em; margin-top: 8px; }
.danger-zone { border-color: #f2c7c5; }
