body:has(.control-shell) {
  background: #101216;
  color: #e7edf3;
}

body:has(.control-shell) header,
body:has(.control-shell) footer {
  display: none;
}

body:has(.control-shell) main,
body:has(.control-shell) .container {
  width: 100%;
  max-width: none;
  margin: 0;
  padding: 0;
}

.control-shell {
  display: flex;
  min-height: 100vh;
  flex-direction: column;
  gap: 0.7rem;
  padding: 0.7rem;
  color: #e7edf3;
  --monitor-preview-width: minmax(24rem, 1fr);
}

.control-shell[data-monitor-size="medium"] {
  --monitor-preview-width: minmax(30rem, 1fr);
}

.control-shell[data-monitor-size="large"] {
  --monitor-preview-width: minmax(36rem, 1fr);
}

.control-header,
.control-panel {
  border: 1px solid #2a323d;
  border-radius: 8px;
  background: #181c22;
  box-shadow: 0 12px 34px rgba(0, 0, 0, 0.28);
}

.control-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.68rem 0.85rem;
}

.control-kicker,
.panel-kicker {
  margin: 0 0 0.18rem;
  color: #8d9bad;
  font-size: 0.68rem;
  font-weight: 850;
  letter-spacing: 0;
  text-transform: uppercase;
}

.control-header h1,
.operator-toolbar h2,
.settings-heading h2 {
  margin: 0;
  color: #ffffff;
  font-weight: 900;
  letter-spacing: 0;
}

.control-header h1 {
  font-size: 1.08rem;
}

.state-stack {
  display: flex;
  gap: 0.55rem;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.live-state {
  display: inline-flex;
  align-items: center;
  gap: 0.42rem;
  min-width: 10rem;
  max-width: 100%;
  padding: 0.42rem 0.58rem;
  border: 1px solid color-mix(in srgb, var(--accent) 38%, #2f3a46);
  border-radius: 8px;
  background: color-mix(in srgb, var(--accent) 13%, #20262e);
  color: #ffffff;
  font-size: 0.82rem;
  font-weight: 850;
}

.state-label {
  color: #a7b3c2;
  font-size: 0.62rem;
  font-weight: 900;
  text-transform: uppercase;
}

.live-dot {
  width: 0.58rem;
  height: 0.58rem;
  flex: 0 0 auto;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 16%, transparent);
}

.control-panel {
  padding: 0.72rem;
}

.operator-panel {
  position: sticky;
  z-index: 40;
  top: 0;
  display: grid;
  gap: 0.62rem;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.025), transparent 38%),
    #151a20;
}

.operator-panel::after {
  position: absolute;
  right: 0.7rem;
  bottom: -0.55rem;
  left: 0.7rem;
  height: 0.55rem;
  background: linear-gradient(180deg, rgba(0, 0, 0, 0.35), transparent);
  content: "";
  pointer-events: none;
}

.operator-toolbar,
.settings-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.8rem;
}

.operator-toolbar h2,
.settings-heading h2 {
  font-size: 0.98rem;
}

.operator-status {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.55rem;
  min-width: max-content;
  color: #9ba8b7;
  font-size: 0.68rem;
  font-weight: 900;
  text-transform: uppercase;
}

.operator-tools-menu {
  position: relative;
}

.operator-tools-menu summary {
  display: inline-flex;
  min-height: 1.65rem;
  align-items: center;
  gap: 0.32rem;
  padding: 0.24rem 0.5rem;
  border: 1px solid #374151;
  border-radius: 999px;
  background: #1f2630;
  color: #dce5ee;
  cursor: pointer;
  font-size: 0.66rem;
  font-weight: 950;
  line-height: 1;
  list-style: none;
}

.operator-tools-menu summary::-webkit-details-marker {
  display: none;
}

.operator-tools-menu summary:hover,
.operator-tools-menu summary:focus {
  border-color: #f26a21;
  outline: 2px solid rgba(242, 106, 33, 0.22);
  outline-offset: 1px;
}

.operator-tools-menu[open] summary {
  border-color: #f26a21;
  background: rgba(242, 106, 33, 0.16);
  color: #ffffff;
}

#connectionState {
  color: #4ade80;
}

.monitor-size-control {
  display: inline-flex;
  overflow: hidden;
  border: 1px solid #374151;
  border-radius: 999px;
  background: #11161c;
}

.monitor-size-button {
  min-width: 1.9rem;
  min-height: 1.45rem;
  padding: 0 0.42rem;
  border: 0;
  border-left: 1px solid #374151;
  background: transparent;
  color: #9ba8b7;
  font-size: 0.68rem;
  font-weight: 950;
  line-height: 1;
}

.monitor-size-button:first-child {
  border-left: 0;
}

.monitor-size-button[aria-pressed="true"] {
  background: #f26a21;
  color: #111111;
}

.monitor-size-button:hover,
.monitor-size-button:focus {
  outline: 2px solid rgba(242, 106, 33, 0.28);
  outline-offset: 1px;
}

.operator-layout {
  display: grid;
  grid-template-columns: minmax(9rem, 0.42fr) minmax(42rem, 2.4fr) minmax(9rem, 0.42fr);
  gap: 0.62rem;
  align-items: stretch;
}

.control-shell[data-monitor-size="medium"] .operator-layout {
  grid-template-columns: minmax(8.2rem, 0.34fr) minmax(46rem, 2.8fr) minmax(8.2rem, 0.34fr);
}

.control-shell[data-monitor-size="large"] .operator-layout {
  grid-template-columns: minmax(7.4rem, 0.26fr) minmax(50rem, 3.35fr) minmax(7.4rem, 0.26fr);
}

.cue-rail {
  display: grid;
  align-content: start;
  gap: 0.42rem;
}

.monitor-stage {
  display: grid;
  min-width: 0;
  gap: 0.48rem;
}

.monitor-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.62rem;
  min-width: 0;
}

.preview-card {
  display: grid;
  min-width: 0;
  gap: 0.24rem;
}

.preview-heading {
  display: flex;
  justify-content: space-between;
  gap: 0.55rem;
  color: #9ba8b7;
  font-size: 0.64rem;
  font-weight: 900;
  line-height: 1;
  text-transform: uppercase;
}

.preview-heading strong {
  overflow: hidden;
  color: #ffffff;
  text-align: right;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.preview-frame {
  position: relative;
  aspect-ratio: 16 / 9;
  overflow: hidden;
  border: 1px solid #303946;
  border-radius: 8px;
  background:
    linear-gradient(45deg, rgba(255, 255, 255, 0.035) 25%, transparent 25%),
    linear-gradient(-45deg, rgba(255, 255, 255, 0.035) 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, rgba(255, 255, 255, 0.035) 75%),
    linear-gradient(-45deg, transparent 75%, rgba(255, 255, 255, 0.035) 75%),
    #0e1511;
  background-position: 0 0, 0 10px, 10px -10px, -10px 0;
  background-size: 20px 20px;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.04);
}

.preview-frame iframe {
  width: 1920px;
  height: 1080px;
  border: 0;
  transform: scale(var(--preview-scale, 0.34));
  transform-origin: 0 0;
}

.graphic-command {
  display: flex;
  position: relative;
  min-height: 3.55rem;
  flex-direction: column;
  align-items: flex-start;
  justify-content: center;
  gap: 0.22rem;
  padding: 0.48rem 0.54rem;
  border: 1px solid #303946;
  border-left: 0.22rem solid var(--accent);
  border-radius: 8px;
  background: linear-gradient(180deg, #20262e, #171c22);
  color: #f8fafc;
  font-size: 0.8rem;
  text-align: left;
  transition: border-color 120ms ease, background 120ms ease, transform 120ms ease;
}

.graphic-command-title {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: start;
  gap: 0.36rem;
  width: 100%;
}

.graphic-command-label {
  display: grid;
  min-width: 0;
  gap: 0.1rem;
}

.graphic-command-name {
  overflow: hidden;
  font-weight: 900;
  line-height: 1.05;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.graphic-command small {
  display: block;
  overflow: hidden;
  color: #9ba8b7;
  font-size: 0.62rem;
  font-weight: 850;
  line-height: 1.05;
  text-overflow: ellipsis;
  text-transform: uppercase;
  white-space: nowrap;
}

.shortcut-badge {
  flex: 0 0 auto;
  padding: 0.15rem 0.32rem;
  border: 1px solid color-mix(in srgb, var(--accent, #0c8040) 35%, #45515f);
  border-radius: 5px;
  background: rgba(0, 0, 0, 0.22);
  color: #dce5ee;
  font-family: "Segoe UI", Arial, Helvetica, sans-serif;
  font-size: 0.58rem;
  font-weight: 950;
  line-height: 1;
  text-transform: uppercase;
}

.graphic-command:hover,
.graphic-command:focus {
  border-color: var(--accent);
  background: color-mix(in srgb, var(--accent) 14%, #1d232b);
  outline: none;
  transform: translateY(-1px);
}

.graphic-command.is-live {
  border-color: color-mix(in srgb, var(--accent) 70%, #ffffff);
  background: color-mix(in srgb, var(--accent) 18%, #1d232b);
}

.graphic-command.is-cued {
  box-shadow: inset 0 0 0 2px color-mix(in srgb, var(--accent) 78%, #101216);
}

.graphic-command.is-cued small {
  padding-right: 2.1rem;
}

.graphic-command.is-cued::after {
  position: absolute;
  right: 0.34rem;
  bottom: 0.28rem;
  padding: 0.12rem 0.32rem;
  border-radius: 999px;
  background: var(--accent);
  color: #ffffff;
  content: "Cued";
  font-size: 0.52rem;
  font-weight: 950;
  text-transform: uppercase;
}

.take-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 0.7rem;
  min-height: 2.55rem;
  margin: 0;
  padding: 0.36rem 0.44rem 0.36rem 0.62rem;
  border: 1px solid rgba(242, 106, 33, 0.48);
  border-radius: 8px;
  background:
    linear-gradient(90deg, rgba(242, 106, 33, 0.18), rgba(242, 106, 33, 0.04)),
    #171c22;
}

.take-row div {
  display: flex;
  min-width: 0;
  align-items: baseline;
  gap: 0.48rem;
}

.take-row span {
  color: #9ba8b7;
  font-size: 0.62rem;
  font-weight: 950;
  text-transform: uppercase;
}

.take-row strong {
  overflow: hidden;
  color: #ffffff;
  font-size: 0.9rem;
  font-weight: 950;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.take-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.48rem;
  min-width: 8.6rem;
  min-height: 2rem;
  padding: 0.42rem 0.7rem;
  border: 0;
  border-radius: 8px;
  background: #f26a21;
  color: #111111;
  font-weight: 950;
  text-transform: uppercase;
}

.take-shortcut {
  border-color: rgba(16, 16, 16, 0.22);
  background: rgba(255, 255, 255, 0.32);
  color: #111111;
}

.take-button:hover,
.take-button:focus {
  background: #ff7d33;
  outline: 2px solid rgba(242, 106, 33, 0.38);
  outline-offset: 2px;
}

.output-strip {
  display: grid;
  position: absolute;
  z-index: 90;
  top: calc(100% + 0.45rem);
  right: 0;
  width: min(34rem, calc(100vw - 1.4rem));
  grid-template-columns: 1fr;
  gap: 0.62rem;
  align-items: stretch;
  padding: 0.62rem;
  border: 1px solid #33404d;
  border-radius: 8px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.04), transparent 58%),
    #151a20;
  box-shadow: 0 18px 42px rgba(0, 0, 0, 0.42);
  text-transform: none;
}

.output-actions {
  display: grid;
  gap: 0.42rem;
}

.output-action-grid {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.output-action-grid a,
.output-action-grid button {
  display: inline-flex;
  min-height: 2rem;
  align-items: center;
  justify-content: center;
  border-color: #3b4653;
  background: #1f2630;
  color: #dce5ee;
  font-size: 0.74rem;
  font-weight: 850;
}

.output-action-grid a:hover,
.output-action-grid button:hover,
.output-action-grid a:focus,
.output-action-grid button:focus {
  border-color: #f26a21;
  background: #2a313b;
  color: #ffffff;
}

.output-link {
  display: grid;
  gap: 0.28rem;
  min-width: 0;
}

.output-link span {
  color: #9ba8b7;
  font-size: 0.64rem;
  font-weight: 900;
  text-transform: uppercase;
}

.output-link code {
  display: block;
  overflow: hidden;
  padding: 0.48rem 0.6rem;
  border: 1px solid #303946;
  border-radius: 8px;
  background: #0e1319;
  color: #baf7d2;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.setup-panel {
  display: grid;
  gap: 0.62rem;
  background:
    linear-gradient(90deg, rgba(12, 128, 64, 0.08), transparent 42%),
    #151a20;
}

.settings-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 0.38rem;
  justify-content: flex-end;
}

.settings-tab {
  min-height: 1.9rem;
  padding: 0.34rem 0.58rem;
  border: 1px solid #303946;
  border-radius: 999px;
  background: #1f2630;
  color: #aeb9c7;
  font-size: 0.68rem;
  font-weight: 900;
  text-transform: uppercase;
}

.settings-tab.is-active {
  border-color: #f26a21;
  background: rgba(242, 106, 33, 0.18);
  color: #ffffff;
}

.setup-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.55rem;
}

.settings-card {
  display: none;
  gap: 0.55rem;
  margin-bottom: 0;
  padding: 0.68rem;
  border: 1px solid #2d3743;
  border-radius: 8px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.03), transparent 52%),
    #1a2028;
}

.settings-card.is-active {
  display: grid;
}

.current-event-heading,
.current-event-form,
.rider-lookup-heading,
.rider-lookup-form,
.stage-profile-heading,
.stage-profile-form,
.sportstiming-results-heading,
.sportstiming-results-form {
  display: flex;
  align-items: end;
  gap: 0.5rem;
}

.current-event-heading,
.rider-lookup-heading,
.stage-profile-heading,
.sportstiming-results-heading {
  align-items: center;
  justify-content: space-between;
}

.current-event-editor h3,
.rider-lookup h3,
.stage-profile-loader h3,
.sportstiming-results-loader h3,
.settings-empty h3 {
  margin: 0;
  color: #ffffff;
  font-size: 0.9rem;
  font-weight: 900;
}

.settings-empty p {
  margin: 0;
  color: #9ba8b7;
  font-weight: 700;
}

.current-event-heading span,
.stage-profile-heading span,
.sportstiming-results-heading span {
  color: #9ba8b7;
  font-size: 0.66rem;
  font-weight: 900;
  text-transform: uppercase;
}

.current-event-form,
.rider-lookup-form,
.stage-profile-form,
.sportstiming-results-form {
  flex-wrap: wrap;
}

.current-event-editor label,
.rider-lookup label,
.stage-profile-loader label,
.sportstiming-results-loader label {
  display: grid;
  min-width: 8rem;
  flex: 1 1 8rem;
  gap: 0.22rem;
  margin: 0;
}

.current-event-editor label span,
.rider-lookup label span,
.stage-profile-loader label span,
.sportstiming-results-loader label span,
.current-event-status,
.rider-lookup-status,
.stage-profile-status,
.sportstiming-results-status {
  color: #9ba8b7;
  font-size: 0.66rem;
  font-weight: 900;
  text-transform: uppercase;
}

.current-event-editor input,
.current-event-editor select,
.current-event-editor textarea,
.rider-lookup input,
.rider-lookup select,
.stage-profile-loader input,
.stage-profile-loader select,
.stage-profile-loader textarea,
.sportstiming-results-loader input,
.sportstiming-results-loader select {
  width: 100%;
  min-height: 2.15rem;
  padding: 0.38rem 0.52rem;
  border: 1px solid #35404c;
  border-radius: 8px;
  background: #0f151b;
  color: #eef4fb;
  font: inherit;
  font-weight: 750;
}

.current-event-editor input::placeholder,
.current-event-editor textarea::placeholder,
.rider-lookup input::placeholder,
.stage-profile-loader input::placeholder,
.stage-profile-loader textarea::placeholder {
  color: #687586;
}

.rider-lookup .rider-photo-toggle {
  display: inline-flex;
  flex: 0 0 auto;
  align-items: center;
  gap: 0.45rem;
  min-width: 0;
  min-height: 2.15rem;
  padding: 0.38rem 0.52rem;
  border: 1px solid #35404c;
  border-radius: 8px;
  background: #0f151b;
}

.rider-photo-toggle input {
  width: 1rem;
  min-height: 1rem;
  padding: 0;
  accent-color: #0c8040;
}

.current-event-editor textarea,
.stage-profile-loader textarea {
  min-height: 3rem;
  resize: vertical;
}

.current-event-preset-field,
.current-event-name-field,
.current-event-notes-field,
.rider-source-field,
.stage-file-field,
.stage-saved-field,
.stage-marker-field,
.sportstiming-source-field,
.sportstiming-stage-field,
.sportstiming-classification-field {
  flex-basis: 100%;
}

.stage-refresh-button {
  align-self: end;
  min-height: 2.15rem;
}

.current-event-editor input:focus,
.current-event-editor select:focus,
.current-event-editor textarea:focus,
.rider-lookup input:focus,
.rider-lookup select:focus,
.stage-profile-loader input:focus,
.stage-profile-loader select:focus,
.stage-profile-loader textarea:focus,
.sportstiming-results-loader input:focus,
.sportstiming-results-loader select:focus {
  border-color: #f26a21;
  outline: 2px solid rgba(242, 106, 33, 0.22);
  outline-offset: 1px;
}

.current-event-cue-button,
.rider-cue-button,
.stage-cue-button,
.sportstiming-cue-button,
.secondary-command {
  border-radius: 8px;
  font-weight: 900;
}

.current-event-cue-button,
.rider-cue-button,
.stage-cue-button,
.sportstiming-cue-button {
  min-height: 2.15rem;
  flex: 0 0 auto;
  padding: 0.42rem 0.72rem;
  border: 0;
  background: #0c8040;
  color: #ffffff;
  font-size: 0.72rem;
  text-transform: uppercase;
}

.weather-cue-button {
  background: #f26a21;
  color: #101010;
}

.route-wind-cue-button {
  background: #dce5ee;
  color: #101010;
}

.current-event-cue-button,
.stage-cue-button,
.sportstiming-cue-button {
  margin-left: auto;
}

.weather-cue-button,
.route-wind-cue-button {
  margin-left: 0;
}

.secondary-command {
  padding: 0.34rem 0.54rem;
  border: 1px solid #35404c;
  background: #202731;
  color: #dce5ee;
  font-size: 0.72rem;
}

.current-event-cue-button:hover,
.current-event-cue-button:focus,
.rider-cue-button:hover,
.rider-cue-button:focus,
.stage-cue-button:hover,
.stage-cue-button:focus,
.sportstiming-cue-button:hover,
.sportstiming-cue-button:focus {
  background: #109b50;
  outline: 2px solid rgba(12, 128, 64, 0.32);
  outline-offset: 2px;
}

.weather-cue-button:hover,
.weather-cue-button:focus {
  background: #ff7d33;
  outline-color: rgba(242, 106, 33, 0.36);
}

.route-wind-cue-button:hover,
.route-wind-cue-button:focus,
.secondary-command:hover,
.secondary-command:focus {
  border-color: #f26a21;
  outline: 2px solid rgba(242, 106, 33, 0.18);
  outline-offset: 2px;
}

.current-event-status,
.rider-lookup-status,
.stage-profile-status,
.sportstiming-results-status {
  margin: 0;
  min-height: 1.1rem;
  text-transform: none;
}

.current-event-status[data-tone="success"],
.rider-lookup-status[data-tone="success"],
.stage-profile-status[data-tone="success"],
.sportstiming-results-status[data-tone="success"] {
  color: #4ade80;
}

.current-event-status[data-tone="pending"],
.rider-lookup-status[data-tone="pending"],
.stage-profile-status[data-tone="pending"],
.sportstiming-results-status[data-tone="pending"] {
  color: #fbbf24;
}

.current-event-status[data-tone="error"],
.rider-lookup-status[data-tone="error"],
.stage-profile-status[data-tone="error"],
.sportstiming-results-status[data-tone="error"] {
  color: #fb7185;
}

.take-button:disabled,
.graphic-command:disabled,
.current-event-cue-button:disabled,
.rider-cue-button:disabled,
.stage-cue-button:disabled,
.sportstiming-cue-button:disabled,
.secondary-command:disabled,
.reset-chrome-button:disabled {
  cursor: wait;
  opacity: 0.65;
}

@media (max-width: 1050px) {
  .operator-layout {
    grid-template-columns: minmax(0, 1fr);
  }

  .cue-rail {
    grid-template-columns: repeat(auto-fit, minmax(8.5rem, 1fr));
  }

  .cue-rail-left {
    order: 1;
  }

  .monitor-stage {
    order: 2;
  }

  .cue-rail-right {
    order: 3;
  }
}

@media (max-width: 900px) {
  .control-header,
  .operator-toolbar,
  .settings-heading,
  .current-event-heading,
  .current-event-form,
  .rider-lookup-heading,
  .rider-lookup-form,
  .stage-profile-heading,
  .stage-profile-form,
  .sportstiming-results-heading,
  .sportstiming-results-form {
    align-items: stretch;
    flex-direction: column;
  }

  .operator-status,
  .settings-tabs {
    justify-content: flex-start;
  }

  .monitor-grid,
  .output-strip {
    grid-template-columns: 1fr;
  }

  .take-row {
    grid-template-columns: 1fr;
  }

  .take-row div {
    display: grid;
  }

  .take-button {
    width: 100%;
  }
}

@media (max-width: 640px) {
  .control-shell {
    padding: 0.4rem;
  }

  .state-stack,
  .cue-rail,
  .output-action-grid {
    grid-template-columns: 1fr;
  }

  .live-state {
    width: 100%;
  }
}
