:root {
  --bg: #0d0f14;
  --panel: #151821;
  --panel-2: #1c202b;
  --line: #2a2f3d;
  --text: #e8eaf0;
  --muted: #8b91a3;
  --accent: #7c5cff;
  --accent-2: #b39dff;
  --ok: #3ecf8e;
  --err: #ff6b6b;
  --radius: 12px;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; margin: 0; }
body { background: var(--bg); color: var(--text); font: 14px/1.5 Inter, system-ui, sans-serif; }
button, input, select, textarea { font: inherit; color: inherit; }

.app { display: grid; grid-template-columns: 380px 1fr; height: 100vh; }

/* ---------- Colonne prompt ---------- */
.side { display: flex; flex-direction: column; border-inline-end: 1px solid var(--line); background: var(--panel); min-height: 0; }
.brand { display: flex; gap: 12px; align-items: center; padding: 18px 20px; border-bottom: 1px solid var(--line); }
.logo { width: 38px; height: 38px; border-radius: 10px; display: grid; place-items: center; font-size: 20px;
  background: linear-gradient(135deg, var(--accent), #ff7ac6); }
.brand h1 { margin: 0; font-size: 17px; }
.brand p { margin: 0; color: var(--muted); font-size: 13px; }

.provider { padding: 14px 20px; border-bottom: 1px solid var(--line); display: grid; gap: 10px; }
.field { display: grid; gap: 4px; }
.field > span { font-size: 12px; color: var(--muted); display: flex; justify-content: space-between; }
.field a { color: var(--accent-2); text-decoration: none; }
.field input, .field select { width: 100%; background: var(--panel-2); border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; outline: none; }
.field input:focus, .field select:focus { border-color: var(--accent); }
.hint { font-size: 12px; color: var(--muted); background: var(--panel-2); border-radius: 8px; padding: 8px 10px; }
.hint b { color: var(--ok); }
.field em { font-style: normal; font-size: 11px; }
.price-inputs { display: flex; gap: 8px; }
.price-inputs label { flex: 1; display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); white-space: nowrap; }
.price-inputs input { min-width: 0; }
.msg .cost { margin-top: 6px; padding-top: 6px; border-top: 1px dashed var(--line); font-size: 11.5px; color: var(--accent-2); }
.total { display: flex; justify-content: space-between; align-items: center; padding: 12px 20px; border-top: 1px solid var(--line); background: var(--panel-2); }
.total span { color: var(--muted); font-size: 12px; }
.total small { margin-inline-start: 6px; opacity: .8; }
.total strong { font-size: 15px; font-variant-numeric: tabular-nums; }
.privacy { margin: 0; font-size: 11px; color: var(--muted); }

.history { flex: 1; overflow-y: auto; padding: 16px 20px; display: flex; flex-direction: column; gap: 10px; min-height: 0; }
.empty p { margin: 0 0 8px; color: var(--muted); font-size: 12px; }
.chip { display: block; width: 100%; text-align: start; margin-bottom: 8px; padding: 10px 12px; border-radius: 10px;
  background: var(--panel-2); border: 1px solid var(--line); cursor: pointer; color: var(--text); }
.chip:hover { border-color: var(--accent); }
.msg { padding: 10px 12px; border-radius: 10px; white-space: pre-wrap; word-break: break-word; }
.msg.user { background: var(--accent); align-self: flex-end; max-width: 90%; }
.msg.ai { background: var(--panel-2); border: 1px solid var(--line); color: var(--muted); font-size: 13px; }
.msg.ai.err { color: var(--err); border-color: #5a2a2a; }
.msg.ai button { background: none; border: 0; color: var(--accent-2); cursor: pointer; padding: 0; margin-inline-start: 6px; }

.composer { padding: 14px 20px 18px; border-top: 1px solid var(--line); }
.style-row { display: flex; gap: 8px; align-items: flex-end; margin-bottom: 10px; }
.style-row .field { flex: 1; min-width: 0; }
.style-row select { width: 100%; background: var(--panel-2); border: 1px solid var(--line); border-radius: 8px; padding: 7px 8px; outline: none; }
.style-row select:focus { border-color: var(--accent); }
.btn.apply { padding: 7px 10px; font-size: 12px; }
.brand-actions { margin-inline-start: auto; display: flex; flex-direction: column; gap: 6px; min-width: 0; }
#accountBtn { max-width: 130px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.privacy a { color: var(--accent-2); }
.lang-select { background: var(--panel-2); border: 1px solid var(--line); border-radius: 9px; padding: 5px 8px; font-size: 12px; color: var(--muted); cursor: pointer; max-width: 130px; }
.lang-select:hover, .lang-select:focus { border-color: var(--accent); color: var(--text); outline: none; }
/* Droite à gauche (arabe, hébreu) : la colonne de saisie passe à droite, le code reste de gauche à droite */
[dir="rtl"] .msg.user { align-self: flex-start; }
[dir="rtl"] .code, [dir="rtl"] #rulesText { direction: ltr; text-align: left; }
[dir="rtl"] .nav button { transform: scaleX(-1); }

.modal { width: min(420px, calc(100vw - 32px)); padding: 28px; border: 1px solid var(--line); border-radius: 16px;
  background: var(--panel); color: var(--text); box-shadow: 0 30px 80px rgba(0,0,0,.5); }
.modal::backdrop { background: rgba(5,6,10,.6); backdrop-filter: blur(3px); }
.modal-close { position: absolute; top: 14px; inset-inline-end: 14px; background: none; border: 0; color: var(--muted); cursor: pointer; font-size: 15px; }
.modal-wide { width: min(760px, calc(100vw - 32px)); }
.modal-title { margin: 0 0 6px; font-size: 18px; }
.modal-intro { margin: 0 0 14px; color: var(--muted); font-size: 13px; }
.modal-intro code { color: var(--accent-2); }
.switch { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; font-size: 13px; cursor: pointer; }
.switch input { accent-color: var(--accent); width: 16px; height: 16px; }
#rulesText { width: 100%; resize: vertical; min-height: 280px; background: var(--bg); border: 1px solid var(--line); border-radius: 10px;
  padding: 12px; color: var(--text); font: 12.5px/1.6 "JetBrains Mono", ui-monospace, monospace; outline: none; }
#rulesText:focus { border-color: var(--accent); }
#rulesText:disabled { opacity: .5; }
.modal-actions { display: flex; align-items: center; gap: 8px; margin-top: 12px; }
.rules-info { flex: 1; font-size: 12px; color: var(--muted); }
.rules-chip { display: inline-flex; align-items: center; gap: 6px; margin-bottom: 10px; padding: 5px 10px; border-radius: 99px; cursor: pointer;
  background: var(--panel-2); border: 1px solid var(--line); color: var(--muted); font-size: 12px; }
.rules-chip:hover { border-color: var(--accent); color: var(--text); }
.rules-chip.on { border-color: rgba(62,207,142,.4); color: var(--ok); }
.domain-row { display: flex; gap: 8px; }
.domain-row input { flex: 1; }
.domain-info { margin: -4px 0 0; font-size: 13px; }
.domain-info.ok { color: var(--ok); }
.domain-info.ko { color: var(--err); }
.price-box { display: grid; gap: 6px; padding: 12px 14px; border-radius: 10px; background: var(--bg); border: 1px solid var(--line); font-size: 13px; }
.price-box > div { display: flex; justify-content: space-between; gap: 10px; }
.price-box span { color: var(--muted); }
.price-box .total-line { padding-top: 6px; border-top: 1px dashed var(--line); font-size: 15px; }
.price-box .total-line span { color: var(--text); }
.auth { display: grid; gap: 12px; }
.auth .field input { padding: 10px 12px; }
.tabs { display: flex; background: var(--bg); border-radius: 10px; padding: 3px; }
.tabs button { flex: 1; background: none; border: 0; color: var(--muted); padding: 8px; border-radius: 8px; cursor: pointer; font-weight: 600; }
.tabs button.on { background: var(--panel-2); color: var(--text); }
.auth-intro { margin: 0; color: var(--muted); font-size: 13px; }
.auth-error { margin: 0; color: var(--err); font-size: 13px; }
.account-head { display: flex; gap: 12px; align-items: center; margin-bottom: 18px; }
.account-head p { margin: 2px 0 0; color: var(--muted); font-size: 12px; }
.avatar { width: 42px; height: 42px; border-radius: 50%; display: grid; place-items: center; font-weight: 700; font-size: 18px;
  background: linear-gradient(135deg, var(--accent), #ff7ac6); }
.account h3 { font-size: 13px; color: var(--muted); font-weight: 600; margin: 0 0 8px; }
.my-sites { list-style: none; margin: 0 0 18px; padding: 0; max-height: 280px; overflow-y: auto; display: grid; gap: 6px; }
.my-sites button { width: 100%; display: flex; justify-content: space-between; gap: 10px; align-items: center; text-align: start;
  background: var(--panel-2); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; cursor: pointer; color: var(--text); }
.my-sites button:hover { border-color: var(--accent); }
.my-sites small { color: var(--muted); white-space: nowrap; }
.my-sites .empty-sites { color: var(--muted); font-size: 13px; }
.btn.new { margin-inline-start: auto; padding: 6px 10px; font-size: 12px; font-weight: 500; }
.btn.publish { padding: 6px 14px; font-size: 13px; white-space: nowrap; }
.icon.locked { opacity: .45; }
.badge { font-size: 11px; padding: 1px 8px; border-radius: 99px; font-weight: 600; }
.badge.private { background: #3a2f12; color: #f5c451; }
.badge.live { background: #12382a; color: var(--ok); }
.code-view { position: absolute; inset: 0; }
.code-lock { position: absolute; inset: 0; display: grid; place-items: center; text-align: center; padding: 24px;
  background: rgba(11,13,18,.92); backdrop-filter: blur(4px); }
.code-lock .big { font-size: 36px; }
.code-lock h3 { margin: 8px 0 6px; }
.code-lock p { color: var(--muted); margin: 0 0 16px; }
.composer textarea { width: 100%; resize: none; background: var(--panel-2); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px; outline: none; }
.composer textarea:focus { border-color: var(--accent); }
.composer-bar { display: flex; align-items: center; gap: 8px; margin-top: 10px; }
.status { flex: 1; font-size: 12px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.btn { border: 0; border-radius: 9px; padding: 9px 16px; cursor: pointer; font-weight: 600; }
.btn.primary { background: var(--accent); color: #fff; }
.btn.primary:disabled { opacity: .5; cursor: wait; }
.btn.ghost { background: var(--panel-2); border: 1px solid var(--line); }

/* ---------- Navigateur ---------- */
.browser { display: flex; flex-direction: column; padding: 16px; min-width: 0; min-height: 0; }
.chrome { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; padding: 10px 14px; background: var(--panel-2);
  border: 1px solid var(--line); border-bottom: 0; border-radius: var(--radius) var(--radius) 0 0; }
.dots { display: flex; gap: 6px; }
.dots i { width: 12px; height: 12px; border-radius: 50%; background: #ff5f57; }
.dots i:nth-child(2) { background: #febc2e; }
.dots i:nth-child(3) { background: #28c840; }
.nav { display: flex; gap: 2px; }
.nav button, .icon { background: none; border: 0; color: var(--muted); cursor: pointer; padding: 4px 7px; border-radius: 6px; font-size: 15px; }
.nav button:hover:not(:disabled), .icon:hover { background: var(--line); color: var(--text); }
.nav button:disabled { opacity: .35; cursor: default; }
.address { flex: 1 1 200px; min-width: 0; overflow: hidden; white-space: nowrap; display: flex; align-items: center; gap: 8px; background: var(--bg);
  border-radius: 8px; padding: 6px 12px; color: var(--muted); font-size: 13px; }
.lock { font-size: 11px; }
.ver { margin-inline-start: auto; font-size: 11px; color: var(--accent-2); }
.tools { display: flex; align-items: center; gap: 8px; }
.seg { display: flex; background: var(--bg); border-radius: 8px; padding: 2px; }
.seg button { background: none; border: 0; color: var(--muted); padding: 4px 10px; border-radius: 6px; cursor: pointer; font-size: 12px; }
.seg button.on { background: var(--line); color: var(--text); }

.viewport { position: relative; flex: 1; min-height: 0; background: #e9ebf0; border: 1px solid var(--line);
  border-radius: 0 0 var(--radius) var(--radius); overflow: hidden; display: flex; justify-content: center; }
.frame-wrap { width: 100%; height: 100%; transition: width .25s ease; background: #fff; }
.frame-wrap.device { box-shadow: 0 0 0 1px #c9ccd5, 0 10px 40px rgba(0,0,0,.15); }
.frame-wrap { position: relative; }
.draft { --blur: 18px; --scale: 1.04; position: absolute; inset: 0; z-index: 2; overflow: hidden;
  background: linear-gradient(135deg, #f4f1ff, #fff 55%, #fdf0f7); transition: opacity .7s ease; }
.draft.done { opacity: 0; pointer-events: none; }
.draft .buf { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; background: transparent; pointer-events: none;
  opacity: 0; filter: blur(var(--blur)) saturate(1.1); transform: scale(var(--scale));
  transition: opacity .6s ease, filter 1.6s ease, transform 1.6s ease; }
.draft .buf.on { opacity: 1; }
.build-label { position: absolute; left: 50%; bottom: 28px; transform: translateX(-50%); display: flex; align-items: center; gap: 10px;
  padding: 10px 18px; border-radius: 99px; background: rgba(13,15,20,.78); color: #fff; font-size: 13px; font-weight: 500;
  backdrop-filter: blur(6px); box-shadow: 0 8px 30px rgba(0,0,0,.18); white-space: nowrap; transition: opacity .4s; }
.draft.sharp .build-label { opacity: 0; }
.spinner { width: 14px; height: 14px; border-radius: 50%; border: 2px solid rgba(255,255,255,.3); border-top-color: #fff; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
#frame { width: 100%; height: 100%; border: 0; display: block; background: #fff; }
.code { position: absolute; inset: 0; margin: 0; padding: 18px; overflow: auto; background: #0b0d12; color: #c9d1e4;
  font: 12.5px/1.6 "JetBrains Mono", ui-monospace, monospace; white-space: pre-wrap; word-break: break-all; }
.progress { position: absolute; left: 0; right: 0; top: 0; height: 3px; overflow: hidden; background: rgba(124,92,255,.2); }
.progress::after { content: ""; position: absolute; inset: 0; width: 40%; background: var(--accent); animation: slide 1.1s infinite ease-in-out; }
@keyframes slide { from { transform: translateX(-100%); } to { transform: translateX(250%); } }

.welcome { font-family: Inter, sans-serif; }

@media (max-width: 900px) {
  .app { grid-template-columns: 1fr; grid-template-rows: auto 70vh; height: auto; }
  .side { border-inline-end: 0; border-bottom: 1px solid var(--line); }
  .history { max-height: 240px; }
  .browser { padding: 8px; }
  .address, #devices { display: none; }
}
