* { box-sizing: border-box; margin: 0; padding: 0; }
:root {
  --bg: #0a0a0a; --card: #0f0f0f; --elevated: #141414;
  --hover: rgba(38,38,38,0.7);
  --border: rgba(38,38,38,0.9); --border-hover: rgba(82,82,82,0.8);
  --text: #fafafa; --text-1: #fafafa; --text-2: #a3a3a3; --text-3: #737373;
  --cyan: #06b6d4; --cyan-h: #22d3ee; --cyan-bg: rgba(6,182,212,0.08); --cyan-b: rgba(6,182,212,0.22);
  --green: #4ade80; --green-bg: rgba(74,222,128,0.08); --green-b: rgba(74,222,128,0.18);
  --orange: #fb923c; --orange-bg: rgba(251,146,60,0.08); --orange-b: rgba(251,146,60,0.18);
  --red: #f87171; --red-bg: rgba(248,113,113,0.08); --red-b: rgba(248,113,113,0.18);
  --blue: #60a5fa; --blue-bg: rgba(96,165,250,0.08); --blue-b: rgba(96,165,250,0.18);
  --amber: #fbbf24; --amber-bg: rgba(251,191,36,0.1); --amber-b: rgba(251,191,36,0.22);
  --font: 'Inter', -apple-system, 'Segoe UI', system-ui, sans-serif;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-left: env(safe-area-inset-left, 0px);
  --safe-right: env(safe-area-inset-right, 0px);
}

/* ── Base ── */
html {
  height: 100%;
  overflow: hidden;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}
body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
  height: 100%;
  height: 100dvh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  user-select: none;
  -webkit-user-select: none;
  -ms-user-select: none;
  overscroll-behavior: none;
  -webkit-tap-highlight-color: transparent;
}
body::before {
  content: '';
  position: fixed;
  inset: 0;
  background: radial-gradient(ellipse 80% 50% at 50% -10%, rgba(120,119,198,0.13), transparent);
  pointer-events: none;
  z-index: 0;
}
body > * { position: relative; z-index: 1; }
input, textarea, select {
  user-select: auto;
  -webkit-user-select: auto;
  -ms-user-select: text;
  touch-action: manipulation;
  cursor: text;
  -webkit-touch-callout: default;
}

/* ── Header ── */
.header {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 14px;
  padding: calc(12px + var(--safe-top)) 20px 12px;
  border-bottom: 1px solid var(--border);
  background: rgba(10,10,10,0.85);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  flex-shrink: 0;
}
.logo { display:flex; align-items:center; gap:12px; }
.logo-icon { width:36px; height:36px; background:transparent; border:none; border-radius:10px; display:flex; align-items:center; justify-content:center; }
.logo-icon svg { width:24px; height:24px; }
.logo-text { font-size:13px; font-weight:600; letter-spacing:.18em; text-transform:uppercase; }
.header-center { display:flex; justify-content:center; justify-self:center; }
.header-actions { display:flex; align-items:center; gap:8px; justify-self:end; }

/* ── Status pill ── */
.status-pill { display:flex; align-items:center; justify-content:center; gap:7px; min-width:130px; border-radius:8px; padding:6px 12px; font-size:12px; font-weight:600; border:1px solid; letter-spacing:.01em; }
.status-pill.running { background:var(--green-bg); border-color:var(--green-b); color:var(--green); }
.status-pill.stopped { background:var(--red-bg); border-color:var(--red-b); color:var(--red); }
.status-pill.connecting { background:var(--blue-bg); border-color:var(--blue-b); color:var(--blue); }
.dot { width:7px; height:7px; border-radius:50%; background:currentColor; }
.status-pill.running .dot { width:10px; height:10px; background:transparent; border:2px solid currentColor; border-right-color:transparent; animation:spin .8s linear infinite; }
.status-pill.connecting .dot { animation:pulse 2s infinite; }
.status-pill.stopped .dot { animation:none; opacity:.95; }
@keyframes pulse{0%,100%{opacity:1}50%{opacity:.4}}

/* ── Tabs ── */
.tabs { display:inline-flex; align-items:center; gap:3px; padding:4px; background:rgba(15,15,15,0.8); border:1px solid var(--border); border-radius:99px; box-shadow:inset 0 1px 0 rgba(255,255,255,.02); }
.tab { padding:6px 16px; font-size:11px; font-weight:600; color:var(--text-3); cursor:pointer; border:1px solid transparent; border-radius:99px; transition:all .2s; display:flex; align-items:center; gap:5px; letter-spacing:.02em; touch-action:manipulation; }
.tab:hover { color:var(--text-2); background:rgba(255,255,255,.03); }
.tab.active { color:var(--text); background:rgba(38,38,38,0.8); border-color:rgba(82,82,82,0.5); box-shadow:0 1px 4px rgba(0,0,0,.4); }
.tab-icon-only { min-width:32px; padding:6px 10px; justify-content:center; }
.lucide-icon { width:14px; height:14px; stroke:currentColor; stroke-width:2; fill:none; stroke-linecap:round; stroke-linejoin:round; vertical-align:middle; flex-shrink:0; }
.lucide-icon.lg { width:16px; height:16px; }
.icon-solid { fill:currentColor; stroke:none; }

/* ── Content (scroll principal) ── */
.content {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-y: contain;
  padding: 20px;
  padding-bottom: calc(90px + var(--safe-bottom));
  padding-left: calc(20px + var(--safe-left));
  padding-right: calc(20px + var(--safe-right));
  scrollbar-width: none;
  max-width: 1500px;
  width: 100%;
  margin: 0 auto;
}
.content::-webkit-scrollbar { display:none; }

/* ── Cards ── */
.card { background:rgba(15,15,15,0.6); border:1px solid rgba(38,38,38,0.8); border-radius:14px; padding:16px; transition:border-color .2s, transform .2s, box-shadow .2s; backdrop-filter:blur(4px); }
.card:hover { border-color:rgba(82,82,82,0.6); transform:translateY(-2px); box-shadow:0 8px 32px -8px rgba(0,0,0,0.8); }
.card-sm { padding:12px; }

/* ── Grids ── */
.grid-4 { display:grid; grid-template-columns:repeat(4,minmax(0,1fr)); gap:14px; }
.grid-2 { display:grid; grid-template-columns:1fr 1fr; gap:14px; }
.grid-3 { display:grid; grid-template-columns:repeat(3,minmax(0,1fr)); gap:14px; }
.stack-col { display:flex; flex-direction:column; gap:12px; }

/* ── Metrics ── */
.metric { display:flex; flex-direction:column; gap:4px; }
.metric-label { font-size:10px; color:var(--text-3); font-weight:600; text-transform:uppercase; letter-spacing:.18em; }
.metric-value { font-size:24px; font-weight:600; line-height:1; }
.metric-sub   { font-size:11px; color:var(--text-3); }

/* ── Settings summary ── */
.settings-summary-grid { display:grid; grid-template-columns:repeat(auto-fit, minmax(170px, 1fr)); gap:8px; }
.settings-summary-item { background:rgba(20,20,20,0.7); border:1px solid var(--border); border-radius:10px; padding:8px 10px; min-height:52px; }
.settings-summary-k { font-size:10px; text-transform:uppercase; letter-spacing:.05em; color:var(--text-3); margin-bottom:4px; }
.settings-summary-v { font-size:12px; color:var(--text-2); font-weight:600; line-height:1.35; word-break:break-word; }

/* ── Settings cards ── */
.settings-cards-row { display:grid; grid-template-columns:1fr 1fr; gap:14px; align-items:start; }


/* ── Section ── */
.section-title { font-size:10px; font-weight:600; color:var(--text-3); text-transform:uppercase; letter-spacing:.2em; margin-bottom:12px; }
.section-hdr { display:flex; align-items:center; justify-content:space-between; gap:10px; flex-wrap:wrap; margin-bottom:12px; }

/* ── Progress ── */
.progress-track { height:6px; background:var(--elevated); border-radius:3px; overflow:hidden; }
.progress-fill  { height:100%; background:var(--cyan); border-radius:3px; transition:width .4s ease; position:relative; overflow:hidden; }
.progress-fill::after { content:''; position:absolute; top:0; left:-100%; width:100%; height:100%; background:linear-gradient(90deg,transparent,rgba(255,255,255,.3),transparent); animation:shimmer 2s infinite; }
@keyframes shimmer{to{left:100%}}

/* ── Buttons ── */
.btn { display:inline-flex; align-items:center; gap:6px; font-size:12px; font-weight:500; border-radius:99px; border:none; cursor:pointer; transition:all .2s; font-family:var(--font); touch-action:manipulation; -webkit-tap-highlight-color:transparent; }
.btn:disabled { opacity:.45; cursor:not-allowed; }
.control-buttons { display:flex; align-items:center; gap:8px; }
.btn-control { min-width:108px; justify-content:center; padding:8px 18px; height:34px; font-weight:600; letter-spacing:.01em; }
.btn-primary   { background:#f5f5f5; color:#0a0a0a; padding:7px 18px; height:32px; font-weight:600; }
.btn-primary:hover { background:#ffffff; box-shadow:0 4px 16px rgba(0,0,0,0.5); }
.btn-danger    { background:var(--red-bg); color:var(--red); border:1px solid var(--red-b); padding:7px 16px; height:32px; }
.btn-danger:hover { background:rgba(248,113,113,.18); box-shadow:0 4px 16px rgba(0,0,0,0.4); }
.btn-secondary { background:rgba(38,38,38,0.7); color:var(--text-2); border:1px solid var(--border); padding:7px 14px; height:32px; }
.btn-secondary:hover { background:rgba(52,52,52,0.8); color:var(--text); border-color:var(--border-hover); }
.btn-ghost     { background:transparent; color:var(--text-3); padding:5px 10px; height:28px; }
.btn-ghost:hover { background:var(--hover); color:var(--text-2); }
.btn-mini { height:24px; padding:4px 10px; font-size:10px; border-radius:99px; }
.btn-mini.active { background:rgba(38,38,38,0.8); color:var(--text); border:1px solid var(--border-hover); }

/* ── Badges ── */
.badge { display:inline-flex; align-items:center; gap:4px; border-radius:99px; font-size:10px; font-weight:600; padding:2px 9px; border:1px solid; letter-spacing:.02em; }
.badge-green  { color:var(--green);  background:var(--green-bg);  border-color:var(--green-b); }
.badge-orange { color:var(--orange); background:var(--orange-bg); border-color:var(--orange-b); }
.badge-red    { color:var(--red);    background:var(--red-bg);    border-color:var(--red-b); }
.badge-blue   { color:var(--blue);   background:var(--blue-bg);   border-color:var(--blue-b); }
.badge-cyan   { color:var(--cyan);   background:var(--cyan-bg);   border-color:var(--cyan-b); }

/* ── Steps ── */
.step-dot  { width:8px; height:8px; border-radius:50%; background:var(--elevated); border:1px solid var(--border); flex-shrink:0; transition:all .3s; }
.step-dot.done   { background:var(--green); border-color:var(--green); }
.step-dot.active { background:var(--cyan); border-color:var(--cyan); box-shadow:0 0 8px rgba(6,182,212,.5); }
.step-dot.error  { background:var(--red); border-color:var(--red); }
.step-line { height:1px; background:var(--border); transition:background .3s; }
.step-line.done { background:var(--green); }

/* ── Runflow ── */
.runflow-track { display:flex; align-items:flex-end; }
.rf-step { display:flex; flex-direction:column; align-items:center; gap:5px; flex-shrink:0; }
.rf-label { font-size:8.5px; color:var(--text-3); font-weight:500; text-align:center; white-space:nowrap; letter-spacing:.01em; }
.rf-conn { flex:1; padding-bottom:4px; min-width:6px; }
.rf-conn .step-line { width:100%; }

/* ── Logs ── */
.log-entry { display:flex; align-items:flex-start; gap:6px; padding:4px 8px; border-radius:8px; font-size:12px; margin-bottom:2px; border:1px solid var(--border); background:rgba(255,255,255,.008); transition:background .15s; }
.log-entry:hover { background:rgba(38,38,38,0.5); }
.log-entry.log-error   { border-color:rgba(239,68,68,.25); }
.log-entry.log-warning { border-color:rgba(249,115,22,.2); }
.log-entry.dev { font-size:11px; }
.log-ts    { color:var(--text-3); font-variant-numeric:tabular-nums; flex-shrink:0; font-family:monospace; font-size:10px; width:42px; padding-top:2px; }
.log-entry.dev .log-ts { width:62px; }
.log-msg   { color:var(--text-2); line-height:1.5; flex:1; word-break:break-word; }
.log-msg.error   { color:var(--red); font-weight:500; }
.log-msg.success { color:var(--green); font-weight:500; }
.log-msg.warning { color:var(--orange); }
.log-msg.debug   { color:var(--blue); font-family:monospace; font-size:11px; }
.log-msg.info    { color:var(--text-2); }
.log-badge { font-size:9px; font-weight:700; padding:1px 5px; border-radius:4px; flex-shrink:0; text-transform:uppercase; letter-spacing:.4px; line-height:1.7; font-family:monospace; }
.log-badge.error   { background:rgba(239,68,68,.15); color:var(--red); }
.log-badge.success { background:rgba(34,197,94,.15); color:var(--green); }
.log-badge.warning { background:rgba(249,115,22,.15); color:var(--orange); }
.log-badge.debug   { background:rgba(59,130,246,.15); color:var(--blue); }
.log-badge.info    { background:rgba(255,255,255,.05); color:var(--text-3); }
.log-count { font-size:10px; font-weight:700; color:var(--text-3); background:rgba(255,255,255,0.07); border:1px solid rgba(255,255,255,0.1); border-radius:99px; padding:1px 7px; flex-shrink:0; font-family:monospace; margin-left:auto; }
.log-new { animation:logSlideIn .28s cubic-bezier(.22,.68,0,1.2) both; }
@keyframes logSlideIn { from{opacity:0;transform:translateX(-10px) translateY(-4px)} to{opacity:1;transform:none} }
.log-new.log-success { animation:logSlideInSuccess .3s cubic-bezier(.22,.68,0,1.2) both; }
@keyframes logSlideInSuccess { from{opacity:0;transform:translateX(-10px);box-shadow:0 0 0 0 rgba(34,197,94,.4)} to{opacity:1;transform:none;box-shadow:0 0 0 4px transparent} }
.log-new.log-error { animation:logSlideInError .3s cubic-bezier(.22,.68,0,1.2) both; }
@keyframes logSlideInError { from{opacity:0;transform:translateX(-10px);box-shadow:0 0 0 0 rgba(239,68,68,.4)} to{opacity:1;transform:none;box-shadow:0 0 0 4px transparent} }
.log-typing { display:flex; align-items:center; gap:4px; padding:8px 12px; margin-bottom:3px; }
.log-typing span { width:6px; height:6px; border-radius:50%; background:var(--text-3); animation:typingDot .9s infinite; }
.log-typing span:nth-child(2) { animation-delay:.15s; }
.log-typing span:nth-child(3) { animation-delay:.3s; }
@keyframes typingDot { 0%,60%,100%{transform:translateY(0);opacity:.4} 30%{transform:translateY(-4px);opacity:1} }

/* ── History ── */
.hist-row { display:flex; align-items:center; gap:12px; padding:10px 14px; border-radius:10px; cursor:pointer; transition:all .2s; border:1px solid transparent; }
.hist-row:hover   { background:rgba(38,38,38,0.5); border-color:var(--border); }
.hist-row.selected{ background:var(--cyan-bg); border-color:var(--cyan-b); }
.detail-panel { background:rgba(15,15,15,0.6); border:1px solid var(--border); border-radius:14px; overflow:hidden; backdrop-filter:blur(4px); }
.detail-header { padding:12px 16px; border-bottom:1px solid var(--border); display:flex; align-items:center; justify-content:space-between; }

/* ── Toggle ── */
.toggle { width:32px; height:18px; background:rgba(38,38,38,0.8); border-radius:99px; position:relative; transition:background .2s; border:1px solid var(--border); cursor:pointer; touch-action:manipulation; }
.toggle.on { background:#f5f5f5; border-color:#f5f5f5; }
.toggle::after { content:''; width:12px; height:12px; background:var(--text-3); border-radius:50%; position:absolute; top:2px; left:2px; transition:all .2s; }
.toggle.on::after { left:16px; background:#0a0a0a; }

/* ── Overflow helpers ── */
.overflow-y { overflow-y:auto; scrollbar-width:none; -webkit-overflow-scrolling:touch; }
.overflow-y::-webkit-scrollbar { display:none; }
#hist-list, #d-content { scrollbar-width:thin; scrollbar-color:var(--border) transparent; }
#hist-list::-webkit-scrollbar, #d-content::-webkit-scrollbar { width:4px; }
#hist-list::-webkit-scrollbar-track, #d-content::-webkit-scrollbar-track { background:transparent; }
#hist-list::-webkit-scrollbar-thumb, #d-content::-webkit-scrollbar-thumb { background:var(--border); border-radius:2px; }
#log-container { overflow-y:auto; -webkit-overflow-scrolling:touch; flex:1; min-height:0; scrollbar-width:thin; scrollbar-color:var(--border) transparent; }
#log-container::-webkit-scrollbar { width:4px; }
#log-container::-webkit-scrollbar-track { background:transparent; }
#log-container::-webkit-scrollbar-thumb { background:var(--border); border-radius:2px; }
.tab-content { display:none; }
.tab-content.active { display:block; }

/* ── Animations ── */
@keyframes spin{to{transform:rotate(360deg)}}
.spin { animation:spin 1s linear infinite; display:inline-block; }
code { background:var(--elevated); border:1px solid var(--border); border-radius:4px; padding:1px 5px; font-size:11px; color:var(--cyan); font-family:monospace; }

/* ── Login overlay ── */
#login-overlay {
  position: fixed;
  inset: 0;
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 300;
  padding: 24px;
  padding-bottom: calc(24px + var(--safe-bottom));
}
.login-card {
  width: min(100%, 380px);
  background: rgba(15,15,15,0.98);
  border: 1px solid rgba(38,38,38,0.9);
  border-radius: 20px;
  padding: 32px 28px;
  box-shadow: 0 24px 64px rgba(0,0,0,.6);
}
.login-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 24px;
}
.login-brand-name {
  font-size: 13px;
  font-weight: 600;
  letter-spacing: .18em;
  text-transform: uppercase;
}
.login-heading {
  font-size: 22px;
  font-weight: 700;
  line-height: 1.15;
  margin-bottom: 6px;
}
.login-sub {
  font-size: 13px;
  color: var(--text-3);
  margin-bottom: 24px;
  line-height: 1.5;
}
.login-fields {
  display: flex;
  flex-direction: column;
  gap: 14px;
  margin-bottom: 14px;
}
.login-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.login-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-3);
  text-transform: uppercase;
  letter-spacing: .08em;
}
.login-input {
  background: var(--elevated);
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text);
  font-size: 14px;
  font-family: var(--font);
  padding: 10px 14px;
  outline: none;
  transition: border-color .15s, box-shadow .15s;
  width: 100%;
}
.login-input:focus {
  border-color: var(--border-hover);
  box-shadow: 0 0 0 2px rgba(255,255,255,.04);
}
.login-remember {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--text-3);
  cursor: pointer;
  margin-bottom: 4px;
  user-select: none;
}
.login-remember input[type="checkbox"] {
  width: 15px;
  height: 15px;
  accent-color: var(--text);
  cursor: pointer;
  flex-shrink: 0;
}
.login-error {
  font-size: 12px;
  color: var(--red);
  background: var(--red-bg);
  border: 1px solid var(--red-b);
  border-radius: 8px;
  padding: 8px 12px;
  margin-bottom: 14px;
  text-align: center;
}
.login-btn {
  width: 100%;
  justify-content: center;
  height: 40px;
  font-size: 13px;
  border-radius: 10px;
  margin-top: 4px;
}

/* ── Connection overlay ── */
#conn-overlay {
  position: fixed;
  inset: 0;
  background: rgba(10,10,10,.9);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  padding: 24px;
  padding-bottom: calc(24px + var(--safe-bottom));
}
.conn-card {
  width: min(100%, 460px);
  background: rgba(15,15,15,0.95);
  border: 1px solid rgba(38,38,38,0.9);
  border-radius: 20px;
  padding: 28px;
  box-shadow: 0 24px 64px rgba(0,0,0,.6);
}
.conn-title { font-size:22px; font-weight:700; line-height:1.15; margin-bottom:8px; text-align:center; }
.conn-sub { font-size:15px; color:var(--text-2); margin-bottom:16px; line-height:1.6; text-align:center; }
.conn-grid { display:grid; grid-template-columns:1fr 1fr; gap:10px; margin-bottom:16px; }
.conn-item { text-align:left; background:var(--elevated); border:1px solid var(--border); border-radius:12px; padding:12px; }
.conn-label { display:block; font-size:10px; font-weight:700; letter-spacing:.08em; text-transform:uppercase; color:var(--text-3); margin-bottom:6px; }
.conn-debug { margin-bottom:18px; background:rgba(10,10,10,0.8); border:1px solid var(--border); border-radius:14px; overflow:hidden; }
.conn-debug-head { display:flex; align-items:center; justify-content:space-between; gap:10px; padding:10px 12px; border-bottom:1px solid var(--border); background:rgba(255,255,255,.02); }
.conn-debug-title { font-size:10px; font-weight:700; letter-spacing:.08em; text-transform:uppercase; color:var(--text-3); }
.conn-debug-live { font-size:10px; color:var(--blue); font-weight:600; }
.conn-debug-body { padding:8px 12px 10px; }
.conn-debug-row { display:grid; grid-template-columns:92px 1fr; gap:10px; align-items:start; padding:6px 0; font-size:12px; border-bottom:1px solid rgba(38,38,38,.5); }
.conn-debug-row:last-child { border-bottom:none; }
.conn-debug-key { color:var(--text-3); text-transform:uppercase; letter-spacing:.05em; font-size:10px; font-weight:700; padding-top:3px; }
.conn-debug-val { color:var(--text-2); font-family:ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; word-break:break-word; line-height:1.55; }
.conn-footer { display:flex; flex-direction:column; align-items:center; gap:10px; }
.conn-note { font-size:11px; color:var(--text-3); text-align:center; line-height:1.5; }

/* ── Dashboard layout ── */
.kpi-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); align-items: start; }
.kpi-grid .metric-value { letter-spacing: -.02em; }
.dashboard-shell { display:flex; gap:14px; margin-bottom:14px; align-items:stretch; }
.dashboard-left-stack { flex:1.6; display:flex; flex-direction:column; gap:14px; min-width:0; }
.dashboard-right-col { flex:1; min-width:0; min-height:0; position:relative; }
.dashboard-info-grid { display:grid; grid-template-columns:1fr 1fr; gap:14px; align-items:stretch; }
.runflow-card { min-height:0; }
.journal-card { position:absolute; inset:0; overflow:hidden; }
.history-layout #hist-list { min-height:420px; max-height:560px; overflow-y:auto; }
.history-layout #d-content { max-height:560px; overflow-y:auto; }

/* ── Code inline input ── */
.code-inline-input {
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 4px;
  padding: 1px 5px;
  font-size: 11px;
  color: var(--cyan);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  text-align: right;
  outline: none;
  cursor: pointer;
  width: 56px;
  transition: border-color .15s, background .15s;
}
.code-inline-input:hover { border-color: var(--border); }
.code-inline-input:focus { border-color: var(--border-hover); background: var(--elevated); cursor: text; }

/* ── Mix journalier ── */
.mix-card { transition: border-color .2s; }
.mix-grid { display:grid; grid-template-columns:repeat(3, minmax(0, 1fr)); gap:10px; }
.mix-channel-card { background:rgba(20,20,20,0.7); border:1px solid var(--border); border-radius:12px; padding:14px 14px 12px; display:flex; flex-direction:column; gap:10px; transition:border-color .2s, box-shadow .2s; }
.mix-channel-card:hover { border-color:var(--border-hover); box-shadow:0 4px 20px rgba(0,0,0,.5); }
.mix-channel-name { font-size:12px; font-weight:600; color:var(--text-2); white-space:nowrap; overflow:hidden; text-overflow:ellipsis; min-width:0; }
.mix-channel-counter { font-size:11px; color:var(--text-3); flex-shrink:0; font-variant-numeric:tabular-nums; font-family:ui-monospace, monospace; }
.mix-pct-label { font-size:10px; font-weight:600; color:var(--text-3); min-width:28px; }
.mix-channel-input {
  width: 52px;
  padding: 4px 7px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 7px;
  color: var(--text);
  font-size: 12px;
  font-weight: 600;
  text-align: center;
  font-family: var(--font);
  outline: none;
  transition: border-color .15s, box-shadow .15s;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  cursor: pointer;
}
.mix-channel-input:focus { border-color:var(--border-hover); box-shadow:0 0 0 2px rgba(255,255,255,.04); cursor:text; }

/* ── Chat widget ── */
#chat-widget { position:fixed; bottom:calc(24px + var(--safe-bottom)); right:calc(24px + var(--safe-right)); z-index:9999; display:flex; flex-direction:column; align-items:flex-end; gap:12px; pointer-events:none; }
#chat-toggle { width:52px; height:52px; border-radius:50%; background:var(--text); color:var(--bg); border:none; cursor:pointer; display:flex; align-items:center; justify-content:center; box-shadow:0 4px 24px rgba(0,0,0,0.6); transition:transform .2s,box-shadow .2s; flex-shrink:0; touch-action:manipulation; pointer-events:auto; }
#chat-toggle:hover { transform:scale(1.08); box-shadow:0 6px 32px rgba(0,0,0,0.75); }
#chat-panel { width:340px; height:480px; background:rgba(12,12,12,0.97); border:1px solid rgba(55,55,55,0.8); border-radius:18px; display:flex; flex-direction:column; overflow:hidden; box-shadow:0 16px 48px rgba(0,0,0,0.8); backdrop-filter:blur(12px); opacity:0; transform:translateY(18px) scale(0.95); pointer-events:none; transition:opacity .25s ease,transform .28s cubic-bezier(0.34,1.4,0.64,1); }
#chat-panel.open { opacity:1; transform:translateY(0) scale(1); pointer-events:auto; }
#chat-header { padding:14px 16px; border-bottom:1px solid rgba(38,38,38,0.8); display:flex; align-items:center; gap:10px; flex-shrink:0; }
.chat-hdr-dot { width:7px; height:7px; border-radius:50%; flex-shrink:0; }
.chat-hdr-dot.online  { background:var(--green); box-shadow:0 0 6px var(--green); }
.chat-hdr-dot.offline { background:var(--text-3); }
.chat-hdr-title { font-size:13px; font-weight:600; color:var(--text); flex:1; }
.chat-hdr-sub { font-size:10px; color:var(--text-3); letter-spacing:.04em; }
#chat-messages { flex:1; overflow-y:auto; -webkit-overflow-scrolling:touch; padding:14px; display:flex; flex-direction:column; gap:8px; scrollbar-width:thin; scrollbar-color:var(--border) transparent; }
.chat-bubble { max-width:86%; padding:9px 13px; font-size:12px; line-height:1.55; word-break:break-word; white-space:pre-wrap; }
.chat-bubble-ai { background:rgba(32,32,32,0.9); color:var(--text-2); border-radius:14px 14px 14px 4px; align-self:flex-start; border:1px solid rgba(45,45,45,0.8); }
.chat-bubble-user { background:var(--text); color:#0a0a0a; border-radius:14px 14px 4px 14px; align-self:flex-end; font-weight:500; }
.chat-greeting { max-width:92%; align-self:flex-start; }
.chat-greeting-body { background:rgba(32,32,32,0.9); border:1px solid rgba(45,45,45,0.8); border-radius:14px 14px 14px 4px; padding:13px 15px; }
.chat-greeting-title { font-size:13px; font-weight:700; color:var(--text); margin-bottom:4px; display:flex; align-items:center; gap:6px; }
.chat-greeting-wave { display:inline-block; font-size:16px; transform-origin:70% 80%; animation:wave-hand 1.6s ease-in-out 0.3s 3; }
@keyframes wave-hand { 0%,100%{transform:rotate(0deg)} 20%{transform:rotate(-10deg)} 40%{transform:rotate(16deg)} 60%{transform:rotate(-8deg)} 80%{transform:rotate(12deg)} }
.chat-greeting-sub { font-size:11.5px; color:var(--text-3); line-height:1.6; }
#chat-chips-wrap { position:relative; flex-shrink:0; overflow:hidden; max-height:52px; opacity:1; transition:opacity .2s ease,max-height .25s ease; }
#chat-chips-wrap.hidden { opacity:0; max-height:0; pointer-events:none; }
#chat-chips-row { display:flex; flex-wrap:nowrap; gap:7px; padding:10px 14px; overflow-x:auto; -webkit-overflow-scrolling:touch; scrollbar-width:none; scroll-behavior:smooth; }
#chat-chips-row::-webkit-scrollbar { display:none; }
.chat-chip { background:rgba(255,255,255,0.06); border:1px solid rgba(255,255,255,0.1); border-radius:99px; padding:6px 13px; font-size:11px; color:var(--text-3); cursor:pointer; transition:background .15s,color .15s,border-color .15s; white-space:nowrap; flex-shrink:0; letter-spacing:.01em; touch-action:manipulation; }
.chat-chip:hover { background:rgba(255,255,255,0.12); color:var(--text); border-color:rgba(255,255,255,0.22); }
.chips-arrow { position:absolute; top:0; bottom:0; width:36px; display:flex; align-items:center; cursor:pointer; z-index:2; opacity:1; transition:opacity .2s; border:none; background:none; padding:0; color:rgba(255,255,255,0.35); touch-action:manipulation; }
.chips-arrow:hover { color:rgba(255,255,255,0.7); }
.chips-arrow.hidden { opacity:0; pointer-events:none; }
#chips-arrow-left { left:0; justify-content:flex-start; padding-left:4px; background:linear-gradient(to right,rgba(12,12,12,0.95) 40%,transparent); }
#chips-arrow-right { right:0; justify-content:flex-end; padding-right:4px; background:linear-gradient(to left,rgba(12,12,12,0.95) 40%,transparent); }
.chat-loading { display:flex; gap:5px; align-items:center; padding:10px 14px; background:rgba(32,32,32,0.9); border-radius:14px 14px 14px 4px; border:1px solid rgba(45,45,45,0.8); align-self:flex-start; }
.chat-loading span { width:6px; height:6px; border-radius:50%; background:var(--text-3); animation:chat-dot .9s infinite; }
.chat-loading span:nth-child(2) { animation-delay:.18s; }
.chat-loading span:nth-child(3) { animation-delay:.36s; }
@keyframes chat-dot { 0%,60%,100%{transform:translateY(0);opacity:.3} 30%{transform:translateY(-5px);opacity:1} }
#chat-input-row { padding:10px 12px; border-top:1px solid rgba(38,38,38,0.8); display:flex; gap:8px; align-items:center; flex-shrink:0; }
#chat-input { flex:1; background:rgba(22,22,22,0.9); border:1px solid rgba(55,55,55,0.7); border-radius:99px; color:var(--text); font-size:16px; padding:8px 14px; outline:none; font-family:var(--font); }
#chat-input:focus { border-color:rgba(120,120,120,0.6); }
#chat-input:disabled { opacity:.5; }
#chat-send { width:40px; height:40px; border-radius:50%; background:var(--text); color:#0a0a0a; border:none; cursor:pointer; display:flex; align-items:center; justify-content:center; flex-shrink:0; transition:opacity .15s; touch-action:manipulation; }
#chat-send:hover { opacity:.8; }
#chat-send:disabled { opacity:.35; cursor:not-allowed; }

/* ═══════════════════════════════════════════════════
   RESPONSIVE BREAKPOINTS
   ═══════════════════════════════════════════════════ */

/* ── 1240px : petit laptop / tablette paysage ── */
@media (max-width: 1240px) {
  .header { grid-template-columns: 1fr; gap: 10px; padding: calc(12px + var(--safe-top)) 14px 12px; }
  .header-center, .header-actions { justify-self: stretch; }
  .header-center { justify-content: flex-start; }
  .header-actions { justify-content: space-between; }
  .tabs { width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; scrollbar-width: none; }
  .tabs::-webkit-scrollbar { display: none; }
  .tab { white-space: nowrap; }
  .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .dashboard-shell { flex-direction: column; }
  .dashboard-info-grid { grid-template-columns: 1fr 1fr; }
  .dashboard-right-col { min-height: 0; }
  .journal-card { position: static; height: 300px; }
  .mix-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

/* ── 900px : tablette portrait / grand téléphone paysage ── */
@media (max-width: 900px) {
  .content {
    padding: 16px;
    padding-bottom: calc(80px + var(--safe-bottom));
    padding-left: calc(16px + var(--safe-left));
    padding-right: calc(16px + var(--safe-right));
    overflow-x: hidden;
    scrollbar-width: thin;
    scrollbar-color: var(--border) transparent;
  }
  .content::-webkit-scrollbar { display: block; width: 3px; }
  .content::-webkit-scrollbar-track { background: transparent; }
  .content::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }
  .logo-text { font-size: 13px; }
  .status-pill { min-width: 118px; font-size: 11px; }
  .control-buttons { gap: 6px; }
  .btn-control { min-width: 94px; }
  .kpi-grid { grid-template-columns: 1fr; }
  .grid-2 { grid-template-columns: 1fr; }
  .dashboard-info-grid { grid-template-columns: 1fr; }
  .grid-3 { grid-template-columns: 1fr; }
  .settings-cards-row { grid-template-columns: 1fr; }
  .history-layout { grid-template-columns: 1fr; min-height: auto !important; }
  .history-layout #hist-list { min-height: 240px; max-height: 40vh; overflow-y: auto; -webkit-overflow-scrolling: touch; }
  #d-content { max-height: none !important; }
  .mix-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

/* ── 640px : téléphone portrait ── */
@media (max-width: 640px) {
  /* Layout principal */
  .content {
    padding: 12px;
    padding-top: 14px;
    padding-bottom: calc(110px + var(--safe-bottom));
    padding-left: calc(12px + var(--safe-left));
    padding-right: calc(12px + var(--safe-right));
    overflow-x: hidden;
    overflow-y: scroll;
  }

  /* ── Header : 2 lignes — tabs centrés, actions centrées ── */
  .header {
    grid-template-columns: 1fr auto 1fr;
    grid-template-rows: auto auto;
    padding: calc(8px + var(--safe-top)) 14px 0;
    gap: 4px 6px;
  }
  /* Tabs : colonne centrale → naturellement centrés sur la page */
  .header-center {
    grid-column: 2;
    grid-row: 1;
    justify-self: center;
    justify-content: center;
  }
  /* Status + boutons : ligne 2, centrés */
  .header-actions {
    grid-column: 1 / -1;
    grid-row: 2;
    justify-self: stretch;
    justify-content: center;
    align-items: center;
    flex-wrap: nowrap;
    gap: 8px;
    padding: 8px 0;
    border-top: 1px solid var(--border);
    margin-top: 2px;
  }
  .logo-text { display: none; }

  /* Tabs */
  .tabs { width: auto; overflow-x: auto; -webkit-overflow-scrolling: touch; scrollbar-width: none; }
  .tabs::-webkit-scrollbar { display: none; }
  .tab { white-space: nowrap; min-height: 32px; padding: 5px 12px; font-size: 10px; gap: 4px; }

  /* Status pill — taille naturelle, centré dans le groupe */
  .status-pill { flex: 0 0 auto; width: auto; height: 34px; padding: 0 12px; border-radius: 8px; font-size: 11px; gap: 6px; justify-content: center; }
  #status-text { display: block; font-size: 11px; white-space: nowrap; }

  /* Boutons Start/Stop avec texte */
  .control-buttons { flex-shrink: 0; gap: 8px; }
  .btn-control { min-width: 72px; width: auto; height: 34px; padding: 0 14px; border-radius: 99px; font-size: 11px; font-weight: 600; justify-content: center; gap: 5px; }
  .btn-control .lucide-icon.lg { width: 13px; height: 13px; }

  /* Cards */
  .card { padding: 12px; border-radius: 12px; }
  .card-sm { padding: 10px; }
  .card:hover { transform: none; box-shadow: none; }

  /* Grids */
  .grid-4, .grid-2, .grid-3 { grid-template-columns: 1fr; }
  .kpi-grid { grid-template-columns: 1fr; }
  .dashboard-shell, .dashboard-info-grid { gap: 10px; margin-bottom: 10px; }
  .mix-grid { grid-template-columns: 1fr 1fr; }

  /* Typo */
  .section-title { font-size: 10px; }
  .metric-value { font-size: 20px; }
  .metric-label { letter-spacing: .05em; font-size: 9px; }

  /* Journal — hauteur fixe statique */
  .journal-card { position: static; height: 300px; }
  .journal-card .section-hdr { flex-wrap: wrap; gap: 8px; }
  .journal-card .section-hdr > div { flex-wrap: wrap; gap: 6px; }

  /* Historique */
  .history-layout #hist-list { min-height: 180px; max-height: 38vh; }
  #d-content { padding: 12px !important; }
  .hist-row { padding: 12px 10px; gap: 8px; min-height: 52px; }

  /* Runflow */
  .runflow-card { overflow: hidden; }
  .rf-label { white-space: normal; word-break: break-word; max-width: 32px; font-size: 7px; }
  .rf-conn { min-width: 2px; }

  /* ─────────────────────────────────────────────
     INPUTS — fixes critiques mobile
     ───────────────────────────────────────────── */
  input:not([type="range"]),
  textarea,
  select {
    font-size: 16px !important;          /* empêche le zoom iOS */
    user-select: auto !important;
    -webkit-user-select: auto !important;
    touch-action: manipulation !important;
    -webkit-touch-callout: default !important;
    pointer-events: auto !important;
  }
  .mix-channel-input {
    width: 64px;
    height: 44px;
    font-size: 16px;
    border-radius: 8px;
  }
  .code-inline-input {
    font-size: 16px;
    width: 70px;
    height: 34px;
    padding: 6px 8px;
  }
  #chat-input { font-size: 16px; }

  /* ─────────────────────────────────────────────
     TOUCH TARGETS — minimum 44×44px
     ───────────────────────────────────────────── */
  .btn-primary:not(.btn-control),
  .btn-danger:not(.btn-control),
  .btn-secondary:not(.btn-control) { min-height: 44px; height: auto; padding: 10px 18px; }
  .btn-ghost:not(.btn-control) { min-height: 36px; height: auto; padding: 8px 12px; }
  .btn-mini { min-height: 32px; height: auto; padding: 6px 12px; font-size: 11px; }

  /* Toggle plus grand */
  .toggle { width: 44px; height: 26px; }
  .toggle::after { width: 18px; height: 18px; top: 3px; left: 3px; }
  .toggle.on::after { left: 22px; }

  /* Connexion overlay */
  .conn-card { padding: 20px; border-radius: 18px; }
  .conn-title { font-size: 20px; }
  .conn-sub { font-size: 14px; }
  .conn-grid { grid-template-columns: 1fr; }
  .conn-debug-row { grid-template-columns: 1fr; gap: 4px; }

  /* Chat widget — plein écran bas */
  #chat-widget { bottom: calc(14px + var(--safe-bottom)); right: 14px; }
  #chat-toggle { width: 50px; height: 50px; }
  #chat-panel {
    width: calc(100vw - 28px);
    max-width: 380px;
    height: 68vh;
    max-height: 520px;
  }

  /* Mix journalier : inputs grands */
  .mix-channel-card { padding: 12px; gap: 8px; }
  .mix-channel-name { font-size: 11px; }

  /* Settings */
  .settings-cards-row { grid-template-columns: 1fr; }
  .settings-summary-grid { grid-template-columns: 1fr 1fr; }
}

/* ── 400px : très petits téléphones ── */
@media (max-width: 400px) {
  .header { grid-template-columns: auto auto; gap: 6px; padding-left: 10px; padding-right: 10px; }
  .header-center { display: none; }
  .tabs { display: none; }
  .mix-grid { grid-template-columns: 1fr; }
  .settings-summary-grid { grid-template-columns: 1fr; }
}

/* ── Paysage mobile ── */
@media (orientation: landscape) and (max-height: 520px) {
  .header { padding: calc(6px + var(--safe-top)) calc(14px + var(--safe-right)) 6px calc(14px + var(--safe-left)); gap: 6px; grid-template-columns: auto 1fr auto; }
  .logo-text { display: none; }
  .content {
    padding: 8px;
    padding-bottom: calc(60px + var(--safe-bottom));
    padding-left: calc(8px + var(--safe-left));
    padding-right: calc(8px + var(--safe-right));
  }
  .kpi-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); align-items: start; }
  .dashboard-shell { flex-direction: row; }
  .dashboard-info-grid { grid-template-columns: 1fr 1fr; }
  .dashboard-right-col { position: relative; min-height: 200px; }
  .journal-card { position: absolute; inset: 0; height: unset; }
  .metric-value { font-size: 18px; }
  #chat-widget { bottom: calc(8px + var(--safe-bottom)); right: calc(8px + var(--safe-right)); }
  #chat-toggle { width: 40px; height: 40px; }
  #chat-panel { height: 340px; width: min(300px, calc(100vw - 60px)); }
}

/* ── Respect prefers-reduced-motion ── */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
