/* FabForge app shell styles (Build 1, ease-of-use layer Build 2). Written from scratch. System fonts only. */
:root {
  --bg: #111316; --bg2: #16191d; --panel: #1b1f24; --panel2: #22272d; --line: #2e343c; --line2: #3c434c;
  --text: #e8eaed; --muted: #a7b0ba; --dim: #8b939c;
  --amber: #ffb000; --amber2: #ffc845; --amberbg: rgba(255,176,0,.12);
  --red: #f0605a; --redbg: rgba(240,96,90,.12); --green: #46c25a; --greenbg: rgba(70,194,90,.12);
  --blue: #5aa2e6; --bluebg: rgba(90,162,230,.12);
  --steel: #3b4047; --steel2: #8a929c;
  --r: 10px; --rail: 84px; --top: 60px;
  --mono: ui-monospace, "SFMono-Regular", Menlo, Consolas, "Liberation Mono", monospace;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, Ubuntu, "Helvetica Neue", Arial, sans-serif;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; background: var(--bg); color: var(--text); font: 16px/1.4 var(--sans); }
body { min-height: 100vh; display: grid; grid-template-columns: var(--rail) 1fr; grid-template-rows: var(--top) 1fr auto;
  grid-template-areas: "top top" "rail view" "rail foot"; }
a { color: var(--amber2); }
button, input, select { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--amber); outline-offset: 2px; }
.skip { position: absolute; left: -999px; }
.skip:focus { left: 8px; top: 8px; z-index: 50; background: var(--amber); color: #111; padding: 8px 12px; border-radius: 6px; }

/* Top bar */
.top { grid-area: top; display: flex; align-items: center; gap: 16px; padding: 0 16px; background: var(--bg2);
  border-bottom: 2px solid var(--amber); position: sticky; top: 0; z-index: 20; }
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--text); }
.brand img { display: block; width: 34px; height: 40px; }
.brand-txt { display: flex; flex-direction: column; line-height: 1.05; }
.brand-txt strong { font-size: 20px; letter-spacing: .06em; text-transform: uppercase; }
.brand-txt small { color: var(--muted); font-size: 12px; letter-spacing: .08em; }
.top-title { font-size: 18px; color: var(--muted); border-left: 1px solid var(--line2); padding-left: 16px; white-space: nowrap; }
.units { margin-left: auto; display: flex; gap: 8px; }
.seg { display: flex; border: 1px solid var(--line2); border-radius: 999px; overflow: hidden; }
.seg button { border: 0; background: transparent; min-width: 46px; height: 44px; padding: 0 10px; cursor: pointer; color: var(--muted); font-weight: 600; }
.seg button.on { background: var(--amber); color: #15120a; }

/* Left module rail */
.rail { grid-area: rail; background: var(--bg2); border-right: 1px solid var(--line); padding: 10px 6px; display: flex;
  flex-direction: column; gap: 4px; position: sticky; top: var(--top); height: calc(100vh - var(--top)); overflow-y: auto; }
.rail a { display: flex; flex-direction: column; align-items: center; gap: 3px; padding: 8px 2px; border-radius: 10px;
  text-decoration: none; color: var(--muted); font-size: 11px; text-align: center; line-height: 1.15; border: 1px solid transparent; position: relative; }
.rail a svg { width: 26px; height: 26px; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.rail a:hover { background: var(--panel); color: var(--text); }
.rail a.on { background: var(--amberbg); border-color: var(--amber); color: var(--amber2); }
.rail a.soon { opacity: .45; }
.rail a.soon:hover { opacity: .75; }
.rail a .soon-tag { font-size: 9px; letter-spacing: .06em; text-transform: uppercase; color: var(--dim); }
.rail .sep { height: 1px; background: var(--line); margin: 6px 8px; flex: none; }
.rail .push { margin-top: auto; }
/* Build 3: Library + My data pinned at the bottom; the module list scrolls on short screens (fixes 1280x900 cut-off) */
.rail { overflow: hidden; padding-bottom: 6px; }
.rail-mods { display: flex; flex-direction: column; gap: 4px; flex: 1 1 auto; min-height: 0; overflow-y: auto; scrollbar-width: thin; }
.rail-end { display: flex; flex-direction: column; gap: 4px; flex: none; }
@media (min-width: 761px) and (max-height: 1000px) {
  .rail a { padding: 5px 2px; gap: 2px; }
  .rail a svg { width: 22px; height: 22px; }
  .rail a .soon-tag { font-size: 8.5px; }
}

main { grid-area: view; padding: 18px; min-width: 0; }
main:focus { outline: none; }
.foot { grid-area: foot; display: flex; flex-wrap: wrap; justify-content: space-between; gap: 6px 16px; padding: 10px 18px 16px;
  color: var(--dim); font-size: 12px; border-top: 1px solid var(--line); }
.est { color: var(--amber); font-weight: 700; }

/* Shared building blocks */
.page-h { display: flex; flex-wrap: wrap; align-items: baseline; gap: 8px 14px; margin: 0 0 14px; }
.page-h h1 { margin: 0; font-size: 24px; letter-spacing: .02em; }
.page-h p { margin: 0; color: var(--muted); }
.badge { display: inline-block; font-size: 12px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase;
  padding: 3px 10px; border-radius: 999px; border: 1px solid var(--line2); color: var(--muted); }
.badge.amber { border-color: var(--amber); color: var(--amber2); background: var(--amberbg); }
.badge.green { border-color: var(--green); color: var(--green); background: var(--greenbg); }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); padding: 16px; min-width: 0; }
.card + .card { margin-top: 0; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px; padding: 0 16px;
  border-radius: 10px; border: 1px solid var(--line2); background: var(--panel2); cursor: pointer; font-weight: 600; text-decoration: none; color: var(--text); }
.btn:hover { border-color: var(--steel2); }
.btn.primary { background: var(--amber); border-color: var(--amber); color: #15120a; }
.btn.danger { border-color: var(--red); color: var(--red); background: transparent; }
.btn.small { min-height: 44px; padding: 0 12px; font-size: 14px; }
.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%) translateY(30px); opacity: 0; pointer-events: none;
  background: var(--panel2); border: 1px solid var(--amber); color: var(--text); padding: 12px 18px; border-radius: 10px;
  transition: .2s; z-index: 60; max-width: 90vw; }
.toast.show { opacity: 1; transform: translateX(-50%); }
.noscript { padding: 20px; }

/* Form fields */
.fld { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.fld > span { font-size: 13px; color: var(--muted); }
.fld .box { position: relative; display: flex; align-items: center; }
.fld input, .fld select { width: 100%; height: 44px; border-radius: 8px; border: 1px solid var(--line2); background: var(--bg);
  padding: 0 10px; font-size: 17px; font-variant-numeric: tabular-nums; }
.fld input { padding-right: 62px; }
.fld .u { position: absolute; right: 10px; color: var(--dim); font-size: 13px; pointer-events: none; }
.fld input.bad { border-color: var(--red); background: var(--redbg); }
.fld select { appearance: none; padding-right: 30px;
  background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: calc(100% - 17px) 19px, calc(100% - 12px) 19px; background-size: 5px 5px; background-repeat: no-repeat; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { min-height: 44px; padding: 0 14px; border-radius: 8px; border: 1px solid var(--line2); background: var(--panel2); cursor: pointer; font-weight: 600; font-size: 14px; color: var(--muted); }
.chip.on { border-color: var(--amber); color: var(--amber2); background: var(--amberbg); }
.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th, .table td { text-align: left; padding: 8px 6px; border-bottom: 1px solid var(--line); vertical-align: top; }
.table th { color: var(--muted); font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: .05em; }
.table td.n { font-family: var(--mono); white-space: nowrap; }
.table.lib-text td.n { font-family: inherit; white-space: normal; min-width: 9em; }

/* Coming-soon and data pages */
.soon-wrap { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 16px; align-items: start; }
.soon-wrap img { width: 100%; height: auto; border-radius: 8px; border: 1px solid var(--line); display: block; }
.soon-wrap .card p { color: var(--muted); }
.soon-list { margin: 0; padding-left: 20px; color: var(--muted); }
.soon-list li { margin: 4px 0; }
.soon-list li.now { color: var(--green); }
.soon-list li.next { color: var(--amber2); }
.data-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; align-items: start; }
.data-grid .wide { grid-column: 1 / -1; }
.data-grid h2 { margin: 0 0 10px; font-size: 18px; }
.row { display: flex; flex-wrap: wrap; gap: 10px; align-items: end; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.res-item { display: flex; gap: 10px; align-items: flex-start; justify-content: space-between; padding: 10px 0; border-bottom: 1px solid var(--line); }
.res-item b { display: block; }
.empty { color: var(--dim); padding: 10px 0; }

/* Tablet / phone */
@media (max-width: 1000px) {
  .soon-wrap { grid-template-columns: 1fr; }
  .data-grid { grid-template-columns: 1fr; }
  .top-title { display: none; }
}
@media (max-width: 760px) {
  :root { --top: 56px; }
  body { grid-template-columns: minmax(0, 1fr); grid-template-rows: auto auto 1fr auto; grid-template-areas: "top" "rail" "view" "foot"; }
  .top { padding: 8px 10px; gap: 8px; flex-wrap: wrap; }
  .brand-txt strong { font-size: 17px; }
  .brand img { width: 28px; height: 33px; }
  .units { gap: 4px; }
  .seg button { min-width: 38px; height: 36px; padding: 0 7px; font-size: 14px; }
  .rail { flex-direction: row; height: auto; position: sticky; top: 0; overflow-x: auto; overflow-y: hidden; padding: 6px; z-index: 15;
    border-right: 0; border-bottom: 1px solid var(--line); scrollbar-width: none; }
  .rail::-webkit-scrollbar { display: none; }
  .rail a { flex: none; width: 70px; }
  .rail .sep { width: 1px; height: auto; margin: 6px 2px; }
  .rail .push { margin-top: 0; }
  .rail { overflow-x: auto; }
  .rail-mods, .rail-end { display: contents; }
  main { padding: 12px 10px; }
}
@media (max-width: 420px) {
  .brand-txt small { display: none; }
  .brand { gap: 7px; }
  .top { gap: 6px; }
  .units { gap: 3px; }
  .seg button { min-width: 34px; padding: 0 5px; font-size: 13px; }
}

/* ---------- Ease of use (Build 2): focus, status colors, teach, tips, wizard, tour ---------- */
:focus-visible { outline: 3px solid var(--amber2); outline-offset: 2px; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn.big { min-height: 52px; padding: 0 20px; font-size: 17px; font-weight: 700; }
.top-tools { display: flex; gap: 6px; }
.top-tools .btn { min-height: 40px; padding: 0 12px; font-size: 14px; }
.top-tools .btn.on { background: var(--greenbg); border-color: var(--green); color: var(--green); }
.page-tools { display: flex; flex-wrap: wrap; gap: 8px; flex-basis: 100%; }
.sec-pills { display: flex; flex-wrap: wrap; gap: 6px; margin: 0 0 14px; }
.pill { min-height: 44px; padding: 0 16px; border-radius: 999px; border: 1px solid var(--line2); background: var(--panel); color: var(--text); cursor: pointer; font-size: 15px; }
.pill.on { background: var(--amber); border-color: var(--amber); color: #15120a; font-weight: 700; }
.fl-l { display: block; font-size: 13px; color: var(--muted); position: relative; line-height: 1.35; }
.fl-l .est { margin-left: 2px; }
.fx-in { align-items: end; }
.fl-l label { cursor: pointer; }
.tip-btn { display: inline-grid; place-items: center; vertical-align: middle; margin-left: 4px; width: 22px; height: 22px; min-width: 22px; border-radius: 50%; border: 1px solid var(--blue); background: var(--bluebg); color: #cfe4f8; font-size: 13px; font-weight: 700; font-style: italic; cursor: pointer; padding: 0; line-height: 1; position: relative; }
.tip-btn::after { content: ""; position: absolute; inset: -10px; }   /* 44px touch target */
.tip { position: absolute; z-index: 30; left: 0; top: 100%; margin-top: 6px; width: min(280px, 80vw); background: #0d1a26; border: 1px solid var(--blue); border-radius: 8px; padding: 8px 10px; color: #e3eef9; font-size: 13px; line-height: 1.4; box-shadow: 0 8px 24px rgba(0,0,0,.5); }
.tile.st-good { border-color: var(--green); }
.tile.st-warn { border-color: var(--amber); }
.tile.st-bad { border-color: var(--red); background: var(--redbg); }
.tile.st-good .stb { color: var(--green); }
.tile.st-warn .stb { color: var(--amber2); }
.tile.st-bad .stb, .tile.st-bad .tv { color: var(--red); }
.stb { font-size: 11px; letter-spacing: .04em; margin-left: 4px; white-space: nowrap; }
.teach { display: none; border: 1px solid var(--green); border-left-width: 4px; background: var(--greenbg); border-radius: 8px; padding: 10px 12px; font-size: 14px; color: var(--text); }
body.teach-on .teach { display: block; }
.teach-h { font-weight: 800; color: var(--green); text-transform: uppercase; letter-spacing: .06em; font-size: 12px; margin-bottom: 4px; }
.teach p { margin: 4px 0; }
.teach ol { margin: 4px 0 4px 20px; padding: 0; }
.teach-ex { font-family: var(--mono); font-size: 13px; }
.teach-why b { color: var(--amber2); }
.tog .box { gap: 10px; }
.tog input[type=checkbox] { width: 52px; height: 30px; appearance: none; border-radius: 999px; background: var(--line2); position: relative; cursor: pointer; border: 1px solid var(--line2); padding: 0; }
.tog input[type=checkbox]::after { content: ""; position: absolute; top: 3px; left: 3px; width: 22px; height: 22px; border-radius: 50%; background: #e8eaed; transition: left .15s; }
.tog input[type=checkbox]:checked { background: var(--green); border-color: var(--green); }
.tog input[type=checkbox]:checked::after { left: 25px; }
.tog-t { font-size: 14px; }
/* Wizard */
.wiz-ov, .tour-ov { position: fixed; inset: 0; z-index: 100; background: rgba(5,6,8,.78); display: grid; place-items: center; padding: 14px; }
.wiz { width: min(640px, 100%); max-height: calc(100vh - 28px); overflow: auto; background: var(--panel); border: 2px solid var(--amber); border-radius: 14px; padding: 18px; box-shadow: 0 20px 60px rgba(0,0,0,.6); }
.wiz-top { display: flex; align-items: center; gap: 10px; }
.wiz-title { font-weight: 800; color: var(--amber2); text-transform: uppercase; letter-spacing: .05em; font-size: 14px; }
.wiz-step { color: var(--muted); font-size: 14px; margin-left: auto; }
.wiz-x { width: 44px; height: 44px; border-radius: 8px; border: 1px solid var(--line2); background: transparent; color: var(--text); font-size: 18px; cursor: pointer; }
.wiz-dots { display: flex; gap: 6px; margin: 10px 0 4px; }
.wiz-dots i { flex: 1; height: 6px; border-radius: 3px; background: var(--line2); }
.wiz-dots i.done { background: var(--amber); opacity: .6; }
.wiz-dots i.now { background: var(--amber); }
.wiz-q { font-size: 26px; line-height: 1.2; margin: 14px 0 6px; }
.wiz-help { color: var(--muted); margin: 0 0 10px; font-size: 16px; }
.wiz-pic { background: #14171b; border: 1px solid var(--line); border-radius: 10px; padding: 8px; margin: 8px 0; text-align: center; }
.wiz-pic svg { max-height: 160px; width: 100%; }
.wiz-opts { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 10px; margin: 12px 0; }
.wiz-opt { min-height: 72px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; padding: 10px; border-radius: 12px; border: 2px solid var(--line2); background: var(--bg); color: var(--text); cursor: pointer; font-size: 17px; font-weight: 700; text-align: center; }
.wiz-opt:hover { border-color: var(--amber2); }
.wiz-opt.on { border-color: var(--amber); background: var(--amberbg); }
.wo-pic svg { width: 64px; height: 42px; display: block; }
.wo-s { font-size: 13px; font-weight: 400; color: var(--muted); }
.wiz-in { display: flex; align-items: center; gap: 10px; margin: 14px 0 4px; }
.wiz-in input { flex: 1; height: 64px; font-size: 30px; font-weight: 700; padding: 0 14px; border-radius: 10px; border: 2px solid var(--line2); background: var(--bg); color: var(--text); min-width: 0; }
.wiz-in input.bad { border-color: var(--red); }
.wiz-in em { font-style: normal; font-size: 20px; color: var(--muted); min-width: 40px; }
.wiz-err { color: var(--red); min-height: 22px; margin: 4px 0; font-weight: 700; }
.wiz-nav { display: flex; justify-content: space-between; gap: 10px; flex-wrap: wrap; margin-top: 14px; }
.wiz-res { border-radius: 12px; padding: 14px; border: 2px solid var(--green); background: var(--greenbg); font-size: 16px; }
.wiz-res.warn { border-color: var(--amber); background: var(--amberbg); }
.wiz-res.bad { border-color: var(--red); background: var(--redbg); }
.wiz-res p { margin: 6px 0; }
.wiz-big { font-size: 40px; font-weight: 800; color: var(--amber2); font-variant-numeric: tabular-nums; }
/* Tour */
.tour-ov { background: rgba(5,6,8,.55); }
.tour-hl { position: fixed; border: 3px solid var(--amber); border-radius: 10px; box-shadow: 0 0 0 9999px rgba(5,6,8,.45); pointer-events: none; display: none; }
.tour-card { position: relative; width: min(460px, 100%); background: var(--panel); border: 2px solid var(--amber); border-radius: 14px; padding: 18px; box-shadow: 0 20px 60px rgba(0,0,0,.6); }
.tour-card h2 { margin: 6px 0; font-size: 24px; }
.tour-card p { font-size: 17px; color: var(--text); margin: 6px 0; }
.tour-step { color: var(--muted); font-size: 13px; text-transform: uppercase; letter-spacing: .06em; }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }
@media (max-width: 760px) {
  .top-tools { order: 3; width: 100%; }
  .top-tools .btn { flex: 1 1 auto; min-height: 44px; padding: 0 9px; font-size: 14px; white-space: nowrap; }
  .top-tools #tourBtn { flex: 0 0 48px; }
  main, #view { min-width: 0; }
  .wiz { padding: 14px; } .wiz-q { font-size: 22px; } .wiz-opts { grid-template-columns: 1fr 1fr; }
  .pill { padding: 0 12px; font-size: 14px; }
}
/* Knowledge Library */
.lib-bar { display: flex; flex-wrap: wrap; gap: 10px; align-items: end; justify-content: space-between; margin-bottom: 4px; }
.lib-search { width: min(320px, 100%); }
.lib-search input { width: 100%; height: 44px; border-radius: 8px; border: 1px solid var(--line2); background: var(--bg); color: var(--text); padding: 0 10px; }
.lib-scroll { overflow-x: auto; }
.lib-body h3 { margin: 16px 0 6px; font-size: 16px; color: var(--amber2); }

/* Cross-check pass: nothing on a page may push the phone screen sideways. Wide tables scroll inside themselves. */
@media (max-width: 760px) {
  #view select, #view input:not([type=checkbox]):not([type=radio]), #view textarea { max-width: 100%; min-width: 0; box-sizing: border-box; }
  #view label { max-width: 100%; min-width: 0; }
  #view table { display: block; max-width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; }
  #view pre, #view code { max-width: 100%; overflow-x: auto; white-space: pre; }
  #view [class*="card"], #view .form-row, #view [class*="grid"] > * { min-width: 0; max-width: 100%; box-sizing: border-box; }
  #view svg[viewBox], #view img { max-width: 100%; height: auto; }
}
/* approval gate */
#ff-gate{position:fixed;inset:0;background:rgba(0,0,0,.6);z-index:9999;display:flex;align-items:center;justify-content:center;padding:12px}
#ff-gate .ffg-box{background:var(--panel,#1b1f24);color:var(--text,#eee);max-width:880px;width:100%;max-height:94vh;overflow:auto;border-radius:10px;padding:16px;border:2px solid #e8a33d}
#ff-gate .ffg-code{max-height:42vh;overflow:auto;background:#0d1014;color:#d8f0d8;padding:8px;font:12px/1.35 ui-monospace,monospace;white-space:pre}
#ff-gate .ffg-n{display:inline-block;width:3.5em;color:#778;user-select:none}
#ff-gate label{display:block;margin:8px 0}#ff-gate input:not([type]){width:100%;padding:8px}
#ff-gate .ffg-err{color:#ff7a6b;min-height:1.2em}#ff-gate .ffg-btns .btn{min-height:44px}

.foot a, .tm-short a { color: var(--amber-text, #f5b301); }
.tm-short { margin: 8px 18px 18px; font-size: 12px; color: var(--muted, #9aa); }
.legal-page h2 { margin-top: 18px; }
