:root {
  color-scheme: dark;
  font-family: 'Inter', 'ui-sans-serif', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --bg: #0f1624;
  --panel: #111a2b;
  --panel2: #0c1422;
  --txt: #e6ecff;
  --muted: #9bb0d1;
  --accent: #7fb3ff;
  --rail: #4b5563;
  --thumb: #9ec5ff;
  --ok: #6ee7b7;
  --warn: #fbbf24;
  --rad: 16px;
  --pad: 16px;
  --gap: 12px;
  --shadow: 0 6px 24px rgba(0, 0, 0, 0.25);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: radial-gradient(circle at top left, rgba(17, 26, 43, 0.96), rgba(15, 22, 36, 0.98));
  color: var(--txt);
}

a {
  color: inherit;
}

button,
input,
select,
textarea {
  font: inherit;
  color: inherit;
}

main,
.app-shell {
  width: min(980px, 94vw);
  margin: 0 auto;
  padding: calc(var(--pad) * 2) 0 calc(var(--pad) * 3);
  display: flex;
  flex-direction: column;
  gap: calc(var(--pad) * 1.5);
}

.card,
.panel {
  background: var(--panel);
  border-radius: var(--rad);
  padding: 20px;
  box-shadow: var(--shadow);
  border: 1px solid rgba(126, 155, 206, 0.12);
  display: flex;
  flex-direction: column;
  gap: var(--gap);
}

.panel.header {
  background: var(--panel2);
  gap: calc(var(--gap) + 4px);
}

.section-title,
.panel > h2,
.panel > h1 {
  margin: 0;
  font-size: 17px;
  font-weight: 600;
  letter-spacing: 0.01em;
}

.panel > h1 {
  font-size: 22px;
  font-weight: 700;
}

.dynamics-info {
  margin: 0;
  font-size: 12px;
  color: var(--muted);
  line-height: 1.5;
}

.route-label {
  margin: 0;
  font-size: 12px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

.prompt-engine {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.prompt-panel {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.prompt-panel__label {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

.prompt-panel__controls {
  display: flex;
  flex-direction: row;
  gap: 10px;
  align-items: stretch;
  flex-wrap: wrap;
}

.prompt-panel__input {
  flex: 1;
  min-width: 0;
  height: 36px;
  border-radius: var(--rad);
  border: 1px solid rgba(126, 155, 206, 0.35);
  background: var(--panel2);
  padding: 0 16px;
  color: var(--txt);
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.prompt-panel__input:focus-visible {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(127, 179, 255, 0.35);
  outline: none;
}

.prompt-panel__button {
  height: 36px;
  padding: 0 20px;
  white-space: nowrap;
}

.prompt-panel__hint,
.prompt-panel__status {
  margin: 0;
  font-size: 12px;
  color: var(--muted);
}

.prompt-panel__status {
  color: var(--accent);
}

.device-header {
  display: flex;
  flex-direction: column;
  gap: calc(var(--gap) + 4px);
}

.device-header__buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.btn {
  height: 28px;
  padding: 0 16px;
  border-radius: 999px;
  border: 1px solid transparent;
  background: rgba(126, 179, 255, 0.18);
  color: var(--txt);
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.02em;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  cursor: pointer;
  transition: border-color 0.2s ease, background-color 0.2s ease, transform 0.2s ease, box-shadow 0.2s ease;
}

.btn:hover:not(:disabled),
.btn:focus-visible:not(:disabled) {
  border-color: rgba(126, 179, 255, 0.45);
  background: rgba(126, 179, 255, 0.28);
  box-shadow: 0 4px 18px rgba(126, 179, 255, 0.2);
  transform: translateY(-1px);
  outline: none;
}

.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  box-shadow: none;
}

.device-header__selectors {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: calc(var(--gap) + 4px);
}

.field,
.device-row {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.field-inline {
  flex-direction: row;
  align-items: center;
  justify-content: space-between;
}

.field__label,
.device-row__label,
.control-label {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

.field__value,
.control-value {
  margin-left: auto;
  font-size: 12px;
  font-weight: 500;
  color: var(--muted);
}

.field__header {
  display: flex;
  align-items: baseline;
  gap: 8px;
}

.field__control {
  width: 100%;
  display: block;
}

.select,
.device-row select,
.field select {
  height: 28px;
  border-radius: var(--rad);
  border: 1px solid rgba(126, 155, 206, 0.35);
  background: var(--panel2);
  padding: 0 12px;
  color: var(--txt);
  appearance: none;
  cursor: pointer;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.select:focus-visible,
.device-row select:focus-visible,
.field select:focus-visible {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(127, 179, 255, 0.35);
  outline: none;
}

.select:disabled,
.device-row select:disabled,
.field select:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.checkbox,
.device-row input[type='checkbox'],
.ir-source input[type='radio'] {
  appearance: none;
  width: 16px;
  height: 16px;
  border-radius: 4px;
  border: 1px solid rgba(126, 155, 206, 0.5);
  background: var(--panel2);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: border-color 0.2s ease, background-color 0.2s ease, transform 0.1s ease;
}

.checkbox:checked,
.device-row input[type='checkbox']:checked,
.ir-source input[type='radio']:checked {
  border-color: var(--accent);
  background: var(--accent);
  box-shadow: 0 0 0 3px rgba(127, 179, 255, 0.25);
}

.device-row input[type='checkbox']:checked::after,
.checkbox:checked::after {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: 2px;
  background: var(--panel2);
}

.ir-source input[type='radio'] {
  border-radius: 999px;
}

.ir-source input[type='radio']:checked::after {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: 999px;
  background: var(--panel2);
}

.slider,
.control-block input[type='range'] {
  width: 100%;
  -webkit-appearance: none;
  appearance: none;
  height: 4px;
  border-radius: 999px;
  background: var(--rail);
  outline: none;
  accent-color: var(--accent);
  box-shadow: inset 0 0 0 1px rgba(20, 28, 44, 0.4);
}

.slider:focus-visible,
.control-block input[type='range']:focus-visible {
  box-shadow: 0 0 0 4px rgba(127, 179, 255, 0.2), inset 0 0 0 1px rgba(20, 28, 44, 0.4);
}

.slider::-webkit-slider-thumb,
.control-block input[type='range']::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--thumb);
  box-shadow: 0 0 0 2px rgba(15, 22, 36, 0.8);
  transition: transform 0.15s ease;
}

.slider::-moz-range-thumb,
.control-block input[type='range']::-moz-range-thumb {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  border: none;
  background: var(--thumb);
  box-shadow: 0 0 0 2px rgba(15, 22, 36, 0.8);
  transition: transform 0.15s ease;
}

.slider:hover::-webkit-slider-thumb,
.control-block input[type='range']:hover::-webkit-slider-thumb,
.slider:focus-visible::-webkit-slider-thumb,
.control-block input[type='range']:focus-visible::-webkit-slider-thumb {
  transform: scale(1.05);
}

.slider:hover::-moz-range-thumb,
.control-block input[type='range']:hover::-moz-range-thumb,
.slider:focus-visible::-moz-range-thumb,
.control-block input[type='range']:focus-visible::-moz-range-thumb {
  transform: scale(1.05);
}

.field.field--toggle,
.device-row[data-role='toggle'] {
  flex-direction: row;
  align-items: center;
  gap: 12px;
}

.field.field--toggle .field__label,
.device-row[data-role='toggle'] .device-row__label {
  order: 2;
  margin: 0;
}

.field.field--disabled {
  opacity: 0.55;
}

.field.field--toggle input[type='checkbox'] {
  order: 1;
}

.device-status {
  margin: 0;
  font-size: 12px;
  color: var(--muted);
}

.field__hint {
  margin: 4px 0 0;
  font-size: 12px;
  color: var(--muted);
}

.app-shell > .panel {
  gap: calc(var(--gap) * 1.25);
}

.controls-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: calc(var(--pad) + 4px);
}

.fx-panel__groups {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: calc(var(--gap) + 8px);
}

.fx-panel__group {
  display: flex;
  flex-direction: column;
  gap: var(--gap);
}

.fx-panel__group-title {
  margin: 0;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

.control-block,
.control-row {
  background: transparent;
  border: none;
  padding: 0;
}

.control-block {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.control-block label {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

.control-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.meters-card {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.meters-card__channels {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

@media (max-width: 720px) {
  .meters-card__channels {
    grid-template-columns: 1fr;
  }
}

.meters-card__channel {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.meters-card__label {
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

.meters-card__value {
  font-size: 24px;
  font-weight: 600;
  letter-spacing: 0.01em;
}

.meters-card__bar {
  position: relative;
  height: 6px;
  border-radius: 999px;
  background: rgba(126, 155, 206, 0.18);
  overflow: hidden;
}

.meters-card__bar-fill {
  position: absolute;
  inset: 0;
  border-radius: inherit;
  width: 0%;
  background: var(--ok);
  transition: width 0.12s ease, background-color 0.12s ease;
}

.meters-card__footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.meters-card__status {
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ok);
}

.meters-card__status--warn {
  color: var(--warn);
}

.meters-card__clip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

.meters-card__clip-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: rgba(126, 155, 206, 0.24);
  box-shadow: 0 0 0 1px rgba(126, 155, 206, 0.3);
  transition: background-color 0.2s ease, box-shadow 0.2s ease;
}

.meters-card__clip--active {
  color: var(--warn);
}

.meters-card__clip--active .meters-card__clip-dot {
  background: var(--warn);
  box-shadow: 0 0 12px rgba(251, 191, 36, 0.55);
}

@media (max-width: 768px) {
  main,
  .app-shell {
    width: min(100%, 96vw);
    padding: calc(var(--pad) * 1.5) 0 calc(var(--pad) * 2.5);
    gap: calc(var(--pad) * 1.25);
  }

  .controls-grid {
    grid-template-columns: 1fr;
  }

  .device-header__buttons {
    justify-content: center;
  }
}

@media (max-width: 480px) {
  .device-header__buttons {
    flex-direction: column;
    align-items: stretch;
  }

  .btn {
    width: 100%;
  }
}
