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

:root {
  --text: #1a1a1a;
  --muted: #888;
  --border: #e8e8e8;
  --accent: #2a6496;
  --bg: #fafafa;
  --max-width: 680px;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Helvetica, Arial, sans-serif;
  font-size: 15px;
  line-height: 1.6;
  color: var(--text);
  background: var(--bg);
}

/* ── Header ── */
.site-header {
  position: relative;
  text-align: center;
  margin-bottom: 0;
  background: #dddfe1;
}

.header-img-wrap {
  max-width: var(--max-width);
  margin: 0 auto;
  aspect-ratio: 2048 / 1365;
  overflow: hidden;
  background: #1a2a3a;
}

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

.header-text {
  padding: 28px 24px 20px;
  background: #fff;
  border-bottom: 1px solid var(--border);
}

.header-text h1 {
  font-size: 1.6rem;
  font-weight: 600;
  letter-spacing: -0.02em;
  color: var(--text);
}

.builder-name {
  color: var(--muted);
  font-size: 0.9rem;
  margin-top: 2px;
}

/* ── Stats bar ── */
.stats-bar {
  display: flex;
  align-items: center;
  gap: 28px;
  flex-wrap: wrap;
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 14px 24px;
  border-bottom: 1px solid var(--border);
  color: var(--muted);
  font-size: 0.85rem;
}

.stats-bar strong { color: var(--text); }

.sync-wrap {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 10px;
}

.sync-btn {
  background: none;
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 4px 10px;
  font-size: 0.8rem;
  color: var(--muted);
  cursor: pointer;
  transition: all 0.15s;
}

.sync-btn:hover { border-color: var(--accent); color: var(--accent); }
.sync-btn.syncing { opacity: 0.5; pointer-events: none; }

.last-sync { font-size: 0.78rem; color: var(--muted); }

/* ── Main log ── */
.log {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 24px 80px;
}

.empty {
  padding: 60px 0;
  text-align: center;
  color: var(--muted);
}

/* ── Section ── */
.log-section {
  margin-top: 56px;
}

.section-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  padding-bottom: 10px;
  border-bottom: 2px solid var(--text);
  margin-bottom: 0;
}

.section-title-wrap {
  display: inline-flex;
  align-items: baseline;
  gap: 8px;
}

.section-header h2 {
  font-size: 1.05rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.section-img-edit-btn {
  background: none;
  border: none;
  font-size: 0.85rem;
  color: var(--muted);
  cursor: pointer;
  padding: 0;
  line-height: 1;
  opacity: 0;
  transition: opacity 0.15s;
}

.section-title-wrap:hover .section-img-edit-btn {
  opacity: 0.6;
}

.section-img-edit-btn:hover {
  opacity: 1 !important;
  color: var(--accent);
}

.section-hours {
  font-size: 0.8rem;
  color: var(--muted);
}

/* ── Section featured image ── */
.section-featured-img-wrap {
  display: flex;
  justify-content: center;
  margin-bottom: 16px;
}

.section-featured-img {
  display: block;
  max-height: 150px;
  width: auto;
  max-width: 100%;
  border-radius: 3px;
  cursor: zoom-in;
  transition: opacity 0.15s;
}

.section-featured-img:hover { opacity: 0.9; }

/* ── Entry ── */
.log-entry {
  padding: 20px 0 20px;
  border-bottom: 1px solid var(--border);
}

.entry-meta {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 4px;
}

.entry-date {
  font-size: 0.78rem;
  color: var(--muted);
  letter-spacing: 0.02em;
}

.entry-hours {
  font-size: 0.78rem;
  color: var(--muted);
}

.entry-task {
  font-size: 0.93rem;
  line-height: 1.5;
  color: var(--text);
}

.entry-helpers {
  font-size: 0.78rem;
  color: var(--muted);
  margin-top: 3px;
}

/* ── Media ── */
.entry-media {
  margin-top: 14px;
}

.video-wrap {
  position: relative;
  width: 100%;
  padding-bottom: 56.25%;
  background: #000;
  border-radius: 4px;
  overflow: hidden;
}

.video-wrap iframe {
  position: absolute;
  top: 0; left: 0;
  width: 100%; height: 100%;
}

.video-wrap.timelapse {
  border: 1px solid var(--border);
}

.media-badge {
  position: absolute;
  top: 8px; left: 8px;
  z-index: 2;
  background: rgba(0,0,0,0.6);
  color: #fff;
  font-size: 0.7rem;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  padding: 2px 7px;
  border-radius: 3px;
  pointer-events: none;
}

.album-link {
  display: inline-block;
  font-size: 0.85rem;
  color: var(--accent);
  text-decoration: none;
  padding: 6px 0;
}
.album-link:hover { text-decoration: underline; }

/* ── Photo grid (multi-photo album entries) ── */
.photo-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 2px;
}

.photo-grid .photo-wrap {
  flex: 1 1 auto;
  min-width: 120px;
  max-width: 300px;
}

.photo-grid .entry-photo {
  width: 100%;
  max-width: 300px;
  max-height: 400px;
  height: auto;
  object-fit: cover;
  border-radius: 3px;
  cursor: zoom-in;
  transition: opacity 0.15s;
  display: block;
}

/* Right column: last photo + inline manual ref stacked vertically */
.photo-col-right {
  flex: 1 1 auto;
  min-width: 120px;
  max-width: 300px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: flex-start;
}

.photo-col-right .photo-wrap {
  flex: none;
  min-width: unset;
  max-width: unset;
  width: 100%;
}

.photo-col-right .entry-photo {
  width: 100%;
  max-width: 300px;
  max-height: 400px;
  object-fit: cover;
}

/* Single photo — keep original layout */
.photo-wrap {
  display: inline-block;
}

.entry-photo {
  display: block;
  max-width: 300px;
  max-height: 400px;
  width: auto;
  height: auto;
  border-radius: 3px;
  cursor: zoom-in;
  transition: opacity 0.15s;
}
.entry-photo:hover { opacity: 0.9; }

/* ── Caption ── */
.caption-wrap { margin-top: 6px; }

.caption {
  font-size: 0.8rem;
  color: var(--muted);
  font-style: italic;
  cursor: pointer;
  line-height: 1.4;
}
.caption:hover { color: var(--text); }

.add-caption-btn {
  background: none;
  border: none;
  font-size: 0.75rem;
  color: #bbb;
  cursor: pointer;
  padding: 0;
}
.add-caption-btn:hover { color: var(--muted); }

.caption-input {
  width: 100%;
  max-width: 400px;
  font-size: 0.8rem;
  font-style: italic;
  color: var(--muted);
  border: none;
  border-bottom: 1px solid var(--border);
  background: transparent;
  padding: 2px 0;
  outline: none;
  font-family: inherit;
}

/* ── Manual ref ── */
.manual-ref-wrap {
  margin-top: 10px;
}

.manual-ref-btn {
  background: none;
  border: none;
  font-size: 0.75rem;
  color: #ccc;
  cursor: pointer;
  padding: 0;
}
.manual-ref-btn:hover { color: var(--muted); }

.manual-ref {
  display: inline-block;
  position: relative;
}

.manual-img {
  display: block;
  max-width: 180px;
  max-height: 240px;
  border-radius: 3px;
  cursor: zoom-in;
  opacity: 0.75;
  transition: opacity 0.15s;
}
.manual-img:hover { opacity: 1; }

.manual-label {
  display: block;
  font-size: 0.7rem;
  color: var(--muted);
  text-align: center;
  margin-top: 3px;
  letter-spacing: 0.04em;
}

/* ── Lightbox ── */
.lightbox {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.88);
  z-index: 1000;
  align-items: center;
  justify-content: center;
  cursor: zoom-out;
}
.lightbox.open { display: flex; }

.lightbox img {
  max-width: 92vw;
  max-height: 92vh;
  object-fit: contain;
  border-radius: 2px;
}

/* ── Footer ── */
.site-footer {
  text-align: center;
  padding: 32px;
  font-size: 0.78rem;
  color: var(--muted);
  border-top: 1px solid var(--border);
}

.footer-admin { margin-top: 10px; }

.admin-link,
.admin-link-btn {
  font-size: 0.72rem;
  color: #ccc;
  text-decoration: none;
  background: none;
  border: none;
  cursor: pointer;
  padding: 0;
  font-family: inherit;
}

.admin-link:hover,
.admin-link-btn:hover { color: var(--muted); }

.admin-link-form { display: inline; }

/* ── Login page ── */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.login-box {
  width: 100%;
  max-width: 320px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 32px 28px;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 6px;
}

.login-box h1 {
  font-size: 1.1rem;
  font-weight: 600;
  text-align: center;
  margin-bottom: 6px;
}

.login-box input[type="password"] {
  font-size: 0.9rem;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 4px;
  font-family: inherit;
}

.login-box button[type="submit"] {
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 4px;
  padding: 9px 10px;
  font-size: 0.9rem;
  cursor: pointer;
}

.login-box button[type="submit"]:hover { opacity: 0.9; }

.login-error {
  color: #c0392b;
  font-size: 0.8rem;
  text-align: center;
}

.login-back {
  text-align: center;
  font-size: 0.78rem;
  color: var(--muted);
  text-decoration: none;
  margin-top: 4px;
}

.login-back:hover { color: var(--accent); }

/* ── TOC Sidebar ── */
.toc-sidebar {
  position: fixed;
  top: 20px;
  right: 20px;
  width: 170px;
  max-height: calc(100vh - 40px);
  overflow-y: auto;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 12px 14px;
  z-index: 200;
  box-shadow: 0 1px 6px rgba(0,0,0,0.07);
}

.toc-title {
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 8px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--border);
}

.toc-list {
  list-style: none;
}

.toc-list li {
  margin: 3px 0;
}

.toc-list a {
  font-size: 0.76rem;
  color: var(--muted);
  text-decoration: none;
  display: block;
  padding: 2px 0;
  line-height: 1.35;
  transition: color 0.1s;
}

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

.toc-list a.toc-active {
  color: var(--accent);
  font-weight: 600;
}

/* ── Gauge Widget ── */
.gauge-widget {
  position: fixed;
  top: 20px;
  left: 20px;
  width: 185px;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 12px 10px 8px;
  z-index: 200;
  box-shadow: 0 1px 6px rgba(0,0,0,0.07);
}

@media (max-width: 600px) {
  .stats-bar { gap: 16px; }
  .sync-wrap { margin-left: 0; width: 100%; }
  .toc-sidebar { display: none; }
  .gauge-widget { display: none; }
}

@media (min-width: 601px) and (max-width: 940px) {
  .toc-sidebar { display: none; }
  .gauge-widget { display: none; }
}
