:root {
  color-scheme: light;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: #f5f7f8;
  color: #17242b;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
}

body[data-state="admin"] {
  height: 100dvh;
  overflow: hidden;
}

button,
input,
textarea {
  font: inherit;
}

button {
  border: 0;
  border-radius: 6px;
  background: #005c83;
  color: #fff;
  cursor: pointer;
  font-weight: 700;
  min-height: 40px;
  padding: 0 16px;
}

button:hover {
  background: #004d6d;
}

button.danger {
  background: #b42318;
}

button.danger:hover {
  background: #912018;
}

input,
textarea {
  width: 100%;
  border: 1px solid #c9d4d8;
  border-radius: 6px;
  background: #fff;
  color: #17242b;
  padding: 10px 12px;
}

textarea {
  resize: vertical;
}

.instructions-field {
  display: grid;
  gap: 6px;
}

label {
  display: grid;
  gap: 6px;
  color: #4a5d66;
  font-size: 0.85rem;
  font-weight: 700;
}

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

.field-header span {
  color: #4a5d66;
  font-size: 0.85rem;
  font-weight: 700;
}

[data-view] {
  display: none;
}

body[data-state="signed-out"] [data-view="signed-out"],
body[data-state="loading"] [data-view="loading"],
body[data-state="denied"] [data-view="denied"],
body[data-state="admin"] [data-view="admin"] {
  display: grid;
}

.auth-panel,
.loading-panel,
.denied-panel {
  min-height: 100vh;
  place-content: center;
  gap: 24px;
  padding: 32px;
}

.auth-panel,
.denied-panel {
  grid-template-columns: minmax(260px, 360px);
}

.logo {
  width: 72px;
  height: 72px;
}

.auth-panel h1,
.denied-panel h1 {
  margin: 16px 0 8px;
  font-size: 2rem;
}

.auth-panel p,
.denied-panel p {
  margin: 0;
  color: #526872;
}

.login-form {
  display: grid;
  gap: 16px;
}

.error {
  min-height: 20px;
  color: #b42318;
  font-weight: 700;
}

.admin-shell {
  height: 100dvh;
  grid-template-columns: auto 1fr;
  overflow: hidden;
}

.nav-rail {
  align-content: start;
  background: #0d3444;
  display: grid;
  gap: 8px;
  padding: 12px;
  width: 188px;
}

.nav-rail.collapsed {
  width: 64px;
}

.nav-rail.collapsed .nav-item span {
  display: none;
}

.nav-rail button {
  align-items: center;
  background: transparent;
  color: #e7f2f6;
  display: flex;
  gap: 10px;
  justify-content: flex-start;
}

.nav-rail button:hover,
.nav-rail button.active {
  background: #005c83;
}

.nav-rail i {
  width: 20px;
}

.admin-page {
  display: none;
  grid-template-columns: minmax(320px, 420px) 1fr;
  height: 100dvh;
  min-width: 0;
  overflow: hidden;
}

.admin-page.active {
  display: grid;
}

.activity-list-panel {
  display: grid;
  grid-template-rows: auto auto auto 1fr;
  gap: 16px;
  border-right: 1px solid #d9e1e5;
  background: #fff;
  height: 100dvh;
  min-height: 0;
  overflow: hidden;
  padding: 20px;
}

.secondary-link {
  align-items: center;
  background: #eef3f5;
  border-radius: 6px;
  color: #17242b;
  display: inline-flex;
  font-weight: 700;
  min-height: 40px;
  padding: 0 14px;
  text-decoration: none;
}

.secondary-link[aria-disabled="true"] {
  opacity: 0.45;
  pointer-events: none;
}

.activity-list-panel header,
.editor-header,
.list-actions,
.editor-actions {
  align-items: center;
  display: flex;
  gap: 12px;
  justify-content: space-between;
}

.eyebrow {
  color: #697c85;
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0;
  margin: 0 0 4px;
  text-transform: uppercase;
}

h1,
h2 {
  margin: 0;
}

.count,
.status {
  color: #526872;
  min-height: 22px;
}

.status {
  font-weight: 700;
}

.activity-list {
  display: grid;
  align-content: start;
  gap: 8px;
  min-height: 0;
  overflow-y: auto;
  padding-right: 4px;
}

.activity-item {
  border: 1px solid #dde6ea;
  border-radius: 6px;
  background: #fff;
  color: #17242b;
  display: grid;
  gap: 4px;
  min-height: 68px;
  padding: 10px 12px;
  text-align: left;
}

.activity-item:hover,
.activity-item.active {
  border-color: #005c83;
  background: #edf7fb;
}

.activity-item strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.activity-item span {
  color: #657981;
  font-size: 0.8rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.editor-panel {
  height: 100dvh;
  min-width: 0;
  overflow-y: auto;
  padding: 24px;
}

#activity-form {
  display: grid;
  gap: 24px;
  max-width: 1180px;
}

.form-grid {
  display: grid;
  gap: 18px;
  grid-template-columns: repeat(2, minmax(240px, 1fr));
}

.wide {
  grid-column: 1 / -1;
}

.image-manager {
  display: grid;
  gap: 10px;
}

.dropzone {
  align-items: center;
  border: 2px dashed #b8c8cf;
  border-radius: 6px;
  color: #526872;
  cursor: pointer;
  display: grid;
  gap: 4px;
  min-height: 112px;
  padding: 18px;
  place-items: center;
  text-align: center;
}

.dropzone strong {
  color: #17242b;
}

.dropzone.dragging,
.dropzone:focus {
  background: #edf7fb;
  border-color: #005c83;
  outline: 0;
}

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

.empty-images {
  border: 1px solid #dde6ea;
  border-radius: 6px;
  color: #657981;
  margin: 0;
  padding: 14px;
}

.image-card {
  align-items: center;
  border: 1px solid #dde6ea;
  border-radius: 6px;
  display: grid;
  gap: 10px;
  grid-template-columns: 112px 1fr auto;
  min-width: 0;
  padding: 10px;
}

.image-card img {
  aspect-ratio: 4 / 3;
  background: #eef3f5;
  border-radius: 4px;
  height: auto;
  object-fit: cover;
  width: 112px;
}

.image-card span {
  color: #526872;
  font-size: 0.78rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.image-card-error img {
  border: 1px solid #b42318;
}

.image-delete {
  min-height: 36px;
}

.related-panel,
.affiliate-links {
  display: grid;
  gap: 10px;
}

.ordered-list,
.affiliate-link-list {
  display: grid;
  gap: 8px;
}

.ordered-item,
.affiliate-row {
  align-items: center;
  border: 1px solid #dde6ea;
  border-radius: 6px;
  display: grid;
  gap: 8px;
  grid-template-columns: 1fr auto auto;
  padding: 10px;
}

.ordered-item strong,
.ordered-item span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ordered-item a {
  color: inherit;
  text-decoration-color: #00769b;
  text-decoration-thickness: 2px;
  text-underline-offset: 3px;
}

.equipment-reference-item {
  grid-template-columns: 1fr;
}

.ordered-item span {
  color: #657981;
  font-size: 0.8rem;
}

.subtle-count {
  color: #657981;
  font-size: 0.85rem;
  font-weight: 700;
}

.ordered-controls {
  display: flex;
  gap: 6px;
}

.ordered-controls button,
.affiliate-row button {
  min-height: 34px;
  padding: 0 10px;
}

.affiliate-row {
  grid-template-columns: 1fr 1.4fr auto;
}

.EasyMDEContainer {
  color: #17242b;
  font-weight: 400;
}

.EasyMDEContainer .CodeMirror {
  border-color: #c9d4d8;
  border-radius: 0 0 6px 6px;
  min-height: 320px;
  padding: 10px 12px;
}

.editor-toolbar {
  background: #f4f7f8;
  border-color: #c9d4d8;
  border-radius: 6px 6px 0 0;
}

.editor-toolbar button {
  background: transparent;
  border: 1px solid transparent;
  color: #17242b;
  font-weight: 700;
  height: 32px;
  min-height: 32px;
  min-width: 32px;
  padding: 0 8px;
}

.editor-toolbar button:hover,
.editor-toolbar button.active {
  background: #e3edf1;
  border-color: #b8c8cf;
  color: #17242b;
}

.editor-toolbar i.separator {
  border-left-color: #b8c8cf;
  border-right-color: #fff;
}

.editor-preview,
.editor-preview-side {
  color: #17242b;
}

.confirm-dialog {
  border: 0;
  border-radius: 8px;
  box-shadow: 0 24px 80px rgba(23, 36, 43, 0.28);
  max-width: 440px;
  padding: 0;
  width: calc(100% - 40px);
}

.confirm-dialog::backdrop {
  background: rgba(23, 36, 43, 0.42);
}

.confirm-card {
  display: grid;
  gap: 24px;
  padding: 24px;
}

.confirm-card h2 {
  margin: 0 0 8px;
}

.confirm-message {
  color: #526872;
  margin: 0;
}

.confirm-actions {
  display: flex;
  gap: 12px;
  justify-content: flex-end;
}

.confirm-actions button:first-child {
  background: #eef3f5;
  color: #17242b;
}

@media (max-width: 860px) {
  body[data-state="admin"] {
    height: auto;
    overflow: auto;
  }

  .admin-shell {
    height: auto;
    grid-template-columns: 1fr;
    overflow: visible;
  }

  .nav-rail {
    display: flex;
    overflow-x: auto;
    width: auto;
  }

  .nav-rail.collapsed {
    width: auto;
  }

  .nav-rail.collapsed .nav-item span {
    display: inline;
  }

  .admin-page {
    height: auto;
    grid-template-columns: 1fr;
    overflow: visible;
  }

  .activity-list-panel {
    border-right: 0;
    height: 46dvh;
    min-height: 320px;
  }

  .editor-panel {
    height: auto;
    overflow: visible;
  }

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

  .image-card {
    grid-template-columns: 88px 1fr;
  }

  .image-card img {
    width: 88px;
  }

  .image-delete {
    grid-column: 1 / -1;
  }

  .ordered-item,
  .affiliate-row {
    grid-template-columns: 1fr;
  }

  .editor-header {
    align-items: flex-start;
    flex-direction: column;
  }
}
