:root {
  --ink: #171714;
  --paper: #f0eee7;
  --paper-deep: #e3e0d6;
  --white: #fff;
  --muted: #8c8a82;
  --line: rgba(23, 23, 20, 0.18);
  --accent: #ff5636;
  --stage: #24241f;
  --display: "Bodoni 72", "Didot", "Times New Roman", serif;
  --sans: "Avenir Next", "Avenir", "Century Gothic", sans-serif;
}

* {
  box-sizing: border-box;
}

/* Author-level display rules override the browser's native [hidden] rule in
   Safari, so keep hidden application views unconditionally out of layout. */
[hidden] {
  display: none !important;
}

html,
body {
  min-height: 100%;
}

body {
  margin: 0;
  overflow-x: hidden;
  color: var(--ink);
  background: var(--paper);
  font-family: var(--sans);
  font-size: 14px;
}

button,
input {
  font: inherit;
}

button {
  color: inherit;
}

button:focus-visible,
input:focus-visible,
canvas:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}

.grain {
  position: fixed;
  inset: 0;
  z-index: 10;
  pointer-events: none;
  opacity: 0.055;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 180 180' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='.8'/%3E%3C/svg%3E");
}

.app-shell {
  min-height: 100vh;
}

.topbar {
  position: relative;
  z-index: 2;
  display: grid;
  grid-template-columns: 270px 1fr auto;
  align-items: center;
  min-width: 0;
  padding: 0 24px 0 30px;
  border-bottom: 1px solid var(--line);
}

.wordmark {
  width: max-content;
  color: var(--ink);
  text-decoration: none;
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.055em;
}

.wordmark__frame {
  font-weight: 500;
}

.wordmark__slash {
  margin: 0 2px;
  color: var(--accent);
}

.topbar__note {
  margin: 0;
  color: #6f6d66;
  font-family: var(--display);
  font-size: 14px;
  font-style: italic;
  letter-spacing: 0.02em;
}

.button {
  height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 24px;
  padding: 0 20px;
  border: 1px solid transparent;
  border-radius: 0;
  cursor: pointer;
  text-transform: uppercase;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.15em;
  transition: transform 160ms ease, background 160ms ease, color 160ms ease, opacity 160ms ease;
}

.button svg {
  width: 17px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
}

.button:hover:not(:disabled) {
  transform: translateY(-2px);
}

.button:active:not(:disabled) {
  transform: translateY(0);
}

.button:disabled {
  cursor: not-allowed;
  opacity: 0.35;
}

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

.button--accent {
  min-width: 220px;
  color: var(--ink);
  background: var(--accent);
}

.button--accent:hover:not(:disabled) {
  color: var(--white);
  background: var(--ink);
}

.button--ghost {
  border-color: var(--line);
  background: transparent;
}

.workspace {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 270px minmax(0, 1fr);
}

.filmstrip {
  min-height: 0;
  display: flex;
  flex-direction: column;
  padding: 25px 16px 18px;
  border-right: 1px solid var(--line);
  background: rgba(231, 228, 218, 0.43);
}

.filmstrip__header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  padding: 0 8px 20px;
}

.eyebrow {
  margin: 0 0 7px;
  color: #7a786f;
  text-transform: uppercase;
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.21em;
}

.filmstrip__count {
  margin: 0;
  font-family: var(--display);
  font-size: 18px;
  font-style: italic;
}

.icon-button {
  width: 33px;
  height: 33px;
  display: grid;
  place-items: center;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: transparent;
  cursor: pointer;
  transition: color 150ms ease, border-color 150ms ease, transform 150ms ease;
}

.icon-button:hover {
  color: var(--accent);
  border-color: var(--accent);
  transform: rotate(90deg);
}

.icon-button svg {
  width: 15px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.5;
}

.thumbnail-list {
  min-height: 0;
  flex: 1;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--ink) transparent;
}

.thumbnail {
  position: relative;
  width: 100%;
  display: grid;
  grid-template-columns: 24px 72px minmax(0, 1fr) 24px;
  align-items: center;
  gap: 10px;
  padding: 10px 8px;
  border: 0;
  border-top: 1px solid var(--line);
  background: transparent;
  text-align: left;
  cursor: pointer;
  transition: background 160ms ease;
}

.thumbnail--enter {
  animation: slide-in 420ms cubic-bezier(0.22, 1, 0.36, 1) both;
}

.thumbnail:last-child {
  border-bottom: 1px solid var(--line);
}

.thumbnail:hover,
.thumbnail.is-active {
  background: var(--white);
}

.thumbnail__number {
  align-self: start;
  padding-top: 2px;
  color: #7a786f;
  font-family: var(--display);
  font-size: 11px;
  font-style: italic;
}

.thumbnail__image {
  width: 72px;
  height: 64px;
  display: block;
  border: 4px solid var(--white);
  object-fit: cover;
  box-shadow: 0 2px 8px rgba(24, 23, 19, 0.12);
}

.thumbnail__meta {
  min-width: 0;
}

.thumbnail__name {
  display: block;
  overflow: hidden;
  margin-bottom: 5px;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 10px;
  font-weight: 650;
  letter-spacing: 0.02em;
}

.thumbnail__size {
  color: #8b8981;
  font-size: 8px;
  letter-spacing: 0.08em;
}

.thumbnail__remove {
  width: 22px;
  height: 22px;
  display: grid;
  place-items: center;
  border: 0;
  background: transparent;
  cursor: pointer;
  opacity: 0;
  transition: opacity 150ms ease, color 150ms ease;
}

.thumbnail:hover .thumbnail__remove,
.thumbnail.is-active .thumbnail__remove,
.thumbnail__remove:focus-visible {
  opacity: 1;
}

.thumbnail__remove:hover {
  color: var(--accent);
}

.thumbnail__remove svg {
  width: 13px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.5;
}

.filmstrip__add {
  width: 100%;
  height: 45px;
  flex: 0 0 auto;
  margin-top: 14px;
  border: 1px dashed rgba(23, 23, 20, 0.3);
  background: transparent;
  cursor: pointer;
  text-transform: uppercase;
  font-size: 8px;
  font-weight: 700;
  letter-spacing: 0.17em;
  transition: border-color 150ms ease, color 150ms ease;
}

.filmstrip__actions {
  flex: 0 0 auto;
}

.filmstrip__export {
  width: 100%;
  margin-top: 8px;
  justify-content: space-between;
}

.filmstrip__add:hover {
  color: var(--accent);
  border-color: var(--accent);
}

.filmstrip__add span {
  margin-right: 8px;
  font-size: 15px;
  font-weight: 400;
}

.editor {
  position: relative;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
}

.empty-state {
  min-height: 100%;
  display: grid;
  place-items: center;
  padding: clamp(42px, 7vw, 100px);
}

.drop-card {
  position: relative;
  z-index: 1;
  justify-self: center;
  width: min(100%, 350px);
  aspect-ratio: 3 / 4;
  padding: 26px;
  border: 1px solid var(--ink);
  border-radius: 0;
  color: var(--paper);
  background-color: var(--stage);
  background-image: repeating-linear-gradient(0deg, transparent 0 38px, rgba(255, 255, 255, 0.035) 39px), repeating-linear-gradient(90deg, transparent 0 38px, rgba(255, 255, 255, 0.035) 39px);
  cursor: pointer;
  box-shadow: 18px 18px 0 var(--accent);
  text-align: left;
  transition: transform 250ms cubic-bezier(0.22, 1, 0.36, 1), box-shadow 250ms ease;
  animation: rise 720ms cubic-bezier(0.22, 1, 0.36, 1) both;
  animation-delay: 100ms;
}

.drop-card:hover,
.editor.is-dragging .drop-card {
  transform: translate(-5px, -5px) rotate(-1deg);
  box-shadow: 26px 26px 0 var(--accent);
}

.drop-card__corner,
.drop-card__formats {
  position: absolute;
  color: rgba(240, 238, 231, 0.62);
  font-size: 8px;
  font-weight: 700;
  letter-spacing: 0.18em;
  line-height: 1.55;
}

.drop-card__corner {
  top: 24px;
  left: 24px;
}

.drop-card__formats {
  right: 22px;
  bottom: 22px;
}

.drop-card__ratio {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: rgba(240, 238, 231, 0.12);
  font-family: var(--display);
  font-size: clamp(80px, 9vw, 138px);
  font-style: italic;
  letter-spacing: -0.08em;
}

.drop-card__action {
  position: absolute;
  z-index: 1;
  left: 25px;
  right: 25px;
  top: 50%;
  transform: translateY(-50%);
  text-transform: uppercase;
  font-size: 17px;
  font-weight: 700;
  letter-spacing: 0.1em;
  line-height: 1.3;
}

.drop-card__action small {
  display: block;
  margin-top: 12px;
  color: rgba(240, 238, 231, 0.66);
  font-size: 7px;
  font-weight: 700;
  letter-spacing: 0.18em;
}

.editor-view {
  min-height: 100%;
  grid-template-columns: minmax(360px, 1fr) minmax(440px, 0.92fr);
  grid-template-rows: auto minmax(0, 1fr) auto;
  column-gap: clamp(38px, 5vw, 90px);
  padding: 34px clamp(30px, 5vw, 72px) 28px;
}

.editor-view:not([hidden]) {
  display: grid;
}

.editor-view__heading {
  grid-column: 1 / -1;
  display: flex;
  justify-content: space-between;
  align-items: start;
  padding-bottom: 22px;
}

.editor-view__heading h1 {
  max-width: 50vw;
  overflow: hidden;
  margin: 0;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-family: var(--display);
  font-size: clamp(24px, 2.6vw, 38px);
  font-style: italic;
  font-weight: 400;
  letter-spacing: -0.035em;
}

.frame-step {
  padding-top: 8px;
  color: #76746d;
  font-family: var(--display);
  font-size: 13px;
  font-style: italic;
}

.frame-step span:first-child {
  color: var(--ink);
  font-size: 22px;
}

.editor-stage-wrap {
  grid-row: 2 / 4;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-width: 0;
  min-height: 0;
}

.editor-stage {
  position: relative;
  overflow: hidden;
  height: min(64vh, 700px);
  max-height: calc(100vh - 210px);
  aspect-ratio: 3 / 4;
  background: var(--white);
  box-shadow: 0 22px 55px rgba(29, 28, 24, 0.22);
  cursor: grab;
  user-select: none;
  touch-action: none;
  animation: reveal-frame 620ms cubic-bezier(0.22, 1, 0.36, 1) both;
}

.editor-stage:active {
  cursor: grabbing;
}

#cropCanvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  background: var(--white);
}

.drag-hint {
  position: absolute;
  left: 50%;
  bottom: 18%;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 12px;
  color: var(--paper);
  background: rgba(23, 23, 20, 0.8);
  backdrop-filter: blur(8px);
  transform: translateX(-50%);
  pointer-events: none;
  text-transform: uppercase;
  white-space: nowrap;
  font-size: 7px;
  font-weight: 700;
  letter-spacing: 0.16em;
  transition: opacity 300ms ease;
}

.drag-hint.is-hidden {
  opacity: 0;
}

.drag-hint svg {
  width: 14px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.4;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.stage-caption {
  width: 100%;
  display: flex;
  justify-content: space-between;
  margin: 11px 0 0;
  color: #89867d;
  text-transform: uppercase;
  font-size: 7px;
  font-weight: 700;
  letter-spacing: 0.15em;
}

.stage-caption span {
  color: var(--ink);
}

.controls {
  grid-column: 2;
  grid-row: 2 / 4;
  align-self: center;
  display: grid;
  gap: 0;
  border-top: 1px solid var(--line);
  animation: rise 600ms 100ms cubic-bezier(0.22, 1, 0.36, 1) both;
}

.control-group {
  padding: 26px 0;
  border-bottom: 1px solid var(--line);
}

.control-group > label:first-child,
.toggle-row > span:first-child {
  text-transform: uppercase;
  font-size: 8px;
  font-weight: 700;
  letter-spacing: 0.17em;
}

.control-group--zoom {
  display: grid;
  grid-template-columns: 1fr auto minmax(120px, 2.2fr) auto 50px;
  align-items: center;
  gap: 12px;
}

.zoom-mark {
  width: 24px;
  height: 24px;
  display: grid;
  place-items: center;
  padding: 0;
  border: 0;
  background: transparent;
  cursor: pointer;
  font-family: var(--display);
  font-size: 20px;
}

#zoomRange,
#borderRange {
  width: 100%;
  height: 2px;
  accent-color: var(--accent);
  cursor: pointer;
}

#zoomValue {
  text-align: right;
  font-family: var(--display);
  font-size: 13px;
  font-style: italic;
}

.control-group--toggles {
  display: grid;
  gap: 20px;
}

.composition-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.composition-row > span {
  text-transform: uppercase;
  font-size: 8px;
  font-weight: 700;
  letter-spacing: 0.17em;
}

.segmented {
  display: grid;
  grid-template-columns: 1fr 1.45fr;
  border: 1px solid rgba(23, 23, 20, 0.25);
}

.segmented button {
  height: 30px;
  padding: 0 10px;
  border: 0;
  background: transparent;
  cursor: pointer;
  text-transform: uppercase;
  white-space: nowrap;
  font-size: 7px;
  font-weight: 700;
  letter-spacing: 0.1em;
  transition: color 150ms ease, background 150ms ease;
}

.segmented button + button {
  border-left: 1px solid rgba(23, 23, 20, 0.25);
}

.segmented button[aria-pressed="true"] {
  color: var(--paper);
  background: var(--ink);
}

.toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
}

.toggle-row input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.toggle {
  position: relative;
  width: 38px;
  height: 20px;
  border: 1px solid rgba(23, 23, 20, 0.3);
  border-radius: 20px;
  transition: background 150ms ease;
}

.toggle::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--ink);
  transition: transform 160ms ease, background 160ms ease;
}

.toggle-row input:checked + .toggle {
  background: var(--ink);
}

.toggle-row input:checked + .toggle::after {
  background: var(--paper);
  transform: translateX(18px);
}

.toggle-row input:focus-visible + .toggle {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}

.border-control {
  display: grid;
  gap: 10px;
  padding-top: 2px;
}

.border-control__heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.border-control__heading label {
  text-transform: uppercase;
  font-size: 8px;
  font-weight: 700;
  letter-spacing: 0.17em;
}

.border-control__heading output {
  min-width: 42px;
  padding: 5px 8px;
  color: var(--paper);
  background: var(--ink);
  text-align: center;
  font-family: var(--display);
  font-size: 11px;
  font-style: italic;
}

.border-control__range {
  display: grid;
  grid-template-columns: 18px 1fr 22px;
  align-items: center;
  gap: 8px;
}

.border-control__range span {
  color: #89867d;
  font-family: var(--display);
  font-size: 10px;
  font-style: italic;
}

.border-control__range span:last-child {
  text-align: right;
}

.border-control p {
  margin: -2px 0 0 26px;
  color: #8a877f;
  text-transform: uppercase;
  font-size: 6px;
  font-weight: 700;
  letter-spacing: 0.14em;
}

.control-actions {
  display: grid;
  grid-template-columns: 0.8fr 1.2fr;
  gap: 10px;
  padding-top: 28px;
}

.footer {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  align-items: center;
  padding: 0 30px;
  border-top: 1px solid var(--line);
  color: #7a786f;
  text-transform: uppercase;
  font-size: 7px;
  font-weight: 700;
  letter-spacing: 0.16em;
}

.footer span:nth-child(2) {
  text-align: center;
}

.footer span:last-child {
  text-align: right;
}

.toast {
  position: fixed;
  z-index: 20;
  right: 24px;
  bottom: 24px;
  padding: 13px 18px;
  color: var(--paper);
  background: var(--ink);
  box-shadow: 5px 5px 0 var(--accent);
  transform: translateY(30px);
  opacity: 0;
  pointer-events: none;
  text-transform: uppercase;
  font-size: 8px;
  font-weight: 700;
  letter-spacing: 0.14em;
  transition: opacity 200ms ease, transform 200ms ease;
}

.toast.is-visible {
  opacity: 1;
  transform: translateY(0);
}

@keyframes rise {
  from { opacity: 0; transform: translateY(22px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes slide-in {
  from { opacity: 0; transform: translateX(-12px); }
  to { opacity: 1; transform: translateX(0); }
}

@keyframes reveal-frame {
  from { opacity: 0; clip-path: inset(0 0 100% 0); }
  to { opacity: 1; clip-path: inset(0); }
}

@media (max-width: 1050px) {
  .workspace { grid-template-columns: 220px minmax(0, 1fr); }
  .editor-view { grid-template-columns: minmax(290px, 1fr) minmax(330px, 0.9fr); column-gap: 32px; }
  .thumbnail { grid-template-columns: 20px 58px minmax(0, 1fr) 20px; gap: 8px; }
  .thumbnail__image { width: 58px; height: 54px; }
  .empty-state { padding: 55px; gap: 55px; }
}

@media (max-width: 760px) {
  .workspace { display: block; }
  .filmstrip { position: relative; height: 154px; padding: 10px 12px 58px; border: 0; border-bottom: 1px solid var(--line); }
  .filmstrip__header { display: none; }
  .thumbnail-list { display: flex; gap: 8px; overflow-x: auto; overflow-y: hidden; }
  .thumbnail { min-width: 76px; width: 76px; display: block; padding: 5px; border: 0; }
  .thumbnail__number, .thumbnail__meta, .thumbnail__remove { display: none; }
  .thumbnail__image { width: 66px; height: 82px; }
  .filmstrip__add { position: absolute; right: 12px; bottom: 9px; z-index: 2; width: 42px; height: 42px; overflow: hidden; margin: 0; color: var(--paper); border: 0; background: var(--ink); font-size: 0; }
  .filmstrip__add span { margin: 0; font-size: 22px; }
  .filmstrip__export { position: absolute; left: 12px; right: 64px; bottom: 9px; width: auto; height: 42px; margin: 0; }
  .empty-state { min-height: calc(100vh - 154px); padding: 42px 24px 65px; }
  .drop-card { width: min(80vw, 330px); justify-self: center; }
  .editor-view:not([hidden]) { display: block; padding: 28px 20px 45px; }
  .editor-view[hidden] { display: none; }
  .editor-view__heading { padding-bottom: 20px; }
  .editor-view__heading h1 { max-width: 70vw; }
  .editor-stage-wrap { min-height: auto; }
  .editor-stage { width: min(78vw, 370px); height: auto; max-height: none; }
  .controls { margin-top: 34px; }
  .control-group--zoom { grid-template-columns: 50px auto 1fr auto 42px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
