/* gbt.chat tool widget (/tools/<slug>), design "Paper": a paper card with the input on the left (top on phones) and
   the answer on a cream sheet beside it. Needs md.css (the --gb-* tokens). */
.gb-widget-wrap { width: 100%; container-type: inline-size; }
.gb-widget { display: grid; grid-template-columns: minmax(0, 1fr); overflow: hidden; border: 1px solid var(--gb-border); border-radius: 20px; background: var(--gb-surface); color: var(--gb-text); font-family: var(--font); box-shadow: var(--gb-shadow); }
@container (min-width: 820px) {
  .gb-widget { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
  .gb-widget-out { border-top: 0 !important; border-inline-start: 1px solid var(--gb-border); }
}
.gb-widget *, .gb-widget *::before, .gb-widget *::after { box-sizing: border-box; }
.gb-widget :where(button, select, textarea) { font-family: inherit; }
.gb-widget .gb-ico { display: block; flex: none; }

.gb-widget-in { display: flex; flex-direction: column; gap: 14px; min-width: 0; padding: 22px; }
.gb-widget-head { display: flex; align-items: center; gap: 10px; }
.gb-widget-ic { flex: none; display: grid; place-items: center; width: 34px; height: 34px; border-radius: 11px; background: var(--gb-accent-wash); color: var(--gb-accent-ink); }
.gb-widget-label { flex: 1 1 auto; min-width: 0; font-family: var(--gb-serif, var(--font-display)); font-size: 18px; font-weight: 600; }
.gb-widget-count { color: var(--gb-dim); font: 500 12px var(--font-mono); font-variant-numeric: tabular-nums; white-space: nowrap; }
.gb-widget-count.is-over { color: var(--gb-danger); }
.gb-widget-box { position: relative; }
.gb-widget-box textarea { display: block; width: 100%; min-height: 168px; max-height: 420px; padding: 14px 16px 42px; border: 1px solid var(--gb-border); border-radius: 14px; outline: none; background: var(--gb-bg); color: var(--gb-text); font-size: 15px; line-height: 1.6; resize: vertical; transition: border-color .15s; }
.gb-widget-box textarea::placeholder { color: var(--gb-dim); }
.gb-widget-box textarea:focus { border-color: color-mix(in srgb, var(--gb-accent) 55%, var(--gb-border)); }
.gb-widget-box textarea[readonly] { opacity: .75; }
.gb-widget-clear { position: absolute; bottom: 10px; inset-inline-end: 10px; display: inline-flex; align-items: center; gap: 5px; height: 28px; padding: 0 10px; border: 1px solid var(--gb-border); border-radius: 999px; background: var(--gb-surface); color: var(--gb-text-2); font-size: 12.5px; cursor: pointer; }
.gb-widget-clear:hover { background: var(--gb-soft); color: var(--gb-text); }
.gb-widget-ex { display: flex; flex-wrap: wrap; gap: 6px; }
.gb-widget-chip { display: inline-flex; align-items: center; gap: 6px; max-width: 100%; height: 34px; padding: 0 12px; border: 1px solid var(--gb-border); border-radius: 18px; background: var(--gb-surface); color: var(--gb-text); font-size: 13px; line-height: 1.35; text-align: start; cursor: pointer; transition: background .15s, border-color .15s; }
.gb-widget-chip span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.gb-widget-chip .gb-ico { color: var(--gb-accent); }
.gb-widget-chip:hover:not(:disabled) { border-color: color-mix(in srgb, var(--gb-accent) 40%, var(--gb-border)); background: var(--gb-bg); }
.gb-widget-chip:disabled { opacity: .5; cursor: default; }
.gb-widget-opts { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; }
.gb-widget-opt { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.gb-widget-opt > span { color: var(--gb-text-2); font-size: 12.5px; font-weight: 600; }
.gb-widget-opt select { width: 100%; height: 42px; padding-inline: 12px 34px; border: 1px solid var(--gb-border); border-radius: 12px; outline: none; background: var(--gb-bg) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%238B8274' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E") no-repeat right 12px center; color: var(--gb-text); font-size: 14px; cursor: pointer; appearance: none; -webkit-appearance: none; }
[dir="rtl"] .gb-widget-opt select { background-position: left 12px center; }
.gb-widget-opt select:focus { border-color: var(--gb-accent); }
.gb-widget-go { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; }
.gb-widget-btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: 46px; padding: 0 26px; border: 0; border-radius: 999px; background: var(--gb-ink); color: var(--gb-on-ink); font-size: 15px; font-weight: 600; cursor: pointer; transition: opacity .15s, transform .12s; }
.gb-widget-btn:active:not(:disabled) { transform: scale(.98); }
.gb-widget-btn:disabled { opacity: .4; cursor: default; }
.gb-widget-btn.is-stop { border: 1px solid var(--gb-border); background: var(--gb-surface); color: var(--gb-text); }
.gb-widget :is(.gb-widget-btn, .gb-widget-act, .gb-widget-cont, .gb-widget-chip, .gb-widget-clear):focus-visible { outline: none; box-shadow: var(--gb-focus); }
.gb-widget-credits { display: inline-flex; align-items: center; gap: 5px; color: var(--gb-dim); font-size: 12.5px; }
.gb-widget-credits .gb-ico { color: var(--gb-accent); }
.gb-widget-credits.is-low { color: var(--gb-accent-ink); }
.gb-widget-msg { margin: 0; padding: 10px 14px; border-radius: 12px; background: color-mix(in srgb, var(--gb-danger) 9%, transparent); color: var(--gb-danger); font-size: 14px; }
.gb-widget [hidden] { display: none !important; }

.gb-widget-out { display: flex; flex-direction: column; min-width: 0; min-height: 320px; border-top: 1px solid var(--gb-border); background: var(--gb-bg); }
.gb-widget-out-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 14px 14px 8px 22px; padding-inline: 22px 14px; }
.gb-widget-out-title { margin: 0; color: var(--gb-dim); font-size: 13px; font-weight: 600; }
.gb-widget-acts { display: flex; gap: 4px; }
.gb-widget-act { display: inline-flex; align-items: center; gap: 6px; height: 34px; padding: 0 12px; border: 1px solid var(--gb-border); border-radius: 999px; background: var(--gb-surface); color: var(--gb-text); font-size: 13px; font-weight: 500; cursor: pointer; transition: background .15s; }
.gb-widget-act:hover:not(:disabled) { background: var(--gb-soft); }
.gb-widget-act:disabled { opacity: .45; cursor: default; }
.gb-widget-act.is-done { color: var(--gb-success); }
.gb-widget-res { flex: 1 1 auto; min-height: 200px; max-height: 560px; padding: 4px 22px 18px; overflow-y: auto; }
.gb-widget-res .gb-prose { font-size: 15.5px; }
.gb-widget-res.is-streaming .gb-prose > :last-child:not(.gb-code, .gb-table)::after { content: ""; display: inline-block; width: 8px; height: 16px; margin-inline-start: 3px; border-radius: 2px; background: var(--gb-accent); vertical-align: -2px; animation: gb-wblink 1s steps(2, start) infinite; }
.gb-widget-empty { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px; height: 100%; min-height: 190px; color: var(--gb-dim); font-size: 14px; text-align: center; }
.gb-widget-empty .gb-ico { color: var(--gb-accent); opacity: .7; }
.gb-widget-wait { display: flex; align-items: center; gap: 10px; height: 32px; color: var(--gb-dim); font-size: 14px; }
.gb-widget-limit { padding: 16px; border: 1px solid var(--gb-border); border-radius: 18px; background: var(--gb-surface); }
.gb-widget-foot { padding: 12px 22px 18px; border-top: 1px solid var(--gb-border); }
.gb-widget-cont { display: inline-flex; align-items: center; gap: 8px; padding: 4px 2px; border-radius: 8px; color: var(--gb-accent-ink); font-size: 14px; font-weight: 600; text-decoration: none; }
.gb-widget-cont .gb-ico { color: currentColor; }
.gb-widget-cont:hover span { text-decoration: underline; text-underline-offset: 3px; }
[dir="rtl"] .gb-widget .gb-flip { transform: scaleX(-1); }
.gb-widget .gb-dots { display: inline-flex; gap: 4px; }
.gb-widget .gb-dots i { width: 6px; height: 6px; border-radius: 50%; background: var(--gb-accent); animation: gb-wdot 1.2s ease-in-out infinite; }
.gb-widget .gb-dots i:nth-child(2) { animation-delay: .15s; }
.gb-widget .gb-dots i:nth-child(3) { animation-delay: .3s; }
@keyframes gb-wdot { 0%, 80%, 100% { opacity: .4; transform: scale(.6); } 40% { opacity: 1; transform: scale(1); } }
@keyframes gb-wblink { to { visibility: hidden; } }
@container (max-width: 520px) {
  .gb-widget-in { padding: 16px; }
  .gb-widget-out-head { padding-inline: 16px 10px; }
  .gb-widget-res, .gb-widget-foot { padding-inline: 16px; }
  .gb-widget-act span { display: none; }
  .gb-widget-act { justify-content: center; width: 34px; padding: 0; }
  .gb-widget-btn { flex: 1 1 100%; }
}
@media (prefers-reduced-motion: reduce) { .gb-widget * { animation: none !important; transition: none !important; } }
