/* Mobile-first. Everything is laid out for a phone; the only wide-screen
   concession is capping the column width and letting the slots breathe. */
:root {
  --bg: #0d0d10;
  --card: #17171c;
  --card-2: #1f1f26;
  --line: #2b2b34;
  --text: #f2f2f5;
  --muted: #9a9aa6;
  --accent: #f68424;
  --accent-press: #d96f16;
  --danger: #ff6b6b;
  --radius: 14px;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, system-ui, sans-serif;
  overscroll-behavior-y: none;
}

body { min-height: 100svh; }
.hidden { display: none !important; }
.muted { color: var(--muted); }

.screen {
  max-width: 560px;
  margin: 0 auto;
  padding: env(safe-area-inset-top) 16px calc(24px + env(safe-area-inset-bottom));
}

/* ---------- lock ---------- */
#lock { display: flex; align-items: center; justify-content: center; min-height: 100svh; }
.lock-card { width: 100%; text-align: center; }
.lock-logo { font-size: 54px; line-height: 1; }
.lock-card h1 { font-size: 22px; margin: 12px 0 4px; }
.lock-card p { margin: 0 0 20px; font-size: 14px; }
#pin {
  width: 100%;
  padding: 16px;
  font-size: 17px;               /* >=16px stops iOS zooming the field */
  text-align: center;
  letter-spacing: 2px;
  color: var(--text);
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  margin-bottom: 12px;
}
#pin:focus { outline: none; border-color: var(--accent); }

/* ---------- chrome ---------- */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 2px 10px;
  position: sticky; top: 0; z-index: 5;
  background: linear-gradient(var(--bg) 70%, transparent);
}
.brand { font-weight: 600; font-size: 16px; }
.topbar-actions { display: flex; gap: 6px; }
.icon-btn {
  background: var(--card); color: var(--muted);
  border: 1px solid var(--line); border-radius: 10px;
  width: 38px; height: 38px; font-size: 16px; cursor: pointer;
}
.icon-btn:active { background: var(--card-2); }

.block { margin-bottom: 22px; }
.block h2 { font-size: 13px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); margin: 0 0 10px; font-weight: 600; }

/* ---------- image slots ---------- */
.slots { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.slot {
  position: relative;
  display: flex; align-items: center; justify-content: center;
  aspect-ratio: 1 / 1;
  background: var(--card);
  border: 1.5px dashed var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  cursor: pointer;
}
.slot.filled { border-style: solid; border-color: var(--accent); }
.slot-empty {
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  color: var(--muted); font-size: 13px; text-align: center;
}
.slot-empty em { font-style: normal; font-size: 11px; opacity: .65; }
.plus { font-size: 28px; line-height: 1; color: var(--accent); }
.thumb { width: 100%; height: 100%; object-fit: cover; display: block; }
.clear {
  position: absolute; top: 6px; right: 6px;
  width: 28px; height: 28px; border-radius: 50%;
  background: rgba(0,0,0,.65); color: #fff;
  border: none; font-size: 17px; line-height: 1; cursor: pointer;
}

/* ---------- prompt ---------- */
textarea {
  width: 100%; padding: 14px; font-size: 16px; font-family: inherit;
  color: var(--text); background: var(--card);
  border: 1px solid var(--line); border-radius: var(--radius);
  resize: vertical; min-height: 84px;
}
textarea:focus { outline: none; border-color: var(--accent); }

.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.chip {
  background: var(--card-2); color: var(--muted);
  border: 1px solid var(--line); border-radius: 999px;
  padding: 7px 12px; font-size: 12.5px; cursor: pointer;
}
.chip:active { color: var(--text); border-color: var(--accent); }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 100%; padding: 15px 18px;
  font-size: 16px; font-weight: 600; font-family: inherit;
  color: var(--text); text-decoration: none;
  background: var(--card-2);
  border: 1px solid var(--line); border-radius: var(--radius);
  cursor: pointer;
}
.btn.primary { background: var(--accent); border-color: var(--accent); color: #17130d; }
.btn.primary:active { background: var(--accent-press); }
.btn.primary[disabled] { opacity: .55; cursor: default; }
.btn.big { padding: 17px; font-size: 17px; }
.btn.ghost { background: transparent; }

/* ---------- result ---------- */
.result {
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); overflow: hidden;
  min-height: 220px; display: flex; align-items: center; justify-content: center;
}
#result-img { width: 100%; height: auto; display: block; }
.spinner-wrap { text-align: center; padding: 34px 16px; }
.spinner {
  width: 34px; height: 34px; margin: 0 auto 12px;
  border: 3px solid var(--line); border-top-color: var(--accent);
  border-radius: 50%; animation: spin 0.9s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
#status-text { font-size: 13px; margin: 0; }
.result-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 12px; }

.error { color: var(--danger); font-size: 13.5px; min-height: 18px; margin: 10px 0 0; }
.foot { text-align: center; font-size: 11.5px; padding-top: 6px; }

/* ---------- diagnostics sheet ---------- */
.sheet {
  position: fixed; inset: 0; z-index: 20;
  background: rgba(0,0,0,.6);
  display: flex; align-items: flex-end; justify-content: center;
}
.sheet-card {
  width: 100%; max-width: 560px;
  background: var(--card); border-top: 1px solid var(--line);
  border-radius: 18px 18px 0 0;
  padding: 18px 16px calc(18px + env(safe-area-inset-bottom));
  max-height: 80svh; overflow: auto;
}
.sheet-card h2 { margin: 0 0 12px; font-size: 15px; }
.sheet-card pre {
  background: var(--bg); border: 1px solid var(--line); border-radius: 10px;
  padding: 12px; font-size: 12px; white-space: pre-wrap; word-break: break-word;
  margin: 0 0 14px; color: var(--muted);
}

@media (min-width: 560px) {
  .slots { gap: 14px; }
  .screen { padding-left: 20px; padding-right: 20px; }
}

@media (prefers-reduced-motion: reduce) {
  .spinner { animation-duration: 2.4s; }
}
