/* Interface façon terminal Claude Code : sombre, monospace, accent orange Claude. */
:root {
  --bg: #151515; --panel: #1b1b1b; --raised: #222222; --line: #333333;
  --text: #e8e6e3; --dim: #8b8985; --faint: #5c5a57;
  --accent: #d97757; --accent-soft: rgba(217, 119, 87, .14);
  --ok: #4eba65; --err: #ff6b80; --warn: #e5c07b; --user-bg: #262626;
  --add-bg: rgba(78, 186, 101, .14); --del-bg: rgba(255, 107, 128, .14);
  --mono: ui-monospace, "Cascadia Code", "JetBrains Mono", "SF Mono", Menlo, Consolas, monospace;
  color-scheme: dark;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); font: 14px/1.6 var(--mono); -webkit-font-smoothing: antialiased; }
button, input, textarea { font: inherit; color: inherit; }
::selection { background: var(--accent-soft); }
.dim { color: var(--dim); }
.star { color: var(--accent); }
a { color: var(--accent); }

/* Boutons */
.btn { cursor: pointer; border: 1px solid var(--line); background: var(--raised); border-radius: 6px; padding: 6px 12px; }
.btn:hover { border-color: var(--dim); }
.btn:disabled { opacity: .45; cursor: default; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #1a1a1a; font-weight: 600; }
.btn.ghost { background: transparent; border-color: transparent; color: var(--dim); }
.btn.ghost:hover { color: var(--text); background: var(--raised); }
.btn.small { padding: 3px 8px; font-size: 12px; }
.btn.icon { padding: 4px 9px; }
.btn:focus-visible, textarea:focus-visible, input:focus-visible, a:focus-visible { outline: 1px solid var(--accent); outline-offset: 1px; }
.badge { background: var(--accent); color: #1a1a1a; border-radius: 8px; padding: 0 6px; font-size: 11px; font-weight: 700; }

/* Encadré d'accueil, comme le démarrage de Claude Code */
.welcome { border: 1px solid var(--accent); border-radius: 8px; padding: 12px 16px; margin: 0 0 18px; }
.welcome-title { font-size: 15px; }
.welcome .dim { margin-top: 4px; font-size: 13px; }
.welcome ul { margin: 10px 0 0; padding-left: 0; list-style: none; color: var(--dim); font-size: 13px; }
.welcome li::before { content: "› "; color: var(--faint); }
.welcome kbd, .help kbd { color: var(--text); font-family: var(--mono); }

/* Connexion */
.login { max-width: 460px; margin: 14vh auto 0; padding: 0 16px; }
.prompt-line { display: flex; align-items: center; gap: 10px; border: 1px solid var(--line); border-radius: 8px; padding: 8px 12px; background: var(--panel); }
.prompt-line input { flex: 1; border: 0; background: transparent; outline: none; }
.caret { color: var(--accent); font-weight: 700; }
.err { color: var(--err); min-height: 22px; font-size: 13px; margin: 8px 0; }
.login .btn { width: 100%; }

/* Mise en page */
.app { display: flex; height: 100dvh; }
.sidebar { width: 260px; flex-shrink: 0; background: var(--panel); border-right: 1px solid var(--line); display: flex; flex-direction: column; gap: 8px; padding: 10px; transition: margin-left .18s; }
.app.side-hidden .sidebar { margin-left: -260px; }
.side-head { display: flex; justify-content: space-between; align-items: center; font-size: 12px; padding: 2px 2px 4px; }
.conv-list { flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 1px; font-size: 13px; }
.conv { display: flex; align-items: center; gap: 2px; border-radius: 6px; padding: 1px 2px 1px 8px; color: var(--dim); }
.conv:hover { background: var(--raised); color: var(--text); }
.conv.active { background: var(--raised); color: var(--text); }
.conv.active a::before { content: "› "; color: var(--accent); }
.conv a { flex: 1; color: inherit; text-decoration: none; padding: 5px 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.conv .btn { opacity: 0; padding: 2px 6px; font-size: 12px; }
.conv:hover .btn, .conv.active .btn, .conv:focus-within .btn { opacity: .8; }
.backdrop { display: none; }

.main { flex: 1; display: flex; flex-direction: column; min-width: 0; position: relative; }
.topbar { display: flex; align-items: center; gap: 8px; padding: 6px 12px; border-bottom: 1px solid var(--line); font-size: 13px; min-height: 42px; }
.brand { white-space: nowrap; }
.conv-title { flex: 1; font-size: 13px; font-weight: 400; margin: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--dim); }

/* Fichiers produits */
.files-panel { position: absolute; right: 12px; top: 46px; z-index: 6; width: min(440px, calc(100% - 24px)); max-height: 60vh; overflow-y: auto; background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 8px 12px; box-shadow: 0 12px 40px rgba(0,0,0,.5); font-size: 13px; }
.files-head { display: flex; justify-content: space-between; align-items: center; color: var(--dim); }
.files-panel ul { list-style: none; padding: 0; margin: 6px 0 0; }
.files-panel li { display: flex; justify-content: space-between; gap: 10px; padding: 5px 0; border-top: 1px solid var(--line); }
.files-panel a { word-break: break-all; }

/* Fil de la conversation */
.log { flex: 1; overflow-y: auto; padding: 18px 18px 8px; scroll-behavior: smooth; }
.log > * { max-width: 900px; margin-left: auto; margin-right: auto; }
.row { display: grid; grid-template-columns: 18px 1fr; gap: 6px; margin: 0 auto 14px; overflow-wrap: anywhere; }
.row > .gutter { color: var(--text); user-select: none; }

.msg.user { background: var(--user-bg); border-radius: 6px; padding: 6px 10px; }
.msg.user > .gutter { color: var(--dim); }
.msg.user .body { white-space: pre-wrap; }
.msg.user .att { display: block; color: var(--dim); font-size: 12px; }

.msg.assistant { position: relative; }
.msg.assistant .body > :first-child { margin-top: 0; }
.msg.assistant .body > :last-child { margin-bottom: 0; }
.msg.assistant p { margin: 0 0 10px; }
.msg.assistant :is(h1,h2,h3,h4) { font-size: 14px; margin: 16px 0 8px; color: var(--text); }
.msg.assistant h1::before { content: "# "; color: var(--accent); }
.msg.assistant h2::before { content: "## "; color: var(--accent); }
.msg.assistant h3::before, .msg.assistant h4::before { content: "### "; color: var(--accent); }
.msg.assistant ul, .msg.assistant ol { padding-left: 22px; margin: 0 0 10px; }
.msg.assistant strong { color: #fff; }
.msg.assistant blockquote { margin: 0 0 10px; padding-left: 12px; border-left: 2px solid var(--line); color: var(--dim); }
.msg.assistant :not(pre) > code { color: var(--warn); background: var(--raised); padding: 1px 5px; border-radius: 4px; }
.msg.assistant pre { position: relative; background: var(--panel); border: 1px solid var(--line); border-radius: 6px; padding: 10px 12px; overflow-x: auto; margin: 0 0 10px; }
.msg.assistant pre code.hljs { background: transparent; padding: 0; }
.msg.assistant table { border-collapse: collapse; display: block; overflow-x: auto; margin: 0 0 10px; font-size: 13px; }
.msg.assistant th, .msg.assistant td { border: 1px solid var(--line); padding: 3px 8px; }
.msg.assistant hr { border: 0; border-top: 1px solid var(--line); }
.copy { position: absolute; top: 6px; right: 6px; font-size: 11px; padding: 1px 7px; opacity: 0; }
pre:hover > .copy, .copy:focus-visible { opacity: .9; }
.msg-actions { margin-top: 4px; opacity: 0; transition: opacity .15s; }
.msg.assistant:hover .msg-actions, .msg-actions:focus-within { opacity: 1; }
.msg-actions .btn { font-size: 11px; padding: 1px 7px; }
.cursor::after { content: "▍"; color: var(--accent); animation: blink 1s steps(2) infinite; }
@keyframes blink { 50% { opacity: 0; } }

.notice { color: var(--dim); font-size: 13px; }
.notice.error { color: var(--err); }
.help { border: 1px solid var(--line); border-radius: 8px; padding: 10px 14px; font-size: 13px; }
.help table { border-collapse: collapse; }
.help td { padding: 1px 14px 1px 0; vertical-align: top; }
.help td:first-child { color: var(--accent); white-space: nowrap; }

/* Outils : ● Nom(argument) puis ⎿ résultat */
.tool { font-size: 13px; }
.tool > .gutter { transition: color .2s; }
.tool.running > .gutter { color: var(--dim); animation: blink 1s steps(2) infinite; }
.tool.ok > .gutter { color: var(--ok); }
.tool.err > .gutter { color: var(--err); }
.tool .head { white-space: pre-wrap; word-break: break-word; }
.tool .tname { font-weight: 700; }
.tool .targ { color: var(--dim); }
.tool .out { display: grid; grid-template-columns: 30px 1fr; color: var(--dim); }
.tool .out > .elbow { user-select: none; color: var(--faint); padding-left: 2px; }
.tool .out pre { margin: 0; white-space: pre-wrap; word-break: break-word; font: inherit; max-height: 480px; overflow: auto; }
.tool .out.error pre { color: var(--err); }
.tool .more { cursor: pointer; color: var(--faint); background: none; border: 0; padding: 0; font: inherit; text-align: left; }
.tool .more:hover { color: var(--text); }
.diff { margin: 2px 0 0; border: 1px solid var(--line); border-radius: 6px; overflow: auto; max-height: 420px; }
.diff div { white-space: pre-wrap; word-break: break-word; padding: 0 8px; }
.diff .add { background: var(--add-bg); color: #b9e8c3; }
.diff .del { background: var(--del-bg); color: #ffc2cc; }
.diff .ctx { color: var(--dim); }
.ask { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; border: 1px solid var(--warn); border-radius: 6px; padding: 8px 10px; margin-top: 6px; color: var(--warn); }

/* Bas d'écran : indicateur, saisie, ligne d'état */
.bottom { padding: 0 14px calc(8px + env(safe-area-inset-bottom)); position: relative; }
.bottom > * { max-width: 900px; margin-left: auto; margin-right: auto; }
.spinner { color: var(--accent); font-size: 13px; padding: 4px 2px 6px; display: flex; gap: 8px; align-items: baseline; }
.spin-glyph { display: inline-block; width: 1ch; }
.composer { border: 1px solid var(--line); border-radius: 8px; background: var(--panel); padding: 4px 6px 4px 10px; }
.composer:focus-within { border-color: var(--dim); }
.input-box { display: flex; gap: 6px; align-items: flex-start; }
.input-box .btn { align-self: flex-end; margin-bottom: 2px; }
.input-box .caret { padding: 6px 0; }
.composer textarea { flex: 1; resize: none; border: 0; outline: none; background: transparent; padding: 6px 0; max-height: 240px; line-height: 1.5; }
.composer textarea::placeholder { color: var(--faint); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; padding: 4px 0 2px; }
.chips:empty { display: none; }
.chip { border: 1px solid var(--line); border-radius: 5px; padding: 1px 4px 1px 8px; font-size: 12px; display: flex; align-items: center; gap: 2px; color: var(--dim); }
.chip.pending { opacity: .6; }
.chip.failed { border-color: var(--err); color: var(--err); }
.chip button { background: none; border: 0; cursor: pointer; color: inherit; padding: 0 4px; }
.statusline { display: flex; justify-content: space-between; gap: 12px; font-size: 11.5px; padding: 5px 2px 0; }
.status-right { display: flex; gap: 6px; white-space: nowrap; }
.status-right .model { color: var(--accent); }
#status:not(:empty)::after { content: " ·"; }

.slash-menu { position: absolute; bottom: calc(100% - 40px); left: 14px; right: 14px; z-index: 7; background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 4px; box-shadow: 0 -8px 30px rgba(0,0,0,.45); font-size: 13px; }
.slash-item { display: grid; grid-template-columns: 170px 1fr; gap: 10px; padding: 4px 8px; border-radius: 5px; cursor: pointer; }
.slash-item .cmd { color: var(--accent); }
.slash-item .desc { color: var(--dim); }
.slash-item.active { background: var(--raised); }

.drop { position: fixed; inset: 0; background: rgba(217,119,87,.12); border: 2px dashed var(--accent); display: flex; align-items: center; justify-content: center; font-size: 16px; z-index: 20; pointer-events: none; color: var(--accent); }

@media (max-width: 760px) {
  body { font-size: 13.5px; }
  .sidebar { position: fixed; inset: 0 auto 0 0; z-index: 10; transform: translateX(-100%); transition: transform .2s; margin-left: 0 !important; }
  .sidebar.open { transform: none; }
  .sidebar.open + .backdrop { display: block; position: fixed; inset: 0; background: rgba(0,0,0,.5); z-index: 9; }
  .brand, .sep { display: none; }
  .log { padding: 12px 10px 6px; }
  .bottom { padding-left: 8px; padding-right: 8px; }
  #hint { display: none; }
  .statusline { justify-content: flex-end; }
  .conv .btn { opacity: .8; }
  .slash-item { grid-template-columns: 120px 1fr; }
  /* 16 px : iOS ne zoome pas sur le champ au moment de la saisie. */
  .composer textarea, .login input { font-size: 16px; }
}
