/* Theme picker — styled with the page's own tokens, so it previews the theme it sets */
html.tp-anim, html.tp-anim *, html.tp-anim *::before, html.tp-anim *::after {
  transition: background-color .4s ease, color .4s ease, border-color .4s ease, fill .4s ease, box-shadow .4s ease !important;
}
.tp-fab {
  position: fixed; left: 18px; bottom: 18px; z-index: 690;
  display: inline-flex; align-items: center; gap: 8px;
  font: 600 13px var(--sans); color: var(--ink); background: var(--paper);
  border: 1px solid var(--line-2); border-radius: 999px; padding: 10px 15px 10px 12px; cursor: pointer;
  box-shadow: 0 10px 30px -12px rgba(0,0,0,.35);
  transition: transform .2s, box-shadow .2s;
}
.tp-fab svg { color: var(--amber-2); }
.tp-fab:hover { transform: translateY(-2px); box-shadow: 0 14px 34px -12px rgba(0,0,0,.4); }
.tp-fab.on { background: var(--ink); color: var(--on-ink); }
.tp-fab.on svg { color: var(--amber-3); }
.tp-fab:focus-visible { outline: 2px solid var(--amber); outline-offset: 3px; }

.tp {
  position: fixed; left: 18px; bottom: 74px; z-index: 695;
  width: min(380px, calc(100vw - 36px)); max-height: min(640px, calc(100dvh - 110px));
  display: flex; flex-direction: column;
  background: var(--bg-2); color: var(--ink); border: 1px solid var(--line-2); border-radius: 18px;
  box-shadow: 0 30px 70px -24px rgba(0,0,0,.45); font-family: var(--sans); overflow: hidden;
}
.tp[hidden] { display: none !important; }
@media (prefers-reduced-motion: no-preference) {
  .tp:not([hidden]) { animation: tpIn .28s cubic-bezier(.2,.7,.25,1); }
  @keyframes tpIn { from { opacity: 0; transform: translateY(12px) scale(.98); } to { opacity: 1; transform: none; } }
}
.tp-head { display: flex; gap: 12px; align-items: flex-start; padding: 18px 18px 12px; border-bottom: 1px solid var(--line); }
.tp-head h2 { font-size: 20px; font-weight: 700; letter-spacing: -.02em; }
.tp-head p { font-size: 13px; line-height: 1.45; color: var(--ink-dim); margin-top: 3px; }
.tp-x { flex: none; width: 32px; height: 32px; border-radius: 50%; border: 1px solid var(--line-2); background: transparent; color: var(--ink); font-size: 20px; line-height: 1; cursor: pointer; }
.tp-x:hover { background: var(--ink); color: var(--on-ink); }

.tp-tabs { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; margin: 12px 18px 4px; padding: 4px; background: var(--line); border-radius: 999px; }
.tp-tabs button { font: 600 13px var(--sans); color: var(--ink-dim); background: transparent; border: 0; border-radius: 999px; padding: 8px; cursor: pointer; }
.tp-tabs button[aria-selected="true"] { background: var(--paper); color: var(--ink); box-shadow: 0 1px 3px rgba(0,0,0,.12); }

.tp-body { overflow: auto; overscroll-behavior: contain; padding: 10px 18px 14px; }
.tp-body [hidden] { display: none !important; }
.tp-list { display: flex; flex-direction: column; gap: 8px; }
.tp-opt {
  display: flex; align-items: center; gap: 14px; width: 100%; text-align: left;
  padding: 10px 12px; border-radius: 14px; border: 1px solid var(--line); background: var(--paper);
  color: var(--ink); cursor: pointer; font: inherit; transition: border-color .2s, transform .15s;
}
.tp-opt:hover { border-color: var(--line-4); }
.tp-opt:active { transform: scale(.99); }
.tp-opt[aria-checked="true"] { border-color: var(--amber); box-shadow: 0 0 0 3px var(--accent-ring); }
.tp-opt:focus-visible, .tp-b:focus-visible, .tp-tabs button:focus-visible, .tp-x:focus-visible, .tp-reset:focus-visible { outline: 2px solid var(--amber); outline-offset: 2px; }
.tp-sw { position: relative; flex: none; width: 58px; height: 46px; border-radius: 10px; overflow: hidden; box-shadow: inset 0 0 0 1px rgba(0,0,0,.08); }
.tp-sw i { position: absolute; left: 8px; top: 8px; width: 6px; height: 6px; border-radius: 50%; }
.tp-sw b { position: absolute; left: 18px; top: 9px; width: 30px; height: 4px; border-radius: 2px; opacity: .55; }
.tp-sw s { position: absolute; left: 8px; right: 8px; bottom: 7px; height: 18px; display: flex; align-items: flex-end; gap: 3px; }
.tp-sw u { flex: 1; height: 50%; border-radius: 2px; }
.tp-n { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.tp-n b { font-size: 15px; font-weight: 700; }
.tp-n span { font-size: 12.5px; color: var(--ink-dim); }
.tp-r { flex: none; width: 24px; height: 24px; border-radius: 50%; border: 1.5px solid var(--line-4); display: grid; place-items: center; }
.tp-opt[aria-checked="true"] .tp-r { background: var(--amber); border-color: var(--amber); }
.tp-opt[aria-checked="true"] .tp-r::after { content: ""; width: 9px; height: 5px; border: 2px solid var(--on-accent); border-top: 0; border-right: 0; transform: translateY(-1px) rotate(-45deg); }

.tp-own { display: grid; gap: 8px; }
.tp-f { display: grid; grid-template-columns: 1fr 44px 92px; align-items: center; gap: 10px; padding: 8px 10px 8px 14px; background: var(--paper); border: 1px solid var(--line); border-radius: 12px; font-size: 14px; font-weight: 600; }
.tp-f input[type=color] { width: 44px; height: 32px; padding: 0; border: 1px solid var(--line-2); border-radius: 8px; background: none; cursor: pointer; }
.tp-f input[type=color]::-webkit-color-swatch-wrapper { padding: 3px; }
.tp-f input[type=color]::-webkit-color-swatch { border: 0; border-radius: 5px; }
.tp-f input[type=color]::-moz-color-swatch { border: 0; border-radius: 5px; }
.tp-f input[type=text] { font: 500 14px var(--sans); color: var(--ink); background: transparent; border: 1px solid var(--line-2); border-radius: 8px; padding: 6px 8px; width: 100%; text-transform: lowercase; }
.tp-cr { margin-top: 10px; font-size: 13px; line-height: 1.45; color: var(--ink-2); padding: 9px 12px; border-radius: 10px; background: var(--accent-soft); }
.tp-cr.bad { background: #fde4dd; color: #7a1d10; }
.tp-cr.bad .tp-fix { color: #7a1d10; }
.tp-fix { font: 600 13px var(--sans); color: inherit; background: none; border: 0; text-decoration: underline; cursor: pointer; padding: 0; }
.tp-acts { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 12px; }
.tp-b { flex: 1; font: 600 13px var(--sans); color: var(--ink); background: var(--paper); border: 1px solid var(--line-2); border-radius: 999px; padding: 10px 14px; cursor: pointer; }
.tp-b:hover { border-color: var(--ink); }
.tp-foot { padding: 10px 18px 14px; border-top: 1px solid var(--line); }
.tp-foot:has(.tp-reset[hidden]) { display: none; }
.tp-reset { font: 600 13px var(--sans); color: var(--amber-2); background: none; border: 0; padding: 0; cursor: pointer; }
.tp-reset[hidden] { display: none; }

.tp-toast {
  position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%); z-index: 700;
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap; justify-content: center;
  background: var(--ink); color: var(--on-ink); font: 500 14px var(--sans);
  padding: 10px 12px 10px 18px; border-radius: 999px; box-shadow: 0 16px 40px -14px rgba(0,0,0,.5);
  max-width: calc(100vw - 32px);
}
.tp-toast button { font: 600 13px var(--sans); color: var(--ink); background: var(--bg); border: 0; border-radius: 999px; padding: 7px 13px; cursor: pointer; }
.tp-toast button + button { background: transparent; color: var(--on-ink); box-shadow: inset 0 0 0 1px currentColor; }

@media (max-width: 560px) {
  .tp-fab { left: 12px; bottom: 12px; padding: 11px; }
  .tp-fab span { display: none; }
  .tp { left: 8px; right: 8px; bottom: 8px; width: auto; max-height: calc(100dvh - 90px); border-radius: 20px; }
  .tp-toast { bottom: 70px; border-radius: 18px; }
}
/* keep the floating button clear of the footer's last line */
.foot-bot { padding-bottom: 58px; }
@media print { .tp-fab, .tp, .tp-toast { display: none !important; } }
