:root{
    --bg: #0D1117;
    --surface: #121821;
    --surface-2: #161D27;
    --border: #232B36;
    --border-soft: #1A212B;
    --text: #E7E9EC;
    --text-muted: #8B95A3;
    --text-faint: #5B6472;
    --accent: #FF8A3D;
    --accent-soft: rgba(255,138,61,0.12);
    --ok: #4FD1A5;
    --font-head: 'Sora', sans-serif;
    --font-body: 'Inter', sans-serif;
    --font-mono: 'IBM Plex Mono', monospace;
    --maxw: 720px;
  }

  *{ box-sizing: border-box; }
  html{ scroll-behavior: smooth; }

  @media (prefers-reduced-motion: reduce){
    html{ scroll-behavior: auto; }
    *{ animation-duration: 0.001ms !important; animation-iteration-count: 1 !important; transition-duration: 0.001ms !important; }
  }

  body{
    margin: 0;
    background:
      radial-gradient(circle, rgba(255,255,255,0.035) 1px, transparent 1px) 0 0/26px 26px,
      var(--bg);
    color: var(--text);
    font-family: var(--font-body);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
  }

  a{ color: inherit; text-decoration: none; }
  ul{ margin: 0; padding: 0; list-style: none; }

  :focus-visible{
    outline: 2px solid var(--accent);
    outline-offset: 3px;
  }

  /* ---------- Layout ---------- */
  .layout{
    display: grid;
    grid-template-columns: 260px 1fr;
    min-height: 100vh;
  }

  .sidebar{
    position: sticky;
    top: 0;
    height: 100vh;
    padding: 40px 32px;
    border-right: 1px solid var(--border-soft);
    display: flex;
    flex-direction: column;
    justify-content: space-between;
  }

  .brand{
    display: flex;
    flex-direction: column;
    gap: 4px;
    margin-bottom: 48px;
  }

  .brand-name{
    font-family: var(--font-head);
    font-weight: 600;
    font-size: 18px;
    letter-spacing: -0.01em;
  }

  .brand-role{
    color: var(--text-muted);
    font-size: 13px;
  }

  .status-pill{
    display: inline-flex;
    align-items: center;
    gap: 7px;
    margin-top: 14px;
    padding: 6px 10px;
    border: 1px solid var(--border);
    border-radius: 3px;
    font-family: var(--font-mono);
    font-size: 11px;
    color: var(--text-muted);
    width: fit-content;
  }

  .status-dot{
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--ok);
    box-shadow: 0 0 0 3px rgba(79,209,165,0.15);
  }

  nav.routes ul{
    display: flex;
    flex-direction: column;
    gap: 2px;
  }

  nav.routes a{
    display: block;
    padding: 9px 10px;
    margin: 0 -10px;
    border-radius: 4px;
    font-family: var(--font-mono);
    font-size: 13px;
    color: var(--text-muted);
    transition: color .15s ease, background .15s ease;
  }

  nav.routes a:hover,
  nav.routes a.active{
    color: var(--accent);
    background: var(--accent-soft);
  }

  .sidebar-footer{
    display: flex;
    flex-direction: column;
    gap: 10px;
  }

  .cv-btn{
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 11px 14px;
    background: var(--accent);
    color: #14100B;
    font-weight: 600;
    font-size: 13px;
    border-radius: 4px;
    transition: background .15s ease;
  }

  .cv-btn:hover{ background: #ff9a54; }

  .social-row{
    display: flex;
    gap: 14px;
    font-size: 12px;
    color: var(--text-faint);
  }

  .social-row a{ transition: color .15s ease; }
  .social-row a:hover{ color: var(--text); }

  /* mobile top bar */
  .mobile-bar{ display: none; }

  /* ---------- Main content ---------- */
  main{
    padding: 64px 48px 40px;
  }

  section{
    max-width: var(--maxw);
    margin: 0 auto 128px;
    scroll-margin-top: 32px;
  }

  .section-label{
    font-family: var(--font-mono);
    font-size: 12px;
    color: var(--text-faint);
    margin: 0 0 14px;
  }

  h2{
    font-family: var(--font-head);
    font-size: 26px;
    font-weight: 600;
    letter-spacing: -0.01em;
    margin: 0 0 28px;
  }

  /* ---------- Hero ---------- */
  .hero{ margin-top: 8px; }

  .terminal{
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 6px;
    overflow: hidden;
    margin-bottom: 36px;
  }

  .terminal-head{
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 16px;
    border-bottom: 1px solid var(--border-soft);
    background: var(--surface-2);
  }

  .terminal-dot{
    width: 9px; height: 9px; border-radius: 50%;
    background: var(--border);
  }

  .terminal-path{
    font-family: var(--font-mono);
    font-size: 12px;
    color: var(--text-faint);
    margin-left: 4px;
  }

  .terminal-body{
    padding: 20px 22px 24px;
    font-family: var(--font-mono);
    font-size: 13.5px;
    line-height: 1.75;
  }

  .req-line{ color: var(--text-muted); margin-bottom: 2px; }
  .status-line{ color: var(--ok); margin-bottom: 14px; }
  .json-key{ color: #7DB2FF; }
  .json-string{ color: var(--accent); }
  .json-punct{ color: var(--text-faint); }

  .terminal-body .cursor{
    display: inline-block;
    width: 7px; height: 14px;
    background: var(--accent);
    margin-left: 2px;
    animation: blink 1s steps(1) infinite;
    vertical-align: middle;
  }

  @keyframes blink{ 50%{ opacity: 0; } }

  .hero h1{
    font-family: var(--font-head);
    font-size: 40px;
    font-weight: 700;
    line-height: 1.2;
    letter-spacing: -0.02em;
    margin: 0 0 18px;
  }

  .hero p{
    color: var(--text-muted);
    font-size: 16px;
    max-width: 58ch;
    margin: 0;
  }

  /* ---------- Projects ---------- */
  .project{
    border: 1px solid var(--border);
    border-top: 2px solid var(--method-color, var(--accent));
    border-radius: 4px;
    padding: 24px 26px;
    margin-bottom: 18px;
    background: var(--surface);
    transition: border-color .15s ease;
  }

  .project:hover{ border-color: var(--border); border-top-color: var(--method-color, var(--accent)); }

  .project-top{
    display: flex;
    align-items: baseline;
    gap: 12px;
    margin-bottom: 10px;
    flex-wrap: wrap;
  }

  .method{
    font-family: var(--font-mono);
    font-size: 11px;
    font-weight: 500;
    padding: 3px 7px;
    border-radius: 3px;
    color: var(--method-color, var(--accent));
    background: color-mix(in srgb, var(--method-color, var(--accent)) 14%, transparent);
  }

  .project-path{
    font-family: var(--font-mono);
    font-size: 13px;
    color: var(--text-faint);
  }

  .project h3{
    font-family: var(--font-head);
    font-size: 18px;
    font-weight: 600;
    margin: 4px 0 10px;
  }

  .project p{
    color: var(--text-muted);
    font-size: 14.5px;
    margin: 0 0 16px;
    max-width: 62ch;
  }

  .stack-tags{
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 16px;
  }

  .stack-tags span{
    font-family: var(--font-mono);
    font-size: 11.5px;
    color: var(--text-muted);
    border: 1px solid var(--border);
    padding: 3px 8px;
    border-radius: 3px;
  }

  .project-links{
    display: flex;
    gap: 20px;
  }

  .project-links a{
    font-size: 13.5px;
    font-weight: 500;
    color: var(--text);
    border-bottom: 1px solid var(--border);
    padding-bottom: 1px;
    transition: border-color .15s ease, color .15s ease;
  }

  .project-links a:hover{
    color: var(--accent);
    border-color: var(--accent);
  }

  /* ---------- Skills ---------- */
  .skills-grid{
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 32px 40px;
  }

  .skill-group h4{
    font-family: var(--font-mono);
    font-size: 12.5px;
    font-weight: 500;
    color: var(--text-faint);
    margin: 0 0 12px;
    padding-bottom: 10px;
    border-bottom: 1px solid var(--border-soft);
  }

  .skill-group ul{
    display: flex;
    flex-direction: column;
    gap: 9px;
  }

  .skill-group li{
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 14.5px;
    color: var(--text);
  }

  .skill-group li::before{
    content: '';
    width: 4px; height: 4px;
    background: var(--text-faint);
    border-radius: 50%;
    flex-shrink: 0;
  }

  /* ---------- Contact ---------- */
  .contact-box{
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 32px 34px;
  }

  .contact-box p{
    color: var(--text-muted);
    font-size: 15px;
    margin: 0 0 24px;
    max-width: 50ch;
  }

  .contact-list{
    display: flex;
    flex-direction: column;
    gap: 14px;
    margin-bottom: 26px;
  }

  .contact-list li{
    display: flex;
    gap: 12px;
    align-items: baseline;
    font-size: 14.5px;
  }

  .contact-list .k{
    font-family: var(--font-mono);
    font-size: 12px;
    color: var(--text-faint);
    width: 72px;
    flex-shrink: 0;
  }

  .contact-list a{
    color: var(--text);
    border-bottom: 1px solid var(--border);
    transition: color .15s ease, border-color .15s ease;
  }

  .contact-list a:hover{ color: var(--accent); border-color: var(--accent); }

  footer{
    max-width: var(--maxw);
    margin: 0 auto;
    padding: 32px 0 0;
    color: var(--text-faint);
    font-size: 12.5px;
    display: flex;
    justify-content: space-between;
  }

  /* ---------- Sobre mí ---------- */
  .about-grid{
    display: grid;
    grid-template-columns: 240px 1fr;
    gap: 40px;
    align-items: start;
  }

  .photo-frame{
    position: relative;
    aspect-ratio: 4 / 5;
    border: 1px solid var(--border);
    border-radius: 4px;
    overflow: hidden;
    background:
      repeating-linear-gradient(
        var(--surface) 0px, var(--surface) 18px,
        var(--surface-2) 18px, var(--surface-2) 19px
      );
  }

  .photo-frame img{
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
  }

  .photo-frame::before,
  .photo-frame::after{
    content: '';
    position: absolute;
    width: 16px;
    height: 16px;
    z-index: 2;
  }
  .photo-frame::before{
    top: 8px; left: 8px;
    border-top: 2px solid var(--accent);
    border-left: 2px solid var(--accent);
  }
  .photo-frame::after{
    bottom: 8px; right: 8px;
    border-bottom: 2px solid var(--accent);
    border-right: 2px solid var(--accent);
  }

  .photo-placeholder-label{
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 24px;
    font-family: var(--font-mono);
    font-size: 12px;
    color: var(--text-faint);
    line-height: 1.7;
    z-index: 1;
  }

  .facts-list{
    display: flex;
    flex-direction: column;
    gap: 20px;
    margin-bottom: 24px;
  }

  .fact{
    display: grid;
    grid-template-columns: 130px 1fr;
    gap: 16px;
    padding-bottom: 18px;
    border-bottom: 1px solid var(--border-soft);
  }

  .fact:last-child{ border-bottom: none; padding-bottom: 0; }

  .fact-label{
    font-family: var(--font-mono);
    font-size: 12.5px;
    color: var(--accent);
  }

  .fact-value{
    font-size: 14.5px;
    color: var(--text-muted);
  }

  .about-note{
    color: var(--text-muted);
    font-size: 14.5px;
    max-width: 56ch;
  }

  /* ---------- Mini diagrama de arquitectura ---------- */
  .arch-diagram{
    display: flex;
    align-items: center;
    margin: 4px 0 18px;
    padding: 16px 18px;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: 4px;
    overflow-x: auto;
  }

  .arch-node{
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    padding: 10px 14px;
    border: 1px solid var(--border);
    border-radius: 3px;
    background: var(--surface);
    font-family: var(--font-mono);
    font-size: 11.5px;
    color: var(--text);
    text-align: center;
    min-width: 84px;
  }

  .arch-node span{
    display: block;
    font-size: 10px;
    color: var(--text-faint);
  }

  .arch-connector{
    flex: 0 0 28px;
    height: 1px;
    background: var(--border);
    position: relative;
  }

  .arch-connector::after{
    content: '';
    position: absolute;
    right: 0; top: 50%;
    width: 5px; height: 5px;
    border-top: 1px solid var(--text-faint);
    border-right: 1px solid var(--text-faint);
    transform: translateY(-50%) rotate(45deg);
  }

  @media (max-width: 460px){
    .about-grid{ grid-template-columns: 1fr; }
    .photo-frame{ max-width: 220px; }
  }


  @media (max-width: 860px){
    .layout{ grid-template-columns: 1fr; }
    .sidebar{ display: none; }

    .mobile-bar{
      display: flex;
      align-items: center;
      justify-content: space-between;
      padding: 18px 24px;
      border-bottom: 1px solid var(--border-soft);
      position: sticky;
      top: 0;
      background: var(--bg);
      z-index: 10;
    }

    .mobile-bar .brand-name{ font-size: 16px; }
    .mobile-bar .cv-btn{ padding: 8px 14px; font-size: 12.5px; }

    main{ padding: 40px 24px 32px; }
    section{ margin-bottom: 88px; }
    .hero h1{ font-size: 30px; }
    .skills-grid{ grid-template-columns: 1fr; gap: 28px; }
    footer{ flex-direction: column; gap: 8px; }
  }

  @media (max-width: 460px){
    .terminal-body{ font-size: 12px; padding: 16px; }
    .project{ padding: 20px; }
  }
