/* Create Story shell — Zone Layout mockup tokens (no Tailwind CDN) */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;600;700&family=Manrope:wght@600;700;800&display=swap');
@import url('https://fonts.googleapis.com/css2?family=Material+Symbols+Outlined:opsz,wght,FILL,GRAD@24,400,0,0');

.create-story-shell {
  --cs-primary: #005bbf;
  --cs-primary-container: #1a73e8;
  --cs-on-primary: #ffffff;
  --cs-on-primary-container: #ffffff;
  --cs-surface: #faf8ff;
  --cs-background: #faf8ff;
  --cs-on-surface: #131b2e;
  --cs-on-surface-variant: #414754;
  --cs-surface-container: #eaedff;
  --cs-surface-container-low: #f2f3ff;
  --cs-surface-container-high: #e2e7ff;
  --cs-surface-container-lowest: #ffffff;
  --cs-outline-variant: #c1c6d6;
  --cs-secondary-fixed: #d5e3fc;
  --cs-container-padding: 20px;
  --cs-section-margin: 16px;
  --cs-stack-gap: 16px;
  --cs-font-headline: "Manrope", system-ui, sans-serif;
  --cs-font-body: "Inter", system-ui, sans-serif;

  height: 100%;
  min-height: 100%;
  max-height: 100dvh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--cs-background);
  color: var(--cs-on-surface);
  font-family: var(--cs-font-body);
  font-size: 16px;
  line-height: 24px;
  -webkit-tap-highlight-color: transparent;
}

.create-story-shell .material-symbols-outlined {
  font-variation-settings: "FILL" 0, "wght" 400, "GRAD" 0, "opsz" 24;
  font-family: "Material Symbols Outlined", sans-serif;
  font-size: 24px;
  line-height: 1;
  user-select: none;
}

.create-story-shell__header {
  position: sticky;
  top: 0;
  z-index: 40;
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 100%;
  padding: 12px var(--cs-container-padding);
  background: var(--cs-surface);
  border-bottom: 1px solid var(--cs-outline-variant);
}

.create-story-shell__header-left {
  display: flex;
  align-items: center;
  gap: 12px;
}

.create-story-shell__icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 8px;
  margin: 0;
  border: none;
  border-radius: 9999px;
  background: transparent;
  color: var(--cs-on-surface-variant);
  cursor: pointer;
}

.create-story-shell__icon-btn:hover {
  background: var(--cs-surface-container-low);
}

.create-story-shell__icon-btn--primary {
  color: var(--cs-primary);
}

.create-story-shell__title {
  margin: 0;
  font-family: var(--cs-font-headline);
  font-size: 22px;
  line-height: 28px;
  font-weight: 700;
  letter-spacing: -0.01em;
  color: var(--cs-on-surface);
}

.create-story-shell__stepper {
  background: var(--cs-surface-container-lowest);
  padding: 16px var(--cs-container-padding);
  border-bottom: 1px solid var(--cs-outline-variant);
}

.create-story-shell__stepper-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 4px;
  overflow-x: auto;
}

.create-story-shell__step {
  display: flex;
  flex-direction: column;
  align-items: center;
  flex: 1;
  min-width: 64px;
}

.create-story-shell__step-circle {
  width: 32px;
  height: 32px;
  border-radius: 9999px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 12px;
  margin-bottom: 4px;
  background: var(--cs-surface-container-high);
  color: var(--cs-on-surface-variant);
}

.create-story-shell__step--active .create-story-shell__step-circle {
  background: var(--cs-primary-container);
  color: var(--cs-on-primary-container);
}

.create-story-shell__step-label {
  font-size: 12px;
  line-height: 16px;
  letter-spacing: 0.05em;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--cs-on-surface-variant);
}

.create-story-shell__step--active .create-story-shell__step-label {
  color: var(--cs-primary);
}

.create-story-shell__step-connector {
  height: 2px;
  flex: 1;
  min-width: 20px;
  margin-bottom: 20px;
  background: var(--cs-outline-variant);
}

.create-story-shell__step-connector--done {
  background: var(--cs-primary-container);
}

.create-story-shell__body {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  display: flex;
  gap: 24px;
  width: 100%;
  max-width: 1100px;
  margin: 0 auto;
  padding: var(--cs-section-margin) var(--cs-container-padding) 24px;
  box-sizing: border-box;
}

.create-story-shell__body--fill {
  max-width: none;
  width: 100%;
  margin: 0;
  overflow: hidden;
  padding: 8px 12px 8px;
  gap: 12px;
  flex: 1;
  min-height: 0;
  align-items: stretch;
}

.create-story-shell__main {
  flex: 1;
  max-width: 42rem;
  margin: 0 auto;
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: var(--cs-stack-gap);
  min-height: 0;
}

.create-story-shell__main--fill {
  max-width: none;
  margin: 0;
  flex: 1;
  min-width: 0;
  min-height: 0;
  height: 100%;
  overflow: hidden;
  gap: 8px;
}

.create-story-shell:has(.create-story-shell__body--fill) .create-story-shell__footer-inner {
  max-width: none;
}

.create-story-shell__sidebar {
  display: none;
  width: 260px;
  flex-shrink: 0;
}

@media (min-width: 900px) {
  .create-story-shell__sidebar {
    display: block;
  }

  .create-story-shell__main {
    margin: 0;
  }
}

/* Fill step: preview-dominant workspace */
.cs-fill-workspace {
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  min-height: 0;
  gap: 12px;
  width: 100%;
  height: 100%;
}

.cs-fill-workspace__preview {
  flex: 1 1 55%;
  min-height: 240px;
  min-width: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.cs-fill-workspace__editor {
  flex: 0 1 auto;
  max-height: 45%;
  min-height: 0;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: var(--cs-stack-gap);
  padding-right: 4px;
}

/* Side-by-side as soon as there is room for preview + ~360px rail */
@media (min-width: 720px) {
  .cs-fill-workspace {
    flex-direction: row;
    align-items: stretch;
    gap: 16px;
  }

  .cs-fill-workspace__preview {
    flex: 1 1 auto;
    min-height: 0;
    max-height: none;
  }

  .cs-fill-workspace__editor {
    flex: 0 0 min(400px, 38%);
    width: min(400px, 38%);
    max-height: none;
    max-width: 400px;
  }
}

.cs-fill-glimpse {
  flex: 1;
  min-height: 0;
  height: 100%;
  width: 100%;
  border-radius: 12px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.cs-fill-glimpse .zone-glimpse-preview,
.cs-fill-glimpse .glimpse-embedded {
  flex: 1 !important;
  min-height: 0 !important;
  height: 100% !important;
  max-height: none !important;
}

.cs-field textarea.cs-field__content {
  min-height: 14rem;
  resize: vertical;
  width: 100%;
  box-sizing: border-box;
}

.create-story-shell__footer {
  position: relative;
  z-index: 50;
  flex-shrink: 0;
  margin-top: 0;
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(12px);
  border-top: 1px solid var(--cs-outline-variant);
  padding: 16px var(--cs-container-padding) 16px;
  box-shadow: 0 -4px 24px rgba(19, 27, 46, 0.06);
  width: 100%;
  box-sizing: border-box;
}

.create-story-shell__footer-inner {
  max-width: 42rem;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.create-story-shell__btn-primary {
  width: 100%;
  height: 56px;
  border: none;
  border-radius: 12px;
  background: var(--cs-primary);
  color: var(--cs-on-primary);
  font-family: var(--cs-font-body);
  font-size: 16px;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  cursor: pointer;
  box-shadow: 0 10px 24px rgba(0, 91, 191, 0.2);
}

.create-story-shell__btn-primary:disabled {
  opacity: 0.55;
  cursor: not-allowed;
  box-shadow: none;
}

.create-story-shell__btn-primary:not(:disabled):active {
  transform: scale(0.98);
}

.create-story-shell__btn-secondary {
  width: 100%;
  height: 48px;
  border-radius: 12px;
  border: 1px solid var(--cs-primary);
  background: transparent;
  color: var(--cs-primary);
  font-family: var(--cs-font-body);
  font-size: 16px;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  cursor: pointer;
}

.create-story-shell__btn-secondary:hover {
  background: rgba(0, 91, 191, 0.05);
}

.create-story-shell__bottom-nav {
  display: none;
}

@media (min-width: 768px) {
  .create-story-shell__bottom-nav {
    display: flex;
    position: relative;
    width: 100%;
    z-index: 45;
    justify-content: space-around;
    align-items: center;
    padding: 8px 16px 12px;
    background: var(--cs-surface-container);
    box-shadow: 0 -2px 12px rgba(19, 27, 46, 0.08);
    border-radius: 12px 12px 0 0;
    box-sizing: border-box;
  }

  .create-story-shell__body {
    padding-bottom: 24px;
  }
}

.create-story-shell__bottom-nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  border: none;
  background: transparent;
  color: var(--cs-on-surface-variant);
  padding: 8px;
  cursor: pointer;
  font-family: var(--cs-font-body);
}

.create-story-shell__bottom-nav-item:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.create-story-shell__bottom-nav-item.active {
  background: var(--cs-primary-container);
  color: var(--cs-on-primary-container);
  border-radius: 9999px;
  padding: 4px 16px;
  transform: scale(0.95);
}

.create-story-shell__bottom-nav-label {
  font-size: 12px;
  line-height: 16px;
  letter-spacing: 0.05em;
  font-weight: 700;
  text-transform: uppercase;
}

.cs-mobile-pages {
  display: block;
  margin-top: 8px;
}

@media (min-width: 900px) {
  .cs-mobile-pages {
    display: none;
  }
}

/* Story map */
.story-map {
  background: var(--cs-surface-container-lowest);
  border: 1px solid var(--cs-outline-variant);
  border-radius: 12px;
  padding: 20px;
}

.story-map__layers {
  display: flex;
  flex-direction: column;
  gap: 16px;
  margin-top: 16px;
}

.story-map__layer-label {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--cs-on-surface-variant);
  margin-bottom: 8px;
}

.story-map__nodes {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.story-map__node {
  display: inline-flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  min-width: 140px;
  padding: 12px 14px;
  border: 1px solid var(--cs-outline-variant);
  border-radius: 12px;
  background: #fff;
  cursor: pointer;
  font-family: var(--cs-font-body);
  text-align: left;
  color: var(--cs-on-surface);
}

.story-map__node:hover {
  border-color: var(--cs-primary);
}

.story-map-node--current {
  border-color: var(--cs-primary);
  box-shadow: 0 0 0 2px rgba(0, 91, 191, 0.2);
  font-weight: 600;
}

.story-map-node--complete {
  border-left: 4px solid #198754;
}

.story-map-node--empty {
  border-left: 4px solid var(--cs-outline-variant);
}

.story-map-node--problem {
  border-left: 4px solid #ba1a1a;
}

.story-map__mark {
  font-size: 14px;
}

.story-map__name {
  font-size: 14px;
  font-weight: 600;
}

.story-map__meta {
  font-size: 12px;
  color: var(--cs-on-surface-variant);
}

.story-map__unreachable {
  margin-top: 16px;
  padding: 12px;
  border-radius: 8px;
  background: #ffdad6;
  color: #93000a;
}

.cs-view-toggle {
  display: flex;
  gap: 0;
  border: 1px solid var(--cs-outline-variant);
  border-radius: 8px;
  overflow: hidden;
  margin-bottom: 12px;
}

.cs-view-toggle button {
  flex: 1;
  border: none;
  background: var(--cs-surface-container-lowest);
  padding: 8px 12px;
  font-family: var(--cs-font-body);
  font-size: 13px;
  font-weight: 600;
  color: var(--cs-on-surface-variant);
  cursor: pointer;
}

.cs-view-toggle button.active {
  background: var(--cs-primary-container);
  color: var(--cs-on-primary-container);
}

.cs-journey-toggle {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin: 0 0 12px;
  font-family: var(--cs-font-body);
  font-size: 13px;
  color: var(--cs-on-surface-variant);
  cursor: pointer;
}

.cs-desktop-only {
  display: none;
}

.cs-mobile-only {
  display: block;
}

@media (min-width: 768px) {
  .cs-desktop-only {
    display: block;
  }

  .cs-mobile-only {
    display: none;
  }
}

.create-story-shell__path {
  font-size: 14px;
  line-height: 20px;
  color: var(--cs-on-surface-variant);
}

.create-story-shell__path strong {
  color: var(--cs-on-surface);
  font-weight: 600;
}

.create-story-shell__error {
  padding: 12px 16px;
  border-radius: 12px;
  background: #ffdad6;
  color: #93000a;
  font-size: 14px;
}

/* Zone cards */
.cs-zone-card {
  position: relative;
  overflow: hidden;
  background: var(--cs-surface-container-lowest);
  border: 1px solid var(--cs-outline-variant);
  border-radius: 12px;
  padding: 16px;
  box-shadow: 0 1px 2px rgba(19, 27, 46, 0.04);
}

.cs-zone-card--reusable {
  padding: 16px;
}

.cs-zone-card--reusable::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  width: 4px;
  height: 100%;
  background: var(--cs-secondary-fixed);
}

.cs-zone-card--edit {
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: var(--cs-stack-gap);
}

.cs-zone-card__row {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
}

.cs-zone-card__title {
  margin: 0;
  font-size: 16px;
  line-height: 24px;
  font-weight: 600;
  color: var(--cs-on-surface);
}

.cs-zone-card__title--lg {
  font-family: var(--cs-font-headline);
  font-size: 22px;
  line-height: 28px;
  font-weight: 600;
}

.cs-zone-card__hint {
  margin: 4px 0 0;
  font-size: 13px;
  line-height: 18px;
  color: var(--cs-on-surface-variant);
}

.cs-zone-card__preview-text {
  margin-top: 8px;
  color: var(--cs-on-surface);
  font-style: italic;
}

.cs-badge {
  display: inline-block;
  font-size: 12px;
  line-height: 16px;
  letter-spacing: 0.05em;
  font-weight: 700;
  text-transform: uppercase;
  padding: 2px 8px;
  border-radius: 4px;
  background: var(--cs-surface-container-high);
  color: var(--cs-on-surface-variant);
  white-space: nowrap;
}

.cs-field {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.cs-field label {
  font-size: 16px;
  font-weight: 600;
  color: var(--cs-on-surface);
}

.cs-field input,
.cs-field textarea {
  width: 100%;
  box-sizing: border-box;
  border: 1px solid var(--cs-outline-variant);
  border-radius: 8px;
  background: #fff;
  font-family: var(--cs-font-body);
  font-size: 16px;
  line-height: 24px;
  color: var(--cs-on-surface);
  outline: none;
  padding: 12px 16px;
}

.cs-field input {
  height: 48px;
}

.cs-field textarea {
  min-height: 144px;
  resize: vertical;
}

.cs-field input:focus,
.cs-field textarea:focus {
  border-color: var(--cs-primary);
  box-shadow: 0 0 0 2px rgba(0, 91, 191, 0.25);
}

.cs-zone-preview {
  position: relative;
  border-radius: 12px;
  overflow: hidden;
  border: 1px solid var(--cs-outline-variant);
  aspect-ratio: 16 / 9;
  background: var(--cs-surface-container);
}

.cs-zone-preview__img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.cs-zone-preview__overlay {
  position: absolute;
  inset: 0;
  background: linear-gradient(to top, rgba(0, 0, 0, 0.4), transparent);
}

.cs-zone-preview__caption {
  position: absolute;
  bottom: 16px;
  left: 16px;
  color: #fff;
}

.cs-zone-preview__caption .cs-badge {
  background: transparent;
  color: rgba(255, 255, 255, 0.9);
  padding: 0;
}

.cs-zone-preview__caption h3 {
  margin: 4px 0 0;
  font-size: 16px;
  font-weight: 600;
}

/* Page tree */
.cs-page-tree {
  background: var(--cs-surface-container-lowest);
  border: 1px solid var(--cs-outline-variant);
  border-radius: 12px;
  padding: 16px;
  position: sticky;
  top: 88px;
}

.cs-page-tree__heading {
  margin: 0 0 12px;
  font-size: 12px;
  letter-spacing: 0.05em;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--cs-on-surface-variant);
}

.cs-page-tree__item {
  display: block;
  width: 100%;
  text-align: left;
  border: none;
  background: transparent;
  padding: 8px 10px;
  border-radius: 8px;
  cursor: pointer;
  font-family: var(--cs-font-body);
  font-size: 14px;
  color: var(--cs-on-surface);
}

.cs-page-tree__item:hover {
  background: var(--cs-surface-container-low);
}

.cs-page-tree__item--current {
  background: var(--cs-surface-container);
  font-weight: 600;
  color: var(--cs-primary);
}

.cs-page-tree__item--incomplete {
  color: var(--cs-on-surface-variant);
}

.cs-page-tree__mark {
  display: inline-block;
  width: 1.1em;
  margin-right: 4px;
}

/* Structure drawer / overview */
.cs-drawer-backdrop {
  position: fixed;
  inset: 0;
  z-index: 60;
  background: rgba(19, 27, 46, 0.4);
}

.cs-drawer {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 61;
  max-height: 80vh;
  overflow: auto;
  background: var(--cs-surface-container-lowest);
  border-radius: 16px 16px 0 0;
  padding: 20px var(--cs-container-padding) 32px;
  box-shadow: 0 -8px 32px rgba(19, 27, 46, 0.15);
}

.cs-overview {
  background: var(--cs-surface-container-lowest);
  border: 1px solid var(--cs-outline-variant);
  border-radius: 12px;
  padding: 20px;
}

.cs-overview h2 {
  margin: 0 0 8px;
  font-family: var(--cs-font-headline);
  font-size: 22px;
  font-weight: 600;
}

.cs-overview p {
  margin: 0 0 16px;
  color: var(--cs-on-surface-variant);
  font-size: 14px;
}

.cs-overview ul {
  list-style: none;
  padding: 0;
  margin: 0 0 20px;
}

.cs-overview li {
  padding: 6px 0;
  font-size: 14px;
}

.cs-link-btn {
  border: none;
  background: none;
  color: var(--cs-primary);
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
  padding: 0;
  text-decoration: underline;
}
