.ig-story-screen {
  --ig-sheet: #fff8f1;
  --ig-sheet-strong: #fff2e7;
  --ig-surface: #fffdf9;
  --ig-line: rgba(70, 49, 38, 0.19);
  --ig-ink: #2b1c13;
  --ig-muted: rgba(78, 58, 48, 0.78);
  --ig-focus: rgba(237, 112, 130, 0.64);
  --ig-accent-a: #ffb252;
  --ig-accent-b: #ff715e;
  --ig-accent-c: #de4de4;
  position: fixed;
  inset: 0;
  z-index: 60;
  background: linear-gradient(180deg, rgba(33, 20, 15, 0.4), rgba(33, 20, 15, 0.24));
  opacity: 0;
  pointer-events: none;
  transition: opacity 240ms ease;
}

.ig-story-screen.is-open {
  opacity: 1;
  pointer-events: auto;
}

body.ig-story-screen-open {
  overflow: hidden;
}

.ig-story-screen-shell {
  width: 100%;
  height: 100dvh;
  max-height: 100dvh;
  padding: 0;
  overflow: hidden;
  background: linear-gradient(180deg, var(--ig-sheet), var(--ig-sheet-strong));
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto;
  opacity: 0.94;
  transform: translateY(10px);
  transition: opacity 240ms ease, transform 240ms ease;
}

.ig-story-screen.is-open .ig-story-screen-shell {
  opacity: 1;
  transform: translateY(0);
}

.ig-story-close {
  border: 1px solid rgba(76, 55, 43, 0.2);
  background: rgba(255, 255, 255, 0.9);
  border-radius: 999px;
  width: 2rem;
  height: 2rem;
  padding: 0;
  line-height: 0.95;
  font-size: 1rem;
  color: var(--ig-ink);
  cursor: pointer;
  flex: 0 0 auto;
}

.ig-story-layout {
  min-height: 0;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  overflow: hidden;
}

.ig-story-preview-shell {
  padding: calc(0.62rem + env(safe-area-inset-top)) 0.95rem 0.68rem;
  display: grid;
  gap: 0.5rem;
  border-bottom: 1px solid rgba(76, 53, 42, 0.12);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.5), rgba(255, 246, 238, 0.56));
  position: sticky;
  top: 0;
  z-index: 3;
}

.ig-story-title-row {
  display: flex;
  align-items: center;
  gap: 0.58rem;
}

.ig-story-story-title {
  margin: 0;
  font-family: 'Cormorant Garamond', serif;
  font-size: 1.14rem;
  color: rgba(45, 31, 22, 0.92);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.ig-story-preview {
  margin: 0;
  border-radius: 18px;
  overflow: hidden;
  border: 1px solid rgba(70, 50, 39, 0.17);
  background: radial-gradient(circle at 18% 14%, rgba(255, 209, 139, 0.45), rgba(255, 240, 222, 0.18));
  min-height: 236px;
  display: grid;
  place-items: center;
  padding: 0.55rem;
}

.ig-story-preview img {
  width: min(100%, 236px);
  aspect-ratio: 9 / 16;
  object-fit: cover;
  border-radius: 13px;
  box-shadow: 0 12px 26px rgba(36, 20, 15, 0.34);
  background: rgba(255, 255, 255, 0.22);
}

.ig-story-controls {
  min-height: 0;
  overflow: auto;
  -webkit-overflow-scrolling: touch;
  padding: 0.86rem 0.95rem 0.76rem;
  display: grid;
  gap: 0.72rem;
  align-content: start;
}

.ig-story-image-options {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(64px, 1fr));
  gap: 0.45rem;
}

.ig-story-image-option {
  margin: 0;
  border: 1px solid rgba(76, 55, 44, 0.24);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.8);
  padding: 0.12rem;
  cursor: pointer;
  aspect-ratio: 3 / 4;
  overflow: hidden;
  transition: transform 170ms ease, border-color 170ms ease, box-shadow 170ms ease;
}

.ig-story-image-option img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 10px;
  display: block;
}

.ig-story-image-option:hover {
  transform: translateY(-1px);
}

.ig-story-image-option.is-selected {
  border-color: rgba(221, 102, 120, 0.74);
  box-shadow: 0 9px 16px rgba(108, 67, 52, 0.2);
}

.ig-story-close:focus-visible,
.ig-story-actions button:focus-visible,
.ig-story-image-option:focus-visible,
.ig-story-toggle-btn:focus-visible,
.storymirror-share-ig .ig-story-share-btn:focus-visible {
  outline: 2px solid var(--ig-focus);
  outline-offset: 2px;
}

.ig-story-row {
  display: grid;
  gap: 0.38rem;
}

.ig-story-fieldset {
  margin: 0;
  border: 1px solid rgba(73, 52, 42, 0.16);
  border-radius: 13px;
  padding: 0.48rem 0.58rem;
  display: grid;
  gap: 0.42rem;
  background: rgba(255, 255, 255, 0.62);
}

.ig-story-fieldset legend {
  padding: 0 0.24rem;
  font-family: 'Work Sans', sans-serif;
  font-size: 0.69rem;
  letter-spacing: 0.11em;
  text-transform: uppercase;
  color: var(--ig-muted);
}

.ig-story-fieldset label {
  display: inline-flex;
  align-items: center;
  gap: 0.43rem;
  font-family: 'Work Sans', sans-serif;
  font-size: 0.87rem;
  color: var(--ig-ink);
}

.ig-story-pill-fieldset {
  border: none;
  border-radius: 0;
  padding: 0;
  background: transparent;
  gap: 0.45rem;
}

.ig-story-pill-fieldset legend {
  padding: 0;
}

.ig-story-pill-options {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.45rem;
}

.ig-story-theme-fieldset .ig-story-pill-options {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.ig-story-pill-fieldset label {
  position: relative;
  display: block;
}

.ig-story-pill-fieldset label span {
  min-height: 2.3rem;
  border: 1px solid rgba(78, 57, 46, 0.18);
  border-radius: 999px;
  padding: 0.44rem 0.6rem;
  background: rgba(255, 255, 255, 0.84);
  display: inline-flex;
  width: 100%;
  align-items: center;
  line-height: 1.2;
  justify-content: center;
  text-align: center;
}

.ig-story-pill-fieldset input[type='radio'] {
  position: absolute;
  opacity: 0;
  pointer-events: none;
  width: 0;
  height: 0;
}

.ig-story-pill-fieldset input[type='radio']:checked + span {
  border-color: rgba(221, 102, 120, 0.52);
  background: linear-gradient(135deg, rgba(255, 210, 161, 0.52), rgba(255, 186, 197, 0.56));
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.62);
}

.ig-story-pill-fieldset input[type='radio']:disabled + span {
  opacity: 0.45;
  cursor: not-allowed;
}

.ig-story-toggles {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.48rem;
}

.ig-story-toggle-btn {
  border: 1px solid rgba(75, 56, 45, 0.18);
  border-radius: 12px;
  min-height: 2.45rem;
  padding: 0.45rem 0.62rem;
  background: rgba(255, 255, 255, 0.72);
  color: var(--ig-ink);
  font-family: 'Work Sans', sans-serif;
  font-size: 0.87rem;
  text-align: center;
  cursor: pointer;
  transition: border-color 170ms ease, background 170ms ease, transform 170ms ease;
}

.ig-story-toggle-btn:hover {
  transform: translateY(-1px);
}

.ig-story-toggle-btn.is-active {
  border-color: rgba(221, 102, 120, 0.56);
  background: linear-gradient(135deg, rgba(255, 210, 161, 0.42), rgba(255, 186, 197, 0.46));
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.58);
}

.ig-story-footer {
  padding: 0.42rem 0.92rem calc(0.78rem + env(safe-area-inset-bottom));
  border-top: 1px solid rgba(78, 56, 45, 0.14);
  background: rgba(255, 250, 244, 0.95);
  display: grid;
  gap: 0.36rem;
}

.ig-story-status {
  margin: 0;
  min-height: 0;
  font-family: 'Work Sans', sans-serif;
  font-size: 0.77rem;
  color: var(--ig-muted);
}

.ig-story-status[hidden] {
  display: none !important;
}

.ig-story-status[data-tone='error'] {
  color: rgba(163, 46, 72, 0.97);
}

.ig-story-status[data-tone='success'] {
  color: rgba(38, 115, 76, 0.97);
}

.ig-story-actions {
  display: grid;
  gap: 0.5rem;
}

.ig-story-actions button {
  margin: 0;
  min-height: 2.75rem;
}

.ig-story-actions .ig-story-share-btn {
  width: 100%;
}

.ig-story-share-btn {
  border: none;
  border-radius: 14px;
  background: linear-gradient(135deg, var(--ig-accent-a), var(--ig-accent-b) 46%, var(--ig-accent-c));
  color: #fff;
  box-shadow: 0 14px 22px rgba(209, 76, 106, 0.33);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.48rem;
  font-family: 'Work Sans', sans-serif;
  font-size: 0.8rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  font-weight: 700;
}

.ig-story-share-btn:hover {
  filter: saturate(1.06);
  transform: translateY(-1px);
}

.ig-story-share-btn-icon {
  width: 1.02rem;
  height: 1.02rem;
  border-radius: 0.28rem;
  border: 1.7px solid rgba(255, 255, 255, 0.96);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  position: relative;
  flex: 0 0 auto;
}

.ig-story-share-btn-icon::before {
  content: '';
  width: 0.4rem;
  height: 0.4rem;
  border-radius: 50%;
  border: 1.65px solid rgba(255, 255, 255, 0.98);
}

.ig-story-share-btn-icon::after {
  content: '';
  position: absolute;
  top: 0.1rem;
  right: 0.1rem;
  width: 0.13rem;
  height: 0.13rem;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.98);
}

.ig-story-actions button:disabled,
.ig-story-close:disabled {
  cursor: not-allowed;
}

.ig-story-busy .ig-story-actions button,
.ig-story-busy .ig-story-close {
  opacity: 0.72;
}

.storymirror-share-ig {
  --ig-focus: rgba(237, 112, 130, 0.64);
  --ig-accent-a: #ffb252;
  --ig-accent-b: #ff715e;
  --ig-accent-c: #de4de4;
  display: flex;
  justify-content: center;
  padding: 0;
}

.storymirror-share-ig .ig-story-actions {
  width: min(100%, 420px);
}

@media (min-width: 920px) {
  .ig-story-layout {
    grid-template-columns: minmax(360px, 420px) minmax(0, 1fr);
    grid-template-rows: minmax(0, 1fr);
    align-content: stretch;
    overflow: hidden;
  }

  .ig-story-preview-shell {
    padding: 1rem;
    border-bottom: none;
    border-right: 1px solid rgba(76, 53, 42, 0.12);
  }

  .ig-story-preview {
    min-height: 100%;
  }

  .ig-story-preview img {
    width: min(100%, 360px);
  }

  .ig-story-controls {
    overflow: auto;
    padding: 1rem 1rem 0.85rem 0.95rem;
  }

  .ig-story-footer {
    padding: 0.65rem 1rem calc(0.78rem + env(safe-area-inset-bottom));
  }
}
