:root {
  --bg: #ffffee;
  --text: #800000;
  --post-bg: #f0e0d6;
  --post-border: #d9bfb7;
  --header: #af0a0f;
  --name: #117743;
  --subject: #cc1105;
  --link: #0000ee;
  --quote: #789922;
  --muted: #707070;
  --form-th: #ea8;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #1d1f21;
    --text: #c5c8c6;
    --post-bg: #282a2e;
    --post-border: #3a3d42;
    --header: #e06c75;
    --name: #98c379;
    --subject: #e5c07b;
    --link: #81a2be;
    --quote: #b5bd68;
    --muted: #8a8f95;
    --form-th: #3f4248;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  padding: 8px 16px;
  background: var(--bg);
  color: var(--text);
  font: 13px/1.4 arial, helvetica, sans-serif;
}

a { color: var(--link); }
a:hover { color: var(--header); }

hr { border: 0; border-top: 1px solid var(--post-border); margin: 12px 0; clear: both; }

nav.boards { font-size: 12px; color: var(--muted); }
footer { margin-top: 16px; }

header { text-align: center; }
header h1 {
  color: var(--header);
  font: bold 28px tahoma, sans-serif;
  letter-spacing: -1px;
  margin: 12px 0 4px;
}

.muted { color: var(--muted); }

header .site-name {
  display: inline-block;
  margin-top: 8px;
  color: var(--name);
  font: bold 15px tahoma, sans-serif;
  letter-spacing: 1px;
  text-decoration: none;
}
header .site-name:hover { color: var(--header); }

.board-list { list-style: none; padding: 0; max-width: 400px; margin: 16px auto; font-size: 15px; }
.board-list li { padding: 4px 0; }

/* post form */
.post-form { display: flex; flex-direction: column; align-items: center; }
.post-form table { border-spacing: 1px; }
.post-form th {
  background: var(--form-th);
  color: var(--text);
  text-align: left;
  padding: 0 6px;
  font-size: 12px;
  border: 1px solid var(--post-border);
}
.post-form input:not([type=file]):not([type=checkbox]):not([type=radio]), .post-form textarea {
  width: 300px;
  max-width: 100%;
  font: inherit;
  padding: 3px;
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--post-border);
}
.post-form textarea { resize: vertical; }
.post-form .rules { font-size: 11px; color: var(--muted); max-width: 400px; text-align: center; }

/* reply box under each thread on a board page */
.quick-reply { clear: both; margin: 6px 0 0 16px; }
.quick-reply summary {
  display: inline-block;
  cursor: pointer;
  color: var(--link);
  list-style: none;
  padding: 4px 0;
}
.quick-reply summary::-webkit-details-marker { display: none; }
.quick-reply summary::before { content: '[ '; color: var(--text); }
.quick-reply summary::after { content: ' ]'; color: var(--text); }
.quick-reply summary:hover { color: var(--header); }
.quick-reply summary:focus-visible { outline: 2px solid var(--link); outline-offset: 2px; }
.quick-reply[open] summary { color: var(--muted); }
.post-form.inline {
  align-items: flex-start;
  margin-top: 4px;
  padding: 6px;
  background: var(--post-bg);
  border: 1px solid var(--post-border);
  max-width: 100%;
  width: fit-content;
}

/* catalog: one tile per thread */
.catalog {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 16px 12px;
  margin: 12px 0;
}
.catalog-tile {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  min-width: 0;
  padding: 6px 4px;
  color: var(--text);
  text-decoration: none;
  text-align: center;
  border: 1px solid transparent;
}
.catalog-tile:hover, .catalog-tile:focus-visible { border-color: var(--post-border); background: var(--post-bg); color: var(--text); }
.catalog-tile img { max-width: 150px; max-height: 150px; box-shadow: 0 0 0 1px var(--post-border); }
.catalog-counts { font-size: 11px; color: var(--muted); }
.catalog-counts b { color: var(--text); font-variant-numeric: tabular-nums; }
.catalog-text {
  font-size: 12px;
  overflow-wrap: anywhere;
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 5;
  overflow: hidden;
}
.catalog-text .subject { color: var(--subject); }
.catalog-sort { margin-left: 8px; }

/* posts */
.thread { display: flow-root; }
.post { margin: 4px 0; }
.post.reply {
  display: table;
  background: var(--post-bg);
  border: 1px solid var(--post-border);
  border-left: none;
  border-top: none;
  padding: 4px 8px;
  margin-left: 16px;
  max-width: calc(100% - 16px);
}
.post.reply:target { background: var(--post-border); }

.post-info .subject { color: var(--subject); font-weight: bold; }
.post-info .name { color: var(--name); font-weight: bold; }
.post-info .trip { color: var(--name); }
.post-info .date { color: var(--muted); }
.post-info a { text-decoration: none; color: inherit; }
.post-info a:hover { color: var(--header); }
.post-info .reply-link { color: var(--link); }

.file { font-size: 12px; color: var(--muted); }
.file img {
  display: block;
  float: left;
  max-width: 250px;
  max-height: 250px;
  margin: 4px 16px 4px 0;
}
.post.reply .file img { max-width: 125px; max-height: 125px; }

blockquote { margin: 8px 24px 8px 24px; overflow-wrap: anywhere; }
.greentext { color: var(--quote); }
.quotelink { color: var(--header); }

.omitted { color: var(--muted); margin: 4px 0 4px 16px; }

.pager, .nav-links { margin: 8px 0; }

.error { text-align: center; padding: 40px 0; }
.error h2 { color: var(--header); }

/* captcha */
.captcha img { display: block; margin-bottom: 4px; border: 1px solid var(--post-border); max-width: 100%; height: auto; }

/* admin */
.mod { margin-left: 6px; font-size: 11px; }
.mod .ip { color: var(--muted); margin-right: 4px; }
.mod form { display: inline; }
.mod button { font-size: 11px; padding: 0 4px; }
.mod a { color: var(--subject); }
.admin-link { color: var(--subject); font-weight: bold; }
.admin-post { margin: 8px 0; }
.admin-post .post.reply { margin-left: 0; }
.logout { text-align: center; }
h2 { color: var(--header); font-size: 16px; }
table.bans { border-collapse: collapse; font-size: 12px; }
table.bans th, table.bans td { border: 1px solid var(--post-border); padding: 3px 6px; text-align: left; }
.post-form select { font: inherit; }
.error.inline { padding: 12px 0; }
.error.inline p:first-child { color: var(--subject); font-weight: bold; font-size: 15px; }

/* reports */
.post-info .report-link { color: var(--muted); font-size: 11px; }
.post-form label.reason { display: block; padding: 1px 0; }
.report { border-left: 3px solid var(--post-border); padding-left: 8px; }
.report.urgent { border-left-color: var(--subject); }
.report-head form { display: inline; margin-left: 6px; }
.report-notes { margin: 4px 0; padding-left: 20px; color: var(--muted); }

@media (max-width: 600px) {
  .file img { max-width: 150px; max-height: 150px; }
  .post.reply { margin-left: 0; max-width: 100%; }
  .quick-reply { margin-left: 0; }
  .catalog { grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 12px 8px; }
  .catalog-tile img { max-width: 120px; max-height: 120px; }
  .post-form { width: 100%; }
  .post-form table { width: 100%; }
  .post-form th { width: 1%; white-space: nowrap; }
  .post-form td input:not([type=file]):not([type=checkbox]):not([type=radio]), .post-form textarea { width: 100%; }
  .post-form input[type=file] { width: 100%; max-width: 100%; font-size: 13px; }
  .post-form th { padding: 0 4px; font-size: 11px; }
  .post-form td { min-width: 0; }
  .file-preview { flex-wrap: wrap; }
  .captcha img { width: 100%; max-width: 200px; height: auto; }
  blockquote { margin: 8px 4px; }
  /* iOS Safari zooms the page into any text field under 16px. */
  .post-form input:not([type=file]):not([type=checkbox]):not([type=radio]), .post-form textarea, .post-form select { font-size: 16px; }
}

/* Touch screens: bigger targets for the small text links and buttons. */
@media (pointer: coarse) {
  .post-info a, .mod a, .nav-links a, .pager a, nav.boards a, .omitted a {
    display: inline-block;
    padding: 8px 4px;
    margin: -8px 0;
  }
  .post-info .report-link { font-size: 13px; }
  .post-info .post-no { padding-right: 0; }
  .post-info .quote-link { padding-left: 0; }
  .quotelink { padding: 6px 2px; }
  .post-form button, .mod button, .report-head button, .logout button { min-height: 40px; padding: 0 14px; }
}

/* Images: tap to expand in place (public/app.js), tap again to shrink.
   Width is capped by the screen rather than a percentage, because replies
   shrink to fit their content. */
.file a > img { cursor: zoom-in; }
.post .file img.expanded {
  max-width: calc(100vw - 68px);  /* page gutters + a reply's indent, padding and border */
  max-height: none;
  cursor: zoom-out;
}

/* admin site stats */
.traffic { margin: 8px 0 12px; max-width: 520px; }
.traffic-label { margin-bottom: 4px; }
.meter {
  appearance: none;
  display: block;
  width: 100%;
  height: 10px;
  border: 1px solid var(--post-border);
  background: var(--post-bg);
}
.meter::-webkit-progress-bar { background: var(--post-bg); }
.meter::-webkit-progress-value { background: var(--name); }
.meter::-moz-progress-bar { background: var(--name); }
.table-scroll { overflow-x: auto; max-width: 100%; }
table.stats { border-collapse: collapse; font-size: 12px; font-variant-numeric: tabular-nums; }
table.stats th, table.stats td { border: 1px solid var(--post-border); padding: 3px 8px; white-space: nowrap; }
table.stats td { text-align: right; }
table.stats th { text-align: left; font-weight: normal; color: var(--muted); }
table.stats tr:first-child th { font-weight: bold; color: var(--text); }
.stats-note { font-size: 11px; max-width: 640px; }
h3 { color: var(--header); font-size: 14px; margin: 14px 0 6px; }

/* attaching images */
.file-preview { display: flex; align-items: flex-start; gap: 8px; margin-top: 6px; max-width: 100%; }
.file-preview img { max-width: 120px; max-height: 120px; border: 1px solid var(--post-border); }
.file-preview-info { display: flex; flex-direction: column; align-items: flex-start; gap: 4px; font-size: 12px; min-width: 0; overflow-wrap: anywhere; }
.file-preview-warn { color: var(--subject); font-weight: bold; }
.file-preview-remove { font-size: 12px; }
.post-form.drop-target table { outline: 2px dashed var(--name); outline-offset: 4px; }
