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

:root {
  --bg:         #0d1117;
  --bg2:        #161b22;
  --bg3:        #1c2128;
  --bg4:        #21262d;
  --border:     #30363d;
  --border2:    #21262d;
  --accent:     #f97316;
  --accent2:    #fb923c;
  --accent-dim: #431407;
  --blue:       #38bdf8;
  --blue-dim:   #0c2a3f;
  --green:      #4ade80;
  --green-dim:  #052e16;
  --red:        #f87171;
  --red-dim:    #2a0a0a;
  --yellow:     #fbbf24;
  --yellow-dim: #1f1500;
  --text:       #e6edf3;
  --text2:      #8b949e;
  --text3:      #484f58;
  --font-ui:    'DM Sans', sans-serif;
  --font-head:  'Syne', sans-serif;
  --font-code:  'JetBrains Mono', monospace;
}

html, body { height: 100%; }
body { font-family: var(--font-ui); background: var(--bg); color: var(--text); }

/* ── HOMEPAGE ── */
.home-page { min-height: 100vh; padding: 40px 20px; }
.home-header { max-width: 900px; margin: 0 auto 40px; text-align: center; }
.home-logo { display: inline-flex; align-items: center; gap: 12px; margin-bottom: 24px; }
.home-logo-icon { width: 44px; height: 44px; background: var(--accent); border-radius: 10px; display: flex; align-items: center; justify-content: center; }
.home-logo-icon svg { width: 22px; height: 22px; fill: white; }
.home-logo-text { font-family: var(--font-head); font-size: 20px; font-weight: 800; color: var(--text); }
.home-logo-sub { font-size: 12px; color: var(--text2); margin-top: 2px; }
.home-title { font-family: var(--font-head); font-size: clamp(26px, 4vw, 42px); font-weight: 800; color: var(--text); margin-bottom: 12px; }
.home-title span { color: var(--accent); }
.home-desc { font-size: 15px; color: var(--text2); max-width: 560px; margin: 0 auto; line-height: 1.7; }
.home-grid { max-width: 900px; margin: 0 auto; display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 16px; }
.ch-card { background: var(--bg2); border: 1px solid var(--border); border-radius: 12px; padding: 20px; text-decoration: none; display: block; transition: all .2s; cursor: pointer; }
.ch-card:hover { border-color: var(--accent); transform: translateY(-2px); box-shadow: 0 8px 24px rgba(0,0,0,.3); }
.ch-num { font-family: var(--font-code); font-size: 11px; color: var(--text3); margin-bottom: 10px; }
.ch-icon { font-size: 26px; margin-bottom: 10px; }
.ch-title { font-family: var(--font-head); font-size: 15px; font-weight: 700; color: var(--text); margin-bottom: 6px; }
.ch-desc { font-size: 12.5px; color: var(--text2); line-height: 1.6; margin-bottom: 12px; }
.ch-tags { display: flex; flex-wrap: wrap; gap: 5px; }
.ch-tag { font-size: 10px; padding: 2px 7px; border-radius: 4px; background: var(--bg3); color: var(--text3); border: 1px solid var(--border); }
.ch-arrow { display: flex; align-items: center; justify-content: flex-end; margin-top: 12px; color: var(--text3); font-size: 13px; transition: color .2s; }
.ch-card:hover .ch-arrow { color: var(--accent); }

/* ── CHAT APP LAYOUT ── */
.chat-app { display: none; height: 100vh; overflow: hidden; flex-direction: column; }
.chat-app.active { display: flex; }

/* Topbar */
.topbar { height: 52px; background: var(--bg2); border-bottom: 1px solid var(--border); display: flex; align-items: center; padding: 0 16px; gap: 10px; flex-shrink: 0; }
.topbar-back { background: none; border: none; color: var(--text2); cursor: pointer; padding: 6px 8px; border-radius: 6px; font-size: 13px; font-family: var(--font-ui); display: flex; align-items: center; gap: 6px; transition: all .15s; }
.topbar-back:hover { background: var(--bg3); color: var(--text); }
.topbar-title { flex: 1; font-family: var(--font-head); font-size: 14px; font-weight: 700; color: var(--text); }
.topbar-badge { font-size: 11px; background: var(--yellow-dim); color: var(--yellow); border: 1px solid #7c3c00; padding: 3px 10px; border-radius: 20px; font-weight: 600; display: none; }
.topbar-report { font-size: 12px; padding: 5px 12px; border-radius: 6px; border: 1px solid var(--blue); color: var(--blue); background: none; cursor: pointer; font-family: var(--font-ui); transition: all .15s; display: none; }
.topbar-report:hover { background: var(--blue-dim); }

/* Progress bar */
.progress-strip { height: 3px; background: var(--bg4); flex-shrink: 0; }
.progress-fill { height: 100%; background: linear-gradient(90deg, var(--accent), var(--accent2)); transition: width .4s ease; width: 0%; }

/* Chat window */
.chat-window { flex: 1; overflow-y: auto; padding: 20px 0; }
.chat-window::-webkit-scrollbar { width: 4px; }
.chat-window::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }
.messages { max-width: 760px; margin: 0 auto; padding: 0 20px; }

/* Messages */
.msg { display: flex; gap: 10px; margin-bottom: 18px; animation: msgIn .2s ease; }
@keyframes msgIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
.msg-av { width: 30px; height: 30px; border-radius: 8px; flex-shrink: 0; display: flex; align-items: center; justify-content: center; font-size: 11px; font-weight: 700; margin-top: 2px; }
.msg.bot .msg-av { background: var(--accent); color: white; font-family: var(--font-head); }
.msg.user .msg-av { background: var(--bg4); color: var(--text2); border: 1px solid var(--border); }
.msg-body { flex: 1; min-width: 0; }
.msg-name { font-size: 11px; font-weight: 600; margin-bottom: 4px; letter-spacing: .03em; }
.msg.bot .msg-name { color: var(--accent); }
.msg.user .msg-name { color: var(--text2); }
.msg-content { font-size: 13.5px; line-height: 1.75; color: var(--text); }
.msg.user .msg-content { background: var(--bg3); border: 1px solid var(--border); border-radius: 4px 12px 12px 12px; padding: 9px 13px; display: inline-block; }
.msg-content p { margin-bottom: 8px; }
.msg-content p:last-child { margin-bottom: 0; }
.msg-content strong { color: var(--text); font-weight: 500; }

/* Callouts */
.co { border-radius: 8px; padding: 10px 14px; margin: 7px 0; font-size: 13px; border: 1px solid; line-height: 1.65; }
.co-good  { background: var(--green-dim);  border-color: #166534; color: #86efac; }
.co-bad   { background: var(--red-dim);    border-color: #7f1d1d; color: #fca5a5; }
.co-warn  { background: var(--yellow-dim); border-color: #7c3c00; color: #fde68a; }
.co-info  { background: var(--blue-dim);   border-color: #1e4a6a; color: #7dd3fc; }
.co-learn { background: #091520; border: 1px solid #1e3a5f; border-left: 3px solid var(--blue); border-radius: 8px; padding: 12px 14px; margin: 8px 0; }
.co-learn .learn-title { font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: .08em; color: var(--blue); margin-bottom: 7px; }
.co-learn .learn-body { font-size: 12.5px; color: #93c5fd; line-height: 1.7; }
.co-learn .learn-body strong { color: #bfdbfe; }

/* Section badge */
.sec-badge { display: inline-block; font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: .07em; background: var(--accent-dim); color: var(--accent); border: 1px solid #7c2d12; padding: 2px 8px; border-radius: 4px; margin-bottom: 8px; }

/* SQL block */
.sql-block { margin: 10px 0; border-radius: 8px; overflow: hidden; border: 1px solid var(--border); }
.sql-block-head { background: var(--bg4); padding: 7px 14px; display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid var(--border); }
.sql-block-label { font-family: var(--font-code); font-size: 10px; color: var(--text3); text-transform: uppercase; letter-spacing: .07em; }
.sql-copy-btn { background: none; border: 1px solid var(--border); color: var(--text2); font-size: 11px; padding: 3px 9px; border-radius: 4px; cursor: pointer; transition: all .15s; font-family: var(--font-ui); }
.sql-copy-btn:hover { border-color: var(--accent); color: var(--accent); }
.sql-block-body { background: #070b10; padding: 13px 16px; font-family: var(--font-code); font-size: 12px; color: #cdd9e5; white-space: pre; line-height: 1.7; overflow-x: auto; }

/* Run prompt */
.run-prompt { background: #16213e; border: 1px solid #2d4a7a; border-radius: 8px; padding: 10px 13px; margin: 8px 0; font-size: 13px; color: #a8c6e8; }
.run-prompt-label { font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--accent); display: block; margin-bottom: 4px; }

/* Resolution box */
.res-box { background: var(--green-dim); border: 1px solid #166534; border-radius: 8px; padding: 12px 15px; margin: 8px 0; }
.res-box-title { color: var(--green); font-weight: 600; font-size: 12.5px; margin-bottom: 7px; }
.res-box ol { list-style: decimal; padding-left: 17px; }
.res-box li { color: #86efac; font-size: 12.5px; margin-bottom: 4px; line-height: 1.5; }

/* Typing */
.typing { display: flex; align-items: center; gap: 5px; padding: 6px 0; }
.typing span { width: 7px; height: 7px; border-radius: 50%; background: var(--accent); animation: blink 1.2s infinite; opacity: .3; }
.typing span:nth-child(2) { animation-delay: .2s; }
.typing span:nth-child(3) { animation-delay: .4s; }
@keyframes blink { 0%,80%,100% { opacity: .3; } 40% { opacity: 1; } }

/* ── ANSWER PANEL — always visible at bottom ── */
.answer-panel { flex-shrink: 0; background: var(--bg2); border-top: 1px solid var(--border); }
.answer-inner { max-width: 760px; margin: 0 auto; padding: 12px 20px; }

/* Status line */
.answer-status { font-size: 11px; color: var(--text3); margin-bottom: 8px; min-height: 16px; }

/* YES / NO buttons — always rendered */
.yn-row { display: flex; gap: 10px; margin-bottom: 8px; }
.yn-btn { flex: 1; padding: 10px; border-radius: 8px; font-family: var(--font-head); font-size: 15px; font-weight: 700; cursor: pointer; transition: all .2s; border: 2px solid; }
.yn-btn-yes { background: rgba(74,222,128,.06); border-color: #166534; color: #4ade80; }
.yn-btn-yes:hover:not(:disabled) { background: rgba(74,222,128,.18); border-color: #4ade80; }
.yn-btn-no  { background: rgba(248,113,113,.06); border-color: #7f1d1d; color: #f87171; }
.yn-btn-no:hover:not(:disabled)  { background: rgba(248,113,113,.18); border-color: #f87171; }
.yn-btn:disabled { opacity: .28; cursor: not-allowed; }

/* Text input row */
.text-row { display: flex; gap: 8px; margin-bottom: 8px; }
#user-input { flex: 1; background: var(--bg3); border: 1px solid var(--border); border-radius: 8px; color: var(--text); font-family: var(--font-ui); font-size: 13.5px; padding: 9px 14px; outline: none; transition: border-color .15s; }
#user-input:focus { border-color: var(--accent); }
#user-input::placeholder { color: var(--text3); }
#user-input:disabled { opacity: .35; }
#send-btn { width: 38px; height: 38px; background: var(--accent); border: none; border-radius: 8px; cursor: pointer; display: flex; align-items: center; justify-content: center; flex-shrink: 0; transition: opacity .15s; }
#send-btn:hover:not(:disabled) { opacity: .85; }
#send-btn:disabled { opacity: .3; cursor: not-allowed; }

/* Multi-choice buttons */
.choice-row { display: flex; flex-wrap: wrap; gap: 6px; }
.c-btn { font-size: 12.5px; padding: 6px 14px; border-radius: 20px; border: 1px solid var(--border); background: var(--bg3); color: var(--text2); cursor: pointer; transition: all .15s; font-family: var(--font-ui); }
.c-btn:hover { border-color: var(--accent); color: var(--accent); background: var(--accent-dim); }

/* ── REPORT MODAL ── */
.modal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,.7); display: none; align-items: center; justify-content: center; z-index: 999; padding: 20px; }
.modal-overlay.open { display: flex; }
.modal { background: var(--bg2); border: 1px solid var(--border); border-radius: 12px; width: 100%; max-width: 720px; max-height: 88vh; display: flex; flex-direction: column; }
.modal-head { padding: 16px 20px; border-bottom: 1px solid var(--border2); display: flex; align-items: center; justify-content: space-between; }
.modal-head-title { font-family: var(--font-head); font-size: 16px; font-weight: 700; }
.modal-close { background: none; border: none; color: var(--text2); font-size: 18px; cursor: pointer; padding: 4px; }
.modal-close:hover { color: var(--text); }
.modal-body { flex: 1; overflow-y: auto; padding: 18px 20px; }
.modal-body::-webkit-scrollbar { width: 4px; }
.modal-body::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }
.modal-foot { padding: 12px 20px; border-top: 1px solid var(--border2); display: flex; justify-content: flex-end; gap: 8px; }
.modal-foot button { padding: 7px 16px; border-radius: 7px; border: 1px solid var(--border); background: transparent; color: var(--text2); font-family: var(--font-ui); font-size: 12.5px; cursor: pointer; transition: all .15s; }
.modal-foot button:first-child { border-color: var(--accent); color: var(--accent); }
.modal-foot button:first-child:hover { background: var(--accent-dim); }

/* Report cards */
.rpt-summary { display: flex; gap: 10px; margin-bottom: 18px; }
.rpt-card { flex: 1; border-radius: 8px; padding: 12px; text-align: center; border: 1px solid; }
.rpt-card .n { font-size: 28px; font-weight: 800; font-family: var(--font-head); }
.rpt-card .l { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; margin-top: 2px; }
.rC { background: var(--red-dim);    border-color: #7f1d1d; color: var(--red); }
.rH { background: var(--yellow-dim); border-color: #7c3c00; color: var(--yellow); }
.rM { background: var(--blue-dim);   border-color: #1e4a6a; color: var(--blue); }
.rpt-finding { border-radius: 8px; padding: 13px 15px; margin-bottom: 11px; border: 1px solid; }
.rpt-fh { display: flex; align-items: center; gap: 7px; margin-bottom: 7px; }
.sev-pill { font-size: 10px; font-weight: 800; text-transform: uppercase; padding: 2px 6px; border-radius: 3px; color: #000; flex-shrink: 0; }
.rpt-issue { font-size: 13px; font-weight: 600; color: var(--text); }
.rpt-sec { font-size: 11px; color: var(--text2); margin-bottom: 6px; }
.rpt-steps { list-style: decimal; padding-left: 17px; }
.rpt-steps li { font-size: 12px; color: var(--text2); margin-bottom: 3px; line-height: 1.5; }

/* ── Responsive ── */
@media (max-width: 600px) {
  .home-grid { grid-template-columns: 1fr; }
  .messages { padding: 0 12px; }
  .answer-inner { padding: 10px 12px; }
  .rpt-summary { flex-wrap: wrap; }
  .rpt-card { min-width: calc(50% - 5px); }
}
