:root {
  color-scheme: dark light;
  --bg: #0f1115;
  --bg-elevated: #161921;
  --bg-overlay: rgba(15, 17, 21, 0.85);
  --border: #2a2f3b;
  --border-muted: #1c2029;
  --accent: #b419c2;
  --accent-strong: #b717df;
  --text: #f7f8fb;
  --text-muted: #9ea7bb;
  --danger: #ff6b6b;
  font-family: 'Inter', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI',
    sans-serif;
  background-color: var(--bg);
  color: var(--text);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  display: flex;
  flex-direction: column;
}

body.is-mobile-panel-open {
  overflow: hidden;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}

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

button {
  border: none;
  cursor: pointer;
}

.app-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem 1.5rem;
  border-bottom: 1px solid var(--border);
  background: var(--bg-elevated);
  position: sticky;
  top: 0;
  z-index: 20;
}

.header-primary {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.brand__badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--accent);
  color: #041725;
  font-weight: 700;
  padding: 0.35rem 0.5rem;
  border-radius: 0.5rem;
  letter-spacing: 0.08em;
}

.brand__title {
  font-size: 1.5rem;
  font-weight: 600;
  margin: 0;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.button {
  background: var(--accent);
  color: #041725;
  padding: 0.5rem 0.9rem;
  border-radius: 0.5rem;
  font-weight: 600;
  transition: transform 0.1s ease, background 0.2s ease;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  text-align: center;
}

.button:hover {
  transform: translateY(-1px);
  background: var(--accent-strong);
}

.button--ghost {
  background: rgba(77, 196, 255, 0.1);
  color: var(--text);
  border: 1px solid rgba(77, 196, 255, 0.3);
}

.button--ghost:hover {
  background: rgba(77, 196, 255, 0.2);
}

.button--icon {
  width: 2rem;
  height: 2rem;
  padding: 0;
  line-height: 1;
  border-radius: 0.4rem;
  background: rgba(158, 167, 187, 0.1);
  border: 1px solid rgba(158, 167, 187, 0.25);
  color: inherit;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.button--icon:hover {
  background: rgba(158, 167, 187, 0.2);
}

.mobile-toggle {
  display: none;
}

.icon {
  position: relative;
  display: block;
  width: 18px;
  height: 2px;
  background: currentColor;
  border-radius: 999px;
}

.icon::before,
.icon::after {
  content: '';
  position: absolute;
  left: 0;
  width: 100%;
  height: 2px;
  background: currentColor;
  border-radius: 999px;
}

.icon::before {
  top: -6px;
}

.icon::after {
  top: 6px;
}

.icon--list {
  width: 16px;
}

.icon--list::before {
  width: 80%;
}

.icon--list::after {
  width: 60%;
}

.mobile-toggle__label {
  display: none;
}

.mobile-overlay {
  position: fixed;
  inset: 0;
  background: rgba(4, 8, 13, 0.6);
  backdrop-filter: blur(2px);
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.25s ease, visibility 0.25s ease;
  z-index: 25;
  pointer-events: none;
}

.mobile-overlay.is-active {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}

.app-shell {
  flex: 1;
  display: grid;
  grid-template-columns: 260px 1fr;
  min-height: 0;
}

.sidebar {
  border-right: 1px solid var(--border);
  background: var(--bg-elevated);
  display: flex;
  flex-direction: column;
  padding: 1rem;
  gap: 1.5rem;
}

.sidebar__section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.75rem;
}

.sidebar__actions {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
}

.sidebar__section-header h2 {
  font-size: 0.95rem;
  font-weight: 600;
  margin: 0;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
}

.map-list {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  overflow-y: auto;
  padding-right: 0.25rem;
}

.map-item {
  padding: 0.55rem 0.75rem;
  border-radius: 0.45rem;
  border: 1px solid transparent;
  background: rgba(255, 255, 255, 0.02);
  font-weight: 500;
  transition: background 0.2s ease, border 0.2s ease;
  flex-shrink: 0;
}

.map-item:hover {
  background: rgba(77, 196, 255, 0.12);
}

.map-item.is-active {
  border-color: var(--accent);
  background: rgba(77, 196, 255, 0.18);
  color: var(--accent);
}

.main {
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem 1.5rem;
  border-bottom: 1px solid var(--border);
  gap: 1rem;
}

.filters {
  display: flex;
  gap: 0.75rem;
}

.filters select,
.search input {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 0.5rem;
  padding: 0.45rem 0.6rem;
  color: inherit;
  min-width: 120px;
}

.search input {
  min-width: 200px;
}

.content {
  flex: 1;
  display: grid;
  grid-template-columns: minmax(280px, 360px) 1fr;
  min-height: 0;
}

.strat-list {
  border-right: 1px solid var(--border);
  overflow-y: auto;
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.strat-card {
  border: 1px solid var(--border);
  border-radius: 0.75rem;
  padding: 1rem;
  background: rgba(255, 255, 255, 0.02);
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  cursor: pointer;
  transition: border 0.2s ease, transform 0.1s ease;
}

.strat-card:hover {
  transform: translateY(-1px);
  border-color: rgba(77, 196, 255, 0.6);
}

.strat-card__header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 0.5rem;
}

.strat-card__title {
  font-weight: 600;
  margin: 0;
}

.tag-group {
  display: flex;
  gap: 0.35rem;
  flex-wrap: wrap;
}

.tag {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  padding: 0.2rem 0.5rem;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(77, 196, 255, 0.12);
  color: var(--accent);
}

.tag--side {
  color: #f7f8fb;
  background: rgba(255, 193, 7, 0.15);
  border-color: rgba(255, 193, 7, 0.2);
}

.tag--economy {
  background: rgba(130, 255, 196, 0.12);
  border-color: rgba(130, 255, 196, 0.2);
  color: #aef7c4;
}

.strat-card__body {
  font-size: 0.9rem;
  color: var(--text-muted);
  line-height: 1.5;
  max-height: 5rem;
  overflow: hidden;
}

.strat-card__footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.75rem;
  color: var(--text-muted);
}

.strat-card__actions {
  display: flex;
  gap: 0.3rem;
}

.strat-card__actions button {
  background: transparent;
  border: 1px solid rgba(158, 167, 187, 0.25);
  border-radius: 0.35rem;
  padding: 0.25rem 0.45rem;
  color: var(--text-muted);
}

.strat-card__actions button:hover {
  color: var(--text);
  border-color: rgba(158, 167, 187, 0.45);
}

.strat-detail {
  padding: 1.75rem;
  overflow-y: auto;
  position: relative;
}

.empty-state {
  margin-top: 12vh;
  text-align: center;
  color: var(--text-muted);
  max-width: 360px;
  margin-inline: auto;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.strat-detail__header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
  margin-bottom: 1.75rem;
}

.strat-detail__title {
  margin: 0;
  font-size: 1.6rem;
  font-weight: 600;
}

.strat-detail__meta {
  display: flex;
  gap: 0.6rem;
  flex-wrap: wrap;
  color: var(--text-muted);
}

.detail-section {
  margin-bottom: 1.5rem;
}

.detail-section h3 {
  margin: 0 0 0.5rem;
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.step-list,
.assignment-list {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.step-card,
.assignment-card {
  border: 1px solid var(--border);
  border-radius: 0.65rem;
  padding: 0.75rem 0.85rem;
  background: rgba(255, 255, 255, 0.02);
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.step-card strong {
  font-size: 1rem;
}

.step-card__details {
  margin: 0;
  color: var(--text-muted);
  line-height: 1.55;
}

.step-card__media {
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.step-card__media img,
.step-card__media video {
  width: 100%;
  border-radius: 0.65rem;
  background: #000;
  box-shadow: 0 16px 36px rgba(0, 0, 0, 0.28);
  max-height: 360px;
  object-fit: cover;
}

.step-card__media figcaption {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.assignment-card__header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-weight: 600;
}

.assignment-card__task {
  color: var(--text-muted);
  line-height: 1.5;
}

.modal {
  border: none;
  border-radius: 0.8rem;
  padding: 0;
  width: min(720px, 90vw);
  background: var(--bg-elevated);
  color: inherit;
}

.modal::backdrop {
  background: rgba(4, 8, 13, 0.7);
}

.modal__content {
  display: flex;
  flex-direction: column;
  width: 100%;
  height: 100%;
}

.modal__header,
.modal__footer {
  padding: 1rem 1.5rem;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.modal__footer {
  border-top: 1px solid var(--border);
  border-bottom: none;
}

.modal__header h2 {
  margin: 0;
  font-size: 1.15rem;
}

.modal__body {
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 1.15rem;
  max-height: 65vh;
  overflow-y: auto;
}

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

label {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  font-size: 0.85rem;
}

input[type='text'],
input[type='search'],
select,
textarea {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 0.5rem;
  padding: 0.55rem 0.7rem;
  resize: vertical;
}

textarea {
  min-height: 3rem;
}

.media-upload {
  border: 1px dashed var(--border);
  border-radius: 0.85rem;
  padding: 1.1rem;
  background: rgba(255, 255, 255, 0.02);
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.media-upload--compact {
  padding: 0.75rem;
  gap: 0.75rem;
}

.media-upload__header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
  flex-wrap: wrap;
}

.media-upload__header h3 {
  margin: 0;
  font-size: 1rem;
}

.media-upload__description {
  margin: 0.25rem 0 0;
  color: var(--text-muted);
  font-size: 0.85rem;
  max-width: 340px;
  line-height: 1.5;
}

.media-upload__actions {
  display: flex;
  gap: 0.5rem;
  align-items: center;
}

.media-upload--compact .media-upload__actions {
  width: 100%;
  justify-content: space-between;
  flex-wrap: wrap;
}

.media-upload__button {
  cursor: pointer;
}

.media-upload__preview {
  border: 1px solid var(--border-muted);
  border-radius: 0.75rem;
  min-height: 160px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0.75rem;
  background: rgba(4, 23, 37, 0.35);
  overflow: hidden;
  position: relative;
}

.media-upload--compact .media-upload__preview {
  min-height: 130px;
}

.media-upload__preview.has-media {
  justify-content: flex-start;
  background: rgba(255, 255, 255, 0.03);
}

.media-upload__placeholder {
  margin: 0;
  text-align: center;
  color: var(--text-muted);
}

.utility-media-preview {
  margin: 0;
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.utility-media-preview img,
.utility-media-preview video {
  width: 100%;
  max-height: 320px;
  object-fit: cover;
  border-radius: 0.65rem;
  background: #000;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.25);
}

.utility-media-preview figcaption {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.dynamic-item__main--step {
  gap: 0.6rem;
}

.step-media {
  width: 100%;
}

.dynamic-section {
  border: 1px solid var(--border);
  border-radius: 0.75rem;
  padding: 1rem;
  background: rgba(255, 255, 255, 0.02);
  display: flex;
  flex-direction: column;
  gap: 0.8rem;
}

.dynamic-section__header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.dynamic-section__header h3 {
  margin: 0;
  font-size: 0.95rem;
}

.dynamic-section__list {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.dynamic-item {
  display: flex;
  gap: 0.6rem;
  align-items: flex-start;
}

.dynamic-item__main {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.dynamic-item__main--assignment {
  display: grid;
  grid-template-columns: 160px 150px 1fr;
  gap: 0.5rem;
}

.roster-input {
  display: flex;
  gap: 0.5rem;
}

.roster-input input {
  flex: 1;
}

.roster-list {
  margin: 0;
  padding: 0;
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.roster-item {
  padding: 0.55rem 0.6rem;
  border-radius: 0.6rem;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.02);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.text-muted {
  color: var(--text-muted);
}

@media (max-width: 960px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    border-right: none;
    border-bottom: 1px solid var(--border);
    padding-bottom: 0.75rem;
    gap: 1rem;
  }

  .map-list {
    flex-direction: row;
    flex-wrap: nowrap;
    overflow-x: auto;
    gap: 0.5rem;
    padding-bottom: 0.5rem;
    margin: 0 -0.25rem;
    padding-inline: 0.25rem;
  }

  .map-item {
    flex: 0 0 auto;
    white-space: nowrap;
  }

  .content {
    display: block;
    grid-template-columns: none;
  }

  .strat-list {
    border-right: none;
    border-bottom: 1px solid var(--border);
    max-height: min(380px, 50vh);
  }
}

@media (max-width: 640px) {
  .mobile-toggle {
    display: inline-flex;
  }

  .mobile-toggle__label {
    display: inline;
  }

  .header-primary {
    width: 100%;
    justify-content: space-between;
  }

  .app-header {
    flex-direction: column;
    align-items: stretch;
    gap: 0.75rem;
    padding: 0.9rem 1rem;
  }

  .brand__title {
    font-size: 1.3rem;
  }

  .header-actions {
    width: 100%;
    flex-wrap: wrap;
    justify-content: space-between;
    gap: 0.5rem;
  }

  .header-actions > * {
    flex: 1 1 calc(50% - 0.25rem);
  }

  .header-actions label {
    text-align: center;
  }

  .toolbar {
    flex-direction: column;
    align-items: stretch;
    padding: 0.8rem 1rem;
  }

  .filters {
    flex-wrap: wrap;
    width: 100%;
    gap: 0.5rem;
  }

  .filters select {
    flex: 1 1 calc(50% - 0.5rem);
    min-width: 0;
  }

  .toolbar__right {
    display: flex;
    justify-content: space-between;
    align-items: stretch;
    gap: 0.5rem;
    flex-wrap: wrap;
  }

  .toolbar__right .search {
    flex: 1 1 100%;
  }

  .toolbar__right .search input {
    width: 100%;
    min-width: 0;
  }

  .toolbar__right .mobile-toggle {
    order: 2;
  }

  .toolbar__right .button[data-action='add-strat'] {
    order: 3;
  }

  .toolbar__right .button {
    flex: 1 1 100%;
  }

  .media-upload {
    padding: 1rem;
  }

  .media-upload__actions {
    width: 100%;
  }

  .media-upload__actions .button {
    flex: 1 1 auto;
    width: 100%;
  }

  .media-upload__preview {
    min-height: 140px;
  }

  .strat-card {
    padding: 0.85rem;
  }

  .strat-card__footer {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.6rem;
  }

  .strat-card__actions {
    width: 100%;
    flex-wrap: wrap;
    gap: 0.4rem;
  }

  .sidebar {
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    width: min(320px, 80vw);
    max-width: 360px;
    padding: calc(4.5rem + env(safe-area-inset-top)) 1.25rem calc(1.5rem + env(safe-area-inset-bottom));
    border-right: 1px solid var(--border);
    border-bottom: none;
    box-shadow: 0 20px 40px rgba(4, 8, 13, 0.45);
    transform: translateX(-105%);
    transition: transform 0.3s ease;
    pointer-events: none;
    z-index: 30;
    flex-direction: column;
    gap: 1.5rem;
    overflow-y: auto;
  }

  .sidebar.is-open {
    transform: translateX(0);
    pointer-events: auto;
  }

  .map-list {
    flex-direction: column;
    overflow-y: auto;
    padding: 0;
    margin: 0;
    max-height: none;
  }

  .content {
    display: block;
    grid-template-columns: none;
  }

  .strat-list {
    position: fixed;
    top: 0;
    bottom: 0;
    right: 0;
    width: min(360px, 85vw);
    max-width: 420px;
    padding: calc(4.5rem + env(safe-area-inset-top)) 1.25rem calc(1.75rem + env(safe-area-inset-bottom));
    background: var(--bg-elevated);
    border-left: 1px solid var(--border);
    border-bottom: none;
    box-shadow: 0 20px 40px rgba(4, 8, 13, 0.45);
    overflow-y: auto;
    transform: translateX(105%);
    transition: transform 0.3s ease;
    pointer-events: none;
    z-index: 30;
  }

  .strat-list.is-open {
    transform: translateX(0);
    pointer-events: auto;
  }

  .strat-detail {
    padding: 1.25rem 1rem 2.75rem;
  }

  .strat-detail__header {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.75rem;
  }

  .strat-detail__header .strat-card__actions {
    width: 100%;
    justify-content: flex-start;
    gap: 0.4rem;
    flex-wrap: wrap;
  }

  .dynamic-item__main--assignment {
    grid-template-columns: 1fr;
  }

  .dynamic-item {
    flex-direction: column;
    align-items: stretch;
  }

  .dynamic-item .button--icon {
    align-self: flex-end;
  }

  .modal {
    width: calc(100vw - 1.5rem);
    max-height: 90vh;
  }

  .modal__body {
    max-height: none;
  }

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