:root {
  --niebla-dark: #4E6B8A;
  --niebla: #6B8CAE;
  --niebla-light: #8FA9C2;
  --arena: #E8DEC8;
  --arena-border: #D6C7AE;
  --arena-soft: #F5EFE6;
  --hueso: #FAF8F5;
  --surface: #FFFFFF;
  --text-main: #243240;
  --text-muted: #5C6D7E;
  --ok-bg: #E6F4EA;
  --ok-text: #1E6B3B;
  --pending-bg: #F1ECE1;
  --pending-text: #6B5B45;
  --shadow-sm: 0 2px 8px rgba(36, 50, 64, 0.06);
  --shadow-md: 0 8px 24px rgba(36, 50, 64, 0.12);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background-color: var(--arena-soft);
  color: var(--text-main);
  min-height: 100vh;
}

.hidden { display: none !important; }

/* Topbar */
.topbar {
  height: 64px;
  background: var(--surface);
  border-bottom: 1px solid var(--arena-border);
  padding: 0 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 30;
}

.topbar-left, .topbar-right { display: flex; align-items: center; gap: 12px; }

.brand { display: flex; align-items: center; gap: 10px; }
.brand-logo {
  width: 38px; height: 38px; border-radius: 10px;
  background: var(--niebla-dark); color: var(--hueso);
  display: grid; place-items: center;
}
.brand-logo svg { width: 24px; height: 24px; }
.brand-title { display: block; font-weight: 700; font-size: 15px; color: var(--niebla-dark); letter-spacing: 0.4px; }
.brand-sub { display: block; font-size: 10px; font-weight: 600; color: var(--text-muted); letter-spacing: 0.6px; }

.last-viewed-pill {
  background: var(--arena-soft);
  border: 1px solid var(--arena-border);
  color: var(--niebla-dark);
  font-size: 12px; font-weight: 500;
  padding: 6px 12px; border-radius: 999px;
  cursor: pointer;
}
.last-viewed-pill:hover { background: var(--arena); }

.user-badge {
  display: flex; align-items: center; gap: 8px;
  background: var(--hueso); border: 1px solid var(--arena-border);
  padding: 4px 10px 4px 4px; border-radius: 999px;
}
.user-avatar {
  width: 28px; height: 28px; border-radius: 50%;
  background: var(--niebla); color: #fff;
  font-size: 11px; font-weight: 700;
  display: grid; place-items: center;
}
.user-label { font-size: 12px; font-weight: 600; color: var(--text-main); }

.icon-btn {
  border: 1px solid var(--arena-border); background: var(--surface);
  color: var(--text-main); width: 34px; height: 34px; border-radius: 8px;
  cursor: pointer; font-size: 16px; display: grid; place-items: center;
}
.icon-btn:hover { background: var(--arena-soft); }
.mobile-only { display: none; }

/* Workspace */
.workspace { display: flex; min-height: calc(100vh - 64px); }

/* Sidebar estilo PAIC */
.sidebar {
  width: 256px; flex-shrink: 0;
  background: var(--surface);
  border-right: 1px solid var(--arena-border);
  padding: 20px 14px;
  display: flex; flex-direction: column; justify-content: space-between; gap: 20px;
}

.sidebar-heading {
  font-size: 11px; font-weight: 700; color: var(--text-muted);
  letter-spacing: 0.7px; padding: 0 10px 8px;
}

.nav-list { display: flex; flex-direction: column; gap: 4px; }

.nav-item {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  width: 100%; text-align: left; border: none; background: transparent;
  padding: 10px 12px; border-radius: 10px;
  font-size: 13.5px; font-weight: 500; color: var(--text-main);
  cursor: pointer; transition: background 0.15s;
}
.nav-item:hover { background: var(--arena-soft); }
.nav-item.active {
  background: #EBF1F6; color: var(--niebla-dark); font-weight: 600;
}
.nav-badge {
  font-size: 10px; font-weight: 600; padding: 2px 7px; border-radius: 999px;
  background: var(--arena); color: var(--text-muted);
}
.nav-item.active .nav-badge { background: var(--niebla-dark); color: #fff; }

.progress-box {
  background: var(--hueso); border: 1px solid var(--arena-border);
  border-radius: 12px; padding: 12px;
}
.progress-row { display: flex; justify-content: space-between; font-size: 12.5px; margin-bottom: 8px; }
.progress-track { height: 8px; background: var(--arena); border-radius: 999px; overflow: hidden; margin-bottom: 10px; }
.progress-fill { height: 100%; background: var(--niebla-dark); transition: width 0.25s ease; }
.btn-link-muted {
  background: none; border: none; color: var(--text-muted);
  font-size: 11.5px; text-decoration: underline; cursor: pointer;
}

/* Main */
.main-content { flex: 1; padding: 24px 28px; max-width: 1180px; }
.view-header { margin-bottom: 20px; }
.view-header h1 { font-size: 22px; font-weight: 700; color: var(--niebla-dark); margin-bottom: 6px; }
.view-header p { font-size: 14px; color: var(--text-muted); line-height: 1.5; max-width: 720px; }

/* Grid de Tarjetas estilo PAIC */
.cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(290px, 1fr));
  gap: 18px;
}

.paic-card {
  background: var(--surface);
  border: 1px solid var(--arena-border);
  border-radius: 14px;
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  display: flex; flex-direction: column;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.paic-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); }

.paic-card-header {
  background: var(--niebla-dark);
  color: #fff;
  padding: 14px 16px;
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
}
.paic-card-title { font-size: 15px; font-weight: 700; line-height: 1.3; }
.paic-card-num {
  font-size: 11px; font-weight: 700;
  background: rgba(255, 255, 255, 0.18);
  padding: 3px 8px; border-radius: 999px; white-space: nowrap;
}

.paic-card-body {
  padding: 14px 16px;
  flex: 1;
  display: flex; flex-direction: column; gap: 10px;
}

.status-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.status-pill {
  font-size: 11px; font-weight: 700; padding: 3px 9px; border-radius: 999px;
}
.status-pill.done { background: var(--ok-bg); color: var(--ok-text); }
.status-pill.pending { background: var(--pending-bg); color: var(--pending-text); }
.last-tag { font-size: 11px; font-weight: 600; color: var(--niebla-dark); }

.card-summary { font-size: 13.5px; color: var(--text-main); line-height: 1.5; }
.card-when {
  background: var(--arena-soft);
  border-left: 3px solid var(--niebla);
  padding: 8px 10px;
  border-radius: 0 8px 8px 0;
  font-size: 12.5px; color: var(--text-muted); line-height: 1.45;
}
.card-when strong { color: var(--niebla-dark); }

.paic-card-footer {
  padding: 12px 16px;
  border-top: 1px solid var(--arena-soft);
  background: var(--hueso);
  display: flex; gap: 8px;
}

/* Botones */
.btn {
  border-radius: 9px; padding: 9px 14px;
  font-size: 13px; font-weight: 600; cursor: pointer;
  border: 1px solid transparent; transition: background 0.15s;
}
.btn-primary { background: var(--niebla-dark); color: #fff; flex: 1; }
.btn-primary:hover { background: #3D5670; }
.btn-secondary { background: var(--surface); border-color: var(--arena-border); color: var(--text-main); }
.btn-secondary:hover { background: var(--arena-soft); }
.btn-check { background: var(--surface); border-color: var(--arena-border); color: var(--niebla-dark); }
.btn-check.is-done { background: var(--ok-bg); border-color: #B7DFC5; color: var(--ok-text); }

/* Modal */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(24, 34, 46, 0.55);
  display: grid; place-items: center; padding: 16px; z-index: 50;
}
.modal-card {
  background: var(--surface); width: 100%; max-width: 580px;
  max-height: 90vh; border-radius: 16px; overflow: hidden;
  display: flex; flex-direction: column; box-shadow: var(--shadow-md);
}
.modal-header {
  background: var(--niebla-dark); color: #fff;
  padding: 16px 20px; display: flex; justify-content: space-between; align-items: flex-start; gap: 12px;
}
.modal-tag { font-size: 11px; font-weight: 600; opacity: 0.85; display: block; margin-bottom: 3px; }
.modal-title { font-size: 18px; font-weight: 700; }
.modal-header .icon-btn { background: rgba(255,255,255,0.15); color: #fff; border: none; }

.modal-body { padding: 20px; overflow-y: auto; display: flex; flex-direction: column; gap: 14px; }
.modal-footer {
  padding: 14px 20px; background: var(--hueso); border-top: 1px solid var(--arena-border);
  display: flex; justify-content: flex-end; gap: 10px;
}

/* Ejercicios internos */
.ex-box {
  background: var(--hueso); border: 1px solid var(--arena-border);
  border-radius: 12px; padding: 16px; text-align: center;
}
.breath-circle {
  width: 120px; height: 120px; margin: 10px auto 14px;
  border-radius: 50%; background: var(--niebla-light); color: #fff;
  display: grid; place-items: center; font-weight: 700; font-size: 18px;
  transition: transform 0.8s ease, background 0.4s ease;
}
.breath-circle.inhale { transform: scale(1.18); background: var(--niebla-dark); }
.breath-circle.hold { transform: scale(1.18); background: var(--niebla); }
.breath-circle.exhale { transform: scale(0.92); background: var(--niebla-light); }

.timer-big { font-size: 38px; font-weight: 700; color: var(--niebla-dark); margin: 8px 0; font-variant-numeric: tabular-nums; }
.ex-controls { display: flex; justify-content: center; gap: 10px; margin-top: 10px; }

.check-list { display: flex; flex-direction: column; gap: 8px; text-align: left; }
.check-item {
  display: flex; align-items: center; gap: 10px;
  background: var(--surface); border: 1px solid var(--arena-border);
  padding: 10px 12px; border-radius: 10px; font-size: 13.5px; cursor: pointer;
}
.check-item input { width: 17px; height: 17px; accent-color: var(--niebla-dark); }

.field-group { display: flex; flex-direction: column; gap: 5px; text-align: left; }
.field-group label { font-size: 12.5px; font-weight: 600; color: var(--niebla-dark); }
.field-group textarea, .field-group input[type="text"] {
  width: 100%; border: 1px solid var(--arena-border); border-radius: 9px;
  padding: 10px; font-family: inherit; font-size: 13.5px; background: var(--surface);
}
.field-group textarea:focus, .field-group input:focus { outline: 2px solid var(--niebla-light); }

.placeholder-panel {
  background: var(--surface); border: 1px dashed var(--niebla);
  border-radius: 14px; padding: 32px; text-align: center;
  grid-column: 1 / -1;
}
.placeholder-panel h2 { color: var(--niebla-dark); margin-bottom: 8px; font-size: 18px; }
.placeholder-panel p { color: var(--text-muted); font-size: 14px; max-width: 520px; margin: 0 auto 14px; }

@media (max-width: 820px) {
  .mobile-only { display: grid; }
  .sidebar {
    position: fixed; left: -270px; top: 64px; bottom: 0; z-index: 40;
    transition: left 0.2s ease; box-shadow: var(--shadow-md);
  }
  .sidebar.open { left: 0; }
  .main-content { padding: 18px 16px; }
  .last-viewed-pill { display: none; }
}
