:root {
  --bg: #FFFFFF;
  --ink: #111111;
  --muted: #9A9A9A;
  --faint: #B5B5B5;
  --line: #EBEBEB;
  --ghost: #F5F5F5;
  --accent: #E1251B;
  --font: "Inter Tight", system-ui, sans-serif;

  /* Motion */
  --ease-out: cubic-bezier(0.23, 1, 0.32, 1);        /* entering, press feedback */
  --ease-in-out: cubic-bezier(0.77, 0, 0.175, 1);    /* things moving on screen */
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  font-size: 15px;
  line-height: 22px;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; }
button:focus-visible, [tabindex]:focus-visible, [contenteditable]:focus-visible { outline: 1.5px solid var(--ink); outline-offset: 3px; border-radius: 4px; }
.muted { color: var(--muted); }

/* Top bar */
.topbar {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  padding: 32px 56px 0;
  font-size: 13px;
  line-height: 16px;
}
.topbar { align-items: center; }
.tb-left { display: flex; align-items: baseline; gap: 16px; min-width: 0; }
.tb-right { display: flex; justify-content: flex-end; align-items: baseline; gap: 24px; }
.brand { font-weight: 500; font-size: 13px; }
.file-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tabs { position: relative; display: flex; gap: 28px; }
.tabs button { font-size: 13px; line-height: 16px; color: var(--muted); padding-bottom: 4px; transition: color 150ms ease; }
.tabs button:hover { color: var(--ink); }
.tabs button[aria-current="step"] { color: var(--ink); font-weight: 500; }
/* One 1px line, stretched with scaleX and moved with translateX to the current tab */
.tab-ind {
  position: absolute; left: 0; bottom: 0; width: 1px; height: 1px;
  background: var(--ink); transform-origin: left; pointer-events: none;
  transition: transform 280ms var(--ease-in-out);
}
.menu-btn { font-size: 13px; line-height: 16px; }
/* Menu only once there is an image */
body[data-step="drop"] .tabs,
body[data-step="drop"] .menu-btn { visibility: hidden; }

main { padding: 0 56px 56px; }
.view { display: none; flex-direction: column; align-items: center; }
/* Each screen settles in when you arrive. Leaving is instant. */
.view {
  transition: opacity 260ms var(--ease-out), transform 260ms var(--ease-out);
  @starting-style { opacity: 0; transform: translateY(8px); }
}
body[data-step="drop"] [data-view="drop"],
body[data-step="arrange"] [data-view="arrange"],
body[data-step="adjust"] [data-view="adjust"],
body[data-step="preview"] [data-view="preview"] { display: flex; }

/* Message */
.message { display: flex; flex-direction: column; align-items: center; gap: 16px; padding-top: 88px; text-align: center; }
.message h1 { margin: 0; font-weight: 300; font-size: 72px; line-height: 76px; letter-spacing: -0.04em; }
.message p { margin: 0; color: var(--muted); max-width: 440px; }
.message.small { gap: 12px; padding-top: 72px; }
.message.small h1 { font-size: 48px; line-height: 52px; letter-spacing: -0.035em; }
.message.small p { max-width: 560px; }

/* Fan */
.fan-wrap { width: 100%; display: flex; justify-content: center; padding-top: 56px; overflow: hidden; }
.fan { position: relative; width: 1160px; height: 380px; flex-shrink: 0; transform-origin: top center; }
.fan .card {
  position: absolute; left: 0; top: 0;   /* placed with transform: translate() rotate() */
  padding: 6px;
  background: #fff;
  border-radius: 4px;
  box-shadow: 0 24px 48px rgba(0,0,0,0.14);
  transition: transform 320ms var(--ease-in-out);
}
.fan .card canvas { display: block; }
.fan .ghost { position: absolute; border-radius: 6px; background: var(--ghost); border: 1px solid var(--line); }
.fan .more {
  position: absolute; right: -8px; bottom: 0;
  font-size: 13px; color: var(--muted);
}

.drop-card {
  position: absolute; left: 454px; top: 0; z-index: 2;
  width: 252px; height: 312px;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px;
  background: #fff; border: 1px dashed #BDBDBD; border-radius: 8px;
  box-shadow: 0 24px 48px rgba(0,0,0,0.08);
  cursor: pointer;
  transition: border-color 200ms ease, transform 200ms var(--ease-out);
}
@media (hover: hover) and (pointer: fine) {
  .drop-card:hover { border-color: var(--ink); transform: translateY(-2px); }
}
.drop-card:active { transform: scale(0.98); transition-duration: 120ms; }
.drop-card strong { font-weight: 500; }
.drop-card span { font-size: 13px; color: var(--muted); line-height: 16px; }

/* Controls */
.controls-slot { display: flex; flex-direction: column; align-items: center; }
.controls { display: flex; align-items: center; gap: 40px; padding-top: 40px; flex-wrap: wrap; justify-content: center; row-gap: 20px; }
.ctl { display: flex; align-items: center; gap: 14px; }
.ctl .label { font-size: 13px; color: var(--muted); }
.ctl .value { font-weight: 500; min-width: 24px; text-align: center; font-variant-numeric: tabular-nums; }
.step-btn { width: 20px; height: 24px; color: var(--ink); transition: transform 140ms var(--ease-out), color 150ms ease; }
.step-btn:active:not(:disabled) { transform: scale(0.85); }
.step-btn:disabled { color: #D6D6D6; cursor: default; }
.opt { color: var(--muted); border-bottom: 1px solid transparent; }
.opt[aria-checked="true"] { color: var(--ink); font-weight: 500; border-bottom-color: var(--ink); }
.divider { width: 1px; height: 16px; background: #E6E6E6; }
.primary {
  display: inline-flex; align-items: center;
  padding: 12px 22px; border-radius: 999px;
  background: var(--accent); color: #fff; font-weight: 500;
  transition: transform 160ms var(--ease-out), opacity 150ms ease;
}
@media (hover: hover) and (pointer: fine) {
  .primary:hover:not(:disabled) { transform: translateY(-1px); }
}
.primary:active:not(:disabled) { transform: scale(0.97); }
.primary:disabled { opacity: .5; cursor: progress; }
.footnote { margin: 0; padding-top: 20px; font-size: 12px; line-height: 16px; color: var(--faint); text-align: center; }
.footnote .warn { color: var(--ink); }
.steps { display: flex; gap: 32px; padding-top: 28px; }
.link { color: var(--ink); }
.link.muted { color: var(--muted); }
.link { transition: color 150ms ease; }
.link:hover { color: var(--accent); }
.underline { border-bottom: 1px solid currentColor; }

/* Cuts: the image split into its slices, one organized sheet */
.sheet-tools { display: flex; gap: 20px; align-items: baseline; justify-content: center; margin-top: 40px; font-size: 13px; line-height: 16px; }
.sheet-tools .link {
  font-size: 13px;
  transition: color 150ms ease, opacity 200ms var(--ease-out);
  @starting-style { opacity: 0; }                  /* "Make them equal" fades in after the first drag */
}
.sheet-wrap { position: relative; width: 100%; margin-top: 24px; }
.sheet-wrap.overflow::after {
  content: ""; position: absolute; right: 0; top: 0; bottom: 28px; width: 120px;
  background: linear-gradient(90deg, #fff0, #fff); pointer-events: none;
}
.sheet {
  display: flex; gap: 0; justify-content: center;
  overflow-x: auto; scrollbar-width: none; padding-bottom: 2px;
}
.sheet::-webkit-scrollbar { display: none; }
.sheet-wrap.overflow .sheet { justify-content: flex-start; padding-right: 120px; }
.sheet .slice { display: flex; flex-direction: column; gap: 10px; flex-shrink: 0; }
.sheet canvas { display: block; box-shadow: 0 0 0 1px rgba(0,0,0,0.06); }
.sheet .num { display: flex; justify-content: space-between; font-size: 12px; line-height: 16px; color: var(--muted); font-variant-numeric: tabular-nums; }
.sheet .slice:first-child .num { color: var(--ink); }
.sheet .num .px { color: var(--faint); }

/* Drag handle between two slices: an 8 px gap you can grab */
.handle {
  position: relative; width: 8px; flex-shrink: 0;
  cursor: col-resize; touch-action: none; outline: none;
}
.handle::before {                     /* the cut line, shown on hover/drag/focus */
  content: ""; position: absolute; left: 3px; top: 0; bottom: 0; width: 2px;
  background: var(--accent); opacity: 0; transition: opacity .15s;
}
.handle::after {                      /* small grip, always visible so it's discoverable */
  content: ""; position: absolute; left: 1px; top: 50%; width: 6px; height: 28px; margin-top: -14px;
  border-radius: 999px; background: #fff; box-shadow: 0 0 0 1px #D6D6D6, 0 2px 6px rgba(0,0,0,.12);
  transition: box-shadow 150ms ease, background 150ms ease, transform 160ms var(--ease-out);
}
.handle:hover::before, .handle.active::before, .handle:focus-visible::before { opacity: 1; }
.handle:hover::after, .handle.active::after, .handle:focus-visible::after { background: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.handle.active::after { transform: scaleY(1.2); }    /* the grip answers the grab */

.overview { position: relative; margin-top: 28px; border-radius: 3px; overflow: hidden; max-width: 100%; cursor: pointer; touch-action: none; display: none; }
.overview.show { display: block; }
.overview canvas { display: block; }
.ov-window { position: absolute; top: 0; height: 100%; box-shadow: 0 0 0 9999px rgba(255,255,255,0.7); border: 1.5px solid var(--ink); border-radius: 2px; pointer-events: none; }

/* Preview */
.post {
  display: flex; flex-direction: column; gap: 12px;
  width: 600px; max-width: 100%; margin-top: 40px;
  padding: 20px 0 20px 20px;
  border: 1px solid var(--line); border-radius: 20px;
  box-shadow: 0 24px 48px rgba(0,0,0,0.06);
  overflow: hidden;
}
.post-head { display: flex; gap: 12px; align-items: center; }
.post-head strong { font-weight: 600; }
.avatar { width: 40px; height: 40px; border-radius: 999px; background: #EDEDED; flex-shrink: 0; }
.caption { margin: 0; padding: 0 20px 0 52px; outline-offset: 2px; }
.swipe {
  display: flex; gap: 4px; overflow-x: auto; scroll-snap-type: x mandatory;
  padding: 4px 20px 0 52px; scroll-padding-left: 52px; scrollbar-width: none;
}
.swipe::-webkit-scrollbar { display: none; }
.swipe canvas { height: 300px; width: auto; flex-shrink: 0; scroll-snap-align: start; display: block; }
.swipe canvas:first-child { border-radius: 14px 0 0 14px; }
.swipe canvas:last-child { border-radius: 0 14px 14px 0; }
.swipe-meta { display: flex; justify-content: space-between; align-items: center; padding: 4px 20px 0 52px; font-size: 13px; font-weight: 500; }
.dots { display: flex; gap: 4px; align-items: center; }
.dots i { width: 4px; height: 4px; border-radius: 999px; background: #D9D9D9; transition: width 220ms var(--ease-out), background-color 220ms ease; }
.dots i.on { width: 16px; background: var(--ink); }
.actions { display: flex; align-items: center; gap: 32px; padding-top: 40px; }

/* Drag overlay + toast */
.dragging-overlay {
  position: fixed; inset: 16px; border: 1px dashed var(--ink); border-radius: 20px;
  display: none; align-items: center; justify-content: center;
  background: rgba(255,255,255,.85); font-size: 15px; z-index: 10; pointer-events: none;
  transition: opacity 150ms ease;
  @starting-style { opacity: 0; }
}
body.dragover .dragging-overlay { display: flex; }
.toast {
  position: fixed; left: 50%; bottom: 32px; transform: translate(-50%, 20px);
  background: var(--ink); color: #fff; font-size: 13px; padding: 10px 16px; border-radius: 999px;
  opacity: 0; pointer-events: none;
  transition: opacity 200ms var(--ease-out), transform 200ms var(--ease-out);   /* leave fast */
}
.toast.show {
  opacity: 1; transform: translate(-50%, 0);
  transition-duration: 380ms;                                                   /* arrive a little slower */
}

/* Reduced motion: keep the fades that explain what changed, drop the movement */
@media (prefers-reduced-motion: reduce) {
  .view { @starting-style { transform: none; } }
  .fan .card, .tab-ind { transition: none; }
  .drop-card, .primary, .step-btn, .handle::after { transform: none !important; }
  .toast, .toast.show { transform: translate(-50%, 0); }
}

/* Narrow screens: no dedicated mobile design yet, this keeps it usable */
@media (max-width: 760px) {
  .topbar { padding: 20px 16px 0; grid-template-columns: 1fr auto; row-gap: 16px; }
  .topbar #fileLabel { display: none; }
  .tabs { grid-row: 2; grid-column: 1 / -1; justify-content: center; }
  .tb-right { gap: 16px; }
  body[data-step="drop"] .tabs { display: none; }
  main { padding: 0 16px 40px; }
  .message { padding-top: 48px; }
  .message h1 { font-size: 40px; line-height: 44px; }
  .message.small h1 { font-size: 32px; line-height: 36px; }
  .fan-wrap { padding-top: 32px; }
  .controls { gap: 20px; }
  .divider { display: none; }
  .swipe canvas { height: 240px; }
  .actions { flex-wrap: wrap; justify-content: center; gap: 20px; }
}
