/* SOS — styles. Mobile-first. */
:root {
  --red: #c1121f;
  --red-dark: #9b0e18;
  --ink: #1b2430;
  --muted: #5b6776;
  --line: #e2e6ec;
  --bg: #f4f6f9;
  --card: #ffffff;
  --blue: #0b6bcb;
  --radius: 14px;
  --shadow: 0 6px 24px rgba(20, 30, 50, 0.08);
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  color: var(--ink);
  background: var(--bg);
  line-height: 1.5;
}
h1 { font-size: 1.45rem; margin: 0 0 .4rem; }
h2 { font-size: 1.05rem; margin: 1.2rem 0 .5rem; }
a { color: var(--blue); }
.muted { color: var(--muted); }
.hint { color: var(--muted); font-size: .85rem; }
.lede { color: var(--muted); margin-top: 0; }

/* Badge */
.sos-badge {
  display: inline-block;
  background: var(--red);
  color: #fff;
  font-weight: 800;
  letter-spacing: 1px;
  padding: .35rem .6rem;
  border-radius: 8px;
  font-size: 1.1rem;
}
.sos-badge.sm { font-size: .9rem; padding: .25rem .45rem; }

/* Buttons */
.btn {
  display: inline-block;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  padding: .7rem 1rem;
  border-radius: 10px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  text-align: center;
}
.btn.primary { background: var(--red); border-color: var(--red); color: #fff; }
.btn.primary:hover { background: var(--red-dark); }
.btn.small { padding: .45rem .7rem; font-size: .85rem; }
.btn.block { display: block; width: 100%; }
.btn.link { border: none; background: none; color: var(--blue); padding: .4rem; }
.btn.danger-btn { background: #fff; color: var(--red); border-color: var(--red); }

.alert { padding: .7rem .9rem; border-radius: 10px; margin: .8rem 0; font-size: .92rem; }
.alert.error  { background: #fdecec; color: #8a1212; }
.alert.notice { background: #e8f6ec; color: #1c6b34; }
.alert.warn   { background: #fff6e5; color: #8a5a00; }

/* ---------- Auth / landing ---------- */
body.auth { display: flex; flex-direction: column; min-height: 100vh; align-items: center; }
.card {
  background: var(--card);
  margin: 8vh 1rem 1rem;
  padding: 1.6rem 1.4rem;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  max-width: 420px;
  width: 100%;
}
.brand { margin-bottom: .8rem; }
.stack { display: flex; flex-direction: column; gap: .6rem; margin-top: 1rem; }
.stack label { font-weight: 600; font-size: .9rem; }
.inline { text-align: center; margin-top: .4rem; }
input, select, textarea {
  font: inherit;
  width: 100%;
  padding: .7rem .8rem;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  color: var(--ink);
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--blue); border-color: var(--blue); }
.code-input { font-size: 1.6rem; letter-spacing: .4rem; text-align: center; }
.legal { color: var(--muted); font-size: .78rem; text-align: center; padding: 1rem; max-width: 420px; }

/* ---------- App chrome ---------- */
.topbar {
  display: flex; align-items: center; gap: .6rem;
  background: #fff; border-bottom: 1px solid var(--line);
  padding: .6rem .8rem; position: sticky; top: 0; z-index: 5;
}
.brand-sm { text-decoration: none; }
.tabs { display: flex; gap: .2rem; flex: 1; overflow-x: auto; }
.tabs a {
  padding: .45rem .7rem; border-radius: 8px; text-decoration: none;
  color: var(--muted); font-weight: 600; font-size: .9rem; white-space: nowrap;
}
.tabs a.active { background: #eef3fb; color: var(--blue); }
.signout { color: var(--muted); text-decoration: none; font-size: .85rem; }
.wrap { max-width: 720px; margin: 0 auto; padding: 1rem; }

/* Share bar */
.share-bar {
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  background: #fff; border: 1px solid var(--line); border-radius: var(--radius);
  padding: .8rem 1rem; margin-bottom: 1rem; flex-wrap: wrap;
}
.share-link { display: block; font-size: .9rem; word-break: break-all; }

/* Profile form */
.section-help { background: #eef3fb; padding: .7rem .9rem; border-radius: 10px; font-size: .9rem; }
.fields { display: grid; gap: .8rem; }
.field {
  display: grid; grid-template-columns: 1fr auto; gap: .3rem .8rem;
  align-items: end; border-bottom: 1px solid var(--line); padding-bottom: .8rem;
}
.field > label:first-child { grid-column: 1 / 2; font-weight: 600; font-size: .9rem; }
.field input, .field select, .field textarea { grid-column: 1 / 2; }
.pub {
  grid-column: 2 / 3; grid-row: 1 / 3;
  display: flex; align-items: center; gap: .3rem;
  font-size: .8rem; color: var(--muted); white-space: nowrap; align-self: center;
}
.pub input { width: auto; }
.contacts { border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem; margin: 1.2rem 0; }
.contacts legend { font-weight: 700; padding: 0 .4rem; }
.pub.master { margin-bottom: .8rem; color: var(--ink); }

/* Stack contact fields on phones so they're full-width and readable. */
.contact-row {
  display: grid;
  grid-template-columns: 1fr;
  gap: .5rem;
  padding: .8rem;
  margin-bottom: .7rem;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fafbfc;
}
.contact-row .pub { justify-self: start; align-self: center; color: var(--ink); }
@media (min-width: 560px) {
  .contact-row {
    grid-template-columns: 1fr 1fr;
    align-items: center;
  }
  .contact-row input[name$="[name]"] { grid-column: 1 / -1; }
}
.form-actions { margin-top: 1rem; }
.form-actions .btn { width: 100%; }

details.danger { margin-top: 1.6rem; border: 1px solid #f3d3d6; border-radius: var(--radius); padding: .8rem 1rem; background: #fff; }
details.danger summary { font-weight: 700; color: var(--red); cursor: pointer; }
details.danger p { font-size: .88rem; color: var(--muted); }

/* QR page */
.qr-preview { display: flex; justify-content: center; padding: 1rem; }
.qr-preview img { width: 260px; height: 260px; image-rendering: pixelated; border: 8px solid #fff; box-shadow: var(--shadow); border-radius: 8px; }
.link-box { display: flex; gap: .5rem; margin: 1rem 0; }
.link-box input { font-size: .85rem; }
.qr-actions { display: grid; gap: .6rem; }

/* Wallpaper */
.wp-layout { display: grid; gap: 1.2rem; }
.wp-stage { text-align: center; }
.wp-canvas {
  max-width: 100%; max-height: 64vh; height: auto; width: auto;
  border-radius: 18px; box-shadow: var(--shadow); background: #1c2430;
  touch-action: none; cursor: grab;
}
.wp-controls { display: grid; gap: 1rem; }
.ctrl { display: grid; gap: .4rem; }
.ctrl > label { font-weight: 600; font-size: .9rem; }
.checkrow { display: flex; align-items: center; gap: .5rem; font-weight: 600; font-size: .92rem; }
.checkrow input { width: auto; }
.dims { font-size: .85rem; color: var(--ink); margin: .2rem 0 0; font-weight: 600; }
.dims.detected { color: #1c6b34; }
.custom-size { display: flex; align-items: center; gap: .4rem; flex-wrap: wrap; }
.custom-size input { width: 5.5rem; text-align: center; }
.custom-size span { color: var(--muted); }

@media (min-width: 720px) {
  .wp-layout { grid-template-columns: 1fr 280px; align-items: start; }
}

/* ---------- Public emergency page ---------- */
body.public { background: #fff; }
.er-header {
  display: flex; align-items: center; gap: .8rem;
  background: var(--red); color: #fff; padding: 1rem;
}
.er-header h1 { font-size: 1.2rem; margin: 0; color: #fff; }
.er-sub { margin: .1rem 0 0; font-size: .82rem; opacity: .9; }
.er-card { max-width: 560px; margin: 0 auto; padding: 1rem; }
.er-critical { display: grid; gap: .1rem; margin-bottom: 1rem; }
.er-item { padding: .7rem .2rem; border-bottom: 1px solid var(--line); }
.er-item.critical { background: #fff5f5; border-bottom: 2px solid #f3d3d6; padding: .8rem .7rem; border-radius: 8px; margin-bottom: .3rem; }
.er-label { display: block; font-size: .75rem; text-transform: uppercase; letter-spacing: .5px; color: var(--muted); }
.er-value { font-size: 1.2rem; font-weight: 600; }
.er-item.critical .er-value { font-size: 1.4rem; }
.er-contacts { margin: 1.2rem 0; }
.er-contact { display: flex; justify-content: space-between; align-items: center; gap: 1rem; padding: .7rem .2rem; border-bottom: 1px solid var(--line); }
.er-rel { color: var(--muted); font-size: .85rem; margin-left: .4rem; }
.er-call {
  background: #1c6b34; color: #fff; text-decoration: none; font-weight: 700;
  padding: .55rem .9rem; border-radius: 10px; white-space: nowrap;
}
.er-foot { margin-top: 1.4rem; color: var(--muted); font-size: .78rem; text-align: center; }
.er-updated { margin: .2rem 0; }
body.notfound .er-card { text-align: center; padding-top: 3rem; }

/* ---------- Help page ---------- */
.help { max-width: 720px; }
.help h2 { border-top: 1px solid var(--line); padding-top: 1rem; margin-top: 1.4rem; }
.help h2:first-of-type { border-top: none; }
.help ol, .help ul { padding-left: 1.2rem; }
.help li { margin: .35rem 0; }
.help .platforms { display: grid; gap: 1rem; }
@media (min-width: 620px) { .help .platforms { grid-template-columns: 1fr 1fr; } }
.help .panel { border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem; background: #fff; }
.help .panel h3 { margin: 0 0 .5rem; }
.help .free { background: #e8f6ec; border-radius: var(--radius); padding: 1rem; font-weight: 600; color: #1c6b34; }
.help .support { display: flex; flex-wrap: wrap; gap: .6rem; align-items: center; margin: .6rem 0; }
.coffee {
  display: inline-block; background: #ffdd00; color: #000; font-weight: 700;
  padding: .6rem 1rem; border-radius: 10px; text-decoration: none;
}
.help-header { display: flex; align-items: center; gap: .6rem; padding: .8rem 1rem; background: #fff; border-bottom: 1px solid var(--line); }
.help-header .back { margin-left: auto; color: var(--muted); text-decoration: none; font-size: .9rem; }
