:root {
  --bg: #ffffff;
  --text: #1a1a1a;
  --accent: #555555;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #111111;
    --text: #f0f0f0;
    --accent: #aaaaaa;
  }
}

* { 
  box-sizing: border-box; 
  margin: 0; 
  padding: 0; 
}

html {
  scroll-behavior: smooth;
}

::selection {
  background: var(--text);
  color: var(--bg);
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  line-height: 1.3;
  max-width: 640px;
  margin: 0 auto;
  padding: 2rem 1rem;
}

h1 { 
  font-size: 1.6rem; 
  font-weight: 700; 
  margin-bottom: 0.15rem;
  letter-spacing: -0.02em;
}

.headline { 
  color: var(--accent); 
  font-size: 0.85rem; 
  margin-bottom: 1.25rem;
  font-weight: 400;
}

.site-sections {
  margin-bottom: 1.5rem;
  font-size: 0.85rem;
}
.site-sections a {
  color: var(--accent);
  text-decoration: none;
  margin-right: 1rem;
  transition: color 0.2s;
}
.site-sections a:hover {
  color: var(--text);
  text-decoration: underline;
}

.overview p { 
  margin-bottom: 0.75rem; 
  line-height: 1.4;
  letter-spacing: -0.01em;
  font-size: 0.95rem;
}

.overview .cta {
  margin-top: 1rem;
  margin-bottom: 0;
}

.overview-more {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.4s ease-out, opacity 0.3s ease-out;
  opacity: 0;
}

.overview-more.expanded {
  max-height: 2000px;
  opacity: 1;
  transition: max-height 0.5s ease-in, opacity 0.3s ease-in;
}

.text-fade {
  height: 70px;
  margin-top: -70px;
  background: linear-gradient(
    to bottom,
    rgba(255, 255, 255, 0) 0%,
    rgba(255, 255, 255, 0.5) 30%,
    rgba(255, 255, 255, 0.85) 70%,
    var(--bg) 100%
  );
  opacity: 1;
  transition: opacity 0.3s ease;
  pointer-events: none;
  position: relative;
  z-index: 1;
}

.text-fade.hidden {
  opacity: 0;
  height: 0;
  margin-top: 0;
}

.read-more-btn {
  background: none;
  border: none;
  color: var(--accent);
  font-family: inherit;
  font-size: 0.9rem;
  cursor: pointer;
  padding: 0;
  margin-top: 0.75rem;
  text-decoration: underline;
  text-underline-offset: 2px;
  transition: color 0.2s;
}

.read-more-btn:hover {
  color: var(--text);
}

.contact-form label {
  display: block;
  margin-bottom: 0.15rem;
  font-size: 0.8rem;
  color: var(--accent);
}

.contact-form input,
.contact-form textarea {
  width: 100%;
  padding: 0.5rem;
  margin-bottom: 0.75rem;
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--accent);
  border-radius: 4px;
  font-family: inherit;
  font-size: 0.9rem;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.contact-form input:focus,
.contact-form textarea:focus {
  outline: none;
  border-color: var(--text);
  box-shadow: 0 0 0 3px rgba(128, 128, 128, 0.12);
}

.contact-form textarea {
  min-height: 80px;
  resize: vertical;
}

.contact-form button {
  background: var(--text);
  color: var(--bg);
  border: none;
  padding: 0.5rem 1rem;
  cursor: pointer;
  font-weight: 500;
  font-size: 0.85rem;
  border-radius: 4px;
  transition: transform 0.15s ease, opacity 0.2s;
}

.contact-form button:hover {
  opacity: 0.85;
  transform: translateY(-1px);
}

.contact a {
  color: var(--accent);
  text-decoration: none;
  transition: color 0.2s;
}

.contact a:hover {
  color: var(--text);
  text-decoration: underline;
}

.contact .meta {
  margin-top: 0.875rem;
  font-size: 0.85rem;
  color: var(--accent);
  line-height: 1.5;
}

.contact p:first-of-type {
  margin-bottom: 0.4rem;
}

.contact-form,
.contact {
  border-top: 1px solid rgba(0, 0, 0, 0.08);
  margin-top: 1.5rem;
  padding-top: 1rem;
}

/* ============================================
   BLOG POSTS
   ============================================ */

.blog-post h1 {
  font-size: 1.8rem;
  font-weight: 700;
  margin-bottom: 0.5rem;
  letter-spacing: -0.02em;
}

.blog-post time {
  display: block;
  font-size: 0.85rem;
  color: var(--accent);
  margin-bottom: 1.5rem;
}

.blog-post .content {
  margin-top: 1.5rem;
}

.blog-post .content p {
  margin-bottom: 1.25rem;
  line-height: 1.6;
  letter-spacing: -0.01em;
  font-size: 1.05rem;
}

.blog-post .content h2,
.blog-post .content h3 {
  margin-top: 2rem;
  margin-bottom: 1rem;
  font-weight: 600;
}

.blog-post .content a {
  color: var(--accent);
  text-decoration: underline;
  transition: color 0.2s;
}

.blog-post .content a:hover {
  color: var(--text);
}

/* ============================================
   NOTES
   ============================================ */

.note-post time {
  display: block;
  font-size: 0.85rem;
  color: var(--accent);
  margin-bottom: 0.75rem;
}

.note-post .content {
  margin-top: 0.75rem;
}

.notes-timeline {
  margin-top: 1.5rem;
}

.note-card {
  position: relative;
  padding-bottom: 1.5rem;
  margin-bottom: 1.5rem;
  border-bottom: 1px solid rgba(0, 0, 0, 0.08);
}

.note-card:last-child {
  border-bottom: none;
  margin-bottom: 0;
}

.note-card time {
  display: block;
  font-size: 0.8rem;
  color: var(--accent);
  margin-bottom: 0.5rem;
}

.note-truncate {
  max-height: 8em;
  overflow: hidden;
  transition: max-height 0.4s ease-out;
  line-height: 1.4;
  font-size: 0.95rem;
  letter-spacing: -0.01em;
}

.note-truncate p:last-child {
  margin-bottom: 0;
}

.note-truncate.expanded {
  max-height: 2000px;
  transition: max-height 0.5s ease-in;
}

.note-card.is-short .text-fade,
.note-card.is-short .read-more-btn {
  display: none;
}

.note-prose {
  line-height: 1.4;
  font-size: 0.95rem;
  letter-spacing: -0.01em;
}
.note-prose > p {
  margin-bottom: 0.75rem;
}
.note-prose > p:last-child {
  margin-bottom: 0;
}

.note-card.is-hidden {
  display: none;
}

.load-sentinel {
  text-align: center;
  font-size: 0.85rem;
  color: var(--accent);
  padding: 1.5rem 0;
  opacity: 0;
  transition: opacity 0.3s;
}
.load-sentinel.is-visible {
  opacity: 1;
}

/* ============================================
   POST LIST
   ============================================ */

.post-list {
  margin-top: 1.5rem;
}

.post-list article {
  margin-bottom: 1.5rem;
  padding-bottom: 1.5rem;
  border-bottom: 1px solid rgba(0, 0, 0, 0.08);
}

.post-list article:last-child {
  border-bottom: none;
  margin-bottom: 0;
}

.post-list h2 {
  font-size: 1.2rem;
  font-weight: 600;
  margin-bottom: 0.25rem;
}

.post-list h2 a {
  color: var(--text);
  text-decoration: none;
  transition: color 0.2s;
}

.post-list h2 a:hover {
  color: var(--accent);
}

.post-list time {
  font-size: 0.85rem;
  color: var(--accent);
}

.back-link {
  font-size: 0.85rem;
  margin-bottom: 1rem;
}
.back-link a {
  color: var(--accent);
  text-decoration: none;
  transition: color 0.2s;
}
.back-link a:hover {
  color: var(--text);
  text-decoration: underline;
}

@keyframes noteReveal {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.note-card.is-revealed {
  animation: noteReveal 0.35s ease-out;
}

/* ============================================
   NOTE GALLERY
   ============================================ */

.note-gallery {
  display: grid;
  gap: 2px;
  margin-top: 0.75rem;
  border-radius: 8px;
  overflow: hidden;
  max-height: 300px;
}

/* ---- Single media: full aspect ratio, left-aligned, transparent ---- */

.note-gallery.is-single {
  display: block;
  max-height: none;
  background: transparent;
  overflow: visible;
  cursor: pointer; 
}

.note-gallery.is-single .gallery-item {
  display: inline-block;
  width: auto;
  max-width: 100%;
  cursor: default;
  background: transparent;
  overflow: visible;
  border-radius: 8px;
}

.note-gallery.is-single .gallery-item img,
.note-gallery.is-single .gallery-item video {
  width: auto;
  max-width: 100%;
  height: auto;
  max-height: 520px;
  object-fit: contain;
  display: block;
  border-radius: 8px;
}

/* Single image: clickable for lightbox */
.note-gallery.is-single .gallery-item.is-image {
  cursor: pointer;
}

/* Single video: no pseudo-element blocking, let native controls work */
.note-gallery.is-single .gallery-item.is-video {
  cursor: pointer;
}

/* Detail view single: larger max-height */
.note-gallery.note-gallery--detail.is-single .gallery-item img,
.note-gallery.note-gallery--detail.is-single .gallery-item video {
  max-height: 720px;
}

/* ---- Multiple media: collage layout ---- */

.note-gallery[data-count="2"] {
  grid-template-columns: 1fr 1fr;
  max-height: 200px;
}

.note-gallery[data-count="3"] {
  grid-template-columns: 1fr 1fr;
  grid-template-rows: 1fr 1fr;
  max-height: 300px;
}

.note-gallery[data-count="3"] .gallery-item:first-child {
  grid-row: span 2;
}

.note-gallery[data-count="4"],
.note-gallery[data-count="5"],
.note-gallery[data-count="6"],
.note-gallery[data-count="7"],
.note-gallery[data-count="8"] {
  grid-template-columns: 1fr 1fr;
  grid-template-rows: 1fr 1fr;
  max-height: 300px;
}

.gallery-item {
  position: relative;
  overflow: hidden;
  cursor: pointer;
  background: var(--bg);
}

/* Images in all layouts */
.gallery-item.is-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: transform 0.2s ease;
}

.gallery-item.is-image:hover img {
  transform: scale(1.02);
}

/* Videos in multi-layout: contain, full aspect ratio */
.gallery-item.is-video {
  background: #000;
}

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

/* Custom play/pause buttons for multi-video — bottom LEFT */
.gallery-video-play,
.gallery-video-pause {
  position: absolute;
  bottom: 8px;
  left: 8px;
  background: rgba(0, 0, 0, 0.6);
  border: none;
  color: #fff;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 4;
  padding: 0;
}

.gallery-video-play:hover,
.gallery-video-pause:hover {
  background: rgba(0, 0, 0, 0.85);
}

/* Hide pause by default */
.gallery-item.is-video .gallery-video-pause {
  display: none;
}

/* Show pause when playing */
.gallery-item.is-video.playing .gallery-video-play {
  display: none;
}

.gallery-item.is-video.playing .gallery-video-pause {
  display: flex;
}

/* Click on video body (not buttons) opens lightbox — ONLY for multi-video */
/* Use a child div instead of pseudo-element to avoid blocking controls */
.gallery-item.is-video .video-click-area {
  position: absolute;
  inset: 0;
  z-index: 2;
  cursor: pointer;
}

.gallery-more {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.5);
  color: #fff;
  font-size: 1.5rem;
  font-weight: 600;
  pointer-events: none;
  z-index: 3;
}

/* ============================================
   NOTE GALLERY — DETAIL VIEW
   ============================================ */

.note-gallery.note-gallery--detail {
  max-height: 400px;
}

/* Override for single media in detail view */
.note-gallery.note-gallery--detail.is-single {
  max-height: none;
}

.note-gallery.note-gallery--detail[data-count="2"] {
  grid-template-columns: 1fr 1fr;
  grid-template-rows: 1fr;
  max-height: 260px;
}

.note-gallery.note-gallery--detail[data-count="3"] {
  grid-template-columns: 1fr 1fr;
  grid-template-rows: 1fr 1fr;
  max-height: 400px;
}

.note-gallery.note-gallery--detail[data-count="3"] .gallery-item:first-child {
  grid-row: span 2;
}

.note-gallery.note-gallery--detail[data-count="4"] {
  grid-template-columns: 1fr 1fr;
  grid-template-rows: 1fr 1fr;
  max-height: 400px;
}

/* ============================================
   CLICKABLE NOTE TEXT
   ============================================ */

.note-text-clickable {
  cursor: pointer;
}

.note-date-link {
  display: block;
  text-decoration: none;
  color: var(--accent);
  margin-bottom: 0.5rem;
}

.note-date-link:hover {
  color: var(--text);
}

/* ============================================
   NOTE DETAIL VIEW
   ============================================ */

.note-post--detail {
  margin-top: 0.5rem;
}

.note-post--detail time {
  display: block;
  font-size: 0.9rem;
  color: var(--accent);
  margin-bottom: 1.25rem;
}

.note-prose--detail {
  font-size: 1.05rem;
  line-height: 1.5;
}

.note-prose--detail p {
  margin-bottom: 1rem;
}

/* ============================================
   LIGHTBOX
   ============================================ */

.lightbox-modal {
  position: fixed;
  inset: 0;
  z-index: 1000;
  background: rgba(0, 0, 0, 0.92);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  animation: lightboxIn 0.2s ease;
  touch-action: none;
}

.lightbox-frame {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  max-width: 90vw;
  max-height: 85vh;
}

.lightbox-content {
  position: relative;
  max-width: 100%;
  max-height: 85vh;
  z-index: 1;
}

.lightbox-content img,
.lightbox-content video {
  max-width: 100%;
  max-height: 85vh;
  object-fit: contain;
  border-radius: 4px;
  display: block;
}

.lightbox-close {
  position: absolute;
  top: -2.5rem;
  right: 0;
  background: none;
  border: none;
  color: #fff;
  font-size: 2rem;
  cursor: pointer;
  padding: 0.5rem;
  line-height: 1;
  opacity: 0.7;
  transition: opacity 0.2s;
  z-index: 2;
}

.lightbox-close:hover {
  opacity: 1;
}

.lightbox-prev,
.lightbox-next {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  background: rgba(0, 0, 0, 0.4);
  border: none;
  color: #fff;
  font-size: 1.5rem;
  cursor: pointer;
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  opacity: 0.8;
  transition: opacity 0.2s;
  z-index: 2;
}

.lightbox-prev:hover,
.lightbox-next:hover {
  opacity: 1;
}

.lightbox-prev {
  left: -22px;
}

.lightbox-next {
  right: -22px;
}

.lightbox-prev:disabled,
.lightbox-next:disabled {
  opacity: 0.2;
  cursor: default;
  pointer-events: none;
  transition: none;
}

/* ============================================
   MOBILE OVERRIDES
   ============================================ */

@media (max-width: 640px) {
  .note-card .text-fade {
    visibility: hidden;
    height: 0;
    margin-top: 0;
    opacity: 0;
  }
  
  .note-card .note-truncate {
    max-height: none;
    display: -webkit-box;
    -webkit-line-clamp: 4;
    line-clamp: 4;
    -webkit-box-orient: vertical;
    overflow: hidden;
  }
  
  .note-card .note-truncate.expanded {
    display: block;
    -webkit-line-clamp: unset;
    line-clamp: unset;
    overflow: visible;
  }
  
  .note-card .read-more-btn {
    margin-top: 0.5rem;
  }
  
  .lightbox-modal {
    padding: 0.5rem;
  }
  
  .lightbox-frame {
    max-width: 95vw;
  }
  
  .lightbox-close {
    top: 0.5rem;
    right: 0.5rem;
  }
  
  /* Mobile arrows: smaller but still visible */
  .lightbox-prev,
  .lightbox-next {
    width: 36px;
    height: 36px;
    font-size: 1.2rem;
  }
  
  .lightbox-prev {
    left: -12px;
  }
  
  .lightbox-next {
    right: -12px;
  }
}

/* ============================================
   TABLET ARROW SPACING
   ============================================ */

@media (min-width: 641px) and (max-width: 1024px) {
  .lightbox-prev {
    left: -18px;
  }
  
  .lightbox-next {
    right: -18px;
  }
}

/* ============================================
   DARK MODE SUPPORT
   ============================================ */

@media (prefers-color-scheme: dark) {
  .contact-form,
  .contact {
    border-top: 1px solid rgba(255, 255, 255, 0.08);
  }
  
  .contact-form input:focus,
  .contact-form textarea:focus {
    box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.08);
  }

  .text-fade {
    background: linear-gradient(
      to bottom,
      rgba(17, 17, 17, 0) 0%,
      rgba(17, 17, 17, 0.5) 30%,
      rgba(17, 17, 17, 0.85) 70%,
      var(--bg) 100%
    );
  }
  
  .note-card,
  .post-list article {
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  }
}

/* ============================================
   CUSTOM VIDEO PLAYER
   ============================================ */

.cv-wrapper {
  position: relative;
  display: inline-block;
  max-width: 100%;
  line-height: 0;
}

.cv-wrapper video {
  display: block;
  max-width: 100%;
  max-height: 520px;
  border-radius: 8px;
}

.note-gallery--detail .cv-wrapper video {
  max-height: 720px;
}

.cv-tap-layer {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 2;
  cursor: pointer;
}

.cv-bar {
  position: absolute;
  bottom: 0;
  left: 0;
  width: 100%;
  background: linear-gradient(to top, rgba(0,0,0,0.75) 0%, rgba(0,0,0,0) 100%);
  padding: 2.5rem 0.75rem 0.5rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  opacity: 0;
  transition: opacity 0.25s ease;
  pointer-events: none;
  z-index: 3;
  box-sizing: border-box;
}

.cv-bar-visible,
.cv-wrapper:hover .cv-bar {
  opacity: 1;
  pointer-events: auto;
}

.cv-bar button {
  background: none;
  border: none;
  color: #fff;
  font-size: 1rem;
  cursor: pointer;
  padding: 0.25rem;
  line-height: 1;
  opacity: 0.9;
  transition: opacity 0.15s;
  flex-shrink: 0;
}

.cv-bar button:hover {
  opacity: 1;
}

.cv-playpause {
  width: 1.5rem;
  text-align: center;
}

.cv-progress {
  flex: 1;
  min-width: 0;
  -webkit-appearance: none;
  appearance: none;
  height: 3px;
  background: rgba(255,255,255,0.3);
  border-radius: 2px;
  outline: none;
  cursor: pointer;
}

.cv-progress::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 12px;
  height: 12px;
  background: #fff;
  border-radius: 50%;
  cursor: pointer;
}

.cv-progress::-moz-range-thumb {
  width: 12px;
  height: 12px;
  background: #fff;
  border-radius: 50%;
  cursor: pointer;
  border: none;
}

.cv-time {
  color: #fff;
  font-size: 0.75rem;
  font-variant-numeric: tabular-nums;
  min-width: 4.5rem;
  text-align: center;
  opacity: 0.9;
  flex-shrink: 0;
}

/* Fullscreen: video fills screen, controls overlay */
.cv-wrapper.is-fullscreen {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: #000;
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
}

.cv-wrapper.is-fullscreen video {
  max-width: 100vw;
  max-height: 100vh;
  width: auto;               /* natural video size, up to viewport */
  height: auto;
  object-fit: contain;
  border-radius: 0;
}

.cv-wrapper.is-fullscreen .cv-tap-layer {
  position: absolute;
  inset: 0;
}

.cv-wrapper.is-fullscreen .cv-bar {
  padding-bottom: 1.5rem;
}