.home-scenes { margin-bottom: 24px; min-width: 0; }
.scene-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 6px; }
.scene-heading h3 { font-size: 14px; margin: 0; font-weight: 600; color: var(--muted); }
.home-devices-heading { margin: 0 0 16px; font-size: 14px; font-weight: 600; color: var(--muted); }
.scene-heading .text-button { width: 44px; min-height: 44px; flex-shrink: 0; display: grid; place-items: center; }
/* Keep WebKit's native overlay indicator below the visible strip as a fallback. */
.scene-strip-viewport { min-width: 0; overflow: hidden; }
.scene-strip { display: flex; gap: 10px; overflow-x: auto; padding: 4px 3px 30px; margin-bottom: -20px; scroll-padding: 3px; scrollbar-width: none; }
.scene-strip::-webkit-scrollbar { display: none; width: 0; height: 0; background: transparent; }
.scene-strip::-webkit-scrollbar-thumb, .scene-strip::-webkit-scrollbar-track { background: transparent; }
.scene-chip { display: inline-flex; align-items: center; gap: 10px; min-height: 54px; flex: 0 0 auto; max-width: 240px; padding: 12px 18px; background: var(--surface); color: var(--ink); border: 1px solid var(--border); border-radius: 18px; font-size: 14px; font-weight: 500; white-space: normal; text-align: start; overflow-wrap: anywhere; box-shadow: none; }
.scene-chip svg, .scene-icon-choice svg, .scene-manage-row svg { width: 22px; height: 22px; flex-shrink: 0; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.scene-chip svg { color: var(--primary); }
.scene-chip:hover:not(:disabled), .scene-chip.is-pressing:not(:disabled), .scene-chip:active:not(:disabled) { background: var(--surface-soft); border-color: var(--active-border); filter: none; box-shadow: none; }
.scene-chip:active:not(:disabled), .scene-chip.is-pressing:not(:disabled) { transform: scale(.975); }
.scene-chip.scene-add { background: transparent; color: var(--muted); border-style: dashed; }
.scene-chip[aria-busy="true"] { color: var(--primary); background: var(--primary-soft); }
.scene-feedback { margin: 0; color: var(--muted); font-size: 13px; line-height: 1.6; white-space: pre-line; }
.scene-feedback:not(:empty) { margin-top: 8px; }
.scene-feedback.is-error { color: var(--danger); }
#automationSceneHint { color: var(--muted); font-size: 13px; line-height: 1.5; font-weight: 400; }
.automation-scene-choices { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; max-height: 240px; overflow-y: auto; padding: 3px; }
.automation-scene-choice { display: flex; align-items: center; gap: 8px; min-height: 48px; padding: 10px 12px; border: 1px solid var(--border); border-radius: 13px; background: var(--surface); color: var(--ink); text-align: start; font-size: 13px; font-weight: 500; overflow-wrap: anywhere; }
.automation-scene-choice svg { width: 20px; height: 20px; flex-shrink: 0; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; color: var(--primary-strong); }
.automation-scene-choice[aria-pressed="true"] { background: var(--primary-soft); color: var(--primary-strong); border-color: var(--active-border); }
.sheet-overlay > .scene-sheet { display: flex; flex-direction: column; overflow: hidden; }
.scene-sheet .detail-sheet-head { margin-bottom: 20px; padding: 0; }
.scene-sheet .detail-sheet-head { flex-shrink: 0; }
#sceneModalBody { min-height: 0; overflow-y: auto; overscroll-behavior: contain; padding: 3px; }
.scene-sheet .detail-sheet-head h2 { font-size: 22px; margin: 0; }
.scene-sheet .detail-sheet-head .icon-button { flex-shrink: 0; }
.scene-sheet[data-saving="true"] > .detail-sheet-head, .scene-sheet[data-saving="true"] > .detail-sheet-grab { pointer-events: none; }
.scene-sheet form { display: grid; gap: 16px; }
.scene-sheet #sceneFormFeedback:empty { display: none; }
.scene-sheet form .confirm-actions { margin-top: 0; }
.scene-sheet fieldset { min-width: 0; border: 0; padding: 0; margin: 0; }
.scene-sheet legend { font-size: 14px; font-weight: 600; margin-bottom: 10px; }
.scene-icons { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }
.scene-icon-choice { height: 48px; display: grid; place-items: center; border: 1px solid var(--border); border-radius: 14px; color: var(--muted); background: var(--surface-soft); }
.scene-icon-choice[aria-pressed="true"] { border-color: var(--primary); color: var(--primary); background: var(--primary-soft); }
.scene-action-list { display: grid; gap: 10px; }
.scene-action-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; min-height: 48px; }
.scene-action-row > span { font-size: 14px; min-width: 0; overflow-wrap: anywhere; }
.scene-action-row select { width: 126px; min-height: 44px; flex-shrink: 0; }
.scene-step-module { display: grid; grid-template-columns: 24px minmax(0, 1fr); gap: 8px 10px; padding: 12px; border: 1px solid var(--border); border-radius: 16px; background: var(--surface-soft); }
.scene-step-number { align-self: center; font-size: 13px; color: var(--muted); text-align: center; }
.scene-step-fields { display: flex; align-items: center; gap: 8px; min-width: 0; }
.scene-step-fields select { width: 0; flex: 1; min-width: 0; min-height: 44px; }
.scene-step-fields label { display: flex; align-items: center; justify-content: space-between; gap: 12px; width: 100%; margin: 0; font-size: 13px; }
.scene-step-fields input { width: 96px; min-height: 44px; }
.scene-step-controls { grid-column: 2; display: flex; gap: 4px; justify-content: flex-end; }
.scene-step-controls svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.scene-step-adders { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.scene-step-adders button { min-height: 44px; padding: 8px 12px; background: var(--primary-soft); color: var(--primary-strong); border: 1px solid var(--active-border); font-size: 13px; }
.scene-templates, .scene-manager-list { display: grid; gap: 8px; }
.scene-templates { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.scene-templates button { padding: 10px 6px; font-size: 13px; min-height: 44px; }
.scene-manage-row { display: flex; align-items: center; gap: 12px; text-align: start; padding: 14px; width: 100%; min-height: 54px; border: 1px solid var(--border); color: var(--ink); background: var(--surface-soft); border-radius: 16px; }
.scene-manage-row span { min-width: 0; flex: 1; overflow-wrap: anywhere; }
.scene-manage-row > svg:last-child { width: 16px; color: var(--muted); }
.scene-sheet .confirm-actions { margin-top: 20px; }
.scene-sheet .scene-delete { background: var(--danger-soft); color: var(--danger); }
.scene-run-results { list-style: none; padding: 0; margin: 16px 0 0; display: grid; gap: 12px; }
.scene-run-results li { display: flex; justify-content: space-between; gap: 18px; font-size: 14px; line-height: 1.5; }
.scene-run-results li span { color: var(--muted); text-align: end; overflow-wrap: anywhere; }
.scene-run-results li[data-state="error"] span { color: var(--danger); }
.scene-last-result summary { display: flex; align-items: center; justify-content: space-between; min-height: 44px; padding: 8px 0; list-style: none; cursor: pointer; color: var(--muted); font-size: 14px; font-weight: 500; }
.scene-last-result summary::-webkit-details-marker { display: none; }
.scene-last-result summary::after { content: ''; width: 6px; height: 6px; border: solid currentColor; border-width: 1.5px 1.5px 0 0; transform: rotate(45deg); transition: transform var(--motion-fast) var(--ease-out); margin-right: 4px; }
.scene-last-result[open] summary::after { transform: rotate(135deg); }
.scene-last-result .scene-run-results { margin: 8px 0 4px; }
.scene-last-result .scene-run-results strong { font-weight: 500; }
@media (max-width: 767px) {
  #sceneModal[data-scene-sheet="true"] { align-items: end; padding: 0; }
  #sceneModal > .scene-sheet.adaptive-sheet { padding: 0; border: 0; border-radius: 24px 24px 0 0; }
  #sceneModal[data-scene-sheet="true"] .detail-sheet-head { padding: 4px 20px 20px; margin: 0; gap: 10px; }
  #sceneModal[data-scene-sheet="true"] #sceneModalBody { padding: 3px 20px max(24px, env(safe-area-inset-bottom)); }
  #sceneModal[data-scene-sheet="false"] .detail-sheet-grab { display: none; }
}
@media (prefers-reduced-motion: reduce) { .scene-chip, .scene-icon-choice { transition: none; transform: none !important; } }
