/* Промпт-Арена — оформление интерфейса. Без внешних библиотек. */

:root {
  --bg: #0f1626;
  --panel: #1a2338;
  --panel-2: #223049;
  --line: #2e3c58;
  --text: #e8edf7;
  --muted: #8b9bb8;
  --accent: #4c8dff;
  --accent-2: #9b6dff;
  --good: #35d07f;
  --warn: #ffb020;
  --bad: #ff5f6d;
  --gold: #ffd15c;
  --radius: 14px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  min-height: 100%;
}

body {
  background: radial-gradient(1200px 600px at 15% -10%, #1d2b4d 0%, transparent 55%),
              radial-gradient(900px 500px at 90% 0%, #2a1f45 0%, transparent 50%),
              var(--bg);
  color: var(--text);
  font-family: "Segoe UI", Roboto, Arial, sans-serif;
  font-size: 15px;
  line-height: 1.5;
}

a { color: var(--accent); }

dialog.card { color: var(--text); width: min(460px, 92vw); border: 1px solid var(--line); }
dialog::backdrop { background: rgba(0, 0, 0, .65); }
#loginError, #passwordError { color: var(--bad); }

.wrap { max-width: 1180px; margin: 0 auto; padding: 18px 20px 60px; }

/* ---------- Шапка ---------- */

header.top {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px 18px;
  background: rgba(26, 35, 56, .85);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  margin-bottom: 18px;
  flex-wrap: wrap;
}

.brand {
  font-size: 20px;
  font-weight: 800;
  letter-spacing: .3px;
  background: linear-gradient(92deg, var(--accent), var(--accent-2));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  white-space: nowrap;
}

.spacer { flex: 1; }

.chip {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 6px 12px;
  border-radius: 999px;
  background: var(--panel-2);
  border: 1px solid var(--line);
  font-size: 13px;
  color: var(--muted);
  white-space: nowrap;
}

.chip b { color: var(--text); font-weight: 600; }

.dot {
  width: 9px; height: 9px; border-radius: 50%;
  background: var(--muted); flex: 0 0 auto;
}
.dot.ok { background: var(--good); box-shadow: 0 0 10px var(--good); }
.dot.bad { background: var(--bad); box-shadow: 0 0 10px var(--bad); }
.dot.wait { background: var(--warn); }

/* ---------- Анимации «шоу»: ожидание, стрим, оценка ---------- */

/* Пока запрос в очереди — индикатор пульсирует, чтобы было видно: процесс идёт. */
@keyframes pulseDot {
  0%, 100% { opacity: 1; transform: scale(1); }
  50%      { opacity: .35; transform: scale(.7); }
}
.dot.wait { animation: pulseDot 1.1s ease-in-out infinite; }

/* По плашке очереди бегает блик — «модель занята, ждём своей очереди». */
@keyframes queueSweep {
  0%   { background-position: -240px 0; }
  100% { background-position: 240px 0; }
}
.queue-hint { position: relative; overflow: hidden; }
.queue-hint::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(100deg, transparent 20%, rgba(255, 255, 255, .18) 50%, transparent 80%);
  background-size: 240px 100%;
  background-repeat: no-repeat;
  animation: queueSweep 1.6s linear infinite;
  pointer-events: none;
}

/* Мигающий курсор в конце ответа, пока модель печатает. */
@keyframes caretBlink {
  0%, 49%   { opacity: 1; }
  50%, 100% { opacity: 0; }
}
.answer-box.streaming::after {
  content: '\258b';
  color: var(--accent);
  animation: caretBlink 1s step-end infinite;
}

/* Бейдж с баллом «выпрыгивает» — момент награды в конце попытки. */
@keyframes popIn {
  0%   { transform: scale(.4); opacity: 0; }
  70%  { transform: scale(1.12); }
  100% { transform: scale(1); opacity: 1; }
}
.score-badge { animation: popIn .5s cubic-bezier(.2, .9, .3, 1.3) both; }

@media (prefers-reduced-motion: reduce) {
  .dot.wait, .queue-hint::after, .answer-box.streaming::after, .score-badge {
    animation: none;
  }
}

/* ---------- Кнопки ---------- */

button, .btn {
  font-family: inherit;
  font-size: 15px;
  border: 0;
  border-radius: 12px;
  padding: 11px 20px;
  background: linear-gradient(92deg, var(--accent), var(--accent-2));
  color: #fff;
  cursor: pointer;
  transition: transform .12s ease, filter .12s ease, opacity .12s ease;
  text-decoration: none;
  display: inline-block;
}
button:hover:not(:disabled), .btn:hover { transform: translateY(-1px); filter: brightness(1.08); }
button:disabled { opacity: .45; cursor: not-allowed; transform: none; }

button.ghost {
  background: var(--panel-2);
  border: 1px solid var(--line);
  color: var(--text);
}
button.small { font-size: 13px; padding: 7px 13px; border-radius: 9px; }

/* ---------- Панели ---------- */

.card {
  background: rgba(26, 35, 56, .82);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px 22px;
  margin-bottom: 18px;
}

.card h2 { margin: 0 0 12px; font-size: 19px; }
.card h3 { margin: 18px 0 8px; font-size: 16px; color: var(--muted); font-weight: 600; }

.grid { display: grid; gap: 18px; }
.grid.two { grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr); }
.grid.side { grid-template-columns: 320px minmax(0, 1fr); }

@media (max-width: 980px) {
  .grid.two, .grid.side { grid-template-columns: 1fr; }
}

/* ---------- Вход ---------- */

.login-box {
  width: 100%;
  max-width: 520px;
  margin: 8vh auto 0;
  text-align: center;
}
.login-box h1 { font-size: 34px; margin: 0 0 6px; }
.login-box p { color: var(--muted); margin: 0 0 26px; }

label {
  display: block;
  text-align: left;
  font-size: 13px;
  color: var(--muted);
  margin: 14px 0 6px;
}

input[type="text"], input[type="password"], select, textarea {
  width: 100%;
  font-family: inherit;
  font-size: 15px;
  color: var(--text);
  background: #131c2e;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px 14px;
  outline: none;
  transition: border-color .15s ease, box-shadow .15s ease;
}
input[type="text"]:focus, input[type="password"]:focus, select:focus, textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(76, 141, 255, .18);
}

textarea {
  min-height: 190px;
  resize: vertical;
  line-height: 1.55;
}

/* ---------- Список заданий ---------- */

.task-list { list-style: none; margin: 0; padding: 0; }

.task-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 13px;
  border-radius: 12px;
  border: 1px solid transparent;
  cursor: pointer;
  transition: background .12s ease, border-color .12s ease;
}
.task-item:hover { background: var(--panel-2); }
.task-item.active { background: var(--panel-2); border-color: var(--accent); }

.task-num {
  width: 30px; height: 30px; flex: 0 0 auto;
  border-radius: 9px;
  background: #131c2e;
  border: 1px solid var(--line);
  display: flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 700; color: var(--muted);
}
.task-item.active .task-num { background: var(--accent); color: #fff; border-color: transparent; }

.task-title { flex: 1; font-size: 14px; }
.task-score { font-size: 13px; font-weight: 700; color: var(--gold); }
.task-score.none { color: var(--muted); font-weight: 500; }

.block-label {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: .8px;
  color: var(--muted);
  margin: 16px 0 6px;
}

/* ---------- Прогресс ---------- */

.progress-outer {
  height: 12px;
  border-radius: 999px;
  background: #131c2e;
  border: 1px solid var(--line);
  overflow: hidden;
}
.progress-inner {
  height: 100%;
  width: 0;
  border-radius: 999px;
  background: linear-gradient(92deg, var(--accent), var(--accent-2));
  transition: width .5s cubic-bezier(.22,.8,.3,1);
}

.kpis { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 12px; }

/* ---------- Задание ---------- */

.task-head h2 { margin: 0 0 4px; font-size: 21px; }
.task-head .block-name { color: var(--muted); font-size: 13px; margin-bottom: 14px; }

.requirement {
  background: #131c2e;
  border-left: 3px solid var(--accent);
  border-radius: 10px;
  padding: 12px 15px;
  font-size: 14.5px;
  color: #d5ddf2;
  margin: 12px 0;
}

.checkpoints { margin: 8px 0 0; padding-left: 20px; font-size: 14px; color: var(--muted); }
.checkpoints li { margin-bottom: 4px; }

/* ---------- Статус выполнения ---------- */

.status-line {
  display: flex; align-items: center; gap: 10px;
  font-size: 14px; color: var(--muted);
  min-height: 24px;
}

.queue-hint {
  background: rgba(255, 176, 32, .12);
  border: 1px solid rgba(255, 176, 32, .4);
  color: #ffd98a;
  border-radius: 10px;
  padding: 10px 14px;
  font-size: 14px;
  margin: 10px 0;
}

/* ---------- Ответ и код ---------- */

.answer-box {
  background: #0b1220;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 16px 18px;
  font-size: 14.5px;
  line-height: 1.65;
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 60vh;
  overflow-y: auto;
}

.answer-box code {
  background: #16203a;
  border-radius: 5px;
  padding: 1px 5px;
  font-family: Consolas, "Courier New", monospace;
  font-size: 13.5px;
}
.answer-box pre {
  background: #101a2e;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 12px 14px;
  overflow-x: auto;
}
.answer-box pre code { background: none; padding: 0; }

.block-bar {
  display: flex; align-items: center; gap: 10px;
  flex-wrap: wrap;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 9px 13px;
  margin: 8px 0;
  font-size: 13px;
}
.block-bar .fname { font-weight: 700; color: var(--accent); }
.block-bar .meta { color: var(--muted); }

/* ---------- Оценка ---------- */

.score-panel {
  border: 2px solid var(--line);
  border-radius: var(--radius);
  padding: 18px 20px;
  background: rgba(19, 28, 46, .9);
}
.score-panel.excellent { border-color: var(--gold); box-shadow: 0 0 28px rgba(255, 209, 92, .18); }

.score-head { display: flex; align-items: center; gap: 16px; margin-bottom: 14px; }

.score-badge {
  width: 78px; height: 78px; flex: 0 0 auto;
  border-radius: 20px;
  display: flex; align-items: center; justify-content: center;
  font-size: 36px; font-weight: 800;
  background: #131c2e;
  border: 2px solid var(--line);
}
.score-badge.s1 { color: var(--bad); border-color: var(--bad); }
.score-badge.s2 { color: #ff9b54; border-color: #ff9b54; }
.score-badge.s3 { color: var(--warn); border-color: var(--warn); }
.score-badge.s4 { color: #7ad3a0; border-color: #7ad3a0; }
.score-badge.s5 { color: var(--gold); border-color: var(--gold); }

.score-verdict { font-size: 15px; color: #d5ddf2; }

.crit-list { list-style: none; margin: 12px 0 0; padding: 0; }
.crit-list li {
  display: flex; gap: 10px; align-items: flex-start;
  padding: 7px 0; border-bottom: 1px solid rgba(46, 60, 88, .6);
  font-size: 14px;
}
.crit-list li:last-child { border-bottom: 0; }
.crit-mark { flex: 0 0 auto; width: 20px; font-weight: 800; }
.crit-mark.yes { color: var(--good); }
.crit-mark.no { color: var(--bad); }

.cols { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-top: 6px; }
@media (max-width: 760px) { .cols { grid-template-columns: 1fr; } }

.list-good, .list-bad, .list-tip { margin: 0; padding-left: 20px; font-size: 14px; }
.list-good li { margin-bottom: 6px; color: #c9f0da; }
.list-bad li { margin-bottom: 6px; color: #ffd3d6; }
.list-tip li { margin-bottom: 6px; color: #ffe7b3; }

/* ---------- Всплывающие сообщения ---------- */

#toasts {
  position: fixed;
  right: 20px; bottom: 20px;
  display: flex; flex-direction: column; gap: 10px;
  z-index: 50;
}
.toast {
  background: var(--panel);
  border: 1px solid var(--line);
  border-left: 4px solid var(--accent);
  border-radius: 12px;
  padding: 12px 16px;
  font-size: 14px;
  box-shadow: 0 12px 32px rgba(0, 0, 0, .35);
  animation: slideIn .25s ease;
  max-width: 380px;
}
.toast.good { border-left-color: var(--good); }
.toast.bad { border-left-color: var(--bad); }
.toast.gold { border-left-color: var(--gold); }

@keyframes slideIn {
  from { opacity: 0; transform: translateX(30px); }
  to { opacity: 1; transform: translateX(0); }
}

/* ---------- Конфетти ---------- */

.confetti {
  position: fixed; inset: 0;
  pointer-events: none;
  z-index: 60;
  overflow: hidden;
}
.confetti i {
  position: absolute;
  width: 10px; height: 14px;
  opacity: .95;
  animation: fall linear forwards;
}
@keyframes fall {
  from { transform: translateY(-40px) rotate(0deg); }
  to { transform: translateY(105vh) rotate(720deg); }
}

/* ---------- Мелочи ---------- */

.muted { color: var(--muted); font-size: 13.5px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.mt { margin-top: 14px; }
.hidden { display: none !important; }
.mono { font-family: Consolas, "Courier New", monospace; }
