@font-face {
  font-family: "Caveat";
  src: url("fonts/caveat-latin-400-normal.woff2") format("woff2");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "Caveat";
  src: url("fonts/caveat-latin-700-normal.woff2") format("woff2");
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}

:root {
  --ink: #2a2118;
  --muted: #6a5340;
  --paper-shadow: 0 12px 18px rgba(62, 32, 8, 0.22);
  --sans: "Segoe UI", "PingFang TC", "Hiragino Sans CNS", "Noto Sans TC", "Microsoft JhengHei", "Heiti TC", system-ui, sans-serif;
  --hand: Caveat, "PingFang TC", "Hiragino Sans CNS", "Noto Sans TC", "Microsoft JhengHei", "Heiti TC", "Segoe Print", cursive;
  --serif: "Iowan Old Style", Palatino, "PingFang TC", "Hiragino Sans CNS", "Noto Sans TC", "Microsoft JhengHei", Georgia, serif;
  color-scheme: light;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  font-family: var(--serif);
  background-color: #c4a484;
  background-image:
    radial-gradient(circle at 12% 8%, rgba(255, 248, 230, 0.35), transparent 32%),
    radial-gradient(circle at 90% 0%, rgba(90, 48, 20, 0.16), transparent 28%),
    repeating-linear-gradient(0deg, rgba(80, 42, 16, 0.045) 0 1px, transparent 1px 7px),
    repeating-linear-gradient(90deg, rgba(80, 42, 16, 0.04) 0 1px, transparent 1px 9px);
}

a { color: inherit; }

.site-header {
  text-align: center;
  padding: 1.75rem 1rem 0.25rem;
}

.eyebrow {
  margin: 0;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  font-family: var(--sans);
  font-size: 0.72rem;
  color: var(--muted);
}

.site-header h1 {
  margin: 0.15rem 0 0;
  font-family: var(--hand);
  font-size: clamp(3.4rem, 8vw, 5.4rem);
  font-weight: 700;
  line-height: 0.9;
  text-shadow: 0 2px 0 rgba(255, 248, 230, 0.35);
}

.site-header h1 a {
  color: inherit;
  font: inherit;
  text-decoration: none;
}

.site-header h1 a:hover { text-decoration: underline; }

.languages {
  margin-top: 0.85rem;
}

.languages form {
  display: inline-flex;
  gap: 0.35rem;
}

.languages button {
  font-family: var(--sans);
  border: none;
  background: rgba(255, 248, 230, 0.55);
  color: var(--ink);
  border-radius: 999px;
  padding: 0.35rem 0.8rem;
  min-height: 44px;
  cursor: pointer;
  font-size: 0.9rem;
}

.languages button.is-active {
  background: var(--ink);
  color: #fff8e6;
}

.lede {
  margin: 0.4rem auto 0;
  max-width: 28rem;
  font-size: 1.05rem;
}

.tag-cloud {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.45rem;
  max-width: 60rem;
  margin: 1rem auto 0;
  padding: 0 1rem;
}

.tag {
  display: inline-flex;
  align-items: baseline;
  gap: 0.3rem;
  padding: 0.28rem 0.65rem;
  border-radius: 999px;
  background: rgba(255, 248, 230, 0.55);
  text-decoration: none;
  font-family: var(--sans);
  font-size: 0.85rem;
}

.tag span { color: var(--muted); font-size: 0.75rem; }

.tag.is-active {
  background: var(--ink);
  color: #fff8e6;
}

.tag.is-active span { color: rgba(255, 248, 230, 0.75); }

.wall-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 1rem 1.25rem;
  align-items: start;
}

.wall-layout.has-sidebar {
  grid-template-columns: minmax(0, 1fr) 16rem;
}

.wall-layout.has-sidebar .wall-column { grid-column: 1; grid-row: 1; }
.wall-layout.has-sidebar .tag-sidebar { grid-column: 2; grid-row: 1 / span 2; }
.wall-layout.has-sidebar .composer { grid-column: 1; grid-row: 2; }

.tag-sidebar {
  background: rgba(255, 248, 230, 0.5);
  padding: 0.85rem 0.8rem 1rem;
  box-shadow: var(--paper-shadow);
  position: sticky;
  top: 0.75rem;
}

.note-search {
  display: grid;
  gap: 0.35rem;
  margin: 0 0 0.85rem;
}

.note-search label {
  font-family: var(--sans);
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}

.note-search input {
  width: 100%;
  min-height: 44px;
  border: 1px solid rgba(42, 33, 24, 0.25);
  border-radius: 0.45rem;
  background: #fff;
  color: var(--ink);
  font-family: var(--sans);
  font-size: 1rem;
  padding: 0.4rem 0.6rem;
}

.note-search button {
  justify-self: start;
  border: none;
  background: var(--ink);
  color: #fff8e6;
  border-radius: 999px;
  min-height: 44px;
  padding: 0.45rem 0.9rem;
  font-family: var(--sans);
  font-size: 0.9rem;
  cursor: pointer;
}

.search-status {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.5rem;
  margin: -0.35rem 0 0.85rem;
  font-family: var(--sans);
  font-size: 0.85rem;
  overflow-wrap: anywhere;
}

.search-clear {
  flex: none;
  text-decoration: none;
  font-size: 1.25rem;
  line-height: 1;
  min-width: 44px;
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.tag-sidebar h2 {
  margin: 0 0 0.55rem;
  font-family: var(--sans);
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}

.tag-sidebar nav {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.tag-sidebar .tag {
  justify-content: space-between;
  border-radius: 0.45rem;
}

.sort-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin: 0 0 1rem;
}

.sort-bar a {
  font-family: var(--sans);
  font-size: 0.9rem;
  text-decoration: none;
  background: rgba(255, 248, 230, 0.55);
  border-radius: 999px;
  padding: 0.4rem 0.8rem;
  min-height: 44px;
  display: inline-flex;
  align-items: center;
}

.sort-bar a.is-active {
  background: var(--ink);
  color: #fff8e6;
}

main {
  width: min(1100px, calc(100% - 1.5rem));
  margin: 1rem auto 2rem;
}

.composer-jump {
  margin: 0 0 0.65rem;
  text-align: end;
  font-family: var(--sans);
  font-size: 0.9rem;
}

.composer {
  background: #fff4c2;
  padding: 1rem 1rem 1.1rem;
  box-shadow: var(--paper-shadow);
  margin-bottom: 1.25rem;
}

.wall-layout .composer {
  margin-top: 1.25rem;
  margin-bottom: 0;
  scroll-margin-top: 1rem;
}

.composer h2,
.note h2 {
  margin: 0 0 0.4rem;
  font-family: var(--hand);
  font-weight: 700;
  line-height: 1.05;
}

.composer h2 { font-size: 2rem; }

.composer form { display: grid; }

.composer label {
  margin-top: 0.55rem;
  font-family: var(--sans);
  font-size: 0.78rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
}

.composer input,
.composer textarea {
  width: 100%;
  border: none;
  border-bottom: 1px solid rgba(42, 33, 24, 0.2);
  background: rgba(255, 255, 255, 0.35);
  color: var(--ink);
  font-family: var(--hand);
  font-size: 1.45rem;
  padding: 0.35rem 0.4rem 0.2rem;
}

.composer textarea { min-height: 7.5rem; resize: vertical; }

.composer input.hp,
.comment-composer input.hp {
  position: absolute;
  left: -10000px;
  width: 1px;
  height: 1px;
  overflow: hidden;
  padding: 0;
  border: 0;
}

.hint,
.errorlist {
  margin: 0.25rem 0 0;
  font-family: var(--sans);
  font-size: 0.82rem;
}

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

.char-count {
  text-align: right;
  margin-top: 0.15rem;
}

.errorlist {
  list-style: none;
  padding: 0;
  color: #8c1d18;
}

.submit,
.vote {
  font-family: var(--sans);
  cursor: pointer;
}

.submit {
  justify-self: start;
  margin-top: 0.9rem;
  border: none;
  background: var(--ink);
  color: #fff8e6;
  border-radius: 999px;
  padding: 0.7rem 1.1rem;
  font-size: 0.95rem;
  min-height: 44px;
}

.filter-banner,
.empty,
.pager,
.site-footer {
  font-family: var(--sans);
}

.filter-banner,
.empty {
  text-align: center;
  margin: 0 0 1rem;
}

.wall {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 1.35rem 1rem;
  align-items: start;
  padding-top: 0.6rem;
}

.note {
  --paper: #ffe792;
  background: var(--paper);
  min-height: 210px;
  padding: 1rem 0.95rem 0.75rem;
  box-shadow: var(--paper-shadow);
  transform: rotate(var(--tilt));
  display: flex;
  flex-direction: column;
  position: relative;
}

.note::before {
  content: "";
  position: absolute;
  top: -9px;
  left: 50%;
  width: 58px;
  height: 14px;
  transform: translateX(-50%) rotate(-1.5deg);
  background: rgba(255, 255, 255, 0.48);
  box-shadow: 0 1px 1px rgba(0, 0, 0, 0.08);
}

.color-0 { --paper: #ffe792; }
.color-1 { --paper: #ffc8d8; }
.color-2 { --paper: #bff3d4; }
.color-3 { --paper: #c9e6ff; }
.color-4 { --paper: #ffd7b0; }
.color-5 { --paper: #e3d4ff; }

.note h2 {
  font-size: 1.85rem;
  overflow-wrap: anywhere;
}

.message {
  margin: 0;
  font-family: var(--hand);
  font-size: 1.35rem;
  line-height: 1.25;
  overflow-wrap: anywhere;
  flex: 1;
}

.note-embed {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  margin-top: 0.75rem;
  background: rgba(42, 33, 24, 0.08);
  overflow: hidden;
  flex: none;
}

.note-embed iframe {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 0;
}

.embed-original {
  margin: 0.35rem 0 0;
  font-family: var(--sans);
  font-size: 0.78rem;
}

.read-more {
  margin: 0.35rem 0 0;
  font-family: var(--sans);
  font-size: 0.78rem;
}

.read-more a { color: inherit; }

.note-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  list-style: none;
  margin: 0.7rem 0 0;
  padding: 0;
}

.note-tags a {
  font-family: var(--sans);
  font-size: 0.78rem;
  text-decoration: none;
  background: rgba(255, 255, 255, 0.45);
  border-radius: 999px;
  padding: 0.15rem 0.45rem;
}

.note footer {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 0.5rem;
  margin-top: 0.8rem;
  flex-wrap: wrap;
}

.note-meta {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  min-width: 0;
}

.comment-link {
  font-family: var(--sans);
  font-size: 0.78rem;
  text-decoration: none;
}

.note time {
  font-family: var(--sans);
  font-size: 0.72rem;
  color: var(--muted);
}

.votes { display: flex; gap: 0.35rem; flex-wrap: wrap; }

.comment .votes { margin-top: 0.45rem; }

.vote {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  min-height: 40px;
  min-width: 44px;
  padding: 0.2rem 0.5rem;
  border: 1px solid rgba(42, 33, 24, 0.18);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.45);
  color: var(--ink);
  font-size: 0.9rem;
}

.vote.is-mine {
  background: var(--ink);
  color: #fff8e6;
  border-color: var(--ink);
}

.pager {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 1rem;
  margin-top: 1.4rem;
}

.pager a { text-underline-offset: 0.15em; }

.site-footer {
  text-align: center;
  padding: 0 1rem 2rem;
  color: var(--muted);
  font-size: 0.82rem;
}

.site-footer p { margin: 0 auto; max-width: 36rem; }

.note-page {
  width: min(40rem, 100%);
  margin: 0 auto;
}

.note-page .note {
  transform: none;
  min-height: 0;
}

.back-link,
.comments h2,
.comment-label,
.already {
  font-family: var(--sans);
}

.back-link { margin: 0 0 0.8rem; }

.comments { margin-top: 1.5rem; }

.comments h2 {
  margin: 0 0 0.35rem;
  font-size: 1.1rem;
  font-weight: 600;
}

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

.already {
  background: rgba(255, 248, 230, 0.72);
  padding: 0.7rem 0.85rem;
  margin: 0.8rem 0;
}

.comment-list {
  list-style: none;
  margin: 0.8rem 0 0;
  padding: 0;
  display: grid;
  gap: 0.7rem;
}

.comment {
  background: rgba(255, 248, 230, 0.78);
  padding: 0.8rem 0.9rem;
  box-shadow: var(--paper-shadow);
}

.comment.is-mine {
  outline: 2px solid rgba(42, 33, 24, 0.35);
}

.comment-label {
  margin: 0 0 0.25rem;
  font-size: 0.75rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
}

.comment-body {
  margin: 0 0 0.45rem;
  font-family: var(--hand);
  font-size: 1.35rem;
  line-height: 1.3;
  overflow-wrap: anywhere;
}

.note h2 a { text-decoration: none; }

button:focus-visible,
a:focus-visible,
input:focus-visible,
textarea:focus-visible {
  outline: 2px solid var(--ink);
  outline-offset: 2px;
}

@media (max-width: 800px) {
  .wall-layout.has-sidebar { grid-template-columns: 1fr; }
  .wall-layout.has-sidebar .composer,
  .wall-layout.has-sidebar .tag-sidebar,
  .wall-layout.has-sidebar .wall-column {
    grid-column: 1;
    grid-row: auto;
  }
  .tag-sidebar { position: static; }
  .tag-sidebar nav {
    flex-direction: row;
    flex-wrap: wrap;
  }
}

@media (max-width: 640px) {
  .note { transform: none; }
  .wall { grid-template-columns: 1fr; }
  .site-header { padding-top: 1.2rem; }
}

@media (prefers-reduced-motion: reduce) {
  .note { transform: none; }
}

@media (hover: hover) and (prefers-reduced-motion: no-preference) {
  .note { transition: transform 160ms ease; }
  .note:hover { transform: rotate(var(--tilt)) translateY(-3px); }
  .note-page .note:hover { transform: none; }
}
