/* Next-update progress: a single natural-height summary, no nested scroller. */
:root[data-app-theme] #app .home-insights-section:has(.home-progress-summary) {
  padding: 20px !important;
  border-radius: 22px !important;
  background: var(--app-theme-card) !important;
  box-shadow: none !important;
  gap: 18px !important;
  overflow: visible !important;
}
#app .home-progress-summary dl { margin: 0; }
#app .home-progress-summary dl > div {
  display: flex; align-items: baseline; justify-content: space-between; gap: 24px;
  padding: 12px 0; border-bottom: 1px solid var(--app-line);
}
#app .home-progress-summary dl > div:last-child { border-bottom: 0; }
#app .home-progress-summary dt { color: var(--muted); font-size: 14px; font-weight: 500; }
#app .home-progress-summary dd { margin: 0; color: var(--text); text-align: right; font-size: 19px; font-weight: 650; font-variant-numeric: tabular-nums; }
#app .home-progress-empty { margin: 12px 0; font-size: 14px; color: var(--muted); }
#app .home-progress-summary-actions { display: flex; justify-content: center; }
:root[data-app-theme] #app [data-open-progress-editor] {
  display: inline-flex !important; align-items: center; justify-content: center; gap: 8px;
  width: auto !important; min-height: 36px !important; padding: 8px 16px !important;
  border: 1px solid var(--app-line) !important; border-radius: 100px !important;
  background: transparent !important; box-shadow: none !important; color: var(--text) !important;
  font-size: 13px !important; font-weight: 600; cursor: pointer;
}
#app [data-open-progress-editor] svg { width: 15px; height: 15px; }
#app [data-open-progress-editor]:disabled { opacity: .4; cursor: default; }

/* Editing stays separate from sharing; only the active control is shown. */
#app .progress-editor {
  position: fixed; inset: 0; z-index: 25000; width: 100%; height: 100%;
  background: transparent; isolation: isolate; color: var(--text); overflow: hidden;
  padding-top: env(safe-area-inset-top, 0px);
}
#app .progress-editor [hidden], #app .progress-editor[hidden] { display: none !important; }
#app .progress-editor::before { content: ''; position: absolute; inset: 0; z-index: -1; background: var(--bg); opacity: 1; transition: opacity .14s ease-out; }
#app .progress-editor-shell { display: flex; flex-direction: column; height: 100%; min-height: 0; margin: 0; opacity: 1; transition: opacity .14s ease-out; }
#app .progress-editor[data-progress-opening="true"]::before,
#app .progress-editor[data-progress-opening="true"] .progress-editor-shell { opacity: 0; transition: none; pointer-events: none; }
#app .progress-editor-opening {
  position: absolute; z-index: 10; left: 50%; bottom: calc(110px + env(safe-area-inset-bottom, 0px));
  transform: translateX(-50%); display: flex; align-items: center; gap: 16px;
  width: max-content; max-width: calc(100% - 40px); padding: 8px 10px 8px 18px;
  background: var(--bg); border: 1px solid var(--app-line); border-radius: 100px;
  box-shadow: 0 4px 24px #0003; font-size: 13px;
  animation: progress-opening-notice .15s .2s both;
}
@keyframes progress-opening-notice { from { opacity: 0; } to { opacity: 1; } }
:root[data-app-theme] #app .progress-editor [data-progress-opening-cancel] { border: 0 !important; border-radius: 100px !important; background: transparent !important; }
#app .progress-editor-topbar {
  flex: none; display: grid; grid-template-columns: 42px 1fr 42px; align-items: center;
  gap: 12px; padding: 10px 20px; background: var(--bg);
}
#app .progress-editor h2 { margin: 0; font-size: 18px; font-weight: 650; text-align: center; letter-spacing: -.4px; }
#app .progress-editor-brand-label { font-size: 10px; font-weight: 800; letter-spacing: 2px; opacity: .5; text-align: right; }
#app .progress-editor-body {
  flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch; touch-action: pan-y; padding: 0 20px;
  display: flex; flex-direction: column;
}
#app .progress-editor-preview { width: min(100%, 420px); margin: auto; }
#app .progress-story-stage {
  position: relative; isolation: isolate; margin: 0 auto;
  width: min(100%, max(260px, calc((var(--progress-viewport-height, 100svh) - 340px - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px)) * var(--progress-ratio, .8))));
  aspect-ratio: var(--progress-ratio, .8);
  flex: none;
  border-radius: var(--progress-corner-radius, 16px); box-shadow: 0 8px 32px #0003;
}
#app .progress-editor canvas { position: absolute; inset: 0; z-index: 1; display: block; width: 100%; height: 100%; border-radius: 0; box-shadow: none; }
#app .progress-editor [data-progress-camera-preview] { z-index: 0; pointer-events: none; }
/* Keep decoding inline, but never expose WebKit's independently sized video
   compositor. The card only displays the fixed canvas drawn from these frames.
   display:none/visibility:hidden can suspend frame delivery on iOS. */
#app .progress-editor [data-progress-camera-source] {
  position: absolute; top: 0; left: 0; width: 1px; height: 1px;
  min-width: 0; min-height: 0; max-width: 1px; max-height: 1px;
  opacity: .001; pointer-events: none;
}
#app .progress-camera-controls { position: relative; display: grid; justify-items: center; gap: 5px; padding-top: 14px; }
:root[data-app-theme] #app .progress-editor [data-progress-shutter] {
  width: 62px !important; height: 62px; min-width: 62px; padding: 4px !important;
  border-radius: 50% !important; border: 2px solid var(--text) !important; background: transparent !important;
}
#app [data-progress-shutter] > span { width: 100%; height: 100%; border-radius: 50%; background: var(--text); }
#app [data-progress-camera-label] { font-size: 11px; font-weight: 550; color: var(--muted); }
:root[data-app-theme] #app .progress-editor [data-progress-camera-flip] {
  position: absolute; left: calc(50% + 66px); top: 24px; border: 0 !important;
  border-radius: 50% !important; background: transparent !important; padding: 0 !important; font-size: 27px !important;
}
#app .progress-camera-message { text-align: center; }
#app .progress-camera-message:empty { display: none; }
#app .progress-editor h3 { font-size: 17px; letter-spacing: -.3px; margin: 0; font-weight: 650; }
#app .progress-editor p { color: var(--muted); line-height: 1.5; font-size: 12px; margin: 8px 0; }
:root[data-app-theme] #app .progress-editor button {
  min-height: 44px !important; min-width: 44px; width: auto !important;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  margin: 0; padding: 9px 13px !important; border: 1px solid var(--app-line) !important;
  border-radius: 12px !important; background: var(--app-control-soft) !important;
  color: var(--text) !important; box-shadow: none !important; font: inherit; font-size: 13px !important;
  font-weight: 550; line-height: 1.3; cursor: pointer; transform: none !important;
}
:root[data-app-theme] #app .progress-editor button:disabled { opacity: .3; cursor: default; }
:root[data-app-theme] #app .progress-editor button[aria-pressed="true"] { border-color: var(--text) !important; }
#app .progress-editor button:focus-visible { outline: 2px solid var(--text); outline-offset: 3px; }
:root[data-app-theme] #app .progress-editor-topbar button { border: 0 !important; padding: 0 !important; background: transparent !important; font-size: 24px !important; }
#app .progress-story-items { position: absolute; z-index: 2; inset: 0; pointer-events: none; }
#app .progress-story-item { position: absolute; pointer-events: auto; }
:root[data-app-theme] #app .progress-story-item .progress-item-select {
  position: absolute; inset: 0; width: 100% !important; min-width: 0; min-height: 0 !important;
  border: 1px solid transparent !important; background: transparent !important; border-radius: 8px !important; padding: 0 !important;
}
:root[data-app-theme] #app .progress-story-item.is-active .progress-item-select { border-color: #ffffffb0 !important; background: #ffffff08 !important; }
:root[data-app-theme] #app .progress-story-item .progress-item-remove {
  position: absolute; right: -15px; top: -18px; width: 44px !important; height: 44px;
  padding: 0 !important; border: 0 !important; background: transparent !important; color: white !important;
}
#app .progress-item-remove span { display: grid; place-items: center; width: 24px; height: 24px; border-radius: 50%; background: #16191cf2; box-shadow: 0 0 0 1px #ffffff70; font-size: 19px; }
#app .progress-story-toolbar { display: flex; justify-content: center; gap: 6px; padding: 4px 0 12px; }
:root[data-app-theme] #app .progress-story-toolbar button { border-radius: 100px !important; background: transparent !important; padding: 8px 12px !important; font-size: 12px !important; }
#app .progress-story-toolbar svg { width: 17px; height: 17px; }
#app .progress-story-toolbar button > span { font-size: 18px; }
#app .progress-editor-hint { min-height: 56px; display: grid; place-items: center; }
#app .progress-editor-hint > * { grid-area: 1 / 1; }
#app .progress-editor-hint:has(.progress-camera-message:not(:empty)) > :not(.progress-camera-message) { visibility: hidden; }
#app .progress-editor-hint p { text-align: center; font-size: 11px; }
#app .progress-story-reorder { display: flex; align-items: center; gap: 2px; width: 100%; }
#app .progress-story-reorder > span { flex: 1; font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
:root[data-app-theme] #app .progress-story-reorder button { border: 0 !important; background: transparent !important; padding: 8px !important; }
#app .progress-editor-footer { flex: none; width: min(100%, 460px); margin: 0 auto; padding: 8px 20px calc(14px + env(safe-area-inset-bottom, 0px)); }
:root[data-app-theme] #app .progress-editor .progress-share-primary { background: var(--text) !important; color: var(--bg) !important; border: 0 !important; border-radius: 100px !important; }
:root[data-app-theme] #app .progress-editor-footer .progress-share-primary { width: 100% !important; min-height: 46px !important; gap: 12px; }
#app [data-progress-status]:empty { display: none; }
#app [data-progress-status] { text-align: center; }
#app .progress-panel-layer { position: absolute; inset: 0; z-index: 5; display: flex; align-items: end; justify-content: center; }
:root[data-app-theme] #app .progress-editor .progress-panel-backdrop {
  position: absolute; inset: 0; width: 100% !important; height: 100%; margin: 0; border: 0 !important;
  background: #0006 !important; padding: 0 !important; border-radius: 0 !important; cursor: default;
}
#app .progress-editor [data-progress-panel] {
  position: relative; width: min(100%, 460px); max-height: 72%; overflow-y: auto;
  overscroll-behavior: contain; padding: 12px 20px calc(20px + env(safe-area-inset-bottom, 0px));
  border: 1px solid var(--app-line-strong); border-radius: 24px 24px 0 0;
  background: var(--bg); color: var(--text); box-shadow: 0 -8px 40px #0003;
  animation: progress-panel-in .18s ease-out;
}
#app .progress-editor [data-progress-panel] header { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 8px; }
:root[data-app-theme] #app .progress-editor [data-progress-panel] [data-progress-dismiss] { border: 0 !important; background: transparent !important; padding: 8px !important; }
#app [data-progress-available] button > span:first-child { flex: 1; min-width: 0; }
#app [data-progress-available] strong { display: block; font-size: 14px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#app [data-progress-available] small, #app .progress-share-destinations small { display: block; font-size: 12px; color: var(--muted); margin-top: 4px; line-height: 1.45; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
:root[data-app-theme] #app .progress-editor input[type="search"] { width: 100%; padding: 12px !important; font-size: 16px !important; min-height: 44px; background: var(--app-control-bg) !important; color: var(--text) !important; border: 1px solid var(--app-line) !important; border-radius: 12px !important; }
#app [data-progress-available] { max-height: 32dvh; overflow-y: auto; overscroll-behavior: contain; margin-top: 8px; }
:root[data-app-theme] #app [data-progress-available] button { width: 100% !important; justify-content: space-between; text-align: left; border: 0 !important; border-bottom: 1px solid var(--app-line) !important; border-radius: 0 !important; background: transparent !important; padding: 14px 0 !important; }
#app .progress-colour-controls { display: flex; justify-content: center; }
#app .progress-colour-controls:has(label:not([hidden])) { padding-top: 12px; }
#app .progress-colour-controls label { display: grid; grid-template-columns: 1fr 32px 1fr; align-items: center; gap: 28px; font-size: 12px; width: 100%; }
:root[data-app-theme] #app .progress-colour-slider {
  appearance: none !important; -webkit-appearance: none !important; writing-mode: vertical-lr; direction: ltr;
  display: block; width: 26px !important; min-width: 26px !important; height: 160px !important; min-height: 160px !important;
  margin: 0 !important; padding: 0 !important; border: 1px solid var(--app-line-strong) !important; border-radius: 100px !important;
  touch-action: none; cursor: pointer; box-shadow: none !important;
  background: linear-gradient(to bottom, #fff 0%, #f00 10%, #ff0 26%, #0f0 42%, #0ff 58%, #00f 74%, #f0f 90%, #000 100%) !important;
}
#app .progress-colour-slider::-webkit-slider-runnable-track { background: transparent; border: 0; border-radius: 100px; }
#app .progress-colour-slider::-webkit-slider-thumb { appearance: none; -webkit-appearance: none; width: 36px; height: 18px; border: 3px solid #fff; border-radius: 100px; background: transparent; box-shadow: 0 1px 5px #0009; }
#app .progress-colour-slider::-moz-range-track { background: transparent; border: 0; }
#app .progress-colour-slider::-moz-range-thumb { width: 32px; height: 12px; border: 3px solid white; border-radius: 100px; background: transparent; box-shadow: 0 1px 5px #0009; }
#app .progress-colour-controls output { display: flex; align-items: center; gap: 6px; color: var(--muted); font-size: 12px; }
#app .progress-colour-controls output::before { content: ''; width: 16px; height: 16px; border: 1px solid var(--app-line-strong); border-radius: 50%; background: var(--swatch, #fff); }
#app .progress-share-destinations { display: grid; }
:root[data-app-theme] #app .progress-share-destinations button { width: 100% !important; text-align: left; justify-content: start; padding: 12px 0 !important; border: 0 !important; border-radius: 0 !important; background: transparent !important; gap: 14px; }
#app .progress-share-destinations button > span:nth-child(2) { flex: 1; }
#app .progress-destination-icon { width: 40px; height: 40px; display: grid; place-items: center; border-radius: 12px; background: var(--app-control-soft); font-size: 23px; }
#app .progress-destination-icon svg { width: 21px; height: 21px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
#app [data-progress-confirm] { padding: 12px 0; }
#app [data-progress-confirm] button { margin: 8px 8px 0 0; }
@keyframes progress-panel-in { from { transform: translateY(18px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }
@media (min-width: 900px) {
  #app .progress-editor-topbar { padding-inline: max(28px, calc((100vw - 460px) / 2)); }
  #app .progress-editor [data-progress-panel] { margin-bottom: 28px; border-radius: 24px; }
}
@media (prefers-reduced-motion: reduce) { #app .progress-editor *, #app .progress-editor::before { scroll-behavior: auto !important; animation: none !important; transition: none !important; } }
