:root {
  --bg: #101215;
  --panel: rgba(20, 22, 26, 0.82);
  --line: rgba(255, 255, 255, 0.08);
  --text: #e8eaed;
  --muted: #8b9199;
  --ok: #6ee7b7;
  --run: #ffd166;
  --radius: 12px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, system-ui, sans-serif;
  overflow: hidden;
}

#app { position: relative; width: 100%; height: 100%; }

#viewport { position: absolute; inset: 0; }
#viewport canvas { display: block; width: 100%; height: 100%; touch-action: none; }

#panel {
  position: absolute;
  top: 16px;
  left: 16px;
  bottom: 56px;
  width: clamp(270px, 24vw, 340px);
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 16px;
  background: var(--panel);
  backdrop-filter: blur(14px);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow-y: auto;
  transition: transform 0.3s ease, opacity 0.3s ease;
}
body.panel-hidden #panel { transform: translateX(calc(-100% - 24px)); opacity: 0; pointer-events: none; }

#toggle-panel {
  position: absolute;
  top: 16px;
  left: calc(16px + clamp(270px, 24vw, 340px) + 10px);
  z-index: 2;
  transition: left 0.3s ease;
}
body.panel-hidden #toggle-panel { left: 16px; }

.brand { display: flex; align-items: center; gap: 12px; }
.brand strong { display: block; font-size: 15px; letter-spacing: 0.04em; }
.brand small { color: var(--muted); font-size: 12px; }
.brand .dot { width: 10px; height: 10px; border-radius: 50%; background: var(--ok); box-shadow: 0 0 10px var(--ok); flex: none; }

section { display: flex; flex-direction: column; gap: 8px; }
section.grow { flex: 1; min-height: 80px; }
section[hidden] { display: none; }
h2 { margin: 0; font-size: 11px; font-weight: 600; letter-spacing: 0.12em; text-transform: uppercase; color: var(--muted); }

button {
  font: inherit;
  color: var(--text);
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--line);
  border-radius: 9px;
  padding: 8px 10px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  transition: background 0.15s, border-color 0.15s;
}
button:hover:not(:disabled) { background: rgba(255, 255, 255, 0.1); }
button:disabled { opacity: 0.45; cursor: default; }
button svg { width: 16px; height: 16px; flex: none; }

#tools { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.tool { font-size: 13px; justify-content: flex-start; position: relative; }
.tool::before { content: ""; width: 4px; height: 16px; border-radius: 2px; background: var(--c); flex: none; }
.tool svg { color: var(--muted); }
.tool.active { border-color: var(--c); background: color-mix(in srgb, var(--c) 18%, transparent); }
.tool.active svg { color: var(--text); }

textarea {
  width: 100%;
  resize: vertical;
  font: inherit;
  font-size: 13px;
  color: var(--text);
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid var(--line);
  border-radius: 9px;
  padding: 10px;
}
textarea:focus { outline: none; border-color: rgba(255, 255, 255, 0.25); }

#suggestions { display: flex; flex-direction: column; gap: 4px; }
#suggestions button { font-size: 12px; color: var(--muted); text-align: left; padding: 6px 8px; background: transparent; }
#suggestions button:hover { color: var(--text); }

.row { display: flex; gap: 6px; }
.primary { flex: 1; justify-content: center; background: var(--text); color: #111; border-color: var(--text); font-weight: 600; }
.primary:hover:not(:disabled) { background: #fff; }
.ghost { background: transparent; }

#steps { margin: 0; padding-left: 0; list-style: none; display: flex; flex-direction: column; gap: 4px; counter-reset: s; }
#steps li { font-size: 12.5px; color: var(--muted); display: flex; gap: 8px; align-items: baseline; counter-increment: s; }
#steps li::before { content: counter(s); font-family: "JetBrains Mono", monospace; font-size: 11px; width: 18px; height: 18px; border-radius: 50%; border: 1px solid var(--line); display: inline-grid; place-items: center; flex: none; }
#steps li.run { color: var(--run); }
#steps li.run::before { border-color: var(--run); }
#steps li.done { color: var(--ok); }
#steps li.done::before { background: var(--ok); color: #111; border-color: var(--ok); }

#log { margin: 0; padding: 0; list-style: none; font-size: 12px; color: var(--muted); display: flex; flex-direction: column; gap: 4px; overflow-y: auto; }
#log li:first-child { color: var(--text); }
#log .t { font-family: "JetBrains Mono", monospace; font-size: 11px; opacity: 0.6; margin-right: 8px; }

.speed { display: flex; align-items: center; gap: 10px; font-size: 12px; color: var(--muted); }
.speed input { flex: 1; accent-color: var(--text); }
#speed-val { font-family: "JetBrains Mono", monospace; width: 34px; text-align: right; }

#tel {
  position: absolute;
  left: 16px;
  right: 16px;
  bottom: 12px;
  font-family: "JetBrains Mono", monospace;
  font-size: 12px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  pointer-events: none;
}

/* Mobile : panneau en bas */
@media (max-width: 720px) {
  #panel {
    top: auto;
    left: 8px;
    right: 8px;
    bottom: 36px;
    width: auto;
    max-height: 48%;
    gap: 10px;
    padding: 12px;
  }
  body.panel-hidden #panel { transform: translateY(calc(100% + 40px)); }
  #toggle-panel, body.panel-hidden #toggle-panel { left: auto; right: 12px; top: 12px; }
  section.grow, #suggestions { display: none; }
  #tools { grid-template-columns: 1fr 1fr 1fr; }
  .tool span { font-size: 11px; }
  #tel { font-size: 10px; left: 8px; bottom: 10px; }
}

#panel, #log { scrollbar-width: thin; scrollbar-color: rgba(255, 255, 255, 0.15) transparent; }
