:root {
  --paper: #f5f2ea;
  --paper-bright: #fffdf8;
  --ink: #172033;
  --muted: #697386;
  --line: #d9d5cb;
  --line-dark: #b7b2a7;
  --blue: #2457d6;
  --blue-dark: #173a9d;
  --blue-soft: #e8efff;
  --green: #18764b;
  --red: #b34141;
  --shadow: 0 20px 55px rgba(40, 45, 59, .12);
  --radius: 18px;
  --ease-out: cubic-bezier(0.23, 1, 0.32, 1);
  --ease-in-out: cubic-bezier(0.77, 0, 0.175, 1);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background-color: var(--paper);
  background-image:
    linear-gradient(rgba(36, 87, 214, .045) 1px, transparent 1px),
    linear-gradient(90deg, rgba(36, 87, 214, .045) 1px, transparent 1px);
  background-size: 32px 32px;
  font: 16px/1.55 Inter, ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

.aurora {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background: radial-gradient(circle at 85% 4%, rgba(255,255,255,.82), transparent 30%);
}

main, .top, footer { position: relative; z-index: 1; }
.top {
  max-width: 1060px;
  margin: 0 auto;
  padding: 26px 26px 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
}
.logo {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--ink);
  text-decoration: none;
  font-weight: 800;
  letter-spacing: -.04em;
  font-size: 18px;
}
.logo b { color: var(--blue); }
.logo-mark {
  display: grid;
  place-items: center;
  width: 31px;
  height: 31px;
  border: 2px solid var(--ink);
  border-radius: 50%;
  background: var(--blue);
  color: white;
  font-size: 17px;
  box-shadow: 3px 3px 0 var(--ink);
}
.nav { display: flex; align-items: center; gap: 22px; font-size: 13px; font-weight: 650; }
.nav a { color: var(--muted); text-decoration: none; transition: color 160ms var(--ease-out); }
.nav a:hover { color: var(--blue); }
.nav .tg {
  padding: 9px 14px;
  border: 1px solid var(--ink);
  border-radius: 999px;
  color: var(--ink);
  background: rgba(255,255,255,.45);
}

main { max-width: 840px; margin: 0 auto; padding: 72px 26px 92px; }
.hero { position: relative; padding: 0 12px 42px; }
.hero::before {
  content: "ЗАДАНИЕ → ОТВЕТ";
  position: absolute;
  top: -34px;
  right: 12px;
  color: var(--blue);
  font: 700 11px/1 ui-monospace, SFMono-Regular, Menlo, monospace;
  letter-spacing: .14em;
  transform: rotate(-3deg);
}
.badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 20px;
  color: var(--blue-dark);
  font: 700 11px/1 ui-monospace, SFMono-Regular, Menlo, monospace;
  letter-spacing: .11em;
  text-transform: uppercase;
}
.badge::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--green); box-shadow: 0 0 0 4px #dcefe5; }
h1 {
  max-width: 720px;
  margin: 0 0 18px;
  font: 800 clamp(45px, 8vw, 78px)/.94 Georgia, "Times New Roman", serif;
  letter-spacing: -.065em;
}
h1 em { color: var(--blue); font-style: normal; }
.lede { max-width: 590px; margin: 0; color: var(--muted); font-size: 16px; }
.models { margin: 14px 0 0; color: var(--muted); font: 11px ui-monospace, SFMono-Regular, Menlo, monospace; letter-spacing: .03em; }
.stats { display: flex; gap: 0; margin-top: 30px; flex-wrap: wrap; }
.stats div { min-width: 145px; padding: 0 22px 0 0; margin-right: 22px; border-right: 1px solid var(--line-dark); display: flex; flex-direction: column; }
.stats div:last-child { border-right: 0; }
.stats b { font: 700 24px/1 Georgia, serif; }
.stats span { margin-top: 5px; color: var(--muted); font: 11px/1.2 ui-monospace, monospace; text-transform: uppercase; letter-spacing: .07em; }

.card, .result, .how-grid article, .history-item {
  border: 1px solid var(--line);
  background: rgba(255,253,248,.88);
  box-shadow: var(--shadow);
}
.card { padding: 20px; border-radius: var(--radius); }
.tabs { display: inline-flex; gap: 4px; padding: 4px; margin-bottom: 17px; border: 1px solid var(--line); border-radius: 12px; background: var(--paper); }
.tab { border: 0; background: transparent; color: var(--muted); padding: 8px 14px; border-radius: 8px; font-family: inherit; font-size: 13px; font-weight: 700; cursor: pointer; transition: color 160ms var(--ease-out), background-color 160ms var(--ease-out), transform 120ms var(--ease-out); }
.tab.is-active { color: white; background: var(--ink); }
.tab:active, .ghost:active, .clear:active { transform: scale(.97); }

.drop {
  position: relative;
  display: grid;
  place-items: center;
  min-height: 252px;
  overflow: hidden;
  border: 1.5px dashed var(--line-dark);
  border-radius: 13px;
  background-color: var(--paper);
  background-image: linear-gradient(rgba(36,87,214,.06) 1px, transparent 1px), linear-gradient(90deg, rgba(36,87,214,.06) 1px, transparent 1px);
  background-size: 24px 24px;
  cursor: pointer;
  outline: none;
  transition: border-color 180ms var(--ease-out), background-color 180ms var(--ease-out);
}
.drop::after { content: ""; position: absolute; top: 0; bottom: 0; left: 18%; width: 1px; background: rgba(179,65,65,.2); }
.drop:hover, .drop:focus-visible, .drop.is-over { border-color: var(--blue); background-color: #edf2ff; }
.drop-inner { z-index: 1; display: grid; justify-items: center; gap: 6px; padding: 26px; text-align: center; color: var(--muted); }
.drop-inner svg { color: var(--blue); }
.drop-inner p { margin: 4px 0 0; color: var(--ink); font-size: 15px; }
.drop-inner span { font-size: 12px; }
.drop img { width: 100%; max-height: 460px; object-fit: contain; background: #e9e6de; display: block; }
.clear { position: absolute; z-index: 2; top: 10px; right: 10px; width: 32px; height: 32px; border: 1px solid var(--line-dark); border-radius: 9px; background: var(--paper-bright); color: var(--ink); cursor: pointer; }

textarea { width: 100%; min-height: 150px; resize: vertical; padding: 16px; border: 1px solid var(--line-dark); border-radius: 12px; background: var(--paper-bright); color: var(--ink); font: inherit; outline: none; transition: border-color 160ms var(--ease-out), box-shadow 160ms var(--ease-out); }
textarea:focus { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(36,87,214,.13); }
.primary { width: 100%; margin-top: 14px; padding: 15px 20px; border: 1px solid var(--ink); border-radius: 10px; background: var(--blue); color: white; font-family: inherit; font-size: 15px; font-weight: 750; cursor: pointer; box-shadow: 3px 3px 0 var(--ink); transition: transform 140ms var(--ease-out), background-color 160ms var(--ease-out), opacity 160ms var(--ease-out); }
.primary:hover:not(:disabled) { background: var(--blue-dark); transform: translate(-1px,-1px); }
.primary:active:not(:disabled) { transform: translate(1px, 1px) scale(.98); box-shadow: 1px 1px 0 var(--ink); }
.primary:disabled { opacity: .43; cursor: not-allowed; box-shadow: none; }
.primary.is-busy span { opacity: .65; }
.loader { display: flex; align-items: center; justify-content: center; gap: 10px; margin-top: 15px; color: var(--muted); font: 13px ui-monospace, monospace; }
.spinner { width: 15px; height: 15px; border: 2px solid #c9d2e7; border-top-color: var(--blue); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.error { margin: 14px 0 0; padding: 12px 14px; border: 1px solid #e3b1b1; border-radius: 10px; background: #fff0ef; color: var(--red); font-size: 14px; }

.result { margin-top: 20px; padding: 23px; border-color: #a9bee9; border-radius: var(--radius); animation: rise 220ms var(--ease-out) both; }
@keyframes rise { from { opacity: 0; transform: translateY(7px) scale(.985); } }
.result-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }
.chip { padding: 4px 9px; border: 1px solid var(--line); border-radius: 999px; background: var(--paper); color: var(--muted); font: 11px ui-monospace, monospace; white-space: nowrap; }
.chip.green { border-color: #9dcdb5; background: #e7f5ed; color: var(--green); }
.chip.warn { border-color: #e4c98c; background: #fff6dc; color: #886518; }
.result h2 { margin: 0 0 10px; color: #354057; font: 600 17px/1.45 Georgia, serif; }
.options { display: grid; gap: 8px; margin: 14px 0 4px; }
.option { display: flex; gap: 10px; align-items: flex-start; padding: 11px 13px; border: 1px solid var(--line); border-radius: 10px; background: var(--paper); color: #465166; font-size: 14px; }
.option.is-correct { border-color: #86c3a5; background: #eaf7ef; color: #194f37; }
.option-mark { flex: 0 0 18px; color: var(--green); font-weight: 800; }
.answer-box { margin-top: 16px; padding: 16px; border: 1px solid #8eace8; border-radius: 11px; background: var(--blue-soft); }
.answer-box .label { color: var(--blue-dark); font: 700 10px ui-monospace, monospace; letter-spacing: .1em; text-transform: uppercase; }
.answer-box .value { margin-top: 6px; color: var(--blue-dark); font: 700 20px/1.35 Georgia, serif; overflow-wrap: anywhere; }
.explanation { margin: 15px 0 0; padding-left: 13px; border-left: 2px solid var(--blue); color: #59657a; font-size: 14.5px; }
.result-actions { display: flex; gap: 9px; margin-top: 18px; flex-wrap: wrap; }
.ghost { padding: 9px 13px; border: 1px solid var(--line-dark); border-radius: 9px; background: var(--paper-bright); color: var(--ink); font-family: inherit; font-size: 13px; font-weight: 700; cursor: pointer; transition: background-color 160ms var(--ease-out), border-color 160ms var(--ease-out), color 160ms var(--ease-out), transform 120ms var(--ease-out); }
a.ghost { display: inline-flex; align-items: center; text-decoration: none; }
.ghost:hover:not(:disabled) { border-color: var(--blue); background: var(--blue-soft); }
.ghost.is-active { border-color: #8bc4a7; background: #e7f5ed; color: var(--green); }
.ghost:disabled { opacity: .6; cursor: default; }

.how { margin-top: 62px; }
.how h2, .history h2 { margin: 0 0 16px; font: 700 25px/1 Georgia, serif; letter-spacing: -.03em; }
.how-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.how-grid article { min-height: 170px; padding: 18px; border-radius: 13px; box-shadow: none; }
.num { color: var(--blue); font: 700 11px ui-monospace, monospace; letter-spacing: .1em; }
.how-grid h3 { margin: 10px 0 6px; font-size: 15px; }
.how-grid p { margin: 0; color: var(--muted); font-size: 13.5px; }
.history { margin-top: 48px; }
.history-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.history-list { display: grid; gap: 8px; }
.history-item { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 13px 15px; border-radius: 10px; box-shadow: none; cursor: pointer; text-align: left; color: inherit; font: inherit; transition: border-color 160ms var(--ease-out), background-color 160ms var(--ease-out), transform 120ms var(--ease-out); }
.history-item:hover { border-color: var(--blue); background: var(--blue-soft); }
.history-item:active { transform: scale(.99); }
.history-item .q { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: #465166; font-size: 14px; }
.history-item .a { flex: 0 0 auto; max-width: 45%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--blue-dark); font: 14px Georgia, serif; }
footer { max-width: 840px; margin: 0 auto; padding: 0 26px 48px; color: #8b8b88; font-size: 12px; text-align: center; }
.toast { position: fixed; left: 50%; bottom: 26px; z-index: 10; transform: translateX(-50%) translateY(10px); padding: 11px 18px; border: 1px solid var(--ink); border-radius: 10px; background: var(--ink); color: white; font-size: 14px; box-shadow: var(--shadow); opacity: 0; transition: opacity 180ms var(--ease-out), transform 180ms var(--ease-out); }
.toast.is-visible { opacity: 1; transform: translateX(-50%) translateY(0); }

:focus-visible { outline: 3px solid rgba(36,87,214,.35); outline-offset: 3px; }
@media (max-width: 720px) {
  .nav a:not(.tg) { display: none; }
  main { padding-top: 55px; }
  h1 { font-size: clamp(43px, 14vw, 66px); }
  .hero::before { right: 12px; top: -27px; font-size: 9px; }
  .stats { gap: 18px 0; }
  .stats div { min-width: 120px; margin-right: 18px; padding-right: 18px; }
  .how-grid { grid-template-columns: 1fr; }
  .result, .card { padding: 16px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; scroll-behavior: auto !important; }
  .result { animation-name: fade-in; }
}
@keyframes fade-in { from { opacity: 0; } }
