/* ============================================================
   Blueprint — Simulateur mobile / tablette
   Ambiance sombre + accent rouge (palette 17), même tokens que console.css
   ============================================================ */

:root {
  --bg: #0c0c0d;
  --bg-2: #15161a;
  --surface: #1a1b1f;
  --surface-2: #1c1d22;
  --border: #26272c;
  --border-strong: #3a3b41;
  --text: #e6e6e6;
  --text-muted: #8a8e98;
  --text-faint: #5d6068;
  --accent: #ef4444;
  --accent-hover: #dc2626;
  --accent-fg: #fff;
  --accent-bg: rgba(239,68,68,.12);
  --accent-border: rgba(239,68,68,.35);
  --radius: 12px;
  --radius-sm: 9px;
}

* { box-sizing: border-box; }
html, body {
  margin: 0; padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: 'Hanken Grotesk', system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
  height: 100%;
  overflow: hidden;
}
a { color: inherit; }
button { font: inherit; cursor: pointer; }

/* ============================================================
   Top bar
   ============================================================ */
.topbar {
  height: 56px;
  display: flex; align-items: center; gap: 18px;
  padding: 0 18px;
  background: rgba(12,12,13,.85);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
  position: relative; z-index: 10;
}
.brand {
  display: flex; align-items: center; gap: 10px;
  font-weight: 700; letter-spacing: -.01em;
}
.brand .dot {
  width: 10px; height: 10px; border-radius: 3px;
  background: var(--accent);
  box-shadow: 0 0 0 3px rgba(239,68,68,.18);
}
.brand .sub {
  font-weight: 500;
  color: var(--text-muted);
  font-size: 13px;
  margin-left: 4px;
}

.device-switch {
  margin-left: auto;
  display: inline-flex; gap: 2px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 11px;
  padding: 3px;
}
.device-switch button {
  background: transparent; border: 0;
  color: var(--text-muted);
  padding: 6px 14px; border-radius: 8px;
  font-weight: 600; font-size: 13px;
  display: inline-flex; align-items: center; gap: 7px;
}
.device-switch button:hover { color: var(--text); }
.device-switch button.active {
  background: var(--accent);
  color: #fff;
}
.device-switch svg { width: 15px; height: 15px; }

.zoom-ctrl {
  display: inline-flex; align-items: center; gap: 8px;
  font-size: 12.5px; color: var(--text-muted);
}
.zoom-ctrl input[type=range] {
  accent-color: var(--accent);
  width: 110px;
}
.zoom-ctrl .val {
  font-family: 'JetBrains Mono', monospace;
  font-size: 11.5px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 2px 6px;
  min-width: 42px;
  text-align: center;
  color: var(--text);
}

/* ============================================================
   Layout principal : panneau source + scène (device frame)
   ============================================================ */
.lab {
  display: grid;
  grid-template-columns: 380px 1fr;
  height: calc(100vh - 56px);
  overflow: hidden;
}

.source-panel {
  background: var(--bg-2);
  border-right: 1px solid var(--border);
  overflow-y: auto;
  padding: 18px 18px 30px;
}
.source-panel::-webkit-scrollbar { width: 10px; }
.source-panel::-webkit-scrollbar-track { background: transparent; }
.source-panel::-webkit-scrollbar-thumb {
  background: #2a2b30; border-radius: 5px;
  border: 2px solid var(--bg-2);
}

.source-panel h2 {
  margin: 4px 2px 6px;
  font-size: 11px; font-weight: 700;
  letter-spacing: .14em; text-transform: uppercase;
  color: var(--text-muted);
}
.source-panel .lead {
  color: var(--text-muted);
  font-size: 12.5px; line-height: 1.55;
  margin: 0 2px 16px;
}

.dropzone {
  position: relative;
  background: var(--surface);
  border: 2px dashed #3a3b41;
  border-radius: var(--radius);
  padding: 22px 16px;
  text-align: center;
  cursor: pointer;
  transition: border-color .15s ease, background .15s ease;
  margin-bottom: 6px;
}
.dropzone:hover,
.dropzone.drag {
  border-color: var(--accent);
  background: var(--accent-bg);
}
.dropzone .ico {
  width: 42px; height: 42px;
  margin: 0 auto 10px;
  border-radius: 12px;
  background: rgba(239,68,68,.12);
  color: var(--accent);
  display: grid; place-items: center;
}
.dropzone p {
  margin: 0;
  color: var(--text);
  font-size: 13.5px; font-weight: 500;
}
.dropzone .hint {
  color: var(--text-muted);
  font-size: 11.5px; font-weight: 400;
  margin-top: 5px;
}
.dropzone input[type=file] {
  position: absolute; inset: 0;
  opacity: 0; cursor: pointer;
}

.files-summary {
  display: flex; flex-wrap: wrap; gap: 5px;
  margin: 10px 0 14px;
}
.files-summary .chip-f {
  display: inline-flex; align-items: center; gap: 5px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text-muted);
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 11.5px;
}
.files-summary .chip-f b { color: var(--accent); }

.separator {
  text-align: center;
  color: var(--text-faint);
  font-size: 11.5px;
  letter-spacing: .04em;
  margin: 16px 0 10px;
  position: relative;
}
.separator::before,
.separator::after {
  content: "";
  display: inline-block;
  width: 60px; height: 1px;
  background: var(--border);
  vertical-align: middle;
  margin: 0 10px;
}

.code-block {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 8px;
  overflow: hidden;
}
.code-block summary {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 14px;
  cursor: pointer;
  font-weight: 600; font-size: 13px;
  list-style: none;
}
.code-block summary::-webkit-details-marker { display: none; }
.code-block summary .lang {
  font-family: 'JetBrains Mono', monospace;
  font-size: 10.5px;
  padding: 2px 7px; border-radius: 5px;
  background: var(--surface-2);
  color: var(--text-muted);
  letter-spacing: .04em;
}
.code-block summary .status {
  margin-left: auto;
  font-weight: 400;
  color: var(--text-faint);
  font-size: 11.5px;
}
.code-block summary .status.filled { color: var(--accent); font-weight: 500; }
.code-block summary .chev {
  width: 14px; height: 14px;
  color: var(--text-muted);
  transition: transform .2s;
}
.code-block[open] summary .chev { transform: rotate(180deg); }

.code-block textarea {
  width: 100%;
  background: #0c0c0d;
  border: 0;
  border-top: 1px solid var(--border);
  color: var(--text);
  padding: 12px 14px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 12px; line-height: 1.55;
  resize: vertical;
  min-height: 140px; max-height: 380px;
  outline: none;
  display: block;
}
.code-block textarea::placeholder { color: var(--text-faint); }

.actions {
  position: sticky; bottom: 0;
  background: linear-gradient(180deg, transparent 0, var(--bg-2) 18px);
  padding: 18px 0 0;
  display: flex; gap: 8px;
  margin-top: 14px;
}
.btn {
  flex: 1;
  background: var(--accent);
  color: #fff; border: 0;
  border-radius: var(--radius-sm);
  padding: 11px 14px;
  font-weight: 600; font-size: 13.5px;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
}
.btn:hover { background: var(--accent-hover); }
.btn.ghost {
  background: transparent;
  color: var(--text);
  border: 1px solid var(--border-strong);
  flex: 0 0 110px;
}
.btn.ghost:hover { border-color: var(--accent); color: var(--accent); }
.btn svg { width: 16px; height: 16px; }

.toolbox {
  display: flex; gap: 10px;
  margin-top: 18px;
  padding-top: 14px;
  border-top: 1px dashed var(--border);
}
.toolbox label {
  display: flex; align-items: center; gap: 8px;
  font-size: 12.5px; color: var(--text-muted);
  user-select: none; cursor: pointer;
}
.toolbox label input[type=checkbox] {
  accent-color: var(--accent);
  width: 16px; height: 16px;
}

.console-out {
  margin-top: 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0;
  font-family: 'JetBrains Mono', monospace;
  font-size: 11.5px;
  max-height: 160px;
  overflow: auto;
}
.console-out .head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
  font-family: 'Hanken Grotesk', sans-serif;
  font-size: 11px; letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--text-muted);
  font-weight: 700;
  position: sticky; top: 0;
  background: var(--surface);
}
.console-out .head button {
  background: transparent; border: 0;
  color: var(--text-muted);
  font-size: 11px;
  text-transform: none; letter-spacing: 0;
  font-family: inherit;
}
.console-out .head button:hover { color: var(--accent); }
.console-out .body { padding: 8px 12px; }
.console-out .row { color: var(--text-muted); line-height: 1.5; padding: 2px 0; word-break: break-word; }
.console-out .row.err { color: #f87171; }
.console-out .row.warn { color: #f59e0b; }
.console-out .row.log { color: var(--text); }
.console-out .empty { color: var(--text-faint); font-style: italic; padding: 4px 0; }

/* ============================================================
   Scène : device frame centré
   ============================================================ */
.stage {
  position: relative;
  background:
    radial-gradient(ellipse at top, rgba(239,68,68,.04) 0%, transparent 60%),
    var(--bg);
  display: grid; place-items: center;
  overflow: auto;
  padding: 30px;
}
.stage::-webkit-scrollbar { width: 10px; height: 10px; }
.stage::-webkit-scrollbar-thumb { background: #2a2b30; border-radius: 5px; }

.device-wrap {
  transform-origin: center center;
  transition: transform .25s ease;
}

/* Phone */
.device {
  --d-w: 390px;
  --d-h: 760px;
  --d-radius: 44px;
  --d-bezel: 12px;
  --d-bezel-color: #0a0a0b;
  --d-inner-radius: 34px;

  width: var(--d-w);
  height: var(--d-h);
  border-radius: var(--d-radius);
  background: var(--d-bezel-color);
  border: 1px solid #2a2b30;
  padding: var(--d-bezel);
  box-shadow:
    0 0 0 10px #1a1b1f,
    0 30px 80px rgba(0,0,0,.55),
    0 8px 24px rgba(0,0,0,.4);
  position: relative;
  transition: width .35s cubic-bezier(.2,.7,.2,1),
              height .35s cubic-bezier(.2,.7,.2,1),
              border-radius .35s cubic-bezier(.2,.7,.2,1);
}
.device::before {
  /* dynamic island / encoche */
  content: "";
  position: absolute;
  top: 22px; left: 50%; transform: translateX(-50%);
  width: 110px; height: 28px;
  background: #000;
  border-radius: 18px;
  z-index: 30;
  pointer-events: none;
  transition: width .35s, height .35s, top .35s;
}

.device.tablet {
  --d-w: 820px;
  --d-h: 1100px;
  --d-radius: 32px;
  --d-bezel: 16px;
  --d-inner-radius: 18px;
}
.device.tablet::before {
  /* tablette : pas d'encoche, juste une caméra latérale */
  width: 8px; height: 8px;
  top: 50%;
  left: auto; right: 8px;
  transform: translateY(-50%);
  border-radius: 50%;
  background: #1f2026;
  box-shadow: inset 0 0 0 1px #0a0a0b;
}

.device-inner {
  width: 100%; height: 100%;
  background: #fff;
  border-radius: var(--d-inner-radius);
  overflow: hidden;
  position: relative;
  isolation: isolate;
}
.device-inner iframe {
  width: 100%; height: 100%;
  border: 0; display: block;
  background: #fff;
}

/* footer info de la scène */
.stage-info {
  position: absolute;
  bottom: 14px; left: 18px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  color: var(--text-faint);
  letter-spacing: .04em;
  pointer-events: none;
}
.stage-info b { color: var(--text-muted); }

/* État vide / placeholder dans l'iframe (fourni via srcdoc initial) */

/* ============================================================
   Responsive : panneau collapse
   ============================================================ */
.toggle-panel {
  display: none;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  color: var(--text);
  padding: 6px 10px;
  border-radius: 8px;
  font-size: 12.5px;
}

@media (max-width: 900px) {
  .lab {
    grid-template-columns: 1fr;
    grid-template-rows: auto 1fr;
  }
  .source-panel {
    max-height: 45vh;
    border-right: 0;
    border-bottom: 1px solid var(--border);
  }
  .topbar { padding: 0 12px; gap: 10px; }
  .zoom-ctrl input[type=range] { width: 80px; }
  .device-switch button .lbl { display: none; }
}
