/* РОП surface — Bruddle neo-brutalism (tokens traced to design-system/bruddle).
   cream page, white cards, pure-black 1px border, hard offset shadows, lavender
   accent, pastel statuses, hierarchy by weight+size (text is pure black). */
@import url('https://fonts.googleapis.com/css2?family=Roboto+Flex:opsz,wght@8..144,100..1000&display=swap');

:root {
  --c-primary-pale: #EDE4FA;
  --c-primary: #AE7AFF;
  --c-primary-deep: #8C62CD;
  --c-yellow-pale: #FEFAED; --c-yellow: #FAEBA4;
  --c-mint-pale: #E8FAEF;   --c-mint: #99E9AB;
  --c-coral-pale: #FBE7EA;  --c-coral: #E99B98;
  --c-slate-pale: #E6E8EC;  --c-slate: #5F646D;
  --c-white: #FFFFFF; --c-cream: #FAF4F0; --c-graphite: #161616;

  --c-page-bg: var(--c-cream);
  --c-card-bg: var(--c-white);
  --c-line: #000000;
  --c-ink: #000000;
  --radius-card: 2px; --radius-btn: 4px; --radius-input: 4px;
  --shadow: 6px 6px 0 #000; --shadow-sm: 3px 3px 0 #000; --shadow-lg: 8px 8px 0 #000;
}
[data-theme="dark"] {
  --c-page-bg: var(--c-graphite); --c-card-bg: var(--c-graphite);
  --c-line: #FFF; --c-ink: #FFF;
  --shadow: 6px 6px 0 #FFF; --shadow-sm: 3px 3px 0 #FFF; --shadow-lg: 8px 8px 0 #FFF;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--c-page-bg); color: var(--c-ink);
  font-family: 'Roboto Flex', system-ui, -apple-system, sans-serif;
  font-size: 15px; line-height: 1.4;
}
h1,h2,h3 { margin: 0 0 .4em; font-weight: 800; letter-spacing: -.01em; }
h1 { font-size: 25px; } h2 { font-size: 19px; } h3 { font-size: 15px; }
.hidden { display: none !important; }
.muted { font-weight: 600; opacity: .6; }

/* Buttons */
button, .btn {
  font: inherit; font-weight: 800; cursor: pointer;
  background: var(--c-card-bg); color: var(--c-ink);
  border: 1px solid var(--c-line); border-radius: var(--radius-btn);
  box-shadow: var(--shadow-sm); padding: 9px 15px;
  transition: transform .04s ease, box-shadow .04s ease;
}
button:hover, .btn:hover { transform: translate(-1px,-1px); box-shadow: 4px 4px 0 var(--c-line); }
button:active { transform: translate(2px,2px); box-shadow: 1px 1px 0 var(--c-line); }
button.primary { background: var(--c-primary); }
button.ghost { box-shadow: none; font-weight: 700; }
button.tiny { padding: 4px 10px; font-size: 13px; }
button:disabled { opacity: .5; cursor: not-allowed; box-shadow: var(--shadow-sm); transform: none; }

/* Inputs */
input[type=text], input[type=email], textarea, select {
  font: inherit; width: 100%; background: var(--c-card-bg); color: var(--c-ink);
  border: 1px solid var(--c-line); border-radius: var(--radius-input);
  padding: 9px 12px; box-shadow: var(--shadow-sm);
}
textarea { resize: vertical; min-height: 64px; }
label { display: block; font-weight: 800; margin: 12px 0 5px; }

/* Cards */
.card { background: var(--c-card-bg); border: 1px solid var(--c-line);
  border-radius: var(--radius-card); box-shadow: var(--shadow); padding: 18px; margin-bottom: 18px; }

/* Topbar */
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 12px 18px; border-bottom: 2px solid var(--c-line); background: var(--c-card-bg);
  position: sticky; top: 0; z-index: 20; }
.topbar .brand { font-weight: 800; font-size: 17px; }
.topbar .nav { display: flex; gap: 8px; flex-wrap: wrap; }
.wrap { max-width: 1320px; margin: 0 auto; padding: 18px; }

/* Login */
.login-box { max-width: 420px; margin: 8vh auto; }

/* ── Drawer (шторка) ─────────────────────────────────────────────── */
#drawer-backdrop { position: fixed; inset: 0; background: rgba(0,0,0,.35); z-index: 30; }
#drawer {
  position: fixed; z-index: 40; background: var(--c-card-bg);
  border-left: 2px solid var(--c-line); box-shadow: var(--shadow-lg);
  display: flex; flex-direction: column;
  top: 0; right: 0; height: 100vh; width: 420px; max-width: 92vw;
  transition: transform .22s ease;
}
#drawer.closed { transform: translateX(105%); }
#drawer .drawer-head { display: flex; align-items: center; justify-content: space-between;
  padding: 14px 16px; border-bottom: 2px solid var(--c-line); }
#drawer .drawer-body { padding: 14px 16px; overflow-y: auto; flex: 1; }
#drawer .drawer-foot { border-top: 2px solid var(--c-line); padding: 12px 16px; background: var(--c-card-bg); }
.dev-card { border: 1px solid var(--c-line); border-radius: var(--radius-btn);
  box-shadow: var(--shadow-sm); padding: 12px; margin: 10px 0; background: var(--c-card-bg); }
.dev-card .dev-head { display: flex; justify-content: space-between; align-items: start; gap: 8px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.chip { border: 1px solid var(--c-line); border-radius: 999px; padding: 3px 11px;
  font-weight: 700; font-size: 13px; background: var(--c-slate-pale); }
.matrix-count { font-weight: 800; margin: 6px 0 10px; }

/* ── Messenger chat ──────────────────────────────────────────────── */
.chat { display: flex; flex-direction: column; gap: 12px; padding: 12px; }
.msg { display: flex; gap: 9px; align-items: flex-end; max-width: 92%; }
.msg.actor { align-self: flex-start; }
.msg.ziina { align-self: flex-end; flex-direction: row-reverse; }
.avatar { flex: 0 0 34px; width: 34px; height: 34px; border-radius: 999px;
  border: 1px solid var(--c-line); display: flex; align-items: center; justify-content: center;
  font-weight: 800; font-size: 12px; box-shadow: var(--shadow-sm); background: var(--c-slate-pale); }
.avatar.ziina { background: var(--c-primary); }
.bubble { border: 1px solid var(--c-line); border-radius: 14px; padding: 8px 12px;
  box-shadow: var(--shadow-sm); background: var(--c-card-bg); }
.msg.actor .bubble { border-bottom-left-radius: 4px; background: var(--c-white); }
.msg.ziina .bubble { border-bottom-right-radius: 4px; background: var(--c-primary-pale); }
.bubble .who { font-weight: 800; font-size: 11px; text-transform: uppercase; letter-spacing: .03em; margin-bottom: 2px; }
.bubble .txt { white-space: pre-wrap; }
.bubble.breach { border-width: 2px; border-color: #B00020; }

/* Badges under Ziina bubbles */
.badges { display: flex; flex-wrap: wrap; gap: 5px; margin: 6px 0 0; justify-content: flex-end; }
.msg.ziina .zmeta { max-width: 100%; }
.badge { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; font-weight: 800;
  padding: 3px 9px; border: 1px solid var(--c-line); border-radius: 999px; white-space: nowrap; }
.badge.up { background: var(--c-mint); } .badge.hold { background: var(--c-primary-pale); }
.badge.flat { background: var(--c-slate-pale); } .badge.call { background: var(--c-yellow); }
.badge.wait { background: var(--c-primary-pale); } .badge.done { background: var(--c-mint); }
.badge.warn { background: var(--c-coral); }
.reasoning { margin-top: 6px; font-size: 13px; }
.reasoning summary { font-weight: 800; cursor: pointer; }
.reasoning .body { border-left: 3px solid var(--c-primary); padding: 4px 0 4px 9px; margin-top: 4px; }

/* Feedback under Ziina turn */
.fb { margin-top: 8px; display: flex; flex-direction: column; gap: 6px; align-items: flex-end; }
.fb .vote { display: inline-flex; gap: 6px; }
.fb .vote button.on { background: var(--c-primary); }
.fb textarea { min-height: 40px; font-size: 13px; border-color: var(--c-primary); border-width: 2px; }

/* ── Desktop columns ─────────────────────────────────────────────── */
.matrix { display: flex; gap: 16px; overflow-x: auto; padding-bottom: 8px; }
.run-col { flex: 0 0 380px; border: 1px solid var(--c-line); border-radius: var(--radius-card);
  box-shadow: var(--shadow-sm); background: var(--c-card-bg); display: flex; flex-direction: column; }
.run-head { padding: 11px 14px; border-bottom: 2px solid var(--c-line); }
.run-head .dev { font-weight: 800; font-size: 14px; }
.run-tally { display: flex; flex-wrap: wrap; gap: 5px 9px; font-size: 12px; font-weight: 800;
  padding: 9px 14px; border-bottom: 1px dashed var(--c-line); }
.run-tally .breach { color: #B00020; }
.verdict-box { padding: 10px 14px; border-top: 1px dashed var(--c-line); display: flex; flex-direction: column; gap: 6px; }

/* ── Mobile modes (carousel + by-turn) ───────────────────────────── */
#mobile-modes { display: none; }
.mode-toggle { display: flex; gap: 8px; margin-bottom: 12px; }
.mode-toggle button.on { background: var(--c-primary); }
.car-head { display: flex; flex-direction: column; gap: 8px; margin-bottom: 8px; }
.dots { display: flex; gap: 6px; justify-content: center; }
.dot { width: 9px; height: 9px; border-radius: 999px; border: 1px solid var(--c-line); background: var(--c-card-bg); }
.dot.on { background: var(--c-primary); }
.branch-chips { display: flex; gap: 6px; overflow-x: auto; }
.branch-chips .chip.on { background: var(--c-primary); }
.car-stage { border: 1px solid var(--c-line); border-radius: var(--radius-card);
  box-shadow: var(--shadow-sm); background: var(--c-card-bg); }
.car-stage .run-head { border-radius: var(--radius-card) var(--radius-card) 0 0; }

.byturn-step { display: flex; align-items: center; justify-content: center; gap: 14px;
  font-weight: 800; margin-bottom: 12px; }
.byturn-branch { border: 1px solid var(--c-line); border-radius: var(--radius-card);
  box-shadow: var(--shadow-sm); background: var(--c-card-bg); margin-bottom: 12px; }
.byturn-branch .bb-head { padding: 8px 12px; border-bottom: 2px solid var(--c-line); font-weight: 800; font-size: 13px; }
.byturn-branch .bb-body { padding: 10px 12px; }

/* Session list */
.sess-row { display: flex; justify-content: space-between; align-items: center; gap: 10px;
  border: 1px solid var(--c-line); border-radius: var(--radius-btn); box-shadow: var(--shadow-sm);
  padding: 11px 14px; margin-bottom: 10px; background: var(--c-card-bg); }
.status-pill { font-size: 12px; font-weight: 800; padding: 2px 10px; border: 1px solid var(--c-line); border-radius: 999px; }
.status-pill.running { background: var(--c-yellow); }
.status-pill.completed { background: var(--c-mint); }
.status-pill.paused, .status-pill.aborted, .status-pill.errored { background: var(--c-coral); }

/* ── Mode switch + live composer ─────────────────────────────────── */
.mode-switch { display: inline-flex; border: 1px solid var(--c-line); border-radius: 999px;
  overflow: hidden; box-shadow: var(--shadow-sm); }
.mode-switch button { box-shadow: none; border: none; border-radius: 0; padding: 8px 16px; }
.mode-switch button.on { background: var(--c-primary); }
.mode-switch button:hover { transform: none; box-shadow: none; }

.composer { margin-top: 14px; display: flex; flex-direction: column; gap: 8px; }
.composer-row { display: flex; gap: 8px; }
.composer-row input { flex: 1; }
.composer-actions { display: flex; gap: 10px; flex-wrap: wrap; }
.role-picker { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.role-picker-label { font-weight: 800; font-size: 13px; }
.role-chips { display: flex; gap: 6px; flex-wrap: wrap; }
.role-chips .chip { cursor: pointer; }
.role-chips .chip.on { background: var(--c-primary); }
.msg.system { align-self: center; }
.msg.system .bubble { background: var(--c-slate-pale); font-style: italic; }
.msg.actor.event .bubble { background: var(--c-yellow-pale); border-style: dashed; }
.msg.actor.event .avatar { background: var(--c-yellow); }

.toast { position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%);
  background: var(--c-ink); color: var(--c-page-bg); padding: 10px 18px; border-radius: var(--radius-btn);
  font-weight: 800; box-shadow: var(--shadow-sm); z-index: 60; }

/* ── Responsive switch ───────────────────────────────────────────── */
@media (max-width: 860px) {
  .wrap { padding: 12px; }
  #drawer { right: 0; left: 0; top: auto; bottom: 0; width: 100%; max-width: 100%; height: 86vh;
    border-left: none; border-top: 2px solid var(--c-line); border-radius: var(--radius-card) var(--radius-card) 0 0; }
  #drawer.closed { transform: translateY(105%); }
  .matrix { display: none; }
  #mobile-modes { display: block; }
  .topbar .nav button.label-long { font-size: 0; }   /* icon-only feel on tiny screens */
}
