/* ─
   GUARDIEE  style.css  v3
   Editorial light mode. Left panel always fully visible.
   No overflow hidden on the left — everything shows.
─ */

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --cream:     #f7f4ee;
  --paper:     #fffefb;
  --ink:       #1c1a17;
  --ink2:      #4a4640;
  --ink3:      #9a9488;
  --rule:      rgba(28,26,23,0.09);
  --rule2:     rgba(28,26,23,0.17);
  --amber:     #b8720f;
  --amber-bg:  rgba(184,114,15,0.08);
  --amber-mid: rgba(184,114,15,0.20);
  --green:     #1a7a52;
  --green-bg:  rgba(26,122,82,0.08);
  --red:       #b82d1e;
  --red-bg:    rgba(184,45,30,0.07);
  --rival:     #8b1a4a;
  --rival-bg:  rgba(139,26,74,0.07);
  --rival-mid: rgba(139,26,74,0.18);
  --you-col:   #1a4a8b;

  --f-serif: 'Instrument Serif', Georgia, serif;
  --f-sans:  'Syne', sans-serif;
  --f-mono:  'DM Mono', 'Courier New', monospace;
}

html, body {
  height: 100%;
  background: var(--cream);
  color: var(--ink);
  font-family: var(--f-mono);
  font-size: 13px;
  -webkit-font-smoothing: antialiased;
}

/*  APP SHELL  */
.app {
  display: grid;
  grid-template-columns: 272px 1fr;
  height: 100vh;
  /* No overflow: hidden here — let left panel scroll if needed */
}

@media (max-width: 680px) {
  .app {
    grid-template-columns: 1fr;
  }
  .left-panel { display: none; }
}

/*  LEFT PANEL ─ */
.left-panel {
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--rule2);
  background: var(--paper);
  height: 100vh;
  overflow-y: auto;          /* scrolls if content is taller than screen */
  overflow-x: hidden;
}

/* Custom scrollbar for left panel */
.left-panel::-webkit-scrollbar { width: 3px; }
.left-panel::-webkit-scrollbar-thumb { background: var(--rule2); border-radius: 2px; }

/* Brand */
.lp-brand {
  padding: 28px 22px 20px;
  border-bottom: 1px solid var(--rule);
  flex-shrink: 0;
}

.wordmark {
  font-family: var(--f-serif);
  font-size: 26px;
  color: var(--ink);
  line-height: 1;
  margin-bottom: 8px;
  letter-spacing: -0.3px;
}

.wordmark-accent { font-style: italic; color: var(--amber); }

.tagline {
  font-family: var(--f-mono);
  font-size: 11px;
  color: var(--ink3);
  line-height: 1.65;
}

/* Generic section block */
.lp-section {
  padding: 18px 22px;
  border-bottom: 1px solid var(--rule);
  flex-shrink: 0;
}

/* Market section can grow to fill space */
.lp-market { flex-shrink: 0; }

.eyebrow {
  font-family: var(--f-mono);
  font-size: 9px;
  text-transform: uppercase;
  letter-spacing: 2px;
  color: var(--ink3);
  margin-bottom: 12px;
}

/*  MODE CHIPS ─ */
.mode-chips {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
}

.chip {
  padding: 7px 6px;
  border-radius: 6px;
  border: 1px solid var(--rule2);
  background: transparent;
  font-family: var(--f-mono);
  font-size: 11px;
  color: var(--ink3);
  cursor: pointer;
  transition: all .15s;
  text-align: center;
  white-space: nowrap;
}

.chip:hover  { color: var(--ink); border-color: var(--amber); background: var(--amber-bg); }
.chip.active { background: var(--ink); color: var(--paper); border-color: var(--ink); }

/*  TICKER LIST ─ */
.ticker-list {
  display: flex;
  flex-direction: column;
}

.ticker-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 7px 0;
  border-bottom: 1px solid var(--rule);
  transition: background .2s;
  border-radius: 4px;
}

.ticker-row:last-child { border-bottom: none; }
.ticker-row.sk { opacity: 0.35; }
.ticker-row.flash-up   { background: var(--green-bg); }
.ticker-row.flash-down { background: var(--red-bg); }

.t-coin {
  font-family: var(--f-sans);
  font-size: 11px;
  font-weight: 700;
  color: var(--ink);
  width: 32px;
  flex-shrink: 0;
}

.t-price {
  font-family: var(--f-mono);
  font-size: 11px;
  color: var(--ink2);
  flex: 1;
  text-align: center;
}

.t-chg {
  font-family: var(--f-mono);
  font-size: 11px;
  font-weight: 500;
  min-width: 48px;
  text-align: right;
}

.up      { color: var(--green); }
.down    { color: var(--red);   }
.neutral { color: var(--ink3);  }

.market-ts {
  margin-top: 10px;
  font-size: 9px;
  color: var(--ink3);
}

/*  BATTLE CARD ─ */
.battle-card {
  display: none;          /* shown by JS when battle starts */
  padding: 16px 22px;
  border-bottom: 1px solid var(--rule);
  background: var(--rival-bg);
  border-left: 3px solid var(--rival);
  flex-shrink: 0;
}

.battle-card.visible { display: block; }

.battle-scores {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 10px;
  gap: 6px;
}

.bs-block       { flex: 1; }
.bs-block.right { text-align: right; }

.bs-label {
  font-size: 9px;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  color: var(--ink3);
  margin-bottom: 3px;
}

.bs-val {
  font-family: var(--f-sans);
  font-size: 16px;
  font-weight: 700;
  color: var(--ink);
}

.bs-val.you   { color: var(--you-col); }
.bs-val.rival { color: var(--rival);   }

.bs-sub {
  font-size: 10px;
  color: var(--ink3);
  font-family: var(--f-mono);
  margin-top: 2px;
}

.bs-vs {
  font-family: var(--f-serif);
  font-style: italic;
  font-size: 13px;
  color: var(--ink3);
  flex-shrink: 0;
}

.bs-leader {
  margin-top: 10px;
  padding-top: 8px;
  border-top: 1px solid var(--rule);
  font-size: 11px;
  color: var(--ink2);
  text-align: center;
  font-family: var(--f-mono);
}

/* Predictions list inside battle card */
.preds-list {
  margin-top: 10px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.pred-item {
  background: var(--paper);
  border: 1px solid var(--rule2);
  border-radius: 6px;
  padding: 8px 10px;
  font-size: 10px;
  font-family: var(--f-mono);
  line-height: 1.5;
}

.pred-item.win  { border-left: 3px solid var(--green); }
.pred-item.lose { border-left: 3px solid var(--red);   }
.pred-item.open { border-left: 3px solid var(--amber); }

/* Credit */
.lp-credit {
  padding: 14px 22px;
  font-size: 10px;
  color: var(--ink3);
  border-top: 1px solid var(--rule);
  flex-shrink: 0;
}

/*  RIGHT PANEL ─ */
.right-panel {
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
  background: var(--cream);
  min-width: 0;
}

/* Topbar */
.chat-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 11px 22px;
  border-bottom: 1px solid var(--rule);
  background: var(--paper);
  flex-shrink: 0;
}

.active-pill {
  display: flex;
  align-items: center;
  gap: 6px;
  font-family: var(--f-mono);
  font-size: 11px;
  color: var(--ink2);
  background: var(--cream);
  border: 1px solid var(--rule2);
  border-radius: 20px;
  padding: 4px 12px;
  transition: all .2s;
}

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

.icon-act {
  background: none;
  border: none;
  font-size: 17px;
  color: var(--ink3);
  cursor: pointer;
  padding: 3px 5px;
  transition: color .15s;
  line-height: 1;
}

.icon-act:hover { color: var(--ink); }

.conn-dot {
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--ink3);
  transition: background .4s;
}

.conn-dot.live    { background: var(--green); animation: pulse 2.5s ease infinite; }
.conn-dot.loading { background: var(--amber); animation: pulse 1s ease infinite; }

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

/* Messages */
.messages {
  flex: 1;
  overflow-y: auto;
  padding: 24px 22px;
  display: flex;
  flex-direction: column;
  gap: 18px;
  scroll-behavior: smooth;
}

.messages::-webkit-scrollbar { width: 4px; }
.messages::-webkit-scrollbar-thumb { background: var(--rule2); border-radius: 2px; }

/* Message rows */
.msg { display: flex; gap: 11px; max-width: 84%; }
.msg.user    { align-self: flex-end; flex-direction: row-reverse; }
.msg.bot,
.msg.rival,
.msg.analyst { align-self: flex-start; }

.msg-avatar {
  width: 30px; height: 30px;
  border-radius: 8px;
  flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 13px;
  font-family: var(--f-sans);
  font-weight: 700;
  margin-top: 2px;
}

.av-g { background: var(--amber-bg); border: 1px solid var(--amber-mid); font-size: 16px; }
.av-u {
  background: var(--rule2);
  color: var(--ink2);
  font-size: 9px;        /* smaller text so "Me" fits cleanly */
  letter-spacing: 0.3px;
}
.av-r { background: var(--rival); color: #fff; }
.av-a { background: var(--green-bg); color: var(--green); border: 1px solid rgba(26,122,82,.25); }

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

.msg-name {
  font-size: 9px;
  color: var(--ink3);
  text-transform: uppercase;
  letter-spacing: 1.2px;
  margin-bottom: 4px;
  font-family: var(--f-mono);
}

.bubble {
  padding: 12px 15px;
  border-radius: 16px 16px 16px 4px;
  font-family: var(--f-mono);
  font-size: 13px;
  line-height: 1.75;
  color: var(--ink);
  background: var(--paper);
  border: 1px solid var(--rule2);
  word-break: break-word;
}

.msg.user .bubble {
  border-radius: 16px 16px 4px 16px;
  background: var(--ink);
  color: var(--paper);
  border-color: var(--ink);
}

.msg.rival .bubble {
  background: var(--rival-bg);
  border-color: rgba(139,26,74,0.2);
  font-style: italic;
}

.msg.analyst .bubble {
  background: var(--green-bg);
  border-color: rgba(26,122,82,0.2);
  font-size: 12px;
}

.msg-time {
  font-size: 9px;
  color: var(--ink3);
  margin-top: 5px;
}

/* Typing indicator */
.typing-dots { display: flex; gap: 4px; align-items: center; padding: 2px 0; }
.typing-dots span {
  width: 5px; height: 5px;
  border-radius: 50%;
  background: var(--ink3);
  animation: dot .9s ease infinite;
}
.typing-dots span:nth-child(2) { animation-delay: .15s; }
.typing-dots span:nth-child(3) { animation-delay: .30s; }
@keyframes dot {
  0%,60%,100% { transform: translateY(0); opacity:.4; }
  30%          { transform: translateY(-5px); opacity:1; }
}

/* Prediction result card inside bubble */
.pred-result {
  margin-top: 10px;
  padding: 10px 13px;
  border-radius: 8px;
  border: 1px solid var(--rule2);
  background: var(--cream);
  font-size: 12px;
  line-height: 1.7;
}

.pred-result.win  { border-left: 3px solid var(--green); background: var(--green-bg); }
.pred-result.loss { border-left: 3px solid var(--red);   background: var(--red-bg); }
.pred-result.open { border-left: 3px solid var(--amber); background: var(--amber-bg); }

/* Suggestions row */
.suggestions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 10px 22px;
  border-top: 1px solid var(--rule);
  background: var(--paper);
  flex-shrink: 0;
}

.sug {
  padding: 5px 13px;
  border-radius: 20px;
  border: 1px solid var(--rule2);
  background: var(--cream);
  font-family: var(--f-mono);
  font-size: 11px;
  color: var(--ink2);
  cursor: pointer;
  transition: all .15s;
  white-space: nowrap;
}

.sug:hover { border-color: var(--amber); color: var(--amber); background: var(--amber-bg); }

.sug.battle-only { display: none; }
.sug.battle-only.visible {
  display: inline-block;
  border-color: rgba(139,26,74,0.3);
  color: var(--rival);
  background: var(--rival-bg);
}

.sug.battle-only.visible:hover { border-color: var(--rival); }

/* Input */
.input-area {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  padding: 12px 22px 16px;
  border-top: 1px solid var(--rule);
  background: var(--paper);
  flex-shrink: 0;
}

.chat-input {
  flex: 1;
  background: var(--cream);
  border: 1px solid var(--rule2);
  border-radius: 12px;
  padding: 10px 15px;
  font-family: var(--f-mono);
  font-size: 13px;
  color: var(--ink);
  outline: none;
  resize: none;
  max-height: 110px;
  overflow-y: auto;
  line-height: 1.5;
  transition: border-color .2s;
}

.chat-input::placeholder { color: var(--ink3); }
.chat-input:focus { border-color: var(--amber); }

.send-btn {
  width: 38px; height: 38px;
  flex-shrink: 0;
  background: var(--ink);
  border: none;
  border-radius: 10px;
  color: var(--paper);
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: all .15s;
  align-self: flex-end;
}

.send-btn:hover    { background: var(--amber); }
.send-btn:active   { transform: scale(0.95); }
.send-btn:disabled { opacity: 0.35; cursor: not-allowed; }

/* Funding Hunter panel */
.hunter-status {
  font-size: 10px;
  color: var(--ink3);
  margin-bottom: 8px;
  font-family: var(--f-mono);
}

.hunter-badge {
  font-size: 10px;
  color: var(--amber);
  background: var(--amber-bg);
  border: 1px solid var(--amber-mid);
  border-radius: 4px;
  padding: 3px 8px;
  margin-bottom: 8px;
  font-family: var(--f-mono);
}

.hunter-scan-btn {
  width: 100%;
  padding: 7px;
  background: transparent;
  border: 1px solid var(--rule2);
  border-radius: 6px;
  font-family: var(--f-mono);
  font-size: 11px;
  color: var(--ink2);
  cursor: pointer;
  transition: all .15s;
  text-align: center;
}

.hunter-scan-btn:hover {
  border-color: var(--amber);
  color: var(--amber);
  background: var(--amber-bg);
}

/*  MOBILE PANEL TOGGLE BUTTON  */
.panel-toggle {
  display: none; /* hidden on desktop */
  position: fixed;
  top: 12px;
  left: 12px;
  z-index: 999;
  width: 38px;
  height: 38px;
  border-radius: 10px;
  border: 1px solid var(--rule2);
  background: var(--paper);
  color: var(--ink);
  font-size: 16px;
  cursor: pointer;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 8px rgba(0,0,0,0.1);
  transition: all .2s;
}

.panel-toggle:hover { background: var(--amber-bg); border-color: var(--amber); }

/* ALL MOBILE STYLES — single block, no conflicts */
@media (max-width: 680px) {

  /* Layout */
  .app {
    grid-template-columns: 1fr;
    height: 100dvh;        /* shrinks when keyboard opens */
  }

  /* Right panel — must NOT use fixed 100vh */
  .right-panel {
    height: 100dvh;
    min-height: 0;         /* allows flex children to shrink */
  }

  /* Messages area — shrinks to give room to input */
  .messages {
    flex: 1;
    min-height: 0;         /* critical — without this it won't shrink */
  }

  /* Suggestions — horizontal scroll, won't wrap and push input down */
  .suggestions {
    padding: 6px 12px;
    gap: 5px;
    overflow-x: auto;
    flex-wrap: nowrap;
    -webkit-overflow-scrolling: touch;
    flex-shrink: 0;
  }

  .sug {
    flex-shrink: 0;
  }

  /* Input area — tight padding, safe area for iPhone home bar */
  .input-area {
    padding: 8px 12px;
    padding-bottom: max(8px, env(safe-area-inset-bottom));
    gap: 8px;
    flex-shrink: 0;
  }

  /* Textarea — 14px prevents iOS Safari auto-zoom on tap */
  .chat-input {
    font-size: 14px;
    padding: 9px 12px;
    max-height: 80px;
  }

  /* Send button */
  .send-btn {
    width: 36px;
    height: 36px;
    flex-shrink: 0;
    align-self: flex-end;
  }

  /* Left panel — hidden by default, overlays when toggled */
  .left-panel {
    display: none;
    position: fixed;
    top: 0; left: 0;
    width: 100vw;
    height: 100vh;
    z-index: 998;
    background: var(--paper);
    overflow-y: auto;
  }

  .left-panel.panel-open {
    display: flex;
  }

  /* Toggle button */
  .panel-toggle {
    display: flex;
  }

  /* Topbar — shift right so toggle button doesn't overlap */
  .chat-topbar {
    padding-left: 60px;
  }
}

/* ── MOBILE STABILITY — no sideways scroll, fully responsive ── */
@media (max-width: 680px) {

  /* Prevent ANY horizontal overflow on the whole page */
  html, body {
    overflow-x: hidden;
    width: 100%;
    position: relative;
  }

  /* App shell must never exceed screen width */
  .app {
    width: 100%;
    max-width: 100vw;
    overflow-x: hidden;
  }

  /* Right panel full width, no overflow */
  .right-panel {
    width: 100%;
    max-width: 100%;
    overflow-x: hidden;
  }

  /* Topbar — allow pill to shrink/truncate instead of pushing width */
  .chat-topbar {
    gap: 8px;
    min-width: 0;
  }

  .active-pill {
    min-width: 0;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
    flex-shrink: 1;         /* allow it to shrink when toggle button eats space */
  }

  /* Messages — prevent wide bubbles from creating scroll */
  .messages {
    padding: 16px 12px;
    width: 100%;
    overflow-x: hidden;
  }

  /* Message rows — constrain to screen */
  .msg {
    max-width: 92%;         /* slightly wider than desktop 84% since screen is smaller */
    min-width: 0;
  }

  /* Bubbles — never wider than their container */
  .bubble {
    word-break: break-word;
    overflow-wrap: anywhere;  /* breaks long URLs/words that cause overflow */
    max-width: 100%;
    font-size: 13px;
  }

  /* Avatar — fixed size, never shrinks or causes overflow */
  .msg-avatar {
    flex-shrink: 0;
    width: 28px;
    height: 28px;
  }

  /* Message body — must shrink with available space */
  .msg-body {
    min-width: 0;
    max-width: 100%;
  }
}
