/* The Hang — warm, simple, phone-first. */

:root {
  --bg: #faf7f2;
  --card: #ffffff;
  --ink: #241f1c;
  --muted: #7c736c;
  --line: #eae3da;
  --accent: #d96b3f;
  --accent-ink: #ffffff;
  --accent-soft: #fbe9e0;
  --teal: #2a9d8f;
  --yes: #1f9d55;
  --yes-soft: #e3f5e9;
  --maybe: #b7871a;
  --maybe-soft: #fdf3d7;
  --no: #d64545;
  --no-soft: #fde7e7;
  --shadow: 0 1px 2px rgba(36, 31, 28, 0.05), 0 6px 20px -8px rgba(36, 31, 28, 0.12);
  --radius: 14px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #17161a;
    --card: #211f25;
    --ink: #f0ece6;
    --muted: #a29a92;
    --line: #322f37;
    --accent: #e07a4e;
    --accent-ink: #1c130e;
    --accent-soft: #3a2a22;
    --yes: #4ade80;
    --yes-soft: #16321f;
    --maybe: #facc15;
    --maybe-soft: #34300f;
    --no: #f87171;
    --no-soft: #3a1d1d;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 8px 24px -10px rgba(0, 0, 0, 0.6);
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.5 system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  padding-bottom: env(safe-area-inset-bottom);
}
#app { max-width: 720px; margin: 0 auto; padding: 0 16px 96px; }

h1, h2, h3 { line-height: 1.2; }
h2 { font-size: 1.05rem; margin: 26px 0 10px; display: flex; align-items: center; gap: 8px; }
h2 .count { color: var(--muted); font-weight: 500; }
a { color: var(--accent); }
p { margin: 8px 0; }

/* ---------- header ---------- */
header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 0 4px; gap: 8px;
}
.brand { font-size: 1.35rem; font-weight: 800; letter-spacing: -0.02em; display: flex; gap: 8px; align-items: center; cursor: pointer; }
.me-menu { position: relative; }
.me-menu summary {
  list-style: none; cursor: pointer; padding: 7px 12px; border-radius: 999px;
  background: var(--card); border: 1px solid var(--line); font-weight: 600; font-size: 0.9rem;
  white-space: nowrap;
}
.me-menu summary::-webkit-details-marker { display: none; }
.me-menu[open] summary { background: var(--accent-soft); }
.me-menu .menu {
  position: absolute; right: 0; top: calc(100% + 6px); z-index: 30; min-width: 170px;
  background: var(--card); border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow);
  padding: 6px; display: flex; flex-direction: column;
}
.me-menu .menu button { text-align: left; background: none; border: 0; padding: 10px 12px; border-radius: 8px; color: var(--ink); font-size: 0.95rem; cursor: pointer; }
.me-menu .menu button:hover { background: var(--accent-soft); }

nav.tabs { display: flex; gap: 6px; margin: 10px 0 4px; overflow-x: auto; scrollbar-width: none; }
nav.tabs::-webkit-scrollbar { display: none; }
nav.tabs a {
  text-decoration: none; color: var(--muted); font-weight: 700; font-size: 0.95rem;
  padding: 8px 14px; border-radius: 999px; white-space: nowrap;
}
nav.tabs a.active { background: var(--ink); color: var(--bg); }

/* ---------- cards & lists ---------- */
.card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 16px; box-shadow: var(--shadow); margin: 10px 0;
}
.row-card { cursor: pointer; transition: transform 0.06s ease; }
.row-card:active { transform: scale(0.99); }
.card .title { font-weight: 700; font-size: 1.02rem; display: flex; gap: 8px; align-items: baseline; }
.card .title .emoji { font-size: 1.2rem; }
.meta { color: var(--muted); font-size: 0.86rem; margin-top: 3px; }
.empty { color: var(--muted); text-align: center; padding: 26px 12px; font-size: 0.95rem; }

.badge {
  display: inline-block; font-size: 0.72rem; font-weight: 800; letter-spacing: 0.03em;
  padding: 3px 9px; border-radius: 999px; vertical-align: 2px;
}
.badge.vote { background: var(--accent); color: var(--accent-ink); }
.badge.scheduled { background: var(--yes-soft); color: var(--yes); }
.badge.cancelled { background: var(--no-soft); color: var(--no); }
.badge.pending { background: var(--maybe-soft); color: var(--maybe); }
.badge.leader { background: var(--maybe-soft); color: var(--maybe); }
.badge.admin { background: var(--accent-soft); color: var(--accent); }

.badge.f-aa, .badge.f-sports { background: #dbeafe; color: #1d4ed8; }
.badge.f-na, .badge.f-outdoors { background: #dcfce7; color: #15803d; }
.badge.f-recovery-dharma, .badge.f-music { background: #f3e8ff; color: #7e22ce; }
.badge.f-smart, .badge.f-food { background: #ffedd5; color: #c2410c; }
.badge.f-games { background: #fce7f3; color: #be185d; }
.badge.f-other { background: var(--line); color: var(--muted); }
@media (prefers-color-scheme: dark) {
  .badge.f-aa, .badge.f-sports { background: #1e3a5f; color: #93c5fd; }
  .badge.f-na, .badge.f-outdoors { background: #14532d; color: #86efac; }
  .badge.f-recovery-dharma, .badge.f-music { background: #3b0764; color: #d8b4fe; }
  .badge.f-smart, .badge.f-food { background: #431407; color: #fdba74; }
  .badge.f-games { background: #500724; color: #f9a8d4; }
}

/* ---------- buttons & forms ---------- */
button, .btn {
  font: inherit; cursor: pointer; border-radius: 11px; border: 1px solid var(--line);
  background: var(--card); color: var(--ink); padding: 10px 16px; font-weight: 700;
  text-decoration: none; display: inline-flex; align-items: center; gap: 7px; justify-content: center;
}
button:disabled { opacity: 0.55; cursor: wait; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn-danger { color: var(--no); border-color: var(--no-soft); background: var(--no-soft); }
.btn-ghost { background: none; border-color: transparent; color: var(--muted); }
.btn-small { padding: 6px 11px; font-size: 0.85rem; border-radius: 9px; }
.btn-block { width: 100%; }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; margin: 12px 0; }

.fab {
  position: fixed; right: 18px; bottom: calc(18px + env(safe-area-inset-bottom)); z-index: 20;
  background: var(--accent); color: var(--accent-ink); border: 0; border-radius: 999px;
  padding: 14px 20px; font-size: 1rem; font-weight: 800; box-shadow: 0 8px 24px -6px rgba(217, 107, 63, 0.55);
}

label { display: block; font-weight: 700; font-size: 0.88rem; margin: 14px 0 5px; }
label .hint { font-weight: 400; color: var(--muted); }
input, select, textarea {
  font: inherit; color: var(--ink); background: var(--bg); width: 100%;
  border: 1px solid var(--line); border-radius: 11px; padding: 11px 12px;
}
input:focus-visible, select:focus-visible, textarea:focus-visible, button:focus-visible {
  outline: 2px solid var(--accent); outline-offset: 1px;
}
textarea { min-height: 84px; resize: vertical; }
.field-row { display: flex; gap: 8px; align-items: center; }
.field-row > * { flex: 1; }
.field-row > .shrink { flex: 0 0 auto; width: auto; }

/* ---------- poll options ---------- */
.option { border: 1px solid var(--line); border-radius: 12px; padding: 12px; margin: 8px 0; background: var(--bg); }
.option.leader { border-color: var(--maybe); }
.option .opt-head { display: flex; justify-content: space-between; gap: 8px; align-items: baseline; flex-wrap: wrap; }
.option .opt-when { font-weight: 800; }
.option .names { color: var(--muted); font-size: 0.82rem; margin-top: 6px; }
.seg { display: flex; gap: 6px; margin-top: 10px; }
.seg button { flex: 1; padding: 9px 4px; font-size: 0.88rem; border-radius: 10px; background: var(--card); }
.seg button.on-yes { background: var(--yes-soft); border-color: var(--yes); color: var(--yes); }
.seg button.on-maybe { background: var(--maybe-soft); border-color: var(--maybe); color: var(--maybe); }
.seg button.on-no { background: var(--no-soft); border-color: var(--no); color: var(--no); }
.opt-admin { display: flex; gap: 8px; margin-top: 10px; }

.hero { text-align: center; padding: 22px 16px; }
.hero .big { font-size: 1.5rem; font-weight: 800; letter-spacing: -0.02em; }
.hero .sub { color: var(--muted); margin-top: 4px; }

/* ---------- ideas ---------- */
.idea-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; margin-top: 12px; }
.idea {
  position: relative; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 14px 12px; cursor: pointer; box-shadow: var(--shadow);
}
.idea .emoji { font-size: 1.7rem; }
.idea .name { font-weight: 800; margin-top: 6px; font-size: 0.95rem; }
.idea .desc { color: var(--muted); font-size: 0.8rem; margin-top: 3px; }
.idea .x { position: absolute; top: 6px; right: 6px; border: 0; background: none; color: var(--muted); padding: 4px 8px; font-size: 0.9rem; }

/* ---------- comments ---------- */
.comment { padding: 10px 0; border-top: 1px solid var(--line); }
.comment:first-of-type { border-top: 0; }
.comment .who { font-weight: 700; font-size: 0.88rem; }
.comment .when { color: var(--muted); font-weight: 400; font-size: 0.8rem; margin-left: 6px; }
.comment .body { margin-top: 2px; white-space: pre-wrap; overflow-wrap: anywhere; }

/* ---------- crew / admin ---------- */
.member-row { display: flex; align-items: center; gap: 10px; padding: 10px 0; border-top: 1px solid var(--line); flex-wrap: wrap; }
.member-row:first-of-type { border-top: 0; }
.member-row .who { font-weight: 700; flex: 1; min-width: 120px; }
.member-row .who .meta { font-weight: 400; }
.code { font-family: ui-monospace, 'Cascadia Mono', Consolas, monospace; font-weight: 700; letter-spacing: 0.06em; }
.fresh-code { text-align: center; padding: 14px; border: 2px dashed var(--accent); border-radius: 12px; margin: 12px 0; }
.fresh-code .code { font-size: 1.4rem; }

details.fold { margin: 18px 0; }
details.fold summary { cursor: pointer; color: var(--muted); font-weight: 700; font-size: 0.92rem; padding: 6px 0; }

/* ---------- login ---------- */
.login-hero { text-align: center; padding: 56px 0 18px; }
.login-hero .logo { font-size: 3.2rem; }
.login-hero h1 { margin: 8px 0 2px; letter-spacing: -0.03em; }
.login-hero .tag { color: var(--muted); }
.mode-switch { display: flex; gap: 6px; background: var(--bg); border-radius: 999px; padding: 4px; margin-bottom: 6px; }
.mode-switch button { flex: 1; border: 0; background: none; padding: 9px; border-radius: 999px; font-weight: 700; color: var(--muted); }
.mode-switch button.active { background: var(--card); color: var(--ink); box-shadow: var(--shadow); }

/* ---------- toast ---------- */
#toast {
  position: fixed; left: 50%; bottom: calc(26px + env(safe-area-inset-bottom)); transform: translateX(-50%) translateY(20px);
  background: var(--ink); color: var(--bg); padding: 11px 18px; border-radius: 999px;
  font-weight: 600; font-size: 0.92rem; opacity: 0; pointer-events: none; transition: all 0.25s ease;
  max-width: min(92vw, 480px); text-align: center; z-index: 100;
}
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
#toast.error { background: var(--no); color: #fff; }

.notice { background: var(--accent-soft); border-radius: 12px; padding: 12px 14px; font-size: 0.92rem; margin: 10px 0; }
.muted { color: var(--muted); }
.small { font-size: 0.86rem; }
.spacer { height: 8px; }
