:root {
  --violet: #44407c;
  --violet-deep: #2a2760;
  --accent: #ff3b30;
  --text: #ffffff;
  --muted: rgba(255, 255, 255, 0.72);
  --input-bg: #ffffff;
  --input-text: #44407c;
  --tab-h: 56px;
  color-scheme: dark;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  height: 100%;
}

body {
  font-family: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
  color: var(--text);
  background: linear-gradient(180deg, #3a3670 0%, #1e1b45 42%, #0f0e22 100%);
  background-attachment: fixed;
}

.u-app {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  max-width: 560px;
  margin: 0 auto;
}

.u-screen {
  flex: 1;
  min-height: 0;
  overflow: auto;
  display: flex;
  flex-direction: column;
  padding: 0 16px calc(var(--tab-h) + env(safe-area-inset-bottom, 0px) + 16px);
}

.u-app.is-auth .u-screen,
.u-app.no-tabs .u-screen {
  padding-bottom: 16px;
}

.u-tabs {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  height: calc(var(--tab-h) + env(safe-area-inset-bottom, 0px));
  padding-bottom: env(safe-area-inset-bottom, 0px);
  background: linear-gradient(180deg, rgba(18, 16, 40, 0.2), rgba(12, 10, 28, 0.92));
  backdrop-filter: blur(10px);
  max-width: 560px;
  margin: 0 auto;
}

.u-tabs[hidden] {
  display: none;
}

.u-tabs a {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  color: rgba(255, 255, 255, 0.62);
  text-decoration: none;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.02em;
}

.u-tabs a.is-active {
  color: #fff;
}

.u-tabs svg {
  width: 22px;
  height: 22px;
  fill: currentColor;
}

.u-header {
  display: flex;
  align-items: center;
  min-height: 56px;
  padding: 8px 0;
  gap: 8px;
}

.u-header h1 {
  flex: 1;
  margin: 0;
  text-align: center;
  font-size: 20px;
  font-weight: 600;
}

.u-icon-btn {
  width: 48px;
  height: 48px;
  border: 0;
  background: transparent;
  color: #eee;
  cursor: pointer;
  display: grid;
  place-items: center;
  flex: 0 0 48px;
  border-radius: 12px;
}

.u-icon-btn svg {
  width: 22px;
  height: 22px;
  fill: currentColor;
}

.u-icon-btn:disabled {
  opacity: 0.45;
}

.u-auth {
  padding: 48px 8px 24px;
}

.u-auth h1 {
  text-align: center;
  font-size: 22px;
  font-weight: 600;
  margin: 0 0 32px;
}

.u-field {
  margin: 0 0 16px;
}

.u-field label {
  display: block;
  font-size: 13px;
  color: var(--muted);
  margin: 0 0 6px;
}

.u-field input {
  width: 100%;
  min-height: 56px;
  border: 0;
  border-radius: 16px;
  padding: 16px;
  font-size: 16px;
  background: var(--input-bg);
  color: var(--input-text);
}

.u-field input:focus {
  outline: 2px solid rgba(255, 255, 255, 0.35);
}

.u-error {
  color: var(--accent);
  min-height: 1.3em;
  margin: 4px 0 12px;
  font-size: 14px;
}

.u-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 48px;
  padding: 0 20px;
  border: 0;
  border-radius: 10px;
  background: var(--violet);
  color: #fff;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
}

.u-btn:disabled {
  opacity: 0.5;
  cursor: default;
}

.u-btn-block {
  width: 100%;
}

.u-btn-ghost {
  background: transparent;
  color: #fff;
}

.u-link {
  display: block;
  text-align: center;
  color: #fff;
  text-decoration: none;
  min-height: 48px;
  line-height: 48px;
  font-size: 16px;
}

.u-empty {
  text-align: center;
  color: #fff;
  padding: 48px 24px;
  line-height: 1.45;
}

.u-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  padding: 8px 0 16px;
}

.u-grid-2 {
  grid-template-columns: repeat(3, 1fr);
}

.u-section-label {
  margin: 16px 0 4px;
  font-size: 13px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
}

.u-photo-empty,
.u-clip-empty {
  display: flex;
  align-items: center;
  justify-content: center;
  aspect-ratio: 1;
  border-radius: 6px;
  background: rgba(0, 0, 0, 0.28);
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
}

.u-photo,
.u-clip {
  position: relative;
  aspect-ratio: 1;
  border: 0;
  padding: 0;
  background: rgba(0, 0, 0, 0.28);
  border-radius: 6px;
  overflow: hidden;
  cursor: pointer;
}

.u-photo img,
.u-clip img,
.u-photo video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.u-photo-del {
  position: absolute;
  top: 4px;
  right: 4px;
  z-index: 3;
  width: 28px;
  height: 28px;
  border: 0;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.45);
  color: #fff;
  cursor: pointer;
  display: grid;
  place-items: center;
}

.u-play {
  position: absolute;
  left: 50%;
  top: 50%;
  z-index: 2;
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.58);
  color: #fff;
  pointer-events: none;
  transform: translate(-50%, -50%);
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.35);
}

.u-play svg {
  display: block;
  width: 22px;
  height: 22px;
  margin-left: 2px;
}

.u-clip:hover .u-play {
  transform: translate(-50%, -50%) scale(1.08);
  background: rgba(0, 0, 0, 0.72);
}

.u-photo-del svg {
  width: 14px;
  height: 14px;
  fill: currentColor;
}

.u-clip-badge {
  position: absolute;
  left: 6px;
  bottom: 6px;
  font-size: 11px;
  font-weight: 700;
  padding: 3px 7px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.55);
}

.u-clip.is-pending,
.u-clip.is-failed {
  cursor: default;
}

.u-clip-ph {
  width: 100%;
  height: 100%;
  display: grid;
  place-items: center;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.u-preview {
  min-height: calc(100dvh - 80px);
  display: flex;
  align-items: center;
  justify-content: center;
}

.u-preview img {
  max-width: 100%;
  max-height: calc(100dvh - 120px);
  object-fit: contain;
}

.u-crop-page {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  margin: 0 -16px;
}

.u-crop {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  padding: 0 16px 16px;
}

.u-crop-stage {
  flex: 1;
  min-height: 0;
  display: grid;
  place-items: center;
}

.u-crop-frame {
  position: relative;
  width: min(100%, calc(100dvh - 140px));
  aspect-ratio: 1;
  background: #000;
  overflow: hidden;
  container-type: inline-size;
}

.u-crop-frame canvas {
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
}

/* Same geometry as lib/app/radial-blur.cjs: sharp disc to 30% of half-side, then fade. */
.u-crop-blur {
  position: absolute;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  backdrop-filter: blur(24px);
  backdrop-filter: blur(7.4cqi);
  -webkit-backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(7.4cqi);
  mask-image: radial-gradient(circle closest-side at 50% 50%, transparent 0%, transparent 30%, #000 100%);
  -webkit-mask-image: radial-gradient(circle closest-side at 50% 50%, transparent 0%, transparent 30%, #000 100%);
}

.u-crop-hint {
  margin: 10px 0 0;
  text-align: center;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.35;
}

.u-pairing {
  text-align: center;
  padding: 48px 8px 16px;
  display: flex;
  flex-direction: column;
  min-height: calc(100dvh - var(--tab-h) - 48px);
}

.u-pairing h1 {
  margin: 0;
  font-size: 22px;
  font-weight: 600;
}

.u-code {
  margin: 48px 0 16px;
  font-size: 36px;
  font-weight: 700;
  letter-spacing: 0.2em;
}

.u-hint {
  color: var(--muted);
  line-height: 1.45;
  margin: 0 0 24px;
}

.u-gallery-hint {
  margin: 0 0 8px;
  padding: 0 4px 8px;
  font-size: 14px;
  text-align: center;
}

.u-pairing .u-btn {
  align-self: center;
}

.u-pairing-spacer {
  flex: 1;
}

.u-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.62);
  display: grid;
  place-items: center;
  padding: 24px;
  z-index: 30;
}

.u-modal {
  width: min(420px, 100%);
  background: #1c1a32;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 14px;
  padding: 18px;
}

.u-modal h2 {
  margin: 0 0 8px;
  font-size: 18px;
}

.u-modal p {
  margin: 0 0 16px;
  color: var(--muted);
  line-height: 1.4;
}

.u-modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.u-modal.u-player {
  width: min(720px, calc(100vw - 48px), calc(100dvh - 160px));
}

.u-player video {
  width: 100%;
  aspect-ratio: 1 / 1;
  height: auto;
  object-fit: contain;
  border-radius: 10px;
  background: #000;
  display: block;
}

.u-toast {
  position: fixed;
  left: 50%;
  top: max(16px, env(safe-area-inset-top, 0px));
  transform: translateX(-50%);
  z-index: 40;
  background: rgba(24, 22, 44, 0.96);
  border: 1px solid rgba(255, 255, 255, 0.18);
  padding: 12px 18px;
  border-radius: 12px;
  max-width: min(480px, calc(100% - 32px));
  text-align: center;
  font-weight: 700;
}

.u-pw-wrap {
  position: relative;
}

.u-pw-wrap input {
  padding-right: 72px;
}

.u-pw-toggle {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  border: 0;
  background: transparent;
  color: var(--violet);
  font-weight: 700;
  cursor: pointer;
  min-height: 40px;
  padding: 0 10px;
}
