/* ========== RESET ========== */
* { margin: 0; padding: 0; box-sizing: border-box; }
html, body { height: 100%; }
body {
  font-family: 'Noto Sans JP', sans-serif;
  background: #0b0f1a;
  color: #e2e8f0;
  font-size: 14px;
  line-height: 1.6;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}
button, input { font-family: inherit; }
button { cursor: pointer; border: none; }

/* ========== APP LAYOUT ========== */
.app {
  display: grid;
  grid-template-columns: 280px 1fr 320px;
  height: 100vh;
}

/* ========== SIDEBAR ========== */
.sidebar {
  background: #0b0f1a;
  border-right: 1px solid #1e293b;
  padding: 24px 20px;
  overflow-y: auto;
}
.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding-bottom: 20px;
  border-bottom: 1px solid #1e293b;
  margin-bottom: 20px;
}
.brand-mark {
  width: 44px; height: 44px;
  background: linear-gradient(135deg, #1e3a8a, #0ea5e9);
  border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  font-size: 22px;
  box-shadow: 0 8px 20px rgba(14, 165, 233, .3);
}
.brand-title { font-size: 16px; font-weight: 900; color: #fff; }
.brand-sub { font-size: 10px; color: #64748b; font-family: 'Roboto Mono', monospace; }

.kb-status {
  background: rgba(14, 165, 233, .05);
  border: 1px solid rgba(14, 165, 233, .15);
  border-radius: 8px;
  padding: 12px;
  margin-bottom: 20px;
}
.kb-row {
  display: flex;
  justify-content: space-between;
  font-size: 11px;
  padding: 4px 0;
  font-family: 'Roboto Mono', monospace;
}
.kb-row span { color: #64748b; }
.kb-row b { color: #FCD34D; font-weight: 700; }

.src-section { margin-bottom: 20px; }
.src-section-title {
  font-size: 11px;
  font-weight: 700;
  color: #94a3b8;
  margin-bottom: 8px;
  letter-spacing: 0.5px;
}
.src-list { display: flex; flex-direction: column; gap: 4px; }
.src-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  background: rgba(255,255,255,.02);
  border: 1px solid rgba(255,255,255,.04);
  border-radius: 6px;
  font-size: 11px;
  color: #cbd5e1;
  transition: all .2s;
}
.src-item.highlight {
  background: rgba(252, 211, 77, .12);
  border-color: rgba(252, 211, 77, .4);
  color: #FCD34D;
}
.src-item .src-icon { font-size: 12px; }
.src-item .src-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.ingest {
  background: rgba(255,255,255,.02);
  border: 1px solid #1e293b;
  border-radius: 8px;
  padding: 12px;
  margin-top: 16px;
}
.ingest-title {
  font-size: 10px;
  font-weight: 700;
  color: #64748b;
  letter-spacing: 1px;
  margin-bottom: 10px;
  font-family: 'Roboto Mono', monospace;
}
.ingest-row {
  display: flex;
  justify-content: space-between;
  font-size: 10px;
  color: #94a3b8;
  padding: 3px 0;
}
.ingest-on {
  color: #22c55e;
  font-size: 8px;
  text-shadow: 0 0 8px #22c55e;
  animation: pulse 2s ease infinite;
}
@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

/* ========== MAIN ========== */
.main {
  background: #0f172a;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.topbar {
  background: rgba(15, 23, 42, .8);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid #1e293b;
  padding: 16px 32px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.topbar-title { font-size: 16px; font-weight: 900; color: #fff; }
.topbar-sub { font-size: 11px; color: #64748b; margin-top: 2px; }
.user-pill {
  display: flex;
  align-items: center;
  gap: 10px;
  background: rgba(255,255,255,.05);
  border: 1px solid rgba(255,255,255,.08);
  padding: 8px 14px;
  border-radius: 100px;
}
.user-avatar {
  width: 32px; height: 32px;
  background: linear-gradient(135deg, #f59e0b, #ef4444);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 16px;
}
.user-name { font-size: 12px; font-weight: 700; color: #fff; }
.user-status { font-size: 10px; color: #94a3b8; }
.user-status b { color: #FCD34D; }

/* ========== CHAT ========== */
.chat {
  flex: 1;
  overflow-y: auto;
  padding: 32px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}
.msg {
  display: flex;
  gap: 12px;
  max-width: 90%;
  animation: msgIn .4s ease;
}
@keyframes msgIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}
.msg.user { align-self: flex-end; flex-direction: row-reverse; }
.avatar {
  width: 36px; height: 36px;
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-size: 18px;
  flex-shrink: 0;
}
.msg.ai .avatar {
  background: linear-gradient(135deg, #1e3a8a, #0ea5e9);
}
.msg.user .avatar {
  background: linear-gradient(135deg, #f59e0b, #ef4444);
}
.bubble {
  background: #1e293b;
  border: 1px solid #334155;
  border-radius: 14px;
  padding: 14px 18px;
  font-size: 13px;
  color: #e2e8f0;
  line-height: 1.8;
}
.msg.user .bubble {
  background: #0ea5e9;
  border-color: #0ea5e9;
  color: #fff;
}
.bubble-name {
  font-size: 11px;
  font-weight: 700;
  color: #94a3b8;
  margin-bottom: 6px;
}
.msg.user .bubble-name { display: none; }
.bubble-text { font-size: 13px; }
.bubble-text b { color: #FCD34D; }
.msg.user .bubble-text b { color: #fff; }

/* Suggested questions */
.suggest {
  margin-top: 14px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.suggest-btn {
  text-align: left;
  background: rgba(14, 165, 233, .1);
  border: 1px solid rgba(14, 165, 233, .25);
  color: #93c5fd;
  padding: 10px 14px;
  border-radius: 8px;
  font-size: 12px;
  transition: all .2s;
}
.suggest-btn:hover {
  background: rgba(14, 165, 233, .2);
  color: #fff;
  transform: translateX(4px);
}

/* AI processing indicator */
.processing {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  background: rgba(14, 165, 233, .08);
  border-left: 2px solid #0ea5e9;
  border-radius: 4px;
  font-size: 11px;
  color: #93c5fd;
  font-family: 'Roboto Mono', monospace;
  margin: 4px 0;
}
.proc-dot {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: #0ea5e9;
  animation: procPulse 1s ease infinite;
}
@keyframes procPulse {
  0%, 100% { opacity: 0.3; transform: scale(1); }
  50% { opacity: 1; transform: scale(1.4); }
}

/* Citations */
.citation {
  display: inline-flex;
  align-items: center;
  background: rgba(252, 211, 77, .15);
  color: #FCD34D;
  border: 1px solid rgba(252, 211, 77, .3);
  font-size: 10px;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 4px;
  margin: 0 2px;
  cursor: pointer;
  font-family: 'Roboto Mono', monospace;
}
.citation:hover {
  background: rgba(252, 211, 77, .3);
}

/* Answer card sections */
.ans-section { margin-top: 8px; }
.ans-section-title {
  font-size: 11px;
  font-weight: 700;
  color: #FCD34D;
  margin-top: 10px;
  margin-bottom: 4px;
}
.ans-fields {
  background: rgba(255,255,255,.04);
  border-radius: 6px;
  padding: 10px 14px;
  margin: 8px 0;
  font-family: 'Roboto Mono', monospace;
  font-size: 11px;
}
.ans-field-row {
  display: flex;
  justify-content: space-between;
  padding: 3px 0;
  border-bottom: 1px dashed rgba(255,255,255,.05);
}
.ans-field-row:last-child { border-bottom: none; }
.ans-field-row span:first-child { color: #94a3b8; }
.ans-field-row span:last-child { color: #fff; font-weight: 700; }

.score-up {
  background: linear-gradient(135deg, rgba(34,197,94,.15), rgba(34,197,94,.05));
  border: 1px solid rgba(34,197,94,.3);
  border-radius: 8px;
  padding: 10px 14px;
  margin-top: 12px;
  font-size: 12px;
  color: #86efac;
}
.score-up b { color: #4ade80; }

/* ========== INPUT ========== */
.inputbar {
  background: #0f172a;
  border-top: 1px solid #1e293b;
  padding: 20px 32px;
}
.inputbar-inner {
  display: flex;
  gap: 10px;
  background: #1e293b;
  border: 1px solid #334155;
  border-radius: 12px;
  padding: 6px 6px 6px 18px;
  transition: border-color .2s;
}
.inputbar-inner:focus-within {
  border-color: #0ea5e9;
  box-shadow: 0 0 0 3px rgba(14, 165, 233, .15);
}
#query-input {
  flex: 1;
  background: transparent;
  border: none;
  color: #fff;
  font-size: 14px;
  outline: none;
}
#query-input::placeholder { color: #64748b; }
.send-btn {
  background: linear-gradient(135deg, #1e3a8a, #0ea5e9);
  color: #fff;
  width: 40px; height: 40px;
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  transition: all .2s;
}
.send-btn:hover {
  transform: scale(1.05);
  box-shadow: 0 8px 20px rgba(14, 165, 233, .4);
}
.send-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}
.input-hint {
  margin-top: 8px;
  font-size: 10px;
  color: #475569;
  text-align: center;
}

/* ========== RIGHT PANEL ========== */
.rightpanel {
  background: #0b0f1a;
  border-left: 1px solid #1e293b;
  padding: 24px 20px;
  overflow-y: auto;
}
.rp-title {
  font-size: 14px;
  font-weight: 900;
  color: #fff;
  margin-bottom: 4px;
}
.rp-sub {
  font-size: 11px;
  color: #64748b;
  margin-bottom: 20px;
}

.pipeline {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 24px;
}
.pl-step {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  background: rgba(255,255,255,.02);
  border: 1px solid rgba(255,255,255,.05);
  border-radius: 8px;
  transition: all .3s;
}
.pl-step.active {
  background: rgba(14, 165, 233, .12);
  border-color: rgba(14, 165, 233, .4);
  box-shadow: 0 0 0 3px rgba(14, 165, 233, .1);
}
.pl-step.done {
  background: rgba(34, 197, 94, .08);
  border-color: rgba(34, 197, 94, .25);
}
.pl-num {
  width: 22px; height: 22px;
  background: #1e293b;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 11px;
  font-weight: 700;
  color: #94a3b8;
  font-family: 'Roboto Mono', monospace;
  flex-shrink: 0;
}
.pl-step.active .pl-num {
  background: #0ea5e9;
  color: #fff;
  animation: numPulse 1s infinite;
}
.pl-step.done .pl-num {
  background: #22c55e;
  color: #fff;
}
@keyframes numPulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.15); }
}
.pl-name {
  flex: 1;
  font-size: 11px;
  font-weight: 700;
  color: #cbd5e1;
}
.pl-status {
  font-size: 9px;
  color: #64748b;
  font-family: 'Roboto Mono', monospace;
}
.pl-step.active .pl-status { color: #0ea5e9; }
.pl-step.done .pl-status { color: #22c55e; }

.rp-section { margin-bottom: 24px; }
.rp-section-title {
  font-size: 11px;
  font-weight: 700;
  color: #94a3b8;
  margin-bottom: 10px;
  letter-spacing: 0.5px;
}
.retrieved {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.retrieved-empty {
  text-align: center;
  font-size: 10px;
  color: #475569;
  padding: 24px 0;
  border: 1px dashed #1e293b;
  border-radius: 8px;
  line-height: 1.6;
}
.ret-card {
  background: rgba(255,255,255,.02);
  border: 1px solid rgba(255,255,255,.06);
  border-radius: 8px;
  padding: 10px;
  font-size: 10px;
  cursor: pointer;
  transition: all .2s;
  animation: retIn .3s ease;
}
@keyframes retIn {
  from { opacity: 0; transform: translateX(8px); }
  to { opacity: 1; transform: translateX(0); }
}
.ret-card:hover {
  background: rgba(252, 211, 77, .08);
  border-color: rgba(252, 211, 77, .3);
}
.ret-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 4px;
}
.ret-id {
  font-family: 'Roboto Mono', monospace;
  font-weight: 700;
  color: #FCD34D;
  font-size: 10px;
}
.ret-score {
  font-family: 'Roboto Mono', monospace;
  color: #22c55e;
  font-size: 9px;
}
.ret-title { color: #fff; font-weight: 700; margin-bottom: 2px; line-height: 1.4; }
.ret-source { color: #64748b; font-size: 9px; }

/* Skill mini progress */
.skill-mini { margin-bottom: 10px; }
.sm-row {
  display: flex;
  justify-content: space-between;
  font-size: 10px;
  color: #cbd5e1;
  margin-bottom: 4px;
  font-weight: 700;
}
.sm-bar {
  height: 4px;
  background: rgba(255,255,255,.06);
  border-radius: 100px;
  overflow: hidden;
}
.sm-fill {
  height: 100%;
  border-radius: 100px;
  transition: width 1s ease;
}

/* ========== SCROLLBAR ========== */
.sidebar::-webkit-scrollbar,
.chat::-webkit-scrollbar,
.rightpanel::-webkit-scrollbar {
  width: 6px;
}
.sidebar::-webkit-scrollbar-track,
.chat::-webkit-scrollbar-track,
.rightpanel::-webkit-scrollbar-track {
  background: transparent;
}
.sidebar::-webkit-scrollbar-thumb,
.chat::-webkit-scrollbar-thumb,
.rightpanel::-webkit-scrollbar-thumb {
  background: #1e293b;
  border-radius: 100px;
}
.sidebar::-webkit-scrollbar-thumb:hover,
.chat::-webkit-scrollbar-thumb:hover,
.rightpanel::-webkit-scrollbar-thumb:hover {
  background: #334155;
}

/* ========== RESPONSIVE ========== */
@media (max-width: 1200px) {
  .app { grid-template-columns: 240px 1fr 280px; }
}
@media (max-width: 968px) {
  .app { grid-template-columns: 1fr; grid-template-rows: auto 1fr auto; }
  .sidebar, .rightpanel { display: none; }
}
