:root {
  --bg: #eceef1;
  --bg-elevated: #ffffff;
  --border: #c9ced6;
  --border-subtle: #e2e5ea;
  --text: #14161a;
  --text-muted: #5a616d;
  --accent: #1a4f8a;
  --accent-soft: rgba(26, 79, 138, 0.08);
  --role-in: #1a4f8a;
  --role-in-soft: rgba(26, 79, 138, 0.1);
  --role-mid: #4a3f7a;
  --role-mid-soft: rgba(74, 63, 122, 0.1);
  --role-out: #8a4a12;
  --role-out-soft: rgba(138, 74, 18, 0.1);
  --live: #1d6b45;
  --live-soft: rgba(29, 107, 69, 0.12);
  --fab: #1a4f8a;
  --fab-hover: #164070;
  --warn: #8a5a00;
  --radius: 6px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

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

html {
  color-scheme: light;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.45;
  display: flex;
  flex-direction: column;
}

a {
  color: var(--accent);
}

header.app-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem 1rem;
  padding: 0.5rem 1.25rem;
  border-bottom: 1px solid var(--border);
  background: var(--bg-elevated);
  position: sticky;
  top: 0;
  z-index: 40;
}

.app-title {
  margin: 0;
  font-size: 1.1rem;
  font-weight: 600;
  letter-spacing: -0.02em;
}

.header-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
}

main.work-shell {
  flex: 1;
  display: grid;
  grid-template-columns: min(292px, 34vw) 1fr;
  gap: 0;
  min-height: 0;
}

@media (max-width: 800px) {
  main.work-shell {
    grid-template-columns: 1fr;
  }
}

.palette {
  border-right: 1px solid var(--border);
  padding: 1.15rem 1rem 1.5rem;
  background: var(--bg-elevated);
  overflow-y: auto;
}

@media (max-width: 800px) {
  .palette {
    border-right: none;
    border-bottom: 1px solid var(--border);
  }
}

.palette-title {
  margin: 0 0 0.35rem;
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
}

.palette-lede {
  margin: 0 0 1.15rem;
  font-size: 0.8rem;
  color: var(--text-muted);
}

.palette-group {
  margin-bottom: 1rem;
}

.palette-group-title {
  margin: 0 0 0.4rem;
  font-size: 0.68rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.palette-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

button.part {
  font-family: inherit;
  font-size: 0.72rem;
  cursor: pointer;
  border-radius: 4px;
  padding: 0.32rem 0.5rem;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}

button.part:hover {
  border-color: var(--accent);
  background: var(--accent-soft);
}

button.part .pi {
  font-size: 0.62rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-muted);
  min-width: 1.75rem;
}

.examples {
  margin-top: 1.35rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border-subtle);
}

.examples h3 {
  margin: 0 0 0.25rem;
  font-size: 0.68rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
}

.examples-hint {
  margin: 0 0 0.45rem;
  font-size: 0.74rem;
  color: var(--text-muted);
}

.chip-save {
  width: 100%;
  margin-bottom: 0.5rem;
  text-align: left;
}

.examples-list {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}

.examples-empty-block {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}

.examples-empty {
  margin: 0;
  padding: 0.15rem 0.1rem 0;
  font-size: 0.72rem;
  color: var(--text-muted);
}

.chip-restore {
  width: 100%;
  text-align: left;
}

.examples-item {
  display: flex;
  align-items: stretch;
  gap: 0.28rem;
}

.examples-item-load {
  flex: 1;
  min-width: 0;
  text-align: left;
}

.examples-item-fav,
.examples-item-del {
  font-family: inherit;
  font-size: 0.85rem;
  line-height: 1;
  flex-shrink: 0;
  width: 2rem;
  padding: 0;
  cursor: pointer;
  border-radius: 4px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text-muted);
}

.examples-item-fav:hover,
.examples-item-del:hover {
  border-color: var(--accent);
  color: var(--text);
  background: var(--accent-soft);
}

.examples-item-fav.is-favorite {
  color: #8a6500;
  background: linear-gradient(180deg, #fffbeb, #fff6d6);
  border: 2px solid #d4a012;
  box-shadow: 0 0 0 1px rgba(212, 160, 18, 0.22);
}

.examples-item-fav.is-favorite:hover {
  color: #6b4f00;
  background: linear-gradient(180deg, #fff8e4, #ffefbf);
  border-color: #b8870c;
}

.examples-item-del {
  font-size: 1rem;
  font-weight: 600;
}

button.chip {
  font-family: inherit;
  font-size: 0.76rem;
  text-align: left;
  cursor: pointer;
  border-radius: 4px;
  padding: 0.42rem 0.55rem;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
}

button.chip:hover {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.workbench {
  padding: 1.15rem 1.25rem 5.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  min-height: 0;
}

.workbench-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.5rem;
}

.workbench-head h2 {
  margin: 0;
  font-size: 0.78rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
}

.workbench-meta {
  font-size: 0.76rem;
  color: var(--text-muted);
}

.editor-section {
  margin-bottom: 0.5rem;
}

.editor-section-details {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-elevated);
  overflow: hidden;
}

.editor-section-summary {
  list-style: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.42rem 0.65rem;
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.03em;
  color: var(--text);
  background: linear-gradient(180deg, #fafbfc, var(--bg-elevated));
  border-bottom: 1px solid var(--border-subtle);
}

.editor-section-summary::-webkit-details-marker {
  display: none;
}

.editor-section-title {
  text-transform: uppercase;
  font-size: 0.68rem;
  letter-spacing: 0.06em;
  color: var(--text-muted);
}

.editor-section-badge {
  font-size: 0.68rem;
  font-weight: 800;
  padding: 0.12rem 0.45rem;
  border-radius: 999px;
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text-muted);
}

.editor-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.55rem;
  padding: 0.55rem 0.65rem 0.65rem;
}

@media (max-width: 1100px) {
  .editor-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 680px) {
  .editor-grid {
    grid-template-columns: 1fr;
  }
}

.editor-grid-empty {
  margin: 0;
  grid-column: 1 / -1;
  font-size: 0.78rem;
  color: var(--text-muted);
  padding: 0.25rem 0;
}

.module-card {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.45rem 0.5rem;
  background: #fafbfc;
  border-left-width: 3px;
  min-width: 0;
}

.module-card.role-input {
  border-left-color: var(--role-in);
}

.module-card.role-process {
  border-left-color: var(--role-mid);
}

.module-card.role-output {
  border-left-color: var(--role-out);
}

.module-card.live {
  border-color: #8ab89a;
  box-shadow: 0 0 0 1px var(--live-soft);
}

.module-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.35rem;
  margin-bottom: 0.35rem;
}

.module-card-code {
  font-size: 0.55rem;
  font-weight: 800;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--text-muted);
  flex-shrink: 0;
}

.module-card-title {
  font-size: 0.74rem;
  font-weight: 600;
  flex: 1;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.module-card-remove {
  flex-shrink: 0;
  border: none;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  padding: 0.1rem 0.35rem;
  border-radius: 3px;
  font-size: 1rem;
  line-height: 1;
}

.module-card-remove:hover {
  color: #9a1c1c;
  background: rgba(154, 28, 28, 0.08);
}

.module-card-fallback {
  margin: 0;
  font-size: 0.72rem;
  color: var(--text-muted);
}

.field-hint {
  margin: 0;
  font-size: 0.65rem;
  line-height: 1.35;
  color: var(--text-muted);
  font-style: italic;
}

.field-compact-checkbox {
  margin-top: 0.1rem;
}

.field label.field-checkbox {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  width: auto;
  font-size: 0.65rem;
  font-weight: 500;
  line-height: 1.25;
  color: var(--text-muted);
  cursor: pointer;
  margin: 0;
}

.field label.field-checkbox input[type="checkbox"] {
  margin: 0;
  width: 0.85rem;
  height: 0.85rem;
  min-width: 0.85rem;
  padding: 0;
  border: none;
  background: transparent;
  flex-shrink: 0;
  accent-color: var(--accent);
}

.field-checkbox span {
  flex: 1;
}

.dropzone {
  border: 1px dashed var(--border);
  border-radius: 4px;
  padding: 0.55rem 0.5rem;
  background: #f8f9fb;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
  position: relative;
}

.dropzone:hover:not(.is-disabled) {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.dropzone.is-dragover {
  border-color: var(--accent);
  background: rgba(26, 79, 138, 0.12);
}

.dropzone.is-disabled {
  opacity: 0.45;
  cursor: not-allowed;
  pointer-events: none;
}

.dropzone-label {
  font-size: 0.74rem;
  font-weight: 600;
  color: var(--text);
}

.dropzone-sub {
  margin-top: 0.25rem;
  font-size: 0.65rem;
  color: var(--text-muted);
}

.dropzone-input {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
  width: 100%;
  height: 100%;
}

.camera-preview {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.camera-preview-video {
  width: 100%;
  max-height: 140px;
  border-radius: 4px;
  background: #0d1117;
  object-fit: cover;
}

.camera-preview-snap {
  width: 100%;
  max-height: 120px;
  border-radius: 4px;
  object-fit: contain;
  background: #f0f2f5;
  border: 1px solid var(--border-subtle);
}

.camera-preview-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

.camera-preview-btn {
  font-family: inherit;
  font-size: 0.68rem;
  font-weight: 600;
  padding: 0.28rem 0.55rem;
  border-radius: 4px;
  border: 1px solid var(--border);
  background: var(--bg-elevated);
  color: var(--text);
  cursor: pointer;
}

.camera-preview-btn:hover:not(:disabled) {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.camera-preview-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.camera-preview-secondary {
  font-weight: 500;
  color: var(--text-muted);
}

.module-card-fields {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}

.field.field-compact label:not(.field-checkbox) {
  font-size: 0.65rem;
  margin-bottom: 0.18rem;
}

.field.field-compact input:not([type="checkbox"]),
.field.field-compact textarea,
.field.field-compact select {
  font-size: 0.76rem;
  padding: 0.32rem 0.4rem;
}

.field.field-compact textarea {
  min-height: 2.5rem;
  line-height: 1.4;
}

.field-run-preview textarea.run-preview-inline {
  background: #f4f6f8;
  color: var(--text);
  font-family: ui-monospace, "Cascadia Code", Menlo, Consolas, monospace;
  font-size: 0.7rem;
  resize: vertical;
  min-height: 3.5rem;
}

.workbench-surface.module-editor-surface {
  flex: 1;
  min-height: 320px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: #fafbfc;
  padding: 0.75rem 0.85rem;
}

.module-editor {
  max-width: none;
}

.module-editor-empty {
  padding: 1rem 0.25rem;
}

.module-editor-empty p {
  margin: 0 0 0.35rem;
  font-size: 0.9rem;
}

.module-editor-empty .hint {
  margin: 0;
  font-size: 0.8rem;
  color: var(--text-muted);
}

.field label:not(.field-checkbox) {
  display: block;
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 0.28rem;
}

.field input:not([type="checkbox"]),
.field textarea,
.field select {
  width: 100%;
  font-family: inherit;
  font-size: 0.82rem;
  padding: 0.45rem 0.55rem;
  border-radius: 4px;
  border: 1px solid var(--border);
  background: var(--bg-elevated);
  color: var(--text);
}

.field textarea {
  resize: vertical;
  min-height: 2.25rem;
  line-height: 1.45;
}

.field input:not([type="checkbox"]):focus,
.field textarea:focus,
.field select:focus {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
  border-color: var(--accent);
}

.multi-hint {
  margin: 0;
  font-size: 0.74rem;
  color: var(--text-muted);
  display: none;
}

.multi-hint.visible {
  display: block;
}

button.ghost {
  font-family: inherit;
  font-size: 0.8rem;
  cursor: pointer;
  border-radius: 4px;
  padding: 0.42rem 0.8rem;
  border: 1px solid var(--border);
  background: var(--bg-elevated);
  color: var(--text);
}

button.ghost:hover {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.fab-run {
  position: fixed;
  bottom: calc(1.15rem + env(safe-area-inset-bottom, 0px));
  right: calc(1.15rem + env(safe-area-inset-right, 0px));
  z-index: 90;
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.65rem 1.15rem 0.65rem 0.95rem;
  border-radius: 999px;
  border: none;
  background: var(--fab);
  color: #fff;
  font-family: inherit;
  font-size: 0.88rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  cursor: pointer;
  box-shadow: 0 6px 24px rgba(26, 79, 138, 0.42), 0 2px 8px rgba(0, 0, 0, 0.12);
  transition: transform 0.15s ease, background 0.15s ease;
}

.fab-run:hover {
  background: var(--fab-hover);
  transform: translateY(-1px);
}

.fab-run:active {
  transform: translateY(0);
}

.fab-run:focus-visible {
  outline: 3px solid #fff;
  outline-offset: 3px;
}

.fab-run-icon {
  display: flex;
  line-height: 0;
  margin-left: -0.05rem;
}

.fab-run-icon svg {
  display: block;
}

.fab-run.is-running {
  background: #157a4d;
  box-shadow: 0 6px 24px rgba(21, 122, 77, 0.45), 0 2px 8px rgba(0, 0, 0, 0.12);
}

.fab-run.is-running:hover {
  background: #126841;
}

.fab-run-icon-busy .fab-rotor-blades {
  transform-origin: 12px 12px;
  animation: fab-rotor-turn 0.95s linear infinite;
}

@media (prefers-reduced-motion: reduce) {
  .fab-run-icon-busy .fab-rotor-blades {
    animation: none;
  }
}

@keyframes fab-rotor-turn {
  to {
    transform: rotate(360deg);
  }
}

button.part.part-active {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent);
  box-shadow: inset 0 0 0 1px rgba(26, 79, 138, 0.12);
}

button.part.part-active .pi {
  color: var(--accent);
}

.palette-locked button.part,
.palette-locked button.chip {
  pointer-events: none;
  opacity: 0.5;
}

.palette-locked .examples-item-fav,
.palette-locked .examples-item-del {
  pointer-events: none;
  opacity: 0.5;
}

.palette-locked .palette-lede {
  color: var(--accent);
  font-weight: 600;
}

.module-card-remove:disabled,
.module-card-remove.is-disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

button.ghost:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

body.pipeline-running .workbench-surface.module-editor-surface {
  box-shadow: inset 0 0 0 1px rgba(154, 68, 18, 0.25);
}

footer.status-bar {
  padding: 0.55rem 1.25rem;
  padding-right: min(11rem, 26vw);
  border-top: 1px solid var(--border);
  color: var(--text-muted);
  font-size: 0.76rem;
  background: var(--bg-elevated);
}

.toast {
  position: fixed;
  bottom: calc(5rem + env(safe-area-inset-bottom, 0px));
  right: calc(1.25rem + env(safe-area-inset-right, 0px));
  padding: 0.65rem 0.95rem;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.12);
  font-size: 0.82rem;
  opacity: 0;
  transform: translateY(8px);
  pointer-events: none;
  transition: opacity 0.2s, transform 0.2s;
  z-index: 95;
  max-width: min(360px, calc(100vw - 2rem));
}

.toast.visible {
  opacity: 1;
  transform: translateY(0);
}

.field-segmented {
  display: flex;
  gap: 0;
  border-radius: 5px;
  border: 1px solid var(--border);
  overflow: hidden;
  background: var(--bg);
}

.segmented-opt {
  flex: 1;
  font-family: inherit;
  font-size: 0.72rem;
  font-weight: 600;
  padding: 0.38rem 0.5rem;
  border: none;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  border-right: 1px solid var(--border-subtle);
}

.segmented-opt:last-child {
  border-right: none;
}

.segmented-opt:hover:not(:disabled) {
  background: var(--accent-soft);
  color: var(--text);
}

.segmented-opt.is-active {
  background: var(--accent-soft);
  color: var(--accent);
}

.segmented-opt:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.media-device-row {
  display: flex;
  gap: 0.4rem;
  align-items: stretch;
}

.media-device-row select {
  flex: 1;
  min-width: 0;
}

.media-device-refresh {
  flex-shrink: 0;
  font-family: inherit;
  font-size: 0.65rem;
  padding: 0.32rem 0.45rem;
  border-radius: 4px;
  border: 1px solid var(--border);
  background: var(--bg-elevated);
  cursor: pointer;
}

.media-device-refresh:hover:not(:disabled) {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.media-device-refresh:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.audio-recorder-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin-bottom: 0.35rem;
}

.audio-recorder-btn {
  font-family: inherit;
  font-size: 0.68rem;
  font-weight: 600;
  padding: 0.3rem 0.55rem;
  border-radius: 4px;
  border: 1px solid var(--border);
  background: var(--bg-elevated);
  cursor: pointer;
}

.audio-recorder-btn:hover:not(:disabled) {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.audio-recorder-secondary {
  font-weight: 500;
  color: var(--text-muted);
}

.audio-recorder-status {
  font-size: 0.65rem;
  color: var(--text-muted);
  line-height: 1.35;
}

.audio-recorder-preview-audio {
  display: block;
  width: 0;
  height: 0;
  margin: 0;
  padding: 0;
  overflow: hidden;
  opacity: 0;
  pointer-events: none;
}

.ptt-live-bar {
  margin-top: 0.35rem;
  padding-top: 0.45rem;
  border-top: 1px dashed var(--border-subtle);
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.ptt-live-title {
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
}

.ptt-live-hint {
  margin: 0;
}

.ptt-live-btn {
  font-family: inherit;
  font-size: 0.78rem;
  font-weight: 700;
  padding: 0.5rem 0.75rem;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--bg-elevated);
  color: var(--text);
  cursor: pointer;
  align-self: flex-start;
  min-width: 11.5rem;
  display: inline-flex;
  align-items: center;
  justify-content: flex-start;
  gap: 0.5rem;
  transition:
    background 0.12s ease,
    border-color 0.12s ease,
    box-shadow 0.12s ease,
    color 0.12s ease;
}

.ptt-live-btn-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  color: var(--text-muted);
}

.ptt-live-btn-icon svg {
  display: block;
}

.ptt-live-btn-label {
  text-align: left;
  line-height: 1.2;
}

.ptt-live-btn:hover:not(:disabled):not(.is-transmitting) {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent);
}

.ptt-live-btn:hover:not(:disabled):not(.is-transmitting) .ptt-live-btn-icon {
  color: var(--accent);
}

.ptt-live-btn:disabled {
  opacity: 0.48;
  cursor: not-allowed;
}

.ptt-live-btn.is-transmitting {
  border: 2px solid #16a34a;
  background: linear-gradient(180deg, rgba(22, 163, 74, 0.26) 0%, rgba(22, 163, 74, 0.09) 100%);
  color: #14532d;
  box-shadow:
    0 0 0 1px rgba(22, 163, 74, 0.35),
    0 4px 16px rgba(22, 163, 74, 0.22);
  animation: ptt-live-pulse 1.2s ease-in-out infinite;
}

.ptt-live-btn.is-transmitting .ptt-live-btn-icon {
  color: #15803d;
}

.ptt-live-btn.is-transmitting:hover:not(:disabled) {
  border-color: #15803d;
  color: #052e16;
  background: linear-gradient(180deg, rgba(22, 163, 74, 0.32) 0%, rgba(22, 163, 74, 0.12) 100%);
}

@keyframes ptt-live-pulse {
  0%,
  100% {
    box-shadow:
      0 0 0 1px rgba(22, 163, 74, 0.3),
      0 4px 14px rgba(22, 163, 74, 0.18);
  }
  50% {
    box-shadow:
      0 0 0 1px rgba(22, 163, 74, 0.5),
      0 0 0 6px rgba(22, 163, 74, 0.1),
      0 6px 22px rgba(22, 163, 74, 0.3);
  }
}

@media (prefers-reduced-motion: reduce) {
  .ptt-live-btn.is-transmitting {
    animation: none;
  }
}

.input-section-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.65rem;
  padding: 0.5rem 0.65rem 0.65rem;
  border-top: 1px solid var(--border-subtle);
  background: #f6f8fb;
}

.input-send-btn {
  font-family: inherit;
  font-size: 0.78rem;
  font-weight: 600;
  padding: 0.42rem 0.9rem;
  border-radius: 4px;
  border: 1px solid var(--role-in);
  background: var(--role-in-soft);
  color: var(--role-in);
  cursor: pointer;
}

.input-send-btn:hover:not(:disabled) {
  background: rgba(26, 79, 138, 0.16);
}

.input-send-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.input-section-actions-hint {
  margin: 0;
  font-size: 0.7rem;
  color: var(--text-muted);
  flex: 1;
  min-width: 12rem;
}

.output-text-chat {
  width: 100%;
  margin: 0 0 0.5rem;
  box-sizing: border-box;
}

.output-text-chat-toolbar {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  margin-bottom: 0.35rem;
}

.output-text-chat-toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.68rem;
  color: var(--text-muted);
  cursor: pointer;
  user-select: none;
}

.output-text-chat-toggle input {
  margin: 0;
  cursor: pointer;
}

.output-text-chat-stream {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  width: 100%;
  min-height: 6.5rem;
  max-height: 18rem;
  overflow-y: auto;
  padding: 0.45rem 0.35rem;
  border-radius: var(--radius);
  border: 1px solid var(--border-subtle);
  background: linear-gradient(180deg, #f6f8fb 0%, #eef1f6 100%);
  box-sizing: border-box;
}

.output-text-chat-empty {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 1rem 0.75rem;
  font-size: 0.74rem;
  color: var(--text-muted);
  line-height: 1.45;
}

.output-text-msg {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  max-width: min(92%, 28rem);
}

.output-text-msg-meta {
  font-size: 0.6rem;
  font-weight: 600;
  color: var(--text-muted);
  letter-spacing: 0.02em;
  padding: 0 0.15rem;
}

.output-text-msg-bubble {
  padding: 0.42rem 0.55rem;
  border-radius: 12px;
  font-size: 0.76rem;
  line-height: 1.45;
  white-space: pre-wrap;
  word-break: break-word;
  border: 1px solid var(--border-subtle);
  box-shadow: 0 1px 0 rgba(15, 23, 42, 0.04);
}

.output-text-msg--assistant {
  align-self: flex-start;
}

.output-text-msg--assistant .output-text-msg-meta {
  text-align: left;
}

.output-text-msg--assistant .output-text-msg-bubble {
  background: #fff;
  border-bottom-left-radius: 4px;
  border-color: rgba(26, 79, 138, 0.22);
  border-left: 3px solid var(--accent, #1a4f8a);
}

.output-text-msg--user {
  align-self: flex-end;
}

.output-text-msg--user .output-text-msg-meta {
  text-align: right;
}

.output-text-msg--user .output-text-msg-bubble {
  background: #e8f4ea;
  border-bottom-right-radius: 4px;
  border-color: rgba(22, 101, 52, 0.28);
  border-right: 3px solid #166534;
}

.output-text-msg--system {
  align-self: stretch;
  max-width: 100%;
}

.output-text-msg--system .output-text-msg-meta {
  text-align: left;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-size: 0.55rem;
}

.output-text-msg--system .output-text-msg-bubble {
  background: rgba(248, 250, 252, 0.95);
  border-radius: 6px;
  font-size: 0.68rem;
  color: var(--text-muted);
  border-style: dashed;
  max-height: 10rem;
  overflow-y: auto;
}

.output-text-settings {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.45rem;
}

@media (max-width: 900px) {
  .output-text-settings {
    grid-template-columns: 1fr;
  }
}

.output-image-stage {
  margin: 0.45rem 0 0;
  padding: 0.45rem;
  border-radius: var(--radius);
  border: 1px dashed var(--border);
  background: linear-gradient(180deg, #f8fafc, #eef1f6);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.4rem;
}

.output-image-progress {
  width: 100%;
  max-width: min(280px, 100%);
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.output-image-progress-label {
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--text);
  text-align: center;
}

.output-image-progress-track {
  height: 8px;
  border-radius: 999px;
  background: rgba(15, 23, 42, 0.12);
  overflow: hidden;
  width: 100%;
}

.output-image-progress-fill {
  height: 100%;
  width: 0%;
  border-radius: 999px;
  background: linear-gradient(90deg, #6366f1, #8b5cf6);
  transition: width 0.18s ease-out;
}

.output-image-progress-hint {
  font-size: 0.62rem;
  color: var(--text-muted);
  text-align: center;
  line-height: 1.25;
}

.output-image-placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  background: repeating-linear-gradient(
    -45deg,
    #e8ebf1,
    #e8ebf1 10px,
    #f0f2f8 10px,
    #f0f2f8 20px
  );
  border: 1px solid var(--border);
  border-radius: 4px;
  box-sizing: border-box;
  position: relative;
}

.output-image-placeholder-cap {
  font-size: 0.74rem;
  font-weight: 600;
  color: var(--text-muted);
}

.output-image-placeholder-sub {
  font-size: 0.65rem;
  color: var(--text-muted);
}

.output-image-result-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.35rem;
  width: 100%;
}

.output-image-result-wrap.is-regenerating {
  opacity: 0.45;
  filter: grayscale(0.15);
}

.output-image-stage .output-image-progress {
  width: 100%;
  max-width: min(280px, 100%);
  margin-bottom: 0.35rem;
}

.output-image-result {
  max-width: 100%;
  width: auto;
  max-height: 320px;
  height: auto;
  object-fit: contain;
  border-radius: 4px;
  border: 1px solid var(--border);
  background: #fff;
}

.output-image-result-caption {
  font-size: 0.62rem;
  color: var(--text-muted);
  text-align: center;
}

.output-audio-stage {
  margin-top: 0.5rem;
  padding: 0.5rem 0;
}

.output-audio-player {
  width: 100%;
  max-width: 420px;
}

.output-audio-placeholder,
.output-audio-generating {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin: 0.25rem 0 0;
}

.output-audio-caption {
  font-size: 0.62rem;
  color: var(--text-muted);
  margin-top: 0.35rem;
}

@media (max-width: 520px) {
  .output-text-msg {
    max-width: 96%;
  }
}

.fab-run .fab-run-icon-play[hidden],
.fab-run .fab-run-icon-busy[hidden] {
  display: none !important;
}

/* ── Form composer (input/output) ── */

.composer-form-module {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  margin-top: 0.2rem;
}

.composer-form-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  align-items: center;
}

.composer-form-toolbar-type,
.composer-form-toolbar-label,
.composer-form-toolbar-options {
  font: inherit;
  font-size: 0.74rem;
  padding: 0.28rem 0.42rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-elevated);
  min-height: 1.95rem;
}

.composer-form-toolbar-label {
  min-width: 10rem;
  flex: 1 1 8rem;
}

.composer-form-toolbar-options {
  min-width: 12rem;
  flex: 2 1 12rem;
}

.composer-form-add {
  font: inherit;
  font-size: 0.72rem;
  font-weight: 600;
  padding: 0.32rem 0.72rem;
  border-radius: var(--radius);
  border: 1px solid var(--accent);
  background: var(--accent-soft);
  color: var(--accent);
  cursor: pointer;
}

.composer-form-add:disabled {
  opacity: 0.45;
  cursor: default;
}

.composer-form-subtitle {
  font-size: 0.68rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  margin-top: 0.2rem;
}

.composer-form-rows {
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius);
  background: #fafbfd;
  max-height: 9rem;
  overflow-y: auto;
}

.composer-form-empty-row,
.composer-form-preview-empty {
  margin: 0;
  padding: 0.5rem 0.65rem;
  font-size: 0.72rem;
  color: var(--text-muted);
}

.composer-form-defined-row {
  display: grid;
  grid-template-columns: minmax(0, 10rem) 1fr auto;
  gap: 0.35rem 0.65rem;
  align-items: center;
  padding: 0.4rem 0.65rem;
  border-bottom: 1px solid var(--border-subtle);
  font-size: 0.72rem;
}

.composer-form-defined-row:last-child {
  border-bottom: none;
}

.composer-form-kind {
  font-size: 0.65rem;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.composer-form-def-label {
  word-break: break-word;
}

.composer-form-remove {
  border: none;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 0.9rem;
  line-height: 1;
  padding: 0.15rem;
  border-radius: 3px;
}

.composer-form-remove:hover:not(:disabled) {
  color: #922;
  background: rgba(153, 34, 34, 0.08);
}

.composer-form-preview-shell {
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  padding: 0.55rem;
  background: var(--bg-elevated);
}

.composer-form-live {
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 0.52rem;
}

.composer-form-field {
  display: flex;
  flex-direction: column;
  gap: 0.28rem;
}

.composer-form-field-label {
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--text-muted);
}

.composer-form-fs {
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius);
  padding: 0.4rem 0.55rem 0.65rem;
  margin: 0;
}

.composer-form-fs legend {
  font-size: 0.72rem;
  font-weight: 600;
  padding: 0 0.2rem;
}

.composer-form-radio-line,
.composer-form-check-line {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.74rem;
  cursor: pointer;
}

.composer-form-el {
  font: inherit;
  font-size: 0.75rem;
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 0.38rem;
  background: var(--bg-elevated);
}

.role-output .composer-form-submit,
.role-output .composer-form-btn {
  opacity: 0.75;
}

.composer-form-submit {
  align-self: flex-start;
  background: linear-gradient(180deg, #2a6099, var(--accent));
  color: #fff;
  border-color: var(--accent);
}

.composer-form-btn {
  align-self: flex-start;
}

/* ── Prompt-driven UI (NL stub + declarative v2 spec) ── */

.dynamic-ui-module {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  margin-top: 0.25rem;
}

.dynamic-ui-prompt-label {
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--text-muted);
}

.dynamic-ui-prompt-field {
  font: inherit;
  font-size: 0.75rem;
  width: 100%;
  resize: vertical;
  min-height: 4rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.45rem;
  background: var(--bg-elevated);
}

.dynamic-ui-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
}

.dynamic-ui-generate {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  font: inherit;
  font-size: 0.74rem;
  font-weight: 600;
  padding: 0.38rem 0.82rem;
  border-radius: var(--radius);
  border: 1px solid var(--role-mid);
  background: var(--role-mid-soft);
  color: var(--role-mid);
  cursor: pointer;
}

.dynamic-ui-generate:disabled {
  opacity: 0.45;
  cursor: default;
}

.dynamic-ui-generate-spinner {
  display: inline-flex;
  line-height: 0;
}

.dynamic-ui-generate-spinner[hidden] {
  display: none;
}

.dynamic-ui-generate-spinner-blades {
  transform-origin: 12px 12px;
  animation: dynamic-ui-gen-spin 0.95s linear infinite;
}

@media (prefers-reduced-motion: reduce) {
  .dynamic-ui-generate-spinner-blades {
    animation: none;
  }
}

@keyframes dynamic-ui-gen-spin {
  to {
    transform: rotate(360deg);
  }
}

.dynamic-ui-reload-preview {
  font: inherit;
  font-size: 0.74rem;
  padding: 0.38rem 0.82rem;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--bg-elevated);
  color: var(--text-muted);
  cursor: pointer;
}

.dynamic-ui-reload-preview:disabled {
  opacity: 0.45;
  cursor: default;
}

.dynamic-ui-stage {
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius);
  padding: 0.55rem 0.65rem;
  background: linear-gradient(180deg, #fafbfd, #f2f5f9);
}

.dynamic-ui-placeholder {
  font-size: 0.72rem;
  color: var(--text-muted);
  margin: 0.4rem 0;
}

.dynamic-ui-cap {
  font-size: 0.65rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  margin-bottom: 0.4rem;
}

.dynamic-ui-body {
  font-size: 0.74rem;
}

.dynamic-ui-schema-preview {
  margin: 0.35rem 0 0;
  padding: 0.45rem 0.55rem;
  font-size: 0.68rem;
  line-height: 1.35;
  border-radius: var(--radius);
  border: 1px solid var(--border-subtle);
  background: #f8fafc;
  color: var(--text-muted);
  overflow-x: auto;
  max-height: 10rem;
}

/* ── Dynamic UI: freeform HTML host ── */

.wdui-root .wdui-html-host {
  min-height: 0.5rem;
  line-height: 1.45;
}

.wdui-root .wdui-html-host img,
.wdui-root .wdui-html-host video {
  max-width: 100%;
  height: auto;
}

.wdui-handler-hint {
  margin-bottom: 0.35rem;
}

@media (max-width: 560px) {
  .fab-run {
    bottom: calc(0.85rem + env(safe-area-inset-bottom, 0px));
    right: calc(0.85rem + env(safe-area-inset-right, 0px));
    padding: 0.58rem 1rem;
    font-size: 0.82rem;
  }

  .toast {
    right: 0.85rem;
    bottom: calc(4.75rem + env(safe-area-inset-bottom, 0px));
  }

  footer.status-bar {
    padding-right: 1.25rem;
  }
}
