:root {
  --ink: #1a1c22;
  --paper: #f7f5f0;
  --panel: #efece4;
  --line: #e0dccf;
  --line2: #d2cdbd;
  --muted: #847c6c;
  --accent: #9b1d20;
  --accent-soft: #f6e7e7;
  --steel: #33475b;
  --gold: #c8932e;

  --ed-bg: #21252b;       /* éditeur sombre type IDE */
  --ed-line: #2c313a;
  --ed-gutter: #5c6370;
  --ed-active: #2f343e;
  --ed-active-bar: #9b1d20;
  --ed-soft: #9aa3b0;

  --mono: "JetBrains Mono", "SF Mono", Menlo, monospace;
  --serif: "Fraunces", "Iowan Old Style", Georgia, serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font-family: var(--serif);
  color: var(--ink);
  background: var(--paper);
  display: flex; flex-direction: column;
  height: 100vh; overflow: hidden;
  -webkit-font-smoothing: antialiased;
}

/* Barre du haut */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 22px; height: 58px; flex: 0 0 58px;
  border-bottom: 1px solid var(--line2);
  background: linear-gradient(180deg, #faf8f3, #f2efe7);
  z-index: 10;
}
.brand { display: flex; align-items: baseline; gap: 16px; }
.logo { font-size: 24px; font-weight: 700; letter-spacing: -.6px; }
.logo em { font-style: normal; color: var(--accent); }
.tag { font-family: var(--mono); font-size: 11px; letter-spacing: .4px;
  color: var(--muted); padding-left: 16px; border-left: 1px solid var(--line2); }
.actions { display: flex; gap: 8px; }

.btn {
  font-family: var(--mono); font-size: 12px; font-weight: 500; letter-spacing: .2px;
  padding: 8px 15px; border: 1px solid var(--line2); background: #fff;
  color: var(--ink); cursor: pointer; border-radius: 7px; transition: .15s;
}
.btn:hover { border-color: var(--ink); transform: translateY(-1px);
  box-shadow: 0 3px 10px rgba(0,0,0,.08); }
.btn:active { transform: translateY(0); }
.btn:disabled { opacity: .4; cursor: not-allowed; transform: none; box-shadow: none; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover { background: #821719; border-color: #821719; }
.btn-ai { width: 100%; background: var(--steel); border-color: var(--steel); color: #fff; }
.btn-ai:hover:not(:disabled) { background: #25384b; border-color: #25384b; }

/* Boutons compacts (éditeur, recherche) */
.icon-btn {
  font-family: var(--mono); font-size: 11px; padding: 5px 10px;
  border: 1px solid var(--ed-line); background: #22262d; color: var(--ed-soft);
  border-radius: 6px; cursor: pointer; transition: .12s; white-space: nowrap;
}
.icon-btn:hover:not(:disabled) { color: #e6e1d5; border-color: #3a414d; background: #272c34; }
.icon-btn:disabled { opacity: .4; cursor: not-allowed; }
.icon-btn.on { color: #fff; border-color: var(--accent); background: rgba(155,29,32,.28); }

/* Disposition 3 colonnes */
.layout { flex: 1; display: grid; grid-template-columns: 260px 1fr 360px; overflow: hidden; min-height: 0; }
.sidebar, .inspector { overflow: hidden; background: var(--panel); display: flex; flex-direction: column; }
.sidebar { border-right: 1px solid var(--line2); }
.inspector { border-left: 1px solid var(--line2); }

.panel-head {
  display: flex; align-items: center; justify-content: space-between;
  font-family: var(--mono); font-size: 10px; text-transform: uppercase;
  letter-spacing: 1.4px; color: var(--muted); padding: 16px 18px 10px; flex: 0 0 auto;
}
.count { background: var(--line); color: var(--muted); border-radius: 20px;
  padding: 2px 8px; font-size: 10px; letter-spacing: 0; }

/* Filtre explorateur */
.tree-filter { padding: 0 12px 10px; flex: 0 0 auto; }
.tree-search-input, .sym-search-input {
  width: 100%; font-family: var(--mono); font-size: 11px; padding: 8px 10px;
  border: 1px solid var(--line2); border-radius: 7px; background: #fff; color: var(--ink);
}
.tree-search-input:focus, .sym-search-input:focus { outline: none; border-color: var(--accent); }

/* Arborescence */
.tree { padding: 0 8px 16px; overflow-y: auto; flex: 1; }
.tree .dir, .tree .file {
  font-family: var(--mono); font-size: 12px; padding: 5px 8px; cursor: pointer;
  border-radius: 6px; transition: .1s; user-select: none;
}
.tree .dir { display: flex; align-items: center; gap: 6px; color: #5a5340; font-weight: 500; }
.tree .dir:hover { background: #fff; }
.tree .dir .caret { display: inline-block; width: 10px; font-size: 9px; color: var(--muted); flex: 0 0 auto; }
.tree .dir .dir-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tree .children.hidden { display: none; }

.tree .file {
  display: flex; align-items: center; gap: 8px; color: #4a4538;
  white-space: nowrap; overflow: hidden;
}
.tree .file:hover { background: #fff; }
.tree .file.active { background: var(--accent); color: #fff; box-shadow: 0 2px 6px rgba(155,29,32,.3); }
.tree .file .ext {
  flex: 0 0 auto; font-size: 8.5px; font-weight: 700; text-transform: uppercase;
  letter-spacing: .5px; color: var(--muted); background: var(--line);
  border-radius: 4px; padding: 2px 5px; min-width: 28px; text-align: center;
}
.tree .file.active .ext { background: rgba(255,255,255,.25); color: #fff; }
.tree .file .fname { overflow: hidden; text-overflow: ellipsis; }
.hint { font-family: var(--mono); font-size: 11px; color: var(--muted); padding: 10px 18px; line-height: 1.6; }

/* Éditeur sombre */
.editor { display: flex; flex-direction: column; overflow: hidden; background: var(--ed-bg); min-width: 0; position: relative; }
.editor-head {
  display: flex; align-items: center; gap: 16px; padding: 0 16px 0 20px; height: 44px;
  border-bottom: 1px solid var(--ed-line); background: #1b1e24; flex: 0 0 44px;
}
.editor-head .spacer { flex: 1; }
.file-name { font-family: var(--mono); font-size: 13px; font-weight: 600; color: #e6e1d5; flex: 0 0 auto; }
.stats { font-family: var(--mono); font-size: 11px; color: var(--ed-gutter); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ed-actions { display: flex; gap: 6px; flex: 0 0 auto; }

/* Barre de recherche dans le code */
.code-search {
  display: flex; align-items: center; gap: 8px; padding: 8px 14px;
  background: #1b1e24; border-bottom: 1px solid var(--ed-line); flex: 0 0 auto;
}
.code-search.hidden { display: none; }
.cs-input {
  flex: 1; font-family: var(--mono); font-size: 12px; padding: 6px 10px;
  border: 1px solid var(--ed-line); border-radius: 6px; background: #22262d; color: #e6e1d5;
}
.cs-input:focus { outline: none; border-color: var(--accent); }
.cs-count { font-family: var(--mono); font-size: 11px; color: var(--ed-gutter); min-width: 46px; text-align: center; }

.code-wrap { flex: 1; overflow: auto; position: relative; }

.code { border-collapse: collapse; width: 100%; font-family: var(--mono);
  font-size: 13px; line-height: 1.65; }
.code td { padding: 0; vertical-align: top; }
.code .ln {
  text-align: right; color: var(--ed-gutter); padding: 0 14px 0 18px; user-select: none;
  width: 1%; white-space: nowrap; position: sticky; left: 0; background: var(--ed-bg);
}
.code .src { padding: 0 20px 0 14px; white-space: pre; color: #abb2bf; }
.code.wrap .src { white-space: pre-wrap; word-break: break-word; }
.code tr.has-note { cursor: pointer; }
.code tr:hover .ln { color: #abb2bf; }
.code tr.has-note:hover { background: var(--ed-line); }
.code tr.active { background: var(--ed-active); }
.code tr.active .ln { background: var(--ed-active); color: #fff; font-weight: 600;
  box-shadow: inset 3px 0 0 var(--ed-active-bar); }

/* Surlignage de recherche */
.code tr.search-hit { background: rgba(155,29,32,.16); }
.code tr.search-hit .ln { background: rgba(155,29,32,.16); }
.code tr.search-current { background: rgba(200,147,46,.30); }
.code tr.search-current .ln { background: rgba(200,147,46,.30); color: #fff; }

.empty { position: absolute; inset: 0; display: flex; flex-direction: column;
  align-items: center; justify-content: center; text-align: center; padding: 40px; color: #cdd2da; }
.empty-mark { font-family: var(--mono); font-size: 56px; color: var(--accent);
  opacity: .85; margin-bottom: 8px; font-weight: 600; }
.empty h1 { font-size: 40px; line-height: 1.04; margin: 0 0 16px; color: #f0ece2; font-weight: 600; }
.empty p { font-family: var(--mono); font-size: 12px; color: #8b93a0; max-width: 44ch;
  line-height: 1.8; margin: 0 0 26px; }
.empty-cta { display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; }
.empty-tip { font-family: var(--mono); font-size: 11px; color: #6b7280; margin-top: 22px; }

/* Voile de glisser-déposer */
.drop-veil {
  position: absolute; inset: 0; z-index: 6; display: flex; align-items: center; justify-content: center;
  background: rgba(27,30,36,.88); border: 2px dashed var(--accent); margin: 8px; border-radius: 12px;
}
.drop-veil.hidden { display: none; }
.drop-msg { font-family: var(--mono); font-size: 14px; color: #f0ece2; letter-spacing: .5px; }

/* Inspecteur : onglets */
.insp-tabs { display: flex; flex: 0 0 auto; border-bottom: 1px solid var(--line2); background: var(--panel); }
.insp-tab {
  flex: 1; font-family: var(--mono); font-size: 10px; text-transform: uppercase; letter-spacing: 1px;
  padding: 15px 6px; background: none; border: none; color: var(--muted); cursor: pointer;
  border-bottom: 2px solid transparent; transition: .12s;
}
.insp-tab:hover { color: var(--ink); }
.insp-tab.active { color: var(--accent); border-bottom-color: var(--accent); }

.insp-body { flex: 1; overflow: hidden; display: flex; flex-direction: column; min-height: 0; }
.tab-pane { display: none; flex: 1; min-height: 0; }
.tab-pane.active { display: flex; flex-direction: column; overflow: hidden; }

/* Aperçu */
.overview { padding: 18px; overflow-y: auto; flex: 1; }
.ov-file { font-family: var(--mono); font-size: 13px; font-weight: 600; color: var(--ink);
  margin-bottom: 14px; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.ov-lang { font-size: 9px; text-transform: uppercase; letter-spacing: 1px; color: var(--muted);
  border: 1px solid var(--line2); border-radius: 4px; padding: 2px 6px; }
.ov-error { font-family: var(--mono); font-size: 11px; color: var(--accent); background: var(--accent-soft);
  border-radius: 6px; padding: 8px 10px; margin-bottom: 14px; line-height: 1.5; }
.ov-stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-bottom: 18px; }
.ov-stat { background: #fff; border: 1px solid var(--line); border-radius: 9px; padding: 10px 4px; text-align: center; }
.ov-stat b { display: block; font-family: var(--mono); font-size: 18px; color: var(--ink); }
.ov-stat span { font-family: var(--mono); font-size: 9px; text-transform: uppercase; letter-spacing: .5px; color: var(--muted); }
.ov-text { font-size: 15px; line-height: 1.7; color: var(--ink); margin: 0; }

/* Symboles */
.sym-filter { padding: 14px 16px 8px; flex: 0 0 auto; }
.symbols { padding: 0 16px 16px; overflow-y: auto; flex: 1; }
.sym {
  font-family: var(--mono); font-size: 12px; padding: 10px 12px; margin-bottom: 8px;
  border: 1px solid var(--line); border-radius: 9px; background: #fff; cursor: pointer;
  transition: .12s; border-left: 3px solid var(--accent);
}
.sym:hover { transform: translateX(2px); box-shadow: 0 3px 10px rgba(0,0,0,.06); }
.sym.active { box-shadow: 0 0 0 2px var(--accent); }
.sym.class { border-left-color: var(--steel); }
.sym.class.active { box-shadow: 0 0 0 2px var(--steel); }
.sym .sym-kind { color: var(--muted); font-size: 9px; text-transform: uppercase;
  letter-spacing: 1px; margin-bottom: 4px; }
.sym .sym-name { font-weight: 600; color: var(--ink); word-break: break-word; }
.sym .sym-sum { color: #4a4538; margin-top: 5px; line-height: 1.5; font-family: var(--serif); font-size: 13.5px; }

/* Ligne (explication) */
.ligne-scroll { flex: 1; overflow-y: auto; min-height: 0; }
.insp-explain { padding: 18px; font-size: 15.5px; line-height: 1.65; }
.insp-explain .ex-line { font-family: var(--mono); font-size: 11px; color: var(--accent);
  text-transform: uppercase; letter-spacing: 1px; margin-bottom: 10px; display: flex;
  align-items: center; justify-content: space-between; }
.ex-copy { font-family: var(--mono); font-size: 10px; color: var(--muted); border: 1px solid var(--line2);
  background: #fff; border-radius: 5px; padding: 2px 7px; cursor: pointer; letter-spacing: 0; }
.ex-copy:hover { color: var(--ink); border-color: var(--ink); }
.insp-explain .ex-code { font-family: var(--mono); font-size: 12px; background: var(--ed-bg);
  color: #abb2bf; padding: 10px 12px; border-radius: 8px; white-space: pre-wrap;
  margin-bottom: 14px; overflow-x: auto; }
.insp-explain .ex-text { color: var(--ink); }

.ai-out { padding: 0 18px 18px; }
.ai-block { border-top: 1px dashed var(--line2); padding-top: 14px; }
.ai-label { font-family: var(--mono); font-size: 10px; text-transform: uppercase; letter-spacing: 1px;
  color: var(--steel); margin-bottom: 8px; }
.ai-text { font-size: 14.5px; line-height: 1.7; white-space: pre-wrap; color: var(--ink); }
.ai-text.err { color: var(--accent); font-family: var(--mono); font-size: 12px; line-height: 1.5; }

.sym.sym-method { margin-left: 16px; border-left: 2px solid var(--line2); }
.ai-box.hidden { display: none; }
.ai-box { padding: 14px 16px; border-top: 1px solid var(--line2); background: var(--panel); flex: 0 0 auto; }
.ai-q { width: 100%; font-family: var(--mono); font-size: 12px; padding: 8px 10px;
  border: 1px solid var(--line2); border-radius: 7px; background: #fff; margin-bottom: 8px; color: var(--ink); }
.ai-q:focus { outline: none; border-color: var(--steel); }
.ai-q:disabled { opacity: .5; }
.ai-hint { font-family: var(--mono); font-size: 10px; color: var(--muted); margin: 9px 0 0; text-align: center; }

/* Modale */
.modal { position: fixed; inset: 0; background: rgba(26,28,34,.6); display: flex;
  align-items: center; justify-content: center; z-index: 50; backdrop-filter: blur(3px); }
.modal.hidden { display: none; }
.modal-card { background: var(--paper); border-radius: 14px; padding: 26px;
  width: min(660px, 92vw); box-shadow: 0 30px 80px rgba(0,0,0,.4); }
.modal-card h2 { margin: 0 0 16px; font-size: 24px; font-weight: 600; }
.modal-input { width: 100%; font-family: var(--mono); font-size: 13px; padding: 10px 12px;
  border: 1px solid var(--line2); border-radius: 8px; margin-bottom: 12px; background: #fff; }
.modal-input:focus, .modal-area:focus { outline: none; border-color: var(--accent); }
.modal-area { width: 100%; height: 320px; font-family: var(--mono); font-size: 13px;
  padding: 12px; border: 1px solid var(--line2); border-radius: 8px; resize: vertical;
  background: #fff; line-height: 1.55; }
.modal-actions { display: flex; align-items: center; gap: 8px; margin-top: 14px; }
.modal-actions .spacer { flex: 1; }
.modal-hint { font-family: var(--mono); font-size: 10px; color: var(--muted); }

/* Info-bulle au survol d'une ligne */
.tip {
  position: fixed; z-index: 80; max-width: 340px; font-family: var(--serif); font-size: 13.5px;
  line-height: 1.5; color: #f0ece2; background: #1b1e24; border: 1px solid #313641;
  border-left: 3px solid var(--accent); border-radius: 8px; padding: 9px 12px;
  box-shadow: 0 10px 30px rgba(0,0,0,.35); pointer-events: none;
}
.tip.hidden { display: none; }

/* Loader */
.loader { position: fixed; inset: 0; display: flex; align-items: center; justify-content: center;
  background: rgba(26,28,34,.3); z-index: 60; }
.loader.hidden { display: none; }
.spinner { width: 34px; height: 34px; border: 3px solid rgba(255,255,255,.4);
  border-top-color: #fff; border-radius: 50%; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.hljs { background: transparent !important; padding: 0 !important; }

/* Scrollbars discrètes */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: rgba(130,124,108,.4); border-radius: 6px; }
.code-wrap::-webkit-scrollbar-thumb { background: rgba(255,255,255,.18); }

/* Adaptatif */
@media (max-width: 1180px) { .layout { grid-template-columns: 210px 1fr 300px; } }
@media (max-width: 920px) { .tag { display: none; } .layout { grid-template-columns: 180px 1fr 260px; } }
