@import url('https://fonts.googleapis.com/css2?family=Onest:wght@400;500;600;700;800&family=JetBrains+Mono:wght@500;700&display=swap');

:root {
  --bg: #F4F3EF;
  --surface: #FFFFFF;
  --surface-2: #FAF9F6;
  --ink: #15151B;
  --ink-2: #4A4A55;
  --ink-3: #8A8A96;
  --line: #E4E2DC;
  --accent: #5B4BDB;
  --accent-soft: #EEEBFF;
  --radar-bg: #101122;
  --radar-ink: #E9E8F5;
  --radar-line: rgba(255,255,255,.09);
  --ok: #12A594;
  --warn: #D97706;
  --err: #DC2626;
  --radius: 18px;
  --shadow: 0 1px 2px rgba(20,20,30,.04), 0 8px 24px rgba(20,20,30,.06);
  --mono: 'JetBrains Mono', ui-monospace, monospace;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg); color: var(--ink);
  font: 15px/1.5 'Onest', system-ui, -apple-system, 'Segoe UI', sans-serif;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; }
button, input, select, textarea { font: inherit; color: inherit; }
.wrap { max-width: 1360px; margin: 0 auto; padding: 0 24px; }
.muted { color: var(--ink-3); }
.mono { font-family: var(--mono); }
.hidden { display: none !important; }

/* ---------- кнопки и поля ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 8px; justify-content: center;
  height: 40px; padding: 0 16px; border-radius: 12px; border: 1px solid var(--line);
  background: var(--surface); cursor: pointer; font-weight: 500; white-space: nowrap;
  text-decoration: none; transition: .15s;
}
.btn:hover { border-color: var(--ink-3); }
.btn.primary { background: var(--ink); color: #fff; border-color: var(--ink); }
.btn.primary:hover { background: #2a2a35; }
.btn.accent { background: var(--accent); color: #fff; border-color: var(--accent); }
.btn.danger { color: var(--err); }
.btn.ghost { background: transparent; border-color: transparent; }
.btn:disabled { opacity: .5; cursor: default; }
.btn.sm { height: 32px; padding: 0 12px; font-size: 13px; border-radius: 10px; }

.input, select.input, textarea.input {
  width: 100%; height: 40px; padding: 0 14px; border-radius: 12px;
  border: 1px solid var(--line); background: var(--surface); outline: none;
}
textarea.input { height: auto; padding: 10px 14px; resize: vertical; line-height: 1.5; }
.input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
label.field { display: block; margin-bottom: 14px; }
label.field > span { display: block; font-size: 13px; color: var(--ink-2); margin-bottom: 6px; font-weight: 500; }

.chip {
  display: inline-flex; align-items: center; gap: 6px; height: 34px; padding: 0 14px;
  border-radius: 999px; border: 1px solid var(--line); background: var(--surface);
  cursor: pointer; font-size: 14px; white-space: nowrap; transition: .15s;
}
.chip:hover { border-color: var(--ink-3); }
.chip.on { background: var(--ink); color: #fff; border-color: var(--ink); }
.chip .n { font-family: var(--mono); font-size: 12px; opacity: .6; }
.tag {
  display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: 999px;
  font-size: 12px; background: var(--surface-2); border: 1px solid var(--line); color: var(--ink-2);
}
.tag i { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }

.card {
  background: var(--surface); border-radius: var(--radius); border: 1px solid var(--line);
  box-shadow: var(--shadow);
}

/* ---------- карточка исследования ---------- */
.study {
  padding: 18px; display: flex; flex-direction: column; gap: 10px; cursor: pointer;
  background: var(--surface); border: 1px solid var(--line); border-radius: 16px; transition: .15s;
}
.study:hover { border-color: var(--ink-3); transform: translateY(-1px); box-shadow: var(--shadow); }
.study .meta { display: flex; gap: 8px; align-items: center; font-size: 13px; color: var(--ink-3); }
.study .pub { font-weight: 600; color: var(--ink); }
.study h4 { margin: 0; font-size: 16px; line-height: 1.35; font-weight: 600; }
.study p { margin: 0; font-size: 14px; color: var(--ink-2);
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.study .tags { display: flex; flex-wrap: wrap; gap: 6px; }

/* ---------- выезжающая панель ---------- */
.drawer-bg { position: fixed; inset: 0; background: rgba(15,15,25,.35); z-index: 40; backdrop-filter: blur(2px); }
.drawer {
  position: fixed; top: 0; right: 0; bottom: 0; width: min(760px, 100vw); background: var(--bg);
  z-index: 41; overflow-y: auto; box-shadow: -20px 0 60px rgba(0,0,0,.15);
  animation: slide .22s ease-out;
}
@keyframes slide { from { transform: translateX(40px); opacity: 0; } }
.drawer-head {
  position: sticky; top: 0; z-index: 2; background: var(--bg); padding: 16px 28px;
  display: flex; justify-content: space-between; align-items: center; border-bottom: 1px solid var(--line);
}
.drawer-body { padding: 24px 28px 48px; }

/* ---------- идеи ---------- */
.ideas { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 12px; }
.idea { padding: 18px; border-radius: 16px; background: var(--surface); border: 1px solid var(--line);
  display: flex; flex-direction: column; gap: 10px; }
.idea .top { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.idea .num { font-family: var(--mono); font-weight: 700; color: var(--accent); }
.idea .hz { font-size: 12px; padding: 3px 9px; border-radius: 999px; background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.idea h5 { margin: 0; font-size: 16px; line-height: 1.3; }
.idea p { margin: 0; font-size: 14px; color: var(--ink-2); }
.idea .aff { background: var(--surface-2); border-left: 3px solid var(--accent); padding: 8px 12px; border-radius: 0 10px 10px 0; font-size: 14px; }
.idea .aff b, .idea .row b { display: block; font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--ink-3); margin-bottom: 2px; font-weight: 600; }
.idea .row { font-size: 13px; color: var(--ink-2); }
.idea .src { font-size: 12px; color: var(--ink-3); border-top: 1px dashed var(--line); padding-top: 8px; }

.chat { display: flex; flex-direction: column; gap: 14px; }
.bubble { align-self: flex-end; max-width: 80%; background: var(--ink); color: #fff; padding: 10px 14px; border-radius: 16px 16px 4px 16px; font-size: 14px; }
.chat-input { display: flex; gap: 8px; align-items: flex-end; }
.chat-input textarea { min-height: 48px; }
.presets { display: flex; flex-wrap: wrap; gap: 6px; }
.presets .chip { height: 30px; font-size: 13px; padding: 0 12px; }
.thinking { display: flex; gap: 10px; align-items: center; color: var(--ink-3); font-size: 14px; }
.dots i { display: inline-block; width: 6px; height: 6px; border-radius: 50%; background: var(--accent); margin-right: 3px; animation: blink 1s infinite; }
.dots i:nth-child(2) { animation-delay: .15s } .dots i:nth-child(3) { animation-delay: .3s }
@keyframes blink { 50% { opacity: .2 } }

.toast { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%); background: var(--ink); color: #fff;
  padding: 10px 18px; border-radius: 12px; z-index: 100; font-size: 14px; }

@media (max-width: 720px) {
  .wrap { padding: 0 16px; }
  .drawer-head, .drawer-body { padding-left: 16px; padding-right: 16px; }
}
