:root {
  --void: #060a10;
  --abyss: #09121a;
  --panel: #0c141c;
  --panel-2: #101a24;
  --line: #16222e;
  --cyan: #00d4ff;
  --cyan-dim: #0aa8cc;
  --gold: #c9a84c;
  --green: #34d399;
  --text: #d8e2ea;
  --text-dim: #7d8b98;
  --user-bubble: #0e2230;
  --font: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --mono: "Share Tech Mono", "SFMono-Regular", Consolas, "Liberation Mono", monospace;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
.hidden { display: none !important; }

html, body {
  height: 100%;
  background: var(--void);
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior: none;
}

body::before {
  content: "";
  position: fixed; inset: 0;
  background-image:
    linear-gradient(rgba(0,212,255,0.035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(0,212,255,0.035) 1px, transparent 1px);
  background-size: 34px 34px;
  pointer-events: none; z-index: 0;
}

#app { position: relative; z-index: 1; display: flex; flex-direction: column; height: 100vh; height: 100dvh; max-width: 980px; margin: 0 auto; }

/* ---------- login ---------- */
.login-screen {
  position: fixed; inset: 0; z-index: 50;
  display: flex; align-items: center; justify-content: center;
  background: var(--void);
}
.login-box {
  text-align: center; padding: 34px 26px; width: 320px;
  border: 1px solid var(--line); border-radius: 16px;
  background: var(--panel);
  box-shadow: 0 0 60px rgba(0,212,255,0.08);
}
.login-mark { font-size: 46px; color: var(--cyan); text-shadow: 0 0 26px var(--cyan); margin-bottom: 8px; }
.login-box h1 { font-weight: 600; font-size: 1.3em; margin-bottom: 2px; }
.login-sub { color: var(--text-dim); font-size: 13px; margin-bottom: 18px; }
#key-input {
  width: 100%; padding: 11px 13px; border-radius: 10px;
  background: var(--void); border: 1px solid var(--line); color: var(--text);
  font-family: var(--mono); font-size: 14px; text-align: center; outline: none;
}
#key-input:focus { border-color: var(--cyan); box-shadow: 0 0 0 1px rgba(0,212,255,0.25); }
#key-submit {
  width: 100%; margin-top: 12px; padding: 11px; border: none; border-radius: 10px;
  background: linear-gradient(135deg, var(--cyan), var(--cyan-dim));
  color: #04121a; font-weight: 700; cursor: pointer; font-size: 14px;
}
#key-submit:active { transform: scale(0.97); }
.key-error { color: #ff5c5c; font-size: 13px; margin-top: 10px; }

/* ---------- topbar ---------- */
#topbar {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--line);
  background: rgba(6,10,16,0.85);
  backdrop-filter: blur(10px);
  flex-wrap: wrap;
}
.brand { display: flex; align-items: center; gap: 8px; }
.brand .dot { width: 10px; height: 10px; border-radius: 50%; background: var(--cyan); box-shadow: 0 0 12px var(--cyan); }
.brand-name { font-weight: 600; letter-spacing: 0.3px; font-size: 14px; }
.brand-name em { color: var(--cyan); font-style: normal; opacity: 0.85; }

#views { display: flex; gap: 4px; flex: 1; justify-content: center; }
#views button {
  background: none; border: 1px solid transparent; color: var(--text-dim);
  padding: 6px 12px; border-radius: 8px; cursor: pointer; font-size: 13px; font-weight: 500;
}
#views button:hover { color: var(--text); }
#views button.active { color: var(--text); border-color: var(--line); background: var(--panel); }

.topbar-actions { display: flex; gap: 6px; align-items: center; }
.icon-btn {
  background: var(--panel); border: 1px solid var(--line); color: var(--text);
  width: 34px; height: 34px; border-radius: 8px; cursor: pointer; font-size: 15px;
}
.icon-btn:hover { border-color: var(--cyan); }
#btn-new {
  background: linear-gradient(135deg, var(--cyan), var(--cyan-dim)); color: #04121a;
  border: none; padding: 8px 13px; border-radius: 8px; font-weight: 700; font-size: 13px; cursor: pointer;
}
#btn-new:active { transform: scale(0.96); }

/* menu dropdown */
#menu {
  position: absolute; top: 52px; right: 12px; z-index: 40;
  background: var(--panel-2); border: 1px solid var(--line); border-radius: 10px;
  padding: 6px; display: flex; flex-direction: column; min-width: 210px;
  box-shadow: 0 8px 30px rgba(0,0,0,0.5);
}
#app { position: relative; }
#menu button {
  background: none; border: none; color: var(--text); text-align: left;
  padding: 10px 12px; border-radius: 7px; cursor: pointer; font-size: 13px;
}
#menu button:hover { background: var(--panel); color: var(--cyan); }

/* ---------- tabs ---------- */
#tabs {
  display: flex; gap: 6px; padding: 8px 12px 0; overflow-x: auto;
  border-bottom: 1px solid var(--line); background: var(--abyss); scrollbar-width: thin;
}
.tab {
  display: flex; align-items: center; gap: 7px; padding: 8px 12px;
  border-radius: 9px 9px 0 0; cursor: pointer; white-space: nowrap;
  color: var(--text-dim); font-size: 13px; border: 1px solid transparent; border-bottom: none;
  max-width: 200px;
}
.tab .tdot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; cursor: pointer; }
.tab .tname { overflow: hidden; text-overflow: ellipsis; }
.tab:hover { color: var(--text); }
.tab.active { color: var(--text); background: var(--panel); border-color: var(--line); border-top: 2px solid var(--cyan); }
.tab .close { opacity: 0; border: none; background: none; color: var(--text-dim); cursor: pointer; font-size: 14px; line-height: 1; padding: 0 2px; }
.tab:hover .close { opacity: 0.7; }
.tab .close:hover { opacity: 1; color: #ff5c5c; }

/* ---------- notes panel ---------- */
#notes-panel { padding: 8px 12px; border-bottom: 1px solid var(--line); background: var(--abyss); }
#notes {
  width: 100%; min-height: 64px; max-height: 160px; resize: vertical;
  background: var(--panel); border: 1px solid var(--line); color: var(--gold);
  border-radius: 9px; padding: 10px 12px; font-family: var(--font); font-size: 13px; outline: none;
}
#notes:focus { border-color: var(--gold); }

/* ---------- chat ---------- */
.view { flex: 1; display: flex; flex-direction: column; min-height: 0; overflow: hidden; }
#chat {
  flex: 1; overflow-y: auto; padding: 20px 16px 8px;
  display: flex; flex-direction: column; gap: 16px; scroll-behavior: smooth;
}
.empty { margin: auto; text-align: center; color: var(--text-dim); padding: 20px; }
.empty-mark { font-size: 42px; color: var(--cyan); text-shadow: 0 0 24px var(--cyan); margin-bottom: 10px; }
.empty h2 { color: var(--text); font-weight: 600; margin-bottom: 6px; }

.msg { display: flex; flex-direction: column; max-width: 100%; }
.msg .role { font-size: 11px; text-transform: uppercase; letter-spacing: 1px; color: var(--text-dim); margin-bottom: 3px; }
.msg.user .role { color: var(--cyan); }
.msg .bubble { padding: 11px 14px; border-radius: 12px; border: 1px solid var(--line); background: var(--panel); overflow-wrap: break-word; }
.msg.user .bubble { background: var(--user-bubble); border-color: #1a3a4d; margin-left: 34px; align-self: flex-end; }
.msg.streaming .bubble::after { content: "▍"; color: var(--cyan); animation: blink 0.9s steps(2) infinite; }
@keyframes blink { 50% { opacity: 0; } }

/* markdown */
.bubble p { margin: 0 0 8px; } .bubble p:last-child { margin-bottom: 0; }
.bubble h1, .bubble h2, .bubble h3, .bubble h4 { color: var(--text); font-weight: 600; margin: 14px 0 6px; line-height: 1.3; }
.bubble h1 { font-size: 1.25em; } .bubble h2 { font-size: 1.15em; } .bubble h3 { font-size: 1.05em; }
.bubble ul, .bubble ol { margin: 0 0 8px; padding-left: 20px; } .bubble li { margin: 2px 0; }
.bubble code { font-family: var(--mono); font-size: 0.9em; background: rgba(0,212,255,0.08); color: var(--cyan); padding: 1px 5px; border-radius: 5px; }
.bubble pre { background: #060b12; border: 1px solid var(--line); border-radius: 9px; padding: 12px; overflow-x: auto; margin: 8px 0; }
.bubble pre code { background: none; color: var(--text); padding: 0; font-size: 0.85em; }
.bubble a { color: var(--cyan); text-decoration: none; } .bubble a:hover { text-decoration: underline; }
.bubble strong { color: #fff; }
.bubble blockquote { border-left: 3px solid var(--cyan); padding-left: 10px; color: var(--text-dim); margin: 8px 0; }
.bubble hr { border: none; border-top: 1px solid var(--line); margin: 12px 0; }
.bubble table { border-collapse: collapse; margin: 8px 0; font-size: 0.9em; }
.bubble th, .bubble td { border: 1px solid var(--line); padding: 5px 9px; text-align: left; } .bubble th { background: var(--panel-2); }

/* composer */
#composer { display: flex; gap: 8px; padding: 12px 16px; border-top: 1px solid var(--line); background: rgba(6,10,16,0.9); backdrop-filter: blur(10px); align-items: flex-end; }
#input { flex: 1; resize: none; background: var(--panel); border: 1px solid var(--line); color: var(--text); border-radius: 10px; padding: 11px 13px; font-family: var(--font); font-size: 15px; line-height: 1.5; max-height: 160px; outline: none; }
#input:focus { border-color: var(--cyan); box-shadow: 0 0 0 1px rgba(0,212,255,0.25); }
#btn-send { width: 44px; height: 44px; border: none; border-radius: 10px; background: linear-gradient(135deg, var(--cyan), var(--cyan-dim)); color: #04121a; font-size: 17px; cursor: pointer; flex-shrink: 0; }
#btn-send:active { transform: scale(0.94); } #btn-send:disabled { opacity: 0.35; cursor: not-allowed; }

/* ---------- architecture ---------- */
.view-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 18px 6px; }
.view-head h2 { font-size: 1.05em; font-weight: 600; }
.view-head .hint { color: var(--text-dim); font-size: 12px; }
#arch-wrap { flex: 1; display: flex; min-height: 0; padding: 0 12px 12px; gap: 12px; }
#arch-svg { flex: 1; min-width: 0; }
#arch-svg .ring { fill: none; stroke: rgba(0,212,255,0.10); stroke-width: 1; stroke-dasharray: 3 5; }
#arch-svg .spoke { stroke: rgba(0,212,255,0.16); stroke-width: 1; }
#arch-svg .node { cursor: pointer; }
#arch-svg .node-rect { fill: rgba(12,20,28,0.92); stroke-width: 1.3; }
#arch-svg .node:hover .node-rect { fill: #12222e; filter: drop-shadow(0 0 6px rgba(0,212,255,0.5)); }
#arch-svg .nl { fill: #e6f2f8; font-size: 13px; font-weight: 600; font-family: var(--font); pointer-events: none; }
#arch-svg .ns { fill: var(--text-dim); font-size: 9px; font-family: var(--font); pointer-events: none; }
#arch-svg .nucleus .nucleus-circle { fill: rgba(0,212,255,0.08); stroke: var(--cyan); stroke-width: 1.8; }
#arch-svg .nucleus:hover .nucleus-circle { filter: drop-shadow(0 0 12px rgba(0,212,255,0.7)); }
#arch-svg .nucleus .nl { font-size: 15px; }

#arch-detail {
  width: 250px; flex-shrink: 0; padding: 14px; border: 1px solid var(--line); border-radius: 12px;
  background: var(--panel); overflow-y: auto; align-self: flex-start;
}
#arch-detail em { color: var(--text-dim); font-size: 13px; }
#arch-detail h3 { color: var(--cyan); font-weight: 600; margin-bottom: 2px; }
#arch-detail .arch-sub { color: var(--gold); font-size: 12px; margin-bottom: 8px; }
#arch-detail p { color: var(--text); font-size: 13px; }

/* ---------- status ---------- */
#status-grid { flex: 1; overflow-y: auto; padding: 8px 18px 18px; display: flex; flex-wrap: wrap; gap: 10px; align-content: flex-start; }
.status-summary { width: 100%; color: var(--text-dim); font-size: 13px; padding-bottom: 4px; }
.status-summary strong { color: var(--green); font-size: 16px; }
.loading { color: var(--text-dim); padding: 20px; font-size: 14px; }
.status-card {
  display: grid; grid-template-columns: 12px 1fr auto; grid-template-areas: "dot name port" ". name state";
  align-items: center; gap: 2px 8px; width: 210px; padding: 12px;
  border: 1px solid var(--line); border-radius: 11px; background: var(--panel);
}
.status-card .sdot { grid-area: dot; width: 10px; height: 10px; border-radius: 50%; }
.status-card.up .sdot { background: var(--green); box-shadow: 0 0 8px var(--green); }
.status-card.down .sdot { background: #ff5c5c; box-shadow: 0 0 8px #ff5c5c; }
.status-card .sname { grid-area: name; font-weight: 600; font-size: 13px; }
.status-card .sport { grid-area: port; color: var(--text-dim); font-size: 11px; font-family: var(--mono); }
.status-card .sstate { grid-area: state; color: var(--text-dim); font-size: 11px; }
.status-card.up .sstate { color: var(--green); }
.status-card.down .sstate { color: #ff5c5c; }

/* ---------- search overlay ---------- */
#search-overlay { position: fixed; inset: 0; z-index: 60; background: rgba(6,10,16,0.9); backdrop-filter: blur(6px); display: flex; justify-content: center; padding-top: 8vh; }
.search-box { width: 560px; max-width: 92vw; height: fit-content; max-height: 80vh; display: flex; flex-direction: column; background: var(--panel-2); border: 1px solid var(--line); border-radius: 14px; overflow: hidden; box-shadow: 0 12px 50px rgba(0,0,0,0.6); }
#search-input { padding: 15px 16px; background: var(--panel); border: none; border-bottom: 1px solid var(--line); color: var(--text); font-size: 15px; outline: none; }
#search-results { overflow-y: auto; padding: 8px; }
.s-empty { color: var(--text-dim); padding: 24px; text-align: center; font-size: 14px; }
.s-result { display: flex; flex-direction: column; gap: 2px; padding: 10px 12px; border-radius: 8px; cursor: pointer; }
.s-result:hover { background: var(--panel); }
.s-result .s-tag { font-size: 10px; text-transform: uppercase; letter-spacing: 1px; color: var(--cyan); }
.s-result .s-tag.user { color: var(--text-dim); }
.s-result .s-tag.note { color: var(--gold); }
.s-result .s-proj { font-size: 11px; color: var(--text-dim); }
.s-result .s-txt { font-size: 13px; color: var(--text); }
#search-close { padding: 12px; background: none; border: none; border-top: 1px solid var(--line); color: var(--text-dim); cursor: pointer; }
#search-close:hover { color: var(--text); }

/* ---------- thinking indicator ---------- */
.thinking-bubble { display: flex; align-items: center; gap: 8px; }
.think-label { color: var(--cyan); font-size: 13px; }
.think-dots { display: inline-flex; gap: 4px; }
.think-dots i { width: 6px; height: 6px; border-radius: 50%; background: var(--cyan); animation: think-bounce 1.2s infinite; }
.think-dots i:nth-child(2) { animation-delay: .2s; }
.think-dots i:nth-child(3) { animation-delay: .4s; }
@keyframes think-bounce { 0%,80%,100% { transform: translateY(0); opacity: .3 } 40% { transform: translateY(-5px); opacity: 1 } }
.think-timer { color: var(--text-dim); font-size: 12px; font-family: var(--mono); margin-left: 4px; }

/* ---------- mic (dictée) ---------- */
.mic-btn.listening {
  background: rgba(255,92,92,0.18);
  border-color: #ff5c5c;
  color: #ff5c5c;
  animation: mic-pulse 1.2s infinite;
}
@keyframes mic-pulse { 0%,100% { box-shadow: 0 0 0 0 rgba(255,92,92,0.5) } 50% { box-shadow: 0 0 0 7px rgba(255,92,92,0) } }

/* ---------- tts (lecture) ---------- */
#btn-tts.active { border-color: var(--cyan); color: var(--cyan); box-shadow: 0 0 8px rgba(0,212,255,0.3); }

/* ---------- vue Projets (dashboard) ---------- */
#projects-grid { flex: 1; overflow-y: auto; padding: 12px 18px 18px; display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 12px; align-content: start; }
.proj-card { padding: 14px; border: 1px solid var(--line); border-radius: 12px; background: var(--panel); cursor: pointer; transition: border-color .15s, transform .08s; display: flex; flex-direction: column; gap: 8px; min-height: 112px; }
.proj-card:hover { border-color: var(--cyan); transform: translateY(-2px); }
.proj-head { display: flex; align-items: center; gap: 8px; }
.proj-dot { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; cursor: pointer; }
.proj-name { font-weight: 600; font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.proj-desc { color: var(--text-dim); font-size: 12px; line-height: 1.4; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; flex: 1; }
.proj-meta { color: var(--text-dim); font-size: 11px; font-family: var(--mono); }
.proj-actions { display: flex; gap: 6px; margin-top: auto; }
.proj-act { width: 30px; height: 30px; border: 1px solid var(--line); border-radius: 7px; background: var(--panel-2); color: var(--text); cursor: pointer; font-size: 14px; display: inline-flex; align-items: center; justify-content: center; text-decoration: none; }
.proj-act:hover { border-color: var(--cyan); color: var(--cyan); }
.proj-act.proj-del:hover { border-color: #ff5c5c; color: #ff5c5c; }
.proj-act.proj-link { color: var(--gold); }

@media (max-width: 640px) {
  #views { order: 3; width: 100%; justify-content: stretch; }
  #views button { flex: 1; }
  #arch-detail { width: 100%; }
  #arch-wrap { flex-direction: column; }
  #arch-svg { min-height: 340px; }
  .status-card { width: 100%; }
  .msg.user .bubble { margin-left: 14px; }
}
