:root {
  --bg: #fbfaf8;
  --surface: #ffffff;
  --text: #20201f;
  --muted: #73706b;
  --line: #e8e4de;
  --accent: #6f2438;
  --accent-soft: #f4eaed;
  --reader-width: 720px;
  --shadow: 0 12px 30px rgba(34, 28, 24, 0.08);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}
a { color: inherit; text-decoration: none; }
button, input, textarea { font: inherit; }
button { color: inherit; }

.home-header {
  max-width: 1180px;
  margin: 0 auto;
  padding: 34px 28px 24px;
}
.brand {
  display: inline-block;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 30px;
  font-weight: 700;
  letter-spacing: -0.5px;
}
.brand-small { font-size: 22px; }

.library {
  max-width: 1180px;
  margin: 0 auto;
  padding: 8px 28px 72px;
}
.category-section { margin: 32px 0 60px; scroll-margin-top: 20px; }
.category-heading {
  display: flex;
  align-items: center;
  gap: 18px;
  margin-bottom: 20px;
}
.category-heading h2 {
  margin: 0;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 27px;
  font-weight: 600;
}
.category-heading::after {
  content: "";
  height: 1px;
  flex: 1;
  background: var(--line);
}
.story-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 34px 24px;
}
.story-card { min-width: 0; }
.cover-link { display: block; }
.story-cover {
  display: block;
  width: 100%;
  aspect-ratio: 2 / 3;
  object-fit: cover;
  border-radius: 3px;
  box-shadow: 0 8px 22px rgba(37, 30, 25, .08);
  transition: transform .18s ease, box-shadow .18s ease;
}
.story-card:hover .story-cover {
  transform: translateY(-3px);
  box-shadow: 0 13px 28px rgba(37, 30, 25, .13);
}
.story-card h3 {
  margin: 15px 0 6px;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 18px;
  line-height: 1.28;
}
.story-card p {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.55;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.site-footer {
  border-top: 1px solid var(--line);
  padding: 26px;
  text-align: center;
  color: var(--muted);
  font-size: 13px;
}

.reader-toolbar {
  position: sticky;
  top: 0;
  z-index: 20;
  height: 58px;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  padding: 0 22px;
  background: color-mix(in srgb, var(--bg) 92%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.reader-toolbar > .brand { grid-column: 2; }
.reader-actions { justify-self: end; display: flex; align-items: center; gap: 8px; }
.icon-button, .text-button {
  border: 0;
  background: transparent;
  cursor: pointer;
  min-width: 38px;
  height: 38px;
  border-radius: 50%;
}
.icon-button:hover, .text-button:hover { background: rgba(127,127,127,.1); }
.menu-button { justify-self: start; font-size: 19px; }
.text-button { font-family: Georgia, serif; font-weight: 700; }

.reader-shell { padding: 58px 24px 90px; }
.story-article { max-width: var(--reader-width); margin: 0 auto; }
.story-head { text-align: center; margin-bottom: 52px; }
.story-head h1 {
  margin: 0 0 14px;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(34px, 5vw, 48px);
  line-height: 1.12;
  letter-spacing: -0.8px;
}
.story-tags {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 14px;
}
.story-tag {
  padding: 5px 10px;
  background: var(--accent-soft);
  color: var(--accent);
  border-radius: 999px;
  font-size: 12px;
  font-weight: 650;
}
.story-meta { color: var(--muted); font-size: 13px; }
.story-body {
  font-family: Georgia, "Times New Roman", serif;
  font-size: var(--story-font-size, 20px);
  line-height: 1.86;
}
.story-body section { scroll-margin-top: 88px; }
.story-body h2 {
  margin: 54px 0 24px;
  font-size: 23px;
  line-height: 1.25;
  text-align: center;
  font-weight: 600;
}
.story-body p { margin: 0 0 1.25em; }
.story-divider { width: 60px; margin: 44px auto; border: 0; border-top: 1px solid var(--line); }

.engagement { max-width: var(--reader-width); margin: 74px auto 0; border-top: 1px solid var(--line); }
.rating-panel { padding: 54px 0; text-align: center; border-bottom: 1px solid var(--line); }
.rating-panel h2, .comments-panel h2 {
  margin: 0 0 22px;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 22px;
  font-weight: 600;
}
.stars { display: flex; justify-content: center; gap: 9px; margin-bottom: 12px; }
.star {
  border: 0;
  padding: 0;
  background: transparent;
  font-size: 34px;
  line-height: 1;
  cursor: pointer;
  color: #aaa49b;
}
.star.active, .star:hover { color: #b78a2b; }
.rating-summary, .form-message { color: var(--muted); font-size: 13px; }
.form-message { min-height: 20px; margin-top: 10px; }

.comments-panel { padding: 54px 0; }
.comment {
  padding: 21px 0;
  border-bottom: 1px solid var(--line);
}
.comment:first-child { padding-top: 0; }
.comment-head { display: flex; justify-content: space-between; gap: 18px; margin-bottom: 8px; }
.comment-name { font-weight: 650; }
.comment-time { color: var(--muted); font-size: 12px; white-space: nowrap; }
.comment-body { color: #3e3c39; line-height: 1.65; white-space: pre-wrap; overflow-wrap: anywhere; }
.empty-comments { color: var(--muted); padding: 6px 0 24px; }
.comment-form { margin-top: 34px; display: grid; gap: 16px; }
.comment-form label { display: grid; gap: 7px; }
.comment-form label span { font-size: 13px; color: var(--muted); }
.comment-form input, .comment-form textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface);
  color: var(--text);
  padding: 12px 13px;
  outline: none;
}
.comment-form input:focus, .comment-form textarea:focus { border-color: #aaa39a; }
.comment-form textarea { resize: vertical; }
.post-button {
  justify-self: start;
  border: 0;
  background: var(--text);
  color: var(--bg);
  border-radius: 5px;
  padding: 10px 18px;
  cursor: pointer;
}
.category-back { display: inline-block; color: var(--muted); font-size: 14px; margin-top: 8px; }
.category-back:hover { color: var(--text); }
.hp-field { position: absolute !important; left: -9999px !important; width: 1px !important; height: 1px !important; opacity: 0 !important; }

.drawer {
  position: fixed;
  z-index: 50;
  inset: 0 auto 0 0;
  width: min(330px, 88vw);
  background: var(--surface);
  border-right: 1px solid var(--line);
  padding: 20px 22px 30px;
  transform: translateX(-103%);
  transition: transform .2s ease;
  overflow-y: auto;
}
.drawer.open { transform: translateX(0); }
.drawer-backdrop {
  position: fixed;
  z-index: 45;
  inset: 0;
  background: rgba(15, 15, 15, .24);
}
.drawer-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 34px; }
.drawer-head .icon-button { font-size: 26px; }
.drawer-block { margin-bottom: 30px; }
.drawer-title { margin-bottom: 11px; color: var(--muted); text-transform: uppercase; font-size: 11px; letter-spacing: .09em; }
.toc, .browse-links { display: grid; }
.toc a, .browse-links a { padding: 8px 0; font-size: 14px; color: #4e4b47; }
.toc a:hover, .browse-links a:hover, .back-home:hover { color: var(--accent); }
.back-home { color: var(--muted); font-size: 13px; }

body.dark {
  --bg: #181817;
  --surface: #212120;
  --text: #edeae4;
  --muted: #a9a49b;
  --line: #373431;
  --accent: #e3a2b4;
  --accent-soft: #37242a;
  --shadow: none;
}
body.dark .comment-body { color: #d3cfc8; }

@media (max-width: 850px) {
  .story-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 30px 18px; }
  .home-header { padding: 26px 18px 16px; }
  .library { padding: 0 18px 56px; }
  .category-section { margin: 28px 0 48px; }
  .category-heading h2 { font-size: 24px; }
}

@media (max-width: 520px) {
  .brand { font-size: 27px; }
  .brand-small { font-size: 20px; }
  .story-card h3 { font-size: 16px; }
  .story-card p { font-size: 13px; -webkit-line-clamp: 2; }
  .reader-toolbar { padding: 0 10px; }
  .reader-shell { padding: 42px 20px 68px; }
  .story-head { margin-bottom: 40px; }
  .story-body { line-height: 1.78; }
  .engagement { margin-top: 58px; }
}
