:root {
  --bg: #f2f3f7;
  --bg-translucent: rgba(242, 243, 247, .82);
  --card: #ffffff;
  --card-2: #f6f7fa;
  --text: #17181c;
  --muted: #6d7178;
  --border: rgba(23, 24, 28, .09);
  --accent: #d8161f;
  --accent-2: #a80f16;
  --accent-soft: rgba(216, 22, 31, .09);
  --gold: #ffc700;
  --green: #1e8e3e;
  --green-soft: #e8f5ec;
  --red: #d93025;
  --red-soft: #fdecea;
  --shadow: 0 1px 2px rgba(23, 24, 28, .05), 0 8px 24px rgba(23, 24, 28, .06);
  --shadow-lg: 0 2px 4px rgba(23, 24, 28, .06), 0 16px 40px rgba(23, 24, 28, .12);
  --radius: 20px;
  --radius-sm: 14px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1013;
    --bg-translucent: rgba(15, 16, 19, .78);
    --card: #1a1c21;
    --card-2: #22242a;
    --text: #eceef1;
    --muted: #9599a1;
    --border: rgba(236, 238, 241, .09);
    --accent: #f04349;
    --accent-2: #c92930;
    --accent-soft: rgba(240, 67, 73, .13);
    --green: #34a55b;
    --green-soft: rgba(52, 165, 91, .16);
    --red: #ef5350;
    --red-soft: rgba(239, 83, 80, .15);
    --shadow: 0 1px 2px rgba(0, 0, 0, .35), 0 8px 24px rgba(0, 0, 0, .35);
    --shadow-lg: 0 2px 4px rgba(0, 0, 0, .4), 0 16px 40px rgba(0, 0, 0, .5);
  }
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html { -webkit-text-size-adjust: 100%; }
html, body { margin: 0; padding: 0; overflow-x: hidden; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
  overscroll-behavior-y: none;
}
button { font: inherit; color: inherit; }
.boot { text-align: center; padding: 5rem 1rem; color: var(--muted); }

.app { max-width: 680px; margin: 0 auto; padding: 0 16px calc(28px + env(safe-area-inset-bottom)); }

.header { display: flex; align-items: center; gap: 12px; padding: 22px 2px 4px; }
.appicon { width: 42px; height: 42px; border-radius: 10.5px; box-shadow: var(--shadow); flex: none; }
.title { font-size: 1.3rem; font-weight: 800; letter-spacing: -.02em; line-height: 1.2; }
.subtitle { color: var(--muted); font-size: .8rem; font-weight: 500; }
.lang { margin-left: auto; display: flex; gap: 2px; background: var(--card); border: 1px solid var(--border); border-radius: 999px; padding: 3px; box-shadow: var(--shadow); }
.langbtn {
  border: 0; background: transparent; color: var(--muted);
  font-size: .72rem; font-weight: 750; letter-spacing: .02em;
  padding: 5px 9px; min-height: 28px; border-radius: 999px; cursor: pointer;
  transition: background .2s, color .2s;
}
.langbtn.active { background: var(--accent-soft); color: var(--accent); }

.tabs {
  position: sticky;
  top: env(safe-area-inset-top);
  z-index: 10;
  display: flex;
  gap: 4px;
  margin: 14px -4px 18px;
  padding: 5px;
  border-radius: 999px;
  background: var(--bg-translucent);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  backdrop-filter: blur(20px) saturate(180%);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
}
.tab {
  flex: 1;
  border: 0;
  background: transparent;
  color: var(--muted);
  padding: 10px 4px;
  min-height: 42px;
  border-radius: 999px;
  font-size: .95rem;
  font-weight: 650;
  cursor: pointer;
  transition: background .25s, color .25s, transform .1s;
}
.tab:active { transform: scale(.96); }
.tab.active {
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #fff;
  box-shadow: 0 3px 12px rgba(216, 22, 31, .35);
}

.controls { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-bottom: 14px; }
.select {
  appearance: none;
  -webkit-appearance: none;
  background: var(--card);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 36px 10px 14px;
  font-size: 16px;
  font-weight: 550;
  cursor: pointer;
  max-width: 100%;
  box-shadow: var(--shadow);
  background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='11' height='7'%3E%3Cpath d='M1 1l4.5 4.5L10 1' stroke='%23888' stroke-width='2' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
}
.toggle { display: inline-flex; align-items: center; gap: 8px; font-size: .92rem; font-weight: 550; color: var(--muted); cursor: pointer; user-select: none; -webkit-user-select: none; min-height: 44px; }
.toggle input { accent-color: var(--accent); width: 18px; height: 18px; cursor: pointer; }

.stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; margin-bottom: 16px; }
.stat {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 4px 10px;
  text-align: center;
  box-shadow: var(--shadow);
}
.stat b { display: block; font-size: 1.3rem; font-weight: 750; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.stat span { display: block; font-size: .66rem; font-weight: 650; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.stat .ok { color: var(--green); }
.stat .bad { color: var(--red); }

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 22px;
}
.qwrap { animation: rise .3s cubic-bezier(.2, .7, .3, 1); }
@keyframes rise {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: none; }
}
.qmeta { display: flex; justify-content: space-between; align-items: center; gap: 8px; font-size: .78rem; font-weight: 600; color: var(--muted); margin-bottom: 12px; flex-wrap: wrap; }
.badge { background: var(--accent-soft); color: var(--accent); border-radius: 999px; padding: 4px 12px; font-weight: 700; }
.qtext { font-size: 1.22rem; font-weight: 700; letter-spacing: -.015em; line-height: 1.35; margin: 0 0 16px; }
.qimg { width: 100%; border-radius: var(--radius-sm); border: 1px solid var(--border); margin-bottom: 16px; background: #fff; }

.options { display: grid; gap: 10px; }
.opt {
  display: flex;
  align-items: center;
  gap: 13px;
  text-align: left;
  width: 100%;
  min-height: 54px;
  background: var(--card-2);
  color: var(--text);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 13px 15px;
  font-size: 1rem;
  font-weight: 500;
  cursor: pointer;
  transition: border-color .18s, background .18s, transform .08s, box-shadow .18s;
}
@media (hover: hover) {
  .opt:not(:disabled):hover { border-color: var(--accent); box-shadow: var(--shadow); }
}
.opt:not(:disabled):active { transform: scale(.985); }
.opt:disabled { cursor: default; }
.opt .letter {
  flex: none;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--card);
  border: 1.5px solid var(--border);
  font-weight: 750;
  font-size: .85rem;
  transition: background .18s, border-color .18s, color .18s;
}
.opt.correct { background: var(--green-soft); border-color: var(--green); }
.opt.correct .letter { background: var(--green); border-color: var(--green); color: #fff; }
.opt.wrong { background: var(--red-soft); border-color: var(--red); animation: shake .35s; }
.opt.wrong .letter { background: var(--red); border-color: var(--red); color: #fff; }
@keyframes shake {
  20% { transform: translateX(-5px); }
  45% { transform: translateX(4px); }
  70% { transform: translateX(-2px); }
}

.verdict { margin: 16px 0 0; font-weight: 750; font-size: 1.02rem; }
.verdict.ok { color: var(--green); }
.verdict.bad { color: var(--red); }

.trans { margin-top: 12px; }
.transbtn {
  border: 0; background: none; padding: 4px 0; cursor: pointer;
  color: var(--muted); font-size: .82rem; font-weight: 650;
  text-decoration: underline; text-decoration-style: dotted; text-underline-offset: 3px;
}
@media (hover: hover) { .transbtn:hover { color: var(--text); } }
.transtext { margin: 8px 0 0; font-size: .92rem; color: var(--muted); font-style: italic; line-height: 1.5; }

.expl {
  margin-top: 14px;
  padding: 13px 15px;
  border-radius: var(--radius-sm);
  background: var(--accent-soft);
  border-left: 3px solid var(--accent);
  animation: rise .3s cubic-bezier(.2, .7, .3, 1);
}
.expl-label { font-size: .7rem; font-weight: 750; text-transform: uppercase; letter-spacing: .07em; color: var(--accent); margin-bottom: 4px; }
.expl p { margin: 0; font-size: .92rem; line-height: 1.55; }

.actions { display: flex; gap: 10px; margin-top: 18px; flex-wrap: wrap; }
.btn {
  border: 0;
  border-radius: var(--radius-sm);
  padding: 14px 24px;
  min-height: 50px;
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #fff;
  box-shadow: 0 3px 12px rgba(216, 22, 31, .3);
  transition: filter .18s, transform .08s, box-shadow .18s;
}
@media (hover: hover) { .btn:hover { filter: brightness(1.07); } }
.btn:active { transform: scale(.97); }
.btn.ghost { background: transparent; color: var(--muted); border: 1.5px solid var(--border); box-shadow: none; }
@media (hover: hover) { .btn.ghost:hover { color: var(--text); border-color: var(--muted); filter: none; } }

.progress { height: 6px; background: var(--border); border-radius: 999px; overflow: hidden; margin: 6px 0 16px; }
.progress div { height: 100%; background: linear-gradient(90deg, var(--accent), var(--gold)); border-radius: 999px; transition: width .35s cubic-bezier(.2, .7, .3, 1); }
.exam-head { display: flex; justify-content: space-between; font-size: .85rem; font-weight: 600; color: var(--muted); font-variant-numeric: tabular-nums; }

.result { text-align: center; padding: 34px 22px; }
.result .big { font-size: 3rem; margin-bottom: 6px; }
.result h2 { margin: 0 0 6px; font-size: 1.5rem; letter-spacing: -.02em; }
.result p { color: var(--muted); margin: 0 0 4px; }
.result .score { font-size: 1.6rem; font-weight: 800; margin: 12px 0; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.pass h2 { color: var(--green); }
.fail h2 { color: var(--red); }

.review-item { margin-bottom: 12px; }
.review-item .qtext { font-size: 1.02rem; margin-bottom: 12px; }
.review-item .opt { min-height: 0; padding: 9px 13px; font-size: .92rem; }
.review-count { color: var(--muted); font-size: .85rem; font-weight: 550; margin: 0 2px 12px; }

.community { margin-top: 20px; font-size: .82rem; color: var(--muted); text-align: center; }
.community b { color: var(--text); }

.hint {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 18px;
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  background: var(--card);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  font-size: .85rem;
  color: var(--muted);
}
.hint b { color: var(--text); }
.hint button { margin-left: auto; border: 0; background: none; color: var(--muted); font-size: 1.1rem; cursor: pointer; padding: 4px 8px; }

.paper {
  position: relative;
  background: #fdfdfb;
  color: #111;
  border: 1px solid #c9c9c4;
  border-radius: 6px;
  padding: 22px 20px 84px;
  box-shadow: var(--shadow-lg);
  font-family: Helvetica, Arial, sans-serif;
}
.paper-cancel {
  position: absolute; top: 12px; right: 12px; z-index: 2;
  border: 1px solid #bbb; background: #fff; color: #555;
  font-size: .75rem; padding: 5px 10px; border-radius: 5px; cursor: pointer;
}
.paper-refs { margin: 26px 0 8px; font-size: .78rem; text-align: right; line-height: 1.6; }
.paper-refs span { color: #555; }
.paper-h1 { font-size: 1.7rem; font-weight: 800; margin: 18px 0 0; letter-spacing: -.01em; }
.paper-h2 { font-size: 1.15rem; color: #222; margin: 2px 0 18px; }
.paper-table { width: 100%; border-collapse: collapse; margin-bottom: 14px; font-size: .8rem; }
.paper-table th, .paper-table td { border: 1px solid #444; padding: 5px 8px; text-align: left; }
.paper-table th { font-weight: 700; width: 42%; }
.paper-table th.sub { font-weight: 600; }
.paper-table td { min-width: 40px; }
.paper-note { font-size: .66rem; color: #555; font-weight: 400; }
.paper-deco { display: flex; gap: 0; margin: 22px 0 6px; height: 34px; align-items: flex-end; }
.paper-deco span { display: block; }
.paper-deco .d1 { width: 14px; height: 34px; background: #1a1a1a; }
.paper-deco .d2 { width: 14px; height: 24px; background: #dd0000; margin-left: 6px; }
.paper-deco .d3 { width: 30px; height: 16px; background: #ffce00; margin-left: auto; }
.paper-termin { text-align: right; font-size: .85rem; line-height: 1.6; margin: 6px 0 14px; }
.paper-disclaimer { font-size: .68rem; color: #888; margin: 14px 0 6px; }
.paper-runhead {
  display: flex; justify-content: space-between; gap: 10px; flex-wrap: wrap;
  font-style: italic; font-size: .68rem; color: #333;
  border-bottom: 1px solid #333; padding: 4px 0 3px; margin: 20px 0 12px;
  font-family: Georgia, 'Times New Roman', serif;
}
.paper-band {
  margin: 14px 0 16px; padding: 4px 10px;
  background: #d6d6d2; color: #111;
  font-weight: 700; font-size: .9rem; letter-spacing: .01em;
  border-bottom: 2px solid #111;
}
.paper-band.center { text-align: center; }
.paper-text { font-size: .92rem; line-height: 1.55; margin: 0 0 14px; }
.paper-text.small { font-size: .85rem; }
.paper-extitle { font-weight: 700; font-size: .9rem; margin: 18px 0 8px; }
.paper-exbox { border: 1.5px solid #111; padding: 14px 16px; margin-bottom: 8px; background: #fff; }
.paper-extext { font-family: 'Courier New', Courier, monospace; font-weight: 700; font-size: .95rem; margin: 0 0 10px; }
.paper-exrow { display: flex; align-items: center; gap: 10px; padding: 3px 0; font-family: 'Courier New', Courier, monospace; font-size: .95rem; }
.paper-box.filled { background: #111; }
.paper-circle {
  display: inline-flex; padding: 2px; border: 2px solid #111; border-radius: 50%;
}
.paper-seite {
  text-align: right; font-style: italic; font-size: .66rem; color: #555;
  border-bottom: 1px solid #999; padding-bottom: 2px; margin: 22px 0 14px;
  font-family: Georgia, 'Times New Roman', serif;
}
.paper-sign { border: 1.5px solid #111; padding: 44px 16px 10px; margin: 6px 0 18px; background: #fff; }
.paper-signline { border-bottom: 1px solid #111; margin-bottom: 4px; }
.paper-signlabel { font-size: .8rem; }
.paper-official { background: #d6d6d2; border: 1px solid #999; padding: 12px 16px 6px; margin-bottom: 10px; font-size: .85rem; }
.paper-official .center { text-align: center; font-weight: 600; margin-bottom: 8px; }
.paper-q { margin-bottom: 22px; page-break-inside: avoid; }
.paper-qnum { font-weight: 700; font-size: .82rem; margin-bottom: 4px; }
.paper-qtext { font-size: 1rem; font-weight: 700; font-style: italic; margin: 0 0 10px; line-height: 1.4; }
.paper-img { max-width: 100%; border: 1px solid #ccc; border-radius: 4px; margin-bottom: 10px; background: #fff; }
.paper-opt {
  display: flex; align-items: flex-start; gap: 10px; width: 100%;
  background: none; border: 0; padding: 6px 2px; margin: 0;
  font-size: .95rem; color: #111; text-align: left; cursor: pointer; line-height: 1.4;
}
.paper-box {
  flex: none; width: 21px; height: 21px; margin-top: 1px;
  border: 1.5px solid #333; background: #fff; border-radius: 2px;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 15px; font-weight: 700; color: #111;
}
.paper-opt.checked .paper-box { background: #fff; }
.paper-bar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  display: flex; align-items: center; gap: 14px;
  padding: 10px 18px calc(10px + env(safe-area-inset-bottom));
  background: rgba(253, 253, 251, .92);
  -webkit-backdrop-filter: blur(14px);
  backdrop-filter: blur(14px);
  border-top: 1px solid #c9c9c4;
  color: #111;
}
.paper-timer { font-variant-numeric: tabular-nums; font-weight: 700; font-size: 1rem; }
.paper-timer.low { color: var(--red); }
.paper-count { font-variant-numeric: tabular-nums; color: #555; font-size: .9rem; }
.paper-submit { margin-left: auto; min-height: 44px; padding: 10px 26px; }
.paper-warn {
  position: fixed; left: 16px; right: 16px; bottom: calc(64px + env(safe-area-inset-bottom)); z-index: 21;
  background: var(--red-soft); color: var(--red); border: 1px solid var(--red);
  padding: 10px 14px; border-radius: 10px; font-size: .85rem; font-weight: 600; text-align: center;
}

.footer { margin-top: 36px; padding-top: 16px; border-top: 1px solid var(--border); font-size: .72rem; color: var(--muted); line-height: 1.6; }
.footer a { color: inherit; }

.done { text-align: center; padding: 32px 16px; }
.done h3 { margin: 0 0 8px; font-size: 1.3rem; }
.done p { color: var(--muted); }

@media (max-width: 420px) {
  .card { padding: 18px; }
  .qtext { font-size: 1.12rem; }
  .stat b { font-size: 1.15rem; }
  .tab { font-size: .88rem; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
