/* Notes Baba — AI Topic Analysis (frontend)
   Palette from notesbaba.com: orange #fa6b29 / #ee6517 · navy #5b4636 / #1a120b · greys #f0e2d8 / #fdf1ea / #fffaf7 · cream #fff8f5 */

.nbta-app {
  --nb-primary: #fa6b29;
  --nb-primary-dark: #ee6517;
  --nb-primary-soft: #fff0e8;
  --nb-ring: rgba(250, 107, 41, .22);
  --nb-ink: #1a120b;
  --nb-text: #5b4636;
  --nb-muted: #8a7262;
  --nb-line: #f0e2d8;
  --nb-soft: #fdf1ea;
  --nb-soft-2: #fffaf7;
  --nb-cream: #fff8f5;
  --nb-green: #15803d;
  --nb-green-soft: #e8f6ee;
  --nb-red: #b42318;
  --nb-shadow: 0 1px 2px rgba(26,18,11, .05), 0 8px 24px rgba(26,18,11, .07);

  position: relative;
  max-width: 1180px;
  margin: 24px auto;
  padding: 0 4px;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  font-size: 15px;
  line-height: 1.55;
  color: var(--nb-text);
}
.nbta-app *, .nbta-app *::before, .nbta-app *::after { box-sizing: border-box; }
/* Block themes cap post content at ~620px; the tool should use the page width instead. */
.nbta-app.nbta-app { max-width: 1180px !important; width: 100%; margin-left: auto !important; margin-right: auto !important; container-type: inline-size; container-name: nbta; }
.nbta-app h2, .nbta-app h3 { color: var(--nb-ink); font-family: inherit; letter-spacing: -.01em; }

/* ---------- Hero ---------- */
.nbta-hero {
  display: flex; justify-content: space-between; align-items: flex-end; gap: 20px; flex-wrap: wrap;
  padding: 28px 30px; margin-bottom: 20px; border-radius: 22px;
  background: radial-gradient(circle at 92% 10%, rgba(250, 107, 41, .16), transparent 42%), linear-gradient(135deg, #fff, var(--nb-cream));
  border: 1px solid #f6dccd; box-shadow: var(--nb-shadow);
}
.nbta-hero-copy { max-width: 720px; }
.nbta-hero h2 { margin: 10px 0 8px; font-size: clamp(24px, 3.2vw, 34px); font-weight: 800; line-height: 1.15; }
.nbta-hero p { margin: 0; color: var(--nb-muted); font-size: 15.5px; }
.nbta-hero-side { display: flex; flex-direction: column; align-items: flex-end; gap: 10px; }
.nbta-link-back { color: var(--nb-text) !important; font-weight: 600; font-size: 14px; text-decoration: none !important; }
.nbta-link-back:hover { color: var(--nb-primary-dark) !important; }

.nbta-eyebrow { display: inline-flex; align-items: center; gap: 8px; font-size: 12px; font-weight: 700; color: var(--nb-primary-dark); text-transform: uppercase; letter-spacing: .06em; }
.nbta-eyebrow-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--nb-primary); box-shadow: 0 0 0 4px var(--nb-ring); }

.nbta-badge { display: inline-flex; align-items: center; gap: 8px; padding: 7px 13px; border-radius: 999px; background: #fff; border: 1px solid var(--nb-line); font-size: 13px; font-weight: 600; color: var(--nb-ink); }
.nbta-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--nb-primary); }
.nbta-badge-green .nbta-dot { background: #22c55e; }
.nbta-badge-orange { background: var(--nb-primary-soft); border-color: #fed7c3; color: var(--nb-primary-dark); }

/* ---------- Layout & cards ---------- */
.nbta-layout { display: grid; grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr); gap: 20px; align-items: start; }
.nbta-card { background: #fff; border: 1px solid var(--nb-line); border-radius: 20px; box-shadow: var(--nb-shadow); padding: 24px; }
.nbta-output { position: sticky; top: 24px; min-height: 420px; }

/* ---------- Steps ---------- */
.nbta-step { padding-bottom: 22px; margin-bottom: 22px; border-bottom: 1px solid var(--nb-line); transition: opacity .2s; }
.nbta-step.is-disabled { opacity: .45; pointer-events: none; }
.nbta-step-head { display: flex; gap: 12px; align-items: flex-start; margin-bottom: 16px; }
.nbta-step-num { flex: 0 0 auto; width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; background: var(--nb-ink); color: #fff; font-weight: 700; font-size: 14px; }
.nbta-step:not(.is-disabled) .nbta-step-num { background: var(--nb-primary); }
.nbta-step-head h3 { margin: 2px 0 2px; font-size: 17px; font-weight: 700; }
.nbta-step-head p { margin: 0; color: var(--nb-muted); font-size: 13.5px; }

.nbta-exams { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.nbta-exam {
  display: flex; align-items: center; gap: 12px; text-align: left; width: 100%;
  padding: 12px 14px; border-radius: 14px; border: 1.5px solid var(--nb-line); background: var(--nb-soft-2);
  cursor: pointer; font: inherit; color: var(--nb-ink); transition: border-color .15s, background .15s, box-shadow .15s, transform .15s;
}
.nbta-exam:hover { border-color: #f8b896; background: #fff; transform: translateY(-1px); }
.nbta-exam:focus-visible { outline: none; box-shadow: 0 0 0 3px var(--nb-ring); }
.nbta-exam.is-active { border-color: var(--nb-primary); background: var(--nb-primary-soft); box-shadow: 0 0 0 3px var(--nb-ring); }
.nbta-exam-icon { flex: 0 0 auto; width: 38px; height: 38px; border-radius: 11px; display: grid; place-items: center; background: #fff; border: 1px solid var(--nb-line); font-size: 19px; }
.nbta-exam.is-active .nbta-exam-icon { border-color: #fdc9ad; }
.nbta-exam-text { display: flex; flex-direction: column; min-width: 0; }
.nbta-exam-text strong { font-size: 14.5px; font-weight: 700; }
.nbta-exam-text small { color: var(--nb-muted); font-size: 12px; line-height: 1.35; }

/* ---------- Fields ---------- */
.nbta-fields { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.nbta-fields:empty { display: none; }
.nbta-field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.nbta-field label { font-size: 13px; font-weight: 600; color: var(--nb-ink); }
.nbta-req { color: var(--nb-primary); }
.nbta-app input[type="text"], .nbta-app input[type="number"], .nbta-app select, .nbta-app textarea {
  width: 100%; min-height: 44px; padding: 10px 12px; border: 1px solid #d5dee6; border-radius: 12px; background: #fff;
  color: var(--nb-ink); font: inherit; font-size: 14.5px; box-shadow: none; transition: border-color .15s, box-shadow .15s; margin: 0;
}
.nbta-app textarea { min-height: 120px; resize: vertical; line-height: 1.5; }
.nbta-app input:focus, .nbta-app select:focus, .nbta-app textarea:focus { outline: none; border-color: var(--nb-primary); box-shadow: 0 0 0 3px var(--nb-ring); }
.nbta-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.nbta-chip { border: 1px solid var(--nb-line); background: #fff; color: var(--nb-text); border-radius: 999px; padding: 4px 11px; font: inherit; font-size: 12.5px; font-weight: 600; cursor: pointer; }
.nbta-chip:hover { border-color: var(--nb-primary); color: var(--nb-primary-dark); }
.nbta-chip.is-active { background: var(--nb-primary); border-color: var(--nb-primary); color: #fff; }

/* ---------- Buttons ---------- */
.nbta-actions { display: flex; gap: 10px; justify-content: flex-end; }
.nbta-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 46px; padding: 0 20px;
  border-radius: 12px; border: 1px solid transparent; font: inherit; font-weight: 600; font-size: 15px; cursor: pointer;
  text-decoration: none !important; transition: background .15s, border-color .15s, box-shadow .15s, transform .15s; line-height: 1;
}
.nbta-btn-primary { background: var(--nb-primary); color: #fff !important; box-shadow: 0 6px 16px rgba(250, 107, 41, .28); }
.nbta-btn-primary:hover { background: var(--nb-primary-dark); transform: translateY(-1px); }
.nbta-btn-primary:disabled { opacity: .7; cursor: wait; transform: none; }
.nbta-btn-ghost { background: #fff; color: var(--nb-ink) !important; border-color: var(--nb-line); }
.nbta-btn-ghost:hover { background: var(--nb-soft); }
.nbta-btn:focus-visible { outline: none; box-shadow: 0 0 0 3px var(--nb-ring); }
.nbta-btn-sm { min-height: 36px; padding: 0 14px; font-size: 13.5px; border-radius: 10px; }
#nbta-submit { flex: 1 1 auto; max-width: 320px; }
.nbta-btn-ldr { display: none; align-items: center; gap: 8px; }
#nbta-submit.is-loading .nbta-btn-txt { display: none; }
#nbta-submit.is-loading .nbta-btn-ldr { display: inline-flex; }
.nbta-spinner { width: 16px; height: 16px; border-radius: 50%; border: 2.5px solid rgba(255, 255, 255, .45); border-top-color: #fff; animation: nbta-spin .8s linear infinite; }
.nbta-form.is-busy .nbta-step { pointer-events: none; opacity: .75; }

/* ---------- Gates ---------- */
.nbta-gate { max-width: 560px; margin: 10px auto; padding: 38px 30px; text-align: center; background: #fff; border: 1px solid var(--nb-line); border-radius: 22px; box-shadow: var(--nb-shadow); }
.nbta-gate-inline { box-shadow: none; border: 0; margin: 0 auto; }
.nbta-gate-icon { width: 58px; height: 58px; margin: 0 auto 14px; border-radius: 16px; display: grid; place-items: center; background: var(--nb-primary-soft); color: var(--nb-primary-dark); }
.nbta-gate h3 { margin: 0 0 8px; font-size: 21px; font-weight: 800; }
.nbta-gate p { margin: 0 0 20px; color: var(--nb-muted); }
.nbta-gate-actions { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }

/* ---------- Output states ---------- */
.nbta-empty { text-align: center; padding: 26px 8px; }
.nbta-empty-art { margin-bottom: 10px; }
.nbta-empty h3 { margin: 0 0 6px; font-size: 18px; font-weight: 700; }
.nbta-empty p { margin: 0 auto 16px; max-width: 38ch; color: var(--nb-muted); }
.nbta-empty-list { list-style: none; margin: 0 auto; padding: 0; display: grid; gap: 8px; max-width: 340px; text-align: left; }
.nbta-empty-list li { position: relative; padding: 10px 12px 10px 36px; border-radius: 12px; background: var(--nb-soft-2); border: 1px solid var(--nb-line); font-size: 13.5px; color: var(--nb-ink); }
.nbta-empty-list li::before { content: "✓"; position: absolute; left: 12px; top: 9px; color: var(--nb-primary); font-weight: 800; }

.nbta-loading { text-align: center; padding: 30px 8px; }
.nbta-loading-ring { position: relative; width: 96px; height: 96px; margin: 0 auto 18px; border-radius: 50%; display: grid; place-items: center; background: var(--nb-primary-soft); }
.nbta-loading-ring::before { content: ""; position: absolute; inset: -6px; border-radius: 50%; border: 3px solid transparent; border-top-color: var(--nb-primary); border-right-color: var(--nb-primary); animation: nbta-spin 1.1s linear infinite; }
.nbta-loading-ring span { font-weight: 800; color: var(--nb-primary-dark); font-size: 13px; padding: 0 6px; }
.nbta-loading h3 { margin: 0 0 6px; font-size: 18px; font-weight: 700; }
.nbta-loading-line { min-height: 22px; margin: 0 0 16px; color: var(--nb-text); font-weight: 500; }
.nbta-progress { max-width: 320px; height: 8px; margin: 0 auto; border-radius: 999px; background: var(--nb-soft); overflow: hidden; }
.nbta-progress-fill { width: 4%; height: 100%; border-radius: 999px; background: linear-gradient(90deg, #fa6b29, #ee6517); transition: width .5s ease; }

.nbta-error { padding: 18px; border-radius: 14px; background: #fdecea; border: 1px solid #f8cbc5; color: var(--nb-red); }
.nbta-error strong { display: block; margin-bottom: 4px; }
.nbta-error p { margin: 0 0 12px; color: #7a271a; }

.nbta-result-head { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; padding-bottom: 16px; margin-bottom: 16px; border-bottom: 1px solid var(--nb-line); }
.nbta-score {
  --pct: 0; flex: 0 0 auto; width: 74px; height: 74px; border-radius: 50%; display: grid; place-items: center;
  background: conic-gradient(var(--tone, var(--nb-primary)) calc(var(--pct) * 1%), var(--nb-soft) 0);
}
.nbta-score.is-good { --tone: #22a35a; }
.nbta-score.is-mid { --tone: #fa6b29; }
.nbta-score.is-low { --tone: #d9452f; }
.nbta-score span { width: 58px; height: 58px; border-radius: 50%; background: #fff; display: grid; place-items: center; font-weight: 800; color: var(--nb-ink); font-size: 16px; }
.nbta-result-meta { display: flex; flex-direction: column; gap: 4px; flex: 1 1 200px; min-width: 0; }
.nbta-score-text { font-size: 20px; font-weight: 800; color: var(--nb-ink); }
.nbta-result-actions { display: flex; gap: 8px; flex-wrap: wrap; }

.nbta-result-body { color: var(--nb-ink); }
.nbta-result-body h2 { margin: 22px 0 8px; padding: 0 0 0 10px; border-left: 4px solid var(--nb-primary); font-size: 17px; font-weight: 700; line-height: 1.3; }
.nbta-result-body h2:first-child { margin-top: 0; }
.nbta-result-body h3 { margin: 14px 0 6px; font-size: 15px; font-weight: 700; color: var(--nb-text); }
.nbta-result-body p, .nbta-result-body li { font-size: 14.5px; line-height: 1.7; }
.nbta-result-body p { margin: 0 0 10px; }
.nbta-result-body ul, .nbta-result-body ol { margin: 6px 0 12px 20px; padding: 0; }
.nbta-result-body blockquote { margin: 10px 0; padding: 10px 14px; background: var(--nb-cream); border-left: 3px solid #fdc9ad; border-radius: 8px; }
.nbta-result-body table { width: 100%; border-collapse: collapse; margin: 10px 0 14px; font-size: 14px; }
.nbta-result-body th, .nbta-result-body td { border: 1px solid var(--nb-line); padding: 8px 10px; text-align: left; vertical-align: top; }
.nbta-result-body th { background: var(--nb-soft); font-weight: 700; }
.nbta-result-body hr { border: 0; border-top: 1px solid var(--nb-line); margin: 16px 0; }

.nbta-lock-shell { position: relative; }

/* ---------- Toast ---------- */
.nbta-toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 99999; max-width: calc(100% - 32px); padding: 12px 18px; border-radius: 12px; background: var(--nb-ink); color: #fff; font-weight: 600; font-size: 14px; box-shadow: 0 12px 30px rgba(26,18,11, .3); transition: opacity .3s, transform .3s; }
.nbta-toast.is-out { opacity: 0; transform: translate(-50%, 8px); }

@keyframes nbta-spin { to { transform: rotate(360deg); } }

/* ---------- Responsive (follows the space the tool actually gets) ---------- */
@container nbta (max-width: 920px) {
  .nbta-layout { grid-template-columns: 1fr; }
  .nbta-output { position: static; min-height: 0; }
}
@container nbta (max-width: 560px) {
  .nbta-hero { padding: 20px 18px; border-radius: 18px; }
  .nbta-hero-side { align-items: flex-start; }
  .nbta-card { padding: 18px 16px; border-radius: 16px; }
  .nbta-exams, .nbta-fields { grid-template-columns: 1fr; }
  .nbta-actions { flex-direction: column-reverse; }
  #nbta-submit { max-width: none; }
  .nbta-btn { width: 100%; }
  .nbta-result-actions { width: 100%; }
  .nbta-result-actions .nbta-btn { flex: 1 1 0; }
}
@container nbta (max-width: 380px) {
  .nbta-exams { grid-template-columns: 1fr; }
}
/* Fallback for browsers without container queries */
@supports not (container-type: inline-size) {
  @media (max-width: 900px) {
    .nbta-layout { grid-template-columns: 1fr; }
    .nbta-output { position: static; min-height: 0; }
  }
  @media (max-width: 560px) {
    .nbta-exams, .nbta-fields { grid-template-columns: 1fr; }
    .nbta-btn { width: 100%; }
  }
}
@media (max-width: 560px) {
  .nbta-app { margin: 12px auto; padding: 0; }
}
@media (prefers-reduced-motion: reduce) {
  .nbta-loading-ring::before, .nbta-spinner { animation: none; }
}

/* ---------- Print: only the evaluation ---------- */
@media print {
  body * { visibility: hidden !important; }
  #nbta-output, #nbta-output * { visibility: visible !important; }
  .nbta-saved { display: none !important; }
  #nbta-output { position: absolute !important; left: 0; top: 0; width: 100%; border: 0; box-shadow: none; padding: 0; }
  .nbta-result-actions { display: none !important; }
  .nbta-score { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}

/* ---------- Topic Analysis extras ---------- */
.nbta-right { display: grid; gap: 20px; align-content: start; position: sticky; top: 24px; }
.nbta-right .nbta-output { position: static; }
.nbta-label { font-size: 13px; font-weight: 600; color: var(--nb-ink); }
.nbta-fields { margin-bottom: 14px; }
.nbta-depth { margin-top: 2px; }
.nbta-segment { display: inline-grid; grid-template-columns: 1fr 1fr; gap: 4px; padding: 4px; border-radius: 12px; background: var(--nb-soft); max-width: 360px; }
.nbta-segment button { border: 0; border-radius: 9px; background: transparent; padding: 9px 14px; font: inherit; font-size: 13.5px; font-weight: 600; color: var(--nb-text); cursor: pointer; }
.nbta-segment button.is-active { background: #fff; color: var(--nb-primary-dark); box-shadow: 0 1px 3px rgba(26,18,11, .14); }
.nbta-segment button:focus-visible { outline: none; box-shadow: 0 0 0 3px var(--nb-ring); }
.nbta-topics-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; margin: 14px 0 8px; }
.nbta-step .nbta-chips { gap: 8px; }
.nbta-step .nbta-chip { padding: 7px 13px; font-size: 13px; font-weight: 500; background: var(--nb-soft-2); }
.nbta-step .nbta-chip.is-active { font-weight: 600; }
.nbta-btn-xs { min-height: 32px; padding: 0 12px; font-size: 12.5px; border-radius: 9px; }
.nbta-btn-xs:disabled { opacity: .7; cursor: default; }
.nbta-muted { color: var(--nb-muted); font-size: 13px; }

.nbta-result-head { align-items: flex-start; }
.nbta-result-meta h3 { margin: 2px 0 2px; font-size: 21px; font-weight: 800; line-height: 1.25; }
.nbta-result-body { max-height: none; }

.nbta-saved { padding: 18px 18px 14px; }
.nbta-saved-head { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 10px; }
.nbta-saved-head h3 { margin: 0; font-size: 16px; font-weight: 700; }
.nbta-saved-list { display: grid; gap: 8px; max-height: 360px; overflow-y: auto; }
.nbta-saved-empty { padding: 14px; border-radius: 12px; background: var(--nb-soft-2); border: 1px dashed var(--nb-line); color: var(--nb-muted); font-size: 13.5px; text-align: center; }
.nbta-saved-item { display: flex; align-items: stretch; border: 1px solid var(--nb-line); border-radius: 12px; background: #fff; transition: border-color .15s, background .15s; }
.nbta-saved-item:hover { border-color: #f8b896; background: var(--nb-cream); }
.nbta-saved-item.is-active { border-color: var(--nb-primary); background: var(--nb-primary-soft); }
.nbta-saved-open { flex: 1 1 auto; min-width: 0; text-align: left; border: 0; background: transparent; padding: 10px 12px; font: inherit; cursor: pointer; display: flex; flex-direction: column; gap: 4px; }
.nbta-saved-open strong { color: var(--nb-ink); font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nbta-saved-open > span { color: var(--nb-muted); font-size: 12px; display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.nbta-pill { display: inline-flex; padding: 1px 8px; border-radius: 999px; background: #f6ebe4; color: var(--nb-ink); font-weight: 600; font-size: 11.5px; }
.nbta-saved-del { flex: 0 0 auto; width: 38px; border: 0; border-left: 1px solid var(--nb-line); background: transparent; color: var(--nb-muted); cursor: pointer; border-radius: 0 12px 12px 0; }
.nbta-saved-del:hover { color: var(--nb-red); background: #fdecea; }

.nbta-quota { min-width: 230px; padding: 10px 12px; border-radius: 12px; background: #fff; border: 1px solid var(--nb-line); font-size: 12.5px; }
.nbta-quota-top { display: flex; justify-content: space-between; gap: 10px; color: var(--nb-text); }
.nbta-quota-top strong { color: var(--nb-ink); }
.nbta-quota-track { height: 6px; margin: 8px 0 4px; border-radius: 999px; background: var(--nb-soft); overflow: hidden; }
.nbta-quota-fill { height: 100%; border-radius: 999px; background: linear-gradient(90deg, #fa6b29, #ee6517); }
.nbta-quota-full .nbta-quota-fill { background: #d9452f; }
.nbta-quota small { color: var(--nb-muted); }

@container nbta (max-width: 920px) {
  .nbta-right { position: static; }
}
