/* Category → board → posts. Keep the familiar HappaMochi palette and shell. */
body.happamochi-connected.bbs-tree-shell {
  --tree-ink: #234b60;
  --tree-muted: #58788a;
  --tree-blue: #027fb9;
  --tree-line: #cfe8f4;
}
body.bbs-tree-shell .hm-community-nav { display: none; }
body.happamochi-connected.bbs-tree-shell .bbs-main {
  padding-top: 18px;
  padding-bottom: 48px;
}
.bbs-tree-page,
.bbs-tree-page * { box-sizing: border-box; }
.bbs-tree-page { min-width: 0; color: var(--tree-ink); }
.bbs-tree-page > * { min-width: 0; }
.bbs-tree-page a { text-underline-offset: 3px; }
.bbs-tree-page [hidden] { display: none !important; }

/* A small search row is the only introduction before the category grid. */
.bbs-tree-topbar {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(220px, 330px) auto;
  align-items: center;
  gap: 18px;
  margin: 0 0 20px;
}
.bbs-tree-home {
  min-width: 0;
  color: var(--tree-ink);
  font-size: 21px;
  font-weight: 800;
  line-height: 1.45;
  text-decoration: none;
}
.bbs-tree-home h1 { margin: 0; font: inherit; }
.bbs-tree-home:hover { color: var(--tree-blue); }
.bbs-tree-search {
  display: flex;
  align-items: stretch;
  min-width: 0;
  padding: 4px;
  border: 1px solid #c4e4f3;
  border-radius: 11px;
  background: #fff;
  box-shadow: 0 2px 8px rgb(31 117 156 / 4%);
}
.bbs-tree-search input {
  flex: 1;
  min-width: 0;
  width: 100%;
  min-height: 36px;
  padding: 6px 9px;
  border: 0;
  border-radius: 8px;
  color: var(--tree-ink);
  background: transparent;
  font: 500 14px/1.5 var(--bbs-font-jp);
  appearance: none;
}
.bbs-tree-search input::placeholder { color: #7b929e; }
.bbs-tree-search button {
  flex: 0 0 auto;
  min-width: 62px;
  padding: 6px 14px;
  border: 0;
  border-radius: 8px;
  color: #fff;
  background: var(--tree-blue);
  font: 700 12px/1.5 var(--bbs-font-jp);
  cursor: pointer;
}
.bbs-tree-search button:hover { background: #026b9b; }
.bbs-tree-saved {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 40px;
  color: #356f8d;
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
  text-decoration: none;
}
.bbs-tree-saved:hover { text-decoration: underline; }
.bbs-tree-crumbs {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 7px;
  margin: -2px 0 14px;
  color: var(--tree-muted);
  font-size: 12px;
  line-height: 1.7;
}
.bbs-tree-crumbs a { color: #286e91; text-decoration: none; }
.bbs-tree-crumbs a:hover { text-decoration: underline; }

.bbs-tree-categories {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}
.bbs-tree-category {
  display: grid;
  grid-template-columns: 36px minmax(0, 1fr) 12px;
  align-items: center;
  gap: 13px;
  min-width: 0;
  min-height: 80px;
  padding: 15px 17px;
  border: 1px solid rgb(255 255 255 / 95%);
  border-radius: 13px;
  color: var(--tree-ink);
  background: rgb(255 255 255 / 93%);
  box-shadow: 0 3px 12px rgb(31 117 156 / 5%);
  text-decoration: none;
  transition: border-color .15s ease, background .15s ease;
}
.bbs-tree-category > i {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border-radius: 10px;
  color: var(--board-accent, #0288d1);
  background: #eff8fc;
  font-size: 21px;
}
.bbs-tree-category strong {
  min-width: 0;
  font-size: 16px;
  font-weight: 800;
  line-height: 1.5;
  overflow-wrap: anywhere;
}
.bbs-tree-category > span { color: #5990aa; font-size: 19px; line-height: 1; }
.bbs-tree-category:hover { border-color: #74c7ed; background: #f7fcff; }

.bbs-tree-popular { margin-top: 32px; }
.bbs-tree-popular > h2 {
  margin: 0 0 13px;
  font-size: 19px;
  font-weight: 800;
  line-height: 1.5;
}
.bbs-tree-popular ol {
  margin: 0;
  padding: 0;
  overflow: hidden;
  border: 1px solid #fff;
  border-radius: 14px;
  background: rgb(255 255 255 / 90%);
  list-style: none;
}
.bbs-tree-popular li + li { border-top: 1px solid #e4f0f6; }
.bbs-tree-popular li > a {
  display: grid;
  grid-template-columns: 28px minmax(0, 1fr) auto;
  align-items: center;
  gap: 13px;
  min-height: 49px;
  padding: 10px 16px;
  color: #2d617b;
  text-decoration: none;
}
.bbs-tree-popular li > a:hover { background: #f1faff; }
.bbs-tree-rank { color: #0288d1; font-size: 14px; font-weight: 800; text-align: center; }
.bbs-tree-popular strong {
  min-width: 0;
  overflow: hidden;
  font-size: 13px;
  font-weight: 700;
  white-space: nowrap;
  text-overflow: ellipsis;
}
.bbs-tree-popular small { color: #668696; font-size: 11px; white-space: nowrap; }

/* The category page previews each child board, rather than mixing its posts. */
.bbs-tree-banner {
  display: flex;
  align-items: center;
  gap: 22px;
  min-height: 128px;
  margin: 0 0 22px;
  padding: 24px 30px;
  border: 1px solid rgb(255 255 255 / 90%);
  border-radius: 17px;
  background: linear-gradient(110deg, #f8fdff, #d9f2ff);
}
.bbs-tree-banner > i {
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  width: 64px;
  height: 64px;
  border-radius: 18px;
  color: var(--board-accent, #0288d1);
  background: rgb(255 255 255 / 85%);
  font-size: 32px;
}
.bbs-tree-banner h1 {
  min-width: 0;
  margin: 0;
  color: #245c78;
  font-size: 29px;
  font-weight: 800;
  line-height: 1.45;
  overflow-wrap: anywhere;
}
.bbs-tree-panels { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; align-items: stretch; }
.bbs-tree-panel {
  min-width: 0;
  overflow: hidden;
  border: 1px solid #fff;
  border-radius: 14px;
  background: rgb(255 255 255 / 88%);
  box-shadow: 0 4px 16px rgb(31 117 156 / 5%);
}
.bbs-tree-panel h2 { margin: 0; font-size: 19px; font-weight: 800; line-height: 1.5; }
.bbs-tree-panel h2 > a {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  align-items: center;
  gap: 10px;
  min-height: 62px;
  padding: 13px 19px;
  color: #fff;
  background: #0789c2;
  text-decoration: none;
}
.bbs-tree-panel h2 > a:hover { background: #027bb3; }
.bbs-tree-panel h2 > a > span { min-width: 0; overflow-wrap: anywhere; }
.bbs-tree-panel h2 small { font-size: 14px; font-weight: 700; white-space: nowrap; }
.bbs-tree-panel h2 b { font-size: 25px; font-weight: 500; line-height: 1; }
.bbs-tree-panel ul { margin: 0; padding: 10px 18px 12px; list-style: none; }
.bbs-tree-panel li > a {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 12px;
  align-items: center;
  gap: 10px;
  min-height: 36px;
  padding: 7px 0;
  color: #1273a3;
  font-size: 13px;
  font-weight: 500;
  line-height: 1.65;
  text-decoration: none;
}
.bbs-tree-panel li > a:hover { text-decoration: underline; }
.bbs-tree-panel li > a > span { min-width: 0; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.bbs-tree-panel li b { color: #659db8; font-size: 17px; font-weight: 500; }
.bbs-tree-empty { margin: 0; padding: 24px 18px; color: var(--tree-muted); font-size: 13px; line-height: 1.8; }
.bbs-tree-empty a { display: inline-block; color: #027fb9; font-weight: 700; }
.bbs-tree-panel .bbs-tree-empty > a { display: block; margin-top: 9px; }

/* Child boards read like a single discussion stream with posting at the end. */
.bbs-tree-board-heading { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 12px 20px; margin: 0 0 10px; }
.bbs-tree-board-heading h1 { min-width: 0; margin: 0; font-size: 27px; font-weight: 800; line-height: 1.5; }
.bbs-tree-board-heading h1 small { display: inline-block; margin-left: 8px; color: var(--tree-muted); font-size: 13px; font-weight: 500; white-space: nowrap; }
.bbs-tree-board-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.bbs-tree-board-actions > a {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  padding: 8px 14px;
  border: 1px solid #b5dfee;
  border-radius: 10px;
  color: #027bb4;
  background: #fff;
  font-size: 12px;
  font-weight: 700;
  text-decoration: none;
}
.bbs-tree-board-actions > a[href$="#post"] { border-color: #0288d1; color: #fff; background: #0288d1; }
.bbs-tree-share { display: flex; flex-wrap: wrap; gap: 7px 15px; margin: 0 0 16px; font-size: 11px; }
.bbs-tree-share a { display: inline-flex; align-items: center; min-height: 32px; color: #427b96; text-decoration: none; }
.bbs-tree-share a:hover { text-decoration: underline; }
.bbs-tree-board-controls { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px 18px; margin: 16px 0; }
.bbs-tree-board-controls .bbs-pagination { justify-content: flex-start; gap: 5px; margin: 0; }
.bbs-tree-board-controls .bbs-page-link { min-width: 35px; height: 35px; padding: 6px 10px; border-radius: 8px; font-size: 12px; }
.bbs-tree-board-controls .bbs-sort { margin: 0 0 0 auto; }
.bbs-tree-board-controls .bbs-sort-link { padding: 6px 8px; font-size: 12px; }
.bbs-tree-page-gap { display: inline-grid; place-items: center; min-width: 20px; color: var(--tree-muted); }
.bbs-tree-posts { display: grid; grid-template-columns: minmax(0, 1fr); gap: 18px; }
.bbs-tree-post {
  min-width: 0;
  padding: 24px;
  border: 1px solid #fff;
  border-radius: 14px;
  background: rgb(255 255 255 / 95%);
  box-shadow: 0 4px 16px rgb(31 117 156 / 5%);
}
.bbs-tree-post > header { display: flex; flex-wrap: wrap; align-items: baseline; gap: 6px 15px; margin-bottom: 15px; }
.bbs-tree-post h2 { flex: 1 0 100%; margin: 0 0 3px; color: var(--tree-ink); font-size: 19px; font-weight: 800; line-height: 1.6; overflow-wrap: anywhere; }
.bbs-tree-post > header :is(a, time, span) { color: var(--tree-muted); font-size: 12px; text-decoration: none; }
.bbs-tree-post > header time { margin-left: auto; }
.bbs-tree-post-content { color: #345e71; font-size: 15px; font-weight: 500; line-height: 1.9; white-space: pre-wrap; overflow-wrap: anywhere; }
.bbs-tree-post-content a { color: #027fb9; }
.bbs-tree-post .bbs-attachment { align-items: center; margin-top: 18px; }
.bbs-tree-post .bbs-attachment-image { max-width: 180px; max-height: 180px; }
.bbs-tree-post-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; margin-top: 21px; padding-top: 14px; border-top: 1px solid #e2eff5; }
.bbs-tree-post-actions form { display: inline-flex; margin: 0; }
.bbs-tree-post-actions > a { display: inline-flex; align-items: center; min-height: 36px; color: #527e94; font-size: 11px; text-decoration: none; }
.bbs-tree-post-actions > a:hover { text-decoration: underline; }
.bbs-tree-post-actions button:not(.bbs-save-button) {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 38px;
  padding: 7px 12px;
  border: 1px solid #c5e4f2;
  border-radius: 9px;
  color: #0277ad;
  background: #f3faff;
  font: 700 12px/1.5 var(--bbs-font-jp);
  cursor: pointer;
}
.bbs-tree-post-actions .bbs-save-button { min-height: 38px; padding: 7px 12px; border-radius: 9px; font-size: 12px; }
.bbs-tree-compose { margin-top: 30px; padding-top: 24px; border-top: 1px solid rgb(255 255 255 / 90%); }
.bbs-tree-compose > h2 { margin: 0 0 9px; font-size: 22px; font-weight: 800; line-height: 1.5; }
.bbs-tree-compose > p { margin: 0 0 16px; color: var(--tree-muted); font-size: 13px; line-height: 1.75; }
body.happamochi-connected .bbs-tree-compose .bbs-form-card { margin: 0; padding: 24px; border: 1px solid #fff; border-radius: 14px; background: #fff; }
.bbs-tree-compose .bbs-form-textarea { min-height: 170px; }
.bbs-tree-compose .bbs-submit-button { margin-top: 20px; }
.bbs-tree-page .bbs-form-status { overflow-wrap: anywhere; }

/* Search goes directly to the relevant board/post, without a filter dashboard. */
.bbs-tree-search-results { display: grid; grid-template-columns: minmax(0, 1fr); gap: 14px; margin: 20px 0; }
.bbs-tree-search-result {
  min-width: 0;
  padding: 19px 22px;
  border: 1px solid #fff;
  border-radius: 13px;
  background: rgb(255 255 255 / 94%);
  box-shadow: 0 3px 12px rgb(31 117 156 / 4%);
}
.bbs-tree-search-result > div { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 16px; color: #6c8998; font-size: 11px; line-height: 1.6; }
.bbs-tree-search-result > div > a { color: #317c9f; text-decoration: none; }
.bbs-tree-search-result > div > a:hover { text-decoration: underline; }
.bbs-tree-search-result > a { position: relative; display: block; min-width: 0; padding: 9px 30px 1px 0; color: var(--tree-ink); text-decoration: none; }
.bbs-tree-search-result h2 { margin: 0; font-size: 18px; font-weight: 800; line-height: 1.65; overflow-wrap: anywhere; }
.bbs-tree-search-result > a:hover h2 { color: #027fb9; text-decoration: underline; }
.bbs-tree-search-result p { margin: 7px 0 0; color: #527487; font-size: 13px; line-height: 1.8; overflow-wrap: anywhere; }
.bbs-tree-search-result > a > span { position: absolute; top: 50%; right: 2px; color: #548daa; font-size: 26px; line-height: 1; transform: translateY(-50%); }

@media (max-width: 900px) {
  .bbs-tree-topbar { grid-template-columns: minmax(0, 1fr) minmax(190px, 270px); gap: 10px 16px; }
  .bbs-tree-topbar .bbs-tree-saved { grid-column: 1 / -1; justify-self: end; min-height: 28px; }
  .bbs-tree-home { font-size: 19px; }
  .bbs-tree-category { grid-template-columns: 30px minmax(0, 1fr) 10px; gap: 10px; padding: 13px; }
  .bbs-tree-category > i { width: 30px; height: 34px; font-size: 18px; }
  .bbs-tree-category strong { font-size: 14px; }
}

@media (max-width: 640px) {
  body.happamochi-connected.bbs-tree-shell .site-header { top: 8px; width: calc(100% - 20px); padding: 8px 10px; border-radius: 14px; }
  body.bbs-tree-shell .header-inner { flex-wrap: nowrap; gap: 8px; }
  body.bbs-tree-shell .site-brand { gap: 6px; font-size: 11px; }
  body.bbs-tree-shell .site-brand > img { width: 27px; height: 27px; }
  body.bbs-tree-shell .site-nav { width: auto; flex-wrap: nowrap; justify-content: flex-end; gap: 3px; margin-left: auto; }
  body.bbs-tree-shell .site-nav a { min-height: 32px; padding: 4px 6px; font-size: 10px; }
  body.happamochi-connected.bbs-tree-shell [id] { scroll-margin-top: 90px; }
  body.happamochi-connected.bbs-tree-shell .bbs-main { padding: 16px 12px 34px; }
  .bbs-tree-topbar { grid-template-columns: minmax(0, 1fr) auto; gap: 10px; margin-bottom: 14px; }
  .bbs-tree-home { font-size: 18px; }
  .bbs-tree-search { grid-column: 1 / -1; grid-row: 2; }
  .bbs-tree-search input { min-height: 36px; font-size: 16px; }
  .bbs-tree-search button { min-width: 62px; }
  .bbs-tree-topbar .bbs-tree-saved { grid-column: 2; grid-row: 1; min-height: 34px; font-size: 11px; }
  .bbs-tree-crumbs { gap: 5px; margin-bottom: 11px; font-size: 11px; }
  .bbs-tree-categories { grid-template-columns: minmax(0, 1fr); gap: 7px; }
  .bbs-tree-category { grid-template-columns: 30px minmax(0, 1fr) 12px; gap: 11px; min-height: 51px; padding: 9px 13px; border-radius: 10px; }
  .bbs-tree-category > i { width: 30px; height: 30px; font-size: 17px; border-radius: 8px; }
  .bbs-tree-category strong { font-size: 14px; line-height: 1.45; }
  .bbs-tree-category > span { font-size: 18px; }
  .bbs-tree-popular { margin-top: 25px; }
  .bbs-tree-popular > h2 { font-size: 18px; }
  .bbs-tree-popular li > a { grid-template-columns: 23px minmax(0, 1fr) auto; gap: 8px; padding: 10px 12px; min-height: 47px; }
  .bbs-tree-popular strong { font-size: 12px; }
  .bbs-tree-popular small { font-size: 10px; }
  .bbs-tree-banner { min-height: 86px; gap: 14px; margin-bottom: 15px; padding: 17px; border-radius: 13px; }
  .bbs-tree-banner > i { width: 47px; height: 47px; border-radius: 13px; font-size: 25px; }
  .bbs-tree-banner h1 { font-size: 22px; }
  .bbs-tree-panels { grid-template-columns: minmax(0, 1fr); gap: 14px; }
  .bbs-tree-panel { border-radius: 12px; }
  .bbs-tree-panel h2 { font-size: 17px; }
  .bbs-tree-panel h2 > a { min-height: 54px; padding: 12px 15px; gap: 8px; }
  .bbs-tree-panel h2 small { font-size: 12px; }
  .bbs-tree-panel h2 b { font-size: 23px; }
  .bbs-tree-panel ul { padding: 6px 15px 8px; }
  .bbs-tree-panel li > a { min-height: 42px; padding: 8px 0; font-size: 13px; }
  .bbs-tree-empty { padding: 21px 15px; font-size: 12px; }
  .bbs-tree-board-heading { gap: 10px; }
  .bbs-tree-board-heading h1 { font-size: 23px; }
  .bbs-tree-board-actions > a { min-height: 37px; padding: 7px 11px; font-size: 11px; }
  .bbs-tree-board-controls { gap: 8px 12px; margin: 13px 0; }
  .bbs-tree-board-controls .bbs-page-link { min-width: 32px; height: 34px; padding-inline: 8px; }
  .bbs-tree-board-controls .bbs-sort-link { padding-inline: 6px; font-size: 11px; }
  .bbs-tree-posts { gap: 14px; }
  .bbs-tree-post { padding: 18px 15px; border-radius: 12px; }
  .bbs-tree-post > header { margin-bottom: 12px; gap: 5px 10px; }
  .bbs-tree-post h2 { font-size: 17px; line-height: 1.65; }
  .bbs-tree-post > header :is(a, time, span) { font-size: 11px; }
  .bbs-tree-post-content { font-size: 14px; line-height: 1.9; }
  .bbs-tree-post .bbs-attachment-image { max-width: 160px; max-height: 180px; }
  .bbs-tree-post-actions { gap: 7px 10px; margin-top: 17px; padding-top: 12px; }
  .bbs-tree-post-actions .bbs-save-button,
  .bbs-tree-post-actions button:not(.bbs-save-button) { min-height: 38px; padding-inline: 10px; font-size: 11px; }
  .bbs-tree-compose { margin-top: 24px; padding-top: 21px; }
  .bbs-tree-compose > h2 { font-size: 19px; }
  .bbs-tree-compose > p { font-size: 12px; }
  body.happamochi-connected .bbs-tree-compose .bbs-form-card { padding: 18px 15px; border-radius: 12px; }
  .bbs-tree-search-results { gap: 12px; margin: 16px 0; }
  .bbs-tree-search-result { padding: 15px; border-radius: 12px; }
  .bbs-tree-search-result > div { gap: 6px 12px; font-size: 10px; }
  .bbs-tree-search-result > a { padding-right: 23px; }
  .bbs-tree-search-result h2 { font-size: 16px; }
  .bbs-tree-search-result p { font-size: 12px; }
}

@media (max-width: 359px) {
  body.bbs-tree-shell .site-nav .nav-guide { display: none; }
  .bbs-tree-home { font-size: 16px; }
  .bbs-tree-topbar .bbs-tree-saved { gap: 4px; font-size: 10px; }
  .bbs-tree-post-actions > a { font-size: 10px; }
}

@media (prefers-reduced-motion: reduce) {
  .bbs-tree-page * { transition: none !important; scroll-behavior: auto !important; }
}
