* { box-sizing: border-box; }

:root {
    --bg: #ffffff;
    --ink: #1a1a1a;
    --muted: #676767;
    --line: #e8e8e8;
    --bubble-bg: #305f8a;
    --bubble-text: #fff;
    --meta-text: #7a8fa0;
    --meta-year: #2a2a2a;
    --meta-link: #a0b5c5;
    --meta-link-hover: #3a8fd9;
    --header-text: #1a1a1a;
    --toggle-bg: #dde4eb;
    --toggle-icon: #555;
}

[data-theme="dark"] {
    --bg: #161f27;
    --ink: #f2f6fa;
    --muted: #9db0c2;
    --line: rgba(160, 175, 190, 0.22);
    --bubble-bg: #305f8a;
    --bubble-text: #fff;
    --meta-text: #6b8ba4;
    --meta-year: #d0d0d0;
    --meta-link: #4a7a9e;
    --meta-link-hover: #8bb8dc;
    --header-text: #fff;
    --toggle-bg: #2b3a4a;
    --toggle-icon: #8fa4b8;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    font-size: 14px;
    color: var(--ink);
    background: var(--bg);
    margin: 0;
    padding: 0;
    line-height: 1.55;
    transition: background 0.3s ease;
}

.site-header {
    padding: 1rem 1rem 0.65rem;
    background: var(--bg);
    text-align: center;
    position: relative;
    transition: background 0.3s ease;
}

.site-header h1 {
    margin: 0;
    font-size: 1rem;
    font-weight: 500;
    letter-spacing: 0;
}

.site-header h1 a {
    color: inherit;
    text-decoration: underline;
    text-decoration-thickness: 1px;
    text-underline-offset: 2px;
}

.site-header h1 a:hover {
    opacity: 0.7;
}

.theme-toggle {
    position: absolute;
    right: 14px;
    top: 8px;
    background: var(--toggle-bg);
    border: none;
    border-radius: 20px;
    padding: 8px 11px;
    cursor: pointer;
    display: flex;
    align-items: center;
    color: var(--toggle-icon);
    transition: opacity 0.2s ease;
}

.theme-toggle:hover { opacity: 0.8; }

.feed {
    max-width: 600px;
    margin: 0 auto;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.message {
    max-width: 88%;
    margin: 0 auto;
}

.bubble {
    background: var(--bubble-bg);
    border-radius: 16px 16px 16px 4px;
    padding: 12px 16px;
    font-size: 15px;
    color: var(--bubble-text);
    transition: background 0.3s ease;
    scroll-margin-top: 80px;
}

.bubble p {
    margin: 0 0 0.6em 0;
}

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

.bubble a {
    color: #ffe4a0;
    text-decoration: none;
    background: rgba(255,200,100,0.15);
    padding: 1px 2px;
    border-radius: 4px;
}

.bubble a:hover {
    background: rgba(255,200,100,0.25);
}

.bubble code {
    background: rgba(255,255,255,0.15);
    padding: 2px 5px;
    border-radius: 3px;
    font-family: 'SF Mono', Monaco, monospace;
    font-size: 14px;
}

.bubble pre {
    background: rgba(255,255,255,0.1);
    padding: 10px;
    border-radius: 6px;
    overflow-x: auto;
    font-family: 'SF Mono', Monaco, monospace;
    font-size: 13px;
    margin: 8px 0;
}

.meta {
    margin-top: 6px;
    padding-left: 6px;
    font-size: 12px;
    color: var(--meta-text);
    transition: color 0.3s ease;
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 6px;
}

.meta a {
    color: var(--meta-link);
    text-decoration: none;
    transition: color 0.3s ease;
}

.meta .msg-anchor {
    margin-left: 8px;
}

.meta .hashtags {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    flex-wrap: wrap;
}

.meta .hashtag-pill {
    margin-left: 0;
    font-size: 10px;
    line-height: 1;
    padding: 2px 7px;
    border-radius: 999px;
    color: rgb(42, 42, 42);
    background: var(--toggle-bg);
    border: 1px solid rgba(127, 127, 127, 0.18);
}

.meta .hashtag-pill:hover {
    border-color: rgba(127, 127, 127, 0.35);
}

[data-theme="dark"] .meta .hashtag-pill {
    color: #fff;
}

.meta a:hover {
    color: var(--meta-link-hover);
}

.meta strong {
    color: var(--meta-year);
}

.bubble:target {
    /* A soft, buttery yellow */
    box-shadow: 0 0 0 3px rgb(247, 238, 75);
}

[data-theme="dark"] .bubble:target {
    /* A slightly brighter, "shimmering" pale yellow for dark mode */
    box-shadow: 0 0 0 3px rgba(247, 238, 75, 0.757);
}

.footer {
    max-width: 600px;
    margin: 0 auto;
    padding: 40px 20px;
    font-size: 13px;
    color: var(--meta-text);
    text-align: center;
}

.footer p {
    margin: 0.3em 0;
}

.footer a {
    color: var(--meta-link);
    text-decoration: none;
}

.footer a:hover {
    text-decoration: underline;
}

.footer a.year-filter-active {
    color: var(--header-text);
    text-decoration: underline;
}

/* Image styles */
.photo-wrapper {
    cursor: pointer;
    position: relative;
}

.photo-wrapper:hover .message-photo {
    opacity: 0.9;
}

.message-photo {
    width: 100%;
    max-width: 100%;
    height: auto;
    border-radius: 12px;
    margin-bottom: 12px;
    display: block;
    transition: opacity 0.2s ease;
}

/* Video styles */
.video-wrapper {
    margin-bottom: 12px;
    max-width: 100%;
}

.message-video {
    width: 100%;
    max-width: 100%;
    height: auto;
    border-radius: 12px;
    display: block;
    background: #000;
}

/* YouTube embed styles */
.youtube-embed {
    position: relative;
    width: 100%;
    max-width: 100%;
    margin: 12px 0;
    padding-bottom: 56.25%; /* 16:9 aspect ratio */
    height: 0;
    overflow: hidden;
    border-radius: 12px;
}

.youtube-embed iframe {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    border-radius: 12px;
}

/* Lightbox styles */
.lightbox {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.95);
    z-index: 10000;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.lightbox.active {
    display: flex;
}

.lightbox img {
    max-width: 95%;
    max-height: 95vh;
    object-fit: contain;
    border-radius: 4px;
}

.lightbox-close {
    position: absolute;
    top: 20px;
    right: 30px;
    font-size: 40px;
    color: white;
    cursor: pointer;
    background: none;
    border: none;
    padding: 0;
    line-height: 1;
    z-index: 10001;
}

.lightbox-close:hover {
    color: #ccc;
}

/* Gallery layouts for multi-image posts */
.gallery {
    display: grid;
    gap: 4px;
    margin-bottom: 12px;
    border-radius: 12px;
    overflow: hidden;
}

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

/* Grid layouts */
.gallery.cols-2 {
    grid-template-columns: repeat(2, 1fr);
}

.gallery.cols-3 {
    grid-template-columns: repeat(3, 1fr);
}

.gallery.cols-4 {
    grid-template-columns: repeat(4, 1fr);
}

/* Custom 3-photo layouts */
.gallery.layout-3a {
    grid-template-columns: 2fr 1fr;
    grid-template-rows: repeat(2, 1fr);
}

.gallery.layout-3a img:first-child {
    grid-row: 1 / 3;
}

.gallery.layout-3b {
    grid-template-columns: 1fr 1fr;
    grid-template-rows: 2fr 1fr;
}

.gallery.layout-3b img:first-child {
    grid-column: 1 / 3;
}

/* Custom 4-photo layouts */
.gallery.layout-4a {
    grid-template-columns: repeat(3, 1fr);
    grid-template-rows: 2fr 1fr;
}

.gallery.layout-4a img:first-child {
    grid-column: 1 / 4;
}

.gallery.layout-4b {
    grid-template-columns: 2fr 1fr;
    grid-template-rows: repeat(3, 1fr);
}

.gallery.layout-4b img:first-child {
    grid-row: 1 / 4;
}

/* Custom 5-photo layouts */
.gallery.layout-5a {
    grid-template-columns: repeat(3, 1fr);
    grid-template-rows: 2fr 2fr;
}

.gallery.layout-5a img:nth-child(1),
.gallery.layout-5a img:nth-child(2) {
    grid-row: 1;
}

.gallery.layout-5a img:nth-child(1) {
    grid-column: 1 / 3;
}

.gallery.layout-5b {
    grid-template-columns: repeat(3, 1fr);
    grid-template-rows: 2fr 1fr;
}

.gallery.layout-5b img:nth-child(1),
.gallery.layout-5b img:nth-child(2),
.gallery.layout-5b img:nth-child(3) {
    grid-row: 1;
}

.gallery.layout-5b img:nth-child(4),
.gallery.layout-5b img:nth-child(5) {
    grid-row: 2;
    grid-column: span 1.5;
}

.gallery.layout-5c {
    grid-template-columns: 2fr repeat(2, 1fr);
    grid-template-rows: repeat(2, 1fr);
}

.gallery.layout-5c img:first-child {
    grid-row: 1 / 3;
}

/* Custom 6-photo layout */
.gallery.layout-6a {
    grid-template-columns: 2fr 1fr;
    grid-template-rows: repeat(3, 1fr);
}

.gallery.layout-6a img:first-child {
    grid-row: 1 / 4;
}

@media (max-width: 640px) {
    .feed { padding: 12px; }
    .message { max-width: 95%; }
    .broadcast-grid-wrap { padding-left: 5px; }
    .broadcast-day { width: auto; height: auto; flex: 1 1 0; aspect-ratio: 1; min-width: 0; }
    .broadcast-day.has-posts .ct { font-size: 6px; }
    .broadcast-month-label { width: 24px; font-size: 8px; }
    .broadcast-days { gap: 1px; flex: 1; min-width: 0; }
    .broadcast-month-row { margin-bottom: 1px; }
}

.page {
    max-width: 660px;
    margin: 0 auto;
    padding: 0.5rem 1rem 22px;
}

.section {
    padding: 0 0 0.8rem;
    margin-bottom: 0.7rem;
}

.section:last-child {
    margin-bottom: 0;
}

.broadcast-section {
    padding-top: 0.18rem;
}

.section-title {
    margin: 0 0 0.4rem;
    font-size: 0.78rem;
    font-weight: 600;
    line-height: 1.8;
    text-align: center;
}

.greybg {
    display: inline-block;
    color: var(--muted);
    padding: 0;
    border-radius: 0;
    font-size: 0.78rem;
    text-transform: lowercase;
    letter-spacing: 0.08em;
}

/* Calendar grid */
.broadcast-grid-wrap {
    max-width: 620px;
    margin: 0 auto;
    padding-left: 15px;
}

.broadcast-month-row {
    display: flex;
    align-items: center;
    margin-bottom: 2px;
}

.broadcast-month-label {
    width: 30px;
    font-size: 9px;
    font-weight: 600;
    color: var(--meta-text);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    flex-shrink: 0;
    text-align: right;
    padding-right: 5px;
}

.broadcast-days {
    display: flex;
    gap: 2px;
}

.broadcast-day {
    width: 15px;
    height: 15px;
    border-radius: 2px;
    background: var(--toggle-bg);
    opacity: 0.25;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.1s ease;
}

.broadcast-day.has-posts {
    background: var(--bubble-bg);
    cursor: pointer;
}

.broadcast-day.has-posts.d1 { opacity: 0.3; }
.broadcast-day.has-posts.d2 { opacity: 0.5; }
.broadcast-day.has-posts.d3 { opacity: 0.7; }
.broadcast-day.has-posts.d4 { opacity: 0.85; }
.broadcast-day.has-posts.d5 { opacity: 1; }

.broadcast-day.has-posts .ct {
    font-size: 8px;
    font-weight: 700;
    color: rgba(255, 255, 255, 0.92);
    line-height: 1;
    pointer-events: none;
}

.broadcast-day.has-posts:hover {
    transform: scale(1.5);
    z-index: 10;
    box-shadow: 0 0 0 2px var(--bubble-bg), 0 2px 8px rgba(0, 0, 0, 0.3);
}

.broadcast-day.blank { visibility: hidden; }

.broadcast-popup-bg {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.45);
    z-index: 1000;
    align-items: center;
    justify-content: center;
}

.broadcast-popup-bg.active { display: flex; }

.broadcast-popup {
    background: var(--bg);
    border: 1px solid rgba(128, 128, 128, 0.25);
    border-radius: 12px;
    padding: 20px 24px;
    min-width: 180px;
    max-width: 280px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.35);
    position: relative;
}

.broadcast-popup-name {
    font-size: 11px;
    color: var(--meta-text);
    margin-bottom: 14px;
}

.broadcast-popup-row {
    display: flex;
    align-items: baseline;
    gap: 8px;
    margin-bottom: 5px;
}

.broadcast-popup-row:last-child { margin-bottom: 0; }

.broadcast-popup-year {
    font-weight: 600;
    font-size: 13px;
    color: var(--header-text);
    min-width: 36px;
}

.broadcast-popup-links {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}

.broadcast-popup-links a {
    color: var(--meta-link);
    text-decoration: none;
    font-size: 12px;
    font-family: 'SF Mono', Monaco, monospace;
}

.broadcast-popup-links a:hover {
    color: var(--meta-link-hover);
    text-decoration: underline;
}

.broadcast-popup-x {
    position: absolute;
    top: 10px;
    right: 14px;
    background: none;
    border: none;
    color: var(--meta-text);
    font-size: 18px;
    cursor: pointer;
    padding: 0;
    line-height: 1;
}

.broadcast-popup-x:hover { color: var(--header-text); }

.broadcast-grid-stats {
    text-align: center;
    font-size: 11px;
    color: var(--meta-text);
    margin-top: 14px;
}

.broadcast-grid-stats span {
    font-weight: 600;
    color: var(--ink, var(--header-text));
}

.no-content {
    color: var(--meta-text);
    text-align: center;
    padding: 40px;
}

/* Highlighted post on landing page */
.highlight-section {
    max-width: 600px;
    margin: 4px auto 0;
    padding: 0 20px;
}

.highlight-header {
    display: flex;
    justify-content: flex-end;
    margin-bottom: 4px;
}

.highlight-shuffle {
    background: var(--toggle-bg);
    border: none;
    border-radius: 50%;
    width: 28px;
    height: 28px;
    font-size: 16px;
    line-height: 1;
    color: var(--toggle-icon);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.highlight-shuffle:hover {
    color: var(--meta-link-hover);
    transform: rotate(90deg);
}

.highlight-card .message {
    max-width: 100%;
}

/* Year navigation */
.year-nav {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 24px;
    padding: 16px 20px;
    border-bottom: 1px solid rgba(128,128,128,0.15);
}

.year-nav .nav-link {
    color: var(--meta-link);
    text-decoration: none;
    font-size: 14px;
    padding: 6px 12px;
    border-radius: 6px;
    transition: all 0.2s ease;
}

.year-nav .nav-link:hover {
    color: var(--meta-link-hover);
    background: var(--toggle-bg);
}

.year-nav .nav-link.home {
    font-weight: 600;
    color: var(--header-text);
}

.year-nav .nav-link.disabled {
    color: var(--meta-link);
    cursor: default;
}
