:root {
  color-scheme: dark;
  --ink: #f6f2ea;
  --muted: #a9b1bc;
  --surface: #0e1218;
  --surface-raised: #171d26;
  --surface-high: #222b37;
  --line: #34404e;
  --accent: #ffaa64;
  --accent-strong: #e47c55;
  --accent-ink: #2a1809;
  --danger: #ff9188;
  --success: #92d1b4;
}

* { box-sizing: border-box; }

html { background: var(--surface); }

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  background: var(--surface);
  color: var(--ink);
  font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  text-rendering: optimizeLegibility;
}

button, a { -webkit-tap-highlight-color: transparent; }

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

button:disabled { cursor: not-allowed; opacity: 0.55; }

.shell {
  width: min(100%, 1120px);
  margin: 0 auto;
  padding: max(28px, env(safe-area-inset-top)) 20px max(48px, env(safe-area-inset-bottom));
}

.page-header {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 28px;
  min-height: 132px;
  padding: 20px 0 28px;
  border-bottom: 1px solid var(--line);
}

.eyebrow {
  margin: 0 0 10px;
  color: var(--accent);
  font-size: 0.75rem;
  font-weight: 750;
  letter-spacing: 0.13em;
  text-transform: uppercase;
}

h1 {
  max-width: 16ch;
  margin: 0;
  font-size: clamp(2rem, 6vw, 4.5rem);
  line-height: 0.98;
  letter-spacing: -0.045em;
}

h2 { letter-spacing: -0.025em; }

.meta { margin: 0; color: var(--muted); font-size: 0.95rem; white-space: nowrap; }

.state {
  display: grid;
  min-height: 56vh;
  place-items: center;
  text-align: center;
}

.state-card { max-width: 460px; }
.state-card h2 { margin: 0 0 12px; font-size: 1.55rem; }
.state-card p { margin: 0; color: var(--muted); line-height: 1.65; }

.state-icon {
  display: grid;
  width: 64px;
  height: 64px;
  margin: 0 auto 24px;
  place-items: center;
  border: 1px solid color-mix(in srgb, var(--danger) 45%, transparent);
  border-radius: 50%;
  background: rgb(255 145 136 / 10%);
  background: color-mix(in srgb, var(--danger) 10%, transparent);
  color: var(--danger);
  font-size: 1.6rem;
  font-weight: 800;
}

.loader {
  width: 44px;
  height: 44px;
  margin: 0 auto 24px;
  border: 2px solid var(--line);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

.gallery {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 3px;
  padding-top: 3px;
}

.tile {
  position: relative;
  overflow: hidden;
  aspect-ratio: 1;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: var(--surface-raised);
  cursor: zoom-in;
}

.tile img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 240ms ease, opacity 240ms ease;
}

.tile:hover img { transform: scale(1.025); }
.tile:active img { transform: scale(1.005); }

.video-placeholder {
  display: grid;
  width: 100%;
  height: 100%;
  place-items: center;
  color: var(--accent);
  font-size: 2rem;
}

.video-badge {
  position: absolute;
  right: 10px;
  bottom: 10px;
  padding: 5px 8px;
  background: rgb(8 12 17 / 82%);
  border-radius: 5px;
  color: white;
  font-size: 0.75rem;
  font-variant-numeric: tabular-nums;
}

.upload-app { padding-top: 36px; }

.invitation {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(220px, 300px);
  gap: 56px;
  align-items: end;
  padding: 24px 0 36px;
}

.invitation h2 {
  max-width: 18ch;
  margin: 0;
  font-size: clamp(1.8rem, 4vw, 3.25rem);
  line-height: 1.03;
}

.invitation-copy {
  max-width: 58ch;
  margin: 18px 0 0;
  color: var(--muted);
  font-size: 1.04rem;
  line-height: 1.65;
}

.invitation-copy strong { color: var(--ink); }

.expiry-card {
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface-raised);
}

.expiry-card span {
  display: block;
  margin-bottom: 7px;
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.expiry-card strong { display: block; line-height: 1.4; }

.privacy-note {
  display: flex;
  gap: 14px;
  align-items: flex-start;
  margin-bottom: 18px;
  padding: 18px 20px;
  border-left: 3px solid var(--success);
  background: #18252a;
  background: color-mix(in srgb, var(--success) 7%, var(--surface-raised));
}

.privacy-mark { color: var(--success); font-weight: 900; }
.privacy-note p { margin: 0; color: var(--muted); line-height: 1.55; }
.privacy-note strong { color: var(--ink); }

.picker-panel { padding: 18px 0; }

.picker-button {
  display: flex;
  width: 100%;
  min-height: 176px;
  align-items: center;
  justify-content: center;
  gap: 22px;
  padding: 28px;
  border: 1px dashed var(--line);
  border-radius: 18px;
  background: var(--surface-raised);
  color: var(--ink);
  font: inherit;
  text-align: left;
  cursor: pointer;
  transition: border-color 160ms ease, background 160ms ease, transform 160ms ease;
}

.picker-button:hover { border-color: var(--accent); background: var(--surface-high); }
.picker-button:active { transform: scale(0.995); }
.picker-button strong { display: block; margin-bottom: 7px; font-size: 1.15rem; }
.picker-button small { display: block; color: var(--muted); font-size: 0.9rem; line-height: 1.45; }

.picker-plus {
  display: grid;
  flex: 0 0 auto;
  width: 56px;
  height: 56px;
  place-items: center;
  border-radius: 50%;
  background: var(--accent);
  color: var(--accent-ink);
  font-size: 2rem;
  font-weight: 500;
}

.selection { padding-top: 22px; }

.selection-bar {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 20px;
  padding-bottom: 18px;
}

.selection-bar h2 { margin: 0; font-size: 1.7rem; }
.selection-size { margin: 7px 0 0; color: var(--muted); }

.primary-button, .secondary-button, .icon-button, .download {
  display: inline-flex;
  min-height: 48px;
  align-items: center;
  justify-content: center;
  padding: 0 20px;
  border: 0;
  border-radius: 11px;
  font: inherit;
  font-weight: 720;
  text-decoration: none;
  cursor: pointer;
  transition: background 160ms ease, transform 160ms ease;
}

.primary-button { background: var(--accent); color: var(--accent-ink); }
.primary-button:hover { background: #ffbd86; }
.secondary-button, .icon-button, .download { background: var(--surface-high); color: var(--ink); }
.secondary-button:hover, .icon-button:hover, .download:hover { background: #303b49; }
.primary-button:active, .secondary-button:active, .icon-button:active, .download:active { transform: scale(0.98); }

.overall-progress {
  margin-bottom: 12px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface-raised);
}

.progress-copy { display: flex; justify-content: space-between; gap: 18px; margin-bottom: 12px; }
.progress-copy span { color: var(--muted); }
.progress-track { overflow: hidden; height: 7px; border-radius: 8px; background: var(--line); }
.progress-track span { display: block; width: 0; height: 100%; background: var(--accent); transition: width 120ms linear; }

.file-list { margin: 0; padding: 0; border-top: 1px solid var(--line); list-style: none; }

.file-row {
  display: grid;
  grid-template-columns: 64px minmax(0, 1fr) auto;
  gap: 16px;
  align-items: center;
  min-height: 88px;
  padding: 12px 0;
  border-bottom: 1px solid var(--line);
}

.file-preview {
  display: grid;
  overflow: hidden;
  width: 64px;
  height: 64px;
  place-items: center;
  border-radius: 9px;
  background: var(--surface-high);
  color: var(--accent);
  font-size: 1.3rem;
}

.file-preview img { width: 100%; height: 100%; object-fit: cover; }
.file-copy { min-width: 0; }
.file-copy strong { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-copy span { display: block; margin-top: 5px; color: var(--muted); font-size: 0.82rem; }
.file-copy .file-error { color: var(--danger); }
.file-copy .file-success { color: var(--success); }
.file-progress { overflow: hidden; width: 100%; height: 4px; margin-top: 9px; border-radius: 5px; background: var(--line); }
.file-progress span { display: block; width: 0; height: 100%; background: var(--accent); }

.remove-file {
  width: 42px;
  height: 42px;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--muted);
  font-size: 1.35rem;
  cursor: pointer;
}

.remove-file:hover { background: var(--surface-high); color: var(--ink); }

.upload-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 22px 0 8px;
}

.upload-actions p { margin: 0; color: var(--muted); line-height: 1.45; }

dialog {
  width: 100vw;
  max-width: none;
  height: 100vh;
  height: 100dvh;
  max-height: none;
  margin: 0;
  padding: 0;
  border: 0;
  background: #080b0f;
  color: var(--ink);
}

dialog::backdrop { background: #080b0f; }

.viewer { display: grid; grid-template-rows: auto 1fr auto; width: 100%; height: 100%; }

.viewer-bar {
  display: flex;
  min-height: 68px;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 10px max(14px, env(safe-area-inset-right)) 10px max(14px, env(safe-area-inset-left));
  background: var(--surface);
}

.viewer-stage { display: grid; min-height: 0; place-items: center; overflow: hidden; }
.viewer-stage img, .viewer-stage video { display: block; max-width: 100%; max-height: 100%; object-fit: contain; }
.viewer-copy { min-width: 0; }
.viewer-copy strong { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.viewer-copy span { display: block; margin-top: 3px; color: var(--muted); font-size: 0.78rem; }

.hidden { display: none !important; }

@media (max-width: 760px) {
  .shell { padding-inline: 0; padding-top: env(safe-area-inset-top); }
  .page-header { min-height: 118px; padding: 24px 18px 22px; }
  .upload-header { min-height: 96px; padding-block: 18px; }
  .upload-header h1 { font-size: clamp(2rem, 10vw, 2.8rem); }
  h1 { font-size: clamp(2rem, 12vw, 3.4rem); }
  .page-header .meta { display: none; }
  .gallery { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .upload-app { padding: 10px 18px 0; }
  .invitation { grid-template-columns: 1fr; gap: 14px; padding: 8px 0 20px; }
  .invitation h2 { max-width: none; }
  .invitation-copy { margin-top: 12px; line-height: 1.5; }
  .expiry-card { max-width: none; }
  .expiry-card { padding: 14px 16px; }
  .privacy-note { margin-bottom: 8px; padding: 14px 16px; font-size: 0.92rem; }
  .picker-panel { padding-block: 8px; }
  .picker-button { min-height: 140px; justify-content: flex-start; }
  .upload-actions { align-items: stretch; flex-direction: column; }
  .primary-button { width: 100%; }
}

@media (max-width: 430px) {
  .gallery { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .selection-bar { align-items: flex-start; }
  .file-row { grid-template-columns: 54px minmax(0, 1fr) auto; gap: 12px; }
  .file-preview { width: 54px; height: 54px; }
  .progress-copy { align-items: flex-start; flex-direction: column; gap: 4px; }
}

@media (max-width: 330px) {
  .picker-button { align-items: flex-start; flex-direction: column; }
}

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