:root { --night: #1b2140; --dusk: #2e3566; --lav: #cfd3f5; --mist: #f6f4fb; --sand: #f4c58a; --ink: #1b2140; --soft: #4b5278; --line: #dcdcf0; --danger: #a1281c; --emoji: "Apple Color Emoji", "Segoe UI Emoji", "Noto Color Emoji", sans-serif; }
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; font-family: system-ui, -apple-system, "Segoe UI", sans-serif; color: var(--ink); background: var(--mist); line-height: 1.55; }
h1, h2, h3, .logo { font-family: "Fraunces", Georgia, "Times New Roman", serif; }
a { color: inherit; }
:focus-visible { outline: 3px solid var(--sand); outline-offset: 2px; }
.wrap { max-width: 1000px; margin: 0 auto; padding: 0 20px; }
.muted { color: var(--soft); }
.hint { margin: 2px 0 0; color: var(--soft); font-size: .86rem; }
button { font: inherit; cursor: pointer; }
button:disabled { opacity: .45; cursor: default; }

/* Top bar */
.topbar { position: sticky; top: 0; z-index: 30; background: rgba(246, 244, 251, .93); backdrop-filter: blur(10px); border-bottom: 1px solid var(--line); }
.bar { display: flex; align-items: center; justify-content: space-between; gap: 16px; min-height: 64px; flex-wrap: wrap; padding-top: 8px; padding-bottom: 8px; }
.logo { font-weight: 700; font-size: 1.3rem; text-decoration: none; letter-spacing: -.01em; }
.logo .tag { font: 700 .7rem system-ui, sans-serif; letter-spacing: .08em; text-transform: uppercase; background: var(--sand); color: #3a2410; padding: 2px 9px; border-radius: 999px; vertical-align: middle; margin-left: 4px; }
.links { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.links > a:not(.btn) { color: var(--soft); text-decoration: none; }
.links > a:not(.btn):hover { color: var(--ink); text-decoration: underline; }
.links form { margin: 0; }
.who { display: inline-flex; align-items: center; gap: 8px; font-weight: 600; font-size: .92rem; }
.modpill { background: var(--night); color: #fff; font-size: .75rem; font-weight: 700; padding: 3px 10px; border-radius: 999px; }

/* Buttons */
.btn { display: inline-block; font-weight: 600; border-radius: 999px; padding: 9px 20px; border: 1.5px solid var(--night); background: transparent; color: var(--night); text-decoration: none; }
.btn:hover:not(:disabled) { background: var(--night); color: #fff; }
.btn.dark { background: var(--night); color: #fff; }
.btn.dark:hover { background: var(--dusk); border-color: var(--dusk); }
.btn.sm { padding: 5px 14px; font-size: .88rem; }
.btn.big { padding: 12px 30px; font-size: 1rem; }
.btn.danger { color: var(--danger); border-color: #e3b7b3; }
.btn.danger:hover:not(:disabled) { background: var(--danger); border-color: var(--danger); color: #fff; }
.linklike { border: 0; background: none; padding: 0; color: var(--soft); text-decoration: underline; text-underline-offset: 3px; font-size: .88rem; }
.linklike:hover { color: var(--ink); }

/* Page */
.main { padding-top: 28px; padding-bottom: 60px; }
.page-title { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 18px; }
.page-title h1 { margin: 0; font-size: clamp(1.6rem, 4vw, 2.2rem); letter-spacing: -.015em; overflow-wrap: anywhere; }
.page-title p { margin: 4px 0 0; }
.crumbs { margin: 0 0 8px; color: var(--soft); font-size: .9rem; }
.notice { margin: 0 0 18px; padding: 12px 16px; border-radius: 14px; font-weight: 500; border: 1px solid transparent; }
.notice.ok { background: #e6f5ec; border-color: #bfe3ca; color: #14532d; }
.notice.err { background: #fbe6e4; border-color: #f1c4c0; color: var(--danger); }
.empty { text-align: center; color: var(--soft); border: 1.5px dashed #c5c8ea; border-radius: 16px; padding: 30px 16px; background: #fff; }
.foot { border-top: 1px solid var(--line); padding: 22px 0 34px; color: var(--soft); font-size: .88rem; }

/* Cards and forms */
.card { background: #fff; border: 1px solid var(--line); border-radius: 20px; padding: 26px; box-shadow: 0 1px 2px rgba(27, 33, 64, .04), 0 14px 34px -20px rgba(27, 33, 64, .25); margin-bottom: 20px; }
.card.narrow { max-width: 460px; margin: 30px auto; }
.card h1, .card h2 { margin: 0 0 10px; }
.stack { display: grid; gap: 14px; }
.field { display: grid; gap: 5px; min-width: 0; }
.lrow { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; }
label { font-weight: 600; font-size: .9rem; }
input:not([type="file"]), textarea, select { width: 100%; font: inherit; padding: 10px 14px; border: 1px solid var(--line); border-radius: 12px; background: #fff; color: var(--ink); }
input:focus, textarea:focus, select:focus { outline: none; border-color: var(--dusk); box-shadow: 0 0 0 3px rgba(46, 53, 102, .16); }
input[type="file"] { width: 100%; padding: 9px; border: 1.5px dashed #b9bde6; border-radius: 12px; background: #fff; cursor: pointer; font: inherit; font-size: .9rem; }
input[type="file"]::file-selector-button { margin-right: 10px; border: 0; border-radius: 999px; padding: 6px 14px; background: var(--night); color: #fff; font: inherit; font-weight: 600; cursor: pointer; }
textarea { resize: vertical; line-height: 1.55; }
.row2 { display: grid; grid-template-columns: minmax(0, 1fr) 200px; gap: 14px; }
.actions { display: flex; gap: 10px; }
.counter { margin-left: auto; color: var(--soft); font-size: .8rem; font-variant-numeric: tabular-nums; }
.counter.near { color: var(--danger); font-weight: 600; }
.inp { position: relative; }
.inp textarea { padding-right: 46px; }
.emoji-ico { position: absolute; right: 8px; bottom: 8px; width: 32px; height: 32px; border: 0; border-radius: 9px; background: transparent; font-size: 1.15rem; line-height: 1; font-family: var(--emoji); }
.emoji-ico:hover { background: #eceafc; }

/* Categories */
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 18px; }
.chip { display: inline-block; padding: 5px 15px; border-radius: 999px; background: #fff; border: 1px solid var(--line); font-weight: 600; font-size: .88rem; text-decoration: none; color: var(--soft); }
a.chip:hover { border-color: var(--dusk); color: var(--ink); }
.chip.on { background: var(--night); border-color: var(--night); color: #fff; }
.chip.sm { padding: 1px 10px; font-size: .75rem; background: #eceafc; border-color: transparent; color: var(--dusk); }

/* Thread list */
.threads { display: grid; gap: 8px; }
.thread { display: grid; grid-template-columns: 44px minmax(0, 1fr) 72px 110px; gap: 14px; align-items: center; padding: 12px 16px; background: #fff; border: 1px solid var(--line); border-radius: 16px; transition: border-color .15s, transform .15s; }
.thread:hover { border-color: #b9bde6; transform: translateY(-1px); }
.thread.sticky { background: #fffaf2; border-color: #f0d3ab; }
.t-title { font-weight: 700; font-size: 1.05rem; text-decoration: none; overflow-wrap: anywhere; }
.t-title:hover { text-decoration: underline; }
.t-meta { color: var(--soft); font-size: .84rem; margin-top: 2px; }
.t-stat { text-align: center; display: grid; line-height: 1.15; }
.t-stat b { font-size: 1.15rem; }
.t-stat span, .t-last span { font-size: .76rem; color: var(--soft); }
.t-last { display: grid; line-height: 1.25; font-size: .85rem; }
.pin { font-family: var(--emoji); }

/* Avatars */
.av { flex: none; width: 44px; height: 44px; border-radius: 50%; object-fit: cover; background: var(--dusk); }
.av.xs { width: 28px; height: 28px; font-size: .85rem; }
.av.lg { width: 64px; height: 64px; font-size: 1.6rem; }
.av.ph { display: grid; place-items: center; color: #fff; font: 700 1.2rem "Fraunces", Georgia, serif; background: linear-gradient(140deg, #3b3f85, #c2587a); }

/* Posts */
.post { display: grid; grid-template-columns: 150px minmax(0, 1fr); gap: 20px; background: #fff; border: 1px solid var(--line); border-radius: 18px; padding: 20px; margin-bottom: 14px; scroll-margin-top: 80px; }
.post:target { border-color: var(--sand); box-shadow: 0 0 0 3px rgba(244, 197, 138, .45); }
.author { display: grid; justify-items: center; align-content: start; gap: 4px; text-align: center; font-size: .9rem; overflow-wrap: anywhere; }
.author .muted { font-size: .8rem; }
.post-top { font-size: .8rem; margin-bottom: 8px; }
.post-top a { text-decoration: none; }
.post-body { overflow-wrap: anywhere; font-size: 1rem; line-height: 1.65; }
.post-body a { color: var(--dusk); text-decoration: underline; text-underline-offset: 3px; }
.attach { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 14px; }
.a-img img { display: block; max-width: 220px; max-height: 170px; border-radius: 12px; border: 1px solid var(--line); object-fit: cover; }
.a-audio { flex: 1 1 100%; display: grid; gap: 4px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 12px; background: var(--mist); font-size: .9rem; }
.a-audio audio { width: 100%; height: 34px; }
.a-file { display: inline-flex; align-items: center; gap: 8px; padding: 8px 14px; border: 1px solid var(--line); border-radius: 12px; background: var(--mist); text-decoration: none; font-size: .9rem; max-width: 100%; }
.a-file span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.a-file small { color: var(--soft); }
.a-file:hover { border-color: var(--dusk); }
.post-foot { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-top: 16px; padding-top: 12px; border-top: 1px solid var(--line); }
.votes { display: flex; gap: 8px; margin: 0; }
.vote { display: inline-flex; align-items: center; gap: 6px; padding: 4px 13px; border-radius: 999px; border: 1.5px solid var(--line); background: #fff; font-weight: 600; font-size: .9rem; font-family: var(--emoji); }
.vote .n { font-family: system-ui, sans-serif; font-variant-numeric: tabular-nums; }
.vote:hover:not(:disabled) { border-color: var(--dusk); background: #eceafc; }
.vote.up.on { background: #e6f5ec; border-color: #7fc79a; }
.vote.down.on { background: #fbe6e4; border-color: #e9a29b; }
.post-tools { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.post-tools form { margin: 0; }
details.mod summary { cursor: pointer; font-size: .88rem; color: var(--danger); }
.banform { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 8px; }
.banform select { width: auto; padding: 6px 10px; }
.banform input { width: 230px; padding: 6px 12px; }
.modbar { display: flex; gap: 8px; flex-wrap: wrap; }
.modbar form { margin: 0; }

.pager { display: flex; justify-content: center; gap: 6px; margin: 22px 0; flex-wrap: wrap; }
.pager a { padding: 6px 14px; border-radius: 999px; border: 1px solid var(--line); background: #fff; text-decoration: none; font-weight: 600; font-size: .9rem; }
.pager a.on { background: var(--night); border-color: var(--night); color: #fff; }

/* Emoji picker */
dialog.emoji-dialog { width: min(440px, calc(100% - 24px)); padding: 0; border: 0; border-radius: 22px; overflow: hidden; box-shadow: 0 30px 80px rgba(10, 13, 30, .45); }
dialog.emoji-dialog::backdrop { background: rgba(17, 21, 43, .55); }
.emoji-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 18px 8px; }
.emoji-x { border: 0; background: transparent; width: 32px; height: 32px; border-radius: 50%; color: var(--soft); font-size: 1rem; }
.emoji-x:hover { background: var(--mist); color: var(--ink); }
.emoji-tabs { display: flex; gap: 4px; padding: 0 12px 8px; overflow-x: auto; border-bottom: 1px solid var(--line); }
.emoji-tabs button { flex: none; border: 0; background: transparent; border-radius: 10px; padding: 6px 10px; font-size: 1.2rem; line-height: 1; font-family: var(--emoji); }
.emoji-tabs button:hover { background: var(--mist); }
.emoji-tabs button[aria-selected="true"] { background: #eceafc; box-shadow: inset 0 -3px 0 var(--dusk); }
.emoji-grid { display: grid; grid-template-columns: repeat(8, 1fr); gap: 2px; padding: 10px 12px; height: 272px; overflow-y: auto; align-content: start; font-family: var(--emoji); }
.emoji-grid button { border: 0; background: transparent; font-size: 1.5rem; line-height: 1; padding: 7px 0; border-radius: 10px; font-family: var(--emoji); }
.emoji-grid button:hover, .emoji-grid button:focus-visible { background: #eceafc; transform: scale(1.15); }
.emoji-foot { display: flex; justify-content: flex-end; padding: 10px 16px; border-top: 1px solid var(--line); background: var(--mist); }

@media (max-width: 760px) {
  .thread { grid-template-columns: 40px minmax(0, 1fr); }
  .t-stat, .t-last { display: none; }
  .post { grid-template-columns: minmax(0, 1fr); gap: 12px; }
  .author { grid-template-columns: auto 1fr; justify-items: start; text-align: left; align-items: center; column-gap: 12px; }
  .author .av { grid-row: span 3; }
  .row2 { grid-template-columns: minmax(0, 1fr); }
  .emoji-grid { grid-template-columns: repeat(7, 1fr); }
}
