:root {
  --bg: #000000;
  --surface: #0c0d0c;
  --surface2: #151715;
  --line: #232523;
  --txt: #f4f6f3;
  --dim: #7e857b;
  --green: #2bd46a;
  --green-deep: #116b32;
  --red: #ef4444;
  --red-deep: #7f1d1d;
  --amber: #f5a524;
  --radius: 16px;
  --tabh: 62px;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg); color: var(--txt);
  font-family: -apple-system, system-ui, "Segoe UI", Roboto, sans-serif;
  overscroll-behavior: none; -webkit-font-smoothing: antialiased;
}
#app { min-height: 100%; display: flex; flex-direction: column; }
#view {
  flex: 1;
  padding: calc(env(safe-area-inset-top) + 18px) 16px calc(var(--tabh) + env(safe-area-inset-bottom) + 26px);
}

/* ---------- Tabbar ---------- */
#tabbar {
  position: fixed; bottom: 0; left: 0; right: 0;
  height: calc(var(--tabh) + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
  display: grid; grid-template-columns: repeat(4, 1fr);
  background: rgba(0,0,0,0.92); backdrop-filter: blur(12px);
  border-top: 1px solid var(--line); z-index: 10;
}
.tab {
  background: none; border: 0; color: var(--dim); cursor: pointer;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px;
  font-size: 10.5px; font-weight: 600; letter-spacing: 0.2px;
}
.tab svg { width: 24px; height: 24px; display: block; }
.tab.active { color: var(--green); }

/* ---------- Header racha ---------- */
.streak {
  display: flex; align-items: flex-end; gap: 14px; margin-bottom: 18px;
}
.streak .num { font-size: 56px; font-weight: 900; line-height: 0.9; letter-spacing: -2px; color: var(--txt); }
.streak .num.hot { color: var(--green); }
.streak .meta { padding-bottom: 6px; }
.streak .meta .l1 { font-size: 12px; font-weight: 800; text-transform: uppercase; letter-spacing: 1.5px; color: var(--dim); }
.streak .meta .l2 { font-size: 15px; font-weight: 700; margin-top: 2px; }
.progress-bar { height: 6px; border-radius: 99px; background: var(--surface2); overflow: hidden; margin-top: 14px; margin-bottom: 4px; }
.progress-bar > span { display: block; height: 100%; background: var(--green); border-radius: 99px; transition: width .3s; }

.section-title { font-size: 28px; font-weight: 900; letter-spacing: -0.8px; margin: 2px 0 16px; }

/* ---------- Frase ---------- */
.quote {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 18px 18px 16px; margin-bottom: 18px;
}
.quote p { margin: 0 0 10px; font-size: 16.5px; line-height: 1.5; font-weight: 500; }
.quote .author { color: var(--green); font-size: 13px; font-weight: 800; letter-spacing: 0.3px; }

/* ---------- Calendario ---------- */
.cal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.cal-head h2 { margin: 0; font-size: 17px; font-weight: 800; text-transform: capitalize; }
.cal-nav { background: var(--surface2); border: 1px solid var(--line); color: var(--txt);
  width: 40px; height: 40px; border-radius: 12px; font-size: 18px; cursor: pointer; }
.weekdays, .grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 7px; }
.weekdays { margin-bottom: 8px; }
.weekdays span { text-align: center; font-size: 10.5px; color: var(--dim); font-weight: 700; }
.cell {
  aspect-ratio: 1; border-radius: 11px; border: 1px solid var(--line);
  background: var(--surface); color: var(--dim);
  display: flex; align-items: center; justify-content: center; font-size: 14px; font-weight: 700;
  cursor: pointer; position: relative;
}
.cell.future { opacity: 0.32; }
.cell.green { background: var(--green); border-color: var(--green); color: #022c12; }
.cell.red { background: var(--red-deep); border-color: var(--red); color: #ffe2e2; }
.cell.today { border-color: var(--amber); color: var(--amber); border-width: 2px; }
.cell.is-today::after { content: ''; position: absolute; bottom: 6px; width: 5px; height: 5px; border-radius: 50%; background: currentColor; }
.cell.blank { background: none; border: 0; cursor: default; }

/* ---------- Items / listas ---------- */
.section-label { font-size: 12px; color: var(--dim); text-transform: uppercase; letter-spacing: 1px;
  font-weight: 800; margin: 22px 2px 12px; }
.item {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 15px; margin-bottom: 11px; display: flex; align-items: center; gap: 12px;
}
.item .meta { flex: 1; min-width: 0; }
.item .meta .title { font-size: 16px; font-weight: 700; }
.item .meta .sub { font-size: 12.5px; color: var(--dim); margin-top: 4px; }
.badge { font-size: 9.5px; font-weight: 800; text-transform: uppercase; letter-spacing: 0.5px;
  padding: 3px 7px; border-radius: 6px; }
.badge.tarea { background: #0f2e4a; color: #74c0ff; }
.badge.aguante { background: #3a2410; color: #ffb866; }

.checks { display: flex; gap: 8px; }
.cbtn { width: 44px; height: 44px; border-radius: 12px; border: 1px solid var(--line);
  background: var(--surface2); font-size: 18px; cursor: pointer; color: var(--dim); display: flex; align-items: center; justify-content: center; }
.cbtn.done.on { background: var(--green); border-color: var(--green); color: #022c12; }
.cbtn.fail.on { background: var(--red-deep); border-color: var(--red); color: #fff; }

/* ---------- Botones ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border: 1px solid var(--line); border-radius: 13px; padding: 14px 16px; font-size: 15px; font-weight: 800;
  cursor: pointer; background: var(--surface2); color: var(--txt); }
.btn.primary { background: var(--green); color: #022c12; border-color: var(--green); }
.btn.danger { background: var(--red-deep); border-color: var(--red); color: #fff; }
.btn.block { width: 100%; }
.btn.ghost { background: none; }
.fab { position: fixed; right: 18px; bottom: calc(var(--tabh) + env(safe-area-inset-bottom) + 16px);
  width: 58px; height: 58px; border-radius: 50%; background: var(--green); color: #022c12;
  font-size: 32px; border: 0; box-shadow: 0 10px 30px rgba(43,212,106,0.4); z-index: 9; cursor: pointer; }

/* ---------- Modal / form ---------- */
#modal-root:empty { display: none; }
.overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.72); z-index: 50; display: flex; align-items: flex-end; }
.sheet { background: var(--surface); width: 100%; border-radius: 22px 22px 0 0;
  padding: 20px 18px calc(env(safe-area-inset-bottom) + 18px); max-height: 92vh; overflow-y: auto; border: 1px solid var(--line); }
.sheet h2 { margin: 4px 0 18px; font-size: 21px; font-weight: 900; }
.field { margin-bottom: 15px; }
.field label { display: block; font-size: 12.5px; color: var(--dim); margin-bottom: 7px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.5px; }
.field input, .field select {
  width: 100%; padding: 13px; border-radius: 11px; background: var(--surface2);
  border: 1px solid var(--line); color: var(--txt); font-size: 15px; }
.seg { display: flex; gap: 8px; }
.seg button { flex: 1; padding: 12px; border-radius: 11px; background: var(--surface2);
  border: 1px solid var(--line); color: var(--dim); font-weight: 800; cursor: pointer; font-size: 14px; }
.seg button.on { background: var(--green); color: #022c12; border-color: var(--green); }
.days { display: flex; gap: 6px; justify-content: space-between; }
.days button { flex: 1; aspect-ratio: 1; max-width: 46px; border-radius: 11px; background: var(--surface2);
  border: 1px solid var(--line); color: var(--dim); font-weight: 800; cursor: pointer; font-size: 13px; }
.days button.on { background: var(--green); color: #022c12; border-color: var(--green); }
.row { display: flex; gap: 10px; margin-top: 8px; }

.empty-state { text-align: center; color: var(--dim); padding: 54px 20px; }
.empty-state svg { width: 46px; height: 46px; margin-bottom: 14px; opacity: 0.6; }
.hidden { display: none !important; }
