/* FUB Hub. Forge's layout in Hammock Bay colors: deep green #002B10, green #006325, mint #BFE1CC (brand guidelines,
   Sept 2024). Colors are tokens; dark mode redefines them. Headings use Cormorant Garamond when it's installed. */
:root {
  --bg: #F3F5F2;
  --surface: #FFFFFF;
  --surface-2: #F6F8F6;
  --ink: #1B2520;
  --muted: #58665D;
  --line: #DFE5E0;
  --brand: #006325;
  --brand-hover: #00501E;
  --brand-deep: #002B10;
  --on-brand: #FFFFFF;
  --tint: #E6F2EA;
  --mint: #BFE1CC;
  --bar-track: #E6ECE7;
  --ok: #0E7A4D;
  --danger: #B42318;
  --warn-bg: #FFF7E6;
  --warn-ink: #8A4B00;
  --focus: #2F6FD6;
  --shadow: 0 1px 2px rgba(16, 24, 20, .06), 0 1px 3px rgba(16, 24, 20, .08);
  --radius: 10px;
  --serif: "Cormorant Garamond", Georgia, "Times New Roman", serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0C120E;
    --surface: #131B16;
    --surface-2: #19231D;
    --ink: #E3ECE6;
    --muted: #9AABA0;
    --line: #27342C;
    --brand: #6CC08E;
    --brand-hover: #88CEA4;
    --brand-deep: #BFE1CC;
    --on-brand: #07130C;
    --tint: #18291F;
    --mint: #BFE1CC;
    --bar-track: #223028;
    --ok: #4CC38A;
    --danger: #F97066;
    --warn-bg: #2E2410;
    --warn-ink: #F5C46B;
    --focus: #8DB4F5;
    --shadow: none;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
/* `hidden` must win over display rules below (.count, phone-sized .nav a), or admin-only links show to everyone. */
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.5 "Segoe UI", system-ui, -apple-system, Roboto, Helvetica, Arial, sans-serif;
  overflow-wrap: break-word;
  -webkit-tap-highlight-color: transparent;
}
a { color: var(--brand); }
h1, h2, h3 { line-height: 1.25; margin: 0; }
h1 { font-size: 30px; font-family: var(--serif); font-weight: 600; letter-spacing: .2px; }
h2 { font-size: 18px; }
h3 { font-size: 16px; }
p { margin: 0 0 12px; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- Header ---------- */
.topbar { background: var(--surface); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 10; }
.topbar-inner { max-width: 1100px; margin: 0 auto; padding: 0 16px; display: flex; align-items: center; gap: 18px; min-height: 60px; }
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--ink); flex: none; }
.brand img { width: 34px; height: 34px; }
.brand b { font-family: var(--serif); font-size: 22px; font-weight: 600; letter-spacing: .3px; }
.nav { display: flex; gap: 2px; overflow-x: auto; scrollbar-width: none; flex: 1; }
.nav::-webkit-scrollbar { display: none; }
.nav a { padding: 8px 12px; border-radius: 8px; color: var(--muted); text-decoration: none; font-weight: 600; white-space: nowrap; }
.nav a:hover { background: var(--surface-2); color: var(--ink); }
.nav a[aria-current="page"] { color: var(--brand); background: var(--tint); }
.who { display: flex; align-items: center; gap: 10px; flex: none; font-size: 13px; color: var(--muted); }
.who .name { max-width: 180px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

main { max-width: 1100px; margin: 0 auto; padding: 24px 16px 64px; }

/* ---------- Buttons & inputs ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  border: 1px solid var(--line); background: var(--surface); color: var(--ink);
  padding: 8px 14px; border-radius: 8px; font: inherit; font-weight: 600; cursor: pointer; text-decoration: none; white-space: nowrap;
}
.btn:hover { background: var(--surface-2); }
.btn:disabled { opacity: .6; cursor: default; }
.btn.primary { background: var(--brand); border-color: var(--brand); color: var(--on-brand); }
.btn.primary:hover { background: var(--brand-hover); border-color: var(--brand-hover); }
.btn.ghost { border-color: transparent; background: transparent; color: var(--muted); }
.btn.ghost:hover { color: var(--ink); background: var(--surface-2); }
.btn.danger { color: var(--danger); }
.btn.sm { padding: 5px 10px; font-size: 13px; }
.btn.add { border-style: dashed; color: var(--brand); }

label { font-weight: 600; font-size: 14px; display: block; margin-bottom: 6px; }
.label-like { font-weight: 600; font-size: 14px; display: block; margin-bottom: 6px; }
.hint { font-weight: 400; color: var(--muted); font-size: 13px; }
.hint-line { display: block; font-weight: 400; color: var(--muted); font-size: 13px; margin-top: 2px; }
/* 16px keeps iPhones from zooming in when a field is tapped. */
input[type="text"], input[type="email"], input[type="tel"], input[type="url"], input[type="date"], input[type="search"], select, textarea {
  width: 100%; font: inherit; font-size: 16px; color: var(--ink); background: var(--surface);
  border: 1px solid var(--line); border-radius: 8px; padding: 9px 11px;
}
textarea { resize: vertical; min-height: 88px; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--focus); outline-offset: -1px; border-color: transparent; }
.check { display: flex; gap: 9px; align-items: flex-start; font-weight: 400; }
.check input { margin-top: 4px; }

/* ---------- Layout pieces ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.pad { padding: 20px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 20px; }
.page-head p { margin: 4px 0 0; color: var(--muted); max-width: 660px; }
.grid-2 { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); gap: 20px; }
.stack > * + * { margin-top: 20px; }
.section-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; margin-bottom: 14px; }
.empty { text-align: center; padding: 40px 20px; color: var(--muted); }
.notice { background: var(--warn-bg); color: var(--warn-ink); border-radius: 8px; padding: 10px 14px; font-size: 14px; }
.info { background: var(--tint); color: var(--ink); border-radius: 8px; padding: 10px 14px; font-size: 14px; }
.error-text { color: var(--danger); font-size: 14px; }
.ok-text { color: var(--ok); font-size: 14px; }
.meta { display: flex; flex-wrap: wrap; gap: 6px 12px; font-size: 13px; color: var(--muted); align-items: center; }
.meta .sep::before { content: "·"; margin-right: 12px; }
.tag { display: inline-block; font-size: 12px; font-weight: 600; color: var(--brand); background: var(--tint); border-radius: 999px; padding: 2px 9px; }
.status { font-size: 12px; font-weight: 700; border-radius: 999px; padding: 1px 9px; border: 1px solid var(--line); color: var(--muted); white-space: nowrap; }
.status.submitted, .status.answered { color: var(--ok); border-color: var(--ok); }
.status.draft, .status.open { color: var(--warn-ink); border-color: currentColor; }
.count { display: inline-block; min-width: 18px; padding: 0 6px; border-radius: 999px; background: var(--brand); color: var(--on-brand); font-size: 11px; font-weight: 700; line-height: 18px; text-align: center; }
.back { text-decoration: none; font-weight: 600; font-size: 14px; }

/* ---------- Questionnaire ---------- */
.q-wrap { max-width: 820px; margin: 0 auto; }
.q-hero { padding: 24px 26px; margin-bottom: 20px; border-top: 4px solid var(--brand); }
.q-hero h1 { margin-bottom: 8px; }
.q-hero p { color: var(--ink); }
.progress { display: flex; align-items: center; gap: 12px; margin-top: 14px; flex-wrap: wrap; }
.progress .track { flex: 1 1 200px; height: 10px; background: var(--bar-track); border-radius: 999px; overflow: hidden; }
.progress .fill { height: 100%; background: var(--brand); border-radius: 999px; transition: width .3s; }
.progress .label { font-size: 13px; color: var(--muted); font-variant-numeric: tabular-nums; }
.q-section { padding: 22px 26px; margin-bottom: 18px; }
.q-section > header { display: flex; gap: 12px; align-items: baseline; margin-bottom: 6px; }
.q-section > header .num { flex: none; width: 28px; height: 28px; border-radius: 50%; background: var(--tint); color: var(--brand); font-weight: 700; font-size: 14px; display: grid; place-items: center; transform: translateY(2px); }
.q-section > header h2 { font-family: var(--serif); font-size: 23px; font-weight: 600; }
.q-section .intro { color: var(--muted); margin: 0 0 16px 40px; }
.q-section .fields { margin-left: 40px; }
.field { margin-bottom: 18px; }
.field:last-child { margin-bottom: 0; }
.opts { display: flex; flex-wrap: wrap; gap: 8px; }
.opt { margin: 0; display: flex; font-weight: 400; }
.opt input { position: absolute; opacity: 0; pointer-events: none; }
.opt span { display: flex; align-items: center; gap: 7px; padding: 7px 13px; border: 1px solid var(--line); border-radius: 999px; cursor: pointer; background: var(--surface); font-size: 14px; }
.opt span::before { content: ""; width: 14px; height: 14px; border: 1.5px solid var(--muted); border-radius: 50%; flex: none; }
.opt input[type="checkbox"] + span::before { border-radius: 4px; }
.opt input:checked + span { background: var(--tint); border-color: var(--brand); color: var(--ink); font-weight: 600; }
.opt input:checked + span::before { background: var(--brand); border-color: var(--brand); box-shadow: inset 0 0 0 2.5px var(--surface); }
.opt input:focus-visible + span { outline: 2px solid var(--focus); outline-offset: 2px; }

/* Editable tables: a real table on wide screens, a card per row on phones. */
.edit-table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 14px; }
.edit-table th { text-align: left; font-size: 12px; font-weight: 700; color: var(--muted); padding: 0 6px 6px; white-space: normal; vertical-align: bottom; }
.edit-table td { padding: 3px; vertical-align: top; }
.edit-table td input, .edit-table td select { padding: 7px 8px; font-size: 15px; }
.edit-table th[scope="row"] { font-size: 14px; color: var(--ink); font-weight: 600; padding: 10px 8px 0 0; vertical-align: top; width: 34%; }
.edit-table .rm { width: 36px; text-align: center; }
.edit-table .rm button { padding: 6px 8px; }
.table-actions { margin-top: 8px; }

.save-bar { position: sticky; bottom: 0; z-index: 5; margin-top: 8px; padding: 12px 0 16px; background: linear-gradient(transparent, var(--bg) 30%); }
.save-bar .inner { display: flex; gap: 12px; align-items: center; justify-content: space-between; flex-wrap: wrap; padding: 12px 16px; }
.save-state { font-size: 13px; color: var(--muted); }
.save-state.error { color: var(--danger); }

/* ---------- Guides ---------- */
.guide-section { padding: 18px 22px; margin-bottom: 16px; }
.guide-section h2 { font-family: var(--serif); font-size: 22px; font-weight: 600; margin-bottom: 6px; }
.guide-list { list-style: none; margin: 0; padding: 0; }
.guide-list li { padding: 12px 0; border-top: 1px solid var(--line); display: flex; gap: 12px; justify-content: space-between; align-items: flex-start; }
.guide-list li:first-child { border-top: 0; }
.guide-list .t { font-weight: 600; font-size: 15px; }
.guide-list a.t { text-decoration: none; }
.guide-list a.t:hover { text-decoration: underline; }
.guide-list .t .ext { font-size: 12px; color: var(--muted); font-weight: 400; margin-left: 4px; }
.guide-list .note { color: var(--muted); font-size: 14px; margin-top: 2px; white-space: pre-wrap; }
.guide-list .row-actions { flex: none; }
.guide-form .row-2 { margin-bottom: 0; }

/* ---------- Questions ---------- */
.form { max-width: 760px; margin: 0 auto; }
.form .card { padding: 22px 24px; }
.row-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.form-foot { display: flex; gap: 10px; align-items: center; justify-content: flex-end; flex-wrap: wrap; }
.q-list { margin-top: 28px; display: grid; gap: 12px; }
.q-list h2 { font-size: 16px; }
.q-item { padding: 14px 16px; display: grid; gap: 8px; }
.q-msg { margin: 0; white-space: pre-wrap; }
.q-answer { border-left: 4px solid var(--brand); background: var(--tint); border-radius: 0 8px 8px 0; padding: 10px 14px; }
.q-answer p { margin: 0; white-space: pre-wrap; }
.q-answer .by { font-size: 12px; color: var(--muted); margin-bottom: 4px; font-weight: 600; }
.q-admin { display: grid; gap: 8px; }
.q-admin .controls { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; justify-content: flex-end; }
.q-admin select { width: auto; min-width: 150px; }
.pick { display: flex; gap: 6px; flex-wrap: wrap; }
.pick label { flex: 1; margin: 0; display: flex; min-width: 130px; }
.pick input { position: absolute; opacity: 0; pointer-events: none; }
.pick span { flex: 1; display: flex; align-items: center; justify-content: center; text-align: center; padding: 8px 6px; border: 1px solid var(--line); border-radius: 8px; font-weight: 600; cursor: pointer; background: var(--surface); }
.pick input:checked + span { background: var(--brand); color: var(--on-brand); border-color: var(--brand); }
.pick input:focus-visible + span { outline: 2px solid var(--focus); outline-offset: 2px; }

/* ---------- Responses ---------- */
.exports { display: flex; gap: 8px; flex-wrap: wrap; }
.mini-bar { display: inline-block; width: 90px; height: 8px; background: var(--bar-track); border-radius: 999px; overflow: hidden; vertical-align: middle; margin-right: 8px; }
.mini-bar i { display: block; height: 100%; background: var(--brand); }
tr.clickable { cursor: pointer; }
tr.clickable:hover td { background: var(--surface-2); }
.answers { max-width: 860px; }
.answers .card { padding: 22px 26px; margin-bottom: 16px; }
.answers h2 { font-family: var(--serif); font-size: 22px; font-weight: 600; margin-bottom: 10px; }
.qa { display: grid; grid-template-columns: minmax(180px, 34%) 1fr; gap: 4px 18px; padding: 9px 0; border-top: 1px solid var(--line); }
.qa:first-of-type { border-top: 0; }
.qa .q { color: var(--muted); font-size: 14px; }
.qa .a { white-space: pre-wrap; }
.qa .a.none { color: var(--muted); font-style: italic; }
.qa.wide { grid-template-columns: 1fr; }
.view-table { font-size: 13px; margin-top: 4px; }
.view-table td, .view-table th { padding: 6px 8px; white-space: normal; }

/* ---------- Admin tables ---------- */
.table-wrap { overflow-x: auto; position: relative; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { font-size: 12px; text-transform: uppercase; letter-spacing: .5px; color: var(--muted); font-weight: 700; white-space: nowrap; }
td { white-space: nowrap; }
td:first-child { white-space: normal; min-width: 140px; }
tr.inactive td { color: var(--muted); }
.role { font-size: 12px; font-weight: 700; border-radius: 999px; padding: 2px 8px; background: var(--tint); color: var(--brand); }
.row-actions { display: flex; gap: 4px; justify-content: flex-end; flex-wrap: wrap; }
.link-row td { white-space: normal; }
.link-box { display: flex; gap: 8px; margin-top: 8px; }
.link-box input { font-size: 12px; }

.toast { position: fixed; left: 50%; bottom: 22px; transform: translateX(-50%); background: var(--ink); color: var(--bg); padding: 10px 16px; border-radius: 8px; font-size: 14px; z-index: 50; box-shadow: 0 6px 20px rgba(0,0,0,.2); max-width: calc(100vw - 32px); }

/* ---------- Sign-in pages ---------- */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; }
.auth .card { width: 100%; max-width: 420px; padding: 30px 30px 32px; border-top: 4px solid var(--brand); }
.auth .logo { text-align: center; margin-bottom: 6px; }
.auth .logo img { width: 180px; height: auto; }
.auth .tagline { text-align: center; font-size: 12px; font-weight: 700; letter-spacing: 1.6px; text-transform: uppercase; color: var(--brand); margin-bottom: 22px; }
.auth h1 { font-size: 26px; margin-bottom: 6px; }
.auth p { color: var(--muted); }
.auth form { margin-top: 18px; }
.auth .btn { width: 100%; margin-top: 12px; padding: 11px 14px; }
.auth .msg { margin-top: 14px; }
.dev-link { word-break: break-all; font-size: 13px; margin-top: 10px; }

/* ---------- Small screens ---------- */
@media (max-width: 900px) {
  .topbar-inner { flex-wrap: wrap; gap: 4px 12px; padding-top: 8px; }
  .nav { order: 3; flex-basis: 100%; margin: 0 -6px; padding-bottom: 6px; }
  .who { margin-left: auto; }
  .grid-2 { grid-template-columns: 1fr; }
}
@media (max-width: 640px) {
  .topbar { position: static; }
  .nav { -webkit-mask-image: linear-gradient(90deg, #000 85%, transparent); mask-image: linear-gradient(90deg, #000 85%, transparent); padding-right: 24px; }
  .nav a { padding: 8px 10px; }
  .who .name { display: none; }
  main { padding-top: 18px; }
  h1 { font-size: 26px; }
  .row-2 { grid-template-columns: 1fr; }
  .card.pad, .q-hero, .q-section, .guide-section, .answers .card { padding: 18px 16px; }
  .q-section .intro, .q-section .fields { margin-left: 0; }
  .form .card { padding: 18px 16px; }
  .form-foot .btn { flex: 1 1 auto; }
  .save-bar { padding: 8px 0 10px; }
  .save-bar .inner { flex-wrap: nowrap; padding: 8px 10px; gap: 10px; }
  .save-bar .save-state { font-size: 12px; line-height: 1.3; }
  .save-bar .btn { flex: none; }
  .qa { grid-template-columns: 1fr; }
  .page-head .exports { width: 100%; }

  /* Editable tables: each row becomes a small card with its labels. */
  .edit-table thead { display: none; }
  .edit-table, .edit-table tbody, .edit-table tr, .edit-table td, .edit-table th[scope="row"] { display: block; width: 100%; }
  .edit-table tr { border: 1px solid var(--line); border-radius: 8px; padding: 10px; margin-bottom: 10px; background: var(--surface-2); }
  .edit-table td { padding: 3px 0; }
  .edit-table td[data-label]::before { content: attr(data-label); display: block; font-size: 12px; font-weight: 700; color: var(--muted); margin-bottom: 2px; }
  .edit-table th[scope="row"] { padding: 0 0 4px; }
  .edit-table .rm { width: auto; text-align: right; }

  /* People and responses: each person becomes a small card instead of a wide table row. */
  .people-table thead { display: none; }
  .people-table, .people-table tbody, .people-table tr, .people-table td { display: block; width: 100%; }
  .people-table tr { padding: 12px 16px; border-bottom: 1px solid var(--line); }
  .people-table tr:last-child { border-bottom: 0; }
  .people-table td { border: 0; padding: 2px 0; white-space: normal; display: flex; justify-content: space-between; gap: 12px; text-align: right; }
  .people-table td[data-label]::before { content: attr(data-label); color: var(--muted); font-size: 13px; text-align: left; }
  .people-table td:first-child { font-weight: 650; font-size: 16px; text-align: left; justify-content: flex-start; gap: 6px; align-items: baseline; }
  .people-table td.email { color: var(--muted); font-size: 14px; word-break: break-all; text-align: left; }
  .people-table td.actions { display: block; }
  .people-table .row-actions { justify-content: flex-start; margin-top: 8px; }
  .people-table .link-row td { display: block; text-align: left; }
  .people-table .link-box { flex-wrap: wrap; }
}
@media (max-width: 360px) {
  .brand b { display: none; }
}

/* Touch screens: every tap target at least ~40px tall. */
@media (max-width: 640px), (pointer: coarse) {
  .nav a { min-height: 44px; display: inline-flex; align-items: center; }
  .btn { min-height: 44px; }
  .btn.sm { min-height: 40px; padding: 8px 12px; font-size: 14px; }
  .opt span { min-height: 40px; padding: 8px 14px; }
  .check { padding: 6px 0; }
  .check input { width: 20px; height: 20px; margin-top: 1px; flex: none; }
  .pick span { padding: 11px 6px; }
  .back { display: inline-block; padding: 10px 0; }
  .link-box input { font-size: 16px; }
}

/* ---------- Print (one person's answers) ---------- */
@media print {
  :root { --ink: #000; --muted: #444; --brand: #006325; --bg: #fff; --surface: #fff; --surface-2: #fff; --line: #ccc; --tint: #fff; }
  body { background: #fff; font-size: 11px; }
  .topbar, .no-print, .toast, .save-bar { display: none !important; }
  main { padding: 0; max-width: none; }
  .card { box-shadow: none; border: 0; padding: 0 !important; margin-bottom: 14px; }
  .qa { padding: 4px 0; break-inside: avoid; }
  a { color: inherit; text-decoration: none; }
}
