/* Stream widgets v2 (assets/js/widgets.js): drawn inside #canvas on the editor, overlay, preview and demo.
   Most styling is inline from the widget's own box/parts settings; this file is layout only. */
.tpw-layer { position: absolute; inset: 0; pointer-events: none; z-index: 50; }
.tpw { position: absolute; transform-origin: 0 0; font-family: system-ui, -apple-system, "Segoe UI", sans-serif; line-height: 1.1; white-space: nowrap; color: #fff; transition: opacity .35s ease; }
.tpw-box { display: inline-flex; flex-direction: column; align-items: center; gap: 2px; min-width: 40px; background-position: center; background-repeat: no-repeat; box-sizing: border-box; }
.tpw--hidden { display: none; }
.tpw-big, .tpw-num, .tpw-time, .tpw-sub, .tpw-gap { font-variant-numeric: tabular-nums; }
.tpw-row { display: flex; align-items: center; gap: 6px; min-height: 30px; }
.tpw-dim { opacity: .55; }
.tpw-chip { display: inline-flex; align-items: center; justify-content: center; padding: 0 7px; box-sizing: border-box; line-height: 1; }
.tpw-chip--img { padding: 0; background-size: contain; background-repeat: no-repeat; background-position: center; }
.tpw-tok { display: inline-flex; align-items: center; gap: 3px; }
.tpw-dir { min-width: 22px; text-align: center; line-height: 1; }
.tpw-plus { opacity: .6; font-size: 13px; font-weight: 700; }
.tpw-gap { opacity: .7; }
.tpw-text { white-space: pre; }
.tpw-cv { display: block; }
.tpw-img { display: block; height: auto; }
/* input history: combos one per line, left aligned; row layout = one line */
.tpw--input_history .tpw-box { align-items: flex-start; min-width: 120px; }
.tpw--input_history .tpw-combo { gap: 8px; }
.tpw--input_history.tpw--row .tpw-box { flex-direction: row; align-items: center; }
.tpw--input_history.tpw--empty .tpw-box { min-height: 34px; }
.tpw--hold_timer .tpw-box, .tpw--button_counts .tpw-box { align-items: flex-start; }
.tpw-grid { display: grid; gap: 6px 14px; }
.tpw-bars { display: flex; gap: 14px; align-items: flex-end; }
.tpw-bars--h { flex-direction: column; align-items: stretch; gap: 8px; }
.tpw-barwrap { display: flex; flex-direction: column; align-items: center; gap: 4px; }
.tpw-bars--h .tpw-barwrap { flex-direction: row-reverse; justify-content: flex-end; gap: 8px; }
.tpw-bar { position: relative; overflow: hidden; display: flex; align-items: flex-end; }
.tpw-bars--h .tpw-bar { align-items: stretch; }
.tpw-bar__fill { transition: height .05s linear, width .05s linear; }
.tpw-wheel { position: relative; border-radius: 50%; box-sizing: border-box; background-size: contain; background-repeat: no-repeat; background-position: center; margin-bottom: 4px; }
.tpw-spoke { position: absolute; left: 50%; top: 50%; border-radius: 3px; }
.tpw-spoke--h { width: 100%; height: 8px; transform: translate(-50%, -50%); }
.tpw-spoke--v { width: 8px; height: 50%; transform: translate(-50%, 0); }
.tpw--combo_popup .tpw-box { min-height: 40px; }
.tpw--fade { opacity: 0; }
.tpw-pop { animation: tpw-pop .22s ease-out; }
.tpw-pop-in { animation: tpw-pop-in .35s cubic-bezier(.2, 1.6, .4, 1); }
@keyframes tpw-pop { 0% { transform: scale(1.25); } 100% { transform: scale(1); } }
@keyframes tpw-pop-in { 0% { transform: scale(.3); opacity: 0; } 100% { transform: scale(1); opacity: 1; } }
@media (prefers-reduced-motion: reduce) { .tpw-pop, .tpw-pop-in { animation: none; } .tpw { transition: none; } }

/* ---------- editor only ---------- */
.tpw-layer--edit .tpw { pointer-events: auto; cursor: move; }
.tpw-layer--edit .tpw.tpw--pinned { cursor: default; }
.tpw-layer--edit .tpw.tpw--fade { opacity: .35; }
.tpw-layer--edit .tpw.tpw--hidden { display: block; opacity: .25; }
.tpw-layer--edit .tpw.is-selected .tpw-box { outline: 2px solid #4c8dff; outline-offset: 3px; }
.tpw-layer--edit .tpw.tpw--locked .tpw-box { outline: 2px dashed #e3b341; outline-offset: 3px; }
.tpw-handle { display: none; position: absolute; right: -9px; bottom: -9px; width: 14px; height: 14px; border-radius: 3px; background: #4c8dff; border: 2px solid #fff; cursor: nwse-resize; box-shadow: 0 1px 4px rgba(0,0,0,.5); }
.tpw-layer--edit .tpw.is-selected:not(.tpw--pinned) .tpw-handle { display: block; }

/* items list rows */
#tpWidgetRows { display: flex; flex-direction: column; gap: 4px; margin-top: 4px; }
#tpWidgetRows .layer-item { gap: 6px; padding: 6px 6px 6px 10px; display: flex; align-items: center; }
#tpWidgetRows .e2-layer-name { flex: 1; min-width: 0; font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#tpWidgetRows .is-hidden .e2-layer-name { opacity: .45; text-decoration: line-through; }
.tpw-li__ic { color: #e3b341; width: 16px; text-align: center; }
.tpw-li__tag { font-size: 11px; opacity: .6; }

/* right panel: the widget editor replaces the controller tabs while a widget is selected */
.tpw-ed { display: none; }
#e2Right.e2-right--widget > .tabs, #e2Right.e2-right--widget > .right-panel { display: none !important; }
#e2Right.e2-right--widget > .tpw-ed { display: flex; flex-direction: column; min-height: 0; flex: 1 1 auto; overflow: hidden; }
.tpw-ed__head { display: flex; align-items: center; gap: 8px; padding: 10px 12px; border-bottom: 1px solid var(--e2-line, rgba(255,255,255,.1)); }
.tpw-ed__head > i { color: #e3b341; }
.tpw-ed__name { flex: 1; min-width: 0; }
.tpw-ed__warn { margin: 8px 12px 0; padding: 8px 10px; border-radius: 8px; background: rgba(227,179,65,.12); border: 1px solid rgba(227,179,65,.35); font-size: 12px; }
.tpw-ed__tabs { display: flex; }
.tpw-ed__body { flex: 1 1 auto; overflow-y: auto; padding: 12px; display: flex; flex-direction: column; gap: 10px; }
.tpw-ed .tpw-f { display: flex; flex-direction: column; gap: 3px; font-size: 12px; margin: 0; min-width: 0; }
.tpw-ed .tpw-f > span { opacity: .75; }
.tpw-ed .tpw-f2 { display: flex; gap: 10px; align-items: flex-end; }
.tpw-ed .tpw-f2 > * { flex: 1 1 0; min-width: 0; }
.tpw-ed .tpw-color { width: 100%; min-width: 44px; height: 32px; padding: 0; border: 1px solid var(--e2-line, rgba(255,255,255,.15)); border-radius: 6px; background: none; cursor: pointer; }
.tpw-ed input[type=range] { padding: 0; }
.tpw-ed .tpw-check { display: flex; align-items: center; gap: 8px; font-size: 12px; margin: 0; min-height: 28px; }
.tpw-ed .tpw-h { font-size: 12px; text-transform: uppercase; letter-spacing: .08em; opacity: .7; margin: 8px 0 0; }
.tpw-ed .tpw-hint { font-size: 11.5px; opacity: .7; margin: 0; white-space: normal; }
.tpw-ed .tpw-hint code { font-size: 11px; }
.tpw-ed .tpw-urlrow { display: flex; gap: 6px; }
.tpw-ed .tpw-urlrow input { flex: 1; min-width: 0; }
.tpw-ed details { border: 1px solid var(--e2-line, rgba(255,255,255,.1)); border-radius: 8px; }
.tpw-ed details > summary { cursor: pointer; padding: 8px 10px; font-size: 13px; font-weight: 600; }
.tpw-ed .tpw-part__in, .tpw-ed .tpw-imgs { display: flex; flex-direction: column; gap: 8px; padding: 0 10px 10px; }
.tpw-ed .tpw-imgs { border: 0; padding: 0; }
.tpw-ed .tpw-imgs > summary { padding: 4px 0; font-weight: 500; font-size: 12px; }
.tpw-ed__acts { display: flex; gap: 8px; margin-top: 6px; }
.tpw-presets { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.tpw-preset { display: flex; align-items: center; gap: 8px; padding: 8px; min-height: 44px; border-radius: 10px; border: 1px solid var(--e2-line, rgba(255,255,255,.12)); background: transparent; color: inherit; cursor: pointer; font-size: 13px; }
.tpw-preset.is-on { border-color: #4c8dff; background: rgba(76,141,255,.1); }
.tpw-preset__sw { width: 26px; height: 26px; border-radius: 7px; flex: 0 0 auto; border: 1px solid rgba(255,255,255,.2); }
.tpw-preset__sw--dark { background: #0a0c12; }
.tpw-preset__sw--neon { background: #05060a; border: 2px solid #22d3ee; box-shadow: 0 0 8px #22d3ee; }
.tpw-preset__sw--glass { background: linear-gradient(135deg, rgba(255,255,255,.35), rgba(255,255,255,.08)); }
.tpw-preset__sw--minimal { background: repeating-conic-gradient(#666 0 25%, #333 0 50%) 0 0 / 10px 10px; }
.tpw-preset__sw--arcade { background: #1a0b2e; border: 2px solid #ff3ea5; }
.tpw-preset__sw--light { background: #fff; }

/* template picker (Add items → Widgets) */
.tpw-picker { position: fixed; inset: 0; z-index: 10050; background: rgba(0,0,0,.6); display: flex; align-items: center; justify-content: center; padding: 16px; }
.tpw-picker__box { width: min(1100px, 100%); max-height: 100%; display: flex; flex-direction: column; background: #12151d; color: #e6e9ef; border: 1px solid rgba(255,255,255,.1); border-radius: 14px; box-shadow: 0 20px 60px rgba(0,0,0,.5); overflow: hidden; }
.tpw-picker__head { display: flex; align-items: center; gap: 14px; padding: 14px 16px; border-bottom: 1px solid rgba(255,255,255,.08); flex-wrap: wrap; }
.tpw-picker__head strong { font-size: 16px; }
.tpw-picker__head strong i { color: #e3b341; }
.tpw-picker__note { font-size: 13px; opacity: .8; flex: 1; }
.tpw-picker__note a { color: #e3b341; }
.tpw-picker__x { margin-left: auto; width: 40px; height: 40px; border-radius: 10px; border: 1px solid rgba(255,255,255,.12); background: transparent; color: inherit; font-size: 22px; cursor: pointer; }
.tpw-picker__body { overflow-y: auto; padding: 4px 16px 16px; }
.tpw-picker__cat { font-size: 12px; text-transform: uppercase; letter-spacing: .1em; opacity: .65; margin: 16px 0 8px; }
.tpw-picker__grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 10px; }
.tpw-picker__type { border: 1px solid rgba(255,255,255,.08); border-radius: 12px; padding: 10px; background: rgba(255,255,255,.02); }
.tpw-picker__type.is-locked { opacity: .6; }
.tpw-picker__name { font-weight: 700; font-size: 14px; }
.tpw-picker__name i { color: #e3b341; width: 18px; }
.tpw-picker__name small { font-weight: 600; font-size: 11px; color: #e3b341; margin-left: 4px; }
.tpw-picker__name p { margin: 2px 0 8px; font-weight: 400; font-size: 12px; opacity: .7; white-space: normal; }
.tpw-picker__presets { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; }
.tpw-picker__card { display: flex; flex-direction: column; align-items: stretch; gap: 4px; padding: 4px; border-radius: 10px; border: 1px solid rgba(255,255,255,.1); background: transparent; color: inherit; cursor: pointer; min-width: 0; }
.tpw-picker__card:hover, .tpw-picker__card:focus-visible { border-color: #4c8dff; background: rgba(76,141,255,.08); }
.tpw-picker__prev { position: relative; height: 92px; border-radius: 7px; overflow: hidden; display: flex; align-items: center; justify-content: center;
  background: #2a2f3a repeating-conic-gradient(rgba(255,255,255,.06) 0 25%, transparent 0 50%) 0 0 / 14px 14px; }
.tpw-picker__prev .tpw { position: absolute; left: 50%; top: 50%; transform-origin: center; transform: translate(-50%, -50%); pointer-events: none; }
.tpw-picker__pname { font-size: 12px; text-align: center; }
@media (max-width: 640px) { .tpw-picker { padding: 0; } .tpw-picker__box { border-radius: 0; height: 100%; } .tpw-picker__grid { grid-template-columns: 1fr; } }

/* ---------- controller "disconnected" looks (editor.js, disconnectedState.style) ----------
   Lives here because this file is loaded by every page that draws controllers (editor, overlay, preview, demo). */
.tp-disc { position: absolute; transform: translate(-50%, -50%); pointer-events: none; z-index: 2000; display: inline-flex; flex-direction: column; align-items: center; gap: 4px;
  white-space: nowrap; line-height: 1.1; --tp-disc-accent: #ff4d4d; }
.tp-disc--badge { padding: 14px 22px 12px; border-radius: 16px; background: rgba(10, 12, 18, .86); border: 2px solid var(--tp-disc-accent);
  box-shadow: 0 8px 30px rgba(0,0,0,.45), 0 0 18px color-mix(in srgb, var(--tp-disc-accent) 45%, transparent); text-shadow: none !important; }
.tp-disc__icon { display: inline-flex; width: 1.3em; height: 1.3em; color: var(--tp-disc-accent); animation: tp-disc-blink 1.6s ease-in-out infinite; }
.tp-disc__icon svg { width: 100%; height: 100%; }
.tp-disc__sub { font-size: max(12px, .42em); font-weight: 600; opacity: .75; letter-spacing: .06em; color: #fff; }
.tp-disc__sub::after { content: ''; display: inline-block; width: 1.2em; text-align: left; animation: tp-disc-dots 1.4s steps(4) infinite; }
.tp-disc--signal { padding: 16px 30px; border-radius: 6px; color: #fff !important; text-transform: uppercase; letter-spacing: .14em;
  background: repeating-linear-gradient(0deg, rgba(255,255,255,.06) 0 2px, transparent 2px 4px), linear-gradient(135deg, #1b1f2a, #0b0d12);
  border: 1px solid rgba(255,255,255,.18); box-shadow: 0 0 0 4px rgba(0,0,0,.35); animation: tp-disc-glitch 2.4s steps(1) infinite; }
.tp-disc--signal .tp-disc__icon { color: var(--tp-disc-accent); }
.tp-disc--back { flex-direction: row; gap: 8px; padding: 10px 18px; border-radius: 999px; background: rgba(10, 12, 18, .86); border: 2px solid #3fb950; color: #fff;
  font: 800 24px system-ui, sans-serif; animation: tp-disc-back 1.8s ease forwards; }
.tp-disc--back .tp-disc__icon { color: #3fb950; animation: none; width: 1.1em; height: 1.1em; }
@keyframes tp-disc-blink { 0%, 100% { opacity: 1; } 50% { opacity: .35; } }
@keyframes tp-disc-dots { 0% { content: ''; } 25% { content: '.'; } 50% { content: '..'; } 75% { content: '...'; } }
@keyframes tp-disc-glitch { 0%, 100% { transform: translate(-50%, -50%); } 92% { transform: translate(calc(-50% + 3px), -50%) skewX(-4deg); } 94% { transform: translate(calc(-50% - 3px), -50%); } }
@keyframes tp-disc-back { 0% { opacity: 0; transform: translate(-50%, -50%) scale(.6); } 15% { opacity: 1; transform: translate(-50%, -50%) scale(1); } 80% { opacity: 1; } 100% { opacity: 0; } }
@media (prefers-reduced-motion: reduce) { .tp-disc__icon, .tp-disc--signal, .tp-disc__sub::after { animation: none; } }

/* ---------- extra controller parts (assets/js/controller-parts.js): hat, slider, twist, strum, whammy ---------- */
.tpp { position: absolute; inset: 0; pointer-events: none; border-radius: inherit; overflow: hidden; }
.tpp--hat { overflow: visible; }
.tpp-hat__w { position: absolute; inset: 0; z-index: 2; pointer-events: none; }
.tpp-hat__a { position: absolute; left: 50%; top: 6%; width: 0; height: 0; border-style: solid; border-color: transparent; transform: translateX(-50%); transition: border-bottom-color .06s; }
.tpp-hat__a.is-on { filter: drop-shadow(0 0 6px currentColor); }
.tpp-hat__dot { position: absolute; left: 50%; top: 50%; width: 18%; height: 18%; border-radius: 50%; transform: translate(-50%, -50%); z-index: 1; }
.tpp--slider .tpp-fill { position: absolute; left: 0; right: 0; bottom: 0; height: 0; opacity: .85; }
.tpp--slider .tpp-knob { position: absolute; left: -4%; right: -4%; height: 8px; bottom: 0; transform: translateY(50%); border-radius: 4px; box-shadow: 0 1px 4px rgba(0,0,0,.6); }
.tpp--slider .tpp-pct { position: absolute; left: 0; right: 0; top: 4px; text-align: center; font: 700 13px system-ui, sans-serif; text-shadow: 0 1px 2px rgba(0,0,0,.8); }
.tpp--slider.tpp--h .tpp-fill { top: 0; bottom: 0; right: auto; width: 0; height: auto; }
.tpp--slider.tpp--h .tpp-knob { top: -4%; bottom: -4%; left: 0; right: auto; width: 8px; height: auto; transform: translateX(-50%); }
.tpp--twist .tpp-fill { position: absolute; top: 15%; bottom: 15%; left: 50%; width: 0; border-radius: 4px; }
.tpp--twist .tpp-mid { position: absolute; top: 8%; bottom: 8%; left: 50%; width: 2px; transform: translateX(-50%); opacity: .8; }
.tpp--strum .tpp-bar { position: absolute; left: 8%; right: 8%; top: 50%; height: 26%; margin-top: -13%; border-radius: 6px; transition: transform .05s ease-out; box-shadow: 0 2px 6px rgba(0,0,0,.5); }
.tpp-whammy-host { rotate: var(--tpp-whammy, 0deg); transform-origin: 6% 50%; }
.tpp-panel { margin-bottom: 8px; }
.tpw-beats { gap: 8px; }
.tpw-beat { display: inline-block; border-radius: 50%; transition: background .05s; }

/* auto-hide when idle (controller-parts.js) */
#canvas [data-item-id] { transition: opacity .6s ease; }
#canvas [data-item-id].tpp-idle { opacity: 0 !important; }

/* Stream effects (Twitch chat / follows / subs / raids, controller-parts.js tpPlayEffect) */
#canvas [data-item-id].tpfx-glow { filter: drop-shadow(0 0 14px #e3b341) drop-shadow(0 0 28px #e3b341); animation: tpfx-pulse 1s ease-in-out infinite; }
#canvas [data-item-id].tpfx-shake { animation: tpfx-shake .45s linear infinite; }
#canvas [data-item-id].tpfx-bounce { animation: tpfx-bounce .6s ease-in-out infinite; }
#canvas [data-item-id].tpfx-rainbow { animation: tpfx-rainbow 2s linear infinite; }
#canvas [data-item-id].tpfx-flash { animation: tpfx-flash .5s steps(2) infinite; }
#canvas [data-item-id].tpfx-spin { animation: tpfx-spin 1.2s ease-in-out infinite; }
@keyframes tpfx-pulse { 50% { filter: drop-shadow(0 0 6px #e3b341); } }
@keyframes tpfx-shake { 0%, 100% { translate: 0 0; } 20% { translate: -6px 2px; } 40% { translate: 5px -3px; } 60% { translate: -4px 3px; } 80% { translate: 6px -2px; } }
@keyframes tpfx-bounce { 0%, 100% { translate: 0 0; } 50% { translate: 0 -18px; } }
@keyframes tpfx-rainbow { from { filter: hue-rotate(0deg) saturate(1.6); } to { filter: hue-rotate(360deg) saturate(1.6); } }
@keyframes tpfx-flash { 50% { filter: brightness(2.2); } }
@keyframes tpfx-spin { 0% { rotate: 0deg; } 100% { rotate: 360deg; } }

/* Button press animations (editor.js TP_PRESS_ANIMS): individual transform properties so they stack with rotation */
@keyframes tpa-sink { to { scale: .9; translate: 0 3px; filter: brightness(.85); } }
@keyframes tpa-pop { 0% { scale: 1; } 45% { scale: 1.22; } 100% { scale: 1.06; } }
@keyframes tpa-jelly { 0% { scale: 1 1; } 30% { scale: 1.2 .82; } 55% { scale: .9 1.12; } 75% { scale: 1.05 .96; } 100% { scale: 1 1; } }
@keyframes tpa-tilt { to { rotate: -8deg; scale: .96; } }
@keyframes tpa-spin { to { rotate: 360deg; } }
@keyframes tpa-flash { 0% { filter: brightness(2.4) drop-shadow(0 0 10px #fff); } 100% { filter: brightness(1.15); } }
@media (prefers-reduced-motion: reduce) { [style*="tpa-"] { animation-duration: 1ms !important; } }
