/* ============================================================
   BuildMetrx — The Toolbox (pairs with js/toolbox.js)
   A help chatbot built as a rolling tool chest. The launcher in the
   bottom-right corner is the chest parked and closed. Opening it
   rolls the real one in, the lid springs up, answers come out of a
   label maker, and every match is a drawer that pulls open onto its
   FAQ answer. Navy, orange and white only.
   Remove this file's <link> and js/toolbox.js's <script> to take it
   off the site; nothing else depends on them.
   ============================================================ */

.tb {
  --tb-navy: #0f172a;
  --tb-deep: #0b1120;
  --tb-steel: #1e293b;
  --tb-edge: rgba(148, 163, 184, 0.28);
  --tb-orange: #FE5D01;
  --tb-burnt: #C24600;
  --tb-ease: cubic-bezier(0.22, 0.61, 0.36, 1);
  --tb-spring: cubic-bezier(0.34, 1.46, 0.5, 1);
  font-family: "Inter", ui-sans-serif, system-ui, -apple-system, sans-serif;
}

.tb *,
.tb *::before,
.tb *::after {
  box-sizing: border-box;
}

.tb [hidden] {
  display: none !important;
}

/* ---------- Launcher: the chest, parked ---------- */

.tb-launch {
  position: fixed;
  right: 1.25rem;
  bottom: calc(1.25rem + var(--tb-lift, 0px));
  z-index: 45;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin: 0;
  padding: 0.5rem 0.5rem 0.5rem 1rem;
  border: 1px solid var(--tb-edge);
  border-radius: 0.875rem;
  background-color: var(--tb-navy);
  background-image: linear-gradient(rgba(148, 163, 184, 0.07) 1px, transparent 1px),
    linear-gradient(90deg, rgba(148, 163, 184, 0.07) 1px, transparent 1px);
  background-size: 12px 12px;
  color: #fff;
  font: inherit;
  text-align: left;
  cursor: pointer;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.25), 0 20px 40px -18px rgba(15, 23, 42, 0.7);
  transition: transform 0.3s var(--tb-ease), opacity 0.2s ease, border-color 0.25s ease, visibility 0s;
  animation: tb-roll-up 0.7s var(--tb-ease) 0.9s both;
}

.tb-launch:hover,
.tb-launch:focus-visible {
  border-color: rgba(254, 93, 1, 0.75);
  transform: translateY(-2px);
}

.tb-launch:focus-visible {
  outline: 2px solid var(--tb-orange);
  outline-offset: 3px;
}

.tb.is-open .tb-launch {
  visibility: hidden;
  opacity: 0;
  transform: translateX(calc(100% + 2rem));
  transition: transform 0.22s ease-in, opacity 0.22s ease-in, visibility 0s linear 0.22s;
}

@keyframes tb-roll-up {
  from { transform: translateX(calc(100% + 2rem)); }
  to { transform: none; }
}

.tb-launch-text {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

.tb-launch-label {
  font-family: "IBM Plex Mono", ui-monospace, monospace;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.2em;
  line-height: 1.2;
  text-transform: uppercase;
  color: #FE8A39;
}

.tb-launch-sub {
  font-size: 0.8125rem;
  line-height: 1.25;
  white-space: nowrap;
  color: #cbd5e1;
}

.tb-mini {
  flex-shrink: 0;
  width: 2.75rem;
  height: 2.75rem;
  overflow: visible;
}

.tb-mini g {
  transition: transform 0.4s var(--tb-spring);
}

.tb-mini .tb-m-lid {
  transform-box: fill-box;
  transform-origin: 0 100%;
}

.tb-launch:hover .tb-m-lid,
.tb-launch:focus-visible .tb-m-lid { transform: rotate(-24deg); }
.tb-launch:hover .tb-m-tool,
.tb-launch:focus-visible .tb-m-tool { transform: translateY(-7px); }
.tb-launch:hover .tb-m-d1,
.tb-launch:focus-visible .tb-m-d1 { transform: translateX(-3px); }
.tb-launch:hover .tb-m-d2,
.tb-launch:focus-visible .tb-m-d2 { transform: translateX(-7px); transition-delay: 0.06s; }

/* About tucks the Breakdown tab away while its job-site hero plays; the
   toolbox goes with it. */
.ab-tuck .tb:not(.is-open) .tb-launch { translate: 0 160%; visibility: hidden; }

/* ---------- Stage: clips the chest while it rolls in from off screen ---------- */

.tb-stage {
  position: fixed;
  inset: 0;
  z-index: 55;
  overflow: hidden;
  overflow: clip;
  pointer-events: none;
  visibility: hidden;
}

.tb.is-open .tb-stage,
.tb.is-closing .tb-stage {
  visibility: visible;
}

.tb-chest {
  position: absolute;
  right: 1.25rem;
  bottom: 2.1rem;
  display: flex;
  flex-direction: column;
  width: 25rem;
  height: 38.5rem;
  max-height: calc(100vh - 8.5rem);
  max-height: calc(100dvh - 8.5rem);
  pointer-events: auto;
  perspective: 1100px;
  filter: drop-shadow(0 30px 40px rgba(2, 6, 23, 0.45));
  transform: translateX(calc(100% + 3rem));
}

.tb.is-open .tb-chest {
  transform: none;
  animation: tb-roll-in 0.62s cubic-bezier(0.2, 0.75, 0.25, 1) 0.12s both;
}

.tb.is-closing .tb-chest {
  animation: tb-roll-out 0.34s cubic-bezier(0.5, 0, 0.8, 0.4) 0.12s both;
}

@keyframes tb-roll-in {
  0% { transform: translateX(calc(100% + 3rem)); }
  78% { transform: translateX(-7px) rotate(-0.5deg); }
  100% { transform: none; }
}

@keyframes tb-roll-out {
  from { transform: none; }
  to { transform: translateX(calc(100% + 3rem)); }
}

/* ---------- Lid ---------- */

.tb-lid {
  position: relative;
  z-index: 1;
  flex: none;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 0.75rem;
  height: 6.9rem;
  margin: 0 0.5rem;
  padding: 0.75rem 0.75rem 0.85rem 1.1rem;
  border-radius: 1rem 1rem 0 0;
  border: 2px solid #7A2C00;
  border-bottom: 0;
  background: linear-gradient(180deg, #FE8A39 0, #FE5D01 10%, #FE5D01 93%, #C24600 100%);
  color: #0f172a;
  transform-origin: 50% 100%;
}

.tb.is-open .tb-lid { animation: tb-lid-up 0.6s var(--tb-spring) 0.6s both; }
.tb.is-closing .tb-lid { animation: tb-lid-down 0.2s ease-in both; }

@keyframes tb-lid-up {
  from { transform: rotateX(-97deg); }
  to { transform: none; }
}

@keyframes tb-lid-down {
  from { transform: none; }
  to { transform: rotateX(-97deg); }
}

/* Tools hung inside the lid: foam cut-outs the color of the lid in shade */
.tb-hung {
  position: absolute;
  inset: 0.6rem 3.5rem auto 1.1rem;
  height: 2rem;
  width: calc(100% - 4.6rem);
  color: #993800;
  pointer-events: none;
}

.tb-hung svg {
  display: block;
  width: 100%;
  height: 100%;
}

.tb-hung path,
.tb-hung rect,
.tb-hung circle {
  fill: rgba(122, 44, 0, 0.5);
}

.tb-hung .tb-hole { fill: #FE5D01; }

.tb-title {
  margin: 0;
  font-family: "Barlow Condensed", Inter, sans-serif;
  font-size: 1.75rem;
  font-weight: 700;
  line-height: 1;
  letter-spacing: 0.01em;
  text-transform: uppercase;
  color: #0f172a;
}

.tb-sub {
  margin: 0.2rem 0 0;
  font-size: 0.8125rem;
  font-weight: 500;
  line-height: 1.25;
  color: #0f172a;
}

.tb-close {
  position: absolute;
  top: 0.6rem;
  right: 0.6rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.5rem;
  height: 2.5rem;
  border: 0;
  border-radius: 0.6rem;
  background: #0f172a;
  color: #fff;
  cursor: pointer;
  transition: background-color 0.2s ease;
}

.tb-close:hover { background: #334155; }
.tb-close svg { width: 1.1rem; height: 1.1rem; }

.tb-close:focus-visible {
  outline: 2px solid #0f172a;
  outline-offset: 2px;
  box-shadow: 0 0 0 2px #fff inset;
}

/* ---------- Chest body ---------- */

.tb-body {
  position: relative;
  z-index: 2;
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  border: solid #FE5D01;
  border-width: 3px 5px 5px;
  border-top-color: #7A2C00;
  border-radius: 0.4rem 0.4rem 0.9rem 0.9rem;
  background-color: var(--tb-navy);
  background-image: linear-gradient(rgba(148, 163, 184, 0.06) 1px, transparent 1px),
    linear-gradient(90deg, rgba(148, 163, 184, 0.06) 1px, transparent 1px);
  background-size: 18px 18px;
  overflow: hidden;
}

.tb-log {
  flex: 1;
  min-height: 0;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 1rem 0.9rem 1.1rem;
  scrollbar-width: thin;
  scrollbar-color: #475569 transparent;
}

.tb-log:focus-visible {
  outline: 2px solid var(--tb-orange);
  outline-offset: -2px;
}

.tb-turn + .tb-turn { margin-top: 1.15rem; }

/* On its own, the bank of drawers fills the chest */
.tb-bank-turn:only-child {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  min-height: 100%;
}

.tb-bank-turn:only-child .tb-bank {
  flex: 1;
  width: 100%;
  grid-auto-rows: 1fr;
}

/* ---------- Label-maker tape: what the toolbox says ---------- */

.tb-tape {
  position: relative;
  display: inline-block;
  max-width: 100%;
  margin: 0;
  padding: 0.4rem 0.95rem 0.4rem 0.75rem;
  border-radius: 3px 0 0 3px;
  background: linear-gradient(180deg, #FE8A39 0, #FE5D01 18%, #FE5D01 82%, #E95500 100%);
  clip-path: polygon(0 0, 100% 0, calc(100% - 6px) 25%, 100% 50%, calc(100% - 6px) 75%, 100% 100%, 0 100%);
  font-family: "Barlow Condensed", Inter, sans-serif;
  font-size: 1.0625rem;
  font-weight: 700;
  line-height: 1.3;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: #0f172a;
  text-shadow: 0 1px 0 rgba(255, 214, 178, 0.75);
  overflow-wrap: anywhere;
}

.tb-tape.is-printing {
  animation: tb-print 0.55s steps(16, end) both;
}

@keyframes tb-print {
  from { clip-path: polygon(0 0, 0 0, 0 25%, 0 50%, 0 75%, 0 100%, 0 100%); }
  to { clip-path: polygon(0 0, 100% 0, calc(100% - 6px) 25%, 100% 50%, calc(100% - 6px) 75%, 100% 100%, 0 100%); }
}

/* ---------- Masking tape: what the visitor typed ---------- */

.tb-said {
  display: flex;
  justify-content: flex-end;
  margin: 0 0 0.7rem;
}

.tb-said span {
  max-width: 85%;
  padding: 0.4rem 1rem;
  background: #f8fafc;
  clip-path: polygon(5px 0, 100% 0, calc(100% - 4px) 20%, 100% 40%, calc(100% - 5px) 62%, 100% 82%, calc(100% - 3px) 100%, 2px 100%, 6px 78%, 0 58%, 5px 36%, 1px 16%);
  font-size: 0.9375rem;
  font-weight: 500;
  line-height: 1.4;
  color: #0f172a;
  overflow-wrap: anywhere;
  transform: rotate(-1.2deg);
}

.tb-said.is-new span { animation: tb-stick 0.3s var(--tb-spring) both; }

@keyframes tb-stick {
  from { transform: rotate(5deg) scale(1.25) translateY(10px); opacity: 0; }
  to { transform: rotate(-1.2deg); opacity: 1; }
}

.tb-note {
  margin: 0.6rem 0 0;
  font-size: 0.875rem;
  line-height: 1.5;
  color: #cbd5e1;
}

/* ---------- Drawers ---------- */

.tb-drawers {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  margin: 0.75rem 0 0;
  padding: 0;
  list-style: none;
}

.tb-drawer {
  position: relative;
  display: block;
  border: 1px solid rgba(148, 163, 184, 0.3);
  border-radius: 0.5rem;
  background: linear-gradient(180deg, #334155 0, #263449 14%, #1e293b 60%, #172033 100%);
  color: #fff;
  text-decoration: none;
  overflow: hidden;
  -webkit-tap-highlight-color: transparent;
  transition: border-color 0.25s ease, box-shadow 0.35s ease, transform 0.35s var(--tb-ease);
}

.tb-drawers.is-sliding .tb-drawer {
  animation: tb-slide 0.42s var(--tb-ease) both;
  animation-delay: calc(0.12s + var(--i, 0) * 0.07s);
}

@keyframes tb-slide {
  from { transform: translateX(56%); opacity: 0; }
  70% { transform: translateX(-5px); opacity: 1; }
  to { transform: none; opacity: 1; }
}

/* The inside of the drawer, seen from above once it is pulled */
.tb-tray {
  display: grid;
  grid-template-rows: 0fr;
  visibility: hidden;
  background: #0b1120;
  transition: grid-template-rows 0.38s var(--tb-ease), visibility 0s linear 0.38s;
}

.tb-tray > span {
  display: block;
  min-height: 0;
  overflow: hidden;
}

.tb-tray-in {
  display: block;
  padding: 0.75rem 0.85rem 0.8rem;
  box-shadow: inset 0 12px 14px -8px rgba(0, 0, 0, 0.85), inset 8px 0 10px -8px rgba(0, 0, 0, 0.7), inset -8px 0 10px -8px rgba(0, 0, 0, 0.7);
  background-image: radial-gradient(rgba(148, 163, 184, 0.13) 1px, transparent 1.4px);
  background-size: 9px 9px;
}

.tb-peek {
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 3;
  overflow: hidden;
  font-size: 0.84375rem;
  line-height: 1.5;
  color: #cbd5e1;
}

.tb-go {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  margin-top: 0.5rem;
  font-size: 0.84375rem;
  font-weight: 600;
  color: #FE8A39;
}

.tb-go svg { width: 0.9rem; height: 0.9rem; transition: transform 0.25s ease; }

/* The drawer front: full-width pull rail, label holder, question */
.tb-front {
  position: relative;
  display: flex;
  align-items: center;
  gap: 0.7rem;
  min-height: 3.25rem;
  padding: 0.95rem 0.8rem 0.6rem 0.7rem;
}

.tb-front::before {
  content: "";
  position: absolute;
  inset: 0 0 auto;
  height: 6px;
  background: linear-gradient(180deg, #f1f5f9, #94a3b8 45%, #475569);
}

.tb-slot {
  flex: none;
  min-width: 2.1rem;
  padding: 0.2rem 0.3rem;
  border: 1px solid #94a3b8;
  border-radius: 3px;
  background: #f8fafc;
  font-family: "IBM Plex Mono", ui-monospace, monospace;
  font-size: 0.75rem;
  font-weight: 600;
  line-height: 1.2;
  text-align: center;
  color: #0f172a;
}

.tb-q {
  flex: 1;
  min-width: 0;
  font-size: 0.9375rem;
  font-weight: 600;
  line-height: 1.35;
}

.tb-q mark {
  border-radius: 2px;
  background: rgba(254, 93, 1, 0.28);
  color: inherit;
  box-shadow: 0 1px 0 #FE5D01;
}

.tb-topic {
  display: block;
  margin-bottom: 0.1rem;
  font-family: "IBM Plex Mono", ui-monospace, monospace;
  font-size: 0.6875rem;
  font-weight: 500;
  letter-spacing: 0.08em;
  line-height: 1.3;
  text-transform: uppercase;
  color: #cbd5e1;
}

.tb-drawer.is-pulled,
.tb-drawer:hover,
.tb-drawer:focus-visible {
  border-color: rgba(254, 93, 1, 0.8);
}

.tb-drawer.is-pulled {
  box-shadow: 0 14px 22px -10px rgba(0, 0, 0, 0.75);
}

.tb-drawer.is-pulled .tb-tray {
  grid-template-rows: 1fr;
  visibility: visible;
  transition: grid-template-rows 0.38s var(--tb-ease), visibility 0s;
}

.tb-drawer:hover .tb-go svg { transform: translateX(3px); }

.tb-drawer:focus-visible {
  outline: 2px solid #fff;
  outline-offset: 2px;
}

/* ---------- The bank: six topic drawers ---------- */

.tb-bank {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.45rem;
  margin: 0.85rem 0 0;
  padding: 0;
  list-style: none;
}

.tb-bank button {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.5rem;
  width: 100%;
  height: 100%;
  min-height: 5.1rem;
  margin: 0;
  padding: 0.95rem 0.7rem 0.6rem;
  border: 1px solid rgba(148, 163, 184, 0.3);
  border-radius: 0.5rem;
  background: linear-gradient(180deg, #334155 0, #263449 14%, #1e293b 60%, #172033 100%);
  color: #fff;
  font: inherit;
  font-size: 0.875rem;
  font-weight: 600;
  line-height: 1.25;
  text-align: left;
  cursor: pointer;
  overflow: hidden;
  transition: transform 0.28s var(--tb-ease), box-shadow 0.28s ease, border-color 0.2s ease;
}

.tb-bank button::before {
  content: "";
  position: absolute;
  inset: 0 0 auto;
  height: 6px;
  background: linear-gradient(180deg, #f1f5f9, #94a3b8 45%, #475569);
}

.tb-bank button:hover,
.tb-bank button:focus-visible {
  border-color: rgba(254, 93, 1, 0.8);
  transform: translateY(3px) scale(1.025);
  box-shadow: 0 -9px 0 -1px #0b1120, 0 14px 20px -8px rgba(0, 0, 0, 0.8);
}

.tb-bank button:focus-visible {
  outline: 2px solid #fff;
  outline-offset: 2px;
}

.tb.is-open .tb-bank.is-sliding li {
  animation: tb-bank-in 0.4s var(--tb-ease) both;
  animation-delay: calc(0.95s + var(--i, 0) * 0.06s);
}

.tb-bank.is-sliding.is-quick li { animation-delay: calc(0.06s + var(--i, 0) * 0.05s) !important; }

@keyframes tb-bank-in {
  from { opacity: 0; transform: translateY(16px); }
  to { opacity: 1; transform: none; }
}

.tb-bank-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
}

.tb-count {
  font-family: "IBM Plex Mono", ui-monospace, monospace;
  font-size: 0.75rem;
  font-weight: 500;
  color: #cbd5e1;
}

/* ---------- Small links and buttons inside the log ---------- */

.tb-acts {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 0.75rem;
}

.tb-act {
  display: inline-flex;
  align-items: center;
  min-height: 2.5rem;
  padding: 0.4rem 0.9rem;
  border: 1px solid rgba(148, 163, 184, 0.45);
  border-radius: 0.5rem;
  background: transparent;
  color: #fff;
  font: inherit;
  font-size: 0.875rem;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  transition: border-color 0.2s ease, background-color 0.2s ease;
}

.tb-act:hover { border-color: #FE5D01; background: rgba(254, 93, 1, 0.12); }
.tb-act.is-main { border-color: #FE5D01; background: #FE5D01; color: #0f172a; }
.tb-act.is-main:hover { background: #FE8A39; }
.tb-act:focus-visible { outline: 2px solid #fff; outline-offset: 2px; }

/* ---------- Search bar: the chest's bottom rail ---------- */

.tb-form {
  flex: none;
  padding: 0.75rem 0.8rem 0.65rem;
  border-top: 1px solid rgba(148, 163, 184, 0.28);
  background: #0b1120;
}

.tb-field {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.3rem 0.3rem 0.3rem 0.9rem;
  border: 2px solid #fff;
  border-radius: 0.65rem;
  background: #fff;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.tb-field:focus-within {
  border-color: #FE5D01;
  box-shadow: 0 0 0 3px rgba(254, 93, 1, 0.35);
}

.tb-input {
  flex: 1;
  min-width: 0;
  height: 2.5rem;
  margin: 0;
  padding: 0;
  border: 0;
  background: none;
  color: #0f172a;
  font: inherit;
  font-size: 1rem;
  -webkit-appearance: none;
  appearance: none;
}

.tb-input:focus { outline: none; }
.tb-input::placeholder { color: #64748b; opacity: 1; }
.tb-input::-webkit-search-cancel-button { display: none; }

/* The submit button is the chest's lock: the key slot turns on send */
.tb-send {
  flex: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.5rem;
  height: 2.5rem;
  border: 0;
  border-radius: 9999px;
  background: #FE5D01;
  color: #0f172a;
  cursor: pointer;
  transition: background-color 0.2s ease;
}

.tb-send:hover { background: #FE8A39; }
.tb-send:focus-visible { outline: 2px solid #0f172a; outline-offset: 2px; }
.tb-send svg { width: 1.15rem; height: 1.15rem; }
.tb-send.is-turning svg { animation: tb-turn-key 0.4s var(--tb-spring); }

@keyframes tb-turn-key {
  from { transform: rotate(-90deg) scale(0.7); }
  to { transform: none; }
}

.tb-fine {
  margin: 0.55rem 0 0;
  font-size: 0.75rem;
  line-height: 1.4;
  text-align: center;
  color: #94a3b8;
}

/* ---------- Casters ---------- */

.tb-casters {
  position: absolute;
  inset: auto 1.6rem -1.35rem;
  z-index: 1;
  display: flex;
  justify-content: space-between;
  height: 1.9rem;
  pointer-events: none;
}

.tb-casters i {
  width: 1.9rem;
  height: 1.9rem;
  border: 6px solid #020617;
  border-radius: 9999px;
  background: conic-gradient(#e2e8f0 0 12.5%, #64748b 0 25%, #e2e8f0 0 37.5%, #64748b 0 50%, #e2e8f0 0 62.5%, #64748b 0 75%, #e2e8f0 0 87.5%, #64748b 0);
  box-shadow: inset 0 0 0 1px #94a3b8, 0 0 0 1px rgba(148, 163, 184, 0.5);
}

.tb.is-open .tb-casters i { animation: tb-wheel 0.62s cubic-bezier(0.2, 0.75, 0.25, 1) 0.12s both; }
.tb.is-closing .tb-casters i { animation: tb-wheel 0.34s ease-in 0.12s reverse both; }

@keyframes tb-wheel {
  from { transform: rotate(900deg); }
  to { transform: none; }
}

.tb-sr {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* ---------- FAQ page: the answer the visitor was sent to ----------
   Applies only when someone arrives on a question's own link. */

.fq-item:target {
  animation: tb-found 2.4s ease-out 0.3s both;
}

@keyframes tb-found {
  0%, 30% { box-shadow: 0 0 0 3px #FE5D01, 0 18px 40px -18px rgba(254, 93, 1, 0.65); }
  100% { box-shadow: 0 0 0 0 rgba(254, 93, 1, 0); }
}

/* ---------- Phones: icon-only launcher, chest becomes a full-width sheet ---------- */

@media (max-width: 639.98px) {
  .tb-launch {
    right: 0.75rem;
    bottom: 0.75rem;
    padding: 0.3rem;
    border-radius: 0.8rem;
  }

  .tb-launch-text { display: none; }

  .tb-mini {
    width: 2.5rem;
    height: 2.5rem;
  }

  .tb-stage { background: rgba(2, 6, 23, 0); transition: background-color 0.3s ease; z-index: 70; }
  .tb.is-open .tb-stage { background: rgba(2, 6, 23, 0.6); pointer-events: auto; }

  .tb-stage { height: var(--tb-vh, 100%); bottom: auto; }

  .tb-chest {
    right: 0;
    bottom: 0;
    width: 100%;
    height: min(39rem, calc(100% - 0.75rem));
    max-height: none;
  }

  .tb-lid {
    height: 6rem;
    margin: 0 0.6rem;
  }

  .tb-title { font-size: 1.6rem; }
  .tb-hung { height: 1.5rem; }
  .tb-body { border-radius: 0.4rem 0.4rem 0 0; border-width: 3px 0 0; }
  .tb-casters { display: none; }
  .tb-form { padding-bottom: calc(0.65rem + env(safe-area-inset-bottom, 0px)); }
}

/* Short screens (phone on its side, keyboard up): the lid gives its room back */
@media (max-height: 520px) {
  .tb-lid { height: 3.6rem; padding-bottom: 0.6rem; align-items: center; }
  .tb-hung, .tb-sub { display: none; }
  .tb-close { top: 0.4rem; }
  .tb-chest { max-height: calc(100vh - 2.75rem); max-height: calc(100dvh - 2.75rem); }
}

.tb.is-cramped .tb-lid { height: 3.6rem; padding-bottom: 0.6rem; align-items: center; }
.tb.is-cramped .tb-hung,
.tb.is-cramped .tb-sub,
.tb.is-cramped .tb-fine { display: none; }
.tb.is-cramped .tb-close { top: 0.4rem; }

@media (prefers-reduced-motion: reduce) {
  .tb *,
  .tb *::before,
  .tb *::after,
  .tb-launch,
  .fq-item:target {
    animation: none !important;
    transition: none !important;
  }
}

@media print {
  .tb { display: none; }
}
