/* Snap — dark-first, one-handed, no build step.
   No external fonts or assets: system stack only. */

:root {
  color-scheme: dark light;

  --bg: #14161f;
  --surface: #1c1f2b;
  --surface-2: #262a38;
  --line: #333849;
  --text: #eef0f7;
  --muted: #9aa1b8;
  --accent: #e8484f;
  --accent-ink: #ffffff;
  --danger: #ff6b6b;
  --warn: #ffc46b;

  --tap: 56px;
  --radius: 14px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
}

@media (prefers-color-scheme: light) {
  :root {
    --bg: #f6f7fb;
    --surface: #ffffff;
    --surface-2: #eef0f6;
    --line: #dce0ea;
    --text: #15171f;
    --muted: #5c6379;
    --accent: #d8353c;
    --accent-ink: #ffffff;
    --danger: #c62d2d;
    --warn: #b7761a;
  }
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
               "Helvetica Neue", Arial, sans-serif;
  font-size: 17px;
  line-height: 1.4;
  -webkit-text-size-adjust: 100%;
  overscroll-behavior-y: contain;
}

body { padding-bottom: calc(24px + var(--safe-b)); }

[hidden] { display: none !important; }

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

button { cursor: pointer; -webkit-tap-highlight-color: transparent; }

.muted { color: var(--muted); }
.center { text-align: center; }
.error { color: var(--danger); font-weight: 600; }

/* ── Setup ───────────────────────────────────────────────────────────────- */

.setup {
  min-height: 100svh;
  display: grid;
  place-items: center;
  padding: 24px;
}
.setup-inner { width: 100%; max-width: 380px; text-align: center; }
.setup-icon { border-radius: 22px; }
.setup h1 { margin: 12px 0 4px; font-size: 30px; }
.setup p { margin: 0 0 24px; }
.setup form { text-align: left; }

label {
  display: block;
  margin: 14px 0 6px;
  font-size: 14px;
  font-weight: 600;
  color: var(--muted);
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

input, textarea {
  width: 100%;
  min-height: var(--tap);
  padding: 12px 14px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  font-size: 17px; /* >=16px stops iOS zooming on focus */
}
textarea { min-height: 88px; resize: vertical; }
input:focus, textarea:focus {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
  border-color: transparent;
}
input[type="file"] { min-height: auto; padding: 10px; }

.btn-primary, .btn-ghost, .btn-danger {
  min-height: var(--tap);
  padding: 0 20px;
  border-radius: var(--radius);
  border: 1px solid transparent;
  font-size: 17px;
  font-weight: 700;
}
.btn-primary { background: var(--accent); color: var(--accent-ink); width: 100%; }
.btn-ghost   { background: var(--surface-2); color: var(--text); }
.btn-danger  { background: transparent; color: var(--danger); border-color: var(--line); }
button[disabled] { opacity: 0.5; cursor: default; }

/* ── Top bar ─────────────────────────────────────────────────────────────- */

.topbar {
  position: sticky;
  top: 0;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: max(10px, var(--safe-t)) 16px 10px;
  background: linear-gradient(var(--bg) 72%, transparent);
}
.brand { font-weight: 800; letter-spacing: 0.02em; }
.linkish {
  background: none;
  border: 0;
  color: var(--muted);
  font-size: 15px;
  padding: 10px 4px;
  text-decoration: underline;
  text-underline-offset: 3px;
}

/* ── Feed ────────────────────────────────────────────────────────────────- */

.feed { padding: 4px 16px 100px; max-width: 560px; margin: 0 auto; }

.post {
  margin-bottom: 16px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 18px;
  overflow: hidden;
}
.post-img {
  display: block;
  width: 100%;
  max-height: 70vh;
  object-fit: contain;
  background: var(--surface-2);
}
.post-body { padding: 12px 14px; }
.post-caption {
  margin: 0;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
}
.post-text {
  margin: 0;
  font-size: 19px;
  font-weight: 600;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
  padding: 18px 14px 4px;
}
.post-expiry {
  display: inline-block;
  margin-top: 6px;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.02em;
  color: var(--muted);
}
.post-expiry.urgent { color: var(--warn); }
.post-img-wrap { position: relative; background: var(--surface-2); min-height: 120px; }
.post-img-wrap.loading::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.06), transparent);
}

/* ── Compose FAB + sheet ─────────────────────────────────────────────────- */

.fab {
  position: fixed;
  right: 20px;
  bottom: calc(20px + var(--safe-b));
  z-index: 10;
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: var(--accent);
  color: var(--accent-ink);
  border: none;
  font-size: 30px;
  line-height: 1;
  box-shadow: 0 8px 24px rgba(0,0,0,0.35);
}
.fab:active { transform: scale(0.95); }

.scrim {
  position: fixed;
  inset: 0;
  z-index: 20;
  background: rgba(0, 0, 0, 0.55);
}
.sheet {
  position: fixed;
  z-index: 21;
  left: 0;
  right: 0;
  bottom: 0;
  max-height: 88svh;
  overflow-y: auto;
  padding: 20px 20px calc(20px + var(--safe-b));
  background: var(--surface);
  border-top: 1px solid var(--line);
  border-radius: 22px 22px 0 0;
}
@media (min-width: 640px) {
  .sheet {
    left: 50%;
    right: auto;
    bottom: 24px;
    width: 520px;
    transform: translateX(-50%);
    border-radius: 22px;
    border: 1px solid var(--line);
  }
}
.sheet h2 { margin: 0 0 4px; font-size: 22px; }

.compose-preview {
  display: block;
  margin-top: 10px;
  max-width: 100%;
  max-height: 260px;
  border-radius: var(--radius);
  border: 1px solid var(--line);
}

.sheet-actions {
  display: flex;
  gap: 10px;
  margin-top: 22px;
}
.sheet-actions .btn-primary { flex: 1 1 auto; width: auto; }

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
  .fab:active { transform: none; }
}
