/* Circle design system. Served from our own origin because the CSP is
   style-src 'self' (no inline styles). System fonts only: no font CDN
   (docs/10-architecture.md §4). Warm and calm: quiet cards, soft family tint. */

:root {
  --bg: #faf6f0;
  --surface: #ffffff;
  --tint: #f4ede3;
  --text: #2a2522;
  --muted: #6b625b;
  --line: #e8e0d4;
  --accent: #1f6f68;
  --accent-hover: #185a54;
  --accent-soft: #e2efec;
  --on-accent: #ffffff;
  --danger: #a63d2f;
  --danger-soft: #f8e7e3;
  --warn-soft: #fbf0d9;
  --warn-text: #7a5a12;
  --radius: 14px;
  --radius-sm: 10px;
  --shadow: 0 1px 2px rgba(42, 37, 34, 0.05), 0 4px 14px rgba(42, 37, 34, 0.06);
  --font-body: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-display: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, "Times New Roman", serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #1a1715;
    --surface: #24201d;
    --tint: #2d2723;
    --text: #f1ebe4;
    --muted: #b0a79e;
    --line: #3a332e;
    --accent: #5cb8ae;
    --accent-hover: #7accc3;
    --accent-soft: #1f3431;
    --on-accent: #10201e;
    --danger: #e58a7c;
    --danger-soft: #3a2420;
    --warn-soft: #3a2f17;
    --warn-text: #e8c872;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 4px 14px rgba(0, 0, 0, 0.25);
  }
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 1rem;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

h1,
h2,
h3 {
  font-family: var(--font-display);
  font-weight: 600;
  line-height: 1.2;
  margin: 0 0 0.5rem;
  letter-spacing: -0.01em;
}
h1 { font-size: 1.85rem; }
h2 { font-size: 1.3rem; }
h3 { font-size: 1.1rem; }

p { margin: 0 0 0.75rem; }

a {
  color: var(--accent);
  text-underline-offset: 2px;
}
a:hover { color: var(--accent-hover); }

:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
  border-radius: 6px;
}

/* ---- Layout ---------------------------------------------------------- */

.site-header {
  border-bottom: 1px solid var(--line);
  background: var(--surface);
}
.site-header-inner {
  max-width: 44rem;
  margin: 0 auto;
  padding: 0.85rem 1rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}
.brand {
  font-family: var(--font-display);
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--text);
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
}
.brand::before {
  content: "";
  width: 1.1rem;
  height: 1.1rem;
  border-radius: 50%;
  border: 3px solid var(--accent);
  display: inline-block;
}

.container {
  max-width: 44rem;
  margin: 0 auto;
  padding: 1.5rem 1rem 4rem;
}
.container-narrow {
  max-width: 28rem;
  margin: 0 auto;
  padding: 2.5rem 1rem 4rem;
}

.stack > * + * { margin-top: 1rem; }
.stack-lg > * + * { margin-top: 1.75rem; }
.row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.6rem;
}
.row-between {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}
.inline-form { display: inline; margin: 0; }

.page-head { margin-bottom: 1.25rem; }
.page-head p { color: var(--muted); margin: 0; }
.crumb {
  display: inline-block;
  margin-bottom: 0.5rem;
  font-size: 0.9rem;
  text-decoration: none;
}

/* ---- Cards ----------------------------------------------------------- */

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.25rem;
}
.card-tint {
  background: var(--tint);
  box-shadow: none;
}

.post {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.25rem 1.25rem 1rem;
}
.post-body {
  font-size: 1.05rem;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.meta {
  color: var(--muted);
  font-size: 0.85rem;
}
.post .meta { margin: 0.75rem 0 0; }

.circle-card > * + * { margin-top: 1rem; }
.circle-card h2 { margin-bottom: 0; }

.empty {
  text-align: center;
  color: var(--muted);
  padding: 2.5rem 1rem;
  border: 1px dashed var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}

/* ---- Buttons --------------------------------------------------------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  min-height: 2.75rem;
  padding: 0.55rem 1.1rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  line-height: 1.2;
}
.btn:hover { background: var(--tint); color: var(--text); }
.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--on-accent);
}
.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); color: var(--on-accent); }
.btn-danger {
  color: var(--danger);
  border-color: var(--danger-soft);
  background: var(--danger-soft);
}
.btn-danger:hover { background: var(--danger-soft); color: var(--danger); border-color: var(--danger); }
.btn-small { min-height: 2.25rem; padding: 0.35rem 0.8rem; font-size: 0.9rem; }
.btn-block { width: 100%; }

/* ---- Forms ----------------------------------------------------------- */

.field { display: block; }
.field > label,
.label {
  display: block;
  font-weight: 600;
  margin-bottom: 0.35rem;
}
.hint { color: var(--muted); font-size: 0.9rem; margin: 0.3rem 0 0; }

input[type="text"],
input[type="email"],
input[type="search"],
input[type="date"],
input[type="time"],
input[type="number"],
select,
textarea {
  width: 100%;
  min-height: 2.75rem;
  padding: 0.65rem 0.8rem;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  font: inherit;
}
textarea { min-height: 10rem; resize: vertical; }
input::placeholder, textarea::placeholder { color: var(--muted); opacity: 0.8; }
input[type="text"]:focus,
input[type="email"]:focus,
textarea:focus {
  outline: 3px solid var(--accent-soft);
  border-color: var(--accent);
}

.code-input {
  font-size: 1.6rem;
  letter-spacing: 0.35em;
  text-align: center;
  font-variant-numeric: tabular-nums;
}

fieldset {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  padding: 0.9rem 1rem 1rem;
  margin: 0;
  min-width: 0;
}
legend {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 1.05rem;
  padding: 0 0.4rem;
}

/* A big, tappable checkbox row: one per group or person. */
.check {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  min-height: 2.75rem;
  padding: 0.4rem 0.6rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
}
.check:hover { background: var(--tint); }
.check input {
  width: 1.3rem;
  height: 1.3rem;
  accent-color: var(--accent);
  flex-shrink: 0;
}
.check-sub { color: var(--muted); font-size: 0.85rem; }

/* ---- Pills, badges, notices ----------------------------------------- */

.badge {
  display: inline-block;
  padding: 0.12rem 0.6rem;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 600;
  background: var(--accent-soft);
  color: var(--accent);
}
.badge-muted { background: var(--tint); color: var(--muted); }
.badge-warn { background: var(--warn-soft); color: var(--warn-text); }

.notice {
  padding: 0.85rem 1rem;
  border-radius: var(--radius-sm);
  background: var(--accent-soft);
  color: var(--text);
}
.notice-warn { background: var(--warn-soft); color: var(--warn-text); }
.notice a { font-weight: 600; }

.recipients {
  list-style: none;
  padding: 0;
  margin: 0.75rem 0 0;
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}
.recipients li {
  background: var(--accent-soft);
  color: var(--text);
  padding: 0.3rem 0.8rem;
  border-radius: 999px;
  font-size: 0.95rem;
}

/* ---- Lists ----------------------------------------------------------- */

.list { list-style: none; padding: 0; margin: 0; }
.list > li {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.6rem;
  padding: 0.7rem 0;
  border-top: 1px solid var(--line);
}
.list > li:first-child { border-top: 0; }

.qr {
  display: block;
  width: 14rem;
  max-width: 100%;
  height: auto;
  margin: 0 auto;
  background: #fff;
  padding: 0.5rem;
  border-radius: var(--radius-sm);
}

/* ---- Tabs, facts, tags ------------------------------------------------ */

.tabs {
  display: flex;
  gap: 0.35rem;
  margin-bottom: 1.25rem;
  padding: 0.3rem;
  background: var(--tint);
  border-radius: var(--radius);
}
.tab {
  flex: 1;
  min-height: 2.75rem;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0.6rem 0.75rem;
  border-radius: var(--radius-sm);
  color: var(--muted);
  font-weight: 600;
  text-decoration: none;
}
.tab[aria-current="page"] {
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow);
}

/* Five subscriber tabs have to fit a phone: let them shrink and wrap text. */
.tabs { overflow-x: auto; }
.tab { padding: 0.6rem 0.4rem; font-size: 0.88rem; flex: 1 1 auto; white-space: nowrap; }

/* Private messages. The other person's sit on the left, yours on the right. */
.bubble {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 0.85rem 1rem;
  margin-right: 2.5rem;
}
.bubble-mine { background: var(--accent-soft); border-color: var(--accent-soft); margin-right: 0; margin-left: 2.5rem; }
.bubble p { margin: 0 0 0.3rem; }
.bubble-context {
  color: var(--muted);
  font-size: 0.85rem;
  border-left: 3px solid var(--line);
  padding-left: 0.6rem;
  margin: 0 0 0.5rem;
}

.card-link {
  display: block;
  color: var(--text);
  text-decoration: none;
}
.card-link:hover { color: var(--text); border-color: var(--accent); }
.card-link h2 { margin-bottom: 0.15rem; }
.card-link .meta { margin: 0; }

.facts { margin: 0; }
.fact { padding: 0.7rem 0; border-top: 1px solid var(--line); }
.fact:first-child { border-top: 0; padding-top: 0; }
.fact dt { font-weight: 600; }
.fact dd { margin: 0.2rem 0 0; }
.updated { color: var(--muted); font-weight: 400; font-size: 0.85rem; }

.tags {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}
.tags li {
  background: var(--accent-soft);
  padding: 0.2rem 0.75rem;
  border-radius: 999px;
  font-size: 0.95rem;
}

.grow { flex: 1; min-width: 9rem; }
.label { font-weight: 600; margin: 0 0 0.15rem; }

.chips { display: flex; flex-wrap: wrap; gap: 0.4rem; margin-bottom: 1.25rem; }
.chip {
  min-height: 2.5rem;
  display: inline-flex;
  align-items: center;
  padding: 0.35rem 0.9rem;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--text);
  font-weight: 600;
  text-decoration: none;
}
.chip[aria-current="page"] { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }

/* A radio presented as a full-width card, with its consequence spelled out. */
.choice {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  padding: 0.9rem 1rem;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface);
  cursor: pointer;
}
.choice:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); }
.choice input { width: 1.3rem; height: 1.3rem; margin-top: 0.15rem; accent-color: var(--accent); flex-shrink: 0; }
.choice-title { display: block; font-weight: 600; }
.choice-text { display: block; color: var(--muted); font-size: 0.95rem; margin-top: 0.15rem; }

.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0.75rem; }
.stat {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 0.8rem 0.5rem;
  text-align: center;
}
.stat strong { display: block; font-family: var(--font-display); font-size: 1.6rem; }
.stat span { color: var(--muted); font-size: 0.85rem; font-weight: 600; }

.item-row { align-items: flex-start; }
.item-main { flex: 1; min-width: 12rem; }
.item-main p { margin: 0 0 0.25rem; }
.item-name { font-weight: 600; font-size: 1.05rem; }
.item-actions { display: flex; flex-wrap: wrap; gap: 0.4rem; }
.tag-badge { margin-left: 0.4rem; }

/* Owner preview: unmistakable, so nobody mistakes it for their own view. */
.preview-banner {
  margin: 0 0 1.5rem;
  padding: 0.9rem 1rem;
  border: 3px dashed var(--accent);
  border-radius: var(--radius);
  background: var(--accent-soft);
}
.badge-sage { background: var(--accent-soft); color: var(--accent); }
button:disabled { opacity: 0.45; cursor: not-allowed; }

.avoid-card,
.fieldset-avoid {
  background: var(--danger-soft);
  border-color: var(--danger-soft);
}
.avoid-card .tags li { background: var(--surface); }

@media (min-width: 40rem) {
  .container { padding-top: 2.25rem; }
  h1 { font-size: 2.1rem; }
}

@media (prefers-reduced-motion: no-preference) {
  .btn, .check { transition: background-color 0.12s ease, border-color 0.12s ease; }
}

/* Photos (D-07). Square-cropped tiles keep a library tidy; feed photos keep
   their shape and never overflow a phone-width column. */
.photo-grid {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(10rem, 1fr));
  gap: 0.9rem;
}
.photo-tile img,
.photo-pick img {
  display: block;
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
  border-radius: 0.6rem;
  background: var(--tint);
}
.photo-tile .meta { margin: 0.35rem 0; }
.photo-pick {
  display: block;
  cursor: pointer;
}
.photo-pick input { margin-top: 0.4rem; }
.post-photos {
  display: grid;
  gap: 0.4rem;
  margin: 0.75rem 0;
}
.post-photos img {
  display: block;
  width: 100%;
  height: auto;
  max-height: 28rem;
  object-fit: cover;
  border-radius: 0.6rem;
  background: var(--tint);
}
.post-photos-2,
.post-photos-3,
.post-photos-4 { grid-template-columns: 1fr 1fr; }
.post-photos-2 img,
.post-photos-3 img,
.post-photos-4 img { aspect-ratio: 1; height: 100%; }

/* Timeline (Epic T): a quiet date above each card, newest first. */
.timeline { list-style: none; padding: 0; margin: 0; display: grid; gap: 1.1rem; }
.timeline-item .card { margin-top: 0.35rem; }
.timeline-date {
  margin: 0;
  color: var(--muted);
  font-size: 0.88rem;
  font-weight: 600;
  letter-spacing: 0.02em;
}

/* Which Circle this device is showing, only when it holds more than one. */
.circle-switch { margin: 0 0 0.6rem; color: var(--muted); font-size: 0.9rem; }

/* Photo storage meter (FR-J6). */
.meter { width: 100%; height: 0.7rem; accent-color: var(--accent); }

/* Calendar: a masked block is quieter than a real event. */
.cal-busy { color: var(--muted); }
