/* Shepherd's Flock admin: the same look as the 2.0 apps (brand red on warm beige, Libre Caslon headings) */
@font-face {
  font-family: "Libre Caslon Text";
  src: url("/assets/LibreCaslonText.ttf") format("truetype");
  font-weight: 400 700;
  font-display: swap;
}

:root {
  --red: #9B2C2C;
  --red-dark: #7F2424;
  --live: #C62828;
  --accent: #9B2C2C;
  --bg: #FAF6F1;
  --surface: #FFFFFF;
  --ink: #231B19;
  --body: #4A3F3B;
  --muted: #6B5E58;
  --hairline: #EFE8E0;
  --tint: #F6EAEA;
  --quote: #F1E8DE;
  --success: #2E6B3A;
  --success-bg: #E7F2E9;
  --field: #FAF6F1;
  --field-border: #E6DDD3;
  --switch-off: #DDD3C9;
  --secondary-text: #9B2C2C;
  --shadow: 0 1px 2px rgba(35, 27, 25, 0.06), 0 2px 8px rgba(35, 27, 25, 0.04);
  /* Background texture: a faint paper grain and a soft warm glow at the top */
  --grain: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='180' height='180'%3E%3Cfilter id='g'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.7' numOctaves='3' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 0.45 0 0 0 0 0.27 0 0 0 0 0.16 0 0 0 0.55 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23g)'/%3E%3C/svg%3E");
  --glow: rgba(155, 44, 44, 0.13);
  --card-edge: transparent;
  --serif: "Libre Caslon Text", Georgia, serif;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, system-ui, sans-serif;
  color-scheme: light dark;
}

/* Dark mode: fields lighter than their card with a visible edge, brighter text and buttons */
@media (prefers-color-scheme: dark) {
  :root {
    --red: #B23B3B;
    --accent: #F2A79F;
    --bg: #161211;
    --surface: #221C1A;
    --ink: #F6F0EB;
    --body: #E3D9D3;
    --muted: #C2B5AD;
    --hairline: #3B322E;
    --tint: #47292A;
    --quote: #2C2421;
    --success: #9EDCAC;
    --success-bg: #1E3424;
    --field: #2E2724;
    --field-border: #4D423D;
    --switch-off: #5C514C;
    --secondary-text: #F8C9C3;
    --shadow: none;
    --grain: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='180' height='180'%3E%3Cfilter id='g'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.7' numOctaves='3' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 1 0 0 0 0 0.92 0 0 0 0 0.86 0 0 0 0.24 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23g)'/%3E%3C/svg%3E");
    --glow: rgba(242, 167, 159, 0.1);
    --card-edge: rgba(255, 240, 230, 0.07);
  }
}

* { box-sizing: border-box; }

/* The glow and paper grain sit on a fixed layer behind everything, so they stay put while
   scrolling and show through the frosted header (background-attachment: fixed isn't
   supported on iPhone, a fixed layer is) */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background-image: radial-gradient(1300px 640px at 50% 0, var(--glow), transparent 70%), var(--grain);
  background-repeat: no-repeat, repeat;
}
[hidden] { display: none !important; }

body {
  margin: 0;
  min-height: 100vh;
  background-color: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3 { font-family: var(--serif); font-weight: 400; margin: 0; }
h1 { font-size: 32px; line-height: 1.15; }
h2 { font-size: 22px; }
h3 { font-size: 18px; }
p { margin: 0; }
a { color: var(--accent); }

.muted { color: var(--muted); }
.small { font-size: 14px; }

/* Layout */
.page { max-width: 760px; margin: 0 auto; padding: 0 16px 48px; }
.stack { display: flex; flex-direction: column; gap: 12px; }
.row { display: flex; align-items: center; gap: 12px; }
.row.wrap { flex-wrap: wrap; }
.grow { flex: 1; min-width: 0; }
section { display: flex; flex-direction: column; gap: 14px; margin-top: 28px; }

/* Header and navigation */
.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  background: color-mix(in srgb, var(--bg) 55%, transparent);
  backdrop-filter: blur(16px) saturate(1.2);
  -webkit-backdrop-filter: blur(16px) saturate(1.2);
  border-bottom: 1px solid var(--hairline);
}
.topbar-inner { max-width: 760px; margin: 0 auto; padding: 12px 16px 0; }
.brand { display: flex; align-items: center; gap: 12px; }
.brand img { width: 40px; height: 40px; border-radius: 10px; box-shadow: var(--shadow); }
.brand-name { font-family: var(--serif); font-size: 18px; }
.tabs { display: flex; gap: 4px; overflow-x: auto; margin-top: 10px; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tab {
  flex: none;
  padding: 10px 8px;
  border-bottom: 2px solid transparent;
  color: var(--muted);
  text-decoration: none;
  font-weight: 600;
  font-size: 14px;
}
.tab[aria-current="page"] { color: var(--accent); border-bottom-color: var(--accent); }

/* Cards */
.card {
  background: var(--surface);
  border: 1px solid var(--card-edge);
  border-radius: 16px;
  box-shadow: var(--shadow);
  padding: 16px;
}
.card.flush { padding: 0; }
.card-row { padding: 14px 16px; display: flex; gap: 12px; align-items: flex-start; }
.card-row + .card-row { border-top: 1px solid var(--hairline); }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 12px; }
.stat-label { font-size: 13px; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); }
.stat-value { font-family: var(--serif); font-size: 28px; line-height: 1.2; margin-top: 4px; }
.stat-detail { font-size: 14px; color: var(--muted); margin-top: 2px; }

/* Badges */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  background: var(--tint);
  color: var(--accent);
  white-space: nowrap;
}
.badge.live { background: var(--live); color: #fff; }
.badge.live::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: #fff; }
.badge.neutral { background: var(--hairline); color: var(--muted); }
.badge.ok { background: var(--success-bg); color: var(--success); }

/* Forms */
label { display: block; font-weight: 600; font-size: 15px; margin-bottom: 6px; }
.hint { font-size: 13px; color: var(--muted); margin-top: 4px; font-weight: 400; }
input[type="text"], input[type="password"], input[type="time"], textarea, select {
  width: 100%;
  font: inherit;
  color: var(--ink);
  background: var(--field);
  border: 1px solid var(--field-border);
  border-radius: 12px;
  padding: 11px 12px;
  min-height: 44px;
}
textarea { min-height: 96px; resize: vertical; }
input:focus-visible, textarea:focus-visible, select:focus-visible, button:focus-visible, a:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
.check { display: flex; gap: 10px; align-items: flex-start; font-weight: 400; }
.check input { width: 20px; height: 20px; margin: 2px 0 0; accent-color: var(--red); flex: none; }
.field-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
fieldset.choice { border: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 10px 20px; }
fieldset.choice legend { font-weight: 600; font-size: 15px; margin-bottom: 8px; padding: 0; width: 100%; }
.check input[type="radio"] { accent-color: var(--red); }
input[type="date"], input[type="datetime-local"] {
  width: 100%;
  font: inherit;
  color: var(--ink);
  background: var(--field);
  border: 1px solid var(--field-border);
  border-radius: 12px;
  padding: 11px 12px;
  min-height: 44px;
}

/* Buttons */
button, .button {
  font: inherit;
  font-weight: 600;
  font-size: 15px;
  min-height: 44px;
  padding: 0 18px;
  border-radius: 12px;
  border: none;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  text-decoration: none;
  background: var(--red);
  color: #fff;
}
button:hover { filter: brightness(1.08); }
button:disabled { opacity: 0.55; cursor: default; filter: none; }
button.secondary { background: var(--tint); color: var(--secondary-text); }
button.quiet { background: transparent; color: var(--accent); padding: 0 10px; }
button.danger { background: transparent; color: var(--live); padding: 0 10px; }
button.full { width: 100%; }
.button-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 10px; }

/* Toggle switch */
.switch { position: relative; width: 52px; height: 32px; flex: none; }
.switch input { position: absolute; inset: 0; opacity: 0; margin: 0; cursor: pointer; z-index: 1; }
.switch .track { position: absolute; inset: 0; border-radius: 999px; background: var(--switch-off); transition: background 0.2s; }
.switch .track::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.25);
  transition: transform 0.2s;
}
.switch input:checked + .track { background: var(--red); }
.switch input:checked + .track::after { transform: translateX(20px); }
.switch input:focus-visible + .track { outline: 2px solid var(--accent); outline-offset: 2px; }

/* Collapsible sections: a <details> whose summary looks like a section heading */
details.panel > summary,
details.inline > summary {
  list-style: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 10px;
  -webkit-tap-highlight-color: transparent;
}
details.panel > summary::-webkit-details-marker,
details.inline > summary::-webkit-details-marker { display: none; }
details.panel > summary { min-height: 44px; }
details.panel > summary h2 { flex: 1; }
details.panel > summary .count { font-size: 14px; color: var(--muted); font-family: var(--sans); }
details.panel > summary::after,
details.inline > summary::after {
  content: "";
  width: 9px;
  height: 9px;
  border-right: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  transform: rotate(45deg) translate(-2px, -2px);
  transition: transform 0.2s;
  flex: none;
}
details[open].panel > summary::after,
details[open].inline > summary::after { transform: rotate(225deg) translate(-2px, -2px); }
details.panel > summary::after { color: var(--muted); margin-right: 6px; }
details.panel[open] > summary { margin-bottom: 14px; }
details.panel > summary:focus-visible,
details.inline > summary:focus-visible { outline: 2px solid var(--accent); outline-offset: 4px; border-radius: 8px; }
/* "Edit" toggles inside cards */
details.inline > summary {
  color: var(--accent);
  font-weight: 600;
  font-size: 15px;
  min-height: 40px;
  width: fit-content;
}
details.inline > summary::after { width: 7px; height: 7px; }
details.inline[open] > summary { margin-bottom: 10px; }
details.inline > .stack { padding-top: 4px; }

/* "Also send as a notification" fields inside the notice form */
.notify-box {
  background: var(--quote);
  border-radius: 14px;
  padding: 14px;
  border-left: 3px solid var(--accent);
}

/* Home shortcuts */
.actions { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.action {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 16px;
  border-radius: 16px;
  background: var(--surface);
  box-shadow: var(--shadow);
  color: var(--ink);
  text-decoration: none;
  border: 1px solid var(--hairline);
}
.action:hover { border-color: var(--accent); }
.action .icon {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  background: var(--tint);
  color: var(--secondary-text);
  display: grid;
  place-items: center;
  flex: none;
}
.action .icon svg { width: 22px; height: 22px; }
.action b { display: block; font-size: 16px; }
.action span { display: block; font-size: 14px; color: var(--muted); }
.intro { color: var(--muted); max-width: 60ch; }

/* Notification preview */
.preview {
  background: var(--quote);
  border-radius: 16px;
  padding: 14px;
}
.preview-banner {
  background: var(--surface);
  border-radius: 14px;
  padding: 10px 12px;
  display: flex;
  gap: 10px;
  box-shadow: 0 4px 14px rgba(35, 27, 25, 0.12);
}
.preview-banner img { width: 36px; height: 36px; border-radius: 8px; }
.preview-app { font-size: 12px; color: var(--muted); }
.preview-title { font-weight: 600; font-size: 15px; overflow-wrap: anywhere; }
.preview-body { font-size: 14px; color: var(--body); overflow-wrap: anywhere; }

/* Lists */
.item-title { font-weight: 600; }
.item-body { color: var(--body); font-size: 15px; white-space: pre-line; overflow-wrap: anywhere; }
.empty { padding: 24px 16px; text-align: center; color: var(--muted); }

/* Toast */
.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%) translateY(20px);
  max-width: calc(100% - 32px);
  padding: 12px 18px;
  border-radius: 12px;
  background: var(--ink);
  color: var(--bg);
  font-weight: 600;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s, transform 0.2s;
  z-index: 20;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.error { background: var(--live); color: #fff; }

/* Login */
.login {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px 16px;
}
.login .card { width: 100%; max-width: 400px; padding: 28px; }
.login .brand { flex-direction: column; text-align: center; gap: 10px; margin-bottom: 24px; }
.login .brand img { width: 64px; height: 64px; border-radius: 16px; }
.error-text { color: var(--live); font-size: 14px; font-weight: 600; min-height: 20px; }

@media (max-width: 520px) {
  h1 { font-size: 28px; }
  .actions { grid-template-columns: 1fr; }
  .tabs { gap: 0; justify-content: space-between; }
  .tab { padding: 10px 6px; }
  .field-grid { grid-template-columns: 1fr; }
}

/* Small phones (iPhone SE and similar) */
@media (max-width: 360px) {
  .page, .topbar-inner { padding-left: 12px; padding-right: 12px; }
  .brand img { width: 34px; height: 34px; }
  .brand-name { font-size: 16px; }
  .tab { font-size: 13px; padding: 10px 4px; }
  .card, .action { padding: 14px; }
  .card-row { padding: 12px; }
  .button-grid { grid-template-columns: 1fr 1fr; }
  .button-grid button { padding: 0 8px; font-size: 14px; }
}
