:root {
  --bg: #f4f4f2;
  --bg-deep: #e7e7e3;
  --surface: #ffffff;
  --surface-soft: #f1f1ee;
  --ink: #111111;
  --ink-soft: #505050;
  --line: #cfcfcb;
  --line-strong: #999994;
  --shadow: 0 18px 40px rgba(15, 15, 15, 0.08);
  --shadow-soft: 0 10px 24px rgba(15, 15, 15, 0.05);
  --radius: 18px;
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  min-height: 100dvh;
  color: var(--ink);
  font-family: "Avenir Next", "PingFang SC", "Hiragino Sans GB", "Helvetica Neue", sans-serif;
  background:
    linear-gradient(160deg, rgba(255, 255, 255, 0.85), rgba(242, 242, 239, 0.9)),
    repeating-linear-gradient(
      90deg,
      rgba(0, 0, 0, 0.012) 0,
      rgba(0, 0, 0, 0.012) 1px,
      transparent 1px,
      transparent 4px
    ),
    var(--bg);
  overflow: hidden;
}

.bg-shape {
  position: fixed;
  border-radius: 999px;
  pointer-events: none;
  z-index: 0;
}

.bg-shape-a {
  width: 360px;
  height: 360px;
  top: -120px;
  right: -90px;
  background: radial-gradient(circle, rgba(0, 0, 0, 0.1), transparent 70%);
  filter: blur(24px);
}

.bg-shape-b {
  width: 300px;
  height: 300px;
  left: -110px;
  bottom: -140px;
  background: radial-gradient(circle, rgba(255, 255, 255, 0.88), transparent 74%);
  filter: blur(30px);
}

.app {
  position: relative;
  z-index: 1;
  max-width: 1240px;
  height: 100dvh;
  margin: 0 auto;
  padding: 28px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: app-enter 520ms ease-out both;
}

.topbar {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--line);
}

.brand {
  margin: 0;
  font-size: clamp(2rem, 4.2vw, 3.4rem);
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.tagline {
  margin: 0;
  color: var(--ink-soft);
  font-size: 0.92rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.layout {
  display: grid;
  grid-template-columns: minmax(270px, 360px) minmax(0, 1fr);
  gap: 18px;
  align-items: stretch;
  flex: 1;
  min-height: 0;
}

.gallery-panel,
.entry-panel {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
  min-height: 0;
}

.gallery-panel {
  padding: 12px;
  height: 100%;
  overflow-y: auto;
}

.panel-title {
  margin: 8px 8px 12px;
  font-size: 0.76rem;
  text-transform: uppercase;
  letter-spacing: 0.18em;
  color: var(--ink-soft);
}

.gallery {
  display: grid;
  gap: 10px;
}

.gallery-card {
  display: grid;
  grid-template-columns: 88px 1fr;
  gap: 10px;
  width: 100%;
  border: 1px solid var(--line);
  background: var(--surface);
  color: inherit;
  border-radius: 12px;
  padding: 8px;
  text-align: left;
  cursor: pointer;
  box-shadow: var(--shadow-soft);
  transition:
    transform 160ms ease,
    border-color 160ms ease,
    background-color 160ms ease,
    box-shadow 160ms ease;
}

.gallery-card:hover {
  transform: translateY(-2px);
  border-color: var(--line-strong);
  background: #fafaf9;
}

.gallery-card:focus-visible {
  outline: 2px solid #161616;
  outline-offset: 2px;
}

.gallery-card.is-selected {
  border-color: #161616;
  background: var(--surface-soft);
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.25);
}

.gallery-thumb {
  width: 100%;
  height: 88px;
  object-fit: cover;
  border-radius: 8px;
  border: 1px solid var(--line);
}

.gallery-copy {
  min-width: 0;
}

.gallery-date {
  margin: 2px 0 4px;
  font-size: 0.72rem;
  letter-spacing: 0.06em;
  color: var(--ink-soft);
  text-transform: uppercase;
}

.gallery-preview {
  margin: 0;
  font-size: 0.98rem;
  line-height: 1.38;
  line-clamp: 2;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.entry-panel {
  padding: 18px;
  animation: panel-enter 420ms ease-out both;
  height: 100%;
  overflow-y: auto;
}

.entry-toolbar {
  display: flex;
  margin-bottom: 12px;
}

.entry-back {
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  padding: 0.38rem 0.78rem;
  background: #f7f7f5;
  color: var(--ink);
  font: inherit;
  font-size: 0.86rem;
  cursor: pointer;
  transition:
    background-color 140ms ease,
    border-color 140ms ease;
}

.entry-back:hover {
  border-color: #2b2b2b;
  background: #ecece9;
}

.entry-back:focus-visible {
  outline: 2px solid #161616;
  outline-offset: 2px;
}

.entry-hero {
  margin: 0;
}

.entry-photo {
  width: 100%;
  max-height: 58vh;
  object-fit: cover;
  border-radius: 12px;
  border: 1px solid var(--line);
}

.entry-caption {
  margin-top: 9px;
  color: var(--ink-soft);
  font-size: 0.82rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.entry-markdown {
  margin-top: 16px;
  padding: 20px;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: #fcfcfb;
  font-family: "Iowan Old Style", "Songti SC", "STSong", "Palatino", serif;
  line-height: 1.8;
  font-size: 1.05rem;
}

.entry-markdown h1,
.entry-markdown h2,
.entry-markdown h3 {
  margin-top: 1.35em;
  margin-bottom: 0.45em;
  line-height: 1.24;
  font-family: "Avenir Next", "PingFang SC", "Hiragino Sans GB", sans-serif;
  letter-spacing: 0.02em;
}

.entry-markdown p,
.entry-markdown ul,
.entry-markdown ol,
.entry-markdown blockquote {
  margin-top: 0;
  margin-bottom: 1em;
}

.entry-markdown a {
  color: inherit;
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
}

.entry-markdown blockquote {
  margin-left: 0;
  border-left: 3px solid #252525;
  padding-left: 0.9em;
  color: #383838;
}

.entry-markdown code {
  background: #ececea;
  padding: 0.12em 0.35em;
  border-radius: 4px;
  font-size: 0.9em;
}

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

.error-banner {
  margin: 16px 0 0;
  border: 1px solid #2a2a2a;
  border-radius: 10px;
  background: #f1f1f1;
  color: #1a1a1a;
  padding: 10px 12px;
}

@keyframes app-enter {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes panel-enter {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (max-width: 960px) {
  .app {
    padding: 18px;
  }

  .topbar {
    flex-direction: column;
    align-items: flex-start;
    gap: 6px;
  }

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

  .app.is-mobile.mobile-show-gallery .entry-panel {
    display: none;
  }

  .app.is-mobile.mobile-show-entry .gallery-panel {
    display: none;
  }

  .app.is-mobile.mobile-show-entry .topbar {
    display: none;
  }

  .app.is-mobile .layout {
    gap: 0;
  }

  .app.is-mobile .gallery-panel,
  .app.is-mobile .entry-panel {
    height: 100%;
  }

  .gallery {
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  }

  .app.is-mobile .gallery {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 640px) {
  .brand {
    letter-spacing: 0.07em;
  }

  .gallery-card {
    grid-template-columns: 84px 1fr;
  }

  .gallery-thumb {
    height: 84px;
  }

  .entry-panel {
    padding: 14px;
  }

  .entry-markdown {
    padding: 16px;
  }
}
