body {
  font-family: "Open Sans", Arial, sans-serif;
  margin: 0;
  background: #ebebeb;
  color: #111827;
}

main {
  margin: 0 auto;
  padding: 1rem;
}

h1 {
  margin-bottom: 0.2rem;
}

.subtitle {
  margin-top: 0;
  color: #4b5563;
}

.layout {
  display: grid;
  gap: 1rem;
  grid-template-columns: 1fr 1fr;
  margin-bottom: 1rem;
}

.panel {
  background: #ffffff;
  border-radius: 8px;
  padding: 1rem;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

.panel-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.75rem 1rem;
  margin-bottom: 0.5rem;
}

.panel-head h2 {
  margin: 0;
}

.panel-toggle-btn {
  min-width: unset;
  font-size: 0.8rem;
  font-weight: 600;
  padding: 0.4rem 0.7rem;
  border-radius: 999px;
}

.map-grid-playback-section.is-collapsed {
  display: none;
}

.panel-head-link {
  font-size: 0.875rem;
  font-weight: 600;
  color: #1d4ed8;
  text-decoration: none;
}

.panel-head-link:hover {
  text-decoration: underline;
}

.entry-links {
  display: flex;
  flex-direction: row;
  flex-wrap: wrap;
  align-items: center;
  gap: 1.25rem;
  margin: 0 0 0.75rem 0;
  text-decoration: none;
}

form {
  display: grid;
  gap: 0.6rem;
  margin-bottom: 0.8rem;
}

.form-autosave-hint {
  font-size: 0.75rem;
  margin: 0.45rem 0 0;
  padding: 0.4rem 0.55rem;
  border-radius: 6px;
  color: #059669;
  background: #ecfdf5;
}

label {
  display: grid;
  gap: 0.2rem;
  font-size: 0.75rem;
}

input,
textarea,
select,
button {
  font: inherit;
  padding: 0.5rem;
}

button {
  border: 0;
  background: #1d4ed8;
  color: #fff;
  border-radius: 6px;
  cursor: pointer;
  padding: .5rem 1.5rem;
}

button.secondary {
  background: #374151;
}

[data-action="delete"] {
  background: #7f1d1d;
  color: #fffcfc;
}

[data-action="delete"]:hover {
  background: #991b1b;
}

[data-action="new"] {
  background: #14532d;
  color: #ffffff;
}

[data-action="new"]:hover {
  background: #166534;
}

ul,
ol {
  margin: 0;
  padding-left: 1.2rem;
}

.row {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 0.6rem;
}

.scenario-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 0.65rem 1rem;
  margin-top: 0.7rem;
  margin-bottom: 0.5rem;
}

.scenario-toolbar .scenario-controls {
  margin-top: 0;
  margin-bottom: 0;
  flex: 1 1 auto;
  min-width: min(100%, 280px);
}

.active-real-scenarios,
.active-idle-scenarios {
  flex: 0 1 auto;
  max-width: 14rem;
  padding: 0.35rem 0.5rem 0.4rem;
  border: 1px solid #e5e7eb;
  border-radius: 6px;
  background: #fafafa;
  font-size: 0.72rem;
  line-height: 1.35;
  color: #374151;
}

.active-real-scenarios-title,
.active-idle-scenarios-title {
  display: block;
  font-weight: 600;
  font-size: 0.68rem;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  color: #6b7280;
  margin-bottom: 0.25rem;
}

.active-real-scenarios-list,
.active-idle-scenarios-list {
  list-style: none;
  padding-left: 0;
  margin: 0;
  max-height: 5.5rem;
  overflow-y: auto;
}

.active-real-scenarios-list li,
.active-idle-scenarios-list li {
  padding: 0.1rem 0;
  border-top: 1px solid #eee;
}

.active-real-scenarios-list li:first-child,
.active-idle-scenarios-list li:first-child {
  border-top: none;
}

.active-real-scenarios-list li.muted,
.active-idle-scenarios-list li.muted {
  color: #9ca3af;
  font-style: italic;
}

.scenario-controls {
  display: flex;
  align-items: flex-end;
  gap: 0.5rem;
  margin-top: 0.7rem;
  margin-bottom: 0.5rem;
}

.scenario-controls label {
  min-width: 150px;
}

.scenario-controls button {
  width: 36px;
  height: 36px;
  min-width: unset;
  padding: 0;
  font-size: 1rem;
  align-self: flex-end;
}

.scenario-controls .cycle-toggle {
  min-width: unset;
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  margin: 0 0.6rem;
}

.scenario-controls .cycle-toggle input {
  margin: 0;
}

.scenario-controls .kiosk-inline {
  display: flex;
  align-items: flex-end;
  flex-wrap: wrap;
  gap: 0.5rem 0.85rem;
  min-width: 0;
}

.scenario-controls .kiosk-inline > label:first-of-type input[type="number"] {
  width: 1.5rem;
}

.scenario-controls .kiosk-filter-toggle {
  min-width: unset;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  margin: 0;
  font-size: 0.85rem;
  width: 8rem;
  font-size: 0.6rem;
}

.scenario-controls .kiosk-filter-toggle input {
  margin: 0;
}

.scenario-pick-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  padding: 0.4rem 0 0.5rem;
  border-bottom: 1px solid #e5e7eb;
  margin-bottom: 0.3rem;
  box-sizing: border-box;
  padding-left: 10px;
}

.scenario-pick-btn {
  padding: 3px 10px;
  font-size: 0.78rem;
  font-weight: 600;
  background: #f3f4f6;
  color: #374151;
  border: 1px solid #d1d5db;
  border-radius: 999px;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.12s, border-color 0.12s, color 0.12s;
  min-width: unset;
}

.scenario-pick-btn:hover {
  background: #e5e7eb;
  border-color: #9ca3af;
}

.scenario-pick-btn.active {
  background: #1d4ed8;
  border-color: #1d4ed8;
  color: #fff;
}

.work-list-header-empty {
  font-size: 0.82rem;
  color: #9ca3af;
  margin: 0.4rem 0;
}


.scenario-step-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 5px 10px;
  border-radius: 5px;
  background: #f3f4f6;
  border: 1px solid #e5e7eb;
  font-size: 0.8rem;
  color: #374151;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, opacity 0.15s;
}

.scenario-step-item:hover {
  background: #e9eaf0;
  border-color: #d1d5db;
}

.scenario-step-item.selected {
  background: #eff6ff;
  border-color: #93c5fd;
  color: #1e40af;
}

.scenario-step-item.selected .step-number {
  background: #3b82f6;
  color: #fff;
}

.scenario-step-item.playing {
  background: #fef2f2;
  border-color: #fca5a5;
  color: #991b1b;
  font-weight: 600;
}

.scenario-step-item.playing .step-number {
  background: #dc2626;
  color: #fff;
}

.scenario-step-item.dragging {
  opacity: 0.4;
}

.scenario-step-item.drag-over {
  border-color: #6366f1;
  background: #eef2ff;
}

.step-drag-handle {
  color: #9ca3af;
  font-size: 1rem;
  cursor: grab;
  flex-shrink: 0;
  user-select: none;
}

.step-number {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #d1d5db;
  color: #111827;
  font-size: 0.7rem;
  font-weight: 700;
  flex-shrink: 0;
}

.scenario-step-item.playing .step-route {
  color: #b91c1c;
}

.step-type {
  font-weight: 600;
  flex-shrink: 0;
}

.step-route {
  color: #89909a;
  color: color-mix(in srgb, #6b7280 80%, white 20%);
  flex: 1;
  font-size: 0.8em;
}


.step-data {
  font-style: italic;
  color: #9ca3af;
  font-size: 0.75rem;
}

.work-tabs {
  display: flex;
  gap: 0.5rem;
  margin: 0.6rem 0;
  width: 100%;
  background: #66758a;
  border: 1px solid #93c5fd;
  border-radius: 10px;
  padding: 0.6rem;
  box-sizing: border-box;
}

.tab-button {
  min-width: 200px;
  background: #101d4030;
  color: #fff;
}

.tab-button.active {
  background: #ffffff;
  color: #000;
  font-weight: bold;
  filter: drop-shadow(0 0 4px rgba(0, 0, 0, 0.4));
}

.work-area {
  display: grid;
  grid-template-columns: 1.1fr 1fr;
  gap: 0.8rem;
  margin-bottom: 0.6rem;
}

.work-list-column {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.work-list-wrap {
  border: 1px solid #d1d5db;
  border-radius: 6px;
 max-height: 1040px; 
  overflow: auto;
  background: #fff;
}

.work-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.work-list-item {
  padding: 0.55rem 0.7rem;
  cursor: pointer;
  border-bottom: 1px solid #e5e7eb;
}

.work-list-node-name {
  display: inline-block;
  vertical-align: middle;
}

.work-list-node-code-text {
  font-weight: 700;
}

.work-list-node-code-pill {
  display: inline-block;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  margin-left: 0.5rem;
  vertical-align: middle;
  background: var(--node-code-color, #6b7280);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.25);
}

.work-list-item:nth-child(odd) {
  background: #f9fafb;
}

.work-list-item:nth-child(even) {
  background: #eef2ff;
}

.work-list-item.active {
  outline: 2px solid #1d4ed8;
  background: #dbeafe;
}

#workListActions {
  display: flex;
}

#workListActions button {
  width: 100%;
}

.steps-panel-actions {
  display: flex;
}

.steps-panel-actions button {
  width: 100%;
}

.work-detail {
  border: 1px solid #d1d5db;
  border-radius: 6px;
  padding: 0.7rem;
  background: #f8fafc;
}

.work-detail .actions {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.6rem;
}

.work-detail .checkbox-row {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  margin-top: 0.45rem;
  font-weight: 500;
  cursor: pointer;
}

.hint {
  color: #4b5563;
  margin-bottom: 0;
}

.step-type-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

#selectedNodePanel {
  border: 1px solid #d1d5db;
  border-radius: 6px;
  padding: 0.6rem;
  margin-bottom: 1rem;
  background: #f9fafb;
}

#status {
  min-height: 1rem;
  font-weight: 600;
}

.actions-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
}

.action-panel {
  border: 1px solid #d1d5db;
  border-radius: 6px;
  background: #fff;
  overflow: hidden;
}

.action-panel.expanded {
  border-color: #93c5fd;
}

.action-panel-header {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.45rem 0.6rem;
  cursor: pointer;
  user-select: none;
  background: #f9fafb;
  border-bottom: 1px solid transparent;
  transition: background 0.12s;
}

.action-panel.expanded .action-panel-header {
  background: #eff6ff;
  border-bottom-color: #dbeafe;
}

.action-panel-header:hover {
  background: #f3f4f6;
}

.action-panel.expanded .action-panel-header:hover {
  background: #dbeafe;
}

.action-panel-toggle {
  font-size: 0.75rem;
  color: #6b7280;
  flex-shrink: 0;
  width: 14px;
  text-align: center;
}

.action-panel-title {
  font-size: 0.82rem;
  font-weight: 500;
  color: #374151;
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.action-remove-btn {
  background: none;
  border: none;
  color: #9ca3af;
  font-size: 0.8rem;
  cursor: pointer;
  padding: 0 0.3rem;
  line-height: 1;
  min-width: unset;
  border-radius: 3px;
}

.action-remove-btn:hover {
  color: #dc2626;
  background: #fef2f2;
}

.action-panel-body {
  padding: 0.6rem;
  display: grid;
  gap: 0.5rem;
}

action-data-editor {
  display: block;
  grid-column: 1 / -1;
}

.action-panel-body input,
.action-panel-body select,
.action-panel-body textarea {
  font-size: 0.77rem;
  line-height: 1.26;
  padding: 0.22rem 0.33rem;
}

.action-data-label {
  grid-column: 1 / -1;
}

.action-field-disclosure {
  grid-column: 1 / -1;
  border: 1px solid #e5e7eb;
  border-radius: 4px;
  background: #fafafa;
  overflow: hidden;
}

.action-field-disclosure.is-open {
  border-color: #d1d5db;
  background: #fff;
}

.action-field-disclosure-btn {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  width: 100%;
  margin: 0;
  padding: 0.4rem 0.5rem;
  border: none;
  background: transparent;
  cursor: pointer;
  text-align: left;
  font: inherit;
  color: #374151;
  transition: background 0.12s;
}

.action-field-disclosure-btn:hover {
  background: #f3f4f6;
}

.action-field-disclosure.is-open .action-field-disclosure-btn {
  background: #f9fafb;
  border-bottom: 1px solid #e5e7eb;
}

.action-field-disclosure.is-open .action-field-disclosure-btn:hover {
  background: #f3f4f6;
}

.action-field-disclosure--widget {
  --action-field-bg: #f4f0d2;
  --action-field-header-bg: #fff7d1;
  border-color: var(--action-field-header-bg);
  background: var(--action-field-bg);
}

.action-field-disclosure--widget .action-field-disclosure-btn,
.action-field-disclosure--widget .action-field-disclosure-btn:hover,
.action-field-disclosure--widget.is-open .action-field-disclosure-btn,
.action-field-disclosure--widget.is-open .action-field-disclosure-btn:hover {
  background: var(--action-field-header-bg);
}

.action-field-disclosure--widget.is-open .action-field-disclosure-btn {
  border-bottom-color: var(--action-field-header-bg);
}

.action-field-disclosure--widget .action-field-disclosure-body {
  background: var(--action-field-bg);
}

.action-field-disclosure--message {
  --action-field-bg: #d6f4d2;
  --action-field-header-bg: #e4ffe6;
  border-color: var(--action-field-header-bg);
  background: var(--action-field-bg);
}

.action-field-disclosure--message .action-field-disclosure-btn,
.action-field-disclosure--message .action-field-disclosure-btn:hover,
.action-field-disclosure--message.is-open .action-field-disclosure-btn,
.action-field-disclosure--message.is-open .action-field-disclosure-btn:hover {
  background: var(--action-field-header-bg);
}

.action-field-disclosure--message.is-open .action-field-disclosure-btn {
  border-bottom-color: var(--action-field-header-bg);
}

.action-field-disclosure--message .action-field-disclosure-body {
  background: var(--action-field-bg);
}

.action-field-disclosure-title {
  font-size: 0.82rem;
  font-weight: 500;
  flex: 1;
}

.action-field-disclosure-hint {
  font-size: 0.72rem;
  font-weight: 500;
  color: #6b7280;
  font-style: italic;
}

.action-field-disclosure-body {
  padding: 0.45rem 0.5rem 0.55rem;
}

.widget-picker-list {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  max-height: 28rem;
  overflow-y: auto;
}

.widget-picker-row {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  width: 100%;
  margin: 0;
  padding: 0.35rem 0.45rem;
  border: 1px solid #e5e7eb;
  border-radius: 4px;
  background: #fff;
  cursor: pointer;
  text-align: left;
  font: inherit;
  color: #111827;
  transition: border-color 0.12s, background 0.12s;
}

.widget-picker-row:hover {
  border-color: #cbd5e1;
  background: #f9fafb;
}

.widget-picker-row.is-selected {
  border-color: #2563eb;
  background: #eff6ff;
}

.widget-picker-thumb {
  flex-shrink: 0;
  max-height: 160px;
}

.widget-picker-thumb--none {
  width: 4.5rem;
  height: 3rem;
  border-radius: 0.375rem;
  border: 1px dashed #d1d5db;
  background: #f3f4f6;
}

.widget-picker-name {
  flex: 1;
  min-width: 0;
  font-size: 0.82rem;
  font-weight: 500;
  line-height: 1.3;
}

.action-data-textarea {
  width: 100%;
  box-sizing: border-box;
  min-height: 3.47rem;
  resize: vertical;
  line-height: 1.26;
}

.action-data-table {
  width: 100%;
  border-collapse: collapse;
}

.action-data-table th,
.action-data-table td {
  padding: 0.2rem;
  text-align: left;
}

.action-data-table th {
  font-size: 0.72rem;
  color: #4b5563;
}

.action-data-cell {
  width: 100%;
  box-sizing: border-box;
}

.action-data-cell-select {
  min-height: 1.75rem;
}

.action-data-actions-col {
  width: 2rem;
  text-align: center;
  vertical-align: middle;
}

.action-data-row-remove {
  border: none;
  background: transparent;
  color: #9ca3af;
  cursor: pointer;
  font-size: 0.85rem;
  line-height: 1;
  padding: 0.15rem 0.35rem;
  border-radius: 0.25rem;
}

.action-data-row-remove:hover {
  color: #b91c1c;
  background: #fef2f2;
}

.action-data-row-actions {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  margin-top: 0.35rem;
}

.action-data-row-actions-sep {
  display: block;
  width: 1px;
  align-self: stretch;
  min-height: 1.5rem;
  margin: 0 0.35rem 0 0.15rem;
  background: #d1d5db;
  flex-shrink: 0;
}

.action-data-add-row,
.action-data-load-keys,
.action-data-clear-all {
  border: 1px dashed #d1d5db;
  background: #f9fafb;
  color: #374151;
  border-radius: 0.35rem;
  padding: 0.25rem 0.5rem;
  font-size: 0.75rem;
  cursor: pointer;
}

.action-data-add-row:hover,
.action-data-load-keys:hover,
.action-data-clear-all:hover {
  background: #f3f4f6;
}

.action-data-load-keys {
  border-color: #bfdbfe;
  background: #eff6ff;
  color: #1d4ed8;
}

.action-data-load-keys:hover:not(:disabled) {
  background: #dbeafe;
}

.action-data-load-keys:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.action-data-clear-all {
  border-color: #fecaca;
  background: #fef2f2;
  color: #991b1b;
}

.action-data-clear-all:hover {
  background: #fee2e2;
}

.action-data-empty {
  font-size: 0.75rem;
  color: #6b7280;
  font-style: italic;
}

.save-success-flash {
  border-color: #16a34a !important;
  box-shadow: 0 0 0 2px rgba(22, 163, 74, 0.22);
  transition: border-color 120ms ease, box-shadow 120ms ease;
}

.action-add-btn {
  width: 100%;
  background: #f0fdf4;
  color: #166534;
  border: 1px dashed #86efac;
  border-radius: 6px;
  padding: 0.4rem;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.12s, border-color 0.12s;
}

.action-add-btn:hover {
  background: #dcfce7;
  border-color: #4ade80;
}

@media (max-width: 1100px) {
  .layout {
    grid-template-columns: 1fr;
  }
  .work-area {
    grid-template-columns: 1fr;
  }
}
