/* ── Reset & Base ─────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:        #FFE4E1;
  --surface:   #F4F4F0;
  --surface2:  #FFFFFF;
  --text:      #000000;
  --muted:     #6A7282;
  --teal:      #1D9E75;
  --blue:      #378ADD;
  --coral:     #D85A30;
  --gold:      #FFD700;
  --cyan:      #00FFFF;
  --pink:      #FF69B4;
  --green-live:#00C950;

  --bw:        2px;          /* border width */
  --bw-mid:    4px;
  --bw-thick:  6px;
  --sh:        4px 4px 0px #000;
  --sh-sm:     2px 2px 0px #000;
  --sh-lg:     6px 6px 0px #000;
  --sh-xl:     8px 8px 0px #000;

  --r:         14px;
  --r-lg:      24px;
  --font:      'Space Mono', 'Menlo', 'Courier New', monospace;
  --sidebar-w: 290px;
}

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  height: 100dvh;
  display: flex;
  overflow: hidden;
}

/* ── Layout ───────────────────────────────────── */
.sidebar {
  width: var(--sidebar-w);
  min-width: var(--sidebar-w);
  background: var(--surface2);
  border-right: var(--bw-mid) solid #000;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
}

.main {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--surface);
}

/* ── Sidebar header (black bar) ───────────────── */
.sidebar-header {
  padding: 16px 18px 14px;
  background: #000;
  border-bottom: var(--bw-mid) solid #000;
}

.logo {
  font-size: 13px;
  font-weight: 700;
  color: #fff;
  text-transform: uppercase;
  letter-spacing: 1px;
}

.logo span {
  color: #6A7282;
  font-weight: 400;
  font-size: 10px;
  display: block;
  margin-top: 3px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.mode-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 10px;
  font-weight: 700;
  padding: 3px 8px;
  margin-top: 10px;
  background: #1a1a1a;
  color: #6A7282;
  border: var(--bw) solid #333;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.mode-badge .dot {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: #6A7282;
}
.mode-badge.dev .dot  { background: #f59e0b; }
.mode-badge.test .dot { background: #60a5fa; }
.mode-badge.prod .dot { background: #34d399; }

/* ── User badge ───────────────────────────────── */
.user-badge {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 10px;
  padding: 6px 8px;
  background: #1a1a1a;
  border: var(--bw) solid #333;
}

.user-avatar {
  width: 22px; height: 22px;
  border-radius: 50%;
  background: var(--gold);
  color: #000;
  font-size: 10px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  border: var(--bw) solid #000;
}

.user-name {
  font-size: 11px;
  color: #ccc;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.user-logout {
  background: none;
  border: none;
  color: #555;
  font-size: 12px;
  cursor: pointer;
  padding: 0 2px;
  line-height: 1;
  flex-shrink: 0;
}
.user-logout:hover { color: #ff6b6b; }

/* ── Brief section ────────────────────────────── */
.brief-section {
  padding: 16px 18px;
  border-bottom: var(--bw) solid #000;
}

.brief-label {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--muted);
  margin-bottom: 8px;
}

.brief-input {
  width: 100%;
  background: var(--surface2);
  border: var(--bw) solid #000;
  color: var(--text);
  font-size: 12px;
  font-family: var(--font);
  padding: 10px 12px;
  resize: vertical;
  min-height: 120px;
  line-height: 1.6;
  box-shadow: var(--sh-sm);
  transition: box-shadow 0.1s;
}

.brief-input:focus {
  outline: none;
  box-shadow: var(--sh);
}

.brief-input::placeholder { color: #bbb; }

/* ── Buttons ──────────────────────────────────── */
.btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  width: 100%;
  padding: 11px 16px;
  border: var(--bw) solid #000;
  font-size: 12px;
  font-weight: 700;
  font-family: var(--font);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  cursor: pointer;
  transition: box-shadow 0.08s, transform 0.08s;
  box-shadow: var(--sh);
}

.btn:active:not(:disabled) {
  box-shadow: none;
  transform: translate(4px, 4px);
}

.btn:disabled { opacity: 0.45; cursor: not-allowed; box-shadow: none; }

.btn-primary {
  background: var(--gold);
  color: #000;
  margin-top: 12px;
}
.btn-primary:hover:not(:disabled) { background: #ffd000; }

.btn-secondary {
  background: var(--surface2);
  color: #000;
}

/* ── Agents in sidebar ────────────────────────── */
.agents-section {
  padding: 16px 18px;
  flex: 1;
}

.agent-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 0;
  border-bottom: 1px dashed #ccc;
}

.agent-item:last-child { border-bottom: none; }

.avatar {
  width: 36px; height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 700;
  color: #fff;
  flex-shrink: 0;
  border: var(--bw) solid #000;
  box-shadow: var(--sh-sm);
}

.agent-info { flex: 1; }

.agent-name {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.agent-status {
  font-size: 9px;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-top: 1px;
}

.status-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: #ddd;
  border: 1px solid #999;
  flex-shrink: 0;
}

.status-dot.thinking {
  background: var(--gold);
  border-color: #000;
  animation: pulse 1s ease-in-out infinite;
}

.status-dot.done {
  background: var(--teal);
  border-color: #000;
}

/* ── Chat header (black bar) ──────────────────── */
.chat-header {
  padding: 0 20px;
  height: 66px;
  border-bottom: var(--bw-mid) solid #000;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: #000;
  flex-shrink: 0;
}

.chat-title {
  font-size: 14px;
  font-weight: 700;
  color: #fff;
  text-transform: uppercase;
  letter-spacing: 1px;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 10px;
}

.live-indicator {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 10px;
  font-weight: 700;
  color: var(--green-live);
  letter-spacing: 1px;
  text-transform: uppercase;
}

.live-indicator.hidden { display: none; }

.live-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--green-live);
  animation: pulse 1.2s ease-in-out infinite;
}

.round-badge {
  font-size: 10px;
  font-weight: 700;
  color: #6A7282;
  background: #1a1a1a;
  padding: 3px 10px;
  border: 1px solid #333;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* ── Messages area ────────────────────────────── */
.messages {
  flex: 1;
  overflow-y: auto;
  padding: 20px 24px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

/* ── Phase separator ──────────────────────────── */
.phase-sep {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 18px 0 10px;
}

.phase-sep::before,
.phase-sep::after {
  content: '';
  flex: 1;
  height: 2px;
  background: #000;
}

.phase-label {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: #000;
  background: var(--gold);
  border: var(--bw) solid #000;
  padding: 3px 10px;
  white-space: nowrap;
  box-shadow: var(--sh-sm);
}

/* ── Message bubble ───────────────────────────── */
.msg {
  display: flex;
  gap: 10px;
  padding: 4px 0;
  animation: fadeIn 0.2s ease;
}

/* Client messages → right-aligned, yellow */
.msg.msg-client {
  flex-direction: row-reverse;
}

.msg-avatar {
  width: 40px; height: 40px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 700;
  color: #fff;
  flex-shrink: 0;
  margin-top: 20px;
  border: var(--bw) solid #000;
  box-shadow: var(--sh-sm);
}

.msg-body { flex: 1; min-width: 0; max-width: 82%; }

.msg-client .msg-body { align-items: flex-end; display: flex; flex-direction: column; }

.msg-meta {
  display: flex;
  align-items: baseline;
  gap: 8px;
  margin-bottom: 5px;
}

.msg-client .msg-meta { flex-direction: row-reverse; }

.msg-name {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.msg-role {
  font-size: 9px;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.msg-time {
  font-size: 10px;
  color: var(--muted);
  font-weight: 700;
}

.msg-cached {
  font-size: 9px;
  font-weight: 700;
  color: var(--muted);
  background: #f0f0f0;
  border: 1px solid #ccc;
  padding: 1px 6px;
}

.msg-text {
  font-size: 12px;
  line-height: 1.65;
  color: var(--text);
  background: var(--surface2);
  border: var(--bw) solid #000;
  border-radius: 14px 14px 14px 6px;   /* agent: bottom-left squared */
  padding: 14px;
  white-space: pre-wrap;
  word-break: break-word;
  box-shadow: var(--sh);
}

.msg-client .msg-text {
  background: var(--gold);
  border-radius: 14px 14px 6px 14px;   /* client: bottom-right squared */
}

.msg-text.final {
  border-color: var(--teal);
  box-shadow: 4px 4px 0px var(--teal);
}

/* ── Typing indicator ─────────────────────────── */
.typing-indicator {
  display: flex;
  gap: 10px;
  padding: 4px 0;
  animation: fadeIn 0.2s ease;
}

.typing-bubble {
  background: var(--surface2);
  border: var(--bw) solid #000;
  border-radius: 14px 14px 14px 6px;
  padding: 14px 18px;
  display: flex;
  gap: 5px;
  align-items: center;
  box-shadow: var(--sh);
  margin-top: 20px;
}

.typing-bubble span {
  width: 7px; height: 7px;
  border-radius: 50%;
  background: #000;
  animation: bounce 1.2s ease-in-out infinite;
}

.typing-bubble span:nth-child(2) { animation-delay: 0.2s; }
.typing-bubble span:nth-child(3) { animation-delay: 0.4s; }

/* ── Thought bubble ───────────────────────────── */
.thought-line {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 2px 0 2px 50px;
  font-size: 11px;
  font-style: italic;
  color: var(--muted);
  animation: fadeIn 0.2s ease;
}

.thought-dot {
  width: 5px; height: 5px;
  border-radius: 50%;
  flex-shrink: 0;
  opacity: 0.6;
}

.thought-name {
  font-style: normal;
  font-weight: 700;
  font-size: 10px;
  opacity: 0.8;
  white-space: nowrap;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.thought-text { opacity: 0.65; }

.thought-text::after {
  content: ' ·';
  opacity: 0.4;
}

/* ── Agent-to-Agent ping ──────────────────────── */
.ping-wrap {
  margin: 6px 0 6px 50px;
  animation: fadeIn 0.25s ease;
}

.ping-reply { margin-left: 90px; }

.ping-header {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 5px;
}

.ping-icon { font-size: 12px; opacity: 0.7; }

.ping-label {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.3px;
  text-transform: uppercase;
}

.ping-arrow { opacity: 0.5; font-style: normal; }

.ping-time {
  font-size: 10px;
  color: var(--muted);
  margin-left: auto;
}

.ping-bubble {
  font-size: 12px;
  line-height: 1.55;
  color: var(--text);
  background: #fffbe6;
  border: var(--bw) solid #000;
  border-left: 4px solid;
  border-radius: 0 14px 14px 14px;
  padding: 10px 14px;
  white-space: pre-wrap;
  word-break: break-word;
  max-width: 560px;
  box-shadow: var(--sh-sm);
}

/* ── Tool-use indicator ───────────────────────── */
.tool-use-line {
  font-size: 11px;
  color: var(--muted);
  padding: 3px 0 3px 50px;
  display: flex;
  align-items: center;
  gap: 5px;
  flex-wrap: wrap;
  animation: fadeIn 0.2s ease;
}

.tool-agent { font-weight: 700; text-transform: uppercase; font-size: 10px; }

.tool-name {
  background: #000;
  color: var(--cyan);
  border: none;
  padding: 2px 8px;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.tool-detail {
  color: var(--muted);
  font-size: 10px;
  opacity: 0.8;
}

/* ── Parallel panel ───────────────────────────── */
.parallel-panel {
  margin: 10px 0 14px;
  border: var(--bw-mid) solid #000;
  background: rgba(255, 255, 255, 0.6);
  box-shadow: var(--sh-lg);
  animation: fadeIn 0.3s ease;
  transition: opacity 0.5s ease;
}

.parallel-panel-done { opacity: 0.65; }

.parallel-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  background: #000;
  font-size: 10px;
  font-weight: 700;
  color: #fff;
  text-transform: uppercase;
  letter-spacing: 1px;
}

.parallel-live-dot {
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--green-live);
  flex-shrink: 0;
  animation: pulse 1.2s ease-in-out infinite;
}

.parallel-cols {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
}

.parallel-col {
  padding: 14px;
  border-right: var(--bw) solid #000;
  transition: background 0.3s ease;
}

.parallel-col:last-child { border-right: none; }

.parallel-col.pc-done { background: rgba(0, 201, 80, 0.07); }

.pc-head {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
}

.pc-avatar {
  width: 28px; height: 28px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 700;
  color: #fff;
  flex-shrink: 0;
  border: var(--bw) solid #000;
  box-shadow: var(--sh-sm);
}

.pc-name {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  flex: 1;
}

.pc-status { display: flex; align-items: center; }

.pc-dot {
  width: 7px; height: 7px;
  border-radius: 50%;
  animation: pulse 1.2s ease-in-out infinite;
  border: 1px solid #000;
}

.pc-thought {
  font-size: 11px;
  font-style: italic;
  color: var(--muted);
  line-height: 1.5;
  min-height: 36px;
  transition: color 0.3s ease;
}

.pc-done .pc-thought {
  color: var(--teal);
  font-style: normal;
  font-weight: 700;
}

.pc-result {
  margin-top: 8px;
  font-size: 10px;
  color: var(--muted);
  line-height: 1.5;
  border-top: 1px solid #000;
  padding-top: 8px;
  opacity: 0.85;
}

.pc-result.hidden { display: none; }

/* ── Blackboard card ──────────────────────────── */
.bb-card {
  border: var(--bw-mid) solid #000;
  background: var(--surface2);
  margin: 10px 0 18px;
  box-shadow: var(--sh-lg);
  animation: fadeIn 0.3s ease;
}

.bb-final {
  border-color: #000;
  box-shadow: 6px 6px 0px var(--pink);
}

.bb-header {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: #fff;
  background: #000;
  padding: 8px 14px;
}

.bb-final .bb-header { background: #000; }

.bb-row {
  display: flex;
  gap: 12px;
  padding: 8px 14px;
  border-bottom: 1px solid #ddd;
  font-size: 12px;
  line-height: 1.5;
  animation: fadeIn 0.3s ease;
}

.bb-row:last-child { border-bottom: none; }

.bb-label {
  flex-shrink: 0;
  width: 110px;
  color: var(--muted);
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding-top: 1px;
}

.bb-value {
  color: var(--text);
  flex: 1;
}

/* ── Concept image ────────────────────────────── */
.msg-image-wrap {
  margin-top: 6px;
  border: var(--bw) solid #000;
  box-shadow: var(--sh);
  max-width: 480px;
  overflow: hidden;
}

.msg-image { display: block; width: 100%; height: auto; }

.msg-image-caption {
  padding: 6px 12px;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--muted);
  background: var(--surface2);
  border-top: 1px solid #000;
}

/* ── Error block ──────────────────────────────── */
.error-block {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  background: #fff0f0;
  border: var(--bw) solid #000;
  box-shadow: var(--sh);
  padding: 16px 18px;
  margin: 12px 0;
  animation: fadeIn 0.2s ease;
}

.error-icon { font-size: 28px; line-height: 1; flex-shrink: 0; }

.error-body { display: flex; flex-direction: column; gap: 5px; }

.error-title {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: #cc0000;
}

.error-msg {
  font-size: 12px;
  color: var(--muted);
  line-height: 1.6;
}

.error-msg.error-detail {
  font-size: 10px;
  opacity: 0.7;
  margin-top: 2px;
  font-style: italic;
}

.error-link {
  color: #000;
  font-weight: 700;
  text-decoration: underline;
  text-decoration-style: wavy;
  text-decoration-color: var(--gold);
}
.error-link:hover { text-decoration-color: var(--coral); }

/* ── Download bar ─────────────────────────────── */
.download-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 20px;
  background: var(--gold);
  border-top: var(--bw-mid) solid #000;
  gap: 12px;
}

.download-bar-label {
  font-size: 11px;
  font-weight: 700;
  color: #000;
  text-transform: uppercase;
  letter-spacing: 0.8px;
}

.btn-download {
  flex-shrink: 0;
  padding: 8px 18px;
  background: #000;
  color: var(--gold);
  border: var(--bw) solid #000;
  font-size: 11px;
  font-weight: 700;
  font-family: var(--font);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  cursor: pointer;
  transition: box-shadow 0.08s, transform 0.08s;
  box-shadow: var(--sh-sm);
}

.btn-download:hover  { box-shadow: var(--sh); }
.btn-download:active { box-shadow: none; transform: translate(2px,2px); }
.btn-download:disabled { opacity: 0.4; cursor: default; }

.btn-download-done {
  background: var(--teal) !important;
  color: #fff !important;
}

/* ── Feedback bar ─────────────────────────────── */
.feedback-bar {
  border-top: var(--bw-mid) solid #000;
  background: var(--surface2);
  padding: 14px 20px;
  flex-shrink: 0;
}

.feedback-bar.hidden { display: none; }

.feedback-label {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--muted);
  margin-bottom: 8px;
}

.feedback-row {
  display: flex;
  gap: 8px;
  align-items: flex-end;
}

.feedback-input {
  flex: 1;
  background: #F3F4F6;
  border: var(--bw) solid #000;
  color: var(--text);
  font-size: 12px;
  font-weight: 700;
  font-family: var(--font);
  text-transform: uppercase;
  letter-spacing: 0.3px;
  padding: 9px 12px;
  resize: none;
  min-height: 40px;
  max-height: 120px;
  line-height: 1.4;
  transition: box-shadow 0.1s;
}

.feedback-input:focus { outline: none; box-shadow: var(--sh-sm); }
.feedback-input::placeholder { color: var(--muted); font-weight: 700; }

.target-select {
  background: var(--surface2);
  border: var(--bw) solid #000;
  color: var(--text);
  font-size: 11px;
  font-weight: 700;
  font-family: var(--font);
  text-transform: uppercase;
  padding: 9px 8px;
  cursor: pointer;
  height: 40px;
}

.target-select:focus { outline: none; }

.send-btn {
  padding: 0 18px;
  height: 40px;
  background: #000;
  color: var(--gold);
  border: var(--bw) solid #000;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  flex-shrink: 0;
  font-size: 11px;
  font-weight: 700;
  font-family: var(--font);
  letter-spacing: 0.5px;
  text-transform: uppercase;
  white-space: nowrap;
  transition: box-shadow 0.08s, transform 0.08s;
  box-shadow: var(--sh-sm);
}

.send-btn:hover:not(:disabled) { box-shadow: var(--sh); }
.send-btn:active:not(:disabled) { box-shadow: none; transform: translate(2px,2px); }
.send-btn:disabled { opacity: 0.35; cursor: not-allowed; }

/* ── Empty state ──────────────────────────────── */
.empty-state {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  color: var(--muted);
  text-align: center;
  padding: 40px;
}

.empty-state .big-icon { font-size: 52px; opacity: 0.5; }

.empty-state p {
  font-size: 12px;
  font-weight: 700;
  max-width: 300px;
  line-height: 1.7;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

/* ── Animations ───────────────────────────────── */
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(5px); }
  to   { opacity: 1; transform: translateY(0); }
}

@keyframes bounce {
  0%, 60%, 100% { transform: translateY(0); }
  30%           { transform: translateY(-6px); }
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.25; }
}

/* ── Scrollbar ────────────────────────────────── */
::-webkit-scrollbar { width: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #000; border-radius: 0; }

/* ── Mobile ───────────────────────────────────── */
@media (max-width: 680px) {
  body { flex-direction: column; }

  .sidebar {
    width: 100%;
    min-width: unset;
    border-right: none;
    border-bottom: var(--bw-mid) solid #000;
    max-height: 50dvh;
    transition: max-height 0.3s ease;
  }

  /* После отправки брифа — сворачиваем до минимума */
  .sidebar.session-active {
    max-height: none;
    overflow: visible;
  }
  .sidebar.session-active .brief-section {
    display: none;
  }

  .agents-section { display: none; }
  .main { min-height: 0; }
  .messages { padding: 12px 16px; }
  .msg-text { font-size: 12px; }
  :root { --sidebar-w: 100%; }
}

/* ═══════════════════════════════════════════════
   GAMIFICATION LAYER
   ═══════════════════════════════════════════════ */

/* ── Agent RPG stat bars ──────────────────────── */
.agent-name-row {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 3px;
}

.agent-chip {
  font-size: 8px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.3px;
  color: var(--muted);
  background: #f0f0f0;
  border: 1px solid #ccc;
  padding: 1px 5px;
}

.agent-model-label {
  font-size: 9px;
  font-weight: 700;
  color: var(--muted);
  letter-spacing: 0.3px;
  margin-bottom: 4px;
  opacity: 0.6;
}

.agent-stat-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 3px;
}

.agent-stat-label {
  font-size: 9px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--muted);
}

.agent-stat-pct {
  font-size: 9px;
  font-weight: 700;
  color: #000;
}

.agent-stat-bar-wrap {
  height: 8px;
  background: #E5E7EB;
  border: 1px solid #000;
  overflow: hidden;
}

.agent-stat-fill {
  height: 100%;
  background: var(--teal);
  transition: width 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275),
              background 0.3s ease;
}

/* Глоу для Марины при критике — одноразовый flash */
.agent-stat-fill.glow {
  animation: stat-glow 0.6s ease-in-out 2;
}

@keyframes stat-glow {
  0%,100% { filter: brightness(1); }
  50%     { filter: brightness(1.5) drop-shadow(0 0 3px currentColor); }
}

/* Vibe EQ для Маши */
.vibe-eq {
  display: flex;
  align-items: flex-end;
  gap: 2px;
  height: 16px;
  margin-top: 3px;
}

.vibe-bar {
  flex: 1;
  background: var(--coral);
  border: 1px solid #000;
  min-height: 3px;
  transition: height 0.2s ease;
}

.vibe-eq.active .vibe-bar {
  animation: eq-dance 0.5s ease-in-out 4 alternate;
}

.vibe-bar:nth-child(1)  { animation-delay: 0s; }
.vibe-bar:nth-child(2)  { animation-delay: 0.05s; }
.vibe-bar:nth-child(3)  { animation-delay: 0.1s; }
.vibe-bar:nth-child(4)  { animation-delay: 0.15s; }
.vibe-bar:nth-child(5)  { animation-delay: 0.2s; }
.vibe-bar:nth-child(6)  { animation-delay: 0.15s; }
.vibe-bar:nth-child(7)  { animation-delay: 0.1s; }
.vibe-bar:nth-child(8)  { animation-delay: 0.05s; }
.vibe-bar:nth-child(9)  { animation-delay: 0.1s; }
.vibe-bar:nth-child(10) { animation-delay: 0.2s; }

@keyframes eq-dance {
  from { transform: scaleY(0.4); }
  to   { transform: scaleY(1.5); }
}

/* ── Agent Team Bar ───────────────────────────── */
/* agent-team-bar скрыт — активный агент подсвечивается в сайдбаре */
.agent-team-bar { display: none !important; }

.agent-item--thinking {
  background: rgba(0,0,0,0.04);
  margin: 0 -8px;
  padding: 10px 8px;
  border-radius: 6px;
  border-bottom-color: transparent !important;
}
.agent-item--thinking .avatar {
  box-shadow: 0 0 0 3px currentColor, var(--sh-sm);
  animation: avatar-pulse 1s ease-in-out infinite alternate;
}
@keyframes avatar-pulse {
  from { transform: scale(1); }
  to   { transform: scale(1.08); }
}
.agent-item--thinking .agent-stat-label {
  color: var(--text);
  font-weight: 700;
}

/* Panic button → левый нижний угол */
.panic-btn-ORIGINAL_HIDDEN {
  display: flex;
  align-items: stretch;
  background: var(--surface);
  border-bottom: var(--bw-mid) solid #000;
  overflow: hidden;
}
.agent-team-bar.hidden { display: none; }

.atb-agent {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1;
  padding: 8px 14px;
  min-width: 0;
}
.atb-agent + .atb-agent {
  border-left: var(--bw) solid #000;
}
.atb-avatar {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  border: var(--bw) solid #000;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 12px;
  color: #fff;
  flex-shrink: 0;
  transition: transform 0.2s;
}
.atb-agent[data-agent] .status-dot.thinking ~ .atb-avatar,
.atb-agent .status-dot.thinking + * .atb-avatar { transform: scale(1.1); }

/* highlight avatar when thinking */
.atb-agent:has(.status-dot.thinking) .atb-avatar {
  box-shadow: 0 0 0 2px #000, 0 0 0 4px var(--gold);
  transform: scale(1.08);
}
.atb-agent:has(.status-dot.done) .atb-avatar {
  box-shadow: 0 0 0 2px var(--teal);
}

.atb-info {
  display: flex;
  flex-direction: column;
  min-width: 0;
  flex: 1;
}
.atb-name {
  font-size: 10px;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.3;
}
.atb-chip {
  font-size: 8px;
  opacity: 0.55;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.3;
}
.atb-agent .status-dot {
  flex-shrink: 0;
  width: 8px;
  height: 8px;
}

/* ── Level Map ────────────────────────────────── */
.level-map {
  background: #fff;
  border-bottom: var(--bw-mid) solid #000;
  padding: 14px 24px 10px;
  flex-shrink: 0;
  box-shadow: 0 4px 0 #000;
}

.level-map.hidden { display: none; }

.lm-inner {
  position: relative;
  padding-bottom: 4px;
}

.lm-bg-track {
  position: absolute;
  left: 20px;
  right: 20px;
  top: 19px;
  height: 8px;
  background: #E5E7EB;
  border: 2px solid #000;
  z-index: 1;
}

.lm-bg-fill {
  height: 100%;
  background: #000;
  width: 0%;
  transition: width 0.8s ease;
}

.lm-nodes {
  display: flex;
  justify-content: space-between;
  position: relative;
  z-index: 2;
}

.lm-node {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  width: 46px;
}

.lm-node-dot {
  width: 46px;
  height: 46px;
  background: #E5E7EB;
  border: var(--bw) solid #000;
  box-shadow: var(--sh-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  transition: background 0.3s, transform 0.3s, box-shadow 0.2s;
  position: relative;
}

.lm-node.active .lm-node-dot {
  background: var(--gold);
  transform: scale(1.15);
  box-shadow: var(--sh);
  animation: node-bounce 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.lm-node.done .lm-node-dot {
  background: var(--teal);
}

.lm-node-label {
  font-size: 9px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--muted);
  white-space: nowrap;
}

.lm-node.active .lm-node-label { color: #000; }
.lm-node.done  .lm-node-label  { color: var(--teal); }

/* Токен-звезда, прыгает по карте */
.lm-token {
  position: absolute;
  top: -14px;
  left: 0;
  font-size: 20px;
  line-height: 1;
  z-index: 10;
  pointer-events: none;
  transition: left 0.7s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  filter: drop-shadow(2px 2px 0px #000);
}

.lm-token.jumping {
  animation: token-jump 0.7s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

@keyframes node-bounce {
  0%  { transform: scale(1); }
  40% { transform: scale(1.4); }
  70% { transform: scale(1.05); }
  100%{ transform: scale(1.15); }
}

@keyframes token-jump {
  0%  { transform: translateY(0) scale(1); }
  35% { transform: translateY(-22px) scale(1.3); }
  70% { transform: translateY(-5px) scale(0.95); }
  100%{ transform: translateY(0) scale(1); }
}

/* ── Thought bubbles (lопать!) ────────────────── */
.thought-bubble {
  display: inline-block;
  background: var(--surface2);
  border: var(--bw) solid #000;
  box-shadow: var(--sh-sm);
  padding: 2px 8px;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.3px;
  cursor: pointer;
  margin-left: 6px;
  vertical-align: middle;
  transition: transform 0.1s;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

.thought-bubble:hover { transform: scale(1.08); background: var(--gold); }
.thought-bubble:active { transform: scale(0.9); }

.thought-bubble.popping {
  animation: bubble-pop 0.3s ease forwards;
}

@keyframes bubble-pop {
  0%  { transform: scale(1);    opacity: 1; }
  50% { transform: scale(1.5);  opacity: 0.7; }
  100%{ transform: scale(0);    opacity: 0; }
}


/* ── Panic button ─────────────────────────────── */
.panic-btn {
  position: fixed;
  bottom: 20px;
  left: 20px;
  width: 48px;
  height: 48px;
  background: #cc0000;
  border: var(--bw) solid #000;
  box-shadow: var(--sh);
  font-size: 22px;
  cursor: pointer;
  z-index: 100;
  transition: transform 0.15s, box-shadow 0.15s;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  display: flex;
  align-items: center;
  justify-content: center;
}

.panic-btn:hover { box-shadow: var(--sh-lg); }
.panic-btn:active { box-shadow: none; transform: translate(4px,4px); }

.panic-counter {
  position: fixed;
  bottom: 70px;
  left: 20px;
  right: auto;
  right: 22px;
  background: var(--gold);
  border: var(--bw) solid #000;
  font-size: 10px;
  font-weight: 700;
  width: 20px;
  height: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 101;
  animation: fadeIn 0.2s ease;
}

.panic-counter.hidden { display: none; }

/* Паника-режим: встряска страницы */
.panic-shake {
  animation: panic-shake 0.5s ease;
}

@keyframes panic-shake {
  0%,100%{ transform: translateX(0); }
  15%    { transform: translateX(-8px) rotate(-1deg); }
  30%    { transform: translateX(8px)  rotate(1deg); }
  45%    { transform: translateX(-5px) rotate(-0.5deg); }
  60%    { transform: translateX(5px)  rotate(0.5deg); }
  75%    { transform: translateX(-3px); }
  90%    { transform: translateX(3px); }
}

/* Стикеры-мемы (при панике) */
.sticker-msg {
  display: flex;
  gap: 10px;
  padding: 4px 0;
  animation: sticker-drop 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.sticker-bubble {
  background: var(--gold);
  border: var(--bw) solid #000;
  box-shadow: var(--sh);
  border-radius: 14px 14px 14px 6px;
  padding: 12px 16px;
  font-size: 13px;
  line-height: 1.5;
  max-width: 80%;
}

@keyframes sticker-drop {
  0%  { opacity: 0; transform: translateY(-20px) scale(0.8); }
  60% { transform: translateY(5px) scale(1.05); }
  100%{ opacity: 1; transform: translateY(0) scale(1); }
}

/* ── Sound toggle ─────────────────────────────── */
.sound-toggle {
  position: fixed;
  bottom: 20px;
  right: 76px;
  width: 48px;
  height: 48px;
  background: #fff;
  border: var(--bw) solid #000;
  box-shadow: var(--sh);
  font-size: 20px;
  cursor: pointer;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: box-shadow 0.1s, transform 0.1s;
}

.sound-toggle:active { box-shadow: none; transform: translate(2px,2px); }
.sound-toggle.muted { opacity: 0.45; }

/* ── Sticker message in chat ──────────────────── */
.msg-sticker {
  font-size: 32px;
  line-height: 1.2;
  margin-top: 4px;
}


/* ── Google fallback auth button ──────────────── */
.gsi-fallback-btn {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 10px 20px;
  background: #fff;
  color: #3c4043;
  border: 1px solid #dadce0;
  border-radius: 4px;
  font-family: 'Google Sans', Roboto, Arial, sans-serif;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s, box-shadow 0.15s;
  min-width: 200px;
  justify-content: center;
}
.gsi-fallback-btn:hover {
  background: #f8f9fa;
  box-shadow: 0 1px 3px rgba(0,0,0,0.15);
}
.gsi-fallback-btn:active {
  background: #e8eaed;
}

/* ── Presentation Cards ────────────────────────── */
.concept-gallery {
  margin: 20px 0;
  width: 100%;
}

.concept-gallery-title {
  font-family: var(--font);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--muted);
  margin-bottom: 14px;
  padding: 0 4px;
}

.concept-cards-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
}

@media (max-width: 900px) {
  .concept-cards-grid { grid-template-columns: 1fr; }
}

.concept-card {
  background: var(--surface2);
  border: var(--bw) solid #000;
  border-radius: var(--r);
  box-shadow: var(--sh);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transition: transform 0.15s, box-shadow 0.15s;
}
.concept-card:hover {
  transform: translate(-2px, -2px);
  box-shadow: var(--sh-lg);
}

.concept-card-img {
  width: 100%;
  aspect-ratio: 1 / 1;
  overflow: hidden;
  border-bottom: var(--bw) solid #000;
  background: #111;
}
.concept-card-img img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.concept-card-img--empty {
  display: flex;
  align-items: center;
  justify-content: center;
  background: #f0f0f0;
}
.concept-card-img--empty span {
  font-size: 48px;
  opacity: 0.2;
  font-family: var(--font);
}

.concept-card-body {
  padding: 14px 16px 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex: 1;
}

.concept-card-num {
  font-size: 20px;
  line-height: 1;
}

.concept-card-name {
  font-family: var(--font);
  font-size: 14px;
  font-weight: 700;
  line-height: 1.3;
  color: var(--text);
}

.concept-card-slogan {
  font-family: var(--font);
  font-size: 12px;
  font-style: italic;
  color: var(--teal);
  border-left: 3px solid var(--teal);
  padding-left: 8px;
  line-height: 1.4;
}

.concept-card-idea {
  font-size: 11px;
  color: var(--muted);
  line-height: 1.6;
}

.concept-card-visual {
  font-size: 10px;
  color: #888;
  margin-top: 4px;
  line-height: 1.5;
  padding: 6px 8px;
  background: #f7f7f7;
  border-radius: 6px;
  border: 1px solid #e0e0e0;
}

.concept-card-pick {
  margin-top: auto;
  padding: 8px 12px;
  background: #000;
  color: #fff;
  border: var(--bw) solid #000;
  border-radius: 8px;
  font-family: var(--font);
  font-size: 10px;
  font-weight: 700;
  cursor: pointer;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  width: 100%;
  box-shadow: var(--sh-sm);
  transition: transform 0.1s, box-shadow 0.1s;
}
.concept-card-pick:hover {
  transform: translate(-1px, -1px);
  box-shadow: var(--sh);
}
.concept-card-pick:active {
  transform: translate(1px, 1px);
  box-shadow: none;
}

.concept-card--selected {
  border-color: var(--teal);
  box-shadow: 4px 4px 0 var(--teal);
}
.concept-card--selected .concept-card-pick {
  background: var(--teal);
  border-color: var(--teal);
}

/* ── Concept inline card (в чате при генерации) ── */
.concept-inline-card {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  margin-top: 6px;
  background: var(--surface2);
  border: var(--bw) solid #000;
  border-radius: var(--r);
  box-shadow: var(--sh-sm);
  overflow: hidden;
  max-width: 480px;
}
.concept-inline-img {
  width: 120px;
  height: 120px;
  object-fit: cover;
  flex-shrink: 0;
  border-right: var(--bw) solid #000;
  display: block;
}
.concept-inline-body {
  padding: 10px 12px 10px 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}
.concept-inline-name {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  line-height: 1.2;
}
.concept-inline-slogan {
  font-size: 11px;
  color: var(--teal);
  font-style: italic;
  line-height: 1.4;
}
.concept-inline-idea {
  font-size: 10px;
  color: var(--muted);
  line-height: 1.5;
  margin-top: 2px;
}
