:root {
  --bg: #ffffff;
  --surface: #f8fdff;
  --text: #1a2b33;
  --muted: #5b6c73;
  --accent: #d97a4b;
  --accent-strong: #ba5f34;
  --border: #eadccd;
  --radius: 16px;
  --max-width: 800px;
}

* {
  box-sizing: border-box;
}

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

body {
  font-family: "Rubik", "Segoe UI", Tahoma, sans-serif;
  color: var(--text);
  background: var(--bg);
  line-height: 1.6;
}

a {
  color: inherit;
}

.site-header {
  position: sticky;
  top: 0;
  z-index: 10;
  backdrop-filter: blur(6px);
  background: rgba(255, 255, 255, 0.9);
  border-bottom: 1px solid var(--border);
}

.header-inner,
.page-wrap {
  width: min(var(--max-width), calc(100% - 2rem));
  margin: 0 auto;
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.8rem 0;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.75rem;
  text-decoration: none;
}

.brand-logo {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  display: inline-grid;
  place-items: center;
  background: linear-gradient(145deg, var(--accent), #e9a073);
  color: #fff;
  font-weight: 700;
  letter-spacing: 0.02em;
}

.brand-name {
  margin: 0;
  font-size: 1.1rem;
  line-height: 1.2;
  font-weight: 450;
}

.notify-btn,
.action-btn,
.read-btn,
.carousel-btn,
.carousel-close {
  border: 1px solid transparent;
  font-family: inherit;
  cursor: pointer;
  transition: transform 0.2s ease, background-color 0.2s ease;
}

.notify-btn {
  border-radius: 999px;
  padding: 0.55rem 1rem;
  font-weight: 500;
  color: var(--accent-strong);
  border-color: #e8d3bd;
  background: #fdf7f1;
}

.notify-btn:hover,
.notify-btn:focus-visible,
.read-btn:hover,
.read-btn:focus-visible,
.action-btn:hover,
.action-btn:focus-visible,
.carousel-btn:hover,
.carousel-close:hover {
  transform: translateY(-1px);
}

.page-wrap {
  padding: 2rem 0 4rem;
}

.page-title {
  font-size: clamp(1.4rem, 3vw, 2rem);
  margin: 0 0 0.35rem;
}

.page-lead {
  margin: 0;
  color: var(--muted);
}

.date-group {
  margin-top: 2.1rem;
}

.date-title {
  margin: 0 0 1rem;
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
}

.posts-list {
  display: grid;
  gap: 1.2rem;
}

.post-card {
  display: grid;
  grid-template-columns: minmax(220px, 300px) 1fr;
  gap: 1rem;
  padding: 0 0 1.2rem;
}

.image-frame {
  display: block;
  overflow: hidden;
  border-radius: 12px;
  aspect-ratio: 1 / 1;
  background: #f8efe6;
}

.image-placeholder {
  background: linear-gradient(135deg, #f1dfcf, #f9f2ea);
}

.image-frame img,
.gallery-grid img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: transform 0.35s ease;
}

.image-frame:hover img,
.gallery-grid button:hover img {
  transform: scale(1.07);
}

.post-preview {
  margin: 0.6rem 0 1rem;
  color: #2a4149;
  text-align: justify;
}

.read-btn {
  border-radius: 10px;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.55rem 0.95rem;
  font-weight: 600;
  color: #fff;
  background: linear-gradient(135deg, var(--accent), #e79b6d);
}

.gallery-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 0.7rem;
  margin-bottom: 1.8rem;
}

.gallery-grid button,
.gallery-video {
  border: 0;
  margin: 0;
  padding: 0;
  border-radius: 12px;
  overflow: hidden;
  background: #f8efe6;
  aspect-ratio: 1 / 1;
}

.gallery-grid button {
  cursor: pointer;
}

.gallery-video video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.gallery-video video:fullscreen,
.gallery-video video:-webkit-full-screen {
  object-fit: contain;
  background: #000;
}

.gallery-video:fullscreen,
.gallery-video:-webkit-full-screen {
  aspect-ratio: auto;
  min-height: 0;
  border-radius: 0;
  overflow: visible;
  background: #000;
  display: flex;
  align-items: center;
  justify-content: center;
}

.gallery-video:-moz-full-screen {
  aspect-ratio: auto;
  min-height: 0;
  border-radius: 0;
  overflow: visible;
  background: #000;
  display: flex;
  align-items: center;
  justify-content: center;
}

.gallery-video:fullscreen video,
.gallery-video:-webkit-full-screen video,
.gallery-video:-moz-full-screen video,
.gallery-video video:fullscreen,
.gallery-video video:-webkit-full-screen,
.gallery-video video:-moz-full-screen {
  width: 100vw !important;
  height: 100vh !important;
  max-width: 100vw !important;
  max-height: 100vh !important;
  object-fit: contain !important;
  object-position: center center !important;
  background: #000 !important;
}

video:fullscreen,
video:-webkit-full-screen,
video:-moz-full-screen,
:fullscreen video,
:-webkit-full-screen video,
:-moz-full-screen video {
  width: 100vw !important;
  height: 100vh !important;
  max-width: 100vw !important;
  max-height: 100vh !important;
  object-fit: contain !important;
  object-position: center center !important;
  background: #000 !important;
}

body[data-post-id] article {
  --text-measure: 48rem;
}

body[data-post-id] .gallery-grid {
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  gap: 0.85rem;
}

body[data-post-id] .gallery-grid button,
body[data-post-id] .gallery-video {
  aspect-ratio: 1 / 1;
  min-height: 250px;
}

body[data-post-id] .page-lead,
body[data-post-id] .post-content,
body[data-post-id] .post-actions {
  width: min(var(--text-measure), 100%);
  margin-left: auto;
  margin-right: auto;
}

body[data-post-id] .page-lead {
  margin-bottom: 1.15rem;
}

.post-content {
  border-top: 0;
  padding-top: 0;
}

.post-content p {
  margin: 0.8rem 0;
}

.post-text {
  margin: 0.8rem 0;
}

.post-text a {
  color: var(--accent-strong);
}

.post-text code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
  font-size: 0.92em;
  background: #f5ece3;
  border-radius: 6px;
  padding: 0.12rem 0.32rem;
}

.post-text .tg-pre {
  display: inline-block;
  white-space: pre-wrap;
  word-break: break-word;
  line-height: 1.45;
  padding: 0.42rem 0.52rem;
}

.post-text .tg-spoiler {
  border-radius: 4px;
  background: #1c2f38;
  color: transparent;
  padding: 0 0.22em;
  transition: color 0.15s ease;
}

.post-text .tg-spoiler:hover,
.post-text .tg-spoiler:focus-visible {
  color: #f7f7f7;
}

.post-text blockquote {
  border-left: 4px solid #e4be98;
  margin: 0.7rem 0;
  padding: 0.45rem 0 0.45rem 0.8rem;
  color: #34525c;
  background: #fdf7f2;
}

.post-actions {
  margin-top: 1.6rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.8rem;
}

.action-btn {
  border-radius: 10px;
  padding: 0.65rem 1rem;
  border-color: #ecd8c4;
  color: #6a4c34;
  background: #fdf8f3;
  font-weight: 500;
}

.action-btn[data-liked="true"] {
  border-color: #d8ae86;
  background: #f7e7d8;
}

.empty {
  padding: 1rem;
  border: 1px dashed #d7dbe3;
  border-radius: 12px;
  color: var(--muted);
  background: #fafbfe;
  margin-top: 1.5rem;
}

.carousel {
  position: fixed;
  inset: 0;
  z-index: 1000;
  background: rgba(8, 21, 25, 0.88);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 0;
}

.carousel.is-open {
  display: flex;
}

.carousel-track {
  width: 100vw;
  height: 100vh;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.carousel-image {
  width: 100%;
  height: 100%;
  object-fit: contain;
  border-radius: 8px;
  background: #0f2026;
  cursor: zoom-in;
  transform-origin: center center;
  transition: transform 0.2s ease;
  touch-action: none;
}

.carousel-image.is-zoomed {
  cursor: grab;
}

.carousel-image.is-dragging {
  cursor: grabbing;
  transition: none;
}

.carousel-btn,
.carousel-close {
  border-radius: 50%;
  width: 44px;
  height: 44px;
  font-size: 1.2rem;
  color: #fff;
  border-color: rgba(255, 255, 255, 0.3);
  background: rgba(255, 255, 255, 0.1);
}

.carousel-close {
  position: absolute;
  top: max(0.55rem, env(safe-area-inset-top));
  right: max(0.55rem, env(safe-area-inset-right));
  border-color: rgba(255, 255, 255, 0.52);
  background: rgba(10, 20, 24, 0.62);
  backdrop-filter: blur(3px);
  z-index: 4;
}

.carousel-btn {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  z-index: 2;
}

.carousel-btn:hover,
.carousel-btn:focus-visible {
  transform: translateY(calc(-50% - 1px));
}

[data-prev] {
  left: 0.4rem;
}

[data-next] {
  right: 0.4rem;
}

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

@media (max-width: 760px) {
  .header-inner {
    gap: 0.6rem;
  }

  .brand-name {
    font-size: 1rem;
  }

  .notify-btn {
    padding: 0.45rem 0.75rem;
    font-size: 0.95rem;
    white-space: nowrap;
  }

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

  .post-card .image-frame {
    width: 100%;
  }

  body[data-post-id] .gallery-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.6rem;
  }

  body[data-post-id] .gallery-grid button,
  body[data-post-id] .gallery-video {
    aspect-ratio: 4 / 5;
    min-height: 170px;
  }
}
