/* ENGFlow Workbook shell: the page is one living workbook. */
.skip-link {
  position: absolute;
  left: 12px;
  top: -60px;
  z-index: 100;
  padding: 10px 14px;
  background: var(--lime);
  color: #0a0d12;
  font-weight: 700;
  border-radius: 8px;
  text-decoration: none;
}
.skip-link:focus { top: 10px; }

.app {
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr) auto auto auto;
  height: 100vh;
  height: 100dvh;
  min-height: 0;
}

.spacer { flex: 1; }

/* ---------------------------------------------------------------- title bar */
.titlebar {
  display: flex;
  align-items: center;
  gap: 14px;
  min-height: 54px;
  padding: 0 14px;
  background: #05070a;
  border-bottom: 1px solid var(--line);
}
.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 19px;
  letter-spacing: -0.02em;
}
.brand__mark {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border: 2px solid var(--lime);
  border-radius: 8px;
  color: var(--lime);
  font-size: 17px;
}
.brand__name span { color: var(--lime); }
.filechip { padding: 3px 8px; border: 1px solid var(--line); border-radius: 6px; }

.tool-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 34px;
  padding: 0 12px;
  background: transparent;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  color: var(--text);
  font-family: var(--font-mono);
  font-size: 12px;
  cursor: pointer;
  transition: background var(--dur) var(--ease), border-color var(--dur) var(--ease), color var(--dur) var(--ease);
}
.tool-btn:hover { border-color: var(--lime); }
.tool-btn[aria-pressed="true"] { background: var(--lime); border-color: var(--lime); color: #0a0d12; }

.lang { display: inline-flex; border: 1px solid var(--line-strong); border-radius: 8px; overflow: hidden; }
.lang a {
  padding: 6px 10px;
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--muted);
  text-decoration: none;
}
.lang a[aria-current="true"] { background: rgba(255, 255, 255, 0.1); color: var(--text); }
.btn--sm { min-height: 34px; padding: 0 14px; font-size: 13px; border-width: 2px; }

/* ---------------------------------------------------------------- formula bar */
.formulabar {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 32px;
  padding: 0 14px;
  background: var(--bg-2);
  border-bottom: 1px solid var(--line);
  font-family: var(--font-mono);
  font-size: 12.5px;
}
.namebox {
  min-width: 96px;
  padding: 3px 10px;
  border: 1px solid var(--line-strong);
  border-radius: 4px;
  background: #0a0f15;
  color: var(--muted);
}
.fx { color: var(--lime); font-style: italic; font-weight: 700; }
#formula { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text); }

/* ---------------------------------------------------------------- grid frame */
.frame {
  position: relative;
  display: grid;
  grid-template-columns: 46px minmax(0, 1fr);
  grid-template-rows: 26px minmax(0, 1fr);
  min-height: 0;
  overflow: hidden;
}
.corner { background: var(--bg-2); border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.colheads, .rowheads { overflow: hidden; background: var(--bg-2); color: var(--faint); font-family: var(--font-mono); font-size: 11px; user-select: none; }
.colheads { border-bottom: 1px solid var(--line); }
.rowheads { border-right: 1px solid var(--line); }
#colheadsInner { display: flex; width: max-content; }
#colheadsInner span { flex: none; width: 120px; height: 26px; display: grid; place-items: center; border-right: 1px solid var(--line); }
#rowheadsInner span { display: grid; place-items: center; height: 28px; border-bottom: 1px solid var(--line); }

.scroll {
  grid-column: 2;
  grid-row: 2;
  min-height: 0;
  overflow: auto;
  outline: none;
  background-image:
    linear-gradient(var(--grid) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid) 1px, transparent 1px);
  background-size: 120px 28px;
  background-attachment: local;
  scroll-behavior: smooth;
}

.sheet {
  max-width: 1200px;
  margin: 0 auto;
  padding: 30px 28px 90px;
}
.sheet[hidden] { display: none; }
.sheet__head { display: grid; gap: 10px; max-width: 820px; margin-bottom: 26px; }
.sheet__head h2 { font-size: clamp(1.9rem, 3.6vw, 3rem); }
.lead { color: var(--muted); font-size: clamp(1rem, 1.5vw, 1.15rem); max-width: 62ch; }
.fine { color: var(--faint); font-size: 12.5px; max-width: 78ch; margin-top: 26px; }
.toolkit-note { margin: 0; font-size: 13px; }
.textlink { color: var(--lime); text-decoration: none; font-weight: 600; }
.textlink:hover { text-decoration: underline; text-underline-offset: 4px; }

/* the hero button invites a click: a soft ring, off for reduced motion and while hovered */
.btn.pulse { animation: btn-pulse 2.4s ease-out infinite; }
.btn.pulse:hover { animation: none; }
@keyframes btn-pulse {
  0% { box-shadow: 0 0 0 0 rgba(185, 255, 102, 0.55); }
  70% { box-shadow: 0 0 0 14px rgba(185, 255, 102, 0); }
  100% { box-shadow: 0 0 0 0 rgba(185, 255, 102, 0); }
}
@media (prefers-reduced-motion: reduce) { .btn.pulse { animation: none; } }

.block { margin-top: 64px; display: grid; gap: 16px; }
.block h2 { font-size: clamp(1.6rem, 3vw, 2.5rem); max-width: 26ch; }
.block.cta {
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 24px;
  padding: 28px;
  background: var(--panel);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  box-shadow: var(--hard);
}
.block.cta h2 { max-width: 22ch; }

/* ---------------------------------------------------------------- hero */
.hero { display: grid; grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr); gap: 40px; align-items: center; }
.hero h1 {
  font-size: clamp(2.3rem, 4.5vw, 4.4rem);
  line-height: 1.16;
  letter-spacing: -0.035em;
  margin: 12px 0 18px;
}
.hl {
  display: inline;
  padding: 0 0.14em;
  background: linear-gradient(transparent 10%, var(--lime) 10% 94%, transparent 94%);
  color: #0a0d12;
  -webkit-box-decoration-break: clone;
  box-decoration-break: clone;
}
.nobr { white-space: nowrap; }
.hero__cta { display: flex; flex-wrap: wrap; gap: 12px; margin: 26px 0 20px; }
.proof { display: grid; gap: 6px; margin: 0; padding: 0; list-style: none; color: var(--muted); font-size: 14px; }
.proof li::before { content: "\2713"; margin-right: 10px; color: var(--lime); font-weight: 800; }

.chaos { display: grid; gap: 12px; }
.chaos__stage {
  position: relative;
  aspect-ratio: 16 / 11;
  overflow: hidden;
  background: #090e14;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
}
.chaos__chips { position: absolute; inset: 0; }
.chip-file, .chip-err {
  position: absolute;
  left: var(--x);
  top: var(--y);
  padding: 5px 10px;
  border-radius: 6px;
  font-family: var(--font-mono);
  font-size: clamp(10px, 1.05vw, 12.5px);
  white-space: nowrap;
  transform: translate(-50%, -50%) rotate(var(--r));
  transition: left 800ms var(--ease), top 800ms var(--ease), transform 800ms var(--ease), opacity 500ms ease;
  transition-delay: calc(var(--i) * 28ms);
}
.chip-file { background: var(--panel-2); border: 1px solid var(--line-strong); color: var(--muted); }
.chip-err { background: rgba(255, 139, 150, 0.12); border: 2px solid var(--bad); color: var(--bad); font-weight: 700; }
.is-running .chip-file, .is-running .chip-err, .is-done .chip-file, .is-done .chip-err {
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%) rotate(0deg) scale(0.1);
  opacity: 0;
}
.chaos__table {
  position: absolute;
  inset: 8% 5%;
  display: grid;
  align-content: center;
  gap: 6px;
  font-size: clamp(10px, 1.1vw, 13px);
}
.mini-head, .mini-row { display: grid; grid-template-columns: 1.1fr 1fr 0.9fr 1.2fr; gap: 10px; padding: 7px 10px; border-radius: 6px; }
.mini-head { background: var(--lime); color: #0a0d12; font-weight: 800; font-family: var(--font-mono); text-transform: uppercase; font-size: 0.85em; }
.mini-row { background: rgba(255, 255, 255, 0.04); border: 1px solid var(--line); }
.mini-row .ok { color: var(--ok); }
.mini-row .wait { color: var(--warn); }
.mini-head, .mini-row { opacity: 0; transform: translateY(10px); transition: opacity 400ms ease, transform 500ms var(--ease); }
.is-done .mini-head, .is-done .mini-row { opacity: 1; transform: none; }
.is-done .mini-head { transition-delay: 700ms; }
.is-done .mini-row:nth-child(2) { transition-delay: 850ms; }
.is-done .mini-row:nth-child(3) { transition-delay: 950ms; }
.is-done .mini-row:nth-child(4) { transition-delay: 1050ms; }
.is-done .mini-row:nth-child(5) { transition-delay: 1150ms; }
.is-done .mini-row:nth-child(6) { transition-delay: 1250ms; }
.chaos__bar { display: flex; gap: 10px; }

/* ---------------------------------------------------------------- loop */
.loop { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 12px; margin: 10px 0 0; padding: 0; list-style: none; }
.loop a {
  display: grid;
  gap: 4px;
  padding: 14px;
  height: 100%;
  background: var(--panel);
  border: 1px solid var(--line);
  border-top: 3px solid var(--c);
  border-radius: 12px;
  text-decoration: none;
  transition: transform var(--dur) var(--ease), border-color var(--dur) var(--ease);
}
.loop a:hover { transform: translateY(-4px); border-color: var(--c); }
.loop__n { font-family: var(--font-mono); font-size: 11px; color: var(--c); }
.loop strong { font-family: var(--font-display); font-size: 1.15rem; }
.loop small { color: var(--muted); font-size: 12.5px; }

/* ---------------------------------------------------------------- tool table */
.tooltable { display: grid; border: 1px solid var(--line-strong); border-radius: var(--radius); overflow: hidden; background: var(--panel); }
.tooltable__row { display: grid; grid-template-columns: 1fr 2fr 2fr; gap: 18px; padding: 14px 18px; border-top: 1px solid var(--line); font-size: 14.5px; }
.tooltable__row:first-child { border-top: 0; }
.tooltable__row--head { background: var(--lime); color: #0a0d12; font-family: var(--font-mono); font-size: 12px; text-transform: uppercase; font-weight: 800; }
.tooltable__row strong { font-family: var(--font-display); }
.tooltable__row strong small { display: block; color: var(--faint); font-family: var(--font-body); font-weight: 500; font-size: 12px; }
.tooltable__row span:last-child { color: var(--muted); }

.chips5 { display: flex; flex-wrap: wrap; gap: 10px; margin: 6px 0 0; padding: 0; list-style: none; }
.chips5 li { padding: 9px 14px; border: 1px solid var(--line-strong); border-radius: 999px; background: var(--panel); font-size: 14px; }

/* ---------------------------------------------------------------- offers, contact */
.offers { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.offer { display: grid; gap: 10px; align-content: start; padding: 22px; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); }
.offer__n { font-family: var(--font-mono); color: var(--lime); font-size: 12px; }
.offer h3 { font-size: 1.5rem; }
.offer p { color: var(--muted); }
.steps ol { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin: 0; padding: 0; list-style: none; }
.steps li { display: grid; gap: 4px; padding: 14px; border-left: 3px solid var(--lime); background: var(--panel); border-radius: 0 10px 10px 0; }
.steps li span { color: var(--muted); font-size: 14px; }
.contactgrid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.contactcard { display: grid; gap: 14px; align-content: start; padding: 22px; }
.contactcard ul { margin: 0; padding-left: 18px; color: var(--muted); }

/* ---------------------------------------------------------------- receipt */
.receipt-host { position: absolute; right: 16px; top: 38px; z-index: 30; display: grid; gap: 12px; width: min(300px, calc(100% - 78px)); pointer-events: none; }
.receipt {
  position: relative;
  pointer-events: auto;
  padding: 16px 16px 26px;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-mono);
  font-size: 12px;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.55);
  transform: rotate(1deg);
  animation: receipt-in 420ms var(--ease) both;
}
.receipt::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: -8px;
  height: 9px;
  background: linear-gradient(-45deg, transparent 6px, var(--paper) 0), linear-gradient(45deg, transparent 6px, var(--paper) 0);
  background-size: 12px 12px;
  background-repeat: repeat-x;
}
.receipt h3 { font-family: var(--font-mono); font-size: 12px; letter-spacing: 0.14em; text-align: center; margin-bottom: 8px; }
.receipt dl { margin: 10px 0; display: grid; gap: 4px; }
.receipt dl div { display: flex; justify-content: space-between; gap: 12px; border-bottom: 1px dashed #b9bcc2; padding-bottom: 3px; }
.receipt dd { margin: 0; text-align: right; font-weight: 700; }
.receipt dt { color: #3b414a; }
.receipt__foot { text-align: center; font-size: 10.5px; letter-spacing: 0.08em; color: #3b414a; }
.receipt__x { position: absolute; right: 6px; top: 4px; border: 0; background: transparent; font-size: 18px; cursor: pointer; color: #3b414a; }
@keyframes receipt-in { from { opacity: 0; transform: translateY(-12px) rotate(-2deg); } to { opacity: 1; transform: rotate(1deg); } }

/* ---------------------------------------------------------------- code panel */
.codepanel { display: grid; grid-template-rows: auto minmax(0, 1fr); height: min(38vh, 360px); background: #070b10; border-top: 2px solid var(--lime); }
.codepanel[hidden] { display: none; }
.codepanel__bar { display: flex; align-items: center; gap: 8px; padding: 6px 10px; border-bottom: 1px solid var(--line); }
.codepanel__tabs { display: flex; gap: 6px; flex: 1; overflow-x: auto; }
.codepanel__tabs button {
  padding: 5px 12px;
  background: transparent;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 12px;
  cursor: pointer;
}
.codepanel__tabs button[aria-selected="true"] { border-color: var(--lime); color: var(--lime); }
.codepanel__pre { margin: 0; padding: 14px 18px; overflow: auto; font-family: var(--font-mono); font-size: 12.5px; line-height: 1.55; tab-size: 4; }
.tok-k { color: #ff9ecb; }
.tok-s { color: #b9ff66; }
.tok-c { color: #7c8a99; font-style: italic; }
.tok-n { color: #ffc86b; }

/* ---------------------------------------------------------------- sheet tabs and status */
.sheettabs { display: flex; align-items: flex-end; gap: 2px; padding: 6px 10px 0; overflow-x: auto; background: var(--bg-2); border-top: 1px solid var(--line); scrollbar-width: thin; }
.sheettabs button {
  --tab-accent: var(--lime);
  flex: none;
  padding: 8px 18px 7px;
  background: transparent;
  border: 1px solid transparent;
  border-top: 3px solid transparent;
  border-radius: 8px 8px 0 0;
  color: var(--muted);
  font-family: var(--font-body);
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
  transition: color var(--dur) var(--ease), background var(--dur) var(--ease);
}
.sheettabs button:hover { color: var(--text); background: rgba(255, 255, 255, 0.04); }
.sheettabs button[aria-selected="true"] { background: var(--panel); color: var(--text); border-color: var(--line); border-top-color: var(--tab-accent); }
.sheettabs button i { display: inline-block; width: 7px; height: 7px; margin-right: 8px; border-radius: 2px; background: var(--tab-accent); }

.statusbar { display: flex; align-items: center; gap: 18px; min-height: 28px; padding: 0 14px; background: #05070a; border-top: 1px solid var(--line); font-family: var(--font-mono); font-size: 11.5px; color: var(--muted); }
.statusbar a { color: var(--muted); text-decoration: none; }
.statusbar a:hover { color: var(--lime); }
.status { display: inline-flex; align-items: center; gap: 8px; }
.status__dot { width: 8px; height: 8px; border-radius: 50%; background: var(--ok); }
.status.is-busy .status__dot { background: var(--warn); animation: pulse 900ms ease-in-out infinite; }
@keyframes pulse { 50% { transform: scale(1.7); opacity: 0.5; } }

/* ---------------------------------------------------------------- responsive */
@media (max-width: 1020px) {
  .hero { grid-template-columns: 1fr; }
  .loop { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .steps ol { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .tooltable__row { grid-template-columns: 1fr; gap: 4px; }
  .tooltable__row--head { display: none; }
}
@media (max-width: 760px) {
  .frame { grid-template-columns: minmax(0, 1fr); grid-template-rows: minmax(0, 1fr); }
  .corner, .colheads, .rowheads { display: none; }
  .scroll { grid-column: 1; grid-row: 1; }
  .filechip, .formulabar .namebox { display: none; }
  .titlebar { gap: 8px; padding: 0 10px; flex-wrap: wrap; padding-block: 6px; }
  .block.cta, .offers, .contactgrid { grid-template-columns: 1fr; }
  .loop { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .sheet { padding: 22px 16px 80px; }
  .receipt-host { right: 10px; top: 10px; }
}
