/* [srcbox] The shared "Add sources" box (srcbox.js). Works on light (/animate, Tutor) and dark (Doodle) pages: colours
   come from the page's text colour (currentColor mixes) plus one accent per page. Phone first: 44 px tap targets. */
.sb-on { --sb-acc: #2563eb; --sb-ok: #15803d; --sb-bad: #b91c1c; --sb-r: 14px; --sb-font: var(--ui, Inter, system-ui, sans-serif); }
[data-srcbox="doodle"] { --sb-acc: #ffd43b; --sb-ok: #4ade80; --sb-bad: #fca5a5; }
[data-srcbox="tutor"] { --sb-acc: var(--u-primary, #2563eb); }
.sb-comp { position: relative; display: flex; align-items: center; gap: 6px; width: 100%; min-width: 0; border: 1px solid color-mix(in srgb, currentColor 22%, transparent);
  border-radius: var(--sb-r); padding: 4px 6px 4px 4px; background: color-mix(in srgb, currentColor 3%, transparent); }
.sb-comp:focus-within { border-color: var(--sb-acc); box-shadow: 0 0 0 3px color-mix(in srgb, var(--sb-acc) 22%, transparent); }
.sb-comp > input, .sb-comp > textarea { flex: 1; min-width: 0; border: 0 !important; outline: 0 !important; box-shadow: none !important; background: transparent !important;
  font: 500 16px var(--sb-font); color: inherit; padding: 10px 6px; margin: 0; width: auto; }
.sb-inline { border: 0; background: none; padding: 0; box-shadow: none !important; }
.sb-inline:focus-within { box-shadow: none; }
.sb-plus { flex: none; width: 40px; height: 40px; border-radius: 50%; border: 1px solid color-mix(in srgb, currentColor 22%, transparent); background: transparent;
  color: inherit; display: inline-flex; align-items: center; justify-content: center; cursor: pointer; padding: 0; }
.sb-plus:hover, .sb-plus[aria-expanded="true"] { background: color-mix(in srgb, var(--sb-acc) 16%, transparent); border-color: var(--sb-acc); }
.sb-plus:focus-visible, .sb-x:focus-visible, .sb-cb:focus-visible, .sb-mi:focus-visible { outline: 3px solid var(--sb-acc); outline-offset: 2px; }
.sb-i { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.sb-big { width: 40px; height: 40px; }
/* the + menu */
.sb-menu { position: absolute; z-index: 60; left: 0; top: calc(100% + 6px); width: min(340px, calc(100vw - 32px)); background: #fff; color: #1f2937; border-radius: 16px;
  box-shadow: 0 10px 40px rgba(0,0,0,.22); padding: 6px; display: flex; flex-direction: column; }
.sb-menu[hidden] { display: none; }
.sb-menu.up { top: auto; bottom: calc(100% + 6px); }
[data-srcbox="tutor"] .sb-under { padding: 0 4px; max-height: 38vh; overflow: auto; }
.sb-mi { display: flex; align-items: center; gap: 12px; min-height: 52px; padding: 8px 12px; border: 0; background: none; color: inherit; text-align: left; border-radius: 10px; cursor: pointer; font: inherit; }
.sb-mi:hover { background: #f3f4f6; }
.sb-mi span { display: flex; flex-direction: column; } .sb-mi b { font: 600 15px var(--sb-font); } .sb-mi small { font: 500 12.5px var(--sb-font); color: #6b7280; }
.sb-mi[hidden] { display: none; }
.sb-limits { margin: 4px 12px 8px; font: 500 12px var(--sb-font); color: #6b7280; }
/* under the box: cards + counter */
.sb-under { display: flex; flex-direction: column; gap: 6px; width: 100%; min-width: 0; }
.sb-under:has(> .sb-cards[hidden]):has(.sb-count:empty):has(.sb-msg:empty) { display: none; }   /* [anim-int] no empty gap under the prompt box */
.sb-cards { list-style: none; margin: 4px 0 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.sb-cards[hidden] { display: none; }
.sb-card { border: 1px solid color-mix(in srgb, currentColor 16%, transparent); border-radius: 12px; background: color-mix(in srgb, currentColor 3%, transparent); overflow: hidden; }
.sb-card.failed { border-color: color-mix(in srgb, var(--sb-bad) 60%, transparent); }
.sb-card.off .sb-ct, .sb-card.off .sb-th { opacity: .5; }
.sb-row { display: flex; align-items: center; gap: 8px; padding: 6px 4px 6px 8px; min-height: 56px; }
.sb-th { flex: none; width: 40px; height: 40px; border-radius: 9px; background: color-mix(in srgb, var(--sb-acc) 14%, transparent); display: inline-flex; align-items: center; justify-content: center; overflow: hidden; }
.sb-th.pic { background: repeating-conic-gradient(#e5e7eb 0 25%, #fff 0 50%) 0 0 / 10px 10px; }
.sb-th img { width: 100%; height: 100%; object-fit: contain; }
.sb-cb { flex: 1; min-width: 0; display: flex; flex-direction: column; align-items: flex-start; gap: 2px; border: 0; background: none; color: inherit; padding: 4px 2px; text-align: left; cursor: pointer; font: inherit; }
.sb-cb:disabled { cursor: default; }
.sb-ct { font: 600 15px var(--sb-font); max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sb-cm { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; font: 500 12.5px var(--sb-font); max-width: 100%; }
.sb-cmeta { opacity: .7; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 100%; }
.sb-st { display: inline-flex; align-items: center; gap: 4px; font-weight: 700; }
.sb-st .sb-i { width: 15px; height: 15px; stroke-width: 2.6; }
.sb-st.ok { color: var(--sb-ok); } .sb-st.bad { color: var(--sb-bad); } .sb-st.busy { opacity: .85; }
.sb-spin { width: 12px; height: 12px; border-radius: 50%; border: 2px solid currentColor; border-right-color: transparent; animation: sbspin .8s linear infinite; display: inline-block; }
@keyframes sbspin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .sb-spin { animation: none; } }
.sb-tick { flex: none; width: 44px; height: 44px; display: inline-flex; align-items: center; justify-content: center; cursor: pointer; }
.sb-tick input { width: 22px; height: 22px; accent-color: var(--sb-acc); cursor: pointer; margin: 0; }
.sb-x { flex: none; width: 44px; height: 44px; border: 0; background: none; color: inherit; opacity: .7; border-radius: 10px; display: inline-flex; align-items: center; justify-content: center; cursor: pointer; padding: 0; }
.sb-x:hover { opacity: 1; background: color-mix(in srgb, currentColor 8%, transparent); }
.sb-prog { display: block; height: 3px; background: color-mix(in srgb, currentColor 10%, transparent); } .sb-prog i { display: block; height: 100%; background: var(--sb-acc); transition: width .2s; }
.sb-why { padding: 0 12px 10px 56px; font: 500 13px var(--sb-font); display: flex; flex-wrap: wrap; gap: 6px 12px; align-items: center; }
.sb-why > span { flex-basis: 100%; color: var(--sb-bad); }
.sb-link { display: inline-flex; align-items: center; gap: 4px; min-height: 36px; border: 0; background: none; color: var(--sb-acc); font: 700 13px var(--sb-font); cursor: pointer; padding: 0 2px; }
[data-srcbox="animate"] .sb-link, [data-srcbox="tutor"] .sb-link { color: #1d4ed8; }
.sb-link .sb-i { width: 16px; height: 16px; }
/* picture role */
.sb-role { padding: 0 10px 10px 56px; display: flex; flex-direction: column; gap: 6px; }
.sb-role small { font: 500 12.5px var(--sb-font); opacity: .75; }
.sb-role.one { padding-top: 0; }
.sb-roles { display: flex; flex-wrap: wrap; gap: 6px 10px; align-items: center; }
.sb-seg { display: inline-flex; flex-wrap: wrap; gap: 0; border: 1px solid color-mix(in srgb, currentColor 24%, transparent); border-radius: 999px; padding: 2px; }
.sb-seg button { border: 0 !important; }
.sb-sum { font: 500 12.5px var(--sb-font); opacity: .72; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; max-width: 100%; }
.sb-seg button { min-height: 38px; padding: 6px 11px; border-radius: 999px; border: 1px solid color-mix(in srgb, currentColor 24%, transparent); background: transparent; color: inherit;
  font: 600 13px var(--sb-font); cursor: pointer; }
.sb-seg button.on { background: var(--sb-acc); border-color: var(--sb-acc); color: #fff; }
[data-srcbox="doodle"] .sb-seg button.on { color: #1b1b1b; }
.sb-sub button { min-height: 32px; padding: 4px 10px; font-size: 12.5px; }
.sb-foot { display: flex; flex-wrap: wrap; gap: 4px 12px; align-items: baseline; }
.sb-count { font: 600 12.5px var(--sb-font); opacity: .7; } .sb-count:empty { display: none; }
.sb-msg { margin: 0; font: 500 13px var(--sb-font); } .sb-msg:empty { display: none; } .sb-msg.bad { color: var(--sb-bad); }
/* drop overlay, sheets, toast (fixed, own light colours) */
.sb-drop { position: fixed; inset: 0; z-index: 90; background: rgba(17,24,39,.55); display: flex; align-items: center; justify-content: center; padding: 16px; }
.sb-drop[hidden] { display: none; }
.sb-drop > div { background: #fff; color: #1f2937; border: 3px dashed #2563eb; border-radius: 20px; padding: 32px 28px; display: flex; flex-direction: column; align-items: center; gap: 8px; text-align: center; font: 600 18px Inter, system-ui, sans-serif; }
.sb-drop small { font: 500 13px Inter, system-ui, sans-serif; color: #6b7280; }
.sb-back { position: fixed; inset: 0; z-index: 80; background: rgba(17,24,39,.45); }
.sb-sheet { position: fixed; z-index: 81; left: 50%; top: 50%; transform: translate(-50%, -50%); width: min(460px, calc(100vw - 32px)); max-height: min(86vh, 760px); overflow: auto;
  background: #fff; color: #1f2937; border-radius: 18px; box-shadow: 0 20px 60px rgba(0,0,0,.3); padding: 14px 16px 18px; font: 500 15px Inter, system-ui, sans-serif; }
.sb-sheet.wide { width: min(620px, calc(100vw - 32px)); }
@media (max-width: 640px) { .sb-sheet, .sb-sheet.wide { left: 0; right: 0; top: auto; bottom: 0; transform: none; width: auto; max-height: 88vh; border-radius: 18px 18px 0 0;
  padding-bottom: max(18px, env(safe-area-inset-bottom)); } }
.sb-sh-h { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 8px; } .sb-sh-h b { font: 700 17px Inter, system-ui, sans-serif; }
.sb-form { display: flex; flex-direction: column; gap: 10px; }
.sb-in { width: 100%; font: 500 16px Inter, system-ui, sans-serif; padding: 12px; border: 1px solid #d1d5db; border-radius: 12px; color: #1f2937; background: #fff; box-sizing: border-box; }
.sb-in:focus { outline: 2px solid #2563eb; border-color: transparent; }
.sb-ta { resize: vertical; min-height: 140px; }
.sb-pri { min-height: 46px; border: 0; border-radius: 12px; background: #2563eb; color: #fff; font: 700 15px Inter, system-ui, sans-serif; padding: 0 16px; cursor: pointer; }
.sb-sm { min-height: 40px; padding: 0 14px; }
.sb-hint { margin: 0; font: 500 13px Inter, system-ui, sans-serif; color: #6b7280; }
.sb-rec { list-style: none; margin: 0 0 10px; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.sb-rec li { display: flex; align-items: center; gap: 8px; border: 1px solid #e5e7eb; border-radius: 12px; padding: 6px 4px 6px 8px; }
.sb-rec .sb-th { background: #eef2ff; color: #1f2937; }
.sb-rt { flex: 1; min-width: 0; display: flex; flex-direction: column; } .sb-rt b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 14.5px; } .sb-rt small { color: #6b7280; font-size: 12px; }
.sb-prev h4 { margin: 14px 0 4px; font: 700 13px Inter, system-ui, sans-serif; text-transform: uppercase; letter-spacing: .04em; color: #6b7280; }
.sb-prev p { margin: 0; line-height: 1.5; }
.sb-pmeta { color: #6b7280; font-size: 13px; } .sb-pmeta a { color: #1d4ed8; }
.sb-pimg { display: block; max-width: 100%; max-height: 300px; margin: 0 auto 8px; border-radius: 10px; background: repeating-conic-gradient(#eee 0 25%, #fff 0 50%) 0 0 / 14px 14px; }
.sb-pts { margin: 0; padding-left: 20px; } .sb-pts li { margin: 2px 0; }
.sb-ex { margin-top: 12px; } .sb-ex summary { cursor: pointer; font-weight: 600; min-height: 36px; display: flex; align-items: center; }
.sb-ex pre { white-space: pre-wrap; font: 500 13px/1.5 Inter, system-ui, sans-serif; background: #f9fafb; border-radius: 10px; padding: 10px; max-height: 260px; overflow: auto; }
.sb-bad { color: #b91c1c; }
.sb-toast { position: fixed; z-index: 95; left: 50%; bottom: max(16px, env(safe-area-inset-bottom)); transform: translateX(-50%); background: #111827; color: #fff; border-radius: 12px;
  padding: 10px 14px; display: flex; gap: 14px; align-items: center; font: 500 14px Inter, system-ui, sans-serif; box-shadow: 0 8px 30px rgba(0,0,0,.3); max-width: calc(100vw - 32px); }
.sb-toast button { border: 0; background: none; color: #93c5fd; font: 700 14px Inter, system-ui, sans-serif; cursor: pointer; min-height: 36px; }
@media (max-width: 420px) { .sb-role, .sb-why { padding-left: 10px; } .sb-seg button { padding: 6px 9px; font-size: 12.5px; } }
/* the Tutor page styles every button / input inside #ask (style.css): the box's own look wins there */
#ask .sb-plus { padding: 0; border-radius: 50%; background: transparent; color: inherit; border: 1px solid color-mix(in srgb, currentColor 22%, transparent); font: inherit; width: 40px; flex: none; }
#ask .sb-plus:hover, #ask .sb-plus[aria-expanded="true"] { background: color-mix(in srgb, var(--sb-acc) 16%, transparent); }
#ask .sb-comp > input { padding: 10px 6px; border: 0; background: transparent; color: inherit; }
#ask .sb-cb, #ask .sb-x, #ask .sb-link, #ask .sb-mi { background: none; color: inherit; padding: 4px 2px; border-radius: 10px; font: inherit; }
#ask .sb-x { padding: 0; }
#ask .sb-link { color: #1d4ed8; font: 700 13px var(--sb-font); padding: 0 2px; }
#ask .sb-mi { padding: 8px 12px; }
#ask .sb-tick input { flex: none; padding: 0; border: 0; background: none; width: 22px; height: 22px; }
#ask .sb-seg button { background: transparent; color: inherit; padding: 6px 11px; border-radius: 999px; font: 600 13px var(--sb-font); }
#ask .sb-seg button.on { background: var(--sb-acc); color: #fff; }
/* [srcbox-all] Doodle / Tutor: the old tray's lesson choices under the cards (chapters, focus, Only use my sources, notebook) */
.sb-opts { display: flex; flex-direction: column; gap: 8px; padding: 4px 2px 2px; font: 500 14px var(--sb-font); }
.sb-opts[hidden] { display: none; }
.sb-olbl { font: 600 14px var(--sb-font); margin-top: 2px; } .sb-olbl small { font-weight: 500; opacity: .7; }
.sb-opts .sb-in { background: transparent; color: inherit; border: 1px solid color-mix(in srgb, currentColor 24%, transparent); min-height: 44px; padding: 10px 12px; }
.sb-opts .sb-in:focus { outline: 2px solid var(--sb-acc); border-color: transparent; }
.sb-toggle { display: flex; align-items: flex-start; gap: 10px; min-height: 44px; cursor: pointer; padding: 4px 0; }
.sb-toggle input { flex: none; width: 22px; height: 22px; margin: 1px 0 0; accent-color: var(--sb-acc); cursor: pointer; }
.sb-toggle span { display: flex; flex-direction: column; gap: 2px; } .sb-toggle b { font: 600 14.5px var(--sb-font); } .sb-toggle small { font: 500 12.5px var(--sb-font); opacity: .72; }
.sb-nblink { display: inline-flex; align-items: center; gap: 6px; min-height: 40px; font: 700 13.5px var(--sb-font); color: var(--sb-acc); text-decoration: none; align-self: flex-start; }
[data-srcbox="tutor"] .sb-nblink, [data-srcbox="animate"] .sb-nblink { color: #1d4ed8; }
.sb-nblink[hidden] { display: none; } .sb-nblink .sb-i { width: 16px; height: 16px; } .sb-nblink:hover { text-decoration: underline; }
.sb-chap { border: 0; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.sb-chap[hidden] { display: none; }
.sb-chap legend { font: 600 14px var(--sb-font); padding: 0; margin-bottom: 6px; }
.sb-seg2 { display: flex; flex-wrap: wrap; gap: 8px; }
.sb-opt { display: flex; align-items: center; gap: 8px; min-height: 44px; padding: 4px 12px 4px 10px; border: 1px solid color-mix(in srgb, currentColor 20%, transparent); border-radius: 12px; cursor: pointer; font: 500 14px var(--sb-font); }
.sb-opt input { flex: none; width: 20px; height: 20px; margin: 0; accent-color: var(--sb-acc); }
.sb-chlist { display: flex; flex-direction: column; gap: 6px; }
.sb-chlist[hidden] { display: none; }
.sb-chsrc { margin: 6px 0 0; font: 700 13px var(--sb-font); opacity: .8; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sb-cho span { flex: 1; min-width: 0; } .sb-cho small { opacity: .65; font-size: 12px; white-space: nowrap; }
/* Find on the web */
.sb-frow { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.sb-sel { width: auto; flex: 1 1 140px; min-height: 46px; }
.sb-depth button { min-height: 42px; }
.sb-find .sb-seg button.on { background: #2563eb; border-color: #2563eb; color: #fff; }
.sb-res { list-style: none; margin: 10px 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.sb-res li { border: 1px solid #e5e7eb; border-radius: 12px; }
.sb-res li.off { opacity: .6; }
.sb-res label { display: flex; gap: 10px; align-items: flex-start; padding: 10px; cursor: pointer; min-height: 44px; }
.sb-res input { flex: none; width: 22px; height: 22px; margin: 2px 0 0; accent-color: #2563eb; }
.sb-res .sb-rt b { white-space: normal; }
.sb-badges { display: flex; flex-wrap: wrap; gap: 6px; margin: 4px 0 2px; }
.sb-badge { display: inline-flex; align-items: center; gap: 4px; font: 700 12px Inter, system-ui, sans-serif; border-radius: 999px; padding: 2px 8px; background: #f3f4f6; color: #374151; }
.sb-badge .sb-i { width: 13px; height: 13px; }
.sb-badge.ok { background: #dcfce7; color: #166534; } .sb-badge.check { background: #fef9c3; color: #854d0e; } .sb-badge.bad { background: #fee2e2; color: #991b1b; }
.sb-snip { color: #4b5563; font-size: 12.5px; line-height: 1.4; }
.sb-nbs h4 { margin: 14px 0 6px; font: 700 13px Inter, system-ui, sans-serif; text-transform: uppercase; letter-spacing: .04em; color: #6b7280; }
.sb-nbs .sb-link { color: #1d4ed8; }
/* the Tutor page styles every input inside #ask (style.css): the box's own look wins */
#ask .sb-opts input.sb-in { width: 100%; background: transparent; color: inherit; border: 1px solid color-mix(in srgb, currentColor 24%, transparent); border-radius: 12px; padding: 10px 12px; font: 500 16px var(--sb-font); }
#ask .sb-opts input[type=checkbox], #ask .sb-opts input[type=radio] { width: 20px; height: 20px; padding: 0; border: 0; background: none; flex: none; }
.sb-vh { position: absolute !important; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
