:root {
  color-scheme: dark;
  --night: #100719;
  --night-soft: #1b0c2b;
  --panel: rgba(31, 15, 47, .88);
  --line: rgba(219, 180, 255, .18);
  --lavender: #d7a4ff;
  --pink: #ff37c7;
  --blue: #5479ff;
  --white: #fff9ff;
  --muted: #c0adc9;
  --radius: 22px;
}

* { box-sizing: border-box; }

html { scrollbar-width: none; }
html::-webkit-scrollbar, body::-webkit-scrollbar, .caption-dialog::-webkit-scrollbar { display: none; }

body {
  min-width: 320px;
  margin: 0;
  overflow-x: clip;
  scrollbar-width: none;
  background:
    radial-gradient(ellipse at 74% 8%, rgba(103, 37, 173, .35), transparent 34rem),
    radial-gradient(ellipse at 10% 33%, rgba(120, 10, 104, .2), transparent 34rem),
    radial-gradient(circle at 13% 8%, #fff 0 1px, transparent 1.7px),
    radial-gradient(circle at 82% 17%, #e8c4ff 0 1px, transparent 1.8px),
    radial-gradient(circle at 91% 43%, #fff 0 1px, transparent 1.8px),
    radial-gradient(circle at 24% 62%, #d7a4ff 0 1px, transparent 1.8px),
    radial-gradient(circle at 65% 74%, #fff 0 1px, transparent 1.8px),
    var(--night);
  background-size: auto, auto, 190px 190px, 250px 250px, 310px 310px, 280px 280px, 370px 370px, auto;
  color: var(--white);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
}

button, input { font: inherit; }
button { color: inherit; }
button:focus-visible, input:focus-visible, .file-button:focus-visible {
  outline: 3px solid var(--lavender);
  outline-offset: 3px;
}

.shell { width: min(1120px, calc(100% - 48px)); margin-inline: auto; }

.topbar {
  min-height: 82px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  border-bottom: 1px solid var(--line);
}

.organizer { display: flex; align-items: center; gap: 12px; }
.organizer-logo { width: 42px; height: 54px; object-fit: contain; }
.organizer-name { color: var(--white); font-size: 11px; font-weight: 850; letter-spacing: .15em; }
.top-note {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 750;
  letter-spacing: .12em;
  text-transform: uppercase;
}
.top-note::before { width: 7px; height: 7px; border-radius: 50%; background: var(--pink); box-shadow: 0 0 14px var(--pink); content: ""; }

.step-label {
  color: var(--lavender);
  font-size: 10px;
  font-weight: 850;
  letter-spacing: .2em;
  text-transform: uppercase;
}
.organizer-name { display: grid; gap: 3px; color: var(--white); font-size: 11px; font-weight: 500; letter-spacing: 0; }
.organizer-name strong { font-size: 11px; font-weight: 800; letter-spacing: .025em; }
.organizer-name span { color: var(--lavender); font-size: 9px; font-weight: 850; letter-spacing: .15em; }

.editor-section { padding: 34px 0 64px; }
.section-heading { max-width: 640px; margin: 0 auto 24px; text-align: center; }
.section-heading { position: relative; isolation: isolate; padding: 22px 0; }
.section-heading::before {
  position: absolute;
  z-index: -1;
  top: 50%;
  left: 50%;
  width: 230px;
  aspect-ratio: 1;
  background: url("assets/Main Logo V2.png") center / contain no-repeat;
  content: "";
  opacity: .13;
  pointer-events: none;
  transform: translate(-50%, -50%);
}
.section-heading h1 {
  margin: 6px 0 0;
  background: linear-gradient(95deg, #ff73dd 4%, #d69aff 50%, #7595ff 94%);
  background-clip: text;
  color: transparent;
  font-size: clamp(30px, 5vw, 48px);
  font-weight: 900;
  letter-spacing: -.06em;
  line-height: 1;
  -webkit-background-clip: text;
}
.section-heading p { margin: 10px 0 0; color: var(--muted); font-size: 13px; line-height: 1.65; }
.studio {
  display: grid;
  grid-template-columns: minmax(280px, .83fr) minmax(340px, 1.17fr);
  gap: 16px;
  align-items: stretch;
}
.panel {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  box-shadow: 0 18px 55px rgba(0, 0, 0, .2);
  backdrop-filter: blur(14px);
}
.upload-panel, .preview-panel { display: flex; flex-direction: column; padding: 26px; }
.panel h3 { margin: 9px 0 6px; font-size: 20px; letter-spacing: -.045em; }
.panel-copy { margin: 0; color: var(--muted); font-size: 12px; line-height: 1.6; }

.dropzone {
  position: relative;
  display: flex;
  min-height: 190px;
  flex: 1;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  margin: 22px 0 16px;
  padding: 20px;
  border: 1px dashed rgba(215,164,255,.48);
  border-radius: 15px;
  background: linear-gradient(140deg, rgba(255,55,199,.06), rgba(84,121,255,.08));
  text-align: center;
  transition: border-color .18s ease, background .18s ease, transform .18s ease;
}
.dropzone.is-over { transform: scale(1.01); border-color: var(--pink); background: rgba(255,55,199,.12); }
.upload-icon { display: grid; width: 44px; height: 44px; margin-bottom: 13px; place-items: center; border: 1px solid rgba(255,55,199,.55); border-radius: 14px; background: rgba(255,55,199,.12); color: #ff8be1; }
.upload-icon svg { width: 21px; height: 21px; }
.drop-title { margin: 0; font-size: 13px; font-weight: 750; }
.drop-hint { margin: 7px 0 13px; color: var(--muted); font-size: 11px; }
.file-button {
  display: inline-flex;
  min-height: 38px;
  align-items: center;
  justify-content: center;
  padding: 0 15px;
  border: 1px solid rgba(255, 94, 210, .58);
  border-radius: 9px;
  background: linear-gradient(110deg, rgba(255,55,199,.18), rgba(84,121,255,.18));
  color: var(--white);
  cursor: pointer;
  font-size: 12px;
  font-weight: 800;
  transition: border-color .15s ease, background .15s ease;
}
.file-button:hover { border-color: #ff9ee5; background: rgba(255,55,199,.24); }
.file-input { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; clip-path: inset(50%); }
.file-input:focus-visible + .file-button { outline: 3px solid var(--lavender); outline-offset: 3px; }
.photo-details { display: none; align-items: center; justify-content: space-between; gap: 10px; width: 100%; }
.photo-details.is-visible { display: flex; }
.file-info { min-width: 0; flex: 1; }
.file-name { overflow: hidden; color: var(--white); font-size: 12px; font-weight: 700; text-overflow: ellipsis; white-space: nowrap; }
.file-size { margin-top: 4px; color: var(--muted); font-size: 11px; }
.text-button { padding: 6px; border: 0; background: transparent; color: var(--lavender); cursor: pointer; font-size: 11px; font-weight: 750; }
.text-button:hover { color: var(--white); text-decoration: underline; }

.hint-row { display: flex; align-items: flex-start; gap: 8px; color: var(--muted); font-size: 11px; line-height: 1.55; }
.hint-row svg { width: 14px; height: 14px; flex: 0 0 auto; margin-top: 1px; color: #d79aff; }
.message { min-height: 16px; margin: 9px 0 0; color: #ff9bdf; font-size: 11px; line-height: 1.5; }

.preview-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.preview-heading h3 { margin-bottom: 0; }
.live-pill { display: inline-flex; align-items: center; gap: 6px; padding: 7px 9px; border: 1px solid var(--line); border-radius: 999px; background: rgba(255,255,255,.04); color: var(--muted); font-size: 9px; font-weight: 850; letter-spacing: .08em; text-transform: uppercase; }
.live-pill::before { width: 6px; height: 6px; border-radius: 50%; background: #92879d; content: ""; }
.live-pill.is-ready::before { background: #ff4bd0; box-shadow: 0 0 0 3px rgba(255,75,208,.16), 0 0 12px #ff4bd0; }
.canvas-wrap {
  position: relative;
  display: grid;
  width: min(100%, 430px);
  aspect-ratio: 1;
  flex: 1;
  align-self: center;
  overflow: hidden;
  margin: 20px auto 16px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 13px;
  background:
    radial-gradient(ellipse at 70% 22%, rgba(124,67,167,.42), transparent 40%),
    linear-gradient(135deg, #261238, #100719 60%, #25113c);
}
#resultCanvas { display: none; width: 100%; height: 100%; object-fit: contain; touch-action: none; cursor: grab; }
#resultCanvas.is-visible { display: block; }
#resultCanvas.is-dragging { cursor: grabbing; }
.gesture-hint { margin: -7px 0 14px; color: var(--muted); font-size: 10px; text-align: center; }
.gesture-hint span { padding-inline: 5px; color: var(--lavender); }
.empty-preview { position: relative; z-index: 1; display: flex; flex-direction: column; align-items: center; color: var(--muted); text-align: center; }
.empty-preview[hidden] { display: none; }
.empty-preview svg { width: 38px; height: 38px; margin-bottom: 12px; color: var(--lavender); }
.empty-preview strong { color: var(--white); font-size: 12px; }
.empty-preview span { margin-top: 5px; font-size: 10px; }

.photo-adjustments { display: none; margin: 0 0 16px; padding: 14px; border: 1px solid var(--line); border-radius: 12px; background: rgba(255,255,255,.035); }
.photo-adjustments.is-visible { display: block; }
.adjustment-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 11px; }
.adjustment-heading .control-heading { margin: 0; }
.adjustment-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.adjustment-control { min-width: 0; }
.adjustment-label { display: flex; justify-content: space-between; gap: 8px; margin-bottom: 6px; color: var(--white); font-size: 10px; font-weight: 700; }
.adjustment-label output { color: var(--muted); font-variant-numeric: tabular-nums; }
.adjustment-control input { display: block; width: 100%; accent-color: #e85cd0; }

.download-button {
  display: flex;
  width: 100%;
  min-height: 48px;
  align-items: center;
  justify-content: center;
  gap: 9px;
  border: 0;
  border-radius: 10px;
  background: linear-gradient(105deg, #e32db3, #7655f4 75%, #4f74ff);
  color: white;
  cursor: pointer;
  font-size: 12px;
  font-weight: 850;
  transition: filter .18s ease, transform .18s ease;
}
.download-button svg { width: 17px; height: 17px; }
.download-button:not(:disabled):hover { transform: translateY(-1px); filter: brightness(1.13); }
.download-button:disabled { background: #42384c; color: #a79bad; cursor: not-allowed; }
.download-note { margin: 9px 0 0; color: var(--muted); font-size: 9px; text-align: center; }
.image-tab-button { display: block; width: 100%; min-height: 44px; margin-top: 12px; border: 1px solid var(--line); border-radius: 10px; background: rgba(255,255,255,.04); color: var(--white); cursor: pointer; font-size: 12px; font-weight: 750; }
.image-tab-button:not(:disabled):hover { border-color: var(--lavender); background: rgba(255,255,255,.08); }
.image-tab-button:disabled { color: var(--muted); cursor: not-allowed; }
.image-tab-note { margin: 7px 0 0; color: var(--muted); font-size: 10px; text-align: center; }
.caption-review-button { display: block; min-height: 42px; margin: 8px auto 0; padding: 0 12px; border: 0; background: transparent; color: var(--lavender); cursor: pointer; font-size: 12px; font-weight: 750; text-decoration: underline; text-underline-offset: 3px; }
.caption-review-button:hover { color: var(--white); }

.caption-dialog {
  width: min(560px, calc(100% - 32px));
  max-height: min(82vh, 760px);
  padding: 24px;
  overflow: auto;
  border: 1px solid rgba(215,164,255,.35);
  border-radius: 20px;
  background: #1b0c2b;
  color: var(--white);
  box-shadow: 0 24px 90px rgba(0,0,0,.62);
}
.caption-dialog::backdrop { background: rgba(8,3,13,.78); backdrop-filter: blur(5px); }
.caption-dialog-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; }
.caption-dialog-header h2 { margin: 7px 0 0; font-size: 24px; letter-spacing: -.045em; }
.dialog-close { display: grid; width: 38px; height: 38px; flex: 0 0 auto; place-items: center; border: 1px solid var(--line); border-radius: 50%; background: rgba(255,255,255,.05); color: var(--white); cursor: pointer; font-size: 25px; line-height: 1; }
.caption-intro { margin: 10px 0 16px; color: var(--muted); font-size: 13px; line-height: 1.6; }
.caption-actions { display: flex; align-items: center; flex-wrap: wrap; gap: 12px; margin-bottom: 14px; }
.caption-copy-button { min-height: 40px; padding: 0 13px; border: 1px solid rgba(255,94,210,.58); border-radius: 9px; background: linear-gradient(110deg, rgba(255,55,199,.18), rgba(84,121,255,.18)); color: var(--white); cursor: pointer; font-size: 12px; font-weight: 750; }
.caption-copy-button:hover { border-color: #ff9ee5; background: rgba(255,55,199,.24); }
.caption-copy-button:disabled { opacity: .6; cursor: wait; }
.caption-status { color: #e4c4ff; font-size: 11px; line-height: 1.5; }
.caption-text { display: block; width: 100%; min-height: 90px; resize: vertical; padding: 11px; border: 1px solid rgba(219,180,255,.2); border-radius: 8px; background: rgba(9,4,15,.55); color: var(--white); font: inherit; font-size: 13px; line-height: 1.6; }
.caption-text:focus { border-color: var(--lavender); outline: 2px solid rgba(215,164,255,.25); outline-offset: 1px; }

footer { padding: 20px 0 30px; border-top: 1px solid var(--line); color: var(--muted); font-size: 11px; text-align: center; }
footer strong { color: var(--white); }

@media (max-width: 760px) {
  .shell { width: min(100% - 32px, 540px); }
  .topbar { min-height: 70px; }
  .organizer-logo { width: 34px; height: 44px; }
  .organizer-name { font-size: 9px; }
  .top-note { font-size: 9px; }
  .organizer-name strong { max-width: 220px; font-size: 10px; line-height: 1.4; }
  .editor-section { padding: 26px 0 45px; }
  .studio { grid-template-columns: 1fr; gap: 14px; }
  .upload-panel, .preview-panel { padding: 21px; }
  .dropzone { min-height: 175px; }
  .canvas-wrap { width: min(100%, 400px); flex: none; }
}

@media (max-width: 420px) {
  .topbar { align-items: center; }
  .top-note { max-width: 120px; text-align: right; line-height: 1.5; }
  .topbar { gap: 10px; }
  .organizer { gap: 8px; }
  .organizer-name strong { max-width: 175px; font-size: 9px; }
  .adjustment-grid { grid-template-columns: 1fr; gap: 8px; }
  .adjustment-control { display: grid; grid-template-columns: 72px 1fr; align-items: center; gap: 10px; }
  .adjustment-label { margin: 0; }
  .caption-dialog { padding: 18px; }
  .caption-dialog-header h2 { font-size: 22px; }
  .caption-intro, .caption-text { font-size: 14px; }
  .caption-copy-button { min-height: 44px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition-duration: .01ms !important; }
}
