:root {
  color-scheme: light;
  --ink: #050505;
  --paper: #ffffff;
  --soft: #f4f7f8;
  --line: #dbe6e9;
  --muted: #65777d;
  --blue: #1dc5e2;
  --blue-soft: rgba(29, 197, 226, 0.14);
  --green: #19c36b;
  --green-dark: #0f9d54;
  --green-soft: rgba(25, 195, 107, 0.14);
  --danger: #ba1a35;
  --ok: #0c7a4a;
  --shadow: 0 18px 50px rgba(0, 0, 0, 0.12);
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  min-height: 100vh;
  background: #eef4f5;
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
textarea,
input {
  font: inherit;
}

button {
  border: 0;
  border-radius: 8px;
  cursor: pointer;
  font-weight: 900;
  letter-spacing: 0;
}

button:disabled {
  cursor: wait;
  opacity: 0.55;
}

.portrait-widget {
  width: min(100%, 430px);
  min-height: 100vh;
  margin: 0 auto;
  padding: 14px;
  background: var(--paper);
}

.view {
  width: 100%;
}

.startView {
  min-height: calc(100vh - 74px);
  display: grid;
  place-content: center;
  gap: 12px;
  text-align: center;
}

.startDelivery {
  width: min(100%, 330px);
  display: grid;
  grid-template-columns: 42px 1fr;
  gap: 2px 10px;
  margin: 0;
  padding: 12px 14px;
  border: 2px solid var(--ink);
  border-radius: 8px;
  background: #fff;
  text-align: left;
  align-items: center;
}

.deliveryIcon {
  grid-row: span 2;
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: var(--ink);
}

.deliveryIcon svg {
  width: 26px;
  height: 26px;
  fill: var(--blue);
}

.deliveryLabel {
  color: var(--blue);
  font-size: 11px;
  font-weight: 950;
  text-transform: uppercase;
}

.startDelivery strong {
  font-size: 18px;
  line-height: 1.2;
}

.miniLabel {
  margin: 0;
  color: var(--blue);
  font-size: 12px;
  font-weight: 950;
  text-transform: uppercase;
  letter-spacing: 0;
}

.uploadCta {
  width: min(100%, 330px);
  min-height: 78px;
  display: grid;
  place-items: center;
  gap: 4px;
  padding: 12px 24px;
  background: var(--green);
  color: #00190c;
  box-shadow: var(--shadow);
}

.uploadCta strong,
.uploadCta span {
  display: block;
  line-height: 1.1;
}

.uploadCta strong {
  font-size: 25px;
}

.uploadCta span {
  color: #003d20;
  font-size: 13px;
  font-weight: 850;
}

.topLine {
  min-height: 44px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
  font-size: 14px;
  font-weight: 900;
}

.iconText {
  min-height: 38px;
  padding: 0 12px;
  background: var(--soft);
  color: var(--ink);
}

.cropView {
  padding-top: 6px;
}

.cropFrame {
  position: relative;
  width: 100%;
  aspect-ratio: 4 / 5;
  overflow: hidden;
  border: 2px solid var(--ink);
  border-radius: 8px;
  background: var(--soft);
  touch-action: none;
}

.cropFrame::after {
  content: none;
  position: absolute;
  inset: 18%;
  border: 1px solid rgba(255, 255, 255, 0.72);
  border-radius: 999px;
  pointer-events: none;
}

.cropFrame img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: contain;
  background: #111;
}

.cropBox {
  position: absolute;
  left: 12%;
  top: 10%;
  width: 76%;
  height: 76%;
  border: 2px solid var(--blue);
  border-radius: 8px;
  box-shadow: 0 0 0 999px rgba(0, 0, 0, 0.42);
  cursor: move;
}

.cropHandle {
  position: absolute;
  right: -8px;
  bottom: -8px;
  width: 26px;
  height: 26px;
  border: 3px solid var(--paper);
  border-radius: 50%;
  background: var(--blue);
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.28);
}

.primaryAction,
.secondaryAction,
.darkAction {
  width: 100%;
  min-height: 52px;
  padding: 0 16px;
}

.primaryAction {
  background: var(--blue);
  color: #001114;
}

.cropView .primaryAction {
  margin-top: 14px;
}

.secondaryAction {
  background: var(--paper);
  color: var(--ink);
  border: 1px solid var(--line);
}

.darkAction {
  background: var(--ink);
  color: var(--paper);
}

.smallNote {
  margin: 10px 0 0;
  color: var(--muted);
  text-align: center;
  font-size: 13px;
  font-weight: 700;
}

.loadingView {
  min-height: calc(100vh - 74px);
  display: grid;
  place-content: center;
  gap: 12px;
  text-align: center;
}

.loadingView strong {
  max-width: 340px;
  font-size: 27px;
  line-height: 1.05;
}

.loadingView span {
  max-width: 320px;
  color: var(--muted);
  font-size: 14px;
  font-weight: 800;
}

.loader {
  width: 52px;
  height: 52px;
  margin: 0 auto;
  border: 5px solid var(--line);
  border-top-color: var(--blue);
  border-radius: 50%;
  animation: spin 900ms linear infinite;
}

.loadingTrack {
  width: min(100%, 320px);
  height: 10px;
  margin: 6px auto 0;
  overflow: hidden;
  border: 2px solid var(--ink);
  border-radius: 999px;
  background: #fff;
}

.loadingBar {
  width: 45%;
  height: 100%;
  border-radius: inherit;
  background: var(--blue);
  animation: loadingSweep 1.35s ease-in-out infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

@keyframes loadingSweep {
  0% {
    transform: translateX(-110%);
  }
  55% {
    transform: translateX(65%);
  }
  100% {
    transform: translateX(245%);
  }
}

.sectionHeader {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin: 6px 0 14px;
}

.sectionHeader.tight {
  margin-top: 0;
}

h1 {
  margin: 4px 0 0;
  font-size: 26px;
  line-height: 1.08;
  letter-spacing: 0;
}

.roundPill {
  display: none;
  min-width: 98px;
  min-height: 32px;
  place-items: center;
  border-radius: 999px;
  background: var(--ink);
  color: var(--paper);
  padding: 0 10px;
  font-size: 12px;
  font-weight: 950;
}

.versionRail {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: minmax(268px, 88%);
  gap: 12px;
  overflow-x: auto;
  overscroll-behavior-x: contain;
  scroll-snap-type: x mandatory;
  padding: 4px 4px 14px;
  margin: 0 -4px;
}

.versionRail::-webkit-scrollbar {
  height: 8px;
}

.versionRail::-webkit-scrollbar-thumb {
  background: var(--line);
  border-radius: 999px;
}

.actionHint {
  margin: 0 0 10px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
  line-height: 1.3;
}

.versionCard {
  scroll-snap-align: center;
  border: 2px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  background: var(--paper);
}

.versionCard.selected {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px var(--blue-soft);
}

.versionImage {
  width: 100%;
  aspect-ratio: 3 / 4;
  display: grid;
  place-items: center;
  overflow: hidden;
  background: var(--soft);
}

.versionImage img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: contain;
}

.versionImage span {
  color: var(--muted);
  font-weight: 900;
}

.versionFooter {
  padding: 10px;
}

.selectVersionBtn {
  width: 100%;
  min-height: 40px;
  padding: 0 10px;
  background: var(--soft);
  color: var(--ink);
  font-size: 14px;
  white-space: nowrap;
}

.versionCard.selected .selectVersionBtn {
  background: var(--blue);
  color: #001114;
}

.quickActions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin: 10px 0 14px;
}

.quickActions .secondaryAction {
  min-height: 48px;
  font-size: 14px;
}

.editBox {
  display: grid;
  gap: 10px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--soft);
}

.editBox label {
  font-size: 14px;
  font-weight: 950;
}

textarea {
  width: 100%;
  min-height: 92px;
  resize: vertical;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  color: var(--ink);
  background: var(--paper);
}

textarea:focus {
  border-color: var(--blue);
  outline: 3px solid var(--blue-soft);
}

.sizeGrid {
  display: grid;
  gap: 10px;
}

.sizeOption {
  min-height: 62px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border: 2px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: var(--paper);
  text-align: left;
}

.sizeOption.selected {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px var(--blue-soft);
}

.sizeOption strong,
.sizeOption span {
  display: block;
}

.sizeOption span {
  color: var(--muted);
  font-size: 13px;
  margin-top: 3px;
}

.price {
  white-space: nowrap;
  font-size: 17px;
  font-weight: 950;
}

.doneView {
  min-height: calc(100vh - 74px);
  display: grid;
  place-content: center;
  gap: 12px;
  text-align: center;
}

.doneMark {
  width: 72px;
  height: 72px;
  display: grid;
  place-items: center;
  margin: 0 auto;
  border-radius: 50%;
  background: var(--blue);
  color: #001114;
  font-size: 42px;
  font-weight: 950;
}

.doneView p {
  margin: 0;
  color: var(--muted);
  font-weight: 800;
}

.status {
  min-height: 22px;
  margin: 12px 0 0;
  color: var(--muted);
  text-align: center;
  font-size: 13px;
  font-weight: 800;
}

.status.ok {
  color: var(--ok);
}

.status.error {
  color: var(--danger);
}

.resultsNotice {
  margin: 0 0 10px;
  padding: 10px 12px;
  border: 1px solid rgba(29, 197, 226, 0.42);
  border-radius: 8px;
  background: rgba(29, 197, 226, 0.1);
  color: #067b8f;
  text-align: center;
  font-size: 14px;
  font-weight: 900;
}

.resultsNotice[hidden] {
  display: none;
}

.viewer {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 16px;
  background: rgba(0, 0, 0, 0.9);
}

.emailGate {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(0, 0, 0, 0.72);
}

.emailPanel {
  position: relative;
  width: min(100%, 390px);
  display: grid;
  gap: 10px;
  padding: 18px;
  border-radius: 8px;
  background: var(--paper);
  box-shadow: var(--shadow);
}

.emailPanel h2,
.emailPanel h3,
.emailPanel p {
  margin: 0;
}

.emailPanel h2 {
  font-size: 24px;
  line-height: 1.05;
}

.emailPanel p {
  color: var(--muted);
  font-size: 14px;
  font-weight: 800;
}

.emailPanel label {
  font-size: 13px;
  font-weight: 950;
}

.emailPanel input {
  min-height: 46px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 12px;
}

.emailNextStep {
  display: grid;
  gap: 10px;
}

.emailChoices {
  display: grid;
  gap: 8px;
}

.emailChoices button {
  min-height: 44px;
  padding: 0 12px;
  border: 1px solid var(--line);
  background: var(--soft);
  color: var(--ink);
  text-align: left;
}

.viewerPanel {
  position: relative;
  width: min(100%, 430px);
  display: grid;
  gap: 12px;
}

.viewer img {
  width: min(100%, 760px);
  max-height: 88vh;
  object-fit: contain;
  border-radius: 8px;
  background: #101010;
}

.viewerClose {
  position: absolute;
  top: 14px;
  right: 14px;
  width: 44px;
  height: 44px;
  background: var(--paper);
  color: var(--ink);
  font-size: 28px;
  line-height: 1;
  z-index: 2;
}

.viewerNav {
  position: absolute;
  top: 45%;
  width: 42px;
  height: 54px;
  transform: translateY(-50%);
  background: rgba(255, 255, 255, 0.92);
  color: var(--ink);
  font-size: 34px;
  z-index: 2;
}

.viewerPrev {
  left: 8px;
}

.viewerNext {
  right: 8px;
}

.viewerChoose,
.viewerImprove {
  min-height: 52px;
}

.viewerChoose {
  background: var(--blue);
  color: #001114;
}

.viewerImprove {
  background: var(--paper);
  color: var(--ink);
}

.viewerEmailEdit {
  display: grid;
  gap: 10px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--paper);
}

.viewerEmailEdit[hidden] {
  display: none;
}

.viewerEmailEdit label {
  font-size: 14px;
  font-weight: 900;
}

.viewerEmailEdit textarea {
  min-height: 100px;
  resize: vertical;
}

@media (min-width: 720px) {
  body {
    display: grid;
    place-items: start center;
  }

  .portrait-widget {
    min-height: auto;
    margin: 28px auto;
    border: 1px solid var(--line);
    border-radius: 8px;
    box-shadow: var(--shadow);
  }
}
