:root {
  --bg: #f7f8fb;
  --card: #ffffff;
  --text: #0f172a;
  --muted: #64748b;
  --border: #e6e8ef;
  --accent: #5b5bf6;
  --accent-2: #8b5cf6;
  --accent-soft: #eef0ff;
  --ok: #15803d; --ok-bg: #dcfce7;
  --warn: #b45309; --warn-bg: #fef3c7;
  --err: #b91c1c; --err-bg: #fee2e2;
  --shadow: 0 1px 2px rgba(15, 23, 42, .04), 0 8px 24px -12px rgba(15, 23, 42, .12);
  --radius: 14px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.6 -apple-system, BlinkMacSystemFont, "Inter", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}

.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
  padding: 14px 24px; background: rgba(255,255,255,.85); backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}
.brand { display: inline-flex; align-items: center; gap: 10px; font-weight: 700; font-size: 17px; color: var(--text); text-decoration: none; letter-spacing: -.01em; }
.sigil {
  width: 28px; height: 28px; border-radius: 50%; display: inline-block;
  background: conic-gradient(from 0deg, var(--accent), var(--accent-2), var(--accent));
  -webkit-mask: radial-gradient(circle, transparent 42%, #000 44%); mask: radial-gradient(circle, transparent 42%, #000 44%);
}
.tagline { color: var(--muted); font-size: 14px; }

.container { max-width: 960px; margin: 0 auto; padding: 48px 20px 56px; }
.footer { text-align: center; padding: 0 20px 32px; }

h1 { font-size: 36px; line-height: 1.15; margin: 0 0 12px; letter-spacing: -.02em; font-weight: 800; }
h2 { font-size: 18px; margin: 0 0 12px; font-weight: 700; letter-spacing: -.01em; }
h3 { font-size: 17px; margin: 0 0 2px; font-weight: 700; }

.muted { color: var(--muted); }
.small { font-size: 13px; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

.hero { text-align: center; }
.hero .muted { max-width: 600px; margin: 0 auto 28px; font-size: 17px; }

/* Эмблема: кольцо из точек, символизирующее участников */
.table-mark { position: relative; width: 72px; height: 72px; margin: 0 auto 20px; }
.table-mark::before {
  content: ""; position: absolute; inset: 0; border-radius: 50%;
  border: 2px solid var(--border);
}
.table-mark span {
  position: absolute; top: 50%; left: 50%; width: 12px; height: 12px; margin: -6px;
  border-radius: 50%; background: linear-gradient(135deg, var(--accent), var(--accent-2));
  transform: rotate(calc(var(--i) * 60deg)) translateY(-36px);
  animation: pulse 2.4s ease-in-out infinite; animation-delay: calc(var(--i) * .2s);
}
.table-mark span:nth-child(1) { --i: 0; } .table-mark span:nth-child(2) { --i: 1; }
.table-mark span:nth-child(3) { --i: 2; } .table-mark span:nth-child(4) { --i: 3; }
.table-mark span:nth-child(5) { --i: 4; } .table-mark span:nth-child(6) { --i: 5; }
@keyframes pulse { 0%, 100% { opacity: .55; } 50% { opacity: 1; } }

.ask-form { text-align: left; max-width: 720px; margin: 0 auto; }
.ask-form textarea {
  width: 100%; padding: 16px 18px; font: inherit; color: var(--text);
  border: 1px solid var(--border); border-radius: var(--radius); resize: vertical;
  background: var(--card); box-shadow: var(--shadow); transition: box-shadow .15s, border-color .15s;
}
.ask-form textarea::placeholder { color: #9aa3b5; }
.ask-form textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft); }
.form-row { display: flex; justify-content: flex-end; margin-top: 14px; }

.btn {
  display: inline-block; padding: 11px 20px; border-radius: 10px; border: 1px solid var(--border);
  background: var(--card); color: var(--text); font: inherit; font-weight: 600; cursor: pointer;
  transition: transform .1s, box-shadow .15s, background .15s;
}
.btn:hover { background: #f8f9fc; }
.btn.primary {
  background: linear-gradient(135deg, var(--accent), var(--accent-2)); border-color: transparent; color: #fff;
  box-shadow: 0 6px 16px -6px rgba(91, 91, 246, .6);
}
.btn.primary:hover { transform: translateY(-1px); box-shadow: 0 10px 20px -8px rgba(91, 91, 246, .7); }
.btn:disabled { opacity: .6; cursor: default; transform: none; }
form.inline { display: inline; margin-top: 8px; }

.recent { margin-top: 64px; }
.recent-list { list-style: none; padding: 0; margin: 0; background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
.recent-list li {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  padding: 12px 18px; border-bottom: 1px solid var(--border);
}
.recent-list li:last-child { border-bottom: 0; }
.recent-list li a { flex: 1 1 300px; color: var(--text); }
.recent-list li a:hover { color: var(--accent); text-decoration: none; }

.card {
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 16px 18px; margin-bottom: 14px; box-shadow: var(--shadow);
}
.back { margin: 0 0 16px; }
.query { white-space: pre-wrap; margin: 0 0 10px; font-size: 16px; }
.status-row { display: flex; align-items: center; gap: 10px; }

.badge {
  display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: 12px;
  font-weight: 600; background: #eef0f4; color: var(--muted); white-space: nowrap;
}
.badge.done { background: var(--ok-bg); color: var(--ok); }
.badge.failed { background: var(--err-bg); color: var(--err); }
.badge.assembling, .badge.consulting, .badge.synthesizing { background: var(--warn-bg); color: var(--warn); }

.alert { background: var(--err-bg); color: var(--err); border-radius: 10px; padding: 10px 14px; margin: 12px 0; }

.verdict { border: 0; background: linear-gradient(135deg, #f3f0ff, #eef4ff); box-shadow: var(--shadow); }
.verdict h2 { color: var(--accent); }
.crown { display: none; }

.experts { display: flex; flex-direction: column; gap: 12px; }

.summoned { margin: 4px 0 18px; }
.chips { list-style: none; padding: 0; margin: 0; display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  display: inline-flex; align-items: center; gap: 8px; padding: 6px 12px; border-radius: 999px;
  background: var(--card); border: 1px solid var(--border); font-size: 13px; transition: all .3s;
}
.chip.pending { color: var(--muted); }
.chip.answered { background: var(--accent-soft); border-color: transparent; color: var(--accent); }
.chip-role { font-weight: 600; }
.chip-name { opacity: .75; }

.appear { animation: appear .45s ease-out; }
@keyframes appear { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
.expert header { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; margin-bottom: 8px; }
.expert h3 { font-size: 16px; margin: 0; }
.expert .knight { margin: 0; color: var(--accent); font-size: 13px; font-weight: 600; }
.expert .prose { font-size: 15px; }

.prose p { margin: 0 0 10px; }
.prose p:last-child { margin-bottom: 0; }
.prose ul, .prose ol { margin: 0 0 10px; padding-left: 22px; }
.prose li { margin-bottom: 4px; }
.prose h1, .prose h2, .prose h3, .prose h4 { font-size: 15px; margin: 12px 0 6px; color: var(--text); }
.prose code { background: #f1f3f8; padding: 1px 5px; border-radius: 4px; font-size: 90%; }

.spinner {
  width: 16px; height: 16px; border: 2px solid var(--border); border-top-color: var(--accent);
  border-radius: 50%; display: inline-block; animation: spin .8s linear infinite; vertical-align: middle;
}
.spinner.small { width: 12px; height: 12px; }
@keyframes spin { to { transform: rotate(360deg); } }

@media (max-width: 600px) {
  h1 { font-size: 28px; }
  .container { padding-top: 32px; }
}
