/* Scoped to the devotional Story editor and its entry button. */
.devo-share-story {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  align-self: flex-start;
  min-height: 48px;
  max-width: 100%;
  margin: 24px 0 4px;
  padding: 12px 19px;
  border: 1px solid #ffffff55;
  border-radius: 12px;
  background: #f3efdf;
  color: #123ce8;
  font: 700 14px/1.35 'DM Sans', Arial, sans-serif;
  box-shadow: 0 5px 16px #00000014;
  transition: background .16s ease, transform .16s ease;
}
.devo-share-story svg { width: 19px; height: 19px; flex: 0 0 19px; fill: none; stroke: currentColor; stroke-width: 1.8; }
.devo-share-story:hover:not(:disabled) { background: #fffdf5; transform: translateY(-1px); }
.devo-share-story:disabled { cursor: not-allowed; }
.devo-story-status, #devo-story-status { color: #f3efdf; font-size: 13px; line-height: 1.5; margin: 10px 0 0; }
.devo-story-status:empty, #devo-story-status:empty { display: none; }

dialog.story-editor {
  --story-border: #dcdace;
  --story-muted: #64645d;
  --story-paper: #fffef9;
  position: fixed;
  inset: 0;
  width: min(960px, calc(100% - 40px));
  max-width: 960px;
  max-height: calc(100vh - 40px);
  max-height: calc(100dvh - 40px);
  margin: auto;
  padding: 0;
  border: 1px solid #ffffff80;
  border-radius: 24px;
  background: var(--story-paper);
  color: #171716;
  overflow: hidden;
  box-shadow: 0 24px 100px #00000050;
  font: 400 14px/1.5 'DM Sans', Arial, sans-serif;
  color-scheme: light;
}
dialog.story-editor[open] { display: flex; flex-direction: column; }
dialog.story-editor::backdrop { background: #10110fc9; backdrop-filter: blur(5px); -webkit-backdrop-filter: blur(5px); }
.story-editor *, .story-editor *::before, .story-editor *::after { box-sizing: border-box; }
.story-editor button, .story-editor input, .story-editor textarea { font-family: 'DM Sans', Arial, sans-serif; }
.story-editor button { min-height: 44px; touch-action: manipulation; }
.story-editor button:disabled { cursor: not-allowed; opacity: .46; }
.story-editor button:focus-visible,
.story-editor input:focus-visible,
.story-editor textarea:focus-visible { outline: 3px solid #123ce8; outline-offset: 3px; }
.story-editor p { font-size: 13px; line-height: 1.5; }
.story-editor [hidden] { display: none !important; }

.story-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex: 0 0 auto;
  gap: 16px;
  padding: 22px 28px 20px;
  border-bottom: 1px solid var(--story-border);
  background: var(--story-paper);
}
.story-eyebrow { display: block; color: #123ce8; font-size: 10px; line-height: 1.3; font-weight: 800; letter-spacing: 1.5px; }
.story-topbar h2 { margin: 6px 0 0; font-size: 26px; line-height: 1.12; font-weight: 700; letter-spacing: -.9px; }
.story-close {
  flex: 0 0 44px;
  width: 44px;
  height: 44px;
  padding: 0;
  border: 1px solid var(--story-border);
  border-radius: 50%;
  background: transparent;
  color: #171716;
  font-size: 29px;
  font-weight: 400;
  line-height: 1;
}
.story-close:hover { background: #f3efdf; }
.story-workspace {
  display: grid;
  grid-template-columns: minmax(260px, .84fr) minmax(0, 1fr);
  flex: 1 1 auto;
  min-height: 0;
  overflow: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
  scrollbar-color: #c7c5ba transparent;
}
.story-preview-panel {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  padding: 24px 28px 20px;
  background: radial-gradient(ellipse at 15% 10%, #f3efdf, transparent 65%), #e9e8e0;
  border-right: 1px solid var(--story-border);
  min-width: 0;
}
.story-preview-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: min(242px, 100%);
  color: #66665e;
  font-size: 9px;
  line-height: 1.2;
  font-weight: 800;
  letter-spacing: 1.5px;
}
.story-preview-meta span:last-child { padding: 4px 6px; border: 1px solid #17171633; border-radius: 4px; letter-spacing: .5px; }
.story-preview-frame {
  position: relative;
  flex: 0 0 auto;
  width: auto;
  height: clamp(220px, calc(100dvh - 360px), 430px);
  max-width: 100%;
  aspect-ratio: 9 / 16;
  overflow: hidden;
  border-radius: 13px;
  background: #123ce8;
  box-shadow: 0 10px 28px #20201b26, 0 0 0 1px #0000000a;
}
.story-preview-frame img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  -webkit-touch-callout: default;
  user-select: auto;
  -webkit-user-select: auto;
}
.story-preview-frame img:not([src]) { visibility: hidden; }
.story-preview-wait {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: #123ce8ba;
  color: #f3efdf;
  font-size: 13px;
  line-height: 1.5;
  font-weight: 600;
  text-align: center;
  pointer-events: none;
}
.story-editor .story-preview-hint { margin: 0; color: #6a6a61; font-size: 11px; }
.story-controls { min-width: 0; padding: 24px 28px 26px; }
.story-tabs { display: flex; gap: 4px; padding: 4px; border-radius: 12px; background: #efeee6; }
.story-tabs button { flex: 1; min-width: 0; padding: 9px 12px; border: 0; border-radius: 9px; background: transparent; color: #63635b; font-size: 13px; font-weight: 700; }
.story-tabs button[aria-selected="true"] { background: #fffef9; color: #123ce8; box-shadow: 0 1px 5px #1717160f; }
.story-tab-panel { padding-top: 22px; }
.story-tab-panel h3 { margin: 0 0 16px; font-size: 18px; line-height: 1.3; font-weight: 700; letter-spacing: -.35px; }
.story-choice-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 20px; }
.story-choice-grid button { min-width: 0; padding: 9px 10px; border: 1px solid var(--story-border); border-radius: 10px; background: #fffef9; color: #494942; font-size: 13px; font-weight: 600; }
.story-choice-grid button[aria-pressed="true"] { border-color: #123ce8; background: #eef1ff; color: #123ce8; box-shadow: inset 0 0 0 .5px #123ce8; }
.story-field { display: block; margin: 0; color: #494942; font-size: 12px; font-weight: 700; line-height: 1.5; }
.story-optional { color: #7c7c72; font-weight: 400; }
.story-field input, .story-field textarea, .story-manual-link input {
  display: block;
  width: 100%;
  min-width: 0;
  margin-top: 7px;
  padding: 12px 13px;
  border: 1px solid #d6d5c9;
  border-radius: 10px;
  background: #fffef9;
  color: #171716;
  font-size: 16px;
  font-weight: 400;
  line-height: 1.5;
  box-shadow: none;
  appearance: none;
  -webkit-appearance: none;
}
.story-field textarea { resize: vertical; min-height: 110px; max-height: 270px; }
.story-field textarea[readonly] { background: #f3f2ea; color: #494942; }
.story-field input::placeholder, .story-field textarea::placeholder { color: #8b8b81; opacity: 1; }
.story-field-meta { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin: 7px 0 18px; color: #74746a; font-size: 10px; line-height: 1.5; }
#story-text-count { flex: 0 0 auto; font-variant-numeric: tabular-nums; }
.story-themes { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; margin-bottom: 20px; }
.story-themes button { display: flex; flex-direction: column; align-items: center; gap: 9px; min-width: 0; padding: 6px 3px 8px; border: 1px solid transparent; border-radius: 11px; background: transparent; color: #64645d; font-size: 10px; font-weight: 600; }
.story-themes button[aria-pressed="true"] { border-color: #123ce8; background: #eef1ff; color: #123ce8; }
.story-swatch { display: block; width: min(100%, 55px); aspect-ratio: 1; border-radius: 9px; border: 1px solid #00000012; }
.story-swatch-blue { background: radial-gradient(ellipse at 90% 20%, #6685ff, transparent 70%), #123ce8; }
.story-swatch-cream { background: linear-gradient(140deg, #fffbed, #e8dfc4); }
.story-swatch-night { background: radial-gradient(ellipse at 100% 0%, #4d537c, transparent 70%), #171716; }
.story-swatch-sunrise { background: linear-gradient(145deg, #efc8ac, #cf746e 48%, #663b5c); }
.story-control-label { display: block; margin: 0 0 8px; color: #64645d; font-size: 11px; font-weight: 700; }
.story-segment { display: flex; gap: 3px; padding: 3px; border: 1px solid var(--story-border); border-radius: 10px; background: #f3f2ea; }
.story-segment button { flex: 1; min-width: 0; padding: 8px 7px; border: 0; border-radius: 7px; background: transparent; color: #64645d; font-size: 12px; font-weight: 600; }
.story-segment button[aria-pressed="true"] { background: #171716; color: #f3efdf; }
.story-segment .story-font-bold { font-family: 'Barlow Condensed', Impact, sans-serif; font-size: 20px; font-weight: 800; }
.story-segment .story-font-classic { font-family: Georgia, 'Times New Roman', serif; font-size: 17px; font-weight: 400; }
.story-control-row { display: grid; grid-template-columns: .85fr 1.15fr; gap: 14px; margin-top: 17px; }
.story-control-row > div { min-width: 0; }
.story-range-label { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 5px 10px; margin-top: 17px; color: #494942; font-size: 11px; font-weight: 700; line-height: 1.4; }
.story-range-label span { color: #7c7c72; font-size: 10px; font-weight: 400; }
.story-range-label input[type="range"] { display: block; flex: 0 0 100%; width: 100%; min-width: 0; height: 36px; margin: 0; padding: 0; accent-color: #123ce8; cursor: pointer; }
.story-editor .story-tip { margin: 9px 0 0; color: #74746a; font-size: 11px; line-height: 1.5; }
.story-logo-toggle { display: flex; align-items: center; justify-content: space-between; gap: 16px; min-height: 60px; margin-top: 20px; padding-top: 16px; border-top: 1px solid var(--story-border); cursor: pointer; }
.story-logo-toggle strong { display: block; color: #494942; font-size: 13px; }
.story-logo-toggle small { display: block; margin-top: 3px; color: #74746a; font-size: 11px; }
.story-logo-toggle input[type="checkbox"] { flex: 0 0 24px; width: 24px; height: 24px; margin: 10px 0 10px 10px; padding: 0; accent-color: #123ce8; cursor: pointer; }
.story-editor .story-photo-copy { color: #6a6a61; margin: -3px 0 20px; }
.story-photo-pick { display: flex; align-items: center; justify-content: center; gap: 9px; width: 100%; padding: 20px 16px; border: 1px dashed #a4abce; border-radius: 13px; background: #f0f2fb; color: #123ce8; font-size: 14px; font-weight: 700; }
.story-photo-pick span { font-size: 24px; font-weight: 400; }
.story-photo-pick:hover { background: #e7ebff; }
.story-text-button { padding: 10px 0; border: 0; background: transparent; color: #123ce8; font-size: 11px; font-weight: 700; text-decoration: underline; text-underline-offset: 3px; }
#story-photo-remove { margin-top: 7px; color: #64645d; }
.story-bottom { flex: 0 0 auto; padding: 14px 28px 18px; border-top: 1px solid var(--story-border); background: var(--story-paper); }
.story-editor .story-status { margin: 0 0 10px; padding: 9px 12px; border-radius: 8px; background: #f3f2ea; color: #494942; font-size: 11px; line-height: 1.45; }
.story-editor .story-status:empty { display: none; }
.story-actions { display: grid; grid-template-columns: 1.35fr 1fr; gap: 10px; }
.story-primary, .story-secondary { min-width: 0; min-height: 48px !important; padding: 12px 16px; border: 1px solid #123ce8; border-radius: 11px; font-size: 14px; font-weight: 700; line-height: 1.3; }
.story-primary { background: #123ce8; color: #fff; }
.story-primary:hover:not(:disabled) { background: #0a2cbf; }
.story-secondary { background: #fffef9; color: #123ce8; }
.story-secondary:hover:not(:disabled) { background: #eef1ff; }
.story-editor .story-share-help { margin: 10px 0 0; color: #74746a; font-size: 11px; line-height: 1.5; }
.story-link-row { display: flex; align-items: center; gap: 12px; margin-top: 2px; }
.story-link-row span { color: #85857c; font-size: 10px; line-height: 1.4; }
.story-manual-link label { display: block; color: #64645d; font-size: 11px; font-weight: 700; }
.story-manual-link input { margin-top: 4px; }

@media (max-width: 680px) {
  .devo-share-story { align-self: stretch; width: 100%; }
  dialog.story-editor {
    inset: 0;
    width: 100%;
    max-width: none;
    height: 100%;
    height: 100dvh;
    max-height: 100%;
    max-height: 100dvh;
    margin: 0;
    border: 0;
    border-radius: 0;
  }
  .story-topbar { padding: max(15px, env(safe-area-inset-top)) 18px 14px; gap: 10px; }
  .story-topbar h2 { font-size: 23px; letter-spacing: -.65px; }
  .story-eyebrow { font-size: 8px; letter-spacing: 1.3px; }
  .story-close { width: 44px; height: 44px; }
  .story-workspace { display: block; }
  .story-preview-panel { gap: 8px; padding: 15px 18px 12px; border-right: 0; border-bottom: 1px solid var(--story-border); }
  .story-preview-frame { height: clamp(220px, 34dvh, 290px); border-radius: 10px; }
  .story-preview-meta { width: 200px; font-size: 8px; }
  .story-preview-hint { display: none; }
  .story-controls { padding: 16px 18px 24px; }
  .story-tab-panel { padding-top: 18px; }
  .story-tab-panel h3 { font-size: 17px; margin-bottom: 14px; }
  .story-choice-grid { gap: 7px; margin-bottom: 18px; }
  .story-field textarea { min-height: 108px; }
  .story-field input, .story-field textarea, .story-manual-link input { font-size: 16px; }
  .story-control-row { gap: 10px; }
  .story-bottom { padding: 12px 18px max(10px, env(safe-area-inset-bottom)); }
  .story-primary, .story-secondary { padding: 11px 10px; font-size: 13px; }
  .story-editor .story-share-help { font-size: 10px; line-height: 1.45; margin-top: 8px; }
  .story-link-row { gap: 10px; }
  .story-link-row span { font-size: 9px; }
  .story-editor .story-status { max-height: 70px; overflow-y: auto; margin-bottom: 8px; font-size: 10px; }
}

@media (max-height: 540px) {
  dialog.story-editor { max-height: 100dvh; }
  .story-topbar { padding-top: 10px; padding-bottom: 10px; }
  .story-topbar h2 { font-size: 20px; }
  .story-eyebrow { display: none; }
  .story-preview-frame { height: 240px; }
  .story-preview-panel { padding-top: 14px; padding-bottom: 14px; }
  .story-bottom { padding-top: 9px; padding-bottom: max(6px, env(safe-area-inset-bottom)); }
  .story-editor .story-share-help { max-height: 33px; overflow-y: auto; margin-top: 6px; }
  .story-link-row { min-height: 30px; }
  .story-link-row .story-text-button { min-height: 32px; padding: 6px 0; }
  .story-editor .story-status { max-height: 36px; overflow-y: auto; }
}

@media (prefers-reduced-motion: reduce) {
  .devo-share-story, .story-editor *, .story-editor *::before, .story-editor *::after { transition: none !important; animation: none !important; scroll-behavior: auto !important; }
}
