:root {
  --bg: #f4f5f7;
  --surface: #ffffff;
  --sidebar: #f7f8fa;
  --border: #e5e7eb;
  --border-soft: #eef0f3;
  --text: #111827;
  --muted: #6b7280;
  --muted2: #9ca3af;
  --orange: #f97316;
  --orange-soft: #fff7ed;
  --orange-btn: #ff6b1a;
  --black: #111111;
  --pill: #f3f4f6;
  --pill-active: #e5e7eb;
  --danger: #dc2626;
  --radius: 10px;
  --radius-lg: 12px;
  --topbar-h: 52px;
  --sidebar-w: 300px;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: inherit; }

/* ——— Auth (light card) ——— */
.auth-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background:
    radial-gradient(800px 400px at 20% 0%, #fff7ed, transparent),
    radial-gradient(600px 300px at 90% 100%, #f3f4f6, transparent),
    var(--bg);
}
.auth {
  width: min(420px, 100%);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 32px 28px;
  box-shadow: 0 12px 40px rgba(17, 24, 39, 0.06);
}
.auth-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 8px;
}
.auth h1 { margin: 0; font-size: 1.35rem; font-weight: 700; }
.auth p { color: var(--muted); margin: 0 0 20px; }
.auth label { display: block; font-size: 0.8rem; color: var(--muted); margin: 12px 0 6px; font-weight: 500; }
.auth input {
  width: 100%;
  padding: 11px 12px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: #fff;
}
.auth input:focus { outline: 2px solid #fed7aa; border-color: var(--orange); }
.auth .row { display: flex; gap: 10px; margin-top: 18px; }
.auth-tabs { display: flex; gap: 8px; margin-bottom: 4px; }

/* ——— Buttons ——— */
.btn {
  border: 0;
  border-radius: 10px;
  padding: 10px 14px;
  font-weight: 600;
  background: var(--black);
  color: #fff;
  transition: opacity .15s, background .15s;
}
.btn:hover { opacity: .92; }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn.secondary {
  background: #fff;
  border: 1px solid var(--border);
  color: var(--text);
}
.btn.ghost {
  background: transparent;
  border: 0;
  color: var(--muted);
  padding: 8px 10px;
}
.btn.orange-soft {
  background: var(--orange-soft);
  color: var(--orange);
  border: 1px solid #ffedd5;
}
.btn.publish {
  background: var(--black);
  color: #fff;
  padding: 8px 16px;
  border-radius: 10px;
  font-size: 13.5px;
}
.btn.mejorar {
  background: var(--orange-soft);
  color: var(--orange);
  border: 1px solid #ffedd5;
  padding: 8px 14px;
  border-radius: 10px;
  font-size: 13.5px;
}
.error { color: var(--danger); font-size: 0.88rem; margin-top: 10px; }

/* ——— Logo ——— */
.logo-mark {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: linear-gradient(145deg, #ff8a3d, #f97316 55%, #ea580c);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-weight: 700;
  font-size: 12px;
  flex-shrink: 0;
  box-shadow: 0 1px 2px rgba(249, 115, 22, 0.35);
}
.logo-mark.lg { width: 36px; height: 36px; font-size: 14px; }

/* ——— App shell ——— */
.app-shell {
  display: grid;
  grid-template-rows: var(--topbar-h) 1fr;
  height: 100vh;
  background: var(--bg);
}
.app-shell.sidebar-collapsed { --sidebar-w: 0px; }

/* Top bar */
.b44-topbar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 12px 0 14px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  height: var(--topbar-h);
  z-index: 20;
}
.b44-topbar .tb-left,
.b44-topbar .tb-center,
.b44-topbar .tb-right {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}
.b44-topbar .tb-left { flex: 1; }
.b44-topbar .tb-center { flex: 0 1 auto; justify-content: center; }
.b44-topbar .tb-right { flex: 1; justify-content: flex-end; }

.project-dd {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  max-width: 180px;
  padding: 6px 8px;
  border-radius: 8px;
  border: 0;
  background: transparent;
  font-weight: 600;
  font-size: 13.5px;
}
.project-dd:hover { background: var(--pill); }
.project-dd .name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.chev { color: var(--muted2); font-size: 10px; }

.branch-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--pill);
  border: 1px solid var(--border-soft);
  font-size: 12px;
  font-weight: 500;
  color: var(--text);
}
.branch-pill .crown { font-size: 11px; }

.icon-btn {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  border: 0;
  background: transparent;
  color: var(--muted);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
}
.icon-btn:hover { background: var(--pill); color: var(--text); }
.icon-btn svg { width: 16px; height: 16px; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

.tab-pills {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  padding: 3px;
  background: var(--pill);
  border-radius: 10px;
  border: 1px solid var(--border-soft);
}
.tab-pill {
  border: 0;
  background: transparent;
  padding: 6px 12px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 500;
  color: var(--muted);
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.tab-pill.active {
  background: #fff;
  color: var(--text);
  box-shadow: 0 1px 2px rgba(0,0,0,.06);
  font-weight: 600;
}
.tab-pill svg { width: 14px; height: 14px; }

.page-select {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: #fff;
  font-size: 13px;
  font-weight: 500;
}
.page-select:hover { background: var(--pill); }

.avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: linear-gradient(135deg, #6366f1, #8b5cf6);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

/* Body: sidebar + main */
.b44-body {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  min-height: 0;
  height: calc(100vh - var(--topbar-h));
  transition: grid-template-columns .2s ease;
}

/* Left sidebar – checkpoints + composer */
.b44-sidebar {
  background: var(--sidebar);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  min-width: 0;
  overflow: hidden;
}
.app-shell.sidebar-collapsed .b44-sidebar {
  border-right: 0;
  visibility: hidden;
  pointer-events: none;
}

.checkpoint-list {
  flex: 1;
  overflow: auto;
  padding: 14px 12px 8px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.checkpoint {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px 10px;
  border-radius: 10px;
  border: 1px solid transparent;
  background: transparent;
  text-align: left;
  width: 100%;
}
.checkpoint:hover { background: #fff; border-color: var(--border-soft); }
.checkpoint .flag {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  background: #fff;
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  color: var(--muted);
}
.checkpoint .flag svg { width: 14px; height: 14px; }
.checkpoint .body { min-width: 0; flex: 1; }
.checkpoint .title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  margin: 0 0 4px;
}
.checkpoint .pill-label {
  display: inline-block;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 11.5px;
  color: var(--muted);
  background: var(--pill);
  border: 1px solid var(--border-soft);
  border-radius: 999px;
  padding: 2px 8px;
}
.checkpoint-empty {
  color: var(--muted);
  font-size: 13px;
  padding: 20px 12px;
  text-align: center;
}

.sidebar-composer {
  padding: 12px;
  border-top: 1px solid var(--border);
  background: var(--sidebar);
}
.composer-box {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 10px 10px 10px 14px;
  box-shadow: 0 1px 2px rgba(0,0,0,.03);
}
.composer-box:focus-within {
  border-color: #fdba74;
  box-shadow: 0 0 0 3px rgba(249, 115, 22, 0.12);
}
.composer-box textarea {
  flex: 1;
  border: 0;
  outline: none;
  resize: none;
  min-height: 44px;
  max-height: 140px;
  background: transparent;
  padding: 4px 0;
  font-size: 13.5px;
  line-height: 1.4;
}
.composer-box textarea::placeholder { color: var(--muted2); }
.composer-send {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  border: 0;
  background: var(--black);
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.composer-send:disabled { opacity: .4; cursor: not-allowed; }
.composer-send svg { width: 16px; height: 16px; }
.composer-hint {
  font-size: 11px;
  color: var(--muted2);
  margin: 8px 4px 0;
}

/* Main workspace */
.b44-main {
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  position: relative;
}

.preview-stage {
  flex: 1;
  min-height: 0;
  display: flex;
  padding: 16px 18px 18px;
}
.device-frame {
  flex: 1;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 14px;
  overflow: hidden;
  box-shadow: 0 8px 30px rgba(17, 24, 39, 0.06);
  display: flex;
  flex-direction: column;
  min-height: 0;
}
.device-frame iframe {
  flex: 1;
  width: 100%;
  border: 0;
  background: #fff;
}
.preview-empty {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  color: var(--muted);
  padding: 40px;
  text-align: center;
}
.preview-empty strong { color: var(--text); font-size: 15px; }

/* Panel / Editar views */
.panel-view, .edit-view {
  flex: 1;
  min-height: 0;
  overflow: auto;
  padding: 20px 24px;
}
.panel-card {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 18px 20px;
  max-width: 720px;
}
.panel-card h3 { margin: 0 0 6px; font-size: 15px; }
.panel-card p { margin: 0 0 14px; color: var(--muted); font-size: 13px; }
.panel-meta { display: grid; gap: 10px; }
.panel-meta .row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border-soft);
  font-size: 13px;
}
.panel-meta .row:last-child { border-bottom: 0; }
.panel-meta .k { color: var(--muted); }
.panel-meta .v { font-weight: 600; }

.file-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
  max-width: 720px;
}
.file-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border-radius: 8px;
  border: 1px solid var(--border-soft);
  background: #fff;
  font-size: 13px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}
.file-item:hover { border-color: var(--border); }
.file-editor {
  margin-top: 12px;
  max-width: 900px;
}
.file-editor textarea {
  width: 100%;
  min-height: 360px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12.5px;
  padding: 12px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: #fff;
  resize: vertical;
}

/* Dropdown menus */
.menu-pop {
  position: absolute;
  top: calc(var(--topbar-h) - 4px);
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 12px 40px rgba(0,0,0,.12);
  min-width: 240px;
  max-height: min(420px, 70vh);
  overflow: auto;
  z-index: 50;
  padding: 6px;
}
.menu-pop.right { right: 12px; }
.menu-pop.left { left: 48px; }
.menu-item {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  text-align: left;
  padding: 9px 10px;
  border: 0;
  background: transparent;
  border-radius: 8px;
  font-size: 13px;
}
.menu-item:hover { background: var(--pill); }
.menu-item.active { background: #fff7ed; color: #c2410c; font-weight: 600; }
.menu-item .meta { margin-left: auto; color: var(--muted2); font-size: 11px; }
.menu-sep { height: 1px; background: var(--border-soft); margin: 4px 6px; }
.menu-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--muted2);
  text-transform: uppercase;
  letter-spacing: .04em;
  padding: 8px 10px 4px;
}

/* Modal */
.modal-bg {
  position: fixed;
  inset: 0;
  background: rgba(17, 24, 39, 0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 16px;
}
.modal {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 20px;
  width: min(440px, 96vw);
  box-shadow: 0 20px 50px rgba(0,0,0,.15);
}
.modal h3 { margin: 0 0 12px; font-size: 16px; }
.modal label { display: block; font-size: 12px; color: var(--muted); margin: 10px 0 6px; font-weight: 500; }
.modal input, .modal select {
  width: 100%;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: #fff;
}
.modal .actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 16px; }

.share-list { margin-top: 12px; display: flex; flex-direction: column; gap: 8px; }
.share-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 10px;
  background: var(--pill);
  border: 1px solid var(--border-soft);
}
.share-row .name { font-weight: 600; font-size: 13px; }
.share-row .meta { color: var(--muted); font-size: 12px; }

.badge {
  display: inline-block;
  font-size: 11px;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: 999px;
  background: var(--pill);
  color: var(--muted);
  border: 1px solid var(--border);
}

.toast {
  position: fixed;
  bottom: 20px;
  right: 20px;
  background: var(--black);
  color: #fff;
  padding: 10px 14px;
  border-radius: 10px;
  font-size: 13px;
  z-index: 200;
  box-shadow: 0 8px 24px rgba(0,0,0,.2);
}

@media (max-width: 900px) {
  :root { --sidebar-w: 260px; }
  .b44-topbar .tb-center .page-select { display: none; }
  .btn.mejorar span.hide-sm { display: none; }
}
@media (max-width: 720px) {
  .app-shell { --sidebar-w: 0px; }
  .app-shell.sidebar-open { --sidebar-w: min(300px, 88vw); }
  .app-shell.sidebar-open .b44-sidebar {
    position: absolute;
    left: 0; top: var(--topbar-h); bottom: 0;
    width: min(300px, 88vw);
    visibility: visible;
    pointer-events: auto;
    z-index: 30;
    box-shadow: 8px 0 30px rgba(0,0,0,.12);
  }
  .tb-center .tab-pills .tab-pill span { display: none; }
}


/* chat-fix-send-label */
.composer-send {
  min-width: 84px !important;
  height: 40px !important;
  padding: 0 12px !important;
  gap: 6px;
  border-radius: 12px !important;
}
.composer-send .send-label {
  font-size: 12px;
  font-weight: 600;
  color: #fff;
}
.composer-send:not(:disabled) {
  opacity: 1 !important;
  background: #111 !important;
  cursor: pointer;
}
.preview-stage, .device-frame, #device-frame, #main-stage {
  position: relative;
}
.preview-empty {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 24px;
  color: #6b7280;
  background: #fafafa;
  font-size: 14px;
  line-height: 1.5;
  z-index: 3;
  pointer-events: none;
}

/* ===== Workspace (lista de plataformas) ===== */
.ws-screen {
  min-height: 100vh;
  background: #f4f5f7;
  color: #111;
  font-family: Inter, system-ui, sans-serif;
}
.ws-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 28px;
  background: #fff;
  border-bottom: 1px solid #e5e7eb;
}
.ws-brand { display: flex; align-items: center; gap: 12px; }
.ws-title { font-weight: 700; font-size: 16px; }
.ws-sub { font-size: 12px; color: #6b7280; }
.ws-actions { display: flex; align-items: center; gap: 10px; }
.ws-user { font-size: 13px; color: #4b5563; }
.ws-main { max-width: 1100px; margin: 0 auto; padding: 28px 24px 48px; }
.ws-head h1 { margin: 0 0 6px; font-size: 28px; letter-spacing: -0.02em; }
.ws-head p { margin: 0 0 22px; color: #6b7280; font-size: 14px; }
.ws-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 16px;
}
.ws-card {
  text-align: left;
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 14px;
  padding: 16px;
  cursor: pointer;
  transition: box-shadow .15s, transform .15s, border-color .15s;
  min-height: 130px;
}
.ws-card:hover {
  border-color: #c7cdd6;
  box-shadow: 0 8px 24px rgba(15, 23, 42, .08);
  transform: translateY(-1px);
}
.ws-card-top { display: flex; justify-content: space-between; align-items: center; margin-bottom: 18px; }
.ws-card-icon { font-size: 20px; color: #111; }
.ws-card-role {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: #6b7280;
  background: #f3f4f6;
  padding: 2px 8px;
  border-radius: 999px;
}
.ws-card-name { font-weight: 600; font-size: 15px; margin-bottom: 4px; }
.ws-card-meta { font-size: 12px; color: #9ca3af; word-break: break-all; }
.ws-card-new {
  border-style: dashed;
  background: #fafafa;
  color: #374151;
}
.ws-empty {
  grid-column: 1 / -1;
  background: #fff;
  border: 1px dashed #d1d5db;
  border-radius: 16px;
  padding: 40px 24px;
  text-align: center;
}
.ws-empty h2 { margin: 0 0 8px; }
.ws-empty p { color: #6b7280; margin: 0 0 16px; }
.logo-home {
  border: 0;
  background: transparent;
  padding: 0;
  cursor: pointer;
  display: inline-flex;
}
.btn-back {
  border: 1px solid #e5e7eb;
  background: #fff;
  border-radius: 8px;
  padding: 6px 10px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  color: #374151;
}
.btn-back:hover { background: #f9fafb; }
