:root {
  color-scheme: light;
  --bg: #f4f8fc;
  --surface: rgba(255, 255, 255, 0.88);
  --text: #14304a;
  --muted: #5d7388;
  --line: #d5e4f2;
  --blue: #1565c0;
  --blue-soft: #e8f2fb;
  --danger: #8c3030;
  --ok: #1d6a43;
  --font: "Avenir Next", "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.45;
}

button, input, select, textarea { font: inherit; color: inherit; }

button, .button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 46px;
  padding: 0 16px;
  border: 1px solid var(--blue);
  background: var(--blue);
  color: #fff;
  text-decoration: none;
  cursor: pointer;
}

button.secondary, a.secondary {
  background: #fff;
  color: var(--text);
  border-color: var(--line);
}

button:disabled { opacity: 0.45; cursor: default; }

.wrap {
  width: min(1080px, 100%);
  margin: 0 auto;
  padding: 18px 16px 96px;
}

.top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}

.top h1 {
  margin: 0;
  font-size: 22px;
  font-weight: 600;
}

.credits {
  border: 1px solid var(--line);
  background: var(--surface);
  padding: 6px 10px;
  color: var(--blue);
  font-size: 14px;
}

.lead, .hint { color: var(--muted); margin: 0 0 14px; }

.grid, .history {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.tile {
  position: relative;
  display: block;
  height: calc((100dvh - 188px) / 2);
  min-height: 132px;
  overflow: hidden;
  border: 1px solid var(--line);
  background: var(--blue-soft);
  color: inherit;
  text-decoration: none;
}

.tile .clip, .tile .hold {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border: 0;
  aspect-ratio: auto;
  pointer-events: none;
  background: var(--blue-soft);
}

.tile .hold {
  display: flex;
  align-items: flex-end;
  padding: 28px 8px 8px;
  color: var(--muted);
  font-size: 13px;
}

.tile .cap {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  padding: 18px 8px 6px;
  color: #fff;
  font-size: 12px;
  line-height: 1.3;
  background: linear-gradient(transparent, rgba(12, 28, 48, 0.78));
}

@media (min-width: 720px) {
  .grid { gap: 12px; }
}

.card {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  justify-content: flex-start;
  gap: 6px;
  width: 100%;
  min-width: 0;
  text-align: left;
  text-decoration: none;
  padding: 8px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
}

.card h2, .name {
  margin: 0;
  font-size: 14px;
  font-weight: 600;
  line-height: 1.25;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.desc {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.preview, .photo {
  width: 100%;
  aspect-ratio: 3 / 4;
  object-fit: cover;
  background: var(--blue-soft);
  border: 1px solid var(--line);
}

.preview.thumb { pointer-events: none; }

.photo { aspect-ratio: 1; max-width: 220px; }

.stage {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.stage .preview {
  width: min(100%, 420px);
  max-height: 54vh;
  margin: 0 auto;
  object-fit: cover;
}

.picker {
  position: relative;
  display: flex;
  align-items: center;
  gap: 14px;
  min-height: 76px;
  padding: 14px 16px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.9);
  cursor: pointer;
}

.picker .icon {
  width: 28px;
  height: 28px;
  flex: none;
  color: var(--blue);
}

.picker-copy {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.picker strong {
  font-size: 16px;
  font-weight: 600;
}

.picker-copy span {
  color: var(--muted);
  font-size: 13px;
}

.picker input[type="file"] {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  min-height: 0;
  margin: 0;
  padding: 0;
  border: 0;
  opacity: 0;
  cursor: pointer;
}

.picker.busy { opacity: 0.65; pointer-events: none; }

.wait {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  padding: 14px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.92);
}

.shot {
  width: 84px;
  height: 112px;
  flex: none;
  object-fit: cover;
  background: var(--blue-soft);
  border: 1px solid var(--line);
}

.wait-copy {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 8px;
  min-width: 0;
  padding-top: 2px;
}

.wait-copy strong {
  font-size: 16px;
  font-weight: 600;
}

.wait-copy span:last-child {
  color: var(--muted);
  font-size: 13px;
}

.credit-wait {
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding-bottom: 18px;
}

.credit-card { align-items: center; width: min(420px, 100%); }

.spin {
  width: 22px;
  height: 22px;
  border: 2px solid #d5e4f2;
  border-top-color: var(--blue);
  border-radius: 50%;
  animation: turn 0.8s linear infinite;
}

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

.stage .film {
  width: min(100%, 420px);
  max-height: 54vh;
}

.stack { display: flex; flex-direction: column; gap: 14px; }

label { font-size: 14px; font-weight: 600; }

input[type="text"], input[type="url"], input[type="password"], input[type="search"], input[type="number"], select, textarea {
  width: 100%;
  min-height: 46px;
  margin-top: 6px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  background: #fff;
}

textarea { min-height: 96px; resize: vertical; }

.row { display: flex; gap: 8px; flex-wrap: wrap; }

.message {
  margin: 0 0 14px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  background: #fff;
}

.message.error { color: var(--danger); border-color: #ead4d4; }
.message.ok { color: var(--ok); border-color: #d3e6db; }

.list { display: flex; flex-direction: column; border-top: 1px solid var(--line); }
.list a {
  display: block;
  padding: 14px 2px;
  border-bottom: 1px solid var(--line);
  color: inherit;
  text-decoration: none;
}
.meta { color: var(--muted); font-size: 14px; margin: 4px 0 0; }
.search { margin-bottom: 14px; }

.drop {
  border: 1px dashed #b9d0e6;
  padding: 16px;
  background: rgba(255, 255, 255, 0.7);
}

.tabbar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 5;
  display: flex;
  justify-content: space-around;
  padding: 8px 12px calc(8px + env(safe-area-inset-bottom));
  background: rgba(255, 255, 255, 0.72);
  border-top: 1px solid rgba(21, 101, 192, 0.16);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
}

.tab {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  min-width: 88px;
  padding: 4px 8px;
  color: var(--muted);
  text-decoration: none;
  font-size: 12px;
  background: transparent;
  border: 0;
}

.tab.on { color: var(--blue); }

.icon { width: 22px; height: 22px; }
