:root {
  --bg: #0b0d17;
  --bg-soft: #11142a;
  --surface: rgba(255, 255, 255, 0.04);
  --surface-hover: rgba(255, 255, 255, 0.09);
  --border: rgba(255, 255, 255, 0.09);
  --text: #f4f5fb;
  --text-dim: #9aa0b8;
  --accent-1: #6d5cff;
  --accent-2: #22d3ee;
  --accent-3: #f472b6;
  --radius: 20px;
}

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

html {
  scroll-behavior: smooth;
}

body {
  font-family: "Sora", system-ui, -apple-system, "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  overflow-x: hidden;
  position: relative;
}

/* ---------- Fondo decorativo ---------- */
.bg-decoration {
  position: fixed;
  inset: 0;
  z-index: -1;
  overflow: hidden;
  background:
    radial-gradient(1200px 600px at 80% -10%, rgba(109, 92, 255, 0.18), transparent 60%),
    radial-gradient(900px 500px at -10% 20%, rgba(34, 211, 238, 0.12), transparent 55%),
    radial-gradient(900px 600px at 50% 110%, rgba(244, 114, 182, 0.12), transparent 55%),
    var(--bg);
}

.blob {
  position: absolute;
  border-radius: 50%;
  filter: blur(90px);
  opacity: 0.45;
  animation: float 18s ease-in-out infinite;
}

.blob-1 {
  width: 420px;
  height: 420px;
  background: rgba(109, 92, 255, 0.35);
  top: -140px;
  right: -100px;
}

.blob-2 {
  width: 340px;
  height: 340px;
  background: rgba(34, 211, 238, 0.28);
  bottom: -120px;
  left: -90px;
  animation-delay: -6s;
}

.blob-3 {
  width: 260px;
  height: 260px;
  background: rgba(244, 114, 182, 0.25);
  top: 45%;
  left: 60%;
  animation-delay: -12s;
}

@keyframes float {
  0%, 100% { transform: translate(0, 0) scale(1); }
  50% { transform: translate(40px, -30px) scale(1.08); }
}

/* ---------- Header ---------- */
.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 22px clamp(18px, 4vw, 48px);
  max-width: 1200px;
  margin: 0 auto;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 14px;
}

.logout-btn {
  padding: 8px 16px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-dim);
  font-family: inherit;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s ease, color 0.2s ease, border-color 0.2s ease;
}

.logout-btn:hover {
  background: rgba(244, 63, 94, 0.15);
  border-color: rgba(244, 63, 94, 0.5);
  color: #fb7185;
}

.logo {
  display: flex;
  align-items: center;
  gap: 12px;
}

.logo-icon {
  font-size: 1.6rem;
  display: grid;
  place-items: center;
  width: 46px;
  height: 46px;
  border-radius: 14px;
  background: linear-gradient(135deg, var(--accent-1), var(--accent-2));
  box-shadow: 0 8px 24px rgba(109, 92, 255, 0.4);
}

.logo-text {
  font-weight: 800;
  font-size: 1.25rem;
  letter-spacing: -0.02em;
}

.date {
  color: var(--text-dim);
  font-size: 0.85rem;
  font-weight: 600;
}

/* ---------- Hero ---------- */
.main {
  max-width: 1200px;
  margin: 0 auto;
  padding: 30px clamp(18px, 4vw, 48px) 60px;
}

.hero {
  text-align: center;
  padding: 14px 0 40px;
}

.hero-title {
  font-size: clamp(1.9rem, 5vw, 3.2rem);
  font-weight: 800;
  letter-spacing: -0.03em;
  background: linear-gradient(120deg, #ffffff 0%, #c9d0ff 55%, #8be9f8 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.hero-sub {
  margin-top: 12px;
  color: var(--text-dim);
  font-size: clamp(0.95rem, 2.5vw, 1.1rem);
  font-weight: 400;
}

/* ---------- Grid de apps ---------- */
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 20px;
}

.card {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 24px;
  border-radius: var(--radius);
  background: var(--surface);
  border: 1px solid var(--border);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  text-decoration: none;
  color: var(--text);
  overflow: hidden;
  transition: transform 0.25s ease, background 0.25s ease, border-color 0.25s ease, box-shadow 0.25s ease;
  animation: fade-up 0.6s ease both;
}

.card::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--c1, var(--accent-1)), var(--c2, var(--accent-2)));
  opacity: 0.6;
  transition: opacity 0.25s ease;
}

.card:hover,
.card:focus-visible {
  transform: translateY(-6px);
  background: var(--surface-hover);
  border-color: rgba(255, 255, 255, 0.2);
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.35);
}

.card:hover::before {
  opacity: 1;
}

.card-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.card-icon {
  display: grid;
  place-items: center;
  width: 52px;
  height: 52px;
  font-size: 1.6rem;
  border-radius: 16px;
  background: linear-gradient(135deg, var(--c1, var(--accent-1)), var(--c2, var(--accent-2)));
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.3);
}

.card-arrow {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.07);
  color: var(--text-dim);
  transition: background 0.25s ease, color 0.25s ease, transform 0.25s ease;
}

.card:hover .card-arrow {
  background: var(--c1, var(--accent-1));
  color: #fff;
  transform: translate(3px, -3px);
}

.card h2 {
  font-size: 1.2rem;
  font-weight: 700;
}

.card p {
  color: var(--text-dim);
  font-size: 0.9rem;
  line-height: 1.5;
}

/* Tarjeta pendiente (sin link aún) */
.card.pending {
  opacity: 0.75;
  cursor: not-allowed;
}

.card.pending .card-arrow {
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-dim);
}

.card.pending:hover {
  transform: none;
  box-shadow: none;
  background: var(--surface);
  border-color: var(--border);
}

.card.pending::after {
  content: "Próximamente";
  position: absolute;
  top: 18px;
  right: -34px;
  transform: rotate(38deg);
  background: linear-gradient(90deg, var(--accent-3), var(--accent-1));
  color: #fff;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  padding: 5px 40px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

/* ---------- Botones de editar / eliminar en tarjeta ---------- */
.card-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.card-delete,
.card-edit {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-dim);
  font-size: 0.72rem;
  cursor: pointer;
  transition: background 0.2s ease, color 0.2s ease, border-color 0.2s ease;
  opacity: 0;
}

.card:hover .card-delete,
.card:focus-within .card-delete,
.card:hover .card-edit,
.card:focus-within .card-edit {
  opacity: 1;
}

.card-delete:hover {
  background: #f43f5e;
  border-color: transparent;
  color: #fff;
}

.card-edit:hover {
  background: #22d3ee;
  border-color: transparent;
  color: #fff;
}

@media (hover: none) {
  .card-delete,
  .card-edit {
    opacity: 1;
  }
}

/* ---------- Tarjeta para agregar app ---------- */
.add-tile {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  min-height: 190px;
  padding: 24px;
  border-radius: var(--radius);
  background: transparent;
  border: 2px dashed rgba(255, 255, 255, 0.18);
  color: var(--text-dim);
  font-family: inherit;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: border-color 0.25s ease, color 0.25s ease, background 0.25s ease;
}

.add-tile:hover {
  border-color: var(--accent-2);
  color: var(--text);
  background: rgba(34, 211, 238, 0.06);
}

.add-icon {
  display: grid;
  place-items: center;
  width: 46px;
  height: 46px;
  font-size: 1.5rem;
  font-weight: 400;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent-1), var(--accent-2));
  color: #fff;
  transition: transform 0.25s ease;
}

.add-tile:hover .add-icon {
  transform: rotate(90deg);
}

/* ---------- Login ---------- */
.login-screen {
  position: fixed;
  inset: 0;
  z-index: 90;
  display: grid;
  place-items: center;
  padding: 20px;
}

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

.login-card {
  width: 100%;
  max-width: 400px;
  padding: 40px 32px;
  border-radius: var(--radius);
  background: rgba(17, 20, 42, 0.85);
  border: 1px solid var(--border);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  box-shadow: 0 30px 70px rgba(0, 0, 0, 0.55);
  text-align: center;
  animation: fade-up 0.4s ease both;
}

.login-logo {
  justify-content: center;
  margin-bottom: 22px;
}

.login-title {
  font-size: 1.7rem;
  font-weight: 800;
  letter-spacing: -0.02em;
}

.login-sub {
  margin: 8px 0 26px;
  color: var(--text-dim);
  font-size: 0.9rem;
}

.login-card form {
  text-align: left;
}

.password-row {
  display: flex;
  gap: 10px;
}

.password-row input {
  flex: 1;
}

.pass-toggle {
  display: grid;
  place-items: center;
  width: 46px;
  flex-shrink: 0;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.04);
  color: var(--text-dim);
  font-size: 1rem;
  cursor: pointer;
  transition: background 0.2s ease, border-color 0.2s ease;
}

.pass-toggle:hover {
  background: rgba(255, 255, 255, 0.1);
  border-color: var(--accent-2);
}

/* ---------- Modal ---------- */
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(5, 7, 15, 0.72);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

.modal-backdrop[hidden] {
  display: none;
}

.modal {
  width: 100%;
  max-width: 440px;
  max-height: 92vh;
  overflow-y: auto;
  padding: 26px;
  border-radius: var(--radius);
  background: var(--bg-soft);
  border: 1px solid var(--border);
  box-shadow: 0 30px 70px rgba(0, 0, 0, 0.55);
  animation: fade-up 0.25s ease both;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}

.modal-header h2 {
  font-size: 1.25rem;
  font-weight: 700;
}

.modal-close {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-dim);
  font-size: 0.85rem;
  cursor: pointer;
  transition: background 0.2s ease, color 0.2s ease;
}

.modal-close:hover {
  background: rgba(255, 255, 255, 0.12);
  color: var(--text);
}

.field {
  margin-bottom: 16px;
}

.field label {
  display: block;
  margin-bottom: 7px;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-dim);
}

.req {
  color: var(--accent-3);
}

.field input {
  width: 100%;
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.04);
  color: var(--text);
  font-family: inherit;
  font-size: 0.95rem;
  outline: none;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.field input::placeholder {
  color: rgba(154, 160, 184, 0.55);
}

.field input:focus {
  border-color: var(--accent-2);
  box-shadow: 0 0 0 3px rgba(34, 211, 238, 0.15);
}

.color-presets {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.color-dot {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 2px solid transparent;
  cursor: pointer;
  transition: transform 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
}

.color-dot:hover {
  transform: scale(1.12);
}

.color-dot.selected {
  border-color: #fff;
  box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.25);
}

.form-error {
  min-height: 18px;
  margin: 2px 0 12px;
  color: #fb7185;
  font-size: 0.82rem;
  font-weight: 600;
}

/* ---------- Selector de emojis ---------- */
.icon-row {
  display: flex;
  gap: 10px;
}

.icon-row input {
  flex: 1;
}

.emoji-toggle {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 0 14px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.04);
  color: var(--text);
  font-size: 1rem;
  cursor: pointer;
  transition: background 0.2s ease, border-color 0.2s ease;
}

.emoji-toggle:hover {
  background: rgba(255, 255, 255, 0.1);
  border-color: var(--accent-2);
}

.chevron {
  color: var(--text-dim);
  font-size: 0.7rem;
  transition: transform 0.2s ease;
}

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

.emoji-picker {
  margin-top: 10px;
  padding: 12px;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(40px, 1fr));
  gap: 6px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.04);
  max-height: 190px;
  overflow-y: auto;
}

.emoji-picker[hidden] {
  display: none;
}

.emoji-opt {
  display: grid;
  place-items: center;
  aspect-ratio: 1;
  border: none;
  border-radius: 10px;
  background: transparent;
  font-size: 1.35rem;
  cursor: pointer;
  transition: background 0.15s ease, transform 0.15s ease;
}

.emoji-opt:hover {
  background: rgba(255, 255, 255, 0.12);
  transform: scale(1.15);
}

.btn-primary {
  width: 100%;
  padding: 13px;
  border: none;
  border-radius: 14px;
  background: linear-gradient(135deg, var(--accent-1), var(--accent-2));
  color: #fff;
  font-family: inherit;
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.2s ease, opacity 0.2s ease;
}

.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 12px 28px rgba(109, 92, 255, 0.4);
}

.btn-primary:active {
  opacity: 0.85;
}

/* ---------- Footer ---------- */
.footer {
  text-align: center;
  padding: 30px 16px 40px;
  color: var(--text-dim);
  font-size: 0.85rem;
}

.heart {
  color: var(--accent-3);
}

/* ---------- Animaciones ---------- */
@keyframes fade-up {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ---------- Accesibilidad / responsive ---------- */
@media (prefers-reduced-motion: reduce) {
  * {
    animation: none !important;
    transition: none !important;
  }
}

@media (max-width: 520px) {
  .grid {
    grid-template-columns: 1fr;
    gap: 16px;
  }

  .header {
    padding-top: 18px;
  }

  .date {
    display: none;
  }
}
