@import url('https://fonts.googleapis.com/css2?family=Cormorant+Garamond:wght@500;600;700&family=DM+Sans:wght@400;500;700&family=Noto+Sans+SC:wght@400;500;700&family=Noto+Serif+SC:wght@500;600;700&display=swap');

:root {
  --bg: #f5f1e8;
  --surface: #fffaf0;
  --surface-soft: #fbf3e3;
  --surface-warm: #eee2cf;
  --line: #ded1bd;
  --line-strong: #b8a68d;
  --text: #241f1a;
  --muted: #6f6256;
  --accent: #c96442;
  --accent-dark: #8f412c;
  --black: #231f1b;
  --shadow: 0 18px 42px rgba(72, 52, 32, 0.08);
  --pixel-shadow: 6px 6px 0 rgba(35, 31, 27, 0.18);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: "DM Sans", "Noto Sans SC", sans-serif;
  line-height: 1.5;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background:
    linear-gradient(rgba(36, 31, 26, 0.025) 1px, transparent 1px),
    linear-gradient(90deg, rgba(36, 31, 26, 0.018) 1px, transparent 1px);
  background-size: 42px 42px;
}

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

img {
  max-width: 100%;
  display: block;
}

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

.site-shell {
  max-width: 1400px;
  margin: 0 auto;
  padding: 18px clamp(14px, 2.5vw, 32px) 44px;
}

.site-shell.narrow {
  max-width: 980px;
}

.topbar {
  position: sticky;
  top: 10px;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 250, 240, 0.92);
  backdrop-filter: blur(12px);
  box-shadow: 0 8px 24px rgba(72, 52, 32, 0.06);
}

.brand {
  font-family: "Cormorant Garamond", "Noto Serif SC", serif;
  font-size: clamp(1.5rem, 2.8vw, 2.1rem);
  font-weight: 700;
  letter-spacing: 0;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.icon-btn {
  width: 38px;
  height: 38px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--surface);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: border-color 180ms ease, background-color 180ms ease;
}

.icon-btn svg {
  width: 20px;
  height: 20px;
  stroke: currentColor;
  fill: none;
  stroke-width: 1.9;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.icon-btn:hover,
.icon-btn:focus-visible {
  border-color: var(--line-strong);
  background: var(--surface-warm);
}

.sort-select-wrap {
  display: inline-flex;
  align-items: center;
  flex-direction: row;
  justify-content: center;
  gap: 6px;
  margin-top: 0;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  padding: 0 12px;
  height: 42px;
  background: var(--surface);
  box-shadow: 3px 3px 0 rgba(35, 31, 27, 0.1);
  cursor: pointer;
  transition: background-color 180ms ease, border-color 180ms ease, box-shadow 180ms ease;
}

.sort-select-wrap:hover,
.sort-select-wrap:focus-within {
  border-color: var(--black);
  background: #fffdf8;
  box-shadow: 4px 4px 0 rgba(35, 31, 27, 0.16);
}

.sort-select-wrap span {
  color: var(--muted);
  font-size: 0.88rem;
  line-height: 1;
  white-space: nowrap;
}

.sort-select {
  border: 0;
  outline: 0;
  background: transparent;
  min-width: 78px;
  height: 100%;
  padding: 0 2px;
  cursor: pointer;
}

.search-bar {
  margin-top: 12px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  display: flex;
  gap: 8px;
  box-shadow: var(--shadow);
}

.search-bar input {
  flex: 1;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  outline: none;
  background: var(--surface);
}

.search-bar input:focus {
  border-color: var(--line-strong);
}

.mobile-tag-panel {
  margin-top: 12px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.mobile-tag-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}

.mobile-tag-head h2,
.sidebar h2,
.admin-list-head h2 {
  margin: 0;
  font-size: 1rem;
  font-weight: 600;
}

.layout {
  margin-top: 14px;
  display: block;
}

.sidebar {
  display: none;
}

.content-column {
  min-width: 0;
}

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

.post-card {
  border: 2px solid var(--black);
  border-radius: 0;
  overflow: hidden;
  background: var(--surface);
  box-shadow: var(--pixel-shadow);
  cursor: pointer;
  transition: background-color 160ms ease, box-shadow 160ms ease, transform 160ms ease;
}

.post-card:hover,
.post-card:focus-visible {
  background: #fffdf8;
  box-shadow: 8px 8px 0 rgba(35, 31, 27, 0.22);
  transform: translate(-1px, -1px);
}

.post-cover {
  width: 100%;
  aspect-ratio: 4 / 5;
  object-fit: cover;
  background: var(--surface-soft);
}

.card-content {
  padding: 10px 10px 12px;
}

.card-title {
  margin: 0;
  font-size: 0.96rem;
  line-height: 1.35;
  min-height: 2.6em;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.tag-list {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 8px;
}

.tag-list.one-row {
  flex-wrap: nowrap;
  overflow: hidden;
  white-space: nowrap;
}

.tag-btn,
.tag-chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 30px;
  padding: 0 12px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: rgba(255, 250, 240, 0.82);
  color: var(--muted);
  font-size: 0.84rem;
  white-space: nowrap;
}

.tag-btn {
  cursor: pointer;
  transition: background-color 180ms ease, border-color 180ms ease, color 180ms ease;
}

.tag-btn:hover,
.tag-btn:focus-visible,
.tag-btn.active {
  background: var(--black);
  border-color: var(--black);
  color: #ffffff;
}

.empty-state {
  margin-top: 16px;
  border: 1px dashed var(--line-strong);
  border-radius: 8px;
  padding: 18px;
  text-align: center;
  color: var(--muted);
}

.pagination {
  margin-top: 18px;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}

.page-info {
  min-width: 70px;
  text-align: center;
  color: var(--muted);
}

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

.jump-wrap input {
  width: 86px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 10px;
  background: var(--surface);
}

.btn {
  height: 36px;
  padding: 0 14px;
  border-radius: 8px;
  border: 1px solid var(--black);
  background: var(--black);
  color: #ffffff;
  cursor: pointer;
  transition: opacity 180ms ease;
}

.btn:hover,
.btn:focus-visible {
  opacity: 0.88;
}

.btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

.btn.ghost {
  border-color: var(--line-strong);
  background: var(--surface);
  color: var(--text);
}

.site-footer {
  margin-top: 28px;
  padding: 22px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-soft);
  display: grid;
  gap: 18px;
}

.site-footer h2 {
  margin: 0 0 6px;
  font-size: 0.96rem;
}

.site-footer p {
  margin: 0;
}

.site-footer a {
  color: var(--accent-dark);
  text-decoration: underline;
  text-underline-offset: 3px;
}

.hidden {
  display: none !important;
}

.post-detail {
  margin-top: 14px;
  padding: clamp(14px, 2.8vw, 28px);
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.post-title {
  margin: 0;
  font-family: "Cormorant Garamond", "Noto Serif SC", serif;
  font-size: clamp(1.9rem, 3.8vw, 2.8rem);
  line-height: 1.15;
}

.meta-row {
  margin-top: 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
  color: var(--muted);
}

.detail-cover {
  margin-top: 14px;
  width: 100%;
  max-height: 540px;
  object-fit: cover;
  border-radius: 8px;
  border: 1px solid var(--line);
}

.like-row {
  margin-top: 14px;
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.like-btn {
  border: 1px solid var(--line-strong);
  background: var(--surface);
  border-radius: 999px;
  min-height: 38px;
  padding: 6px 14px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  transition: border-color 180ms ease, color 180ms ease;
}

.like-btn svg {
  width: 20px;
  height: 20px;
  stroke: currentColor;
  fill: none;
  stroke-width: 1.7;
}

.like-btn:hover,
.like-btn:focus-visible,
.like-btn.liked {
  border-color: var(--black);
  color: var(--black);
}

.like-btn.liked svg {
  fill: var(--black);
}

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

.markdown-body {
  margin-top: 18px;
  color: #22242a;
}

.markdown-body h1,
.markdown-body h2,
.markdown-body h3,
.markdown-body h4,
.markdown-body h5,
.markdown-body h6 {
  font-family: "Cormorant Garamond", "Noto Serif SC", serif;
  margin: 1.2em 0 0.6em;
  line-height: 1.2;
}

.markdown-body p,
.markdown-body ul,
.markdown-body ol,
.markdown-body blockquote {
  margin: 0.8em 0;
}

.markdown-body a {
  text-decoration: underline;
  text-underline-offset: 2px;
}

.markdown-body img {
  border: 1px solid var(--line);
  border-radius: 14px;
  margin: 12px 0;
}

.markdown-body .md-clickable-image {
  cursor: zoom-in;
}

.markdown-body .md-image-single {
  margin: 12px 0;
}

.markdown-body .md-image-single > img,
.markdown-body .md-image-single > a > img {
  margin: 0;
}

.markdown-body .md-image-row {
  margin: 12px 0;
  display: flex;
  gap: 10px;
  overflow-x: auto;
  padding-bottom: 6px;
  scroll-snap-type: x mandatory;
  -webkit-overflow-scrolling: touch;
}

.markdown-body .md-image-row-item {
  flex: 0 0 auto;
  scroll-snap-align: start;
}

.markdown-body .md-image-row-item img {
  margin: 0;
  height: 190px;
  width: auto;
  max-width: none;
  border: 1px solid var(--line);
  border-radius: 12px;
}

.markdown-body pre {
  background: #f7f7f9;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  overflow-x: auto;
}

.markdown-body code {
  font-family: "JetBrains Mono", "SFMono-Regular", Consolas, monospace;
  font-size: 0.92em;
}

.image-viewer {
  position: fixed;
  inset: 0;
  z-index: 1200;
  background: rgba(8, 9, 12, 0.94);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 22px;
}

.viewer-stage {
  width: min(92vw, 1180px);
  height: min(84vh, 860px);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  touch-action: none;
}

.viewer-image {
  max-width: 100%;
  max-height: 100%;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  user-select: none;
  -webkit-user-drag: none;
  transform-origin: center center;
  transition: transform 140ms ease;
}

.viewer-stage.is-gesturing .viewer-image {
  transition: none;
}

.viewer-nav,
.viewer-close,
.viewer-tool {
  border: 1px solid rgba(255, 255, 255, 0.3);
  background: rgba(18, 19, 23, 0.6);
  color: #ffffff;
  cursor: pointer;
  transition: background-color 180ms ease, border-color 180ms ease;
}

.viewer-nav:hover,
.viewer-close:hover,
.viewer-tool:hover,
.viewer-nav:focus-visible,
.viewer-close:focus-visible,
.viewer-tool:focus-visible {
  background: rgba(28, 30, 35, 0.86);
  border-color: rgba(255, 255, 255, 0.45);
}

.viewer-close {
  position: absolute;
  top: 18px;
  right: 18px;
  width: 42px;
  height: 42px;
  border-radius: 12px;
  font-size: 1.5rem;
  line-height: 1;
}

.viewer-nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 42px;
  height: 58px;
  border-radius: 12px;
  font-size: 1.7rem;
  line-height: 1;
}

.viewer-prev {
  left: 14px;
}

.viewer-next {
  right: 14px;
}

.viewer-toolbar {
  position: absolute;
  bottom: 16px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 8px;
  border: 1px solid rgba(255, 255, 255, 0.24);
  background: rgba(10, 11, 14, 0.7);
  border-radius: 12px;
  padding: 8px;
}

.viewer-tool {
  min-width: 44px;
  height: 34px;
  border-radius: 8px;
}

.viewer-counter {
  min-width: 74px;
  text-align: center;
  color: rgba(255, 255, 255, 0.9);
  font-size: 0.9rem;
}

body.viewer-open {
  overflow: hidden;
}

.admin-login-card,
.admin-panel {
  margin-top: 14px;
  padding: clamp(14px, 2.5vw, 24px);
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.admin-login-card h1,
.admin-panel h1 {
  margin: 0 0 6px;
  font-size: 1.36rem;
}

label {
  margin-top: 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 0.95rem;
}

input,
textarea,
select {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  outline: none;
  background: var(--surface);
}

input:focus,
textarea:focus,
select:focus {
  border-color: var(--line-strong);
}

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

.form-message {
  min-height: 1.4em;
  margin: 10px 0 0;
  color: var(--muted);
}

.admin-list-head {
  margin-top: 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
}

.admin-search-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
}

.admin-post-list {
  margin-top: 12px;
  display: grid;
  gap: 10px;
}

.admin-post-item {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: var(--surface-soft);
}

.admin-post-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}

.admin-post-top h3 {
  margin: 0;
  font-size: 1rem;
}

.admin-post-meta {
  margin-top: 8px;
  color: var(--muted);
  font-size: 0.88rem;
}

.admin-post-actions {
  margin-top: 10px;
  display: flex;
  align-items: center;
  gap: 8px;
}

@media (min-width: 1024px) {
  .mobile-tag-panel {
    display: none;
  }

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

  .sidebar {
    display: block;
    position: sticky;
    top: 86px;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 14px;
    background: var(--surface);
    box-shadow: var(--shadow);
    max-height: calc(100vh - 108px);
    overflow: hidden;
  }

  .sidebar-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
  }

  .sidebar-toggle {
    min-width: 94px;
    height: 32px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--surface-soft);
    color: var(--muted);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    cursor: pointer;
    transition: border-color 180ms ease, color 180ms ease, background-color 180ms ease;
  }

  .sidebar-toggle:hover,
  .sidebar-toggle:focus-visible {
    border-color: var(--line-strong);
    color: var(--text);
    background: var(--surface-warm);
  }

  .sidebar-toggle svg {
    width: 16px;
    height: 16px;
    stroke: currentColor;
    fill: none;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
    transition: transform 180ms ease;
  }

  .desktop-tag-list {
    align-content: flex-start;
    max-height: min(48vh, 430px);
    overflow-y: auto;
    padding-right: 4px;
    scrollbar-width: thin;
    scrollbar-color: var(--line-strong) transparent;
  }

  .desktop-tag-list.collapsed {
    max-height: 154px;
  }

  .desktop-tag-list::-webkit-scrollbar {
    width: 8px;
  }

  .desktop-tag-list::-webkit-scrollbar-thumb {
    background: var(--line-strong);
    border-radius: 999px;
  }

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

  .markdown-body .md-image-single.md-image-single-half > img,
  .markdown-body .md-image-single.md-image-single-half > a > img {
    width: 50%;
    min-width: 260px;
    margin-left: auto;
    margin-right: auto;
  }
}

@media (max-width: 760px) {
  .sort-select-wrap span {
    display: none;
  }

  .sort-select {
    min-width: 70px;
  }

  .topbar {
    padding: 10px;
  }

  .brand {
    font-size: 1.45rem;
  }

  .card-content {
    padding: 8px;
  }

  .card-title {
    font-size: 0.9rem;
  }

  .jump-wrap {
    margin-left: 0;
  }

  .markdown-body .md-image-row-item img {
    height: 156px;
  }

  .image-viewer {
    padding: 10px;
  }

  .viewer-stage {
    width: 100%;
    height: 82vh;
  }

  .viewer-nav {
    width: 36px;
    height: 48px;
    font-size: 1.35rem;
  }

  .viewer-prev {
    left: 6px;
  }

  .viewer-next {
    right: 6px;
  }

  .viewer-close {
    top: 8px;
    right: 8px;
  }

  .viewer-toolbar {
    bottom: 10px;
    padding: 6px;
    gap: 6px;
  }

  .viewer-tool {
    min-width: 40px;
    height: 32px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation: none !important;
    transition: none !important;
    scroll-behavior: auto !important;
  }
}
