:root {
  --bg: #f4f5f9; --panel: #fff; --text: #1f2430; --muted: #6b7280; --line: #e3e6ee;
  --primary: #3b5bdb; --ok: #2f9e44; --bad: #e03131; --radius: 14px;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #14161c; --panel: #1d2028; --text: #e8eaf0; --muted: #9aa1b2; --line: #2b2f3a; --primary: #5c7cfa; --ok: #51cf66; --bad: #ff6b6b; }
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
header { background: var(--panel); border-bottom: 1px solid var(--line); }
nav { max-width: 760px; margin: 0 auto; display: flex; gap: 4px; padding: 0 12px; }
nav a { padding: 14px 16px; color: var(--muted); text-decoration: none; font-weight: 600; border-bottom: 3px solid transparent; }
nav a.active { color: var(--primary); border-bottom-color: var(--primary); }
main { max-width: 760px; margin: 0 auto; padding: 16px 12px 48px; }
h2 { margin: 0 0 12px; font-size: 1.25rem; }
h3 { margin: 18px 0 8px; font-size: 1rem; color: var(--muted); }
a { color: var(--primary); }
.muted { color: var(--muted); font-size: .9rem; }
.ok { color: var(--ok); } .bad { color: var(--bad); }

.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; margin-bottom: 16px; }
.row { display: flex; align-items: center; gap: 10px; padding: 10px 0; border-top: 1px solid var(--line); flex-wrap: wrap; }
.row:first-of-type { border-top: 0; }
.grow { flex: 1; min-width: 160px; }

.flash { padding: 12px 14px; border-radius: 10px; margin-bottom: 12px; border: 1px solid var(--line); background: var(--panel); }
.flash.ok { border-color: var(--ok); } .flash.error { border-color: var(--bad); color: var(--bad); }

.btn { display: inline-block; font: inherit; font-weight: 600; padding: 9px 16px; border-radius: 10px; border: 1px solid var(--line); background: var(--panel); color: var(--text); cursor: pointer; text-decoration: none; }
.btn.primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn.danger { color: var(--bad); }
.btn.small { padding: 4px 10px; }
.btn.big { padding: 16px 20px; font-size: 1.1rem; }
.btn.wide { width: 100%; }
.ok-btn { background: var(--ok); border-color: var(--ok); color: #fff; }
.bad-btn { background: var(--bad); border-color: var(--bad); color: #fff; }

.choices { display: flex; flex-wrap: wrap; gap: 8px; }
.choice { display: inline-flex; align-items: center; gap: 8px; padding: 8px 14px; border: 1px solid var(--line); border-radius: 999px; cursor: pointer; }
.choice.all { margin-bottom: 8px; }
.choice:has(input:checked) { border-color: var(--primary); background: color-mix(in srgb, var(--primary) 12%, transparent); }
form .btn.big { margin-top: 20px; }
input[type=file] { margin-right: 8px; max-width: 100%; }

.progress-info { display: flex; justify-content: space-between; color: var(--muted); margin-bottom: 6px; }
.bar { height: 6px; background: var(--line); border-radius: 99px; overflow: hidden; margin-bottom: 16px; }
.bar > div { height: 100%; background: var(--primary); }

.card { position: relative; background: var(--panel); border: 1px solid var(--line); border-radius: 20px; padding: 40px 24px 28px; min-height: 260px; text-align: center; margin-bottom: 16px; box-shadow: 0 6px 24px rgba(0,0,0,.06); }
.badge { position: absolute; top: 12px; left: 50%; transform: translateX(-50%); background: color-mix(in srgb, #f59f00 20%, transparent); color: #f08c00; border: 1px solid #f59f00; padding: 2px 12px; border-radius: 999px; font-size: .8rem; font-weight: 700; white-space: nowrap; }
.lang { text-transform: uppercase; letter-spacing: .08em; font-size: .75rem; color: var(--muted); margin-bottom: 6px; }
.word { font-size: 2rem; font-weight: 700; word-break: break-word; }
.word.solution { color: var(--primary); }
.card hr { border: 0; border-top: 1px dashed var(--line); margin: 22px 0 16px; }
.note { margin: 10px 0 0; color: var(--muted); }
.answer-buttons { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.answer-buttons .btn { margin-top: 0; }
.hint { text-align: center; }

.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(110px, 1fr)); gap: 12px; margin: 16px 0; text-align: center; color: var(--muted); }
.big-num { display: block; font-size: 1.8rem; font-weight: 700; color: var(--text); }
.big-num.ok { color: var(--ok); } .big-num.bad { color: var(--bad); }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: .95rem; }
th, td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; }
th { color: var(--muted); font-weight: 600; }
td form { margin: 0; }
main.wide { max-width: 1200px; }
td.wrap { white-space: normal; min-width: 120px; }
.filter-actions { display: flex; gap: 8px; margin-top: 16px; flex-wrap: wrap; }
.filter-actions .btn { margin: 0; }
.pager { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 14px; flex-wrap: wrap; }
.btn.disabled { opacity: .4; pointer-events: none; }
.btn:disabled { opacity: .5; cursor: default; }

.toolbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 8px; }
.toolbar h2 { margin: 0; }
details.panel > summary { cursor: pointer; font-weight: 700; font-size: 1.1rem; }
.new-form { display: flex; flex-direction: column; gap: 10px; margin-top: 14px; max-width: 640px; }
.new-form label { display: grid; grid-template-columns: 130px 1fr; align-items: center; gap: 10px; }
.new-form-actions { display: flex; padding-left: 140px; }
@media (max-width: 560px) {
  .new-form label { grid-template-columns: 1fr; gap: 4px; }
  .new-form-actions { padding-left: 0; }
}
.new-form input, .cell-input { font: inherit; color: var(--text); background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: 7px 9px; width: 100%; }
.cell-input { min-width: 110px; padding: 4px 6px; border-radius: 6px; }
tr.editing td { background: color-mix(in srgb, var(--primary) 8%, transparent); }
td.actions { white-space: nowrap; }