:root {
  --bg: #FFFFFF;
  --surface: #F8FAFC;
  --ink: #111827;
  --ink-muted: #374151;
  --brand-orange: #EA580C;
  --brand-orange-deep: #9A3412;
  --line: #E2E8F0;
  --status-ok-bg: #ECFDF5;
  --status-ok-ink: #065F46;
  --status-fail-bg: #FEF2F2;
  --status-fail-ink: #991B1B;
  --status-wait-bg: #FFF7ED;
  --status-wait-ink: #9A3412;
  --status-draft-bg: #F1F5F9;
  --status-draft-ink: #334155;

  --text-display: 28px;
  --text-title: 20px;
  --text-body-lg: 18px;
  --text-body: 16px;
  --text-label: 15px;
  --text-caption: 13px;

  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-6: 24px;
  --space-8: 32px;

  --radius: 8px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: var(--text-body);
  line-height: 1.5;
}

.screen {
  display: none;
  min-height: 100vh;
  padding: var(--space-8) var(--space-4);
  max-width: 480px;
  margin: 0 auto;
  flex-direction: column;
}

.screen.active { display: flex; }

.logo {
  display: block;
  margin: 0 auto var(--space-8);
  width: 120px;
}

.passcode-heading {
  font-size: var(--text-title);
  font-weight: 700;
  line-height: 1.3;
  text-align: center;
  margin: 0 0 var(--space-4);
  white-space: normal;
  overflow-wrap: break-word;
}

.field {
  width: 100%;
  min-height: 56px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  font-size: var(--text-display);
  text-align: center;
  letter-spacing: 6px;
  padding: 0 var(--space-3);
}

.hint {
  font-size: var(--text-body);
  color: var(--ink-muted);
  margin-top: var(--space-4);
  min-height: 22px;
}

.hint.error { color: var(--status-fail-ink); }

.btn {
  min-height: 56px;
  border-radius: var(--radius);
  border: none;
  font-size: var(--text-body-lg);
  font-weight: 700;
  width: 100%;
  cursor: pointer;
  margin-top: var(--space-6);
}

.btn-primary {
  background: var(--brand-orange);
  color: #FFFFFF;
}

.btn-primary:disabled {
  background: var(--status-draft-bg);
  color: var(--ink-muted);
  cursor: not-allowed;
}

.btn-secondary {
  background: var(--surface);
  color: var(--ink);
  font-size: var(--text-body);
  font-weight: 600;
  min-height: 48px;
  margin-top: var(--space-3);
}

.btn-secondary:disabled {
  color: var(--ink-muted);
  cursor: not-allowed;
}

.btn-tertiary {
  background: none;
  border: none;
  color: var(--brand-orange-deep);
  font-size: var(--text-label);
  min-height: 48px;
  margin-top: var(--space-2);
  cursor: pointer;
  width: 100%;
}

.btn-tertiary:disabled {
  color: var(--ink-muted);
  cursor: not-allowed;
}

.link {
  display: block;
  text-align: center;
  min-height: 48px;
  line-height: 48px;
  color: var(--ink-muted);
  font-size: var(--text-label);
  text-decoration: none;
  margin-top: var(--space-4);
  cursor: pointer;
  background: none;
  border: none;
  width: 100%;
}

.capture {
  width: 100%;
  min-height: 200px;
  background: var(--surface);
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  cursor: pointer;
  position: relative;
}

.capture img { width: 100%; height: 100%; object-fit: cover; }

.capture .icon { font-size: 40px; color: var(--ink-muted); }

.retake-pill {
  position: absolute;
  bottom: var(--space-2);
  right: var(--space-2);
  min-height: 48px;
  padding: 0 var(--space-4);
  background: rgba(17,24,39,0.75);
  color: #FFFFFF;
  border-radius: 24px;
  border: none;
  font-size: var(--text-label);
}

textarea.field-textarea {
  width: 100%;
  min-height: 96px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  font-size: var(--text-body-lg);
  padding: var(--space-3);
  margin-top: var(--space-4);
  font-family: inherit;
  resize: vertical;
}

.review-textarea {
  min-height: 140px;
  font-size: var(--text-body-lg);
}

.char-count {
  font-size: var(--text-caption);
  color: var(--ink-muted);
  margin-top: var(--space-1);
}

.char-count.over { color: var(--status-fail-ink); }

.photo-preview {
  width: 100%;
  border-radius: var(--radius);
  display: block;
}

.spinner-wrap {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--space-4);
}

.spinner {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 3px solid var(--status-wait-bg);
  border-top-color: var(--brand-orange);
  animation: spin 1s linear infinite;
}

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

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

.channel-row {
  min-height: 56px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 var(--space-3);
  border-radius: var(--radius);
  margin-bottom: var(--space-2);
  font-size: var(--text-label);
  font-weight: 600;
}

.channel-row.ok { background: var(--status-ok-bg); color: var(--status-ok-ink); }
.channel-row.fail { background: var(--status-fail-bg); color: var(--status-fail-ink); }
.channel-row.wait { background: var(--status-wait-bg); color: var(--status-wait-ink); }

.channel-row a { color: inherit; }

.chip {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  padding: var(--space-1) var(--space-3);
  border-radius: 999px;
  font-size: var(--text-label);
  font-weight: 600;
}

.chip.ok { background: var(--status-ok-bg); color: var(--status-ok-ink); }
.chip.fail { background: var(--status-fail-bg); color: var(--status-fail-ink); }
.chip.wait { background: var(--status-wait-bg); color: var(--status-wait-ink); }
.chip.draft { background: var(--status-draft-bg); color: var(--status-draft-ink); }

.post-row {
  display: flex;
  gap: var(--space-3);
  min-height: 72px;
  padding: var(--space-2) 0;
  border-bottom: 1px solid var(--line);
  cursor: pointer;
  text-align: left;
  background: none;
  border-left: none;
  border-right: none;
  border-top: none;
  width: 100%;
}

.post-row img {
  width: 56px;
  height: 56px;
  object-fit: cover;
  border-radius: var(--radius);
  flex-shrink: 0;
  background: var(--surface);
}

.post-row .meta { flex: 1; min-width: 0; }

.post-row .caption {
  font-size: var(--text-body-lg);
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

.post-row .chips { display: flex; gap: var(--space-2); margin-top: var(--space-1); }
.post-row .timestamp { color: var(--ink-muted); font-size: var(--text-caption); margin-top: var(--space-1); }

.title { font-size: var(--text-title); font-weight: 700; margin-bottom: var(--space-6); }

.empty-state { color: var(--ink-muted); text-align: center; margin-top: var(--space-8); }

input[type="date"], input[type="time"] {
  width: 100%;
  min-height: 56px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  font-size: var(--text-body-lg);
  padding: 0 var(--space-3);
  margin-bottom: var(--space-4);
  font-family: inherit;
}

.echo-line { font-size: var(--text-body); color: var(--ink); margin-bottom: var(--space-6); }

.install-banner {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  background: var(--ink);
  color: #FFFFFF;
  padding: var(--space-4);
  font-size: var(--text-body);
  display: none;
  z-index: 10;
}

.install-banner.show { display: block; }

.install-banner-dismiss {
  position: absolute;
  top: var(--space-2);
  right: var(--space-2);
  width: 32px;
  height: 32px;
  min-height: 32px;
  border: none;
  background: transparent;
  color: #FFFFFF;
  font-size: 22px;
  line-height: 1;
  padding: 0;
}

.install-banner button {
  margin-top: var(--space-2);
  min-height: 48px;
  width: 100%;
  background: var(--brand-orange);
  color: #FFFFFF;
  border: none;
  border-radius: var(--radius);
  font-weight: 700;
  font-size: var(--text-body);
}

.hidden { display: none !important; }

/* ---- Delta 2026-09-17: photo sources, thumbnail strip ---- */

.photo-sources {
  display: flex;
  gap: var(--space-3);
}

.photo-source-btn {
  flex: 1;
  min-height: 96px;
  background: var(--surface);
  border-radius: var(--radius);
  border: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  cursor: pointer;
  color: var(--ink);
  font-size: var(--text-label);
  font-weight: 600;
}

.photo-source-btn .icon { font-size: 28px; }

.thumb-strip {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  margin-top: var(--space-4);
}

.thumb {
  position: relative;
  width: 64px;
  height: 64px;
  flex-shrink: 0;
  cursor: pointer;
  /* overflow stays visible on the outer element so the first-photo badge
     (positioned half outside the thumbnail edge) isn't clipped; the image
     itself gets its own rounded, clipped inner box. */
}

.thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  border-radius: var(--radius);
  background: var(--surface);
}

.thumb-badge {
  position: absolute;
  top: -6px;
  left: -6px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--brand-orange);
  color: #FFFFFF;
  font-size: 11px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
}

.thumb-remove {
  position: absolute;
  /* Visible glyph sits in the top-right corner as a small circle; the
     button's actual hit area is padded out to the 48px floor and biased
     upward/outward from the thumbnail's own centre so a tap intended for
     the remove control can never be mistaken for a tap on the photo
     itself (which opens the full action sheet instead), and so two
     adjacent 64px thumbnails at an 8px gap keep their hit zones apart at
     the facing corner. */
  top: -20px;
  right: -14px;
  width: 48px;
  height: 48px;
  background: none;
  border: none;
  display: flex;
  align-items: flex-end;
  justify-content: flex-start;
  padding: 4px;
  cursor: pointer;
}

.thumb-remove span {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: rgba(17,24,39,0.75);
  color: #FFFFFF;
  font-size: 13px;
  line-height: 20px;
  text-align: center;
}

.thumb-add {
  width: 64px;
  height: 64px;
  border-radius: var(--radius);
  background: var(--surface);
  border: none;
  color: var(--brand-orange-deep);
  font-size: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
}

.hint.caption {
  font-size: var(--text-caption);
  margin-top: var(--space-2);
  min-height: 0;
}

.hint.body-note {
  font-size: var(--text-body);
  color: var(--ink-muted);
  margin-top: var(--space-3);
  margin-bottom: 0;
}

/* ---- Delta 2026-09-17: Rewrite link (review screen) ---- */

.rewrite-link {
  display: block;
  text-align: left;
  min-height: 48px;
  line-height: 48px;
  padding: 0;
  background: none;
  border: none;
  cursor: pointer;
  color: var(--brand-orange-deep);
  font-size: var(--text-label);
  font-weight: 600;
  margin-top: var(--space-4);
  margin-bottom: 0;
}

.rewrite-link:disabled,
.rewrite-link.exhausted {
  color: var(--ink-muted);
  cursor: not-allowed;
}

.rewrite-link.loading {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.rewrite-spinner {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 2px solid var(--status-wait-bg);
  border-top-color: var(--brand-orange);
  animation: spin 1s linear infinite;
  display: inline-block;
}

.review-textarea.dimmed { opacity: 0.6; }

/* ---- Delta 2026-09-17: Cancel (replaces Start over everywhere) ---- */

.cancel-link {
  text-align: left;
}

.cancel-link.confirming {
  display: inline-block;
  width: auto;
  border: 1px solid var(--ink-muted);
  border-radius: 999px;
  padding: 0 var(--space-3);
  min-height: 40px;
  line-height: 38px;
  color: var(--ink-muted);
  background: none;
}

/* ---- Delta 2026-09-17: photo action sheet ---- */

.action-sheet {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: flex;
  align-items: flex-end;
}

.action-sheet-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(17,24,39,0.4);
}

.action-sheet-panel {
  position: relative;
  width: 100%;
  background: var(--bg);
  border-radius: var(--radius) var(--radius) 0 0;
  padding: var(--space-4);
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.action-sheet-btn {
  min-height: 48px;
  border-radius: var(--radius);
  border: none;
  background: var(--surface);
  font-size: var(--text-body-lg);
  font-weight: 600;
  color: var(--ink);
  cursor: pointer;
}

.action-sheet-cancel {
  background: none;
  color: var(--ink-muted);
}
