:root[data-kfir] body { min-width: 280px; }
:root[data-kfir] .kfir-shell {
  width: min(100%, 1540px); margin: auto; padding: 16px;
  display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  align-items: start; gap: 20px;
}
:root[data-kfir] .play { width: 100%; margin: 0; min-height: auto; padding: 0; }
:root[data-kfir] .top { flex-wrap: wrap; }
:root[data-kfir] .actions { flex-wrap: wrap; }
.kfir-scene-panel {
  position: sticky; top: 16px;
  overflow: hidden; min-width: 0; color-scheme: dark;
  color: #f0f0fa; background: #171b2a;
  border: 1px solid #3a3e51; border-radius: 18px;
}
.kfir-scene-panel header {
  position: absolute;
  z-index: 1;
  inset: 6px 6px auto auto;
  pointer-events: none;
}
#kfir-scene-title {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
}
.kfir-scene-panel header p { display: none; }
.kfir-camera-actions { display: flex; gap: 4px; pointer-events: auto; }
.kfir-scene-panel p { font-size: .8rem; color: #bcc1d7; }
.kfir-scene-panel canvas { display: block; width: 100%; height: min(calc(65vw + 72px), 672px); }
.kfir-scene-panel button {
  color: #f0f0fa; padding-inline: 11px; background: #30364a; border-color: #525c78;
}
#kfir-scene-status { padding: 9px 16px; min-height: 37px; }
#kfir-coach {
  position: fixed; z-index: 6; display: flex; align-items: start; gap: 6px;
  width: min(245px, calc(100vw - 35px)); padding: 8px;
  background: var(--paper); color: var(--ink);
  border: 1px solid var(--teal); border-radius: 10px;
  box-shadow: 0 3px 12px #1113; pointer-events: none;
}
#kfir-coach p { flex: 1; padding-inline-start: 4px; font-size: .79rem; line-height: 1.4; }
#kfir-dismiss-hint {
  flex: none; width: 38px; min-height: 38px; padding: 0; pointer-events: auto;
}
:root[data-kfir] [data-kfir-coached] { outline: 2px solid var(--teal); outline-offset: 2px; }
:root[data-kfir] .brick[data-id="wled"] { --brick-color: #bdb2e4; }
.kfir-wled-params {
  font-size: .72rem; font-weight: 700; line-height: 1.15;
  padding: 3px; min-height: 30px; border-radius: 5px;
  color: #2f2146; background: #f3edff; border-color: #6a5488;
}
.brick[data-id="wled"] { --control-ink: #523976; --control-paper: #f6efff; }
:is(#kfir-wled-settings, #modulation) {
  position: fixed; inset: 0 auto auto 0; margin: 0;
  width: min(360px, calc(100vw - 16px)); overflow: auto;
}
:is(#kfir-wled-settings, #modulation)::backdrop { background: transparent; }
#kfir-wled-fields label {
  display: grid; grid-template-columns: minmax(7em, 1fr) 1fr;
  align-items: center; gap: 8px; font-size: .9rem;
}
#kfir-wled-fields input[type="range"] { accent-color: light-dark(#5d4584, #c9afea); }
#kfir-wled-fields input[type="checkbox"] { width: 22px; min-height: 22px; justify-self: start; }
#kfir-wled-fields select { min-height: 40px; }
#kfir-speech-notice { font-size: .85rem; line-height: 1.45; margin-block: 8px; }
#kfir-invite { margin-block: 4px; }
@media (max-width: 940px) {
  :root[data-kfir] .kfir-shell { grid-template-columns: minmax(0, 1fr); gap: 14px; }
  :root[data-kfir] .play { max-width: 740px; margin-inline: auto; }
  .kfir-scene-panel { position: relative; top: auto; width: min(100%, 740px); margin-inline: auto; }
  .kfir-scene-panel canvas { height: clamp(307px, calc(66vw + 72px), 532px); }
}
@media (max-width: 460px) {
  :root[data-kfir] .kfir-shell { padding-inline: 7px; padding-top: 8px; }
  :root[data-kfir] .actions { gap: 4px; }
  :root[data-kfir] .actions button { padding-inline: 7px; }
  :root[data-kfir] .top { align-items: start; }
}

@media (max-width: 700px) and (orientation: portrait),
       (max-width: 1024px) and (max-height: 520px) and (orientation: landscape) {
  :root[data-kfir] .kfir-shell {
    height: 100dvh;
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: clamp(112px, 24dvh, 230px) minmax(0, 1fr);
    align-items: stretch;
    gap: 6px;
    padding: max(6px, env(safe-area-inset-top)) max(6px, env(safe-area-inset-right))
      max(6px, env(safe-area-inset-bottom)) max(6px, env(safe-area-inset-left));
  }
  :root[data-kfir] .play { grid-row: 2; max-width: none; height: 100%; min-height: 0; }
  .kfir-scene-panel {
    grid-row: 1;
    position: relative;
    top: auto;
    display: grid;
    grid-template-rows: minmax(0, 1fr);
    width: 100%;
    min-height: 0;
    border-radius: 12px;
  }
  .kfir-scene-panel header { inset: 3px 3px auto auto; }
  .kfir-scene-panel header button { min-height: 44px; padding: 0 6px; font-size: .72rem; }
  .kfir-scene-panel canvas { height: 100%; min-height: 0; }
  .kfir-scene-panel footer {
    position: absolute;
    inset: auto 3px 3px;
    pointer-events: none;
  }
  #kfir-scene-status {
    width: fit-content;
    min-height: 0;
    padding: 2px 5px;
    border-radius: 4px;
    background: #131724d9;
    font-size: .65rem;
  }
  #kfir-camera-help {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip-path: inset(50%);
  }
}

@media (max-width: 1024px) and (max-height: 520px) and (orientation: landscape) {
  :root[data-kfir] .kfir-shell {
    grid-template-rows: clamp(72px, 20dvh, 108px) minmax(0, 1fr);
  }
}

#kfir-invite-result { margin-block: 9px; }
#kfir-create-invite, #kfir-copy-invite { min-height: 44px; }
