:root {
  --bg: #faf7f2;
  --surface: #ffffff;
  --ink: #1f1a15;
  --muted: #6b6259;
  --line: #e4dccf;
  --accent: #b4532a;
  --accent-ink: #ffffff;
  --accent-soft: #f7e7dc;
  --error: #b42318;
  --focus: #1d4ed8;
  --radius: 12px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #15120f;
    --surface: #1f1b17;
    --ink: #f2ece4;
    --muted: #a99f94;
    --line: #362e27;
    --accent: #e3906a;
    --accent-ink: #1a0f08;
    --accent-soft: #3b261b;
    --error: #ff8a80;
    --focus: #8ab4ff;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans", sans-serif;
  -webkit-text-size-adjust: 100%;
}

a { color: var(--accent); }

.wrap { max-width: 1040px; margin: 0 auto; padding: 0 16px; }

/* Header and tabs */
.top { padding: 28px 0 12px; }
.tabs { display: flex; gap: 4px; margin-bottom: 16px; border-bottom: 1px solid var(--line); }
.tab {
  flex: 1 1 0;
  max-width: 220px;
  padding: 12px 8px;
  text-align: center;
  font-weight: 650;
  color: var(--muted);
  text-decoration: none;
  border-bottom: 3px solid transparent;
  margin-bottom: -1px;
}
.tab[aria-selected="true"] { color: var(--accent); border-bottom-color: var(--accent); }
.tab:hover { color: var(--ink); }
h1 { margin: 0; font-size: clamp(2.1rem, 7vw, 3rem); line-height: 1.05; letter-spacing: -0.03em; }
.tagline { margin: 6px 0 0; color: var(--muted); font-size: 1.1rem; }
h2 { margin: 0 0 12px; font-size: 1.35rem; letter-spacing: -0.01em; }

/* Controls */
label { display: flex; flex-direction: column; gap: 4px; font-size: 0.85rem; font-weight: 600; color: var(--muted); }
input, select, textarea {
  width: 100%;
  min-height: 44px;
  padding: 10px 12px;
  font: inherit;
  font-size: 16px;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
}
textarea { resize: vertical; min-height: 64px; }
input:focus-visible, select:focus-visible, textarea:focus-visible, button:focus-visible, a:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 10px 18px;
  font: inherit;
  font-weight: 650;
  color: var(--accent-ink);
  background: var(--accent);
  border: 1px solid var(--accent);
  border-radius: 999px;
  text-decoration: none;
  cursor: pointer;
}
.button.ghost { color: var(--accent); background: transparent; }
.button.danger { color: var(--error); background: transparent; border-color: var(--error); }
.button[disabled] { opacity: 0.6; cursor: progress; }
.linkish {
  padding: 4px 0;
  font: inherit;
  font-size: 0.95rem;
  color: var(--accent);
  background: none;
  border: 0;
  text-decoration: underline;
  cursor: pointer;
}

/* Search */
.search form {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  padding: 14px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}
.search .wide { grid-column: 1 / -1; }
@media (min-width: 760px) {
  .search form { grid-template-columns: repeat(4, 1fr); }
  .search .wide { grid-column: auto; }
}

.count-row { display: flex; align-items: baseline; gap: 12px; min-height: 44px; padding: 10px 2px 4px; }
.count { margin: 0; color: var(--muted); }

/* Cards */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 14px; }
.card {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 16px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow-wrap: anywhere;
}
.card.mine { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent); }
.card p { margin: 0; }
.card-head { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.card-name { margin: 0; font-size: 1.2rem; line-height: 1.25; }
.badge { flex: none; padding: 2px 8px; font-size: 0.75rem; font-weight: 700; color: var(--accent-ink); background: var(--accent); border-radius: 999px; }
.card-inst { font-weight: 650; color: var(--accent); }
.card-meta { color: var(--muted); font-size: 0.95rem; }
.tags { display: flex; flex-wrap: wrap; gap: 6px; margin: 4px 0; padding: 0; list-style: none; }
.tag { padding: 2px 10px; font-size: 0.85rem; background: var(--accent-soft); border-radius: 999px; }
.card-about { margin-top: 2px; }
.card-want { padding: 6px 10px; font-weight: 600; background: var(--accent-soft); border-radius: 8px; }
.card-contact { display: flex; flex-direction: column; gap: 2px; margin-top: auto; padding-top: 8px; border-top: 1px solid var(--line); font-size: 0.95rem; }
.card-contact .label { color: var(--muted); }
.handle { font-weight: 650; user-select: all; -webkit-user-select: all; }

.empty { padding: 28px 16px; text-align: center; color: var(--muted); background: var(--surface); border: 1px dashed var(--line); border-radius: var(--radius); }
.error, .status.error { color: var(--error); }

/* Post panel */
.panel {
  margin: 0 0 16px;
  padding: 20px 16px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  scroll-margin-top: 16px;
}
.hint { margin: 0 0 12px; color: var(--muted); }
.hint strong { color: var(--ink); }
.signed-in { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 10px; }
.inline-form { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 10px; }
.inline-form .grow { flex: 1 1 220px; }
.card-form { display: grid; grid-template-columns: 1fr; gap: 12px; align-items: end; }
.form-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 14px; padding-top: 4px; }
@media (min-width: 640px) {
  .card-form { grid-template-columns: 1fr 1fr; }
  .card-form .wide { grid-column: 1 / -1; }
}
.status { min-height: 1.5em; margin: 12px 0 0; }
.form-note { margin: -4px 0 0; font-size: 0.85rem; color: var(--muted); }
.opt { font-weight: 400; }
.want { margin: 0; padding: 0; border: 0; min-width: 0; }
.want legend { margin-bottom: 6px; padding: 0; font-size: 0.85rem; font-weight: 600; color: var(--muted); }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { position: relative; display: inline-flex; font-size: 0.95rem; font-weight: 500; color: var(--ink); cursor: pointer; }
.chip input { position: absolute; opacity: 0; width: 1px; height: 1px; min-height: 0; }
.chip span { padding: 8px 14px; border: 1px solid var(--line); border-radius: 999px; background: var(--surface); }
.chip input:checked + span { color: var(--accent-ink); background: var(--accent); border-color: var(--accent); }
.chip input:focus-visible + span { outline: 3px solid var(--focus); outline-offset: 2px; }
.check { flex-direction: row; align-items: center; gap: 10px; min-height: 44px; font-size: 0.95rem; font-weight: 500; color: var(--ink); cursor: pointer; grid-column: 1 / -1; }
.check input { width: 22px; min-height: 0; height: 22px; margin: 0; accent-color: var(--accent); }

/* Footer */
.soon { margin: 32px 0 24px; color: var(--muted); font-size: 0.95rem; }
.privacy { margin: 0 0 48px; padding-top: 20px; border-top: 1px solid var(--line); font-size: 0.92rem; color: var(--muted); }
.privacy h2 { font-size: 1.05rem; color: var(--ink); }
.privacy strong { color: var(--ink); }
.privacy ul { padding-left: 1.2em; }
.privacy li { margin: 4px 0; }

[hidden] { display: none !important; }
