:root {
  --bg: #0a0a0f;
  --panel: rgba(16, 14, 22, 0.86);
  --panel-solid: #121019;
  --line: rgba(255, 79, 163, 0.28);
  --pink: #ff4fa3;
  --pink-soft: #ff8cc6;
  --teal: #2de2d0;
  --teal-soft: #7ff5ea;
  --text: #f4eef6;
  --muted: #a99bb3;
  --comment: #7c6f86;
  --serif: 'Playfair Display', 'Cormorant Garamond', Georgia, serif;
  --elegant: 'Cormorant Garamond', Georgia, serif;
  --mono: 'JetBrains Mono', ui-monospace, Consolas, monospace;
  --radius: 14px;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--elegant);
  font-size: 19px;
  line-height: 1.6;
  overflow-x: hidden;
}
#binary-rain { position: fixed; inset: 0; z-index: 0; }
.app, .topbar, .toast { position: relative; z-index: 1; }
a { color: var(--teal); }
img { max-width: 100%; display: block; }
[hidden] { display: none !important; }

/* ---------- Colores de sintaxis ---------- */
.c-pink { color: var(--pink); }
.c-teal { color: var(--teal); }
.kw   { color: var(--pink); }
.fn   { color: var(--teal); }
.str  { color: #ffd1e8; }
.prop { color: var(--teal-soft); }
.num  { color: #f7a8d0; }
.cm   { color: var(--comment); font-style: italic; }
.punc { color: var(--muted); }

.code {
  font-family: var(--mono);
  font-size: 15px;
  line-height: 1.8;
  white-space: pre-wrap;
  word-break: break-word;
}

/* ---------- Topbar ---------- */
.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 14px 24px;
  background: rgba(10, 10, 15, 0.8);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 5;
  flex-wrap: wrap;
}
.brand { font-family: var(--mono); font-weight: 600; font-size: 18px; color: var(--text); text-decoration: none; }
#nav { display: flex; gap: 6px; flex-wrap: wrap; }
#nav a, #nav button {
  font-family: var(--mono); font-size: 13px; color: var(--muted);
  background: none; border: 1px solid transparent; border-radius: 8px;
  padding: 6px 10px; cursor: pointer; text-decoration: none;
}
#nav a:hover, #nav button:hover, #nav a.active { color: var(--teal); border-color: rgba(45, 226, 208, 0.35); }

.app { max-width: 1080px; margin: 0 auto; padding: 32px 16px 80px; }

/* ---------- Inicio ---------- */
.home {
  min-height: calc(100vh - 64px);
  display: grid; place-items: center; text-align: center;
}
.terminal {
  width: min(640px, 100%);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: 0 0 60px rgba(255, 79, 163, 0.15), 0 0 120px rgba(45, 226, 208, 0.08);
  overflow: hidden;
  text-align: left;
}
.terminal-bar {
  display: flex; gap: 8px; align-items: center;
  padding: 10px 14px; border-bottom: 1px solid var(--line);
  font-family: var(--mono); font-size: 12px; color: var(--muted);
}
.dot { width: 11px; height: 11px; border-radius: 50%; }
.dot.p { background: var(--pink); } .dot.t { background: var(--teal); } .dot.w { background: #f4eef6; opacity: .5; }
.terminal-bar span:last-child { margin-left: auto; }
.terminal-body { padding: 28px 28px 32px; }
.hello {
  font-family: var(--serif); font-style: italic; font-weight: 700;
  font-size: clamp(44px, 9vw, 76px); line-height: 1.05; margin: 8px 0 4px;
  background: linear-gradient(90deg, var(--pink), var(--pink-soft) 45%, var(--teal));
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.cursor::after { content: '▍'; color: var(--teal); animation: blink 1s steps(1) infinite; -webkit-text-fill-color: var(--teal); }
@keyframes blink { 50% { opacity: 0; } }
.choices { display: grid; gap: 14px; margin-top: 28px; }
.choice {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  width: 100%; padding: 16px 20px;
  font-family: var(--mono); font-size: 16px; color: var(--text);
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--line); border-radius: 12px; cursor: pointer;
  text-decoration: none; transition: all .2s ease;
}
.choice:hover { border-color: var(--teal); box-shadow: 0 0 24px rgba(45, 226, 208, 0.25); transform: translateY(-1px); }
.choice .arrow { color: var(--pink); }

/* ---------- Secciones ---------- */
.section { margin: 0 0 40px; }
.section-title {
  font-family: var(--mono); font-size: 15px; color: var(--muted);
  margin: 0 0 14px; font-weight: 400;
}
.section-title b { font-family: var(--serif); font-style: italic; font-size: 30px; color: var(--text); font-weight: 700; margin: 0 6px; }
.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 24px;
}

.hero { display: grid; grid-template-columns: 200px 1fr; gap: 28px; align-items: center; }
.avatar {
  width: 200px; height: 200px; border-radius: 50%; object-fit: cover;
  border: 3px solid var(--pink);
  box-shadow: 0 0 0 6px rgba(45, 226, 208, 0.25), 0 0 40px rgba(255, 79, 163, 0.35);
  background: var(--panel-solid);
}
.avatar.placeholder { display: grid; place-items: center; font-family: var(--mono); font-size: 48px; color: var(--pink); }
.hero h1 { font-family: var(--serif); font-style: italic; font-size: clamp(36px, 6vw, 54px); margin: 0; line-height: 1.1; }
.hero .role { font-family: var(--mono); color: var(--teal); font-size: 15px; margin: 6px 0 14px; }
.hero p { margin: 0; color: #e6dcea; }

.tags { display: flex; flex-wrap: wrap; gap: 8px; margin: 0; padding: 0; list-style: none; }
.tag {
  font-family: var(--mono); font-size: 13px;
  padding: 4px 10px; border-radius: 999px;
  border: 1px solid rgba(45, 226, 208, 0.45); color: var(--teal-soft);
}
.tag.pink { border-color: rgba(255, 79, 163, 0.5); color: var(--pink-soft); }

.btn {
  display: inline-flex; align-items: center; gap: 8px;
  font-family: var(--mono); font-size: 14px;
  padding: 10px 16px; border-radius: 10px; cursor: pointer;
  border: 1px solid var(--pink); color: var(--text);
  background: linear-gradient(135deg, rgba(255, 79, 163, 0.25), rgba(45, 226, 208, 0.15));
  text-decoration: none; transition: all .2s ease;
}
.btn:hover { box-shadow: 0 0 20px rgba(255, 79, 163, 0.4); }
.btn.ghost { background: transparent; border-color: var(--line); color: var(--muted); }
.btn.danger { border-color: #ff5a6e; background: rgba(255, 90, 110, 0.12); }
.btn:disabled { opacity: .5; cursor: wait; }
.btn-row { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 18px; }

/* ---------- CV ---------- */
.timeline { display: grid; gap: 16px; }
.tl-item { border-left: 2px solid var(--pink); padding: 2px 0 2px 18px; }
.tl-item h4 { font-family: var(--serif); margin: 0; font-size: 22px; }
.tl-item .meta { font-family: var(--mono); font-size: 13px; color: var(--teal); }
.tl-item p { margin: 6px 0 0; color: #ddd2e2; }
.cv-cols { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 20px; }
.cv-cols h3 { font-family: var(--mono); font-size: 14px; color: var(--pink); font-weight: 400; margin: 0 0 12px; }

/* ---------- Fotos ---------- */
.gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 14px; }
.gallery figure { margin: 0; border-radius: 12px; overflow: hidden; border: 1px solid var(--line); background: var(--panel-solid); cursor: zoom-in; }
.gallery img { width: 100%; aspect-ratio: 1; object-fit: cover; transition: transform .3s ease; }
.gallery figure:hover img { transform: scale(1.04); }
.gallery figcaption { font-size: 15px; padding: 8px 10px; color: var(--muted); font-style: italic; }
.lightbox { position: fixed; inset: 0; z-index: 20; background: rgba(5, 5, 8, 0.92); display: grid; place-items: center; padding: 24px; cursor: zoom-out; }
.lightbox img { max-height: 88vh; border-radius: 12px; border: 1px solid var(--pink); }
.lightbox video { max-width: 100%; max-height: 88vh; border-radius: 12px; border: 1px solid var(--pink); cursor: default; }
.lightbox iframe { width: min(1100px, 100%); aspect-ratio: 16 / 9; border: 1px solid var(--pink); border-radius: 12px; }
.lightbox .close { position: absolute; top: 14px; right: 16px; background: none; border: 0; color: var(--pink); font-size: 26px; cursor: pointer; }

/* Carrusel "Mis proyectos en acción" */
.carousel { position: relative; }
.carousel .track { display: flex; overflow-x: auto; scroll-snap-type: x mandatory; scroll-behavior: smooth; scrollbar-width: none; border-radius: 14px; border: 1px solid var(--line); background: var(--panel-solid); }
.carousel .track::-webkit-scrollbar { display: none; }
.carousel .slide { flex: 0 0 100%; margin: 0; scroll-snap-align: start; position: relative; cursor: zoom-in; }
.carousel .slide img, .carousel .slide video { display: block; width: 100%; aspect-ratio: 16 / 9; object-fit: cover; background: #000; }
.carousel .slide figcaption { font-family: var(--mono); font-size: 13px; padding: 10px 14px; }
.carousel .play { position: absolute; top: 12px; left: 12px; padding: 4px 10px; border-radius: 8px; background: rgba(10, 10, 15, .75); color: var(--pink); font-size: 14px; pointer-events: none; }
.carousel .nav { position: absolute; top: calc(50% - 40px); width: 40px; height: 40px; border-radius: 50%; border: 1px solid var(--pink); background: rgba(10, 10, 15, .7); color: var(--pink); font-size: 24px; line-height: 1; cursor: pointer; }
.carousel .prev { left: 10px; } .carousel .next { right: 10px; }
.carousel .dots { display: flex; justify-content: center; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.carousel .dots button { width: 9px; height: 9px; padding: 0; border-radius: 50%; border: 1px solid var(--pink); background: transparent; cursor: pointer; }
.carousel .dots button.active { background: var(--pink); }

/* ---------- Proyectos ---------- */
.projects { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 18px; }
.project-card {
  display: flex; flex-direction: column; gap: 12px;
  text-decoration: none; color: inherit; transition: all .2s ease;
}
.project-card:hover { border-color: var(--teal); transform: translateY(-2px); box-shadow: 0 0 30px rgba(45, 226, 208, 0.2); }
.project-card img { border-radius: 10px; aspect-ratio: 16 / 9; object-fit: cover; }
.project-card h3 { font-family: var(--serif); font-style: italic; margin: 0; font-size: 26px; }
.project-card p { margin: 0; color: #ddd2e2; flex: 1; }
.project-detail h1 { font-family: var(--serif); font-style: italic; font-size: clamp(36px, 6vw, 56px); margin: 0 0 8px; }
.project-detail .cover { border-radius: 12px; margin: 16px 0; border: 1px solid var(--line); }
.detail-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 18px; margin-top: 18px; }
.detail-grid h3, .project-detail h2 { font-family: var(--mono); font-size: 14px; color: var(--pink); font-weight: 400; margin: 0 0 10px; }
.prose { white-space: pre-line; }

/* Lista de proyectos tipo explorador de archivos */
.tree { display: grid; gap: 4px; }
.tree-item {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 12px; border-radius: 10px;
  color: var(--text); text-decoration: none; transition: all .2s ease;
}
.tree-name { font-family: var(--serif); font-style: italic; font-size: 24px; flex: 1; }
.tree-open { color: var(--comment); font-size: 13px; opacity: 0; transition: opacity .2s ease; }
.tree-item:hover { background: rgba(45, 226, 208, 0.08); box-shadow: inset 2px 0 0 var(--teal); }
.tree-item:hover .tree-name { color: var(--pink-soft); }
.tree-item:hover .tree-open { opacity: 1; color: var(--teal); }

/* Diagramas dentro del detalle de un proyecto */
.diagrams { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 14px; }
.diagrams figure { margin: 0; border: 1px solid var(--line); border-radius: 12px; overflow: hidden; background: var(--panel-solid); cursor: zoom-in; }
.diagrams img { width: 100%; height: auto; }
.diagrams figure.video-fig { cursor: default; }
.diagrams video, .diagrams iframe { display: block; width: 100%; aspect-ratio: 16 / 9; border: 0; background: #000; }
.diagrams figure.mermaid-fig { background: var(--panel-solid); cursor: default; grid-column: 1 / -1; }
.mermaid-box { overflow-x: auto; padding: 16px; }
.mermaid-box pre.mermaid { margin: 0; color: var(--comment); font-size: 12px; }
.mermaid-box svg { max-width: 100%; height: auto; margin: 0 auto; display: block; }
.diagrams figcaption { background: var(--panel-solid); color: var(--muted); font-size: 15px; font-style: italic; padding: 8px 10px; }
@media (max-width: 700px) { .tree-open { opacity: 1; } .tree-name { font-size: 20px; } }
.empty { font-family: var(--mono); color: var(--comment); font-size: 14px; }

/* ---------- Formularios ---------- */
.form { display: grid; gap: 14px; }
.form .row { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 14px; }
label { display: grid; gap: 6px; font-family: var(--mono); font-size: 13px; color: var(--teal); }
input, textarea, select {
  font-family: var(--mono); font-size: 14px; color: var(--text);
  background: rgba(0, 0, 0, 0.45);
  border: 1px solid var(--line); border-radius: 10px;
  padding: 10px 12px; width: 100%;
}
textarea { min-height: 110px; resize: vertical; line-height: 1.6; }
input:focus, textarea:focus, select:focus { outline: none; border-color: var(--teal); box-shadow: 0 0 0 3px rgba(45, 226, 208, 0.2); }
input[type=file] { padding: 8px; }
.hint { font-size: 12px; color: var(--comment); font-family: var(--mono); }

.login { max-width: 460px; margin: 8vh auto 0; }
.error { color: #ff7a8e; font-family: var(--mono); font-size: 13px; min-height: 1em; }

/* ---------- Admin ---------- */
.tabs { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 20px; }
.tabs button {
  font-family: var(--mono); font-size: 14px; color: var(--muted);
  background: var(--panel); border: 1px solid var(--line); border-radius: 10px;
  padding: 8px 14px; cursor: pointer;
}
.tabs button.active { color: var(--text); border-color: var(--pink); box-shadow: 0 0 16px rgba(255, 79, 163, 0.3); }
.list { display: grid; gap: 10px; margin-top: 18px; }
.list-item {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 12px 14px; border: 1px solid var(--line); border-radius: 10px; background: rgba(0,0,0,.3);
}
.list-item .t { font-family: var(--mono); font-size: 14px; }
.list-item .actions { display: flex; gap: 6px; flex-shrink: 0; }
.list-item .btn { padding: 6px 10px; font-size: 12px; }
.thumbs { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 12px; margin-top: 18px; }
.thumb { position: relative; border-radius: 10px; overflow: hidden; border: 1px solid var(--line); }
.thumb img, .thumb video { aspect-ratio: 1; object-fit: cover; width: 100%; display: block; }
.thumb button { position: absolute; top: 6px; right: 6px; }

.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%) translateY(120px);
  z-index: 30; font-family: var(--mono); font-size: 14px;
  background: var(--panel-solid); border: 1px solid var(--teal); border-radius: 10px;
  padding: 10px 18px; transition: transform .3s ease, visibility .3s;
  visibility: hidden;
}
.toast.show { transform: translateX(-50%) translateY(0); visibility: visible; }
.toast.err { border-color: #ff5a6e; }

@media (max-width: 700px) {
  body { font-size: 18px; }
  .hero { grid-template-columns: 1fr; text-align: center; justify-items: center; }
  .avatar { width: 150px; height: 150px; }
  .terminal-body { padding: 22px 18px; }
  .card { padding: 18px; }
  .topbar { padding: 12px 16px; }
  .code { font-size: 13px; }
}
