:root {
  --bg: #f6f3ec;
  --ink: #26302a;
  --ink-soft: #5b6359;
  --line: #d9d2c1;
  --surface: #fffdf8;
  --green: #33513a;
  --green-dark: #23392a;
  --ochre: #b8621b;
  --ochre-soft: #f0dcc6;
  --danger: #a3402f;
  --radius: 3px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: "Work Sans", system-ui, sans-serif;
  line-height: 1.5;
}

h1, h2, h3, .brand {
  font-family: "Fraunces", Georgia, serif;
  font-weight: 600;
  color: var(--green-dark);
  margin: 0;
}

button {
  font-family: inherit;
  cursor: pointer;
}

a { color: var(--green-dark); }

/* Topbar */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 24px;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
}

.brand {
  font-size: 20px;
  letter-spacing: 0.2px;
}
.brand span { color: var(--ochre); }

.tabs {
  display: flex;
  gap: 4px;
}

.tab {
  background: none;
  border: none;
  padding: 8px 14px;
  font-size: 14px;
  color: var(--ink-soft);
  border-bottom: 2px solid transparent;
}

.tab.active {
  color: var(--green-dark);
  border-bottom-color: var(--ochre);
  font-weight: 500;
}

.mobile-tabs {
  display: none;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--surface);
  border-top: 1px solid var(--line);
  justify-content: space-around;
  padding: 6px 0;
  z-index: 20;
}

.account {
  font-size: 14px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.account button {
  background: none;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 6px 12px;
  font-size: 13px;
  color: var(--ink);
}

/* Layout */
main#app {
  max-width: 720px;
  margin: 0 auto;
  padding: 28px 20px 90px;
}

/* Forms (login/register) */
.auth-card {
  max-width: 380px;
  margin: 60px auto;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 32px;
}

.auth-card h1 { margin-bottom: 6px; font-size: 26px; }
.auth-card p.sub { color: var(--ink-soft); margin: 0 0 22px; font-size: 14px; }

.field { margin-bottom: 14px; }
.field label {
  display: block;
  font-size: 13px;
  color: var(--ink-soft);
  margin-bottom: 4px;
}
.field input, .field textarea, .field select {
  width: 100%;
  padding: 9px 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  font-family: inherit;
  font-size: 14px;
  background: #fff;
  color: var(--ink);
}
.field textarea { resize: vertical; min-height: 70px; }

.btn {
  display: inline-block;
  background: var(--green);
  color: #fff;
  border: none;
  border-radius: var(--radius);
  padding: 10px 18px;
  font-size: 14px;
  font-weight: 500;
}
.btn:hover { background: var(--green-dark); }
.btn.secondary {
  background: none;
  border: 1px solid var(--line);
  color: var(--ink);
}
.btn.block { width: 100%; }

.switch-mode {
  text-align: center;
  margin-top: 16px;
  font-size: 13px;
  color: var(--ink-soft);
}
.switch-mode a { cursor: pointer; text-decoration: underline; }

.error-msg {
  background: #fbeae6;
  color: var(--danger);
  border: 1px solid #e6bfb4;
  border-radius: var(--radius);
  padding: 8px 12px;
  font-size: 13px;
  margin-bottom: 14px;
}

/* Section headers */
.section-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 16px;
}
.section-head h2 { font-size: 22px; }

/* Category filter */
.cat-filter { display: flex; gap: 8px; margin-bottom: 20px; flex-wrap: wrap; }
.cat-chip {
  border: 1px solid var(--line);
  background: var(--surface);
  border-radius: 20px;
  padding: 5px 13px;
  font-size: 13px;
  color: var(--ink-soft);
}
.cat-chip.active { background: var(--ochre-soft); border-color: var(--ochre); color: var(--ochre); }

/* Thread list */
.thread-list { border-top: 1px solid var(--line); }
.thread-row {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  padding: 16px 4px;
  border-bottom: 1px solid var(--line);
}
.thread-row .cat-tag {
  font-size: 11px;
  color: var(--ochre);
  text-transform: uppercase;
  letter-spacing: 0.4px;
  margin-bottom: 4px;
  display: block;
}
.thread-row h3 { font-size: 16px; font-weight: 500; font-family: inherit; color: var(--ink); }
.thread-row .meta { font-size: 12px; color: var(--ink-soft); margin-top: 4px; }
.thread-row .replies { font-size: 13px; color: var(--ink-soft); white-space: nowrap; align-self: center; }

/* Thread detail / posts */
.post {
  border-bottom: 1px solid var(--line);
  padding: 14px 4px;
}
.post .author { font-weight: 500; font-size: 14px; }
.post .when { font-size: 12px; color: var(--ink-soft); margin-left: 8px; }
.post .body { margin-top: 6px; white-space: pre-wrap; font-size: 15px; }

.back-link { display: inline-block; margin-bottom: 16px; font-size: 13px; color: var(--ink-soft); }

/* Polls */
.poll-card {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  padding: 18px;
  margin-bottom: 16px;
}
.poll-card h3 { font-size: 16px; margin-bottom: 12px; }
.poll-option {
  display: flex;
  align-items: center;
  justify-content: space-between;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 8px 12px;
  margin-bottom: 8px;
  font-size: 14px;
  cursor: pointer;
  position: relative;
  overflow: hidden;
}
.poll-option .fill {
  position: absolute;
  left: 0; top: 0; bottom: 0;
  background: var(--ochre-soft);
  z-index: 0;
}
.poll-option span { position: relative; z-index: 1; }
.poll-option.voted { border-color: var(--ochre); }

/* Directory */
.resident-row {
  display: flex;
  justify-content: space-between;
  padding: 12px 4px;
  border-bottom: 1px solid var(--line);
  font-size: 14px;
}
.resident-row .apt { color: var(--ink-soft); font-size: 13px; }

/* Documents */
.doc-row { padding: 14px 4px; border-bottom: 1px solid var(--line); }
.doc-row h3 { font-size: 15px; }
.doc-row a { font-size: 13px; }
.doc-row p { font-size: 13px; color: var(--ink-soft); margin: 4px 0; }

/* Floating add button */
.fab {
  position: fixed;
  bottom: 76px;
  right: 20px;
  background: var(--green);
  color: #fff;
  border: none;
  border-radius: 50%;
  width: 52px;
  height: 52px;
  font-size: 26px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.25);
  z-index: 15;
}

.modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(38,48,42,0.4);
  display: flex; align-items: flex-end;
  justify-content: center;
  z-index: 30;
}
.modal {
  background: var(--surface);
  width: 100%;
  max-width: 480px;
  border-radius: 12px 12px 0 0;
  padding: 24px;
  max-height: 85vh;
  overflow-y: auto;
}
@media (min-width: 640px) {
  .modal-backdrop { align-items: center; }
  .modal { border-radius: var(--radius); }
}

.empty-state {
  text-align: center;
  color: var(--ink-soft);
  padding: 40px 10px;
  font-size: 14px;
}

/* Responsive */
@media (max-width: 720px) {
  .topbar .tabs.desktop-only, #tabs { display: none; }
  .mobile-tabs { display: flex; }
  main#app { padding-bottom: 100px; }
}
