/* HackCell — RedCell-style chat UI. Brand: body #070E0F, accent #EC0000, zero blue, zero emojis. */
:root {
  --bg: #070E0F;
  --bg-2: #0B1213;
  --bg-3: #101A1B;
  --surface: #131F20;
  --border: #22302F;
  --text: #E8EDED;
  --muted: #8FA3A0;
  --accent: #EC0000;
  --accent-dim: #B30000;
  --accent-soft: rgba(236, 0, 0, 0.12);
  --code-bg: #0A0F0F;
  --radius: 12px;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: Inter, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-size: 15px;
  line-height: 1.55;
  overflow: hidden;
}
button { font-family: inherit; cursor: pointer; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.hidden { display: none !important; }

#app { display: flex; height: 100vh; }

/* ---------- Sidebar ---------- */
#sidebar {
  width: 264px; flex: 0 0 264px;
  background: var(--bg-2);
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
  padding: 14px 12px;
  transition: margin-left .2s ease;
}
#sidebar.closed { margin-left: -264px; }
.side-top { display: flex; align-items: center; gap: 10px; padding: 2px 4px 14px; }
.icon-btn {
  background: none; border: none; color: var(--muted);
  font-size: 19px; line-height: 1; padding: 6px; border-radius: 8px;
}
.icon-btn:hover { background: var(--surface); color: var(--text); }
.logo { display: flex; align-items: baseline; gap: 8px; }
.logo-mark {
  display: inline-flex; align-items: center; justify-content: center;
  width: 26px; height: 26px; border-radius: 7px;
  background: var(--accent); color: #fff; font-weight: 800; font-size: 16px;
}
.logo-name { font-weight: 700; font-size: 17px; letter-spacing: .2px; }
.logo-tag { font-size: 10px; color: var(--muted); border: 1px solid var(--border); border-radius: 20px; padding: 1px 7px; text-transform: uppercase; letter-spacing: .6px; }

.new-chat {
  display: flex; align-items: center; gap: 8px;
  background: var(--surface); color: var(--text);
  border: 1px solid var(--border); border-radius: 10px;
  padding: 10px 12px; font-size: 14px; font-weight: 600; text-align: left;
}
.new-chat:hover { border-color: var(--accent); }
.new-chat .plus { font-size: 18px; line-height: 1; color: var(--accent); }

.side-section { margin-top: 22px; }
.side-section h3 {
  font-size: 11px; text-transform: uppercase; letter-spacing: 1px;
  color: var(--muted); font-weight: 600; padding: 0 8px 6px;
}
.side-item {
  display: flex; align-items: center; gap: 9px; width: 100%;
  background: none; border: none; color: var(--text);
  padding: 8px; border-radius: 8px; font-size: 13.5px; text-align: left;
}
.side-item:hover, .side-item.active { background: var(--surface); }
.side-item .side-ico { color: var(--accent); font-size: 14px; }
.side-item .side-title { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1; }
.side-item .side-del { color: var(--muted); font-size: 15px; padding: 0 2px; border-radius: 4px; background: none; border: none; visibility: hidden; }
.side-item:hover .side-del { visibility: visible; }
.side-item .side-del:hover { color: var(--accent); }
.side-recents { flex: 1; overflow-y: auto; min-height: 0; }
.side-empty { color: var(--muted); font-size: 13px; padding: 2px 8px; }
.side-bottom { border-top: 1px solid var(--border); padding-top: 12px; }
.status-pill {
  display: inline-flex; align-items: center; gap: 7px;
  font-size: 12.5px; font-weight: 600;
  border: 1px solid var(--border); border-radius: 20px; padding: 5px 11px;
  color: var(--muted); background: var(--bg-3);
}
.status-pill .dot { width: 8px; height: 8px; border-radius: 50%; background: #E8A33D; }
.status-pill.live { color: #7BD88A; border-color: #2A4A30; }
.status-pill.live .dot { background: #3ECF5A; }
.side-note { color: var(--muted); font-size: 11.5px; margin-top: 10px; line-height: 1.5; }

/* ---------- Main / topbar ---------- */
#main { flex: 1; display: flex; flex-direction: column; min-width: 0; }
#topbar {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 20px; border-bottom: 1px solid var(--border);
}
#sidebar-open { display: none; }
#main.sidebar-hidden #sidebar-open { display: block; }
.model-select-wrap { display: flex; align-items: center; gap: 8px; }
#model-select {
  background: var(--surface); color: var(--text);
  border: 1px solid var(--border); border-radius: 9px;
  padding: 7px 10px; font-size: 13.5px; font-weight: 600;
}
.model-note { font-size: 12px; color: var(--muted); }
.top-actions { margin-left: auto; display: flex; gap: 8px; }
.top-btn {
  background: var(--surface); color: var(--text);
  border: 1px solid var(--border); border-radius: 9px;
  padding: 8px 14px; font-size: 13.5px; font-weight: 600;
}
.top-btn:hover { border-color: var(--accent); }
.top-btn-accent { background: var(--accent); border-color: var(--accent); color: #fff; }
.top-btn-accent:hover { background: var(--accent-dim); border-color: var(--accent-dim); }

/* ---------- Chat area / welcome ---------- */
#chat-area { flex: 1; overflow-y: auto; display: flex; flex-direction: column; }
#welcome {
  margin: auto; width: 100%; max-width: 760px;
  padding: 48px 24px 32px; text-align: center;
}
#welcome h1 { font-size: 34px; font-weight: 700; letter-spacing: -.5px; margin-bottom: 10px; }
.welcome-sub { color: var(--muted); font-size: 15.5px; max-width: 600px; margin: 0 auto 28px; }

.composer {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 16px; padding: 12px 14px 8px; text-align: left;
}
.composer:focus-within { border-color: var(--accent); }
.composer textarea {
  width: 100%; background: none; border: none; outline: none; resize: none;
  color: var(--text); font-family: inherit; font-size: 15.5px; line-height: 1.5;
  min-height: 26px; max-height: 220px;
}
.composer textarea::placeholder { color: var(--muted); }
.composer-foot { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: 6px; }
.composer-hint { color: var(--muted); font-size: 12px; }
.send-btn {
  width: 32px; height: 32px; border-radius: 50%; flex: 0 0 32px;
  background: var(--accent); color: #fff; border: none; font-size: 17px; line-height: 1;
}
.send-btn:hover { background: var(--accent-dim); }
.send-btn:disabled { opacity: .45; cursor: default; }

.entry-cards { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin-top: 22px; }
.entry-card {
  background: var(--bg-2); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 16px 14px; text-align: left; color: var(--text);
  display: flex; flex-direction: column; gap: 6px; min-height: 118px;
}
.entry-card:hover { border-color: var(--accent); background: var(--bg-3); }
.card-ico { color: var(--accent); font-size: 20px; line-height: 1; }
.card-title { font-weight: 650; font-size: 14.5px; }
.card-desc { color: var(--muted); font-size: 12.5px; line-height: 1.45; }
.welcome-foot { color: var(--muted); font-size: 12px; margin-top: 22px; line-height: 1.6; }

/* ---------- Thread ---------- */
#thread { width: 100%; max-width: 780px; margin: 0 auto; padding: 28px 24px 16px; flex: 1; }
.msg { margin-bottom: 26px; }
.msg-role { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .8px; color: var(--muted); margin-bottom: 6px; }
.msg.user .msg-role { color: var(--accent); }
.msg-body { white-space: normal; }
.msg.user .msg-body {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 12px; padding: 12px 14px; white-space: pre-wrap; word-break: break-word;
}
.msg-body h2 { font-size: 19px; margin: 18px 0 8px; }
.msg-body h3 { font-size: 16px; margin: 16px 0 6px; }
.msg-body h2:first-child, .msg-body h3:first-child { margin-top: 0; }
.msg-body p { margin: 8px 0; }
.msg-body ul, .msg-body ol { margin: 8px 0 8px 20px; }
.msg-body li { margin: 4px 0; }
.msg-body code {
  background: var(--code-bg); border: 1px solid var(--border);
  border-radius: 5px; padding: 1px 5px; font-size: 13px;
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
}
.msg-body pre {
  background: var(--code-bg); border: 1px solid var(--border);
  border-radius: 10px; padding: 12px 14px; overflow-x: auto; margin: 10px 0;
}
.msg-body pre code { background: none; border: none; padding: 0; font-size: 13px; display: block; white-space: pre; }
.msg-body a { color: #FF6B6B; }
.msg-body table { border-collapse: collapse; margin: 10px 0; font-size: 13.5px; width: 100%; }
.msg-body th, .msg-body td { border: 1px solid var(--border); padding: 7px 10px; text-align: left; vertical-align: top; }
.msg-body th { background: var(--bg-3); }
.sev { display: inline-block; font-size: 11px; font-weight: 700; border-radius: 20px; padding: 1px 8px; margin-left: 6px; vertical-align: middle; }
.sev-critical { background: rgba(236,0,0,.18); color: #FF5A5A; border: 1px solid rgba(236,0,0,.5); }
.sev-high { background: rgba(236,0,0,.10); color: #FF7A5A; border: 1px solid rgba(236,0,0,.35); }
.sev-medium { background: rgba(232,163,61,.14); color: #E8A33D; border: 1px solid rgba(232,163,61,.4); }
.sev-low { background: rgba(143,163,160,.14); color: var(--muted); border: 1px solid var(--border); }
.callout {
  border: 1px solid rgba(236,0,0,.45); background: var(--accent-soft);
  border-radius: 10px; padding: 11px 13px; margin: 12px 0; font-size: 14px;
}
.callout.info { border-color: var(--border); background: var(--bg-3); }
.callout strong { color: #FF5A5A; }
.callout.info strong { color: var(--text); }
.typing { color: var(--muted); font-style: italic; }

/* Inline flow panels (forms inside chat) */
.flow-panel { background: var(--bg-2); border: 1px solid var(--border); border-radius: 12px; padding: 16px; margin-top: 10px; }
.flow-panel h3 { margin: 0 0 4px; }
.flow-panel .flow-sub { color: var(--muted); font-size: 13.5px; margin-bottom: 14px; }
.field { margin-bottom: 12px; }
.field label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 5px; }
.field input[type="text"], .field textarea, .field select {
  width: 100%; background: var(--surface); color: var(--text);
  border: 1px solid var(--border); border-radius: 9px;
  padding: 9px 11px; font-family: inherit; font-size: 14px; outline: none;
}
.field input:focus, .field textarea:focus, .field select:focus { border-color: var(--accent); }
.field textarea { min-height: 120px; resize: vertical; font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 13px; }
.field .hint { color: var(--muted); font-size: 12px; margin-top: 4px; }
.check-row { display: flex; align-items: flex-start; gap: 8px; font-size: 14px; margin: 7px 0; cursor: pointer; }
.check-row input { margin-top: 3px; accent-color: var(--accent); }
.btn {
  background: var(--accent); color: #fff; border: none; border-radius: 9px;
  padding: 10px 18px; font-size: 14px; font-weight: 650;
}
.btn:hover { background: var(--accent-dim); }
.btn.ghost { background: var(--surface); color: var(--text); border: 1px solid var(--border); }
.btn.ghost:hover { border-color: var(--accent); }
.btn-row { display: flex; gap: 10px; margin-top: 14px; flex-wrap: wrap; }
.thread-composer { max-width: 780px; margin: 0 auto 24px; width: calc(100% - 48px); }

/* ---------- Modal ---------- */
#modal-backdrop {
  position: fixed; inset: 0; background: rgba(0,0,0,.65);
  display: flex; align-items: center; justify-content: center; z-index: 50; padding: 20px;
}
.modal {
  background: var(--bg-2); border: 1px solid var(--border); border-radius: 14px;
  max-width: 640px; width: 100%; max-height: 82vh; overflow-y: auto;
  padding: 24px 26px; position: relative;
}
.modal-close { position: absolute; top: 12px; right: 14px; font-size: 24px; }
.modal h2 { font-size: 20px; margin-bottom: 10px; padding-right: 30px; }
.modal p { margin: 9px 0; color: var(--text); }
.modal pre {
  background: var(--code-bg); border: 1px solid var(--border); border-radius: 10px;
  padding: 12px 14px; overflow-x: auto; margin: 12px 0; font-size: 13px;
  font-family: ui-monospace, Menlo, Consolas, monospace; white-space: pre;
}
.modal ul { margin: 8px 0 8px 20px; }
.modal li { margin: 4px 0; }

/* ---------- Responsive ---------- */
@media (max-width: 860px) {
  #sidebar { position: fixed; z-index: 40; height: 100vh; box-shadow: 0 0 40px rgba(0,0,0,.5); }
  #sidebar.closed { margin-left: -280px; }
  #sidebar-open { display: block; }
  #welcome h1 { font-size: 27px; }
  .entry-cards { grid-template-columns: 1fr; }
  .entry-card { min-height: 0; }
  .top-actions .top-btn:not(.top-btn-accent) { display: none; }
  .model-note { display: none; }
  #thread { padding: 20px 16px 12px; }
  .thread-composer { width: calc(100% - 32px); margin-bottom: 16px; }
}
