:root {
  color-scheme: light;
  --bg: #f7f4ed;
  --surface: #fffdf8;
  --surface-strong: #ffffff;
  --ink: #2f3136;
  --muted: #73706a;
  --line: #e4ddd1;
  --accent: #6f7f55;
  --accent-ink: #f9fbf2;
  --accent-soft: #eaf0df;
  --warn: #ba6b3a;
  --shadow: 0 20px 50px rgba(74, 66, 54, 0.09);
  --radius: 8px;
  --font-sans: "Inter", "Microsoft YaHei", "PingFang SC", system-ui, sans-serif;
  --font-serif: Georgia, "Times New Roman", "Songti SC", serif;
}

body[data-theme="journal"] {
  --bg: #f4f8fb;
  --surface: #ffffff;
  --surface-strong: #fdfefe;
  --ink: #26333d;
  --muted: #687985;
  --line: #dbe6ed;
  --accent: #4b7f9d;
  --accent-ink: #ffffff;
  --accent-soft: #e7f2f8;
  --warn: #a86b2a;
  --shadow: 0 18px 45px rgba(42, 78, 101, 0.11);
}

body[data-theme="rose"] {
  --bg: #fff5f8;
  --surface: #fffafd;
  --surface-strong: #ffffff;
  --ink: #342631;
  --muted: #7e6877;
  --line: #efd8e4;
  --accent: #c65b8a;
  --accent-ink: #ffffff;
  --accent-soft: #f8ddea;
  --warn: #a86b2a;
  --shadow: 0 20px 52px rgba(153, 73, 115, 0.11);
}

body[data-theme="brownrose"] {
  --bg: #fff7f2;
  --surface: #fffdfb;
  --surface-strong: #ffffff;
  --ink: #3a2b2a;
  --muted: #846f69;
  --line: #ead8ce;
  --accent: #a96f73;
  --accent-ink: #ffffff;
  --accent-soft: #f7e1dc;
  --warn: #9a633c;
  --shadow: 0 20px 52px rgba(117, 70, 61, 0.11);
}

body[data-theme="nightlibrary"] {
  color-scheme: dark;
  --bg: #0f1720;
  --surface: #16202b;
  --surface-strong: #1c2935;
  --ink: #eef5f8;
  --muted: #9fb1bd;
  --line: #263848;
  --accent: #7fb2d4;
  --accent-ink: #07111a;
  --accent-soft: #1d3443;
  --warn: #d7b56d;
  --shadow: 0 22px 56px rgba(2, 7, 12, 0.28);
  background:
    linear-gradient(180deg, rgba(127, 178, 212, 0.12), rgba(15, 23, 32, 0) 300px),
    var(--bg);
}

body[data-theme="garden"] {
  --bg: #f8f7f1;
  --surface: #ffffff;
  --surface-strong: #fffefa;
  --ink: #29332c;
  --muted: #697267;
  --line: #dfe5d8;
  --accent: #477c67;
  --accent-ink: #ffffff;
  --accent-soft: #e7f2ec;
  --warn: #a16942;
  --shadow: 0 20px 52px rgba(56, 92, 72, 0.1);
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-width: 320px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.62), rgba(255, 255, 255, 0) 280px),
    var(--bg);
  color: var(--ink);
  font-family: var(--font-sans);
  letter-spacing: 0;
}

button,
input,
select,
textarea {
  font: inherit;
}

button,
a {
  -webkit-tap-highlight-color: transparent;
}

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

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: grid;
  grid-template-columns: auto 1fr minmax(220px, 340px);
  gap: 22px;
  align-items: center;
  padding: 16px clamp(18px, 4vw, 48px);
  border-bottom: 1px solid color-mix(in srgb, var(--line) 82%, transparent);
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  backdrop-filter: blur(14px);
}

.brand,
.nav,
.search,
.theme-actions,
.section-heading,
.post-meta,
.post-tags,
.resource-meta,
.plan-item,
.progress-panel {
  display: flex;
  align-items: center;
}

.brand {
  gap: 10px;
  font-weight: 800;
  white-space: nowrap;
}

.brand-mark {
  width: 24px;
  height: 24px;
  border: 7px solid var(--accent);
  border-radius: 50%;
  box-shadow: inset 0 0 0 4px var(--surface);
}

.nav {
  gap: 6px;
  justify-content: center;
}

.nav a,
.theme-button,
.filter-list button {
  min-height: 36px;
  border: 1px solid transparent;
  border-radius: 999px;
  padding: 8px 14px;
  color: var(--muted);
  background: transparent;
  cursor: pointer;
}

.nav a.active,
.nav a:hover,
.theme-button.active,
.theme-button:hover,
.filter-list button.active,
.filter-list button:hover {
  border-color: var(--line);
  background: var(--surface-strong);
  color: var(--ink);
}

.search {
  gap: 10px;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0 14px;
  background: var(--surface-strong);
}

.search-icon {
  width: 13px;
  height: 13px;
  border: 2px solid var(--muted);
  border-radius: 50%;
  position: relative;
  flex: 0 0 auto;
}

.search-icon::after {
  content: "";
  position: absolute;
  width: 7px;
  height: 2px;
  right: -6px;
  bottom: -4px;
  border-radius: 3px;
  background: var(--muted);
  transform: rotate(45deg);
}

.search input {
  width: 100%;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--ink);
}

main {
  width: min(1062px, calc(100% - 44px));
  margin: 0 auto;
  padding: 27px 0 54px;
}

body[data-route="post"] main {
  width: min(1380px, calc(100% - 32px));
}

body[data-route="writer"] main {
  width: min(1420px, calc(100% - 32px));
}

.theme-strip {
  display: flex;
  justify-content: space-between;
  gap: 24px;
  align-items: end;
  margin-bottom: 30px;
  padding: 36px 0 28px;
}

.theme-strip h1,
.page-head h2,
.section-heading h2,
.profile-panel h2,
.filter-panel h2,
.post-card h3,
.reader h1,
.reader h2,
.reader h3 {
  margin: 0;
}

.theme-strip h1 {
  max-width: 760px;
  font-family: "Bodoni 72", Didot, "Playfair Display", Georgia, var(--font-serif);
  font-size: clamp(2.9rem, 8.1vw, 6.7rem);
  font-weight: 900;
  line-height: 0.88;
  color: transparent;
  background:
    linear-gradient(110deg, #18364f 0%, var(--accent) 42%, #9f7aea 72%, #d88fbc 100%);
  -webkit-background-clip: text;
  background-clip: text;
  text-wrap: balance;
}

body[data-theme="atelier"] .theme-strip h1 {
  background:
    linear-gradient(110deg, #2f3136 0%, #6f7f55 48%, #d69d59 100%);
  -webkit-background-clip: text;
  background-clip: text;
}

body[data-theme="garden"] .theme-strip h1 {
  background:
    linear-gradient(110deg, #18362c 0%, #477c67 48%, #8cba7a 100%);
  -webkit-background-clip: text;
  background-clip: text;
}

body[data-theme="rose"] .theme-strip h1 {
  background:
    linear-gradient(112deg, #5c2342 0%, #c65b8a 42%, #eaa6c4 70%, #f2c66d 100%);
  -webkit-background-clip: text;
  background-clip: text;
}

body[data-theme="brownrose"] .theme-strip h1 {
  background:
    linear-gradient(112deg, #49312e 0%, #a96f73 52%, #d4a55f 100%);
  -webkit-background-clip: text;
  background-clip: text;
}

body[data-theme="nightlibrary"] .theme-strip h1 {
  background:
    linear-gradient(112deg, #f0f7fb 0%, #7fb2d4 56%, #d7b56d 100%);
  -webkit-background-clip: text;
  background-clip: text;
}

.hero-copy p {
  margin: 18px 0 0;
  color: var(--muted);
  font-family: "Trebuchet MS", var(--font-sans);
  font-size: clamp(1rem, 2vw, 1.35rem);
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: lowercase;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--accent);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.theme-actions {
  display: grid;
  width: min(320px, 100%);
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.theme-button {
  width: 100%;
  background: var(--surface);
}

.view {
  display: none;
}

.view.active {
  display: block;
}

.home-grid {
  display: grid;
  grid-template-columns: minmax(260px, 340px) 1fr;
  gap: 24px;
  align-items: start;
}

.left-rail,
.studio-grid,
.plan-grid,
.resources-layout,
.content-layout {
  display: grid;
  gap: 18px;
}

.profile-panel,
.taxonomy-panel,
.friends-panel,
.recent-panel,
.filter-panel,
.editor-panel,
.preview-panel,
.progress-panel,
.reader,
.resource-card,
.post-card,
.plan-item {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.profile-panel,
.taxonomy-panel,
.friends-panel,
.recent-panel,
.filter-panel,
.editor-panel,
.preview-panel,
.progress-panel {
  padding: 20px;
}

.photo-slot {
  position: relative;
  overflow: hidden;
  width: 100%;
  aspect-ratio: 4 / 3;
  margin-bottom: 18px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background:
    linear-gradient(135deg, color-mix(in srgb, var(--accent-soft) 78%, #fff), #fff 70%),
    var(--surface-strong);
}

.photo-slot img {
  display: none;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.photo-slot.has-image img {
  display: block;
}

.photo-slot.has-image .photo-fallback {
  display: none;
}

.photo-fallback {
  position: absolute;
  inset: 0;
  display: grid;
  place-content: center;
  gap: 8px;
  text-align: center;
  color: var(--muted);
}

.photo-fallback span {
  font-size: 1.4rem;
  color: var(--ink);
  font-weight: 800;
}

#profileBio,
.post-card p,
.resource-card p,
.progress-panel p,
.reader p,
.empty-state {
  color: var(--muted);
  line-height: 1.75;
}

.section-heading {
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
}

.section-heading.compact {
  margin-top: 20px;
}

.section-heading span {
  color: var(--muted);
  font-size: 0.86rem;
}

.text-link {
  color: var(--accent);
  font-weight: 800;
}

.taxonomy-list,
.tag-list,
.filter-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.taxonomy-list button,
.tag,
.post-tags a {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 7px 10px;
  color: var(--muted);
  background: var(--surface-strong);
}

.taxonomy-list button,
.tag {
  cursor: pointer;
}

.post-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

.post-card {
  display: grid;
  gap: 12px;
  padding: 18px;
  --card-lift: 0px;
  --card-scale: 1;
  --card-shadow-alpha: 0.09;
  transform: translateY(var(--card-lift)) scale(var(--card-scale));
  transform-origin: center;
  transition:
    transform 180ms cubic-bezier(0.2, 0.8, 0.2, 1),
    box-shadow 180ms ease-out,
    border-color 180ms ease,
    background 180ms ease;
  will-change: transform;
}

.post-card.is-near,
.post-card:hover,
.post-card:focus-within {
  border-color: color-mix(in srgb, var(--accent) 46%, var(--line));
  background:
    radial-gradient(circle at 18% 0%, color-mix(in srgb, var(--accent-soft) 68%, transparent), transparent 42%),
    var(--surface);
  box-shadow: 0 28px 68px rgba(42, 78, 101, var(--card-shadow-alpha));
}

.post-card:hover,
.post-card:focus-within {
  --card-lift: -12px;
  --card-scale: 1.045;
  --card-shadow-alpha: 0.26;
}

.post-card h3 {
  font-size: 1.25rem;
  line-height: 1.3;
  cursor: pointer;
}

.post-meta,
.resource-meta {
  gap: 10px;
  color: var(--muted);
  font-size: 0.85rem;
}

.post-card button,
.editor-panel button,
.button-link {
  width: fit-content;
  min-height: 38px;
  border: 0;
  border-radius: 999px;
  padding: 9px 16px;
  color: var(--accent-ink);
  background: var(--accent);
  cursor: pointer;
}

.button-link {
  display: inline-flex;
  align-items: center;
}

.secondary-button {
  border: 1px solid var(--line) !important;
  border-radius: 999px;
  min-height: 38px;
  padding: 9px 14px;
  color: var(--ink) !important;
  background: var(--surface-strong) !important;
  cursor: pointer;
}

.button-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

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

.muted-note {
  margin: 12px 0 0;
  color: var(--muted);
  line-height: 1.7;
}

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

.filter-panel {
  position: sticky;
  top: 92px;
}

.filter-list {
  margin-top: 14px;
}

.reader {
  padding: clamp(18px, 3vw, 34px);
}

.post-page {
  width: min(920px, 100%);
  margin: 0 auto;
  background:
    linear-gradient(180deg, color-mix(in srgb, var(--accent-soft) 34%, transparent), transparent 180px),
    var(--surface);
}

.reader.hidden {
  display: none;
}

.reader h1 {
  font-family: var(--font-serif);
  font-size: clamp(2rem, 4vw, 3.4rem);
  line-height: 1.08;
}

.reader h2 {
  margin-top: 28px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
}

.reader pre {
  overflow: auto;
  border-radius: var(--radius);
  padding: 16px;
  background: #20252a;
  color: #f5f1e8;
}

.reader code {
  border-radius: 5px;
  padding: 2px 5px;
  background: color-mix(in srgb, var(--accent-soft) 72%, transparent);
}

.reader pre code {
  padding: 0;
  background: transparent;
}

.reader img {
  display: block;
  max-width: 100%;
  height: auto;
  margin: 18px auto;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-strong);
}

.reader blockquote {
  margin: 18px 0;
  border-left: 4px solid var(--accent);
  padding-left: 16px;
  color: var(--muted);
}

.reader .callout {
  border: 1px solid var(--line);
  border-left: 4px solid var(--accent);
  border-radius: var(--radius);
  padding: 14px 16px;
  background: color-mix(in srgb, var(--accent-soft) 42%, transparent);
}

.math-block {
  overflow-x: auto;
  margin: 22px 0;
  padding: 14px 16px;
  border-radius: var(--radius);
  background: color-mix(in srgb, var(--accent-soft) 35%, transparent);
}

.math-inline {
  color: var(--ink);
}

.wiki-link {
  border-bottom: 1px dotted var(--accent);
  color: var(--accent);
  font-weight: 800;
}

.back-link {
  display: inline-flex;
  width: fit-content;
  margin-bottom: 20px;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 8px 12px;
  color: var(--accent);
  background: var(--surface-strong);
  font-weight: 800;
}

.reader a,
.resource-card a {
  color: var(--accent);
  font-weight: 800;
}

.pdf-link {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 9px 13px;
  background: color-mix(in srgb, var(--accent-soft) 36%, transparent);
}

.page-head {
  margin-bottom: 18px;
}

.page-head h2 {
  font-family: var(--font-serif);
  font-size: clamp(2rem, 4vw, 3.4rem);
}

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

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

.editor-panel {
  display: grid;
  gap: 14px;
  align-content: start;
}

.editor-panel h3 {
  margin: 0 0 4px;
}

.editor-panel label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 700;
}

.editor-panel p {
  margin: 0;
  color: var(--muted);
  line-height: 1.75;
}

.editor-panel input,
.editor-panel select,
.editor-panel textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 11px 12px;
  background: var(--surface-strong);
  color: var(--ink);
  outline: 0;
}

.editor-panel textarea {
  resize: vertical;
}

.file-drop {
  border: 1px dashed var(--line);
  border-radius: var(--radius);
  padding: 12px;
  background: color-mix(in srgb, var(--accent-soft) 42%, transparent);
}

.writer-login-panel {
  max-width: 720px;
}

.writer-studio {
  grid-template-columns: minmax(420px, 0.9fr) minmax(460px, 1.1fr);
}

.writer-inline-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.writer-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}

.writer-message {
  min-height: 1.4em;
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 700;
}

.writer-message[data-type="success"] {
  color: color-mix(in srgb, var(--accent) 78%, #20643f);
}

.writer-message[data-type="error"] {
  color: #b94a4a;
}

.markdown-editor-panel textarea {
  min-height: 560px;
  font-family: "Cascadia Code", "SFMono-Regular", Consolas, monospace;
  line-height: 1.65;
}

.markdown-preview-panel {
  min-height: 720px;
}

.writer-preview {
  min-height: 620px;
  box-shadow: none;
}

.resource-list,
.plan-list,
.friend-list {
  display: grid;
  gap: 12px;
}

.friend-link {
  display: grid;
  grid-template-columns: 46px minmax(0, 1fr);
  gap: 12px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px;
  background:
    linear-gradient(135deg, color-mix(in srgb, var(--accent-soft) 45%, transparent), transparent),
    var(--surface-strong);
  transition:
    transform 160ms ease,
    border-color 160ms ease,
    box-shadow 160ms ease;
}

.friend-link:hover {
  border-color: color-mix(in srgb, var(--accent) 55%, var(--line));
  box-shadow: 0 16px 34px rgba(42, 78, 101, 0.12);
  transform: translateY(-3px);
}

.friend-link strong {
  color: var(--ink);
  font-size: 0.98rem;
  line-height: 1.25;
}

.friend-avatar {
  width: 46px;
  height: 46px;
  border: 1px solid color-mix(in srgb, var(--line) 70%, var(--surface));
  border-radius: 50%;
  background: var(--accent-soft);
  object-fit: cover;
}

.friend-copy {
  display: grid;
  gap: 4px;
  min-width: 0;
}

.friend-copy small {
  color: var(--muted);
  font-size: 0.82rem;
  line-height: 1.35;
}

.resource-card {
  padding: 18px;
}

.resource-card h3 {
  margin: 8px 0;
}

.plan-grid {
  grid-template-columns: 1fr 340px;
}

.progress-panel {
  gap: 18px;
}

.progress-ring {
  display: grid;
  place-items: center;
  width: 118px;
  height: 118px;
  flex: 0 0 auto;
  border-radius: 50%;
  background: conic-gradient(var(--accent) var(--progress, 0%), var(--accent-soft) 0);
}

.progress-ring span {
  display: grid;
  place-items: center;
  width: 82px;
  height: 82px;
  border-radius: 50%;
  background: var(--surface);
  font-weight: 900;
}

.plan-list {
  grid-column: 1 / -1;
}

.plan-item {
  justify-content: space-between;
  gap: 14px;
  padding: 16px 18px;
}

.plan-item strong {
  display: block;
  margin-bottom: 5px;
}

.status {
  border-radius: 999px;
  padding: 7px 10px;
  color: var(--accent);
  background: var(--accent-soft);
  white-space: nowrap;
}

.studio-grid {
  grid-template-columns: minmax(270px, 360px) minmax(320px, 1fr);
  align-items: start;
}

.studio-grid .preview-panel {
  grid-column: 2;
}

.preview-panel {
  min-height: 360px;
}

.empty-state {
  border: 1px dashed var(--line);
  border-radius: var(--radius);
  padding: 22px;
  background: color-mix(in srgb, var(--surface) 72%, transparent);
}

.empty-state.compact {
  padding: 14px;
  font-size: 0.92rem;
}

.reader-layout {
  display: grid;
  grid-template-columns: minmax(190px, 250px) minmax(620px, 1fr) minmax(180px, 230px);
  gap: 18px;
  align-items: start;
}

.reader-layout.hide-left {
  grid-template-columns: minmax(620px, 1fr) minmax(180px, 230px);
}

.reader-layout.hide-right {
  grid-template-columns: minmax(190px, 250px) minmax(620px, 1fr);
}

.reader-layout.hide-left.hide-right {
  grid-template-columns: 1fr;
}

.reader-layout.hide-left .reader-sidebar,
.reader-layout.hide-right .reader-toc-sidebar {
  display: none;
}

.reader-sidebar,
.reader-toc-sidebar {
  position: sticky;
  top: 92px;
  max-height: calc(100vh - 112px);
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.reader-sidebar .section-heading,
.reader-toc-sidebar .section-heading {
  margin-bottom: 12px;
}

.reader-sidebar h2,
.reader-toc-sidebar h2 {
  margin: 0;
  font-size: 1rem;
}

.reader h1[id],
.reader h2[id],
.reader h3[id],
.reader h4[id] {
  scroll-margin-top: 105px;
}

.reader .reader-title {
  margin: 4px 0 16px;
  font-family: "Bodoni 72", Didot, "Playfair Display", Georgia, var(--font-serif);
  font-size: clamp(1.75rem, 3vw, 2.35rem);
  font-weight: 800;
  line-height: 1.16;
  color: var(--ink);
  text-wrap: balance;
}

.icon-button {
  min-height: 30px;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 5px 10px;
  color: var(--muted);
  background: var(--surface-strong);
  cursor: pointer;
}

.reader-nav-list {
  display: grid;
  gap: 8px;
}

.article-toc-list {
  display: grid;
  gap: 6px;
}

.article-toc-item {
  width: 100%;
  border: 0;
  border-left: 2px solid color-mix(in srgb, var(--accent) 18%, var(--line));
  padding: 6px 8px;
  color: color-mix(in srgb, var(--muted) 86%, var(--accent));
  background: transparent;
  text-align: left;
  font-size: 0.84rem;
  line-height: 1.35;
  cursor: pointer;
  transition:
    color 160ms ease,
    border-color 160ms ease,
    background 160ms ease,
    transform 160ms ease;
}

.article-toc-item:hover,
.article-toc-item.active {
  border-left-color: var(--accent);
  color: color-mix(in srgb, var(--ink) 72%, var(--accent));
  background: color-mix(in srgb, var(--accent-soft) 42%, transparent);
  transform: translateX(3px);
}

.article-toc-item.level-2 {
  padding-left: 16px;
}

.article-toc-item.level-3 {
  padding-left: 26px;
  font-size: 0.8rem;
}

.article-toc-item.level-4 {
  padding-left: 36px;
  font-size: 0.78rem;
}

.reader-nav-item,
.adjacent-posts a {
  display: grid;
  gap: 5px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px;
  background: var(--surface-strong);
}

.reader-nav-item:hover,
.reader-nav-item.active,
.adjacent-posts a:hover {
  border-color: color-mix(in srgb, var(--accent) 55%, var(--line));
}

.reader-nav-item.active {
  background: color-mix(in srgb, var(--accent-soft) 58%, var(--surface));
}

.reader-nav-item span,
.adjacent-posts span {
  color: var(--muted);
  font-size: 0.82rem;
}

.reader-nav-item strong,
.adjacent-posts strong {
  color: var(--ink);
  line-height: 1.35;
}

.reader-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  margin-bottom: 20px;
}

.reader-actions .back-link {
  margin-bottom: 0;
}

.adjacent-posts {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin-top: 34px;
}

.search-summary {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px 14px;
  color: var(--muted);
  background: color-mix(in srgb, var(--accent-soft) 36%, transparent);
  font-weight: 700;
}

.comments-panel {
  margin-top: 42px;
  border-top: 1px solid var(--line);
  padding-top: 24px;
}

@media (max-width: 1100px) {
  .reader-layout,
  .reader-layout.hide-left,
  .reader-layout.hide-right,
  .reader-layout.hide-left.hide-right {
    grid-template-columns: 1fr;
  }

  .reader-sidebar,
  .reader-toc-sidebar {
    position: static;
    max-height: none;
  }
}

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

  .nav {
    justify-content: flex-start;
    overflow-x: auto;
    padding-bottom: 2px;
  }

  .theme-strip,
  .home-grid,
  .content-layout,
  .resources-layout,
  .reader-layout,
  .plan-grid,
  .studio-grid {
    grid-template-columns: 1fr;
  }

  .theme-strip {
    display: grid;
    align-items: start;
  }

  .theme-actions {
    justify-content: flex-start;
  }

  .filter-panel {
    position: static;
  }

  .reader-sidebar {
    position: static;
    max-height: none;
  }

  .reader-toc-sidebar {
    position: static;
    max-height: none;
  }

  .studio-grid .preview-panel,
  .plan-list {
    grid-column: auto;
  }
}

@media (max-width: 620px) {
  main {
    width: min(100% - 24px, 1062px);
    padding-top: 18px;
  }

  .topbar {
    padding: 12px;
  }

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

  .adjacent-posts {
    grid-template-columns: 1fr;
  }

  .writer-inline-grid {
    grid-template-columns: 1fr;
  }

  .theme-strip h1,
  .page-head h2 {
    font-size: 2rem;
  }

  .plan-item,
  .progress-panel {
    align-items: flex-start;
    flex-direction: column;
  }
}
