:root {
  --bg: #fafaf9;
  --panel: #ffffff;
  --ink: #1c1917;
  --muted: #6b6b66;
  --line: #e7e5e4;
  --accent: #0f766e;
  --accent-ink: #115e59;
  --accent-soft: #e6f4f1;
  --warm: #b45309;
  --warm-soft: #fef3e2;
  --sidebar: 272px;
  --radius: 12px;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: 24px; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent-ink); text-decoration: none; }
a:hover { text-decoration: underline; }
::selection { background: var(--accent-soft); }

/* Sidebar */
.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  width: var(--sidebar);
  display: flex;
  flex-direction: column;
  gap: 24px;
  padding: 24px 18px;
  background: var(--panel);
  border-right: 1px solid var(--line);
  overflow-y: auto;
  z-index: 20;
}
.brand { display: flex; align-items: center; gap: 12px; color: var(--ink); }
.brand:hover { text-decoration: none; }
.brand-mark {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border-radius: 10px;
  background: var(--accent);
  color: #fff;
  font-weight: 700;
  letter-spacing: 0.5px;
}
.brand-text { display: flex; flex-direction: column; line-height: 1.25; }
.brand-text small { color: var(--muted); font-size: 12px; }

.nav { display: flex; flex-direction: column; gap: 2px; flex: 1; }
.nav a {
  padding: 7px 12px;
  border-radius: 8px;
  color: var(--muted);
  font-size: 14.5px;
  border-left: 2px solid transparent;
}
.nav a:hover { background: var(--bg); color: var(--ink); text-decoration: none; }
.nav a.active { color: var(--accent-ink); background: var(--accent-soft); font-weight: 600; }
.nav-sub { display: flex; flex-direction: column; gap: 1px; margin: 2px 0 6px 14px; border-left: 1px solid var(--line); }
.nav-sub a { font-size: 13.5px; padding: 5px 12px; }

.side-actions { display: flex; flex-direction: column; gap: 10px; }
.lang { display: grid; grid-template-columns: 1fr 1fr; background: var(--bg); border: 1px solid var(--line); border-radius: 10px; padding: 3px; }
.lang button {
  border: 0;
  background: transparent;
  padding: 6px;
  border-radius: 8px;
  font: 600 13px var(--sans);
  color: var(--muted);
  cursor: pointer;
}
.lang button.on { background: var(--panel); color: var(--accent-ink); box-shadow: 0 1px 2px rgba(0, 0, 0, 0.08); }
.ghost-btn {
  border: 1px solid var(--line);
  background: var(--panel);
  padding: 8px 12px;
  border-radius: 10px;
  font: 500 13.5px var(--sans);
  color: var(--ink);
  cursor: pointer;
}
.ghost-btn:hover { border-color: var(--accent); color: var(--accent-ink); }

.menu-btn { display: none; }

/* Content */
.content { margin-left: var(--sidebar); padding: 56px clamp(20px, 4vw, 72px) 40px; max-width: none; }
.content > section { max-width: none; }
.content > section.sub { margin-top: 56px; }
section { margin-bottom: 64px; }
section.sub { margin-bottom: 16px; }

h1 { font-size: clamp(34px, 5vw, 52px); line-height: 1.1; margin: 4px 0 18px; letter-spacing: -0.02em; }
h2 { font-size: 28px; margin: 0 0 22px; padding-bottom: 12px; border-bottom: 1px solid var(--line); letter-spacing: -0.01em; }
h3 { font-size: 23px; margin: 0 0 14px; letter-spacing: -0.01em; }
h4 { font-size: 15px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); margin: 32px 0 12px; }
p { margin: 0 0 14px; max-width: 130ch; }
.eyebrow { font: 600 13px var(--mono); text-transform: uppercase; letter-spacing: 0.1em; color: var(--muted); margin: 0; }
.eyebrow.accent { color: var(--accent); }
.lead { font-size: 18px; color: #3a3a36; max-width: 130ch; }
.lead.soft { color: var(--muted); font-size: 16.5px; }
code, .mono { font-family: var(--mono); font-size: 0.88em; background: #f1f0ee; padding: 1px 6px; border-radius: 5px; }

.hero { padding-top: 8px; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin: 30px 0 22px; }
.stat { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; }
.stat b { display: block; font-size: 28px; line-height: 1.1; color: var(--accent-ink); letter-spacing: -0.02em; }
.stat span { font-size: 13px; color: var(--muted); }
.hero-links { display: flex; flex-wrap: wrap; gap: 10px; }
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 9px 16px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--ink);
  font-weight: 500;
  font-size: 14.5px;
}
.btn:hover { text-decoration: none; border-color: var(--accent); color: var(--accent-ink); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { background: var(--accent-ink); color: #fff; }

.callout {
  margin-top: 18px;
  padding: 14px 18px;
  background: var(--warm-soft);
  border: 1px solid #f6dcb4;
  border-radius: var(--radius);
  color: #6b3a07;
  font-size: 14.5px;
}

/* Jobs */
.callout.owner { background: var(--accent-soft); border-color: #b5ded7; color: var(--accent-ink); margin: 0 0 8px; }
.feature-index { display: flex; flex-wrap: wrap; gap: 10px; margin: 4px 0 8px; }
h3.feat { display: flex; align-items: center; gap: 12px; font-size: 24px; margin: 52px 0 16px; padding-top: 28px; border-top: 1px solid var(--line); }
h3.feat span { display: grid; place-items: center; width: 34px; height: 34px; border-radius: 10px; background: var(--accent); color: #fff; font: 700 16px var(--mono); }
#hm h3.feat { margin-top: 28px; }
.results { margin: 8px 0 0; padding-left: 20px; }
.results li { margin: 6px 0; }
#hm .lead { font-size: 17px; }
.jobs { display: flex; flex-direction: column; gap: 16px; position: relative; }
.job {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px 22px;
}
.job.featured { border-color: #99d5cc; box-shadow: 0 0 0 3px var(--accent-soft); }
.job-head { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 6px 16px; align-items: baseline; }
.job h3 { font-size: 19px; margin: 0; }
.job .company { color: var(--accent-ink); }
.job .when { font: 500 13px var(--mono); color: var(--muted); }
.job .position { color: var(--muted); font-size: 14.5px; margin: 2px 0 10px; }
.job ul { margin: 0; padding-left: 20px; color: #3a3a36; font-size: 15px; }
.job li { margin: 3px 0; }
.job .go { display: inline-block; margin-top: 12px; font-weight: 600; font-size: 14.5px; }
.badge { display: inline-block; font: 600 11px var(--mono); text-transform: uppercase; letter-spacing: 0.06em; background: var(--accent); color: #fff; padding: 2px 8px; border-radius: 99px; margin-left: 8px; vertical-align: 2px; }
.earlier { margin-top: 18px; }
.earlier summary { cursor: pointer; font-weight: 600; color: var(--muted); padding: 8px 0; }
.jobs.compact { margin-top: 10px; }
.jobs.compact .job { padding: 14px 18px; }
.jobs.compact h3 { font-size: 16px; }

/* Cards / tags */
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); gap: 14px; margin: 18px 0; }
.cards.two { grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); }
.cards.three { grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px 20px; }
.card h5 { margin: 0 0 8px; font-size: 15.5px; }
.card p, .card li { font-size: 14.5px; color: #4a4a45; }
.card ul { margin: 0; padding-left: 18px; }
.card .ico { display: inline-grid; place-items: center; width: 30px; height: 30px; border-radius: 8px; background: var(--accent-soft); margin-bottom: 10px; font-size: 16px; }
.card.link { transition: border-color 0.15s, transform 0.15s; color: inherit; display: block; }
.card.link:hover { text-decoration: none; border-color: var(--accent); transform: translateY(-2px); }
.tags { display: flex; flex-wrap: wrap; gap: 8px; }
.tag { background: var(--panel); border: 1px solid var(--line); padding: 4px 12px; border-radius: 99px; font-size: 13.5px; color: #3a3a36; }
.tag.strong { background: var(--accent-soft); border-color: #b5ded7; color: var(--accent-ink); font-weight: 600; }

.table { width: 100%; border-collapse: collapse; font-size: 14.5px; margin: 14px 0; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.table th, .table td { text-align: left; padding: 10px 14px; border-bottom: 1px solid var(--line); vertical-align: top; }
.table th { background: #f5f5f4; font-size: 12.5px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); }
.table tr:last-child td { border-bottom: 0; }

/* Diagrams */
.diagram { margin: 18px 0 26px; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; }
.diagram-body { overflow-x: auto; text-align: center; min-height: 80px; }
.diagram-body svg { max-width: 100%; height: auto; }
.diagram.wide .diagram-body svg { min-width: 1000px; width: 100%; max-width: none !important; max-height: 760px; }
.diagram figcaption { margin-top: 10px; font-size: 13px; color: var(--muted); text-align: center; }
.diagram-body.loading::before { content: "…"; color: var(--muted); }
.diagram pre { text-align: left; font-size: 12px; white-space: pre-wrap; }

/* Phases */
.phases { display: flex; flex-direction: column; gap: 12px; }
.phase { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); }
.phase summary { list-style: none; cursor: pointer; display: grid; grid-template-columns: 44px 1fr auto; gap: 14px; align-items: center; padding: 16px 18px; }
.phase summary::-webkit-details-marker { display: none; }
.phase .num { display: grid; place-items: center; width: 40px; height: 40px; border-radius: 10px; background: var(--accent-soft); color: var(--accent-ink); font: 700 15px var(--mono); }
.phase .ptitle { font-weight: 650; }
.phase .pwhen { font: 500 12.5px var(--mono); color: var(--muted); }
.phase .chev { transition: transform 0.2s; color: var(--muted); }
.phase[open] .chev { transform: rotate(90deg); }
.phase[open] { border-color: #99d5cc; }
.phase .pbody { padding: 0 20px 18px 76px; }
.phase .pbody p { color: #4a4a45; font-size: 15px; }
.phase .pbody ul { margin: 6px 0 12px; padding-left: 18px; font-size: 15px; }
.phase.now .num { background: var(--accent); color: #fff; }
.phase.now .pwhen::after { content: " · NOW"; color: var(--accent); font-weight: 700; }
html[lang="es"] .phase.now .pwhen::after { content: " · HOY"; }

.footer { display: flex; justify-content: space-between; flex-wrap: wrap; gap: 8px; border-top: 1px solid var(--line); padding-top: 18px; font-size: 13px; color: var(--muted); }

/* Responsive */
@media (max-width: 960px) {
  .sidebar { transform: translateX(-100%); transition: transform 0.25s; box-shadow: 0 0 40px rgba(0, 0, 0, 0.15); }
  .sidebar.open { transform: none; }
  .content { margin-left: 0; padding-top: 76px; }
  .menu-btn {
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 4px;
    position: fixed;
    top: 14px;
    left: 14px;
    z-index: 30;
    width: 42px;
    height: 42px;
    padding: 0 11px;
    border: 1px solid var(--line);
    background: var(--panel);
    border-radius: 10px;
    cursor: pointer;
  }
  .menu-btn span { height: 2px; background: var(--ink); border-radius: 2px; }
  .phase summary { grid-template-columns: 40px 1fr; }
  .phase .chev { display: none; }
  .phase .pbody { padding-left: 20px; }
}

@media print {
  .sidebar, .menu-btn { display: none !important; }
  .content { margin: 0; padding: 0; max-width: none; }
  body { background: #fff; font-size: 12.5px; }
  section { break-inside: avoid-page; margin-bottom: 28px; }
  .diagram, .job, .card, .phase { break-inside: avoid; }
  details > *:not(summary) { display: block !important; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  * { transition: none !important; }
}
