/*
Theme Name: Simple Blog
Theme URI: https://cnoos.com/
Author: YuCnoos
Author URI: https://cnoos.com/
Description: 极简个人博客主题：月分组文章列表、侧栏筛选、阅读页目录、前端写作与登录。
Version: 1.0.0
Requires at least: 6.0
Requires PHP: 7.4
License: Private
License URI: Private
Text Domain: simple-blog
*/

/* -------------------------------------------------------------------------
 * Design tokens
 * ---------------------------------------------------------------------- */

:root {
  color-scheme: light;
  --bg: #fbfbfa;
  --ink: #171717;
  --text: #3f3f3f;
  --muted: #737373;
  --line: #e6e6e4;
  --soft: #f3f3f1;
  --sans: "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans SC", sans-serif;
  --serif: "Palatino Linotype", "Songti SC", Georgia, serif;
}

[data-theme="dark"] {
  color-scheme: dark;
  --bg: #141413;
  --ink: #f5f5f4;
  --text: #d6d3d1;
  --muted: #a8a29e;
  --line: #2c2c2a;
  --soft: #1c1c1a;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  scroll-behavior: smooth;
  scrollbar-gutter: stable;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  line-height: 1.6;
}

button,
input,
textarea,
select {
  font: inherit;
  color: inherit;
  background: none;
  border: 0;
}

button {
  cursor: pointer;
  padding: 0;
}

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

img {
  max-width: 100%;
  height: auto;
}

:focus-visible {
  outline: 2px solid var(--ink);
  outline-offset: 3px;
}

.sr-only,
.screen-reader-text {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

[hidden] {
  display: none !important;
}

/* -------------------------------------------------------------------------
 * Layout
 * ---------------------------------------------------------------------- */

/* Scoped to the wrapper div: WordPress also puts a `page` class on <body>
   for static pages, which would otherwise narrow the whole document. */
div.page {
  max-width: 1040px;
  margin: 0 auto;
  padding: 28px 32px 40px;
}

.mast {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding-bottom: 16px;
  margin-bottom: 28px;
  border-bottom: 1px solid var(--line);
}

.mast h1 {
  margin: 0;
  font-family: var(--serif);
  font-size: 2rem;
  font-weight: 500;
  letter-spacing: -0.03em;
  line-height: 1.1;
  color: var(--ink);
}

.mast h1 a:hover {
  opacity: 0.72;
}

.mast-copy {
  display: flex;
  align-items: baseline;
  gap: 12px;
  min-width: 0;
}

.tagline {
  margin: 0;
  font-size: 0.92rem;
  color: var(--muted);
}

.mast-nav {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 22px;
  font-size: 0.95rem;
  color: var(--muted);
}

.mast-nav a:hover,
.mast-nav button:hover {
  color: var(--ink);
}

/* Wrapper for the menu links. On desktop it has no box of its own, so the
   links line up directly inside .mast-nav; on mobile it becomes the row that
   holds the links side by side inside the bottom sheet. */
.mast-nav-links {
  display: contents;
}

.mast-nav a[aria-current="page"] {
  color: var(--ink);
  font-weight: 600;
}

.mast {
  position: relative;
}

/* Mobile menu trigger and drawer scaffolding; only activated at <= 800px. */
.mast-menu-toggle {
  display: none;
}

.mast-nav {
  margin-left: auto;
}

.mast-account {
  display: block;
  position: relative;
  flex: 0 0 auto;
  order: 3;
}

.mast-account-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  max-width: 170px;
  padding: 4px 10px 4px 4px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--soft);
  color: var(--ink);
  font-size: 0.82rem;
  line-height: 1;
  cursor: pointer;
}

.mast-account-btn:hover {
  border-color: var(--ink);
}

.mast-account-avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--soft);
  border: 1px solid var(--line);
  color: var(--ink);
  font-size: 0.78rem;
  font-weight: 600;
  line-height: 1;
  flex-shrink: 0;
}

.mast-account-name {
  max-width: 108px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.mast-account-menu {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  min-width: 152px;
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--bg);
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.16);
  z-index: 950;
}

.mast-account-menu a {
  display: block;
  padding: 8px 10px;
  border-radius: 6px;
  font-size: 0.86rem;
  color: var(--text);
}

.mast-account-menu a:hover {
  background: var(--soft);
  color: var(--ink);
}

.mast-account-login {
  display: inline-flex;
  position: relative;
  flex: 0 0 auto;
  order: 3;
  padding: 7px 14px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--soft);
  color: var(--muted);
  font-size: 0.84rem;
  line-height: 1;
  cursor: pointer;
}

.mast-account-login:hover {
  color: var(--ink);
  border-color: var(--ink);
}

.mast-menu-bars {
  display: block;
  position: relative;
  width: 18px;
  height: 12px;
}

.mast-menu-bars span {
  position: absolute;
  left: 0;
  width: 100%;
  height: 2px;
  border-radius: 2px;
  background: currentColor;
  transition: transform 180ms ease, opacity 180ms ease;
}

.mast-menu-bars span:nth-child(1) {
  top: 0;
}

.mast-menu-bars span:nth-child(2) {
  top: 5px;
}

.mast-menu-bars span:nth-child(3) {
  top: 10px;
}

.mast-menu-toggle[aria-expanded="true"] .mast-menu-bars span:nth-child(1) {
  transform: translateY(5px) rotate(45deg);
}

.mast-menu-toggle[aria-expanded="true"] .mast-menu-bars span:nth-child(2) {
  opacity: 0;
}

.mast-menu-toggle[aria-expanded="true"] .mast-menu-bars span:nth-child(3) {
  transform: translateY(-5px) rotate(-45deg);
}

.mast-drawer-head,
.mast-drawer-backdrop,
.mast-subnavs {
  display: none;
}

body.mast-drawer-open {
  overflow: hidden;
}

.mast-login {
  color: var(--muted);
}

.mast-logout {
  color: var(--muted);
}

.crumbs {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 6px 8px;
  margin: 0 0 14px;
  font-size: 0.82rem;
  line-height: 1.5;
  color: var(--muted);
}

.crumbs a:hover {
  color: var(--ink);
}

.crumbs [aria-current="page"] {
  min-width: 0;
  color: var(--text);
}

/* Floating tools: back-to-top + theme switch. */
.floating-tools {
  position: fixed;
  right: max(16px, env(safe-area-inset-right));
  bottom: max(18px, env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  gap: 10px;
  z-index: 500;
}

.floating-tools .floating-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: var(--bg);
  background: color-mix(in srgb, var(--bg) 42%, transparent);
  color: var(--ink);
  font-size: 1.15rem;
  line-height: 1;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.1);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  transition: border-color 140ms ease, transform 140ms ease, background-color 140ms ease, opacity 140ms ease;
}

.floating-tools .floating-btn:hover,
.floating-tools .floating-btn:focus-visible {
  border-color: var(--ink);
  background: var(--bg);
  transform: translateY(-2px);
}

.floating-tools .floating-btn:active {
  transform: translateY(0);
}

.floating-tools .theme-toggle-icon {
  font-family: "Segoe UI Emoji", "Apple Color Emoji", "Noto Color Emoji", sans-serif;
  font-size: 1.1rem;
}

/* The menu entry only exists in the mobile floating stack. */
.floating-tools .mast-menu-toggle {
  display: none;
}

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

.list {
  grid-column: 1;
  grid-row: 1;
  min-width: 0;
}

.rail {
  grid-column: 2;
  grid-row: 1;
  position: sticky;
  top: 32px;
  min-width: 0;
}

.groups h2 {
  margin: 0 0 8px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--line);
  font-family: var(--sans);
  font-size: 0.88rem;
  font-weight: 600;
  line-height: 1.3;
  color: var(--ink);
}

form.search {
  display: flex;
  gap: 8px;
}

form.search input {
  flex: 1 1 auto;
  width: auto;
  min-width: 0;
  height: 38px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--soft);
  color: var(--ink);
  font-size: 0.95rem;
}

/* 桌面端靠回车提交，按钮仅在移动端出现（见 ≤800px 媒体查询） */
.search-submit {
  display: none;
  flex: 0 0 auto;
  height: 38px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--soft);
  color: var(--ink);
  font-size: 0.9rem;
  white-space: nowrap;
  transition: border-color 120ms ease, background-color 120ms ease;
}

.search-submit:hover,
.search-submit:focus-visible {
  border-color: var(--ink);
}

.search-submit:active {
  background: var(--line);
}

form.search input::placeholder {
  color: var(--muted);
}

form.search input:focus {
  outline: none;
  border-color: var(--ink);
}

form.search input:focus-visible {
  outline: none;
  border-color: var(--ink);
}

form.search input::-webkit-search-cancel-button {
  -webkit-appearance: none;
}

.groups {
  display: flex;
  flex-direction: column;
  gap: 28px;
  margin-top: 32px;
}

.rail > .groups:first-child {
  margin-top: 0;
}

.index-list {
  display: flex;
  flex-direction: column;
}

.index-btn {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  width: 100%;
  padding: 6px 0;
  text-align: left;
  font-size: 0.92rem;
  color: var(--text);
}

.index-btn:hover,
.index-btn.is-active {
  color: var(--ink);
}

.index-btn.is-active {
  font-weight: 600;
}

.count {
  font-variant-numeric: tabular-nums;
  font-size: 0.82rem;
  color: var(--muted);
}

.recent {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.recent a {
  display: block;
  font-size: 0.92rem;
  line-height: 1.45;
  color: var(--text);
}

.recent a:hover,
.recent a[aria-current="page"] {
  color: var(--ink);
}

.recent a[aria-current="page"] {
  font-weight: 600;
}

.list-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 4px;
  font-size: 0.82rem;
}

.filter-note {
  color: var(--muted);
}

.filter-clear {
  color: var(--ink);
  text-decoration: underline;
  text-underline-offset: 3px;
  white-space: nowrap;
}

.post {
  padding: 18px 0 20px;
  border-bottom: 1px solid var(--line);
}

.vis-badge {
  display: inline-flex;
  align-items: center;
  padding: 1px 6px;
  border-radius: 4px;
  font-size: 0.72rem;
  font-weight: 500;
  background: var(--soft);
  border: 1px solid var(--line);
  color: var(--muted);
}

.vis-badge.is-login {
  color: var(--ink);
}

.post-locked {
  margin: 8px 0 0;
  font-size: 0.9rem;
  color: var(--muted);
}

.post-locked a {
  color: var(--ink);
  text-decoration: underline;
  text-underline-offset: 3px;
}

.reading-gate {
  margin: 26px 0 34px;
  padding: 26px 24px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--soft);
}

.reading-gate-title {
  margin: 0 0 6px;
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--ink);
}

.reading-gate-desc {
  margin: 0;
  font-size: 0.92rem;
  color: var(--muted);
}

.reading-gate-actions {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-top: 16px;
}

.gate-login-btn {
  padding: 7px 16px;
  border: 1px solid var(--ink);
  border-radius: 6px;
  background: var(--ink);
  color: var(--bg);
  font-size: 0.88rem;
  cursor: pointer;
}

.gate-login-btn:hover {
  opacity: 0.88;
}

.gate-home-link {
  display: inline-block;
  margin-top: 14px;
  font-size: 0.88rem;
  color: var(--muted);
  text-decoration: underline;
  text-underline-offset: 3px;
}

.reading-gate-actions .gate-home-link {
  margin-top: 0;
}

.reading-cover {
  margin: 18px 0 26px;
  border-radius: 8px;
  overflow: hidden;
  background: var(--soft);
}

.reading-cover img {
  display: block;
  width: 100%;
  max-height: 400px;
  object-fit: cover;
}

.post.is-last {
  border-bottom: 0;
}

.meta {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 0 0 6px;
  font-size: 0.82rem;
  font-variant-numeric: tabular-nums;
  color: var(--muted);
}

.cat-btn {
  color: var(--muted);
  border-bottom: 1px solid transparent;
}

.cat-btn:hover,
.cat-btn.is-active {
  color: var(--ink);
  border-bottom-color: currentColor;
}

.post-title {
  margin: 0;
  font-size: 1.28rem;
  font-weight: 600;
  letter-spacing: -0.02em;
  line-height: 1.4;
  color: var(--ink);
}

.post-title a {
  background-image: linear-gradient(currentColor, currentColor);
  background-repeat: no-repeat;
  background-position: 0 100%;
  background-size: 0 1px;
  transition: background-size 180ms ease;
}

.post-title a:hover {
  background-size: 100% 1px;
}

.excerpt {
  margin: 8px 0 0;
  max-width: 66ch;
  font-size: 0.95rem;
  line-height: 1.75;
  color: var(--text);
}

.list .excerpt a {
  color: var(--ink);
  text-decoration: underline;
  text-underline-offset: 3px;
}

.list > form.search {
  margin-bottom: 8px;
}

.empty {
  margin: 28px 0;
  color: var(--muted);
}

.list-count {
  margin: 18px 0 4px;
  font-size: 0.82rem;
  color: var(--muted);
}

.site-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-top: 56px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
  font-size: 0.82rem;
  color: var(--muted);
}

.site-footer p {
  margin: 0;
}

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

/* -------------------------------------------------------------------------
 * Reading page
 * ---------------------------------------------------------------------- */

.reading {
  grid-column: 1;
  grid-row: 1;
  max-width: none;
  min-width: 0;
}

.reading .meta {
  margin: 10px 0 0;
}

.reading-title {
  margin: 0;
  font-size: 1.7rem;
  font-weight: 600;
  letter-spacing: -0.02em;
  line-height: 1.35;
  color: var(--ink);
}

.prose {
  margin-top: 28px;
  font-size: 1.02rem;
  line-height: 1.85;
  color: var(--text);
}

.prose h2 {
  scroll-margin-top: 20px;
  margin: 2.1rem 0 0.7rem;
  font-size: 1.12rem;
  font-weight: 650;
  letter-spacing: -0.01em;
  line-height: 1.4;
  color: var(--ink);
}

.prose h3 {
  margin: 1.45rem 0 0.4rem;
  font-size: 1rem;
  font-weight: 650;
  color: var(--ink);
}

.prose p {
  margin: 0.7rem 0;
}

.prose ul,
.prose ol {
  margin: 0.45rem 0 1rem;
  padding-left: 1.25rem;
}

.prose li + li {
  margin-top: 0.35rem;
}

.prose a {
  color: var(--ink);
  text-decoration: underline;
  text-underline-offset: 3px;
}

.prose code {
  font-family: ui-monospace, "Cascadia Mono", Consolas, monospace;
  font-size: 0.82em;
  background: var(--soft);
  padding: 0.08em 0.32em;
  border-radius: 4px;
}

.prose pre,
.prose pre[class*="language-"] {
  margin: 0.85rem 0 1.15rem;
  padding: 12px 14px;
  background: var(--soft);
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow-x: auto;
  font-family: ui-monospace, "Cascadia Mono", Consolas, monospace;
  font-size: 0.78rem;
  line-height: 1.48;
  text-shadow: none;
}

.prose pre code,
.prose pre[class*="language-"] code[class*="language-"] {
  background: transparent;
  padding: 0;
  font-family: inherit;
  font-size: inherit;
  line-height: inherit;
  color: inherit;
  text-shadow: none;
}

/* Light-mode Prism tokens matching var(--soft) */
:root:not([data-theme="dark"]) .prose pre .token.comment,
:root:not([data-theme="dark"]) .prose pre .token.prolog,
:root:not([data-theme="dark"]) .prose pre .token.doctype,
:root:not([data-theme="dark"]) .prose pre .token.cdata { color: #6e7781; }
:root:not([data-theme="dark"]) .prose pre .token.punctuation { color: #57606a; }
:root:not([data-theme="dark"]) .prose pre .token.property,
:root:not([data-theme="dark"]) .prose pre .token.tag,
:root:not([data-theme="dark"]) .prose pre .token.boolean,
:root:not([data-theme="dark"]) .prose pre .token.number,
:root:not([data-theme="dark"]) .prose pre .token.constant,
:root:not([data-theme="dark"]) .prose pre .token.symbol,
:root:not([data-theme="dark"]) .prose pre .token.deleted { color: #0550ae; }
:root:not([data-theme="dark"]) .prose pre .token.selector,
:root:not([data-theme="dark"]) .prose pre .token.attr-name,
:root:not([data-theme="dark"]) .prose pre .token.string,
:root:not([data-theme="dark"]) .prose pre .token.char,
:root:not([data-theme="dark"]) .prose pre .token.builtin,
:root:not([data-theme="dark"]) .prose pre .token.inserted { color: #0a3069; }
:root:not([data-theme="dark"]) .prose pre .token.operator,
:root:not([data-theme="dark"]) .prose pre .token.entity,
:root:not([data-theme="dark"]) .prose pre .token.url,
:root:not([data-theme="dark"]) .prose pre .language-css .token.string,
:root:not([data-theme="dark"]) .prose pre .style .token.string { color: #953800; background: transparent; }
:root:not([data-theme="dark"]) .prose pre .token.atrule,
:root:not([data-theme="dark"]) .prose pre .token.attr-value,
:root:not([data-theme="dark"]) .prose pre .token.keyword { color: #cf222e; }
:root:not([data-theme="dark"]) .prose pre .token.function,
:root:not([data-theme="dark"]) .prose pre .token.class-name { color: #8250df; }
:root:not([data-theme="dark"]) .prose pre .token.regex,
:root:not([data-theme="dark"]) .prose pre .token.important,
:root:not([data-theme="dark"]) .prose pre .token.variable { color: #953800; }

.prose blockquote {
  margin: 1.2rem 0;
  padding: 0.2rem 0 0.2rem 1rem;
  border-left: 3px solid var(--line);
  color: var(--muted);
}

.prose hr {
  border: 0;
  border-top: 1px solid var(--line);
  margin: 2rem 0;
}

.prose figure {
  margin: 1.2rem 0;
}

.prose figure img {
  border-radius: 8px;
}

.prose figcaption {
  margin-top: 6px;
  font-size: 0.82rem;
  color: var(--muted);
  text-align: center;
}

.prose iframe,
.prose video,
.prose embed {
  max-width: 100%;
}

.prose .alignleft {
  float: left;
  margin: 0 1rem 0.6rem 0;
}

.prose .alignright {
  float: right;
  margin: 0 0 0.6rem 1rem;
}

.prose .aligncenter {
  display: block;
  margin: 1rem auto;
}

.table-wrap,
.prose .wp-block-table {
  margin: 0.9rem 0 1.2rem;
  overflow-x: auto;
}

.prose table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
  line-height: 1.5;
}

.prose th,
.prose td {
  text-align: left;
  padding: 8px 10px;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
}

.prose th {
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 600;
}

.page-links {
  margin-top: 24px;
  font-size: 0.9rem;
  color: var(--muted);
}

.page-links a {
  color: var(--ink);
  text-decoration: underline;
  text-underline-offset: 3px;
}

.pager {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
  margin-top: 40px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
}

.pager a,
.pager span {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}

.pager .next {
  text-align: right;
  align-items: flex-end;
}

.pager .dir {
  font-size: 0.78rem;
  color: var(--muted);
}

.pager .to {
  color: var(--ink);
  font-weight: 600;
  line-height: 1.45;
}

.pager a:hover .to {
  text-decoration: underline;
  text-underline-offset: 3px;
}

.pager .end {
  color: var(--muted);
  font-weight: 500;
}

/* -------------------------------------------------------------------------
 * Archives / search
 * ---------------------------------------------------------------------- */

.archive-head {
  margin-bottom: 4px;
}

.archive-title {
  font-size: 1.5rem;
}

.archive-description {
  margin-top: 8px;
  font-size: 0.92rem;
  color: var(--muted);
}

.archive-description p {
  margin: 0.3rem 0;
}

.pagination {
  margin-top: 32px;
  font-size: 0.86rem;
}

.pagination .nav-links {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
}

.pagination .page-numbers {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 30px;
  height: 30px;
  padding: 0 9px;
  border-radius: 5px;
  color: var(--text);
}

.pagination .page-numbers:hover,
.pagination .page-numbers.current {
  background: var(--soft);
  color: var(--ink);
}

.pagination .page-numbers.current {
  font-weight: 600;
}

.pagination .dots {
  color: var(--muted);
}

/* -------------------------------------------------------------------------
 * WordPress core alignment / captions
 * ---------------------------------------------------------------------- */

.wp-caption {
  max-width: 100%;
}

.wp-caption-text,
.gallery-caption {
  font-size: 0.82rem;
  color: var(--muted);
}

.sticky,
.bypostauthor {
  position: relative;
}

/* -------------------------------------------------------------------------
 * Login modal
 * ---------------------------------------------------------------------- */

.login-modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(0, 0, 0, 0.42);
  opacity: 0;
  visibility: hidden;
  transition: opacity 180ms ease, visibility 180ms ease;
}

.login-modal-overlay.is-open {
  opacity: 1;
  visibility: visible;
}

.login-modal-card {
  position: relative;
  width: 100%;
  max-width: 380px;
  padding: 28px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--bg);
  color: var(--text);
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.18);
}

.login-modal-close {
  position: absolute;
  top: 8px;
  right: 12px;
  font-size: 1.5rem;
  line-height: 1;
  color: var(--muted);
}

.login-modal-close:hover {
  color: var(--ink);
}

.login-modal-title {
  margin: 0 0 18px;
  font-family: var(--serif);
  font-size: 1.6rem;
  font-weight: 500;
  color: var(--ink);
}

.login-modal-field {
  display: block;
  margin-bottom: 14px;
}

.login-modal-field span {
  display: block;
  margin-bottom: 6px;
  font-size: 0.82rem;
  color: var(--muted);
}

.login-modal-field input {
  width: 100%;
  height: 40px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--soft);
  color: var(--ink);
}

.login-modal-field input:focus {
  outline: none;
  border-color: var(--ink);
}

.login-modal-remember {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 4px 0 12px;
  font-size: 0.85rem;
  color: var(--muted);
  cursor: pointer;
  user-select: none;
}

/* The global input reset removes checkbox borders/backgrounds, so draw the
   box ourselves and keep the native input for keyboard + form submission. */
.login-modal-remember input[type="checkbox"] {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

.login-modal-checkbox {
  position: relative;
  flex: 0 0 auto;
  width: 17px;
  height: 17px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: var(--soft);
  transition: background-color 120ms ease, border-color 120ms ease;
}

.login-modal-remember input:checked + .login-modal-checkbox {
  border-color: var(--ink);
  background: var(--ink);
}

.login-modal-remember input:checked + .login-modal-checkbox::after {
  content: "";
  position: absolute;
  top: 1px;
  left: 4px;
  width: 5px;
  height: 9px;
  border: solid var(--bg);
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
}

.login-modal-remember input:focus-visible + .login-modal-checkbox {
  outline: 2px solid var(--ink);
  outline-offset: 2px;
}

.login-modal-msg {
  min-height: 1.2em;
  margin-bottom: 10px;
  font-size: 0.85rem;
  color: #b91c1c;
}

.login-modal-submit {
  width: 100%;
  height: 42px;
  border-radius: 6px;
  background: var(--ink);
  color: var(--bg);
  font-weight: 600;
}

.login-modal-submit:disabled {
  opacity: 0.6;
  cursor: default;
}

.login-modal-sub {
  margin: -6px 0 16px;
  font-size: 0.86rem;
  color: var(--muted);
}

.login-modal-masked-email {
  color: var(--ink);
  font-weight: 500;
}

.login-modal-code-inputs {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 12px;
}

.login-modal-code-inputs input {
  width: 100%;
  height: 44px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--bg);
  color: var(--ink);
  text-align: center;
  font-size: 1.15rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.login-modal-code-inputs input:focus {
  outline: none;
  border-color: var(--ink);
}

.login-modal-msg.is-ok {
  color: #15803d;
}

.login-modal-verify-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 14px;
  font-size: 0.82rem;
}

.login-modal-resend {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.login-modal-link-btn {
  padding: 0;
  border: 0;
  background: none;
  color: var(--muted);
  font: inherit;
  cursor: pointer;
}

.login-modal-link-btn:hover:not(:disabled) {
  color: var(--ink);
}

.login-modal-link-btn:disabled {
  opacity: 0.55;
  cursor: default;
}

.login-modal-countdown {
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.login-modal-captcha-group {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
}

.login-modal-captcha-group[hidden] {
  display: none;
}

.login-modal-captcha-img {
  width: 112px;
  height: 38px;
  border-radius: 6px;
  border: 1px solid var(--line);
  cursor: pointer;
  flex-shrink: 0;
}

.login-modal-captcha-group input[type="text"] {
  flex: 1;
  min-width: 0;
  height: 38px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--bg);
  color: var(--ink);
  font: inherit;
  font-size: 0.92rem;
  letter-spacing: 2px;
  text-transform: uppercase;
}

.login-modal-captcha-group input[type="text"]:focus {
  outline: none;
  border-color: var(--ink);
}

.login-modal-captcha-refresh {
  width: 38px;
  height: 38px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--soft);
  color: var(--ink);
  font-size: 1.05rem;
  line-height: 1;
  cursor: pointer;
  flex-shrink: 0;
}

.login-modal-captcha-refresh:hover {
  border-color: var(--ink);
}

/* -------------------------------------------------------------------------
 * Responsive
 * ---------------------------------------------------------------------- */

@media (max-width: 800px) {
  div.page {
    padding: 16px 20px 32px;
  }

  .mast h1 {
    font-size: 1.65rem;
  }

  .reading-title {
    font-size: 1.35rem;
  }

  .prose {
    font-size: 1rem;
  }

  .pager {
    grid-template-columns: 1fr;
    gap: 16px;
  }

  .pager .next {
    text-align: left;
    align-items: flex-start;
  }

  .mast {
    flex-direction: row;
    flex-wrap: nowrap;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 20px;
    padding-bottom: 14px;
  }

  .mast-copy {
    flex: 1 1 auto;
    flex-wrap: wrap;
    gap: 2px 10px;
    min-width: 0;
  }

  .tagline {
    font-size: 0.85rem;
  }

  .mast-nav {
    gap: 16px;
  }

  .board {
    display: flex;
    flex-direction: column;
    /* The grid layout above uses align-items: start; in the stacked layout
       that leaves the rail's search form at its intrinsic (narrow) width. */
    align-items: stretch;
  }

  .rail {
    display: contents;
    position: static;
  }

  form.search {
    order: 1;
    width: 100%;
    margin-bottom: 22px;
  }

  /* 移动端无实体回车键，显示明确的提交按钮 */
  .search-submit {
    display: block;
  }

  .list,
  .reading {
    order: 2;
  }

  .groups {
    order: 3;
    margin-top: 36px;
    padding-top: 8px;
    border-top: 1px solid var(--line);
  }

  .post-title {
    font-size: 1.12rem;
  }

  .mast-account,
  .mast-account-login {
    order: 0;
  }

  .mast-nav {
    margin-left: 0;
  }

  /* ---------------------------------------------------------------------
   * Bottom-sheet navigation
   * ------------------------------------------------------------------ */

  .floating-tools .mast-menu-toggle {
    display: flex;
  }

  .mast-nav {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100%;
    max-height: 82vh;
    flex-direction: column;
    flex-wrap: nowrap;
    align-items: stretch;
    justify-content: flex-start;
    gap: 0;
    padding: 12px 20px calc(24px + env(safe-area-inset-bottom));
    background: var(--bg);
    border-top: 1px solid var(--line);
    border-radius: 18px 18px 0 0;
    box-shadow: 0 -18px 44px rgba(0, 0, 0, 0.18);
    overflow-y: auto;
    overscroll-behavior: contain;
    transform: translateY(102%);
    visibility: hidden;
    transition: transform 260ms cubic-bezier(0.22, 1, 0.36, 1), visibility 0s linear 260ms;
    z-index: 900;
  }

  .mast-nav.is-open {
    transform: translateY(0);
    visibility: visible;
    transition: transform 260ms cubic-bezier(0.22, 1, 0.36, 1);
  }

  /* Auth actions live in the header account control on mobile. */
  .mast-nav .mast-login,
  .mast-nav .mast-logout,
  .mast-nav .mast-admin {
    display: none;
  }

  /* Links sit in one horizontal row; they scroll sideways only if the
     viewport is too narrow to fit every item. */
  .mast-nav-links {
    display: flex;
    flex-wrap: nowrap;
    align-items: center;
    justify-content: space-between;
    gap: 4px;
    width: 100%;
    overflow-x: auto;
    overscroll-behavior-x: contain;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
  }

  .mast-nav-links::-webkit-scrollbar {
    display: none;
  }

  .mast-nav-links a,
  .mast-nav-links button {
    flex: 0 0 auto;
    width: auto;
    padding: 10px;
    border: 0;
    border-radius: 8px;
    font-size: 0.95rem;
    line-height: 1.4;
    text-align: center;
    white-space: nowrap;
  }

  .mast-nav-links a[aria-current="page"] {
    background: var(--soft);
    color: var(--ink);
  }

  .mast-nav-links .mast-parent::after {
    content: "▾";
    margin-left: 4px;
    font-size: 0.7em;
    opacity: 0.6;
  }

  .mast-nav-links .mast-parent[aria-expanded="true"] {
    background: var(--soft);
    color: var(--ink);
  }

  .mast-nav-links .mast-parent[aria-expanded="true"]::after {
    content: "▴";
  }

  /* Sub items open as their own row just above the main one. */
  .mast-subnavs {
    display: block;
    width: 100%;
  }

  .mast-subnav {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    padding: 0 0 10px;
    margin-bottom: 8px;
    border-bottom: 1px solid var(--line);
  }

  .mast-subnav[hidden] {
    display: none;
  }

  .mast-subnav a {
    padding: 8px 10px;
    border-radius: 8px;
    background: var(--soft);
    color: var(--text);
    font-size: 0.88rem;
    line-height: 1.3;
    white-space: nowrap;
  }

  .mast-subnav a:hover,
  .mast-subnav a[aria-current="page"] {
    color: var(--ink);
  }

  .mast-drawer-head {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 10px;
    padding: 0 0 6px;
  }

  .mast-nav .mast-drawer-close {
    width: 34px;
    height: 34px;
    padding: 0;
    border-bottom: 0;
    font-size: 1.55rem;
    line-height: 1;
    text-align: center;
    color: var(--muted);
  }

  .mast-nav .mast-drawer-close:hover {
    color: var(--ink);
  }

  .mast-drawer-backdrop {
    position: fixed;
    inset: 0;
    z-index: 899;
    background: rgba(0, 0, 0, 0.42);
  }

  .mast-drawer-backdrop:not([hidden]) {
    display: block;
  }

  /* Narrow phones: tighten the row so every item still fits without
     sideways scrolling when submenu carets are present. */
  @media (max-width: 360px) {
    .mast-nav-links {
      gap: 2px;
    }

    .mast-nav-links a,
    .mast-nav-links button {
      padding: 9px 8px;
      font-size: 0.9rem;
    }

    .mast-nav-links .mast-parent::after {
      margin-left: 2px;
    }
  }
}

@media (prefers-reduced-motion: reduce) {
  .post-title a {
    transition: none;
  }

  html {
    scroll-behavior: auto;
  }
}

/* -------------------------------------------------------------------------
 * Reading & UX enhancements
 * ---------------------------------------------------------------------- */

#back-to-top {
  opacity: 0;
  pointer-events: none;
  transform: translateY(8px);
}

#back-to-top.is-visible {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0);
}

body.login-modal-open {
  overflow: hidden;
}

.sticky-badge {
  display: inline-block;
  padding: 1px 6px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: var(--soft);
  color: var(--ink);
  font-size: 0.72rem;
  font-weight: 600;
  line-height: 1.4;
}

.meta-edit {
  color: var(--ink);
  text-decoration: underline;
  text-underline-offset: 3px;
}

.recent a.is-active {
  color: var(--ink);
  font-weight: 600;
}

.mobile-toc {
  display: none;
  margin-top: 18px;
  padding: 10px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--soft);
  font-size: 0.9rem;
}

.mobile-toc summary {
  cursor: pointer;
  font-weight: 600;
  color: var(--ink);
}

.mobile-toc ol {
  margin: 10px 0 4px;
  padding-left: 1.2rem;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.mobile-toc a {
  color: var(--text);
}

.mobile-toc a:hover {
  color: var(--ink);
}

@media (max-width: 800px) {
  .mobile-toc {
    display: block;
  }
}

.prose pre {
  position: relative;
}

.code-copy-btn {
  position: absolute;
  top: 8px;
  right: 8px;
  padding: 2px 8px;
  border: 1px solid var(--line);
  border-radius: 5px;
  background: var(--bg);
  color: var(--muted);
  font-family: var(--sans);
  font-size: 0.7rem;
  line-height: 1.45;
  opacity: 0;
  transition: opacity 140ms ease, color 140ms ease, border-color 140ms ease;
}

.prose pre:hover .code-copy-btn,
.prose pre:focus-within .code-copy-btn,
.code-copy-btn.is-copied {
  opacity: 1;
}

.code-copy-btn:hover,
.code-copy-btn:focus-visible {
  border-color: var(--ink);
  color: var(--ink);
}

@media (hover: none) {
  .code-copy-btn {
    opacity: 0.85;
  }
}

.prose img {
  cursor: zoom-in;
}

.post-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 28px;
}

.post-tags a {
  padding: 3px 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--soft);
  color: var(--muted);
  font-size: 0.8rem;
}

.post-tags a:hover {
  border-color: var(--ink);
  color: var(--ink);
}

.lightbox-overlay {
  position: fixed;
  inset: 0;
  z-index: 1100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(0, 0, 0, 0.82);
  cursor: zoom-out;
}

.lightbox-overlay[hidden] {
  display: none;
}

.lightbox-overlay img {
  max-width: min(94vw, 1200px);
  max-height: 90vh;
  border-radius: 8px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.45);
  cursor: default;
}

.lightbox-close {
  position: fixed;
  top: 16px;
  right: 20px;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.14);
  color: #fff;
  font-size: 1.5rem;
  line-height: 1;
}

.lightbox-close:hover {
  background: rgba(255, 255, 255, 0.28);
}

.lightbox-nav {
  position: fixed;
  top: 50%;
  transform: translateY(-50%);
  width: 44px;
  height: 44px;
  border: 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.14);
  color: #fff;
  font-size: 1.7rem;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.lightbox-nav:hover {
  background: rgba(255, 255, 255, 0.28);
}

.lightbox-nav[hidden],
.lightbox-counter[hidden] {
  display: none;
}

.lightbox-prev {
  left: 18px;
}

.lightbox-next {
  right: 18px;
}

.lightbox-counter {
  position: fixed;
  bottom: 18px;
  left: 50%;
  transform: translateX(-50%);
  padding: 4px 12px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.55);
  color: #fff;
  font-size: 0.82rem;
  font-variant-numeric: tabular-nums;
}

/* -------------------------------------------------------------------------
 * Sidebar tags & horizontal scroll gallery
 * ---------------------------------------------------------------------- */

.rail-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding-top: 2px;
}

.rail-tag {
  display: inline-block;
  padding: 3px 9px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--soft);
  color: var(--text);
  font-size: 0.8rem;
  line-height: 1.45;
  transition: border-color 140ms ease, color 140ms ease, background-color 140ms ease;
}

.rail-tag:hover,
.rail-tag.is-active {
  border-color: var(--ink);
  color: var(--ink);
}

.rail-tag.is-active {
  font-weight: 600;
}

.sb-gallery-wrap {
  position: relative;
  margin: 1.3rem 0;
}

.prose .sb-gallery {
  display: flex;
  gap: 0;
  overflow-x: auto;
  overflow-y: hidden;
  padding: 0;
  border-radius: 8px;
  scroll-snap-type: x mandatory;
  scroll-behavior: smooth;
  scrollbar-width: none;
  -ms-overflow-style: none;
}

.prose .sb-gallery::-webkit-scrollbar {
  display: none;
}

.sb-gallery-wrap .sb-gallery {
  margin: 0;
}

.prose .sb-gallery figure,
.prose .sb-gallery > img {
  flex: 0 0 100%;
  width: 100%;
  margin: 0;
  scroll-snap-align: start;
}

.prose .sb-gallery img {
  display: block;
  width: 100%;
  aspect-ratio: 16 / 10;
  max-height: 480px;
  object-fit: cover;
  border-radius: 8px;
}

.sb-gallery-wrap.is-dragging .sb-gallery {
  cursor: grabbing;
  scroll-behavior: auto;
  scroll-snap-type: none;
}

.sb-gallery-status {
  position: absolute;
  top: 12px;
  right: 12px;
  z-index: 2;
  padding: 2px 8px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.56);
  color: #fff;
  font-size: 0.72rem;
  font-variant-numeric: tabular-nums;
  pointer-events: none;
}

.sb-gallery-dots {
  display: flex;
  justify-content: center;
  gap: 6px;
  margin-top: 8px;
}

.sb-gallery-dots button {
  width: 7px;
  height: 7px;
  padding: 0;
  border: 0;
  border-radius: 999px;
  background: var(--line);
  cursor: pointer;
  transition: width 160ms ease, background 160ms ease;
}

.sb-gallery-dots button.is-active {
  width: 18px;
  background: var(--ink);
}

/* -------------------------------------------------------------------------
 * Front-end profile & settings page
 * ---------------------------------------------------------------------- */

.profile-wrap {
  max-width: 760px;
  margin: 12px 0 48px;
}

.profile-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  padding: 20px 0 24px;
  border-bottom: 1px solid var(--line);
}

.profile-head-main {
  display: flex;
  align-items: flex-start;
  gap: 16px;
  min-width: 0;
}

.profile-avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: var(--soft);
  border: 1px solid var(--line);
  color: var(--ink);
  font-size: 1.45rem;
  font-weight: 600;
  line-height: 1;
  flex-shrink: 0;
}

.profile-name-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.profile-name {
  margin: 0;
  font-size: 1.35rem;
  font-weight: 600;
  color: var(--ink);
}

.profile-role {
  padding: 1px 7px;
  border-radius: 999px;
  background: var(--soft);
  border: 1px solid var(--line);
  font-size: 0.72rem;
  color: var(--muted);
}

.profile-login {
  margin: 4px 0 0;
  font-size: 0.82rem;
  color: var(--muted);
}

.profile-bio {
  margin: 8px 0 0;
  font-size: 0.92rem;
  line-height: 1.65;
  color: var(--text);
}

.profile-primary-btn {
  display: inline-flex;
  align-items: center;
  padding: 7px 14px;
  border: 1px solid var(--ink);
  border-radius: 6px;
  background: var(--ink);
  color: var(--bg);
  font-size: 0.84rem;
  white-space: nowrap;
  cursor: pointer;
}

.profile-primary-btn:hover {
  opacity: 0.88;
}

.profile-tabs {
  display: flex;
  gap: 18px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 20px;
}

.profile-tabs button {
  padding: 10px 2px;
  border: 0;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  background: transparent;
  color: var(--muted);
  font-size: 0.9rem;
  cursor: pointer;
}

.profile-tabs button.is-active {
  color: var(--ink);
  border-bottom-color: var(--ink);
  font-weight: 600;
}

.profile-post-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 0;
  border-bottom: 1px solid var(--line);
}

.profile-post-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.76rem;
  color: var(--muted);
}

.profile-post-status {
  padding: 1px 6px;
  border-radius: 4px;
  background: var(--soft);
  border: 1px solid var(--line);
}

.profile-post-status.is-pub {
  color: #15803d;
  border-color: rgba(22, 163, 74, 0.35);
}

.profile-post-title {
  margin: 4px 0 0;
  font-size: 1rem;
  font-weight: 500;
  color: var(--ink);
}

.profile-post-title a:hover {
  text-decoration: underline;
  text-underline-offset: 3px;
}

.profile-post-actions {
  display: flex;
  gap: 8px;
  flex-shrink: 0;
}

.profile-mini-link {
  padding: 4px 10px;
  border: 1px solid var(--line);
  border-radius: 5px;
  font-size: 0.78rem;
  color: var(--ink);
}

.profile-mini-link:hover {
  border-color: var(--ink);
  background: var(--soft);
}

.profile-form {
  max-width: 480px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.profile-field label {
  display: block;
  margin-bottom: 6px;
  font-size: 0.84rem;
  font-weight: 600;
  color: var(--ink);
}

.profile-field input,
.profile-field textarea {
  width: 100%;
  box-sizing: border-box;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--bg);
  color: var(--text);
  font-family: inherit;
  font-size: 0.9rem;
}

.profile-field input:disabled {
  background: var(--soft);
  color: var(--muted);
}

.profile-form-footer {
  display: flex;
  align-items: center;
  gap: 12px;
}

.profile-msg {
  font-size: 0.84rem;
  color: var(--muted);
}

.profile-msg.is-error {
  color: #dc2626;
}

.profile-empty {
  padding: 32px 0;
  color: var(--muted);
  font-size: 0.92rem;
}

.profile-empty a {
  color: var(--ink);
  text-decoration: underline;
}

@media (max-width: 640px) {
  .profile-head {
    flex-direction: column;
  }
  .profile-post-row {
    flex-direction: column;
    align-items: flex-start;
  }
}

.sb-gallery-nav {
  position: absolute;
  top: 50%;
  transform: translateY(-60%);
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: var(--bg);
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  color: var(--ink);
  font-size: 1.2rem;
  line-height: 1;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.12);
  opacity: 0.78;
  transition: opacity 160ms ease, border-color 140ms ease;
}

.sb-gallery-wrap:hover .sb-gallery-nav,
.sb-gallery-wrap:focus-within .sb-gallery-nav {
  opacity: 1;
}

.sb-gallery-nav:hover {
  border-color: var(--ink);
}

.sb-gallery-nav[hidden] {
  display: none;
}

.sb-gallery-prev {
  left: 8px;
}

.sb-gallery-next {
  right: 8px;
}

@media (hover: none) {
  .sb-gallery-nav {
    opacity: 0.9;
  }
}

/* -------------------------------------------------------------------------
 * Minimal front-end comments
 * ---------------------------------------------------------------------- */

.sb-comments {
  margin-top: 48px;
  padding-top: 28px;
  border-top: 1px solid var(--line);
}

.sb-comments-header {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 18px;
}

.sb-comments-title {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.sb-comments-count {
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.sb-comments-hint {
  font-size: 0.78rem;
  color: var(--muted);
}

.sb-comment-list,
.sb-comment-children {
  list-style: none;
  margin: 0;
  padding: 0;
}

.sb-comment-list {
  display: flex;
  flex-direction: column;
  gap: 16px;
  margin-bottom: 24px;
}

.sb-comment-children {
  margin-top: 12px;
  margin-left: 18px;
  padding-left: 14px;
  border-left: 2px solid var(--line);
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.sb-comment-card {
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--soft);
}

.sb-comment-item.is-pending > .sb-comment-card {
  border-style: dashed;
}

.sb-comment-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 6px;
}

.sb-comment-author-wrap {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.sb-comment-author {
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--ink);
}

.sb-comment-badge {
  padding: 1px 6px;
  border-radius: 999px;
  font-size: 0.7rem;
  line-height: 1.4;
  border: 1px solid var(--line);
  color: var(--muted);
}

.sb-comment-badge.is-author {
  color: var(--ink);
  border-color: var(--ink);
}

.sb-comment-badge.is-pending {
  color: #b45309;
  border-color: rgba(180, 83, 9, 0.35);
}

.sb-comment-time {
  font-size: 0.76rem;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.sb-comment-body {
  font-size: 0.92rem;
  line-height: 1.65;
  color: var(--ink);
  word-break: break-word;
}

.sb-comment-body p {
  margin: 0 0 6px;
}

.sb-comment-body p:last-child {
  margin-bottom: 0;
}

.sb-comment-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 8px;
}

.sb-comment-action {
  padding: 0;
  border: 0;
  background: none;
  color: var(--muted);
  font-size: 0.78rem;
  cursor: pointer;
  transition: color 140ms ease;
}

.sb-comment-action:hover {
  color: var(--ink);
}

.sb-comment-action.is-delete:hover {
  color: #dc2626;
}

.sb-comments-empty,
.sb-comments-closed {
  margin: 0 0 18px;
  font-size: 0.88rem;
  color: var(--muted);
}

.sb-comment-form {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.sb-hp {
  position: absolute;
  left: -9999px;
  width: 1px;
  height: 1px;
  overflow: hidden;
}

.sb-comment-replying {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 10px;
  border-radius: 6px;
  background: var(--soft);
  border: 1px solid var(--line);
  font-size: 0.82rem;
  color: var(--muted);
}

.sb-comment-cancel-reply {
  padding: 0;
  border: 0;
  background: none;
  color: var(--ink);
  font-size: 0.8rem;
  cursor: pointer;
}

.sb-comment-identity {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.84rem;
}

.sb-comment-user {
  font-weight: 600;
  color: var(--ink);
}

.sb-comment-note {
  color: var(--muted);
  font-size: 0.78rem;
}

.sb-comment-guest-row {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.sb-comment-guest-row input,
.sb-comment-form textarea {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--bg);
  color: var(--ink);
  font: inherit;
  font-size: 0.9rem;
  transition: border-color 140ms ease;
}

.sb-comment-guest-row input:focus,
.sb-comment-form textarea:focus {
  outline: none;
  border-color: var(--ink);
}

.sb-comment-form textarea {
  resize: vertical;
  min-height: 84px;
}

.sb-comment-form-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.sb-comment-status {
  font-size: 0.8rem;
  color: var(--muted);
}

.sb-comment-status.is-error {
  color: #dc2626;
}

.sb-comment-status.is-ok {
  color: #15803d;
}

.sb-comment-login-link {
  padding: 0;
  border: 0;
  background: none;
  color: var(--ink);
  font: inherit;
  text-decoration: underline;
  cursor: pointer;
}

.sb-comment-submit {
  padding: 7px 16px;
  border: 1px solid var(--ink);
  border-radius: 999px;
  background: var(--ink);
  color: var(--bg);
  font: inherit;
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  transition: opacity 140ms ease;
}

.sb-comment-submit:hover {
  opacity: 0.88;
}

.sb-comment-submit:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

@media (max-width: 600px) {
  .sb-comment-guest-row {
    grid-template-columns: 1fr;
  }

  .sb-comment-children {
    margin-left: 10px;
    padding-left: 10px;
  }
}
