@import url("https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&family=Noto+Serif:wght@700&display=swap");

:root {
  --bg: #f4f1ea;
  --paper: #fffdf8;
  --paper-deep: #ebe4d7;
  --ink: #25211b;
  --muted: #6f6658;
  --line: #d8cfbf;
  --red: #b64232;
  --green: #28785b;
  --blue: #326b9d;
  --gold: #d19a2b;
  --shadow: 0 18px 40px rgba(62, 49, 31, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  color: var(--ink);
  background:
    linear-gradient(rgba(255, 255, 255, 0.72), rgba(255, 255, 255, 0.72)),
    repeating-linear-gradient(0deg, transparent 0 31px, rgba(90, 72, 42, 0.06) 32px),
    var(--bg);
  font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

a {
  color: inherit;
  text-decoration: none;
}

button,
input {
  font: inherit;
}

.notice {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 18px;
  padding: 12px max(20px, calc((100vw - 1180px) / 2));
  background: #30291f;
  color: #fff7e7;
  font-size: 14px;
}

.notice strong {
  color: #ffd26a;
}

.icon-button {
  width: 30px;
  height: 30px;
  border: 1px solid rgba(255, 255, 255, 0.28);
  border-radius: 50%;
  background: transparent;
  color: #fff7e7;
  cursor: pointer;
}

.site-header,
.layout,
.footer {
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
}

.site-header {
  display: grid;
  grid-template-columns: minmax(260px, 1fr) auto auto;
  gap: 24px;
  align-items: center;
  padding: 24px 0 18px;
}

.brand {
  display: flex;
  gap: 12px;
  align-items: center;
}

.brand-mark {
  width: 46px;
  height: 46px;
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 4px;
  padding: 6px;
  border: 2px solid var(--ink);
  background: var(--paper);
  box-shadow: 5px 5px 0 var(--gold);
}

.brand-mark span {
  background: var(--red);
}

.brand-mark span:nth-child(2) {
  background: var(--blue);
}

.brand-mark span:nth-child(3) {
  background: var(--green);
}

.brand-mark span:nth-child(4) {
  background: var(--gold);
}

.brand strong {
  display: block;
  font-family: "Noto Serif", Georgia, serif;
  font-size: 28px;
  line-height: 1;
}

.brand small {
  display: block;
  margin-top: 5px;
  color: var(--muted);
  font-size: 12px;
}

.top-nav,
.account-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.account-name {
  display: inline-flex;
  align-items: center;
  min-height: 40px;
  border: 1px solid rgba(40, 120, 91, 0.35);
  border-radius: 6px;
  background: #dce9e4;
  color: var(--green);
  font-weight: 800;
  padding: 8px 12px;
}

.top-nav a,
.text-button {
  padding: 9px 11px;
  border-radius: 6px;
  color: var(--muted);
  background: transparent;
  border: 0;
  cursor: pointer;
}

.top-nav a:hover,
.text-button:hover {
  color: var(--ink);
  background: rgba(255, 255, 255, 0.64);
}

.primary-button,
.subscribe button {
  border: 0;
  border-radius: 6px;
  background: var(--red);
  color: #fffdf8;
  padding: 10px 14px;
  font-weight: 700;
  cursor: pointer;
}

.layout {
  display: grid;
  grid-template-columns: 260px minmax(0, 1fr);
  gap: 28px;
  align-items: start;
  padding-bottom: 36px;
}

.sidebar {
  position: sticky;
  top: 16px;
  display: grid;
  gap: 16px;
}

.side-block {
  border: 1px solid var(--line);
  background: rgba(255, 253, 248, 0.78);
  border-radius: 8px;
  padding: 16px;
  box-shadow: 0 8px 20px rgba(62, 49, 31, 0.06);
}

.side-block h2 {
  margin: 0 0 12px;
  font-size: 15px;
  text-transform: uppercase;
  color: var(--muted);
}

.link-stack,
.category-list,
.compact {
  display: grid;
  gap: 7px;
}

.side-link,
.category-list a,
.compact a {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  border: 0;
  border-radius: 6px;
  padding: 9px 10px;
  background: transparent;
  color: var(--ink);
  text-align: left;
  cursor: pointer;
}

.side-link:hover,
.category-list a:hover,
.compact a:hover {
  background: #f3ead9;
}

.side-link.active,
.category-list a.current {
  background: var(--ink);
  color: var(--paper);
}

.category-list b {
  color: var(--muted);
}

.category-list .current b {
  color: #f2d38e;
}

.content {
  min-width: 0;
}

.category-hero {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 260px;
  gap: 24px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--paper);
  box-shadow: var(--shadow);
  padding: 28px;
}

.kicker {
  margin: 0 0 8px;
  color: var(--green);
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: 12px;
}

h1 {
  margin: 0 0 12px;
  font-family: "Noto Serif", Georgia, serif;
  font-size: 46px;
  line-height: 1.05;
}

h1 span {
  color: var(--red);
}

.category-hero p:last-child {
  max-width: 660px;
  margin: 0;
  color: var(--muted);
  line-height: 1.65;
}

.logic-art {
  position: relative;
  height: 180px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background:
    linear-gradient(90deg, rgba(50, 107, 157, 0.07) 1px, transparent 1px),
    linear-gradient(0deg, rgba(50, 107, 157, 0.07) 1px, transparent 1px),
    #faf6ed;
  background-size: 22px 22px;
  overflow: hidden;
}

.logic-art svg {
  position: absolute;
  inset: 10px;
  width: calc(100% - 20px);
  height: calc(100% - 20px);
  fill: none;
  stroke: var(--blue);
  stroke-width: 5;
  stroke-linecap: round;
}

.node {
  position: absolute;
  z-index: 1;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 3px solid var(--paper);
  box-shadow: 0 8px 16px rgba(62, 49, 31, 0.16);
}

.node.one { left: 34px; top: 92px; background: var(--red); }
.node.two { left: 74px; top: 36px; background: var(--gold); }
.node.three { right: 62px; top: 104px; background: var(--green); }
.node.four { right: 28px; top: 68px; background: var(--blue); }

.toolbar {
  display: flex;
  justify-content: space-between;
  align-items: end;
  gap: 16px;
  margin: 18px 0;
}

.toolbar[hidden] {
  display: none;
}

.search {
  display: grid;
  gap: 6px;
  width: min(420px, 100%);
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.search input,
.subscribe input {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--paper);
  padding: 11px 12px;
  color: var(--ink);
}

.stats {
  display: flex;
  align-items: baseline;
  gap: 8px;
  color: var(--muted);
}

.stats strong {
  color: var(--red);
  font-size: 30px;
}

.puzzle-list {
  display: grid;
  gap: 14px;
}

.puzzle-card {
  display: grid;
  grid-template-columns: 92px minmax(0, 1fr);
  gap: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 253, 248, 0.92);
  padding: 18px;
  box-shadow: 0 10px 22px rgba(62, 49, 31, 0.08);
}

.puzzle-rank {
  display: grid;
  place-items: center;
  align-content: center;
  gap: 8px;
  border-radius: 6px;
  background: var(--paper-deep);
  min-height: 120px;
}

.puzzle-rank strong {
  font-size: 34px;
}

.puzzle-rank span {
  color: var(--muted);
  font-size: 12px;
}

.puzzle-head {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  align-items: start;
}

.puzzle-title {
  margin: 0;
  font-size: 23px;
}

.new-badge,
.tag {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  border-radius: 999px;
  padding: 3px 9px;
  font-size: 12px;
  font-weight: 800;
}

.new-badge {
  background: #f4d27b;
  color: #5b3a00;
}

.tag {
  margin-top: 9px;
  background: #dce9e4;
  color: var(--green);
}

.puzzle-text {
  margin: 14px 0;
  color: #3c362e;
  line-height: 1.62;
}

mark {
  border-radius: 4px;
  background: #ffe38c;
  color: inherit;
  padding: 0 2px;
}

.meta-row,
.card-actions {
  display: flex;
  gap: 14px;
  align-items: center;
  flex-wrap: wrap;
  color: var(--muted);
  font-size: 14px;
}

.meta-row b {
  color: var(--ink);
}

.card-actions {
  margin-top: 16px;
}

.card-actions button {
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fffaf0;
  color: var(--ink);
  padding: 8px 10px;
  cursor: pointer;
}

.card-actions button:hover {
  border-color: var(--red);
  color: var(--red);
}

.card-actions .like-button {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: #fffaf0;
  border-color: var(--line);
  color: var(--ink);
  font-weight: 800;
}

.card-actions .like-button:hover,
.card-actions .like-button.liked {
  border-color: var(--red);
  color: var(--red);
}

.heart-icon {
  color: var(--red);
  font-size: 18px;
  line-height: 1;
}

.discussion-view {
  display: grid;
  gap: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 253, 248, 0.92);
  padding: 16px;
  box-shadow: 0 10px 22px rgba(62, 49, 31, 0.08);
}

.discussion-topbar {
  display: flex;
  justify-content: flex-start;
}

.back-button,
.message-composer button {
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fffaf0;
  color: var(--ink);
  padding: 9px 12px;
  cursor: pointer;
  font-weight: 700;
}

.messages-feed {
  display: grid;
  gap: 10px;
  max-height: 560px;
  overflow-y: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background:
    linear-gradient(rgba(255, 255, 255, 0.56), rgba(255, 255, 255, 0.56)),
    repeating-linear-gradient(135deg, rgba(50, 107, 157, 0.08) 0 1px, transparent 1px 18px),
    #f4ead8;
  padding: 16px;
}

.message-row {
  display: flex;
}

.message-row.incoming {
  justify-content: flex-start;
}

.message-row.outgoing {
  justify-content: flex-end;
}

.message-bubble {
  max-width: min(620px, 88%);
  border-radius: 8px;
  padding: 11px 13px;
  box-shadow: 0 5px 12px rgba(62, 49, 31, 0.08);
}

.incoming .message-bubble {
  background: var(--paper);
  border: 1px solid var(--line);
}

.outgoing .message-bubble {
  background: #dce9e4;
  border: 1px solid rgba(40, 120, 91, 0.24);
}

.message-bubble strong {
  display: block;
  margin-bottom: 6px;
}

.message-author {
  color: var(--green);
  font-size: 13px;
}

.message-bubble p {
  margin: 0;
  line-height: 1.55;
}

.message-bubble time {
  display: block;
  margin-top: 7px;
  color: var(--muted);
  font-size: 12px;
  text-align: right;
}

.message-composer {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
}

.message-composer input {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--paper);
  padding: 11px 12px;
  color: var(--ink);
}

.suggestion-panel {
  margin-top: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 253, 248, 0.92);
  padding: 18px;
  box-shadow: 0 10px 22px rgba(62, 49, 31, 0.08);
}

.suggestion-form {
  display: grid;
  gap: 14px;
}

.suggestion-form label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.suggestion-form input,
.suggestion-form textarea,
.suggestion-form select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--paper);
  color: var(--ink);
  padding: 11px 12px;
}

.suggestion-form textarea {
  resize: vertical;
  min-height: 150px;
}

.suggestion-grid {
  display: grid;
  grid-template-columns: minmax(120px, 0.35fr) minmax(220px, 0.65fr);
  gap: 14px;
}

.suggestion-form button {
  justify-self: start;
  border: 0;
  border-radius: 6px;
  background: var(--red);
  color: var(--paper);
  padding: 10px 14px;
  font-weight: 800;
  cursor: pointer;
}

.suggestion-status {
  min-height: 24px;
  margin: 0;
  color: var(--green);
  font-weight: 800;
}

.pagination {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 20px;
}

.page-button {
  min-width: 38px;
  height: 38px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--paper);
  cursor: pointer;
}

.page-button.active {
  background: var(--ink);
  color: var(--paper);
}

.footer {
  display: flex;
  gap: 16px;
  align-items: center;
  flex-wrap: wrap;
  border-top: 1px solid var(--line);
  padding: 22px 0 34px;
  color: var(--muted);
}

.footer a:hover {
  color: var(--red);
}

.subscribe {
  margin-left: auto;
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}

.subscribe input {
  width: 180px;
}

@media (max-width: 920px) {
  .site-header {
    grid-template-columns: 1fr;
  }

  .layout {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .side-block:first-child {
    grid-column: 1 / -1;
  }

  .category-hero {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 640px) {
  .notice,
  .toolbar,
  .puzzle-head,
  .footer,
  .subscribe {
    align-items: stretch;
    flex-direction: column;
  }

  .sidebar {
    grid-template-columns: 1fr;
  }

  .category-hero {
    padding: 20px;
  }

  h1 {
    font-size: 36px;
  }

  .puzzle-card {
    grid-template-columns: 1fr;
  }

  .puzzle-rank {
    min-height: 70px;
    grid-template-columns: auto auto;
    justify-content: start;
    padding: 12px;
  }

  .subscribe {
    margin-left: 0;
  }

  .subscribe input {
    width: 100%;
  }

  .suggestion-grid {
    grid-template-columns: 1fr;
  }
}
