* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: Arial, Helvetica, sans-serif;
  background: #f4f7fb;
  color: #1d2733;
}

body.modal-open {
  overflow: hidden;
}

.wrap {
  width: min(1000px, calc(100% - 32px));
  margin: 0 auto;
}

.site-header {
  background: #152033;
  color: #fff;
  border-bottom: 1px solid #0e1624;
}

.site-header .wrap {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 0;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  color: #fff;
  text-decoration: none;
  font-weight: 700;
}

.brand-icon {
  width: 42px;
  height: 42px;
  object-fit: cover;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.22);
  flex: 0 0 auto;
}

.top-nav {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
}

.top-nav a {
  color: #dfe8f7;
  text-decoration: none;
}

main.wrap {
  padding: 24px 0 40px;
}

.page-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  margin-bottom: 20px;
}

.banner-panel {
  margin-bottom: 24px;
}

.page-banner {
  display: block;
  width: min(100%, 760px);
  margin: 0 auto;
  border-radius: 8px;
  border: 1px solid #d8e0eb;
  box-shadow: 0 10px 24px rgba(21, 32, 51, 0.1);
}

.page-header h1,
.page-header h2,
.panel h2,
.panel h3 {
  margin: 0 0 8px;
}

.panel {
  background: #fff;
  border: 1px solid #d8e0eb;
  border-radius: 8px;
  padding: 20px;
  margin-bottom: 16px;
}

.section-panel {
  padding: 22px;
}

.compact-metadata-panel {
  padding: 16px 18px;
}

.section-heading {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  margin-bottom: 18px;
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 16px;
}

.stack {
  display: grid;
  gap: 16px;
}

.scenario-meta-form {
  gap: 12px;
}

.compact-meta-section {
  gap: 8px;
}

.compact-meta-grid {
  gap: 10px;
}

.compact-access-options {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  align-items: center;
}

.form-columns {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 12px;
}

.compact-meta-details {
  border-top: 1px solid #d4dbe6;
  padding-top: 14px;
  padding-bottom: 8px;
}

.tool-access-section {
  margin-bottom: 28px;
}

.compact-tool-actions {
  margin-top: 10px;
}

.compact-meta-details summary {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  font-weight: 600;
  color: #2f3f57;
  list-style: none;
}

.compact-meta-details summary::before {
  content: "►";
  font-size: 0.85rem;
  color: #5b6b82;
  flex: 0 0 auto;
}

.compact-meta-details[open] summary::before {
  content: "▼";
}

.compact-meta-details summary::-webkit-details-marker {
  display: none;
}

.compact-details-meta {
  margin: 6px 0 0;
}

.color-field-row {
  display: grid;
  grid-template-columns: minmax(0, 120px) minmax(140px, 1fr) 32px;
  gap: 12px;
  align-items: center;
}

.color-preview-swatch {
  width: 32px;
  height: 32px;
  border: 1px solid #999;
  border-radius: 4px;
  display: inline-block;
}

.checkbox-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 12px;
}

.compact-checkbox-grid {
  gap: 10px;
}

label {
  display: grid;
  gap: 8px;
}

label span {
  font-weight: 600;
}

.checkbox-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.checkbox-row input {
  width: auto;
}

.checkbox-row-tight {
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}

.choice-checkbox-group {
  display: grid;
  gap: 8px;
}

.checkbox-card {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px;
  border: 1px solid #d8e0eb;
  border-radius: 8px;
  background: #fbfcfe;
}

.checkbox-card input {
  width: auto;
  margin-top: 3px;
}

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

input,
textarea,
select {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid #c4cfdd;
  border-radius: 6px;
  background: #fff;
}

textarea {
  resize: vertical;
}

.actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: center;
}

.button {
  display: inline-block;
  padding: 10px 14px;
  border: 1px solid #1d5ed8;
  border-radius: 6px;
  background: #1d5ed8;
  color: #fff;
  text-decoration: none;
  cursor: pointer;
}

.button-secondary {
  border-color: #9fb0c6;
  background: #fff;
  color: #1d2733;
}

.button-header {
  border-color: #7fb1ff;
  background: #fff;
  color: #152033;
}

.button-danger {
  border-color: #c03636;
  background: #c03636;
}

button:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.flash-list,
.error-list {
  display: grid;
  gap: 10px;
  margin-bottom: 16px;
}

.flash,
.error {
  border-radius: 6px;
  padding: 12px 14px;
}

.flash {
  background: #e8f6ea;
  border: 1px solid #b8dfbf;
}

.flash-success {
  background: #e8f6ea;
  border: 1px solid #b8dfbf;
}

.flash-error {
  background: #fdecec;
  border: 1px solid #f0bbbb;
}

.flash-warning {
  background: #fff5df;
  border: 1px solid #efd39a;
}

.error {
  background: #fdecec;
  border: 1px solid #f0bbbb;
}

.meta {
  color: #5e6c80;
}

.step-header {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: flex-start;
}

.step-card {
  border-left: 5px solid #9fb0c6;
}

.step-header-copy {
  min-width: 0;
  flex: 1;
}

.step-text {
  border-left-color: #6f8db7;
}

.step-roll {
  border-left-color: #2e8b57;
}

.step-choice {
  border-left-color: #8f5db7;
}

.step-kicker {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
  margin-bottom: 10px;
}

.step-number {
  font-size: 0.95rem;
  font-weight: 700;
}

.step-type {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 0.82rem;
  font-weight: 700;
  text-transform: capitalize;
}

.step-type-text {
  background: #e8f0fb;
  color: #35547c;
}

.step-type-roll {
  background: #e7f5ec;
  color: #276946;
}

.step-type-choice {
  background: #f1e8fb;
  color: #66418d;
}

.step-actions {
  justify-content: flex-end;
}

.step-table .step-type {
  white-space: nowrap;
}

.inline-move-form {
  display: flex;
  align-items: center;
  gap: 6px;
}

.inline-move-input {
  width: 60px;
  padding: 5px 7px;
}

.compact-row-actions {
  gap: 4px;
}

.compact-row-button {
  padding: 4px 8px;
  font-size: 0.86rem;
}

.clone-to-form {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-wrap: wrap;
}

.clone-to-form select {
  width: 150px;
  padding: 4px 6px;
  min-width: 0;
}

.step-move-form {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.step-move-label {
  display: flex;
  align-items: center;
  margin: 0;
}

.step-move-label span {
  font-weight: 600;
}

.step-move-input {
  width: 92px;
}

.step-summary {
  margin-bottom: 0;
  word-break: break-word;
}

.step-details[hidden] {
  display: none;
}

.step-card.collapsed {
  padding-bottom: 16px;
}

.step-body p {
  margin-top: 0;
}

.choice-list ul {
  margin: 8px 0 0;
  padding-left: 20px;
}

.field-help {
  color: #5e6c80;
  font-size: 0.92rem;
}

.choice-option-list {
  display: grid;
  gap: 14px;
}

.choice-option-card {
  padding: 14px;
}

.choice-option-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 10px;
}

.choice-nested-details {
  margin-top: 8px;
  border-top: 1px solid #e3e8f0;
  padding-top: 12px;
}

.choice-nested-details summary {
  cursor: pointer;
  font-weight: 600;
  color: #2f3f57;
  margin-bottom: 4px;
}

.choice-nested-fields {
  margin-top: 12px;
  gap: 10px;
}

.choice-nested-toggle {
  margin-bottom: 0;
}

.choice-nested-toggle + .choice-nested-help {
  margin-top: -2px;
}

.choice-option-remove {
  flex-shrink: 0;
}

.scene-subrecord-section {
  display: grid;
  gap: 12px;
}

.scene-subrecord-heading {
  margin-bottom: 0;
}

.scene-subrecord-heading h2 {
  margin-bottom: 4px;
}

.scene-event-list {
  display: grid;
  gap: 12px;
}

.scene-event-card {
  padding: 14px;
  margin-bottom: 0;
}

.scene-remove-event-button {
  flex-shrink: 0;
}

.hook-enemy-card {
  border: 1px solid #d8e0eb;
  background: #fbfcfe;
}

.hook-remove-enemy-button {
  flex-shrink: 0;
  padding: 6px 10px;
  font-size: 0.9rem;
}

.hook-enemy-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
  align-items: start;
}

.hook-enemy-column {
  display: grid;
  gap: 12px;
  min-width: 0;
}

.hook-enemy-notes {
  margin-top: 12px;
}

.arena-form-sections {
  gap: 14px;
}

.arena-form-section {
  margin-bottom: 0;
}

.arena-selector-group {
  display: grid;
  gap: 8px;
  align-content: start;
}

.arena-linked-actions {
  gap: 8px;
}

.arena-inline-checkbox {
  margin-top: 4px;
}

.arena-form-actions {
  justify-content: flex-end;
}

.button.is-disabled {
  opacity: 0.55;
  cursor: not-allowed;
  pointer-events: none;
}

.section-gap {
  margin-top: 24px;
}

.add-step-panel {
  margin-top: 20px;
}

.empty-state {
  text-align: center;
}

.table-panel {
  overflow: hidden;
}

.table-wrap {
  overflow-x: auto;
}

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

.data-table th,
.data-table td {
  padding: 12px 14px;
  border-bottom: 1px solid #d7dfe9;
  text-align: left;
  vertical-align: top;
}

.data-table th {
  background: #eef3f9;
  color: #314050;
  font-size: 0.95rem;
}

.data-table tbody tr:last-child td {
  border-bottom: 0;
}

.data-table td code {
  white-space: nowrap;
}

.table-actions {
  flex-wrap: wrap;
}

.scenario-table-actions {
  gap: 6px;
  flex-wrap: nowrap;
}

.scenario-table-actions form {
  margin: 0;
}

.icon-action-button {
  min-width: 34px;
  min-height: 34px;
  padding: 4px 6px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  line-height: 1;
}

.table-actions-compact {
  flex-direction: column;
  align-items: stretch;
  gap: 4px;
}

.compact-table-button {
  width: 100%;
  padding: 4px 8px;
  font-size: 0.82rem;
  line-height: 1.2;
  min-height: 0;
  justify-content: center;
}

.table-actions-compact form {
  margin: 0;
}

.compact-section-header {
  margin-top: 24px;
  margin-bottom: 14px;
}

.compact-table-panel {
  padding: 12px 14px;
}

.compact-table th,
.compact-table td {
  padding: 5px 7px;
  white-space: nowrap;
}

.compact-table td {
  vertical-align: middle;
}

.truncate-cell {
  max-width: 260px;
  overflow: hidden;
  text-overflow: ellipsis;
}

.compact-empty-state {
  padding: 16px;
}

.compact-commands-panel {
  padding: 14px 16px;
  margin-bottom: 16px;
}

.compact-commands-panel h2 {
  margin-bottom: 10px;
}

.profile-command-list {
  display: grid;
  gap: 10px;
}

.profile-command-list p {
  margin: 0;
  line-height: 1.45;
}

.player-profiles-table th,
.player-profiles-table td {
  white-space: normal;
}

.player-profiles-table .truncate-cell {
  max-width: 220px;
}

.arena-list-table {
  width: 100%;
  table-layout: fixed;
}

.arena-list-table th,
.arena-list-table td {
  padding: 6px 8px;
  white-space: normal;
  overflow-wrap: anywhere;
}

.arena-list-table th:nth-child(1),
.arena-list-table td:nth-child(1) {
  width: 92px;
}

.arena-list-table th:nth-child(2),
.arena-list-table td:nth-child(2) {
  width: 170px;
}

.arena-list-table th:nth-child(3),
.arena-list-table td:nth-child(3) {
  width: 100px;
}

.arena-list-table th:nth-child(4),
.arena-list-table td:nth-child(4) {
  width: 90px;
}

.arena-list-table th:nth-child(6),
.arena-list-table td:nth-child(6) {
  width: 140px;
}

.arena-list-table th:nth-child(7),
.arena-list-table td:nth-child(7) {
  width: 118px;
}

.arena-description-cell {
  max-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.arena-thumbnail {
  display: block;
  width: 80px;
  height: 45px;
  border-radius: 6px;
  border: 1px solid #d7dfe9;
  object-fit: cover;
  background: #eef3f9;
}

.arena-thumbnail-placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.74rem;
  color: #5c6f82;
}

.page-section-divider {
  margin: 28px 0 24px;
  border-top: 1px solid #d4dbe6;
}

.filter-panel {
  padding-top: 14px;
  padding-bottom: 14px;
}

.compact-subnav-panel {
  margin-bottom: 16px;
}

.compact-subnav-meta {
  margin-top: 8px;
  margin-bottom: 0;
}

.filter-group {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
}

.filter-label {
  font-weight: 600;
}

.filter-link {
  display: inline-block;
  padding: 8px 12px;
  border: 1px solid #c4cfdd;
  border-radius: 6px;
  color: #314050;
  text-decoration: none;
  background: #fff;
}

.filter-link.is-active {
  border-color: #1d5ed8;
  background: #eaf1ff;
  color: #1d5ed8;
}

.status-badge {
  display: inline-block;
  margin-top: 8px;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 0.82rem;
  font-weight: 700;
}

.status-published {
  background: #e8f6ea;
  color: #236944;
}

.status-unpublished {
  background: #eef2f7;
  color: #5e6c80;
}

.step-report-list,
.compact-report-list {
  margin: 0;
  padding-left: 20px;
}

.step-report-list {
  display: grid;
  gap: 8px;
}

.compact-report-list {
  display: grid;
  gap: 6px;
}

.step-report-link {
  color: #1d5ed8;
  text-decoration: none;
}

.step-report-link:hover {
  text-decoration: underline;
}

.report-diagnostics-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 16px;
}

.compact-report-panel {
  padding: 16px 18px;
}

.diagnostic-table th,
.diagnostic-table td {
  white-space: normal;
  word-break: break-word;
}

.report-ok {
  margin: 0;
  font-weight: 600;
  color: #236944;
}

.scenario-description {
  max-width: 380px;
  white-space: normal;
  word-break: break-word;
  line-height: 1.4;
}

.scenario-list-table.scenario-list-collapsed .scenario-description {
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

code {
  background: #eef3fb;
  padding: 2px 6px;
  border-radius: 4px;
}

@media (max-width: 700px) {
  .site-header .wrap,
  .page-header,
  .step-header,
  .section-heading {
    flex-direction: column;
  }

  .step-actions {
    justify-content: flex-start;
  }

  .compact-access-options,
  .inline-move-form {
    align-items: stretch;
    flex-direction: column;
  }

  .brand {
    align-items: center;
  }

  .hook-enemy-grid {
    grid-template-columns: 1fr;
  }
}
