:root {
  --bg: #f4f0e7;
  --canvas: #fffcf6;
  --surface: #ffffff;
  --ink: #1f2621;
  --muted: #68716b;
  --line: #ded6c8;
  --moss: #315643;
  --leaf: #587a59;
  --teal: #2f7f85;
  --coral: #c76a50;
  --amber: #cf8f35;
  --blue: #496c92;
  --shadow: 0 18px 44px rgba(40, 45, 38, 0.12);
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  font-family:
    Inter, "Noto Sans TC", "Microsoft JhengHei", system-ui, -apple-system,
    BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
input,
textarea,
select {
  font: inherit;
}

button,
a {
  -webkit-tap-highlight-color: transparent;
}

button {
  cursor: pointer;
}

.site-frame {
  min-height: 100vh;
}

.desktop-sidebar {
  display: none;
}

.desktop-panel {
  width: min(100%, 760px);
  margin: 0 auto;
  padding: 0 12px 92px;
  display: grid;
  gap: 12px;
}

.app-main {
  width: min(100%, 760px);
  margin: 0 auto;
  padding: 12px 12px 92px;
}

.app-topbar {
  position: sticky;
  top: 0;
  z-index: 5;
  min-height: 64px;
  margin: -12px -12px 12px;
  padding: 10px 12px;
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr) 42px;
  gap: 10px;
  align-items: center;
  background: rgba(244, 240, 231, 0.92);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid rgba(222, 214, 200, 0.72);
}

.app-topbar p,
.eyebrow,
.card-top small,
.event-row small,
.quiet-card span,
.brand small {
  margin: 0;
  color: var(--muted);
  font-size: 0.78rem;
  line-height: 1.35;
}

.app-topbar strong {
  display: block;
  margin-top: 2px;
  font-size: 1rem;
}

.icon-button {
  width: 42px;
  height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--moss);
  font-weight: 900;
}

.menu-button {
  color: var(--coral);
}

.town-hero {
  position: relative;
  min-height: 390px;
  overflow: hidden;
  border-radius: 8px;
  background: var(--moss);
  box-shadow: var(--shadow);
}

.town-hero img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.town-hero::after {
  content: "";
  position: absolute;
  inset: 0;
  background:
    linear-gradient(0deg, rgba(18, 24, 20, 0.86), rgba(18, 24, 20, 0.16) 58%),
    linear-gradient(90deg, rgba(18, 24, 20, 0.58), transparent 62%);
}

.hero-copy {
  position: absolute;
  inset: auto 0 0;
  z-index: 1;
  padding: 24px;
  color: #fffdf7;
}

.hero-copy .eyebrow {
  color: #ffd8a5;
  font-weight: 900;
}

.hero-copy h1 {
  margin: 8px 0 0;
  max-width: 620px;
  font-size: 2.45rem;
  line-height: 1.06;
  letter-spacing: 0;
}

.hero-metrics {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 18px;
}

.hero-metrics span {
  min-height: 38px;
  padding: 8px 10px;
  border: 1px solid rgba(255, 253, 247, 0.3);
  border-radius: 8px;
  background: rgba(255, 253, 247, 0.16);
  backdrop-filter: blur(8px);
  display: inline-flex;
  align-items: baseline;
  gap: 6px;
}

.hero-metrics strong {
  font-size: 1.18rem;
}

.quick-post,
.account-panel,
.admin-panel,
.home-alerts,
.notice-panel,
.section-block,
.panel,
.quiet-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--canvas);
}

.quick-post {
  margin-top: 12px;
  padding: 12px;
}

.account-panel {
  margin-top: 12px;
  padding: 14px;
}

.account-forms {
  display: grid;
  gap: 10px;
}

.account-form {
  display: grid;
  gap: 8px;
}

.account-form input {
  width: 100%;
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
  padding: 9px 11px;
}

.account-profile {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  align-items: center;
}

.account-profile span {
  font-weight: 900;
}

.home-alerts {
  margin-top: 12px;
  padding: 14px;
  border-color: rgba(207, 143, 53, 0.55);
  background: #fff8ed;
}

.home-alerts .section-title {
  align-items: center;
}

.home-alerts a {
  color: var(--moss);
  font-weight: 900;
  text-decoration: none;
}

.alert-strip {
  display: grid;
  gap: 8px;
}

.alert-card {
  min-height: 58px;
  padding: 10px 12px;
  border: 1px solid rgba(207, 143, 53, 0.42);
  border-radius: 8px;
  background: var(--surface);
  color: inherit;
  display: grid;
  gap: 4px;
  text-decoration: none;
}

.alert-card strong,
.alert-card span {
  display: block;
}

.alert-card strong {
  line-height: 1.35;
}

.alert-card span {
  color: #8a5a13;
  font-size: 0.82rem;
  font-weight: 900;
}

.admin-panel {
  margin-top: 12px;
  padding: 14px;
}

.notice-panel {
  margin-top: 12px;
  padding: 14px;
}

.priority-notices {
  border-color: rgba(207, 143, 53, 0.48);
  background: #fff8ed;
  box-shadow: 0 12px 34px rgba(138, 90, 19, 0.08);
}

.quick-post-head {
  display: flex;
  gap: 10px;
  align-items: center;
}

.avatar {
  flex: 0 0 auto;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  color: #fff;
  font-weight: 900;
}

.avatar.teal {
  background: var(--teal);
}

.open-composer {
  min-width: 0;
  width: 100%;
  min-height: 42px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--muted);
  text-align: left;
}

.composer {
  display: grid;
  gap: 10px;
  margin-top: 10px;
}

.composer textarea {
  width: 100%;
  padding: 12px;
  resize: vertical;
  border: 1px solid var(--line);
  border-radius: 8px;
  outline-color: var(--teal);
  background: var(--surface);
  color: var(--ink);
  line-height: 1.55;
}

.composer-bottom,
.section-title,
.card-top,
.card-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.topic-picker,
.card-actions,
.hero-metrics {
  overflow-x: auto;
  scrollbar-width: none;
}

.topic-picker {
  display: flex;
  gap: 6px;
  min-width: 0;
}

.topic-picker::-webkit-scrollbar,
.card-actions::-webkit-scrollbar,
.hero-metrics::-webkit-scrollbar {
  display: none;
}

.topic-picker button,
.primary-button,
.ghost-button,
.card-actions button,
.board-grid button {
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
  font-weight: 800;
}

.topic-picker button {
  flex: 0 0 auto;
  padding: 0 12px;
}

.topic-picker button.active {
  border-color: rgba(49, 86, 67, 0.55);
  background: #e8efe7;
  color: var(--moss);
}

.primary-button {
  flex: 0 0 auto;
  padding: 0 16px;
  border-color: var(--moss);
  background: var(--moss);
  color: #fffdf7;
}

.secondary-button {
  min-height: 38px;
  border: 1px solid var(--teal);
  border-radius: 8px;
  background: var(--teal);
  color: #fffdf7;
  font-weight: 800;
}

.admin-badge {
  min-height: 30px;
  padding: 6px 10px;
  border-radius: 8px;
  background: #eee7da;
  color: var(--moss);
  font-size: 0.82rem;
  font-weight: 900;
}

.admin-login,
.admin-form {
  display: grid;
  gap: 10px;
}

.admin-login {
  grid-template-columns: minmax(0, 1fr);
}

.admin-login label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 800;
}

.admin-login input,
.admin-form input,
.admin-form textarea,
.admin-form select {
  width: 100%;
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
  padding: 9px 11px;
}

.admin-form textarea {
  resize: vertical;
  line-height: 1.55;
}

.admin-status {
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 0.86rem;
  line-height: 1.5;
}

.admin-tools {
  display: grid;
  gap: 12px;
  margin-top: 12px;
}

.admin-tools h3 {
  margin: 0;
  font-size: 1rem;
}

.admin-lists {
  display: grid;
  gap: 12px;
}

.admin-list {
  display: grid;
  gap: 8px;
  margin-top: 8px;
}

.admin-row {
  min-height: 42px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  align-items: center;
}

.admin-row span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 800;
}

.admin-row button,
.admin-delete-post {
  min-height: 32px;
  border: 1px solid rgba(199, 106, 80, 0.45);
  border-radius: 8px;
  background: #fff0ea;
  color: #9d4d37;
  font-weight: 900;
}

.admin-delete-post {
  margin-top: 12px;
  padding: 0 12px;
}

.wide {
  width: 100%;
}

.section-block,
.panel {
  margin-top: 12px;
  padding: 14px;
}

.section-title {
  align-items: flex-end;
  margin-bottom: 12px;
}

.section-title.compact {
  margin-bottom: 10px;
}

.eyebrow {
  color: var(--coral);
  font-weight: 900;
}

.section-title h2,
.panel h2 {
  margin: 0;
  font-size: 1.18rem;
  letter-spacing: 0;
}

.section-title select {
  min-height: 38px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
}

.feed-search {
  margin-bottom: 12px;
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 800;
}

.feed-search input,
.service-form input {
  width: 100%;
  min-height: 40px;
  padding: 9px 11px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
}

.feed-list {
  display: grid;
  gap: 10px;
}

.discussion-card {
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.discussion-card.pinned {
  border-color: rgba(199, 106, 80, 0.45);
  background: #fff8f2;
}

.tag {
  min-height: 28px;
  padding: 5px 9px;
  border-radius: 8px;
  background: #e8efe7;
  color: var(--moss);
  font-size: 0.82rem;
  font-weight: 900;
}

.tag.amber {
  background: #fbefd9;
  color: #8a5a13;
}

.tag.teal {
  background: #e5f1f1;
  color: #1f676d;
}

.tag.coral {
  background: #fbe7df;
  color: #9d4d37;
}

.discussion-card h3 {
  margin: 12px 0 8px;
  font-size: 1.06rem;
  line-height: 1.35;
  letter-spacing: 0;
}

.discussion-card p,
.rules p {
  margin: 0;
  color: #3f4741;
  line-height: 1.62;
}

.card-actions {
  justify-content: flex-start;
  margin-top: 12px;
}

.card-actions button {
  flex: 0 0 auto;
  min-height: 34px;
  padding: 0 12px;
  color: var(--moss);
}

.comments {
  display: none;
  gap: 8px;
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
}

.discussion-card.comments-open .comments {
  display: grid;
}

.comment-row {
  display: grid;
  gap: 3px;
  padding: 8px 10px;
  border-radius: 8px;
  background: #f4f0e7;
}

.comment-row strong {
  font-size: 0.82rem;
  color: var(--moss);
}

.comment-row span {
  color: #414943;
  line-height: 1.45;
}

.comment-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
}

.comment-form input {
  min-width: 0;
  min-height: 36px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 10px;
}

.comment-form button,
.danger-button,
.service-actions button {
  min-height: 36px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--moss);
  font-weight: 900;
}

.danger-button {
  border-color: rgba(199, 106, 80, 0.45);
  background: #fff0ea;
  color: #9d4d37;
}

.admin-tool-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.service-form,
.service-list {
  display: grid;
  gap: 8px;
  margin-top: 10px;
}

.service-row {
  padding: 10px;
  border-radius: 8px;
  background: var(--surface);
  display: grid;
  gap: 8px;
}

.service-row strong,
.service-row small {
  display: block;
}

.service-row small {
  margin-top: 3px;
  color: var(--muted);
}

.status-pill {
  width: fit-content;
  padding: 5px 8px;
  border-radius: 8px;
  background: #e8efe7;
  color: var(--moss);
  font-size: 0.82rem;
  font-weight: 900;
}

.service-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.notice-list {
  display: grid;
  gap: 8px;
}

.notice-row {
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  display: grid;
  grid-template-columns: 76px minmax(0, 1fr);
  gap: 10px;
  align-items: start;
}

.notice-row > span {
  min-height: 34px;
  border-radius: 8px;
  background: #fbefd9;
  color: #8a5a13;
  display: grid;
  place-items: center;
  font-size: 0.82rem;
  font-weight: 900;
}

.notice-row strong,
.notice-row small {
  display: block;
}

.notice-row small {
  margin-top: 5px;
  color: var(--muted);
  line-height: 1.45;
}

.notice-row em {
  display: block;
  margin-top: 7px;
  color: var(--teal);
  font-size: 0.82rem;
  font-style: normal;
  font-weight: 900;
}

.bottom-nav {
  position: fixed;
  left: 10px;
  right: 10px;
  bottom: 10px;
  z-index: 10;
  height: 64px;
  padding: 6px;
  border: 1px solid rgba(222, 214, 200, 0.92);
  border-radius: 8px;
  background: rgba(255, 252, 246, 0.94);
  box-shadow: 0 14px 38px rgba(33, 39, 33, 0.18);
  backdrop-filter: blur(14px);
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 4px;
}

.bottom-nav a {
  min-width: 0;
  border-radius: 8px;
  color: var(--muted);
  display: grid;
  place-items: center;
  text-decoration: none;
  font-size: 0.86rem;
  font-weight: 900;
}

.bottom-nav a.active {
  background: #e8efe7;
  color: var(--moss);
}

.is-hidden {
  display: none;
}

@media (min-width: 980px) {
  body {
    overflow-y: scroll;
  }

  .site-frame {
    display: grid;
    grid-template-columns: 250px minmax(520px, 760px) minmax(300px, 360px);
    gap: 18px;
    align-items: start;
    padding: 18px;
  }

  .desktop-sidebar,
  .desktop-panel {
    position: sticky;
    top: 18px;
    display: grid;
    gap: 14px;
  }

  .desktop-sidebar {
    height: calc(100vh - 36px);
    align-content: start;
  }

  .app-main {
    width: 100%;
    padding: 0 0 24px;
  }

  .app-topbar {
    display: none;
  }

  .bottom-nav {
    display: none;
  }

  .brand {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    border-radius: 8px;
    color: inherit;
    text-decoration: none;
    background: var(--canvas);
    border: 1px solid var(--line);
  }

  .brand-mark {
    flex: 0 0 auto;
    width: 44px;
    height: 44px;
    border-radius: 8px;
    display: grid;
    place-items: center;
    background: var(--moss);
    color: #fffdf7;
    font-weight: 900;
  }

  .brand strong,
  .brand small {
    display: block;
  }

  .area-select {
    display: grid;
    gap: 8px;
    padding: 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--canvas);
    color: var(--muted);
    font-size: 0.82rem;
    font-weight: 800;
  }

  .area-select strong,
  .area-select small {
    display: block;
  }

  .area-select strong {
    min-height: 40px;
    padding: 10px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--surface);
    color: var(--ink);
  }

  .area-select small {
    color: var(--muted);
    line-height: 1.45;
  }

  .area-select select {
    min-height: 40px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--surface);
    color: var(--ink);
    padding: 0 10px;
  }

  .desktop-nav {
    display: grid;
    gap: 7px;
    padding: 8px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--canvas);
  }

  .desktop-nav a {
    min-height: 42px;
    padding: 11px 12px;
    border-radius: 8px;
    color: #414943;
    text-decoration: none;
    font-weight: 900;
  }

  .admin-login {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) auto;
    align-items: end;
  }

  .account-forms {
    grid-template-columns: 1fr 1fr;
  }

  .alert-strip {
    grid-template-columns: repeat(3, 1fr);
  }

  .admin-lists {
    grid-template-columns: 1fr 1fr;
  }

  .desktop-nav a:hover,
  .desktop-nav a.active {
    background: #e8efe7;
    color: var(--moss);
  }

  .quiet-card {
    padding: 14px;
    margin-top: auto;
  }

  .quiet-card strong {
    display: block;
    margin-bottom: 6px;
  }

  .town-hero {
    min-height: 420px;
  }

  .hero-copy h1 {
    font-size: 3.15rem;
  }

  .desktop-panel {
    padding-bottom: 24px;
  }

  .panel {
    margin-top: 0;
  }

  .board-grid {
    display: grid;
    gap: 8px;
  }

  .board-grid button {
    width: 100%;
    min-height: 70px;
    padding: 12px;
    text-align: left;
    display: grid;
    gap: 4px;
  }

  .board-grid button:hover {
    border-color: rgba(47, 127, 133, 0.48);
    background: #eef8f4;
  }

  .board-grid strong,
  .board-grid span,
  .event-row strong,
  .event-row small {
    display: block;
  }

.board-grid span,
.board-grid small {
    color: var(--muted);
    font-size: 0.84rem;
  }

  .board-grid small {
    color: var(--teal);
    font-weight: 900;
  }

  .event-list {
    display: grid;
    gap: 4px;
  }

  .event-row {
    display: grid;
    grid-template-columns: 52px minmax(0, 1fr) auto;
    gap: 10px;
    align-items: center;
    padding: 9px 0;
    border-top: 1px solid var(--line);
  }

  .event-row:first-child {
    border-top: 0;
  }

  .event-row time {
    min-height: 42px;
    border-radius: 8px;
    background: #f0eadc;
    color: var(--moss);
    display: grid;
    place-items: center;
    font-weight: 900;
  }

  .ghost-button {
    min-height: 34px;
    padding: 0 11px;
    color: var(--moss);
  }

  .ghost-button.active {
    border-color: rgba(199, 106, 80, 0.58);
    background: #fff0ea;
    color: #9d4d37;
  }

  .services {
    background: #fff8f2;
    border-color: rgba(199, 106, 80, 0.32);
  }

  .services ul {
    margin: 10px 0 0;
    padding: 0;
    list-style: none;
    display: grid;
    gap: 8px;
  }

  .services li {
    min-height: 34px;
    padding: 8px 10px;
    border-radius: 8px;
    background: var(--surface);
    color: #414943;
  }
}

@media (max-width: 520px) {
  .hero-copy {
    padding: 20px;
  }

  .hero-copy h1 {
    font-size: 2.15rem;
  }

  .hero-metrics span {
    flex: 1 0 calc(50% - 8px);
  }

  .hero-metrics span:first-child {
    flex-basis: 100%;
  }

  .composer-bottom,
  .section-title {
    align-items: stretch;
    flex-direction: column;
  }

  .primary-button {
    width: 100%;
  }
}
