/* REQ Builder — strictly namespaced under #req-app */
#req-app {
  --ink: #14202b;
  --muted: #5d6b78;
  --line: #dfe4ea;
  --req-bg: #f5f7f9;
  --card: #fff;
  --brand: #0f4c5c;
  --brand2: #e6f0f2;
  --err: #b42318;
  --errbg: #fef3f2;
  --warn: #a15c07;
  --warnbg: #fffaeb;
  --ok: #067647;
  --okbg: #ecfdf3;
  --r: 10px;

  font: 14px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  color: var(--ink);
  background: var(--req-bg);
  border: 1px solid var(--line);
  border-radius: var(--r);
  overflow: clip;
  margin: 1.5rem 0 2rem;
}

#req-app *,
#req-app *::before,
#req-app *::after {
  box-sizing: border-box;
}

/* Reset site-wide styles that could bleed into #req-app */
#req-app h2,
#req-app h3 {
  font-family: inherit;
  color: var(--ink);
  letter-spacing: normal;
  line-height: 1.3;
}

#req-app p {
  max-width: none;
}

#req-app a {
  border-bottom: none;
}

#req-app code {
  font-family: ui-monospace, Menlo, Consolas, monospace;
  font-size: 0.92em;
  background: #eef1f4;
  color: var(--ink);
  padding: 1px 5px;
  border-radius: 4px;
  border: none;
}

#req-app ul {
  list-style: disc;
  margin: 6px 0 0;
  padding-left: 18px;
}

#req-app ul li {
  padding-left: 0;
  margin-bottom: 3px;
}

#req-app ul li::before {
  content: none;
}

/* App toolbar banner (privacy pill + version) */
#req-app .req-ribbon {
  background: var(--brand);
  color: #fff;
  padding: 10px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

#req-app .req-ribbon__title {
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.2px;
}

#req-app .req-ribbon__priv {
  font-size: 12px;
  background: rgba(255, 255, 255, 0.14);
  padding: 4px 10px;
  border-radius: 20px;
  white-space: nowrap;
}

/* Controls */
#req-app button,
#req-app .btn {
  font: inherit;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  padding: 7px 12px;
  border-radius: 8px;
  cursor: pointer;
}

#req-app button:hover {
  border-color: #b9c3cd;
}

#req-app button.primary {
  background: var(--brand);
  border-color: var(--brand);
  color: #fff;
}

#req-app button.primary:disabled {
  background: #9fb4ba;
  border-color: #9fb4ba;
  cursor: not-allowed;
}

#req-app button.link {
  border: none;
  background: none;
  color: var(--brand);
  padding: 2px 4px;
}

#req-app input,
#req-app select,
#req-app textarea {
  font: inherit;
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 6px 8px;
  background: #fff;
  width: 100%;
}

#req-app input[type="checkbox"] {
  width: auto;
  margin: 0;
}

#req-app input:focus,
#req-app select:focus,
#req-app textarea:focus {
  outline: 2px solid #9cc8d1;
  border-color: var(--brand);
}

#req-app textarea {
  resize: vertical;
  min-height: 34px;
}

/* start */
#req-app #start {
  max-width: 980px;
  margin: 32px auto;
  padding: 0 20px 8px;
}

#req-app #start h2 {
  font-size: 22px;
  font-weight: 600;
  margin: 0 0 6px;
}

#req-app #start p.lead {
  color: var(--muted);
  margin: 0 0 24px;
  max-width: 720px;
}

#req-app .cards {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
}

#req-app .card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--r);
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

#req-app .card h3 {
  margin: 0;
  font-size: 15px;
  font-weight: 600;
}

#req-app .card p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  flex: 1;
}

#req-app .drop {
  border: 2px dashed var(--line);
  border-radius: var(--r);
  transition: 0.15s;
}

#req-app .drop.over {
  border-color: var(--brand);
  background: var(--brand2);
}

#req-app .facts {
  margin-top: 24px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--r);
  padding: 16px 20px;
  font-size: 13px;
  color: var(--muted);
}

#req-app .facts b {
  color: var(--ink);
}

/* work */
#req-app #work {
  display: none;
  height: 85vh;
  min-height: 600px;
  grid-template-columns: 280px 1fr;
  grid-template-rows: auto minmax(0, 1fr);
}

#req-app #bar {
  grid-column: 1 / 3;
  position: sticky;
  top: 0;
  z-index: 10;
  background: #fff;
  border-bottom: 1px solid var(--line);
  padding: 10px 20px;
  display: flex;
  gap: 14px;
  align-items: end;
  flex-wrap: wrap;
}

#req-app #bar label {
  font-size: 11.5px;
  color: var(--muted);
  display: flex;
  flex-direction: column;
  gap: 3px;
}

#req-app #bar input {
  width: auto;
}

#req-app #fname {
  font-family: ui-monospace, Menlo, Consolas, monospace;
  font-size: 12.5px;
  color: var(--muted);
  padding-bottom: 8px;
}

#req-app #bar .spacer {
  flex: 1;
}

#req-app #status {
  display: flex;
  gap: 8px;
  align-items: center;
  padding-bottom: 4px;
}

#req-app .pill {
  font-size: 12px;
  padding: 3px 9px;
  border-radius: 20px;
  font-weight: 600;
  white-space: nowrap;
}

#req-app .pill.err {
  background: var(--errbg);
  color: var(--err);
}

#req-app .pill.warn {
  background: var(--warnbg);
  color: var(--warn);
}

#req-app .pill.ok {
  background: var(--okbg);
  color: var(--ok);
}

#req-app nav {
  border-right: 1px solid var(--line);
  background: #fff;
  overflow: auto;
  min-height: 0;
  padding: 10px 0;
}

#req-app nav .grp {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--muted);
  padding: 12px 16px 4px;
}

#req-app nav a {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  padding: 6px 16px;
  color: var(--ink);
  text-decoration: none;
  border-bottom: none;
  font-size: 13px;
}

#req-app nav a:hover {
  background: var(--req-bg);
  color: var(--ink);
}

#req-app nav a.on {
  background: var(--brand2);
  color: var(--brand);
  font-weight: 600;
}

#req-app nav .n {
  font-size: 11px;
  border-radius: 10px;
  padding: 0 7px;
  line-height: 18px;
  height: 18px;
  align-self: center;
  flex: none;
}

#req-app nav .n.e {
  background: var(--errbg);
  color: var(--err);
}

#req-app nav .n.w {
  background: var(--warnbg);
  color: var(--warn);
}

#req-app .req-main {
  overflow: auto;
  min-height: 0;
  padding: 18px 24px 80px;
}

#req-app .tools {
  display: flex;
  gap: 10px;
  align-items: center;
  margin-bottom: 12px;
  flex-wrap: wrap;
}

#req-app .tools label {
  display: flex;
  gap: 6px;
  align-items: center;
  font-size: 13px;
  color: var(--muted);
  white-space: nowrap;
}

#req-app .tools input[type="search"] {
  width: 260px;
  max-width: 100%;
}

#req-app .tabs {
  display: flex;
  gap: 4px;
}

#req-app .tabs button {
  border-radius: 20px;
}

#req-app .tabs button.on {
  background: var(--ink);
  color: #fff;
  border-color: var(--ink);
}

#req-app section.sec {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--r);
  margin-bottom: 16px;
}

#req-app section.sec > h2 {
  font-size: 14.5px;
  font-weight: 600;
  margin: 0;
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}

#req-app section.sec > h2 small {
  font-weight: 400;
  color: var(--muted);
}

#req-app .f {
  display: grid;
  grid-template-columns: 56px minmax(220px, 1fr) minmax(220px, 360px);
  gap: 4px 14px;
  padding: 10px 16px;
  border-bottom: 1px solid #eef1f4;
  align-items: start;
}

#req-app .f:last-child {
  border-bottom: none;
}

#req-app .f.hasErr {
  background: linear-gradient(90deg, var(--errbg), #fff 60%);
}

#req-app .f.hasWarn {
  background: linear-gradient(90deg, var(--warnbg), #fff 60%);
}

#req-app .code {
  font-family: ui-monospace, Menlo, Consolas, monospace;
  font-size: 12px;
  color: var(--muted);
  padding-top: 7px;
}

#req-app .lbl {
  padding-top: 5px;
}

#req-app .lbl .t {
  font-weight: 500;
}

#req-app .lbl .q {
  color: var(--muted);
  font-size: 12.5px;
}

#req-app .lbl details {
  font-size: 12.5px;
  color: var(--muted);
  margin-top: 2px;
}

#req-app .lbl summary {
  cursor: pointer;
  color: var(--brand);
  width: max-content;
}

#req-app .meta {
  font-size: 11.5px;
  color: var(--muted);
  margin-top: 3px;
}

#req-app .msg {
  font-size: 12.5px;
  margin-top: 4px;
}

#req-app .msg.e {
  color: var(--err);
}

#req-app .msg.w {
  color: var(--warn);
}

#req-app table.grid {
  border-collapse: collapse;
  width: 100%;
}

#req-app table.grid th {
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  text-align: left;
  padding: 8px 6px;
  border-bottom: 1px solid var(--line);
  vertical-align: bottom;
}

#req-app table.grid th .c {
  font-family: ui-monospace, Menlo, Consolas, monospace;
  font-weight: 400;
  display: block;
}

#req-app table.grid td {
  padding: 5px 6px;
  border-bottom: 1px solid #eef1f4;
  vertical-align: top;
}

#req-app table.grid td.bad input,
#req-app table.grid td.bad select {
  border-color: var(--err);
  background: var(--errbg);
}

#req-app .tblwrap {
  padding: 8px 16px 14px;
  overflow: auto;
}

#req-app .tblmsgs {
  padding: 0 16px 10px;
}

#req-app pre.xml {
  background: #0f1720;
  color: #d6e2ea;
  padding: 16px;
  border-radius: var(--r);
  border: none;
  margin: 0;
  overflow: auto;
  font-family: ui-monospace, Menlo, Consolas, monospace;
  font-size: 12px;
  line-height: 1.45;
  max-height: 75vh;
}

#req-app .issues .row {
  display: grid;
  grid-template-columns: 70px 56px 1fr 120px;
  gap: 10px;
  padding: 8px 14px;
  border-bottom: 1px solid #eef1f4;
  cursor: pointer;
  font-size: 13px;
}

#req-app .issues .row:hover {
  background: var(--req-bg);
}

#req-app .lev {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
}

#req-app .lev.error {
  color: var(--err);
}

#req-app .lev.warn {
  color: var(--warn);
}

#req-app .hide {
  display: none !important;
}

#req-app #toast {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--ink);
  color: #fff;
  padding: 10px 16px;
  border-radius: 8px;
  font-size: 13px;
  opacity: 0;
  transition: 0.2s;
  pointer-events: none;
  z-index: 1000;
}

#req-app #toast.show {
  opacity: 1;
}

/* Surrounding prose sections on /tools/req-builder/ */
.req-page {
  max-width: 1280px;
  margin: 0 auto 3rem;
}

.req-intro {
  margin-bottom: 1rem;
}

.req-intro h1 {
  margin-bottom: 0.5rem;
}

.req-intro__meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1.25rem;
  font-size: 0.8rem;
  color: var(--fg-dim);
  margin-top: 0.75rem;
}

.req-intro__badge {
  color: var(--green);
}

.req-guide {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1.25rem;
  margin-top: 2rem;
}

.req-guide__card {
  background: var(--bg-raised);
  border: 1px solid var(--accent-dim);
  padding: 1.25rem 1.4rem;
}

.req-guide__card--full {
  grid-column: 1 / -1;
}

.req-guide__card h2 {
  margin-bottom: 0.75rem;
}

.req-guide__card p,
.req-guide__card li {
  font-size: 0.88rem;
  color: var(--fg);
  max-width: none;
}

.req-faq dt {
  color: var(--cyan);
  font-weight: 700;
  font-size: 0.88rem;
  margin-top: 0.9rem;
}

.req-faq dt:first-child {
  margin-top: 0;
}

.req-faq dd {
  margin: 0.3rem 0 0;
  font-size: 0.86rem;
  color: var(--fg-dim);
}

.req-disclaimer {
  margin-top: 1.5rem;
  padding: 1rem 1.25rem;
  border-left: 3px solid var(--accent-dim);
  background: var(--bg-raised);
  font-size: 0.82rem;
  color: var(--fg-dim);
}

.req-disclaimer p {
  max-width: none;
  margin-bottom: 0.6rem;
}

.req-disclaimer p:last-child {
  margin-bottom: 0;
}

.req-cta {
  margin-top: 1.25rem;
  padding: 1rem 1.25rem;
  border: 1px solid var(--accent-dim);
  background: var(--bg-raised);
  font-size: 0.86rem;
  color: var(--fg-dim);
}

.req-cta p {
  max-width: none;
  margin: 0;
}

/* Responsive rules — ALWAYS after base rules */
@media (max-width: 900px) {
  #req-app .cards {
    grid-template-columns: 1fr;
  }

  #req-app #work {
    grid-template-columns: 1fr;
    height: auto;
    min-height: 75vh;
  }

  #req-app #bar {
    grid-column: 1;
    padding: 10px 14px;
    gap: 10px;
  }

  #req-app #bar .spacer {
    display: none;
  }

  #req-app nav {
    display: none;
  }

  #req-app .req-main {
    padding: 14px 12px 48px;
  }

  #req-app .f {
    grid-template-columns: 1fr;
  }

  #req-app .issues .row {
    grid-template-columns: 60px 1fr;
  }

  .req-guide {
    grid-template-columns: 1fr;
  }
}
