:root {
  color: #22201d;
  background: #f6f3ee;
  font-family: "Hiragino Sans", "Yu Gothic", system-ui, -apple-system, sans-serif;
  line-height: 1.6;
  --ink: #22201d;
  --muted: #6f6a63;
  --line: #d9d3ca;
  --accent: #7a4b8f;
  --accent-soft: #ece4f1;
  --paper: #fffdf9;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
}

a {
  color: var(--accent);
}

/* The header block: the brand row plus the category menu under it. Both
   stay together at the top of every page. */
.site-top {
  background: var(--paper);
  border-bottom: 1px solid var(--line);
}

.site-top .site-header {
  border-bottom: none;
}

.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--line);
  background: var(--paper);
}

.site-header .brand {
  font-weight: 700;
  text-decoration: none;
  color: var(--ink);
}

.site-header .session-bar {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin: 0;
}

.site-footer {
  max-width: 44rem;
  margin: 2rem auto 0;
  padding: 1rem;
  border-top: 1px solid var(--line);
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 0.5rem 1rem;
  font-size: 0.85rem;
}

.site-footer nav {
  display: flex;
  gap: 1rem;
}

.site-header .sign-in,
.button {
  display: inline-block;
  padding: 0.4rem 0.9rem;
  border-radius: 999px;
  background: var(--accent);
  color: #fff;
  text-decoration: none;
  font-size: 0.9rem;
}

main {
  max-width: 44rem;
  margin: 0 auto;
  padding: 1rem;
}

.lede,
.meta,
.count,
.empty,
.crumbs {
  color: var(--muted);
  font-size: 0.9rem;
}

.thread-list ul {
  list-style: none;
  padding: 0;
  margin: 0;
}

.thread-item {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.6rem 0;
  border-bottom: 1px solid var(--line);
}

.post {
  padding: 0.8rem 0;
  border-bottom: 1px solid var(--line);
}

.post header {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: baseline;
  font-size: 0.85rem;
  color: var(--muted);
}

.post .pseudonym {
  color: var(--ink);
  font-weight: 600;
}

.post .body {
  white-space: pre-wrap;
  margin: 0.4rem 0 0;
}

.badge {
  display: inline-block;
  padding: 0 0.5rem;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 0.75rem;
}

.composer {
  display: grid;
  gap: 0.75rem;
}

.button.secondary {
  background: var(--paper);
  color: var(--accent);
  border: 1px solid var(--accent);
}

.button[disabled] {
  opacity: 0.6;
}

.composer input,
.composer select,
.composer textarea {
  width: 100%;
  padding: 0.5rem;
  border: 1px solid var(--line);
  border-radius: 6px;
  font: inherit;
}

.composer textarea {
  min-height: 10rem;
}

.notice {
  padding: 0.6rem 0.8rem;
  border-radius: 6px;
  background: var(--accent-soft);
}

.notice p {
  margin: 0 0 0.4rem;
}

.notice p:last-child {
  margin-bottom: 0;
}

.hint {
  color: var(--muted);
  font-size: 0.85rem;
  margin: 0.2rem 0 0;
}

.checks {
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0.6rem 0.8rem;
  display: grid;
  gap: 0.3rem;
}

.checks legend {
  font-weight: 600;
}

.check {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.check input {
  width: auto;
}

.check.radio {
  align-items: flex-start;
}

.check.radio .hint {
  display: block;
}

.composer label .hint {
  display: block;
}

.actions {
  margin: 0.5rem 0;
}

.mod-nav {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-bottom: 0.75rem;
}

.dev-toggle {
  font-size: 0.85rem;
  color: var(--muted);
  margin-bottom: 0.75rem;
}

.queue-item {
  padding: 0.8rem 0;
  border-bottom: 1px solid var(--line);
}

.queue-item header {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: baseline;
  font-size: 0.85rem;
}

.queue-item .excerpt {
  white-space: pre-wrap;
  margin: 0.4rem 0;
}

.tag {
  display: inline-block;
  padding: 0 0.5rem;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 0.75rem;
}

.tag.overdue {
  background: #f7dcd8;
  color: #8a2f21;
}

.mod-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.6rem;
  margin-top: 0.4rem;
}

.mod-actions select {
  padding: 0.3rem;
  border: 1px solid var(--line);
  border-radius: 6px;
  font: inherit;
}

.intro {
  padding: 0.9rem 1rem;
  margin-bottom: 1rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--paper);
}

.intro h2 {
  margin: 0 0 0.3rem;
  font-size: 1.05rem;
}

.intro p {
  margin: 0 0 0.6rem;
}

.checks.columns {
  grid-template-columns: repeat(auto-fill, minmax(11rem, 1fr));
}

.checks.columns legend,
.checks.columns .hint {
  grid-column: 1 / -1;
}

.composer textarea.short {
  min-height: 5rem;
}

.thread-item > div {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  min-width: 0;
}

/* The row's one link: the opener's thumbnail, when there is one, and the
   title beside it. A row without a picture is the same link without the
   square, so nothing reserves empty space for a thumbnail that never comes. */
.thread-link {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  min-width: 0;
}

/* A fixed square whatever the picture's own shape: `cover` crops it rather
   than letting a portrait photograph make one row twice as tall as the next.
   The `img` carries the same number as `width` and `height` (contracts'
   ROW_THUMBNAIL_PX), so the box is held before the bytes arrive. */
.thread-link .thumb {
  flex: none;
  width: 64px;
  height: 64px;
  object-fit: cover;
  border-radius: 6px;
  border: 1px solid var(--line);
  background: var(--line);
}

.thread-title {
  min-width: 0;
}

.chips {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 0.3rem;
  margin: 0;
}

.chip {
  display: inline-block;
  padding: 0 0.55rem;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--paper);
  color: var(--ink);
  font: inherit;
  font-size: 0.78rem;
  line-height: 1.5;
  text-decoration: none;
  cursor: pointer;
}

.chip.space {
  border-color: var(--accent);
  color: var(--accent);
}

.chip.clinic,
.chip.doctor,
.chip.agent {
  background: var(--accent-soft);
}

.chip.selected {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.chip.clear {
  border-style: dashed;
  color: var(--muted);
}

.chip-with-remove {
  display: inline-flex;
  gap: 0.2rem;
  align-items: center;
}

.filter-bar {
  display: grid;
  gap: 0.5rem;
  padding: 0.6rem 0;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  margin-bottom: 0.5rem;
}

.filter-group {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
  align-items: center;
}

.filter-group > .meta {
  min-width: 4.5rem;
}

.tag-filters {
  display: grid;
  gap: 0.35rem;
}

.free-picker label {
  flex: 1 1 12rem;
}

.notice.rule {
  font-size: 0.9rem;
}

.thread-context {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  align-items: center;
}

.me .pseudonym {
  font-weight: 600;
  margin: 0 0 1rem;
}

.survey-summary {
  margin-top: 1.5rem;
  padding-top: 0.75rem;
  border-top: 1px solid var(--line);
}

.survey-summary h3 {
  font-size: 0.95rem;
  margin: 0.6rem 0 0.2rem;
}

.counts {
  list-style: none;
  padding: 0;
  margin: 0;
  max-width: 20rem;
}

.counts li {
  display: flex;
  justify-content: space-between;
  padding: 0.15rem 0;
  border-bottom: 1px solid var(--line);
}

/* Categories: the way in (decision D-011). The menu scrolls sideways on a
   phone rather than collapsing into a dropdown, so a category is always one
   tap away; the grid on the front page is the same fourteen with counts. */
.category-menu {
  display: flex;
  gap: 0.3rem;
  padding: 0 1rem 0.6rem;
  overflow-x: auto;
  scrollbar-width: thin;
}

.category-menu .chip {
  white-space: nowrap;
}

.categories {
  margin-bottom: 0.5rem;
}

.categories h1 {
  margin-bottom: 0.2rem;
}

.category-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(9rem, 1fr));
  gap: 0.4rem;
  margin-bottom: 1.5rem;
}

.category-card {
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
  padding: 0.6rem 0.7rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--paper);
  color: var(--ink);
  text-decoration: none;
}

.category-card .category-name {
  font-weight: 600;
}

.chip.category {
  border-color: var(--accent);
  color: var(--accent);
}

.chip.category.selected {
  background: var(--accent);
  color: #fff;
}

/* The composer's required category picker: every category visible, wrapping
   over as many rows as a phone needs. */
.category-picker {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
}

.category-field .hint {
  margin-bottom: 0.4rem;
}

.filter-group.suggested .meta,
.filter-group.controlled .meta {
  min-width: 4.5rem;
}

/* One disclosure for everything optional: the extra tags in the composer and
   the quotation block. Closed by default. */
.more {
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--paper);
  padding: 0.5rem 0.8rem;
}

.more > summary {
  cursor: pointer;
  font-weight: 600;
  padding: 0.2rem 0;
}

.more[open] > summary {
  margin-bottom: 0.5rem;
  border-bottom: 1px solid var(--line);
}

.more > * {
  margin-top: 0.5rem;
}

.citation-fields .counter {
  display: block;
  text-align: right;
}

.citation-fields .counter.over {
  color: #8a2f21;
}

/* The image picker (decision D-013). One row per picked file, so that a
   refusal names the file it belongs to and a stored image shows what the
   Worker actually kept. */
.image-drafts {
  list-style: none;
  margin: 0;
  padding: 0;
}

.image-draft {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  gap: 0.5rem;
  padding: 0.5rem 0;
  border-top: 1px solid var(--line);
}

.image-draft .thumb {
  width: 6rem;
  height: auto;
  border-radius: 6px;
  border: 1px solid var(--line);
}

.image-draft label {
  flex: 1 1 12rem;
}

.image-draft .notice {
  margin: 0;
}

.image-fields input[type="file"] {
  display: block;
}

.image-fields input[type="file"]:disabled {
  color: var(--muted);
}

.sign-in-note {
  margin: 0 0 0.6rem;
}

.sign-in-note .inline {
  white-space: nowrap;
}

.notice.held p:not(:first-child) {
  margin-top: 0.3rem;
}

.pseudonym.default {
  color: var(--muted);
  font-weight: 500;
}

/* A quoted article (decision D-013): clearly separated from the post's own
   text, with the attribution under it. */
.citation {
  margin: 0.6rem 0 0;
  padding: 0.5rem 0.8rem;
  border-left: 3px solid var(--accent);
  background: var(--paper);
}

.citation blockquote {
  margin: 0;
  white-space: pre-wrap;
}

.citation figcaption {
  margin-top: 0.3rem;
}

/* Attached images (decision D-013). The Leptos thread view lays them out in
   the grid; the Worker's own thread page prints the same images without it,
   so the picture rules are written for both. */
.attachments {
  margin: 0.6rem 0 0;
}

.image-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(8rem, 1fr));
  gap: 0.4rem;
  margin: 0;
}

.image-grid a {
  display: block;
  line-height: 0;
}

.attachments img {
  max-width: 100%;
  height: auto;
  border-radius: 6px;
  border: 1px solid var(--line);
}

.image-grid img {
  width: 100%;
}

.attachments figcaption,
.attachments .own-work {
  margin: 0.3rem 0 0;
  color: var(--muted);
  font-size: 0.8rem;
}

@media (max-width: 30rem) {
  .thread-item {
    flex-direction: column;
    gap: 0.2rem;
  }

  .category-grid {
    grid-template-columns: repeat(auto-fill, minmax(7.5rem, 1fr));
  }

  .site-header {
    flex-wrap: wrap;
    gap: 0.4rem;
  }
}
