/* ── Reset & Variables ───────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:        #080810;
  --surface:   #0f0f1e;
  --surface2:  #161628;
  --border:    #1e1e38;
  --border2:   #2a2a42;

  --text:      #e2e8f0;
  --text2:     #64748b;
  --text3:     #2d3a50;

  --lived:     #f97316;   /* naranja cálido — recuerdos */
  --current:   #fbbf24;   /* ámbar brillante — el presente */
  --remaining: #151528;   /* azul oscuro — el futuro desconocido */

  --accent:    #a855f7;
  --accent2:   #7c3aed;

  --r: 6px;
  --font: system-ui, -apple-system, 'Segoe UI', Helvetica, sans-serif;
}

html { font-size: 16px; scroll-behavior: smooth; }

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

/* ── Screen Management ───────────────────────────────────────────────────── */
.screen { display: none; }
.screen.active { display: flex; flex-direction: column; min-height: 100vh; }

/* ── ONBOARDING ──────────────────────────────────────────────────────────── */
#screen-onboarding {
  align-items: center;
  justify-content: center;
  padding: 2rem 1.5rem;
  background:
    radial-gradient(ellipse 80% 60% at 15% 60%, rgba(124,58,237,.18) 0%, transparent 60%),
    radial-gradient(ellipse 60% 50% at 85% 20%, rgba(249,115,22,.10) 0%, transparent 55%),
    var(--bg);
}

.onboarding-wrap {
  width: 100%;
  max-width: 440px;
}

/* Brand */
.brand {
  text-align: center;
  margin-bottom: 2.5rem;
}

.brand-icon {
  display: block;
  font-size: 3rem;
  color: var(--accent);
  margin-bottom: 1rem;
  line-height: 1;
}

.brand h1 {
  font-size: 2rem;
  font-weight: 700;
  letter-spacing: -.03em;
  margin-bottom: .75rem;
  background: linear-gradient(135deg, #fff 30%, #a78bfa);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.brand p {
  color: var(--text2);
  line-height: 1.65;
  font-size: .95rem;
}

/* Form */
#form-profile {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 2rem;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  box-shadow: 0 24px 48px rgba(0,0,0,.4);
}

.form-field {
  display: flex;
  flex-direction: column;
  gap: .45rem;
}

.form-field label {
  font-size: .7rem;
  font-weight: 600;
  color: var(--text2);
  letter-spacing: .08em;
  text-transform: uppercase;
}

.form-field input,
.form-field select {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: .75rem 1rem;
  color: var(--text);
  font-size: 1rem;
  font-family: var(--font);
  outline: none;
  transition: border-color .2s;
  -webkit-appearance: none;
  appearance: none;
  cursor: pointer;
  width: 100%;
}

.form-field input:focus,
.form-field select:focus {
  border-color: var(--accent);
}

.form-field input[type="date"]::-webkit-calendar-picker-indicator {
  filter: invert(.45) sepia(1) hue-rotate(240deg);
  cursor: pointer;
}

.le-preview {
  background: rgba(168,85,247,.08);
  border: 1px solid rgba(168,85,247,.25);
  border-radius: var(--r);
  padding: .75rem 1rem;
  font-size: .9rem;
  color: #c084fc;
  text-align: center;
}
.le-preview.hidden { display: none; }

.form-error {
  color: #f87171;
  font-size: .85rem;
  text-align: center;
}
.form-error.hidden { display: none; }

.btn-primary {
  background: linear-gradient(135deg, var(--accent2), var(--accent));
  color: #fff;
  border: none;
  border-radius: var(--r);
  padding: .9rem 1.5rem;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  font-family: var(--font);
  transition: opacity .2s, transform .1s;
  margin-top: .25rem;
  letter-spacing: .01em;
}
.btn-primary:hover { opacity: .88; transform: translateY(-1px); }
.btn-primary:active { transform: translateY(0); }

/* ── CALENDAR HEADER ─────────────────────────────────────────────────────── */
.cal-header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 1rem 1.5rem 0;
  position: sticky;
  top: 0;
  z-index: 100;
  flex-shrink: 0;
}

.header-top {
  display: flex;
  align-items: flex-start;
  gap: 1rem;
  flex-wrap: wrap;
  padding-bottom: .75rem;
}

.btn-back {
  background: none;
  border: 1px solid var(--border);
  color: var(--text2);
  border-radius: var(--r);
  padding: .4rem .9rem;
  font-size: .82rem;
  cursor: pointer;
  font-family: var(--font);
  white-space: nowrap;
  transition: all .2s;
  flex-shrink: 0;
}
.btn-back:hover { color: var(--text); border-color: var(--border2); }

.header-stats {
  display: flex;
  gap: .6rem;
  flex-wrap: wrap;
  flex: 1;
}

.stat-pill {
  display: flex;
  flex-direction: column;
  align-items: center;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: .45rem .9rem;
  min-width: 80px;
}

.stat-accent {
  border-color: rgba(251,191,36,.3);
  background: rgba(251,191,36,.05);
}

.stat-num {
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--text);
  line-height: 1;
  font-variant-numeric: tabular-nums;
}

.stat-accent .stat-num { color: var(--current); }

.stat-lbl {
  font-size: .6rem;
  color: var(--text2);
  text-transform: uppercase;
  letter-spacing: .05em;
  margin-top: .2rem;
  text-align: center;
  line-height: 1.3;
}

.header-profile {
  font-size: .78rem;
  color: var(--text2);
  padding-bottom: .5rem;
}

/* View Nav */
.view-nav {
  display: flex;
  gap: 0;
  margin-top: .25rem;
}

.view-btn {
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--text2);
  padding: .6rem 1.2rem;
  font-size: .88rem;
  cursor: pointer;
  font-family: var(--font);
  font-weight: 500;
  transition: color .15s, border-color .15s;
  white-space: nowrap;
}
.view-btn:hover { color: var(--text); }
.view-btn.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

/* ── CALENDAR MAIN ───────────────────────────────────────────────────────── */
.cal-main {
  padding: 1.5rem;
  flex: 1;
  overflow-x: auto;
}

/* ── SQUARES — base ──────────────────────────────────────────────────────── */
.sq {
  border-radius: 2px;
  flex-shrink: 0;
  display: inline-block;
  transition: transform .1s;
  cursor: default;
}
.sq:hover { transform: scale(1.8); z-index: 20; position: relative; }

.sq--lived     { background: var(--lived); }
.sq--current   { background: var(--current); box-shadow: 0 0 8px var(--current); }
.sq--remaining { background: var(--remaining); outline: 1px solid var(--border); }
.sq--pre       { background: transparent; outline: none; }

/* ── YEARS VIEW ──────────────────────────────────────────────────────────── */
#calendar-grid.view-anos {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(46px, 46px));
  gap: 5px;
  max-width: 680px;
}

.view-anos .sq {
  width: 46px;
  height: 46px;
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: .58rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  color: transparent;
}
.view-anos .sq--lived     { color: rgba(255,255,255,.45); }
.view-anos .sq--current   { color: rgba(0,0,0,.55); }
.view-anos .sq--remaining { color: var(--text3); }

/* ── ROW-BASED VIEWS (months + weeks) ───────────────────────────────────── */
.year-row {
  display: flex;
  align-items: center;
  gap: 5px;
  margin-bottom: 2px;
}

.yr-lbl {
  font-size: .6rem;
  color: var(--text3);
  min-width: 34px;
  text-align: right;
  user-select: none;
  font-variant-numeric: tabular-nums;
  flex-shrink: 0;
}

.year-squares {
  display: flex;
  gap: 2px;
  flex-wrap: nowrap;
}

/* MONTHS */
.view-meses .sq {
  width: 17px;
  height: 17px;
}

/* WEEKS */
.view-semanas .sq {
  width: 9px;
  height: 9px;
}

/* ── DAYS VIEW ───────────────────────────────────────────────────────────── */
.year-section {
  margin-bottom: .6rem;
}

.yr-lbl--day {
  display: block;
  font-size: .6rem;
  color: var(--text3);
  margin-bottom: 3px;
  user-select: none;
}

.day-squares {
  display: flex;
  flex-wrap: wrap;
  gap: 2px;
}

.sq--day {
  width: 5px;
  height: 5px;
  border-radius: 1px;
}

/* ── LEGEND ──────────────────────────────────────────────────────────────── */
.legend {
  display: flex;
  gap: 1.5rem;
  margin-top: 2.5rem;
  flex-wrap: wrap;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border);
}

.legend-item {
  display: flex;
  align-items: center;
  gap: .5rem;
  font-size: .8rem;
  color: var(--text2);
}

.legend-sq {
  width: 12px;
  height: 12px;
  border-radius: 2px;
  flex-shrink: 0;
}
.legend-sq.lived     { background: var(--lived); }
.legend-sq.current   { background: var(--current); }
.legend-sq.remaining { background: var(--remaining); outline: 1px solid var(--border); }

/* ── RESPONSIVE ──────────────────────────────────────────────────────────── */
@media (max-width: 768px) {
  .cal-header  { padding: .75rem 1rem 0; }
  .cal-main    { padding: 1rem .75rem; }

  .brand h1    { font-size: 1.6rem; }
  #form-profile { padding: 1.5rem; }

  .header-stats { gap: .4rem; }
  .stat-pill    { padding: .35rem .65rem; min-width: 68px; }
  .stat-num     { font-size: 1rem; }

  .view-anos { grid-template-columns: repeat(auto-fill, minmax(36px, 36px)); gap: 4px; }
  .view-anos .sq { width: 36px; height: 36px; font-size: .5rem; }

  .view-semanas .sq { width: 7px; height: 7px; }
  .view-meses   .sq { width: 14px; height: 14px; }
}

@media (max-width: 480px) {
  .header-top  { flex-direction: column; }
  .view-btn    { padding: .5rem .8rem; font-size: .8rem; }
}
