/* WEB MASTER — estilo inspirado en Liquid Glass */
:root {
  --bg: #0c1430;
  --glass: rgba(255, 255, 255, 0.11);
  --glass-hi: rgba(255, 255, 255, 0.18);
  --glass-strong: rgba(22, 30, 60, 0.72);
  --stroke: rgba(255, 255, 255, 0.24);
  --stroke-soft: rgba(255, 255, 255, 0.14);
  --text: #f6f8ff;
  --text-2: #c9d1e8;
  --text-3: #9aa6c6;
  --accent: #7dd3fc;
  --accent-ink: #062638;
  --ok: #86efac;
  --warn: #fcd34d;
  --danger: #fda4af;
  --radius: 20px;
  --radius-sm: 12px;
  --blur: blur(26px) saturate(170%);
  --shadow: 0 12px 36px rgba(2, 6, 24, 0.38);
  --side-w: 236px;
  --notes-w: 350px;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  overflow: hidden;
  font: 15px/1.45 -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Inter, Roboto, system-ui, sans-serif;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}
/* Fondo con manchas de color para que el vidrio tenga algo que refractar */
body::before {
  content: "";
  position: fixed; inset: -10%;
  z-index: -1;
  background:
    radial-gradient(38% 42% at 12% 18%, rgba(56, 189, 248, 0.55), transparent 70%),
    radial-gradient(34% 40% at 88% 12%, rgba(244, 114, 182, 0.45), transparent 70%),
    radial-gradient(40% 46% at 78% 88%, rgba(129, 140, 248, 0.55), transparent 70%),
    radial-gradient(36% 40% at 18% 92%, rgba(52, 211, 153, 0.35), transparent 70%),
    linear-gradient(160deg, #0b1330, #121b3d 50%, #0b1129);
  filter: saturate(120%);
}

svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; }
button { font: inherit; color: inherit; }
[hidden] { display: none !important; }

.glass {
  background: linear-gradient(140deg, rgba(255,255,255,.15), rgba(255,255,255,.05));
  backdrop-filter: var(--blur);
  -webkit-backdrop-filter: var(--blur);
  border: 1px solid var(--stroke);
  border-radius: var(--radius);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.35), inset 0 -1px 0 rgba(255,255,255,.06), var(--shadow);
}
.glass-strong {
  background: linear-gradient(150deg, rgba(40, 52, 96, .82), rgba(20, 28, 58, .86));
  backdrop-filter: var(--blur);
  -webkit-backdrop-filter: var(--blur);
  border: 1px solid var(--stroke);
  border-radius: 24px;
  box-shadow: inset 0 1px 0 rgba(255,255,255,.3), 0 24px 70px rgba(0,0,0,.5);
}

/* ---------- estructura ---------- */
.shell { height: 100dvh; display: flex; flex-direction: column; gap: 10px; padding: 10px; }
.workspace { flex: 1; display: flex; gap: 10px; min-height: 0; }

.topbar { display: flex; align-items: center; gap: 10px; padding: 7px 10px; min-height: 54px; }
.brand { display: flex; align-items: center; gap: 9px; font-weight: 700; letter-spacing: .12em; font-size: 15px; white-space: nowrap; }
.brand img { border-radius: 8px; }
.current { flex: 1; min-width: 0; display: flex; align-items: center; gap: 8px; color: var(--text-2); font-size: 14px; overflow: hidden; }
.current .sep { opacity: .5; }
.current .crumb-logo { width: 24px; height: 24px; border-radius: 7px; font-size: 10px; }
.current .name { color: var(--text); font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.actions { display: flex; align-items: center; gap: 6px; }

.icon-btn, .chip, .btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  border: 1px solid var(--stroke-soft);
  background: rgba(255,255,255,.08);
  border-radius: 999px;
  cursor: pointer;
  transition: background .15s, border-color .15s, transform .1s, color .15s;
}
.icon-btn { width: 38px; height: 38px; padding: 0; }
.chip { height: 38px; padding: 0 14px; font-size: 14px; white-space: nowrap; }
.btn { height: 38px; padding: 0 16px; font-size: 14px; font-weight: 500; }
.btn.small { height: 32px; padding: 0 12px; font-size: 13px; }
.btn.block { width: 100%; }
.icon-btn:hover, .chip:hover, .btn:hover { background: var(--glass-hi); border-color: var(--stroke); }
.icon-btn:active, .chip:active, .btn:active { transform: scale(.97); }
.chip[aria-pressed="true"] { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); font-weight: 600; }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); font-weight: 600; }
.btn.primary:hover { background: #a5e3fd; }
.btn.ghost { background: transparent; }
.btn.danger, .icon-btn.danger { color: var(--danger); }
.btn.danger:hover { background: rgba(253,164,175,.14); border-color: rgba(253,164,175,.4); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---------- menú lateral ---------- */
.sidebar { width: var(--side-w); display: flex; flex-direction: column; padding: 10px; gap: 6px; transition: width .2s ease; min-height: 0; }
.app-list { flex: 1; display: flex; flex-direction: column; gap: 4px; overflow-y: auto; min-height: 0; scrollbar-width: thin; }
.side-item {
  display: flex; align-items: center; gap: 11px; width: 100%;
  padding: 8px 9px; border-radius: 14px; border: 1px solid transparent;
  background: transparent; text-align: left; cursor: pointer; font-size: 14.5px; font-weight: 500;
  transition: background .15s, border-color .15s;
}
.side-item:hover { background: rgba(255,255,255,.09); }
.side-item.active { background: rgba(255,255,255,.2); border-color: rgba(255,255,255,.3); box-shadow: inset 0 1px 0 rgba(255,255,255,.3); }
.side-item .label { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.side-item .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--ok); box-shadow: 0 0 0 3px rgba(134,239,172,.2); flex: none; }
.side-settings { color: var(--text-2); border-top: 1px solid var(--stroke-soft); border-radius: 0 0 14px 14px; padding-top: 12px; }
.logo {
  width: 32px; height: 32px; border-radius: 10px; flex: none; overflow: hidden;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 700; color: #fff; letter-spacing: .02em;
  background: rgba(255,255,255,.9);
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.4);
}
.logo img { width: 100%; height: 100%; object-fit: contain; }
.logo.initials { background: var(--c, #64748b); }
.logo-plain { background: rgba(255,255,255,.1); color: var(--text); }
.logo.big { width: 64px; height: 64px; border-radius: 18px; font-size: 20px; }

body.side-collapsed .sidebar { width: 70px; }
body.side-collapsed .side-item { justify-content: center; padding: 8px 0; }
body.side-collapsed .side-item .label, body.side-collapsed .side-item .dot { display: none; }

/* ---------- área principal ---------- */
.stage { flex: 1; position: relative; min-width: 0; overflow: hidden; padding: 8px; }
.frames { position: absolute; inset: 8px; }
.frame-host { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; overflow: hidden; }
.frame-host:not(.active) { visibility: hidden; pointer-events: none; }
.device {
  position: relative; width: 100%; height: 100%;
  background: #fff; border-radius: 14px; overflow: hidden; flex: none;
  transition: width .25s ease, height .25s ease, border-radius .25s ease, transform .25s ease;
}
.device iframe { width: 100%; height: 100%; border: 0; display: block; background: #fff; }
.frame-host.phone .device {
  width: 390px; height: 844px; border-radius: 46px;
  transform: scale(var(--s, 1));
  box-shadow: 0 0 0 11px #070b18, 0 0 0 12px rgba(255,255,255,.28), 0 30px 80px rgba(0,0,0,.55);
}
.phone-caption {
  position: absolute; left: 50%; bottom: 2px; transform: translateX(-50%);
  font-size: 12px; color: var(--text-3); white-space: nowrap; pointer-events: none;
}
.frame-host:not(.phone) .phone-caption { display: none; }
.frame-loading { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; color: #475569; font-size: 14px; background: #f8fafc; }
.frame-hint {
  position: absolute; right: 12px; bottom: 12px; z-index: 2;
  display: flex; align-items: center; gap: 10px; padding: 8px 8px 8px 14px; font-size: 13px;
  color: var(--text); border-radius: 999px;
  background: rgba(15, 23, 48, .82); backdrop-filter: var(--blur); border: 1px solid var(--stroke);
}

.placeholder { position: absolute; inset: 8px; display: flex; align-items: center; justify-content: center; text-align: center; padding: 24px; }
.placeholder .card { max-width: 480px; padding: 28px; }
.placeholder h2 { margin: 12px 0 8px; font-size: 22px; }
.placeholder p { color: var(--text-2); margin: 0 0 18px; }
.placeholder .row { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; }
.placeholder .reason { font-size: 13px; color: var(--text-3); margin-top: 14px; }

/* ---------- notas ---------- */
.notes { width: var(--notes-w); display: flex; flex-direction: column; gap: 10px; padding: 14px; min-height: 0; }
.notes-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
.eyebrow { font-size: 12px; text-transform: uppercase; letter-spacing: .1em; color: var(--text-3); }
.notes h2 { margin: 2px 0 0; font-size: 18px; }
.note-list { display: flex; flex-direction: column; gap: 6px; overflow-y: auto; max-height: 34%; min-height: 0; flex: none; scrollbar-width: thin; }
.note-item { text-align: left; padding: 9px 11px; border-radius: 12px; border: 1px solid var(--stroke-soft); background: rgba(255,255,255,.06); cursor: pointer; }
.note-item:hover { background: rgba(255,255,255,.11); }
.note-item.active { border-color: var(--accent); background: rgba(125,211,252,.12); }
.note-item b { display: block; font-weight: 600; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.note-item small { color: var(--text-3); font-size: 12px; }
.note-empty { color: var(--text-3); font-size: 14px; padding: 14px 4px; text-align: center; }
.note-editor { flex: 1; display: flex; flex-direction: column; gap: 8px; min-height: 0; }
.note-title, .note-body, .field input:not([type=radio]):not([type=file]), .input-row input {
  width: 100%; color: var(--text); font: inherit;
  background: rgba(5, 10, 30, .35); border: 1px solid var(--stroke-soft); border-radius: var(--radius-sm);
  padding: 10px 12px;
}
.note-title { font-weight: 600; font-size: 16px; }
.note-body { flex: 1; resize: none; min-height: 140px; line-height: 1.55; }
.note-title:focus, .note-body:focus, .field input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(125,211,252,.2); }
::placeholder { color: var(--text-3); }
.note-meta { display: flex; justify-content: space-between; gap: 8px; font-size: 12px; color: var(--text-3); flex-wrap: wrap; }
.save-state { display: inline-flex; align-items: center; gap: 5px; font-weight: 500; }
.save-state.ok { color: var(--ok); }
.save-state.busy { color: var(--warn); }
.save-state.err { color: var(--danger); }

/* ---------- ventanas ---------- */
.scrim { position: fixed; inset: 0; background: rgba(3, 6, 20, .45); z-index: 30; }
.overlay { position: fixed; inset: 0; z-index: 50; display: flex; align-items: center; justify-content: center; padding: 16px; background: rgba(3, 6, 20, .5); }
.settings { width: min(1100px, 100%); overflow-x: clip; height: min(760px, 100%); display: flex; flex-direction: column; overflow: hidden; }
.settings-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 16px 18px; border-bottom: 1px solid var(--stroke-soft); flex-wrap: wrap; }
.settings-head h2 { margin: 0; font-size: 20px; }
.settings-tools { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.settings-body { flex: 1; display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.25fr); min-height: 0; }
.settings-list { padding: 16px 18px; border-right: 1px solid var(--stroke-soft); overflow-y: auto; }
.settings-form { padding: 16px 20px; overflow-y: auto; }
.settings h3 { margin: 0; font-size: 16px; }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.hint { color: var(--text-3); font-size: 12.5px; margin: 6px 0 10px; display: block; }
.cfg-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.cfg-item { display: flex; align-items: center; gap: 10px; padding: 7px 8px; border-radius: 14px; border: 1px solid var(--stroke-soft); background: rgba(255,255,255,.05); }
.cfg-item.editing { border-color: var(--accent); background: rgba(125,211,252,.1); }
.cfg-item.dragging { opacity: .45; }
.cfg-item.drop-before { box-shadow: 0 -3px 0 var(--accent); }
.cfg-item .grip { cursor: grab; color: var(--text-3); display: flex; }
.cfg-item .info { flex: 1; min-width: 0; }
.cfg-item .info b { display: block; font-weight: 600; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cfg-item .info small { display: block; color: var(--text-3); font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cfg-item .icon-btn { width: 32px; height: 32px; }
.cfg-item .icon-btn svg { width: 16px; height: 16px; }
.badge { font-size: 11px; padding: 2px 8px; border-radius: 999px; background: rgba(252,211,77,.16); color: var(--warn); white-space: nowrap; }

.field { display: flex; flex-direction: column; gap: 6px; margin: 14px 0 0; font-size: 13.5px; color: var(--text-2); }
.field > span em { color: var(--text-3); font-style: normal; }
.input-row { display: flex; gap: 8px; align-items: center; }
.input-row input { flex: 1; min-width: 0; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.detect { font-size: 12.5px; color: var(--text-3); min-height: 18px; }
.detect.ok { color: var(--ok); }
.detect.warn { color: var(--warn); }
.detect.err { color: var(--danger); }
.logo-edit { display: flex; align-items: center; gap: 12px; }
.logo-actions { display: flex; flex-wrap: wrap; gap: 6px; }
.file-btn { position: relative; overflow: hidden; }
.file-btn input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.segmented { position: relative; display: inline-flex; padding: 3px; border-radius: 999px; background: rgba(5,10,30,.35); border: 1px solid var(--stroke-soft); width: max-content; }
.segmented input { position: absolute; opacity: 0; pointer-events: none; width: 1px; height: 1px; }
.segmented span { display: inline-block; padding: 6px 16px; border-radius: 999px; cursor: pointer; color: var(--text-2); font-size: 14px; }
.segmented input:checked + span { background: var(--accent); color: var(--accent-ink); font-weight: 600; }
.segmented input:focus-visible + span { outline: 2px solid var(--accent); }
.form-error { color: var(--danger); font-size: 13.5px; min-height: 20px; margin: 14px 0 4px; }
.form-actions { display: flex; gap: 8px; align-items: center; }
.sp { flex: 1; }

.dialog { width: min(520px, 100%); max-height: min(86vh, 760px); display: flex; flex-direction: column; padding: 20px; gap: 12px; overflow: hidden; }
.dialog h2 { margin: 0; font-size: 19px; }
.dialog p { margin: 0; color: var(--text-2); }
.dialog .scroll { overflow-y: auto; min-height: 0; flex: 1; }
.dialog .actions-row { display: flex; justify-content: flex-end; gap: 8px; flex-wrap: wrap; }
.dialog.wide { width: min(760px, 100%); }
.cred-row { display: flex; align-items: center; gap: 8px; padding: 10px 12px; border-radius: 14px; background: rgba(5,10,30,.35); border: 1px solid var(--stroke-soft); }
.cred-row .k { color: var(--text-3); font-size: 12px; width: 82px; flex: none; }
.cred-row .v { flex: 1; min-width: 0; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cred-row .icon-btn { width: 34px; height: 34px; }
.tree details { margin-left: 6px; }
.tree summary { cursor: pointer; padding: 5px 4px; border-radius: 8px; font-weight: 500; }
.tree summary:hover { background: rgba(255,255,255,.07); }
.tree .bm { display: flex; align-items: center; gap: 8px; padding: 4px 6px 4px 22px; font-size: 13.5px; border-radius: 8px; cursor: pointer; }
.tree .bm:hover { background: rgba(255,255,255,.06); }
.tree .bm span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tree .bm small { color: var(--text-3); }
.tree .count { color: var(--text-3); font-weight: 400; font-size: 12px; }

.toast {
  position: fixed; left: 50%; bottom: 22px; transform: translateX(-50%); z-index: 80;
  padding: 10px 18px; border-radius: 999px; font-size: 14px;
  background: rgba(15, 23, 48, .9); backdrop-filter: var(--blur); border: 1px solid var(--stroke); box-shadow: var(--shadow);
  max-width: calc(100vw - 32px);
}

.only-mobile { display: none !important; }

/* ---------- pantallas medianas ---------- */
@media (max-width: 1180px) {
  .chip span { display: none; }
  .chip { width: 38px; padding: 0; }
}

/* ---------- teléfono ---------- */
@media (max-width: 760px) {
  :root { --notes-w: 100%; }
  .only-mobile { display: inline-flex !important; }
  .only-desktop, #btnPhone, #btnReload { display: none !important; }
  .shell { padding: 6px; gap: 6px; padding-top: max(6px, env(safe-area-inset-top)); }
  .topbar { gap: 6px; padding: 6px; border-radius: 18px; }
  .brand span { font-size: 13px; letter-spacing: .08em; }
  .brand img { width: 22px; height: 22px; }
  .current .sep, .current .crumb-logo { display: none; }
  .current { font-size: 13px; }
  .actions { gap: 4px; }
  .icon-btn, .chip { width: 36px; height: 36px; }
  .sidebar {
    position: fixed; z-index: 40; top: 6px; bottom: 6px; left: 6px; width: min(300px, 82vw);
    transform: translateX(calc(-100% - 20px)); transition: transform .25s ease;
    background: linear-gradient(150deg, rgba(40, 52, 96, .9), rgba(20, 28, 58, .92));
  }
  body.menu-open .sidebar { transform: none; }
  body.side-collapsed .sidebar { width: min(300px, 82vw); }
  body.side-collapsed .side-item { justify-content: flex-start; padding: 8px 9px; }
  body.side-collapsed .side-item .label, body.side-collapsed .side-item .dot { display: initial; }
  .stage { padding: 0; border-radius: 16px; }
  .frames, .placeholder { inset: 0; }
  .device { border-radius: 16px; }
  .notes {
    position: fixed; z-index: 40; left: 6px; right: 6px; bottom: 6px; top: 22vh;
    background: linear-gradient(150deg, rgba(40, 52, 96, .94), rgba(20, 28, 58, .96));
    border-radius: 24px 24px 20px 20px;
  }
  .settings { height: 100%; border-radius: 20px; }
  .settings-body { grid-template-columns: 1fr; overflow-y: auto; }
  .settings-list { border-right: 0; border-bottom: 1px solid var(--stroke-soft); overflow: visible; }
  .settings-form { overflow: visible; }
  .grid-2 { grid-template-columns: 1fr; gap: 0; }
  .overlay { padding: 6px; }
  .frame-hint { left: 8px; right: 8px; bottom: 8px; justify-content: space-between; }
  .frame-hint > span { display: none; }
  .settings-tools .btn { height: 34px; padding: 0 12px; font-size: 13px; }
}

/* ---------- inicio de sesión ---------- */
.login-wrap { min-height: 100dvh; display: flex; align-items: center; justify-content: center; padding: 16px; }
.login { width: min(380px, 100%); padding: 32px 28px; display: flex; flex-direction: column; align-items: center; gap: 10px; text-align: center; }
.login h1 { margin: 6px 0 0; font-size: 24px; letter-spacing: .12em; }
.login p { margin: 0; color: var(--text-2); }
.login input { width: 100%; margin-top: 8px; color: var(--text); font: inherit; background: rgba(5, 10, 30, .35); border: 1px solid var(--stroke-soft); border-radius: var(--radius-sm); padding: 12px 14px; }
.login input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(125,211,252,.2); }
.login .form-error { margin: 0; min-height: 20px; }

.check { display: flex; align-items: flex-start; gap: 10px; margin-top: 16px; font-size: 14px; color: var(--text-2); cursor: pointer; }
.check input { width: 18px; height: 18px; margin: 1px 0 0; accent-color: var(--accent); flex: none; }
.check em { color: var(--text-3); font-style: normal; }

/* ---------- grupos del menú ---------- */
.group { display: flex; flex-direction: column; gap: 2px; }
.group-head .count { font-size: 12px; color: var(--text-3); background: rgba(255,255,255,.1); border-radius: 999px; padding: 1px 8px; }
.group-head svg { width: 16px; height: 16px; color: var(--text-3); }
.group.open > .group-head { background: rgba(255,255,255,.07); }
.group-items { display: flex; flex-direction: column; gap: 2px; margin-left: 14px; padding-left: 8px; border-left: 1px solid var(--stroke-soft); }
.group-empty { margin: 4px 8px; font-size: 12.5px; color: var(--text-3); }
.logo.group-logo { border-radius: 50%; }
body.side-collapsed .group-items { margin-left: 0; padding-left: 0; border-left: 0; }
body.side-collapsed .group-head .count, body.side-collapsed .group-head svg { display: none; }
.cfg-group { display: flex; justify-content: space-between; align-items: center; margin: 12px 4px 2px; padding: 4px 6px; font-size: 12px; text-transform: uppercase; letter-spacing: .08em; color: var(--text-3); border-radius: 8px; list-style: none; }
.cfg-group:first-child { margin-top: 0; }
.cfg-group.drop-into { background: rgba(125,211,252,.16); color: var(--accent); }
.field select { width: 100%; color: var(--text); font: inherit; background: rgba(5, 10, 30, .35); border: 1px solid var(--stroke-soft); border-radius: var(--radius-sm); padding: 10px 12px; }
.field select option { background: #1b2546; }
@media (max-width: 760px) { body.side-collapsed .group-items { margin-left: 14px; padding-left: 8px; border-left: 1px solid var(--stroke-soft); } body.side-collapsed .group-head .count, body.side-collapsed .group-head svg { display: initial; } }
