/* TonwyMail · Sistema de Diseño Unificado Tonwy Studio */
:root {
  color-scheme: light;
  --bg: #f5f7f3;
  --surface: #ffffff;
  --surface-2: #f6f7fb;
  --line: #e6e8ef;
  --line-strong: #d4d8e3;
  --text: #0b0d12;
  --text-2: #52525b;
  --muted: #71717a;
  --accent: #1E3F20;
  --accent-2: #2D5F30;
  --accent-soft: #ecf4ec;
  --grad: linear-gradient(120deg, var(--accent), var(--accent-2));
  --danger: #e11d48;
  --ok: #059669;
  --radius: 16px;
  --radius-sm: 12px;
  --shadow: 0 2px 10px rgba(15, 23, 42, .035);
  --shadow-lg: 0 24px 60px -20px rgba(15, 23, 42, .22);
  --font: "Plus Jakarta Sans", "Inter", ui-sans-serif, system-ui, -apple-system, sans-serif;
  --display: "Plus Jakarta Sans", "Inter", ui-sans-serif, system-ui, -apple-system, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  height: 100%;
}

body {
  font: 14px/1.5 var(--font);
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

svg {
  width: 16px;
  height: 16px;
  flex: none;
}

::selection {
  background: rgba(30, 63, 32, .18);
}

/* Controles */
button {
  font: 500 13px/1 var(--font);
  cursor: pointer;
  color: var(--text-2);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 9px 14px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  transition: border-color .15s, color .15s, background .15s, box-shadow .15s, transform .05s;
}

button:hover {
  border-color: var(--line-strong);
  color: var(--text);
}

button:active {
  transform: translateY(1px);
}

button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(30, 63, 32, .15);
}

button.primary {
  background: var(--text);
  color: #fff;
  border-color: var(--text);
}

button.primary:hover {
  background: #1f2738;
  color: #fff;
}

button.danger {
  color: var(--danger);
}

button.danger:hover {
  border-color: var(--danger);
}

button.link {
  border: 0;
  background: none;
  padding: 2px 6px;
  font-size: 15px;
  color: var(--muted);
  border-radius: 6px;
}

button.link:hover {
  background: var(--surface-2);
  color: var(--accent);
}

input,
select,
textarea {
  font: 14px var(--font);
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 9px 11px;
  width: 100%;
  transition: border-color .15s, box-shadow .15s;
}

input::placeholder,
textarea::placeholder {
  color: var(--muted);
}

textarea {
  resize: vertical;
  line-height: 1.55;
}

kbd {
  font: 500 11px var(--mono);
  color: var(--muted);
  border: 1px solid var(--line);
  border-radius: 5px;
  padding: 1px 6px;
  background: var(--surface-2);
}

/* Layout: paneles flotantes */
.app {
  display: grid;
  grid-template-columns: 248px 400px 1fr;
  gap: 10px;
  height: 100vh;
  padding: 10px;
}

.sidebar,
.list-pane,
.reader {
  background: rgba(255, 255, 255, .82);
  backdrop-filter: blur(14px);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  min-width: 0;
}

/* Sidebar */
.sidebar {
  display: flex;
  flex-direction: column;
  padding: 16px 10px;
  overflow-y: auto;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font: 600 15px var(--display);
  letter-spacing: .14em;
  padding: 2px 8px 18px;
}

.brand .slash {
  color: var(--accent);
  margin: 0 -6px;
}

.brand-logo {
  width: 28px;
  height: 28px;
  object-fit: contain;
  display: block;
  flex: none;
  filter: drop-shadow(0 3px 8px rgba(15, 76, 255, .28));
}

.mark {
  width: 22px;
  height: 22px;
  border-radius: 7px;
  background: var(--grad);
  box-shadow: 0 4px 12px -2px rgba(30, 63, 32, .45), inset 0 0 0 1px rgba(255, 255, 255, .25);
  position: relative;
}

.mark::after {
  content: "";
  position: absolute;
  inset: 6px 5px;
  border: 1.5px solid #fff;
  border-top-color: transparent;
  border-radius: 0 0 3px 3px;
}

.compose {
  justify-content: center;
  margin: 0 4px 16px;
  padding: 11px;
}

.sidebar h4 {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin: 20px 8px 6px;
  font: 500 10.5px var(--mono);
  text-transform: uppercase;
  letter-spacing: .14em;
  color: var(--muted);
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  margin: 1px 0;
  border-radius: var(--radius-sm);
  cursor: pointer;
  white-space: nowrap;
  color: var(--text-2);
  position: relative;
  transition: background .15s, color .15s;
}

.nav-item svg {
  color: var(--muted);
}

.nav-item:hover {
  background: var(--surface-2);
  color: var(--text);
}

.nav-item.active {
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 600;
}

.nav-item.active svg {
  color: var(--accent);
}

.nav-item.active::before {
  content: "";
  position: absolute;
  left: -10px;
  top: 8px;
  bottom: 8px;
  width: 3px;
  border-radius: 0 3px 3px 0;
  background: var(--grad);
}

.nav-item .label {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
}

.nav-item .edit {
  opacity: 0;
  color: var(--muted);
  font-weight: 700;
  padding: 0 2px;
}

.nav-item:hover .edit {
  opacity: 1;
}

.nav-item .edit:hover {
  color: var(--accent);
}

.dot {
  width: 8px;
  height: 8px;
  border-radius: 3px;
  flex: none;
  background: var(--c);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--c) 18%, transparent);
  margin: 0 4px;
}

.badge {
  margin-left: auto;
  font: 700 11px var(--font);
  color: #ffffff;
  background: #ef4444;
  border: 1px solid #dc2626;
  border-radius: 999px;
  padding: 1px 7px;
  min-width: 20px;
  text-align: center;
  box-shadow: 0 2px 5px rgba(239, 68, 68, .3);
}

.badge:empty {
  display: none !important;
}

.nav-more-toggle {
  border-radius: 999px;
  color: var(--text-2);
  font-weight: 500;
  margin-top: 2px;
  user-select: none;
}

.nav-more-toggle:hover {
  background: rgba(15, 23, 42, .06);
  color: var(--text);
}

.nav-more-toggle svg {
  width: 16px;
  height: 16px;
  transition: transform .18s ease;
}

.nav-more-toggle[aria-expanded="true"] svg {
  transform: rotate(180deg);
}

.nav-more-drawer[hidden] {
  display: none !important;
}

.nav-more-drawer {
  display: flex;
  flex-direction: column;
  padding-top: 1px;
}

.badge.muted {
  color: var(--text-2);
  background: var(--surface-2);
  border-color: var(--line);
}

.err {
  color: var(--danger);
  font-size: 11px;
  white-space: normal;
}

.sidebar-footer {
  margin-top: auto;
  padding: 16px 4px 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
  font: 11px var(--mono);
  color: var(--muted);
}

.sidebar-footer button {
  justify-content: center;
  background: var(--surface-2);
}

.hint {
  font-size: 12px;
  color: var(--muted);
}

/* Lista */
.list-pane {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.toolbar {
  padding: 12px;
  border-bottom: 1px solid var(--line);
  display: flex;
  gap: 8px;
  align-items: center;
}

.search {
  position: relative;
  display: flex;
  align-items: center;
  flex: 1;
}

.mobile-only {
  display: none;
}

.icon-btn {
  padding: 9px 10px;
  flex: none;
}

.sidebar-backdrop {
  display: none;
}

.search svg {
  position: absolute;
  left: 11px;
  color: var(--muted);
}

.search input {
  padding-left: 34px;
  padding-right: 40px;
  background: var(--surface-2);
}

.search input:focus {
  background: var(--surface);
}

.search kbd {
  position: absolute;
  right: 9px;
}

.list-header {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.list-title {
  padding: 12px 16px 6px;
  font: 500 10.5px var(--mono);
  text-transform: uppercase;
  letter-spacing: .14em;
  color: var(--muted);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}

.list-title-left {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.mail-check {
  width: 14px;
  height: 14px;
  margin: 0;
  cursor: pointer;
  accent-color: var(--accent);
  flex: none;
  border-radius: 4px;
}

.bulk-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  flex-wrap: wrap;
  margin: 0 10px 6px;
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  background: var(--accent-soft);
  border: 1px solid rgba(30, 63, 32, .2);
}

.bulk-bar .bulk-info {
  font: 600 11.5px var(--mono);
  color: var(--accent);
  display: flex;
  align-items: center;
  gap: 8px;
}

.bulk-bar .bulk-actions {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-wrap: wrap;
}

.bulk-bar button {
  padding: 4px 8px;
  font: 500 11.5px var(--font);
  border-radius: 6px;
}

.item.checked {
  background: var(--accent-soft);
  border-color: rgba(30, 63, 32, .22);
}

.folder-tabs {
  display: flex;
  gap: 4px;
  padding: 0 12px 8px;
  overflow-x: auto;
}

.folder-tabs .tab {
  padding: 4px 9px;
  font: 500 11px var(--mono);
  border-radius: 6px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--muted);
}

.folder-tabs .tab:hover {
  background: var(--surface-2);
  color: var(--text);
}

.folder-tabs .tab.active {
  background: var(--accent-soft);
  color: var(--accent);
  border-color: rgba(30, 63, 32, .18);
}

.list {
  overflow-y: auto;
  flex: 1;
  padding: 0 8px 8px;
}

.item {
  padding: 11px 12px 11px 20px;
  margin-bottom: 2px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  position: relative;
  border: 1px solid transparent;
  transition: background .12s, border-color .12s;
}

.item:hover {
  background: var(--surface-2);
}

.item.selected {
  background: var(--surface);
  border-color: var(--line-strong);
  box-shadow: var(--shadow);
}

.item.selected::after {
  content: "";
  position: absolute;
  left: 0;
  top: 10px;
  bottom: 10px;
  width: 2px;
  border-radius: 2px;
  background: var(--grad);
}

.item .row {
  display: flex;
  gap: 8px;
  align-items: center;
}

.item .from {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--text-2);
}

.item .date {
  font: 11px var(--mono);
  color: var(--muted);
  flex: none;
}

.item .subject {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--muted);
  font-size: 13px;
}

.item.unread .from {
  font-weight: 600;
  color: var(--text);
}

.item.unread .subject {
  color: var(--text-2);
  font-weight: 500;
}

.item.unread::before {
  content: "";
  position: absolute;
  left: 7px;
  top: 18px;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 3px rgba(30, 63, 32, .15);
}

.tags {
  display: flex;
  gap: 6px;
  margin-top: 6px;
  flex-wrap: wrap;
  align-items: center;
}

.tag {
  font: 500 11px var(--font);
  padding: 1px 8px 1px 7px;
  border-radius: 6px;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  color: color-mix(in srgb, var(--c) 75%, #121826);
  background: color-mix(in srgb, var(--c) 10%, #fff);
  border: 1px solid color-mix(in srgb, var(--c) 22%, #fff);
}

.tag::before {
  content: "";
  width: 5px;
  height: 5px;
  border-radius: 2px;
  background: var(--c);
}

.acc-tag {
  font: 11px var(--mono);
  color: var(--muted);
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.clip-icon {
  color: var(--muted);
  display: inline-flex;
  align-items: center;
}

.clip-icon svg {
  width: 13px;
  height: 13px;
}

.star {
  cursor: pointer;
  color: var(--line-strong);
  font-size: 14px;
  line-height: 1;
  transition: color .15s;
}

.star:hover {
  color: var(--muted);
}

.star.on {
  color: #f2a516;
}

/* Lector */
.reader {
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}

.empty {
  margin: auto;
  color: var(--muted);
  font: 12px var(--mono);
  letter-spacing: .04em;
  text-align: center;
}

.reader-head {
  padding: 26px 30px 18px;
  border-bottom: 1px solid var(--line);
}

.reader-head h2 {
  margin: 0 0 14px;
  font: 600 22px/1.3 var(--display);
  letter-spacing: -.01em;
}

.meta {
  color: var(--text-2);
  font-size: 13px;
}

.meta+.meta {
  color: var(--muted);
  font: 12px var(--mono);
  margin-top: 3px;
}

.reader-head .tags {
  margin-top: 10px;
}

.actions {
  display: flex;
  gap: 6px;
  margin-top: 18px;
  flex-wrap: wrap;
  align-items: center;
}

.actions .spacer {
  flex: 1;
}

.reader-body {
  padding: 26px 30px;
  flex: 1;
}

.reader-body pre {
  white-space: pre-wrap;
  font: 15px/1.7 var(--font);
  color: var(--text);
  margin: 0;
  max-width: 72ch;
}

.reader-body iframe {
  width: 100%;
  border: 1px solid var(--line);
  min-height: 70vh;
  background: #fff;
  border-radius: var(--radius-sm);
}

.attach {
  margin-top: 18px;
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.attach span,
.attach a {
  text-decoration: none;
  border: 1px solid var(--line);
  background: var(--surface-2);
  border-radius: var(--radius-sm);
  padding: 6px 11px;
  font: 12px var(--mono);
  color: var(--text-2);
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: border-color .15s, color .15s, background .15s;
}

.attach a:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-soft);
}

/* Modales */
dialog {
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 0;
  background: var(--surface);
  color: var(--text);
  width: min(650px, 94vw);
  box-shadow: var(--shadow-lg);
}

dialog[open] {
  animation: pop .18s ease-out;
}

@keyframes pop {
  from {
    opacity: 0;
    transform: translateY(6px) scale(.99);
  }
}

dialog::backdrop {
  background: rgba(238, 241, 246, .6);
  backdrop-filter: blur(6px);
}

dialog form {
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

dialog h3 {
  margin: 0 0 4px;
  font: 600 18px var(--display);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.grid2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.grid3 {
  display: grid;
  grid-template-columns: 2fr 1fr 1fr;
  gap: 8px;
  align-items: center;
}

fieldset {
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 12px;
  background: var(--surface-2);
  margin: 0;
}

legend {
  font: 500 10.5px var(--mono);
  text-transform: uppercase;
  letter-spacing: .12em;
  color: var(--muted);
  padding: 0 6px;
}

label.check {
  display: flex;
  gap: 6px;
  align-items: center;
  font-size: 13px;
  white-space: nowrap;
  color: var(--text-2);
}

label.check input {
  width: auto;
  accent-color: var(--accent);
}

input[type=color] {
  padding: 3px;
  height: 38px;
  cursor: pointer;
}

.form-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  margin-top: 8px;
  align-items: center;
  flex-wrap: wrap;
}

.form-actions .left {
  margin-right: auto;
}

.rule {
  display: grid;
  grid-template-columns: 170px 1fr auto;
  gap: 6px;
}

.msg {
  font: 12px var(--mono);
}

.msg.ok {
  color: var(--ok);
}

.msg.bad {
  color: var(--danger);
}

.compose-Attachments {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.att-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 4px 9px;
  font: 11.5px var(--mono);
  color: var(--text-2);
}

.att-chip button {
  border: 0;
  background: none;
  padding: 0 2px;
  color: var(--muted);
  font-size: 13px;
}

.att-chip button:hover {
  color: var(--danger);
}

.toast {
  position: fixed;
  bottom: 20px;
  right: 20px;
  background: var(--text);
  color: #fff;
  padding: 10px 16px;
  border-radius: var(--radius-sm);
  font: 500 12.5px var(--font);
  box-shadow: var(--shadow-lg);
  z-index: 9999;
}

.login-screen {
  position: fixed;
  inset: 0;
  z-index: 9500;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(238, 241, 246, .82);
  backdrop-filter: blur(12px);
}

.login-screen[hidden] {
  display: none;
}

.login-card {
  width: min(380px, 92vw);
  padding: 28px 24px;
  border-radius: 18px;
  background: var(--surface);
  border: 1px solid var(--line);
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* Resumen diario (Digest) y Campañas */
@media (min-width: 901px) {
  body.campaigns-view .app {
    grid-template-columns: 248px 1fr;
  }

  body.campaigns-view .list-pane {
    display: none;
  }
}

body.campaigns-view .reader {
  display: flex !important;
}

.digest-view,
.digest-wrap {
  padding: 26px 30px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.digest-head,
.digest-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  flex-wrap: wrap;
}

.digest-head h2,
.digest-header h2 {
  margin: 0 0 4px;
  font: 600 22px var(--display);
  letter-spacing: -.01em;
}

.digest-header .sub {
  font-size: 13px;
  color: var(--text-2);
}

.digest-list {
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  overflow: hidden;
}

.digest-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--line);
  cursor: pointer;
  font-size: 13px;
  transition: background .12s;
}

.digest-row:last-child {
  border-bottom: 0;
}

.digest-row:hover {
  background: var(--accent-soft);
}

.digest-row .from {
  font-weight: 600;
  white-space: nowrap;
}

.digest-row .subj {
  flex: 1;
  color: var(--text-2);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.digest-row .dt {
  font: 11px var(--mono);
  color: var(--muted);
}

.digest-proj-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  overflow: hidden;
  box-shadow: var(--shadow);
}

.digest-proj-card .head {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 11px 14px;
  background: var(--surface-2);
  border-bottom: 1px solid var(--line);
  font-size: 13px;
}

.digest-proj-card .head .stats {
  margin-left: auto;
  font: 11.5px var(--mono);
  color: var(--text-2);
}

.digest-config-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  padding: 14px 16px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
}

.digest-config-bar input[type=time],
.digest-config-bar input[type=email] {
  width: auto;
}

.digest-kpis {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(135px, 1fr));
  gap: 10px;
}

.digest-kpi {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 14px 16px;
  box-shadow: var(--shadow);
  position: relative;
}

.digest-kpi.kpi-clickable {
  cursor: pointer;
  user-select: none;
  transition: transform .14s ease, border-color .14s ease, box-shadow .14s ease, background .14s ease;
}

.digest-kpi.kpi-clickable:hover {
  transform: translateY(-2px);
  border-color: var(--kpi-color, var(--accent));
  box-shadow: 0 6px 18px rgba(15, 23, 42, .08);
}

.digest-kpi.kpi-active {
  border: 2px solid var(--kpi-color, var(--accent));
  background: var(--kpi-bg, var(--accent-soft));
  box-shadow: 0 6px 18px rgba(15, 23, 42, .09);
}

.digest-kpi .kpi-pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font: 600 10px var(--mono);
  padding: 2px 7px;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--muted);
  border: 1px solid var(--line);
  margin-top: 6px;
}

.digest-kpi.kpi-active .kpi-pill {
  background: var(--kpi-color, var(--accent));
  color: #fff;
  border-color: transparent;
}

.digest-kpi .num {
  font: 600 24px var(--display);
  color: var(--text);
}

.digest-kpi .num.accent { color: var(--accent); }
.digest-kpi .num.danger { color: var(--danger); }
.digest-kpi .lbl {
  font: 500 11px var(--mono);
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .08em;
  margin-top: 2px;
}

.digest-section h3 {
  margin: 0 0 10px;
  font: 600 11.5px var(--mono);
  text-transform: uppercase;
  letter-spacing: .12em;
  color: var(--muted);
}

.digest-proj-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 10px;
}

.digest-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  cursor: pointer;
  transition: border-color .15s, box-shadow .15s;
}

.digest-card:hover {
  border-color: var(--accent);
  box-shadow: var(--shadow);
}

.digest-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  margin-bottom: 6px;
  cursor: pointer;
  transition: border-color .15s, background .15s;
}

.digest-item:hover {
  border-color: var(--accent);
  background: var(--accent-soft);
}

dialog form.drop-active {
  outline: 2px dashed var(--accent);
  outline-offset: -8px;
  background: var(--accent-soft);
}

/* Scrollbars discretas */
* {
  scrollbar-width: thin;
  scrollbar-color: var(--line-strong) transparent;
}

@media (max-width: 900px) {
  .app {
    grid-template-columns: 1fr;
    padding: 0;
    gap: 0;
    height: 100dvh;
  }

  .list-pane,
  .reader {
    border-radius: 0;
    border: 0;
    padding-top: env(safe-area-inset-top);
    padding-bottom: env(safe-area-inset-bottom);
  }

  .mobile-only {
    display: inline-flex;
  }

  .search kbd {
    display: none;
  }

  .sidebar {
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    width: min(286px, 84vw);
    z-index: 1001;
    border-radius: 0 18px 18px 0;
    background: rgba(255, 255, 255, .97);
    padding-top: calc(16px + env(safe-area-inset-top));
    padding-bottom: calc(16px + env(safe-area-inset-bottom));
    transform: translateX(-105%);
    transition: transform .22s cubic-bezier(.2, .8, .2, 1);
    box-shadow: var(--shadow-lg);
  }

  body.menu-open .sidebar {
    transform: translateX(0);
  }

  body.menu-open .sidebar-backdrop {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 1000;
    background: rgba(15, 23, 42, .35);
    backdrop-filter: blur(3px);
  }

  .reader {
    display: none;
  }

  body.reading .list-pane {
    display: none;
  }

  body.reading .reader {
    display: flex;
  }

  .reader-head {
    padding: 14px 16px 14px;
  }

  .reader-head h2 {
    font-size: 18px;
    margin-bottom: 10px;
  }

  .reader-head .back {
    display: inline-flex !important;
    align-items: center;
    gap: 6px;
    margin-bottom: 12px;
    padding: 7px 12px;
    background: var(--surface-2);
    border: 1px solid var(--line);
    border-radius: 8px;
    font: 600 12.5px var(--font);
    color: var(--text);
  }

  .reader-body {
    padding: 16px;
  }

  input,
  select,
  textarea {
    font-size: 16px;
  }

  .mail-check {
    width: 17px;
    height: 17px;
  }

  .nav-item {
    padding: 10px 12px;
    font-size: 14px;
  }

  .item {
    padding: 12px 12px 12px 18px;
  }

  dialog {
    width: 100vw;
    max-width: 100vw;
    max-height: 92dvh;
    margin: auto 0 0;
    border-radius: 20px 20px 0 0;
    overflow-y: auto;
  }

  dialog form {
    padding: 18px 16px calc(18px + env(safe-area-inset-bottom));
  }

  .grid2,
  .grid3 {
    grid-template-columns: 1fr;
  }

  .rule {
    grid-template-columns: 1fr auto;
  }

  .rule select {
    grid-column: 1 / -1;
  }
}

.accounts-drawer {
  margin-top: 12px;
  border-top: 1px solid var(--line);
  padding-top: 8px;
}

.accounts-drawer summary {
  list-style: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font: 600 11px var(--mono);
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--muted);
  user-select: none;
  transition: background .15s, color .15s;
}

.accounts-drawer summary::-webkit-details-marker {
  display: none;
}

.accounts-drawer summary:hover {
  background: var(--surface-2);
  color: var(--text-2);
}

.accounts-drawer[open] summary {
  color: var(--text);
  margin-bottom: 4px;
}

.brand-logo-wrap {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.brand-unread-badge {
  position: absolute;
  top: -5px;
  right: -6px;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 999px;
  background: #ef4444;
  color: #fff;
  font: 700 10.5px/18px var(--font);
  text-align: center;
  box-shadow: 0 2px 6px rgba(239, 68, 68, 0.45), 0 0 0 2px var(--surface);
  letter-spacing: 0;
  pointer-events: none;
}

.snooze-select {
  width: auto;
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  background: var(--surface-2);
  font: 500 12.5px var(--font);
  color: var(--text-2);
  cursor: pointer;
}

.snooze-select:hover {
  border-color: var(--accent);
  color: var(--text);
}

.thread-box {
  margin-top: 22px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
}

.thread-title {
  font: 600 11.5px var(--mono);
  text-transform: uppercase;
  letter-spacing: .1em;
  color: var(--muted);
  margin-bottom: 10px;
}

.thread-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.thread-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  font-size: 12.5px;
  cursor: pointer;
  transition: border-color .15s, background .15s;
}

.thread-item:hover {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.thread-item.current {
  border-color: var(--accent);
  background: var(--surface);
  font-weight: 600;
  cursor: default;
}

.thread-badge {
  font: 600 10.5px var(--mono);
  padding: 2px 7px;
  border-radius: 99px;
  white-space: nowrap;
}

.thread-badge.sent {
  background: #eff6ff;
  color: #1d4ed8;
}

.thread-badge.in {
  background: #f0fdf4;
  color: #15803d;
}

.thread-who {
  color: var(--text);
  white-space: nowrap;
}

.thread-count-pill {
  font: 600 11px var(--mono);
  color: var(--accent);
  background: var(--accent-soft);
  padding: 1px 6px;
  border-radius: 99px;
  margin-left: 3px;
}

.thread-head-pill {
  font: 600 11.5px var(--mono);
  color: var(--accent);
  background: var(--accent-soft);
  border: 1px solid rgba(30, 63, 32, .22);
  padding: 3px 9px;
  border-radius: 99px;
}

.thread-stack {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.thread-card {
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
  overflow: hidden;
  transition: border-color .15s, box-shadow .15s;
}

.thread-card.is-sent {
  border-color: #bfdbfe;
  background: #f8fbff;
}

.thread-card.is-current.expanded {
  border-color: rgba(30, 63, 32, .45);
  box-shadow: 0 3px 14px rgba(15, 76, 255, .07);
}

.thread-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 11px 15px;
  cursor: pointer;
  user-select: none;
  background: var(--surface-2);
}

.thread-card.is-sent .thread-card-head {
  background: #eff6ff;
}

.thread-card.expanded .thread-card-head {
  border-bottom: 1px solid var(--line);
}

.thread-card-left {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  flex: 1;
}

.thread-card-sender {
  font: 600 13.5px var(--font);
  color: var(--text);
  white-space: nowrap;
}

.thread-card-addr {
  font: 500 12px var(--mono);
  color: var(--muted);
  white-space: nowrap;
}

.thread-card-snippet {
  font-size: 12.5px;
  color: var(--text-2);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1;
}

.thread-card.expanded .thread-card-snippet {
  display: none;
}

.thread-card-right {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: none;
}

.thread-mini-reply {
  padding: 3px 7px;
  font-size: 12px;
  border-radius: 6px;
}

.thread-chevron {
  font-size: 12px;
  color: var(--muted);
  width: 14px;
  text-align: center;
}

.thread-card-body {
  padding: 14px 16px 16px;
  background: #ffffff;
}

.thread-card-submeta {
  font: 11.5px var(--mono);
  color: var(--muted);
  margin-bottom: 10px;
  padding-bottom: 8px;
  border-bottom: 1px dashed var(--line);
}

.thread-card-body .thread-frame {
  width: 100%;
  min-height: 80px;
  border: 0;
  background: #ffffff;
}

.thread-continue-bar {
  margin-top: 16px;
  padding: 14px 16px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 12px;
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.thread-date {
  font: 11px var(--mono);
  color: var(--muted);
  white-space: nowrap;
}

/* Editor HTML enriquecido en Redactar (compose) */
dialog:has(.html-composer) {
  width: min(840px, 96vw);
}

.html-composer {
  display: flex;
  flex-direction: column;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  overflow: hidden;
}

.html-composer-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 6px 10px;
  background: var(--surface-2);
  border-bottom: 1px solid var(--line);
  flex-wrap: wrap;
}

.html-mode-tabs {
  display: inline-flex;
  gap: 4px;
  background: var(--bg-2);
  padding: 3px;
  border-radius: 7px;
}

.html-mode-tab {
  border: 0;
  background: transparent;
  padding: 5px 10px;
  font: 600 11.5px var(--font);
  color: var(--text-2);
  border-radius: 5px;
  cursor: pointer;
}

.html-mode-tab:hover {
  color: var(--text);
  background: rgba(255, 255, 255, .6);
}

.html-mode-tab.active {
  background: var(--surface);
  color: var(--accent);
  box-shadow: var(--shadow-sm);
}

.html-brand-toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font: 600 11.5px var(--font);
  color: var(--text-2);
  cursor: pointer;
  user-select: none;
  padding: 4px 8px;
  border-radius: 6px;
  background: var(--surface);
  border: 1px solid var(--line);
}

.html-brand-toggle input {
  width: auto;
  margin: 0;
  accent-color: var(--accent);
}

.html-toolbar {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 6px 8px;
  background: #f8fafc;
  border-bottom: 1px solid var(--line);
  flex-wrap: wrap;
}

.html-toolbar button,
.html-toolbar .tb-btn {
  padding: 4px 8px;
  font: 600 12px var(--font);
  border-radius: 5px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  line-height: 1.2;
}

.html-toolbar button:hover,
.html-toolbar .tb-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-soft);
}

.html-toolbar .tb-sep {
  width: 1px;
  height: 18px;
  background: var(--line-strong);
  margin: 0 3px;
}

.html-toolbar input[type="color"] {
  width: 26px;
  height: 26px;
  padding: 1px;
  border-radius: 5px;
  border: 1px solid var(--line);
  cursor: pointer;
  background: var(--surface);
}

.html-editor-visual {
  min-height: 250px;
  max-height: 400px;
  overflow-y: auto;
  padding: 14px 16px;
  font: 14px/1.6 var(--font);
  color: #121826;
  background: #ffffff;
  outline: none;
}

.html-editor-visual:focus {
  box-shadow: inset 0 0 0 2px rgba(15, 76, 255, .12);
}

.html-editor-visual p {
  margin: 0 0 10px;
}

.html-editor-visual h2,
.html-editor-visual h3 {
  margin: 12px 0 6px;
  line-height: 1.3;
}

.html-editor-visual ul,
.html-editor-visual ol {
  margin: 6px 0 12px 20px;
  padding: 0;
}

.html-editor-visual blockquote {
  margin: 10px 0;
  padding: 8px 12px;
  border-left: 3px solid #cbd5e1;
  color: #475569;
  background: #f8fafc;
  border-radius: 0 6px 6px 0;
}

.html-editor-visual img {
  max-width: 100%;
  height: auto;
  border-radius: 6px;
}

.html-editor-code {
  min-height: 260px;
  max-height: 400px;
  width: 100%;
  border: 0 !important;
  border-radius: 0 !important;
  padding: 12px 14px;
  font: 12.5px/1.55 var(--mono);
  background: #0f172a;
  color: #e2e8f0;
  resize: vertical;
}

.html-editor-code:focus {
  box-shadow: none !important;
}

.html-preview-wrap {
  background: #f1f5f9;
  padding: 10px;
}

.html-preview-frame {
  width: 100%;
  min-height: 300px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
}

/* ---------- Campañas v28: Densidad Above-the-Fold, Tarjetas CRM y Cola Visual ---------- */
.sidebar h4.nav-sec-label {
  margin: 12px 8px 4px;
}

body.campaigns-view .digest-wrap {
  padding: 16px 22px !important;
  gap: 12px !important;
}

body.campaigns-view .digest-header {
  align-items: center;
  gap: 10px;
}

body.campaigns-view .digest-header h2 {
  font-size: 19.5px !important;
  margin: 0 0 2px !important;
  line-height: 1.25;
}

body.campaigns-view .digest-header .sub {
  font-size: 12.5px !important;
  line-height: 1.4;
}

body.campaigns-view .digest-kpis {
  grid-template-columns: repeat(4, minmax(170px, 1fr));
  gap: 10px;
}

@media (max-width: 1180px) {
  body.campaigns-view .digest-kpis {
    grid-template-columns: repeat(2, minmax(160px, 1fr));
  }
}

@media (max-width: 600px) {
  body.campaigns-view .digest-wrap {
    padding: 12px 14px !important;
    gap: 10px !important;
  }

  body.campaigns-view .digest-kpis {
    grid-template-columns: 1fr;
  }
}

body.campaigns-view .digest-kpi {
  padding: 11px 14px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

body.campaigns-view .digest-kpi .num {
  font-size: 21px;
  line-height: 1.18;
  display: flex;
  align-items: center;
  gap: 7px;
  flex-wrap: wrap;
}

body.campaigns-view .digest-kpi .lbl {
  font-size: 10.5px;
  margin-top: 3px;
}

body.campaigns-view .digest-kpi .kpi-pill {
  margin-top: 5px;
  align-self: flex-start;
}

.camp-rate-badge {
  font: 700 11px var(--mono);
  padding: 2px 7px;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--text-2);
  border: 1px solid var(--line);
  white-space: nowrap;
}

/* Tira CRM de respuestas de campaña */
.camp-replies-strip {
  background: linear-gradient(180deg, #f0fdf4 0%, #ecfdf5 100%);
  border: 1.5px solid #6ee7b7;
  border-radius: 12px;
  padding: 10px 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  box-shadow: 0 3px 12px rgba(16, 185, 129, .07);
}

.camp-replies-strip.is-muted {
  background: var(--surface);
  border: 1px solid var(--line);
  box-shadow: none;
  padding: 8px 14px;
}

.camp-replies-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.camp-replies-head-left,
.camp-replies-head-right {
  display: flex;
  align-items: center;
  gap: 7px;
  flex-wrap: wrap;
}

.camp-reply-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(330px, 1fr));
  gap: 10px;
  max-height: 262px;
  overflow-y: auto;
  padding-right: 3px;
}

@media (max-width: 600px) {
  .camp-reply-grid {
    grid-template-columns: 1fr;
    max-height: 320px;
  }
}

.camp-reply-card {
  background: #ffffff;
  border: 1px solid #a7f3d0;
  border-radius: 10px;
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 7px;
  min-width: 0;
  transition: border-color .15s, box-shadow .15s;
}

.camp-reply-card:hover {
  border-color: #10b981;
  box-shadow: 0 4px 12px rgba(16, 185, 129, .10);
}

.camp-reply-card.is-unsub {
  background: #fffafa;
  border-color: #fca5a5;
}

.camp-reply-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-width: 0;
}

.camp-reply-title {
  font: 700 13.5px/1.25 var(--font);
  color: #064e3b;
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.camp-reply-card.is-unsub .camp-reply-title {
  color: #991b1b;
}

.camp-reply-meta {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  flex: none;
}

.camp-reply-city {
  font: 600 10.5px var(--mono);
  color: #047857;
  background: #ecfdf5;
  padding: 1px 6px;
  border-radius: 5px;
  border: 1px solid #a7f3d0;
  max-width: 120px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.camp-reply-date {
  font: 500 10.5px var(--mono);
  color: var(--muted);
  white-space: nowrap;
}

.camp-reply-quote {
  font: 400 12.5px/1.42 var(--font);
  color: #1e293b;
  background: #f8fafc;
  border-left: 3px solid #10b981;
  padding: 6px 9px;
  border-radius: 0 7px 7px 0;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  word-break: break-word;
}

.camp-reply-card.is-unsub .camp-reply-quote {
  border-left-color: #ef4444;
  background: #fef2f2;
  color: #7f1d1d;
}

.camp-reply-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-width: 0;
  margin-top: auto;
  padding-top: 1px;
}

.camp-reply-email {
  font: 500 11.5px var(--mono);
  color: #047857;
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.camp-reply-card.is-unsub .camp-reply-email {
  color: #dc2626;
  text-decoration: line-through;
}

.camp-reply-actions {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  flex: none;
}

/* Barra de cola activa compacta con progreso */
.camp-queue-bar {
  border-radius: 12px;
  padding: 10px 14px;
  display: flex;
  flex-direction: column;
  gap: 7px;
}

.camp-queue-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.camp-queue-progress {
  width: 100%;
  height: 5px;
  background: rgba(15, 23, 42, .08);
  border-radius: 999px;
  overflow: hidden;
}

.camp-queue-fill {
  height: 100%;
  border-radius: 999px;
  transition: width .35s ease;
}

/* ============================================================================
   SISTEMA UNIFICADO TONWY STUDIO (Flush Dock + 224px Sub-Sidebar + Canvas #f6f7fb)
   ============================================================================ */
.studio-shell {
  display: flex;
  width: 100vw;
  height: 100vh;
  overflow: hidden;
  background: #f6f7fb;
}

/* Dock Global Oscuro (70px) cuando se abre mail.tonwy.com directo */
.standalone-dock {
  width: 70px;
  flex-shrink: 0;
  background: #0c0f17;
  border-right: 1px solid rgba(255, 255, 255, .06);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
  padding: 14px 0;
  user-select: none;
  z-index: 30;
}

.dock-top {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  width: 100%;
}

.dock-logo {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  background: rgba(255, 255, 255, .1);
  border: 1px solid rgba(255, 255, 255, .15);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform .15s, background .15s;
}

.dock-logo:hover {
  transform: scale(1.05);
  background: rgba(255, 255, 255, .16);
}

.dock-logo img {
  width: 28px;
  height: 28px;
  object-fit: contain;
  border-radius: 7px;
}

.dock-create {
  width: 40px;
  height: 40px;
  padding: 0;
  border: 0;
  border-radius: 12px;
  background: linear-gradient(45deg, #2563eb, #6366f1);
  color: #fff;
  font: 700 21px/1 var(--font);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 12px rgba(37, 99, 235, .28);
}

.dock-create:hover {
  filter: brightness(1.1);
  color: #fff;
}

.dock-sep {
  width: 32px;
  height: 1px;
  background: rgba(255, 255, 255, .1);
  margin: 2px 0;
}

.dock-nav {
  display: flex;
  flex-direction: column;
  gap: 6px;
  width: 100%;
  padding: 0 6px;
}

.dock-item {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 8px 2px;
  border-radius: 12px;
  color: #a1a1aa;
  text-decoration: none;
  font: 500 10px/1.1 var(--font);
  transition: background .15s, color .15s;
}

.dock-item svg {
  width: 19px;
  height: 19px;
}

.dock-item:hover {
  background: rgba(255, 255, 255, .06);
  color: #f4f4f5;
}

.dock-item.active {
  background: rgba(255, 255, 255, .14);
  color: #ffffff;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .15);
}

.dock-item.active::before {
  content: "";
  position: absolute;
  left: 0;
  top: 10px;
  bottom: 10px;
  width: 3px;
  border-radius: 0 3px 3px 0;
  background: #60a5fa;
}

/* Ocultar Dock exterior cuando ya está dentro de Tonwy Hub */
html.in-tonwy-hub .standalone-dock,
html.in-tonwy-hub #btn-install-pwa {
  display: none !important;
}

/* ============================================================================
   TONWY TACTILE STUDIO UI v36 (Bento Cards · Pastel Squircles · Pill Controls)
   ============================================================================ */
[hidden],
button[hidden] {
  display: none !important;
}

.studio-shell {
  background: #f1f3f8;
}

.app {
  flex: 1;
  min-width: 0;
  display: grid;
  grid-template-columns: 232px 384px 1fr;
  gap: 10px;
  padding: 10px;
  height: 100vh;
  background: #f1f3f8;
}

@media (min-width: 901px) {
  body.campaigns-view .app {
    grid-template-columns: 232px 1fr;
  }
  body.mail-sidebar-collapsed .app {
    grid-template-columns: 384px 1fr;
  }
  body.mail-sidebar-collapsed.campaigns-view .app {
    grid-template-columns: 1fr;
  }
  body.mail-sidebar-collapsed .sidebar {
    display: none !important;
  }
}

.sidebar,
.list-pane,
.reader {
  background: #ffffff;
  border-radius: 22px;
  border: 1px solid rgba(15, 23, 42, .06);
  box-shadow: 0 4px 20px -2px rgba(15, 23, 42, .035);
  min-height: 0;
}

.sidebar,
.list-pane {
  overflow: hidden;
}

.reader {
  overflow-y: auto !important;
  overflow-x: hidden !important;
}

/* Sub-barra contextual de 232px con controles en píldora */
.sidebar {
  padding: 0;
  display: flex;
  flex-direction: column;
}

.studio-subhead {
  height: 60px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 18px;
  border-bottom: 1px solid #f1f3f7;
}

.studio-eyebrow {
  font: 800 10.5px/1.2 var(--display);
  letter-spacing: .12em;
  color: var(--accent);
  text-transform: uppercase;
  display: flex;
  align-items: center;
  gap: 6px;
}

.studio-sub {
  font: 700 13.5px/1.3 var(--display);
  letter-spacing: -.01em;
  color: #0f172a;
  margin-top: 1px;
}

.studio-collapse-btn {
  width: 30px;
  height: 30px;
  padding: 0;
  justify-content: center;
  border: 1px solid #eef0f5;
  background: #f8fafc;
  color: #64748b;
  border-radius: 999px;
}

.studio-collapse-btn:hover {
  background: #111318;
  border-color: #111318;
  color: #ffffff;
}

.studio-collapse-btn svg {
  width: 15px;
  height: 15px;
}

.mail-expand-btn {
  position: fixed;
  top: 16px;
  left: 86px;
  z-index: 40;
  padding: 8px 14px;
  border-radius: 999px;
  border: 1px solid rgba(15, 23, 42, .08);
  background: #ffffff;
  color: #0f172a;
  font: 600 12px/1 var(--font);
  box-shadow: 0 6px 18px rgba(15, 23, 42, .08);
}

html.in-tonwy-hub .mail-expand-btn {
  left: 16px;
}

.studio-cta-wrap {
  padding: 14px 14px 8px;
  flex-shrink: 0;
}

.compose {
  width: 100%;
  margin: 0;
  padding: 11px 16px;
  border-radius: 999px;
  font: 700 13px/1.2 var(--display);
  letter-spacing: -.01em;
  justify-content: center;
  background: #111318 !important;
  border-color: #111318 !important;
  color: #ffffff !important;
  box-shadow: 0 6px 16px rgba(17, 19, 24, .16);
}

.compose:hover {
  background: var(--accent) !important;
  border-color: var(--accent) !important;
  box-shadow: 0 8px 20px rgba(0, 68, 255, .24);
}

.studio-nav-scroll {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 6px 12px 14px;
}

.nav-item {
  font: 600 13px/1.25 var(--font);
  padding: 9px 13px;
  margin: 2px 0;
  border-radius: 999px;
  gap: 10px;
  color: #475569;
  transition: background .15s, color .15s, transform .1s;
}

.nav-item svg {
  width: 16px;
  height: 16px;
  color: #64748b;
}

.nav-item:hover {
  background: #f3f5f9;
  color: #0f172a;
}

.nav-item.active {
  background: #111318;
  color: #ffffff;
  font-weight: 700;
  box-shadow: 0 4px 12px rgba(17, 19, 24, .14);
}

.nav-item.active svg {
  color: #ffffff !important;
}

.nav-item.active::before {
  display: none;
}

.sidebar h4 {
  margin: 18px 12px 6px;
  font: 700 10.5px var(--display);
  letter-spacing: .08em;
  text-transform: uppercase;
  color: #94a3b8;
}

.accounts-drawer {
  margin-top: 12px;
  border-top: 1px solid #f1f3f7;
  padding-top: 10px;
}

.accounts-drawer summary {
  list-style: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 7px 12px;
  border-radius: 999px;
  font: 600 12.5px var(--font);
  color: #475569;
  cursor: pointer;
}

.accounts-drawer summary:hover {
  background: #f3f5f9;
  color: #0f172a;
}

.sidebar-footer {
  border-top: 1px solid #f1f3f7;
  padding: 12px 14px;
  margin-top: 0;
  flex-shrink: 0;
  background: #ffffff;
}

.sidebar-footer button {
  border-radius: 999px;
  padding: 9px 14px;
  font: 600 12.5px var(--font);
  background: #f4f6fa;
  border-color: transparent;
  color: #334155;
}

.sidebar-footer button:hover {
  background: #e2e8f0;
  color: #0f172a;
}

/* Columna central: Lista de mensajes como cápsulas táctiles */
.list-pane {
  background: #f8f9fc;
  display: flex;
  flex-direction: column;
}

.toolbar {
  height: 60px;
  padding: 0 14px;
  background: #ffffff;
  border-bottom: 1px solid #eef0f5;
}

.search {
  background: #f3f5f9;
  border-radius: 999px;
}

.search input {
  border-radius: 999px;
  border-color: transparent;
  background: transparent;
  padding: 9px 38px 9px 36px;
  font: 500 13px var(--font);
}

.search input:focus {
  background: #ffffff;
  border-color: var(--accent);
}

.list-header {
  background: #ffffff;
  border-bottom: 1px solid #eef0f5;
  padding-bottom: 4px;
}

.list-title {
  padding: 10px 16px 6px;
  font: 700 11.5px var(--display);
  text-transform: none;
  letter-spacing: -.01em;
  color: #475569;
}

.list {
  padding: 10px 10px 14px;
  display: flex;
  flex-direction: column;
  gap: 7px;
}

.item {
  padding: 12px 14px;
  margin: 0;
  border-radius: 16px;
  background: #ffffff;
  border: 1px solid rgba(15, 23, 42, .055);
  box-shadow: 0 2px 6px rgba(15, 23, 42, .02);
  display: flex;
  align-items: flex-start;
  gap: 11px;
  transition: transform .12s ease, box-shadow .12s ease, border-color .12s ease, background .12s ease;
}

.item:hover {
  background: #ffffff;
  border-color: rgba(15, 23, 42, .14);
  box-shadow: 0 6px 16px rgba(15, 23, 42, .05);
  transform: translateY(-1px);
}

.item.selected {
  background: #f5f8ff;
  border-color: var(--accent);
  box-shadow: 0 8px 20px rgba(0, 68, 255, .09);
}

.item.selected::after,
.item.unread::before {
  display: none;
}

.item-squircle {
  width: 36px;
  height: 36px;
  border-radius: 11px;
  background: var(--sq-bg, #eef3ff);
  color: var(--sq-fg, #1E3F20);
  font: 800 14px/1 var(--display);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  position: relative;
  margin-top: 1px;
}

.item.unread .item-squircle::after {
  content: "";
  position: absolute;
  top: -2px;
  right: -2px;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--accent);
  border: 2px solid #ffffff;
}

.item-body {
  flex: 1;
  min-width: 0;
}

.item .from {
  font: 600 13.5px/1.3 var(--display);
  color: #1e293b;
  letter-spacing: -.01em;
}

.item.unread .from {
  font-weight: 800;
  color: #0b0d12;
}

.item .subject {
  font: 400 12.5px/1.4 var(--font);
  color: #64748b;
  margin-top: 2px;
}

.item.unread .subject {
  font-weight: 600;
  color: #334155;
}

.thread-count-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font: 700 10.5px var(--font);
  padding: 1px 6px;
  border-radius: 999px;
  background: #f1f5f9;
  color: #475569;
  margin-left: 4px;
}

button.star {
  border: 0;
  background: transparent;
  padding: 2px;
  border-radius: 6px;
  color: #cbd5e1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

button.star:hover {
  color: #94a3b8;
  background: #f1f5f9;
}

button.star.on {
  color: #f59e0b;
}

.tag {
  font: 600 11px/1.2 var(--font);
  padding: 3px 9px;
  border-radius: 999px;
  gap: 5px;
  color: color-mix(in srgb, var(--c) 82%, #0f172a);
  background: color-mix(in srgb, var(--c) 12%, #ffffff);
  border: 1px solid color-mix(in srgb, var(--c) 20%, #ffffff);
}

.tag::before {
  width: 6px;
  height: 6px;
  border-radius: 50%;
}

/* Lienzo derecho: Resumen del día (Bento + Squircles + Cápsulas) y Lector */
.reader {
  background: #f6f7fb;
}

.reader-head {
  background: #ffffff;
  margin: 12px 14px 0;
  padding: 22px 26px 18px;
  border-radius: 20px;
  border: 1px solid rgba(15, 23, 42, .06);
  box-shadow: 0 2px 10px rgba(15, 23, 42, .025);
}

.reader-head h2 {
  font: 800 20px/1.3 var(--display);
  letter-spacing: -.02em;
}

.reader-body {
  padding: 14px 14px 24px;
}

.reader-body iframe {
  border-radius: 18px;
  border: 1px solid rgba(15, 23, 42, .06);
  box-shadow: 0 2px 10px rgba(15, 23, 42, .025);
}

/* Botones Píldora y Squircles (Inspiración Kaysar Zami) */
.pill-btn {
  border-radius: 999px !important;
  padding: 9px 16px !important;
  font: 600 12.5px/1.1 var(--display) !important;
  letter-spacing: -.01em;
}

.pill-btn--soft {
  background: #eef2ff !important;
  border-color: #dbeafe !important;
  color: var(--accent) !important;
}

.pill-btn--soft:hover {
  background: #dbeafe !important;
}

.squircle-ico {
  width: 40px;
  height: 40px;
  border-radius: 13px;
  background: var(--sq-bg, #eef3ff);
  color: var(--sq-fg, #1E3F20);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.squircle-ico svg {
  width: 19px;
  height: 19px;
}

.squircle-ico--sm {
  width: 34px;
  height: 34px;
  border-radius: 11px;
}

.squircle-ico--sm svg {
  width: 16px;
  height: 16px;
}

.digest-view,
.digest-wrap {
  padding: 18px 22px 32px;
  max-width: 1380px;
  width: 100%;
  margin: 0 auto;
  gap: 20px;
}

.digest-head,
.digest-header {
  background: #ffffff;
  border: 1px solid rgba(15, 23, 42, .06);
  border-radius: 20px;
  padding: 18px 22px;
  box-shadow: 0 2px 12px rgba(15, 23, 42, .025);
  align-items: center;
}

.digest-head h2,
.digest-header h2 {
  font: 800 22px/1.2 var(--display);
  letter-spacing: -.025em;
  color: #0b0d12;
  margin: 0 0 3px;
}

.digest-header .sub {
  font: 500 13px/1.4 var(--font);
  color: #64748b;
}

.digest-kpis {
  display: grid;
  grid-template-columns: repeat(4, minmax(160px, 1fr));
  gap: 12px;
}

@media (max-width: 1180px) {
  .digest-kpis {
    grid-template-columns: repeat(2, 1fr);
  }
}

.digest-kpi {
  background: #ffffff;
  border: 1px solid rgba(15, 23, 42, .06);
  border-radius: 20px;
  padding: 18px 20px;
  box-shadow: 0 2px 12px rgba(15, 23, 42, .025);
  display: flex;
  flex-direction: column;
}

.digest-kpi .kpi-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 14px;
}

.digest-kpi .num {
  font: 800 34px/1.05 var(--display);
  letter-spacing: -.03em;
  color: #0b0d12;
  font-variant-numeric: tabular-nums;
}

.digest-kpi .lbl {
  font: 600 13px/1.3 var(--font);
  color: #64748b;
  text-transform: none;
  letter-spacing: -.01em;
  margin-top: 4px;
}

.digest-kpi .kpi-pill {
  font: 600 11px var(--font);
  padding: 5px 10px;
  border-radius: 999px;
  background: #f4f6fa;
  color: #475569;
  border: 0;
  margin-top: 0;
  white-space: nowrap;
}

.digest-kpi.kpi-clickable:hover .kpi-pill {
  background: #111318;
  color: #ffffff;
}

.digest-sec-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
  padding: 0 4px;
}

.digest-section h3 {
  margin: 0;
  font: 700 16px/1.25 var(--display);
  text-transform: none;
  letter-spacing: -.02em;
  color: #0b0d12;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

/* Filas Cápsula estilo "Daily routine" */
.digest-list.tactile-list {
  background: transparent;
  border: 0;
  border-radius: 0;
  overflow: visible;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.digest-row.tactile-capsule {
  background: #ffffff;
  border: 1px solid rgba(15, 23, 42, .06);
  border-radius: 16px;
  padding: 12px 16px;
  display: flex;
  align-items: center;
  gap: 14px;
  box-shadow: 0 2px 8px rgba(15, 23, 42, .02);
  transition: transform .14s ease, border-color .14s ease, box-shadow .14s ease;
}

.digest-row.tactile-capsule:hover {
  background: #ffffff;
  border-color: rgba(0, 68, 255, .28);
  box-shadow: 0 6px 18px rgba(15, 23, 42, .06);
  transform: translateY(-1px);
}

.capsule-main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.capsule-top {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.capsule-top .from {
  font: 700 14px/1.25 var(--display);
  color: #0f172a;
  letter-spacing: -.01em;
}

.capsule-main .subj {
  font: 400 13px/1.35 var(--font);
  color: #64748b;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.capsule-action {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: #f4f6fa;
  color: #475569;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background .15s, color .15s;
}

.capsule-action svg {
  width: 14px;
  height: 14px;
}

.tactile-capsule:hover .capsule-action,
.digest-proj-card .head:hover .capsule-action {
  background: #111318;
  color: #ffffff;
}

/* Tarjetas por Proyecto */
.digest-proj-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(290px, 1fr));
  gap: 12px;
}

.digest-proj-card {
  background: #ffffff;
  border: 1px solid rgba(15, 23, 42, .06);
  border-radius: 20px;
  box-shadow: 0 2px 12px rgba(15, 23, 42, .025);
  overflow: hidden;
}

.digest-proj-card .head {
  padding: 14px 16px;
  background: #ffffff;
  border-bottom: 1px solid #f1f3f7;
  gap: 12px;
}

.digest-proj-items .digest-row {
  padding: 10px 16px;
  border-bottom: 1px solid #f5f6fa;
}

.digest-proj-items .digest-row:last-child {
  border-bottom: 0;
}

.digest-config-bar {
  background: #ffffff;
  border: 1px solid rgba(15, 23, 42, .06);
  border-radius: 20px;
  padding: 16px 20px;
  box-shadow: 0 2px 12px rgba(15, 23, 42, .025);
}

@media (max-width: 900px) {
  .standalone-dock,
  .studio-collapse-btn,
  .mail-expand-btn {
    display: none !important;
  }
  .app {
    grid-template-columns: 1fr;
    padding: 0;
    gap: 0;
    height: 100dvh;
  }
  .list-pane,
  .reader {
    border-radius: 0;
    border: 0;
  }
  .sidebar {
    border-radius: 0 22px 22px 0;
  }
  .digest-kpis {
    grid-template-columns: 1fr 1fr;
  }
}

.camp-tools-more {
  position: relative;
  display: inline-block;
}
.camp-tools-more > summary {
  list-style: none;
  cursor: pointer;
  user-select: none;
  font: 600 12px var(--font);
  color: var(--text-2);
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 9px;
  padding: 6px 10px;
}
.camp-tools-more > summary::-webkit-details-marker {
  display: none;
}
.camp-tools-more[open] > summary {
  background: var(--surface);
  color: var(--text);
  border-color: var(--line-strong);
}
.camp-tools-pop {
  position: absolute;
  left: 0;
  top: calc(100% + 6px);
  z-index: 30;
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 230px;
  padding: 8px;
  background: #ffffff;
  border: 1px solid var(--line-strong);
  border-radius: 12px;
  box-shadow: var(--shadow-lg);
}
.camp-tools-pop button {
  width: 100%;
  justify-content: flex-start;
}

/* ---- Radar Global de Campañas en Vivo (Digest + Vista Completa) ---- */
.camp-radar-box {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 18px 20px;
  box-shadow: var(--shadow);
}
.camp-radar-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}
.camp-radar-title {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.camp-radar-title h3 {
  margin: 0;
  font-size: 15.5px;
  font-weight: 800;
  color: #0f172a;
  letter-spacing: -0.01em;
}
.live-pulse-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 11.5px;
  font-weight: 700;
  color: #047857;
  background: #ecfdf5;
  border: 1px solid #a7f3d0;
  border-radius: 999px;
  padding: 4px 10px;
}
.live-pulse-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #10b981;
  box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.6);
  animation: radarPulse 2s infinite;
}
@keyframes radarPulse {
  0% { box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.55); }
  70% { box-shadow: 0 0 0 6px rgba(16, 185, 129, 0); }
  100% { box-shadow: 0 0 0 0 rgba(16, 185, 129, 0); }
}
.camp-radar-totals {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(135px, 1fr));
  gap: 10px;
  margin-bottom: 14px;
}
.camp-radar-stat {
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 14px;
  padding: 10px 13px;
}
.camp-radar-stat .v {
  font: 800 20px/1.15 var(--display);
  color: #0f172a;
}
.camp-radar-stat .k {
  font-size: 11.5px;
  font-weight: 600;
  color: #64748b;
  margin-top: 3px;
}
.camp-radar-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(275px, 1fr));
  gap: 12px;
}
.camp-brand-card {
  background: #ffffff;
  border: 1px solid #e5e7eb;
  border-top: 3px solid var(--bc, #1E3F20);
  border-radius: 15px;
  padding: 13px 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  transition: border-color .15s, box-shadow .15s, transform .12s;
}
.camp-brand-card:hover {
  border-color: color-mix(in srgb, var(--bc, #1E3F20) 45%, #cbd5e1);
  box-shadow: 0 8px 22px -12px rgba(15, 23, 42, 0.16);
}
.camp-brand-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
}
.camp-brand-name {
  font-weight: 800;
  font-size: 14px;
  color: #0f172a;
  display: flex;
  align-items: center;
  gap: 7px;
}
.camp-brand-sender {
  font-size: 11px;
  color: #64748b;
  margin-top: 1px;
}
.camp-state-pill {
  font-size: 10.5px;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 999px;
  white-space: nowrap;
}
.camp-state-pill--sending {
  background: #dcfce7;
  color: #15803d;
  border: 1px solid #86efac;
}
.camp-state-pill--daily_cap,
.camp-state-pill--sleeping {
  background: #fef3c7;
  color: #b45309;
  border: 1px solid #fde68a;
}
.camp-state-pill--completed {
  background: #f1f5f9;
  color: #334155;
  border: 1px solid #cbd5e1;
}
.camp-state-pill--ready {
  background: #eef4ff;
  color: #1d4ed8;
  border: 1px solid #bfdbfe;
}
.camp-progress-track {
  height: 6px;
  background: #f1f5f9;
  border-radius: 999px;
  overflow: hidden;
}
.camp-progress-bar {
  height: 100%;
  background: var(--bc, #1E3F20);
  border-radius: 999px;
  transition: width .35s ease;
}
.camp-metrics-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
  padding-top: 4px;
  border-top: 1px dashed #e2e8f0;
}
.camp-metric-cell .mv {
  font: 700 13.5px/1.2 var(--display);
  color: #0f172a;
}
.camp-metric-cell .ml {
  font-size: 10.5px;
  color: #64748b;
}
.camp-steps-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-size: 11px;
  color: #475569;
  background: #f8fafc;
  padding: 6px 9px;
  border-radius: 9px;
}
.camp-open-link {
  padding: 4px 9px;
  font-size: 11px;
  font-weight: 700;
  border-radius: 8px;
  background: #fff;
  color: #0f172a;
  border: 1px solid #cbd5e1;
}
.camp-open-link:hover {
  border-color: #0f172a;
}
.camp-overview-page {
  max-width: 1280px;
  margin: 0 auto;
  padding: 24px 26px 48px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}
.camp-feed-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 10px;
}
.camp-feed-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 12px;
  font-size: 12.5px;
}
.camp-feed-badge {
  font-size: 10.5px;
  font-weight: 700;
  padding: 3px 7px;
  border-radius: 7px;
  flex: none;
}









/* ---- Adaptación Exclusiva Frutas Jopami (100% Zona Email sin Dock externo) ---- */
.jopami-shell {
  display: block;
  height: 100vh;
  width: 100vw;
  overflow: hidden;
}
.jopami-shell > .app {
  width: 100%;
  height: 100vh;
}
button.primary,
.primary.compose {
  background: #1E3F20 !important;
  border-color: #1E3F20 !important;
  color: #ffffff !important;
}
button.primary:hover,
.primary.compose:hover {
  background: #2D5F30 !important;
  border-color: #2D5F30 !important;
}
.jopami-mb-box {
  background: #ffffff;
  border: 1px solid #dfe5dc;
  border-radius: 18px;
  padding: 16px 18px;
  box-shadow: var(--shadow);
}
.jopami-mb-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(235px, 1fr));
  gap: 10px;
  margin-top: 12px;
}
.jopami-mb-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 11px 13px;
  border-radius: 13px;
  border: 1px solid #e2e8df;
  background: #fafbf9;
  transition: border-color .15s, background .15s;
}
.jopami-mb-card.is-connected {
  background: #f2f8f2;
  border-color: #b7d7b8;
}
.jopami-mb-card:hover {
  border-color: #1E3F20;
}
