:root {
  --bg: #0e0f12;
  --bg-elev: #16181d;
  --bg-row: #131519;
  --bg-row-alt: #181a1f;
  --fg: #e8e8ea;
  --fg-dim: #9aa0a6;
  --accent: #76e1ff;
  --border: #2a2d34;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 16px;
  line-height: 1.5;
}

/* ─────── Top bar ─────── */

.topshelf {
  position: sticky;
  top: 0;
  z-index: 5;
  background: var(--bg-elev);
  border-bottom: 1px solid var(--border);
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.7rem 1.25rem;
}

.topbar .brand {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  font-size: 1.15rem;
  font-weight: 600;
  color: var(--fg);
  text-decoration: none;
  letter-spacing: -0.01em;
}

.brand-logo {
  width: 32px;
  height: 32px;
  border-radius: 6px;
  object-fit: contain;
  display: block;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 0.85rem;
}

.topbar .ext {
  font-size: 0.85rem;
  color: var(--fg-dim);
  text-decoration: none;
}

.topbar .ext:hover { color: var(--accent); }

/* ─────── Language switch ─────── */

.lang-switch {
  display: inline-flex;
  border: 1px solid var(--border);
  border-radius: 6px;
  overflow: hidden;
}

.lang-btn {
  background: transparent;
  color: var(--fg-dim);
  border: none;
  padding: 0.3rem 0.6rem;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.05em;
  cursor: pointer;
  font-family: inherit;
}

.lang-btn + .lang-btn { border-left: 1px solid var(--border); }
.lang-btn.active { background: var(--bg); color: var(--fg); }
.lang-btn:hover:not(.active) { color: var(--fg); }

/* ─────── Page ─────── */

.page {
  max-width: 1100px;
  margin: 0 auto;
  padding: 1.5rem 1.25rem 3rem;
}

header { margin-bottom: 1.25rem; }

header .sub {
  margin: 0;
  color: var(--fg-dim);
  font-size: 0.95rem;
  max-width: 640px;
}

/* ─────── Tabs ─────── */

.tabs {
  display: flex;
  gap: 0.4rem;
  padding: 0 1.25rem;
  border-top: 1px solid var(--border);
}

.view { margin-top: 1rem; }

.tab {
  background: transparent;
  color: var(--fg-dim);
  border: none;
  border-bottom: 2px solid transparent;
  padding: 0.55rem 0.9rem;
  font-size: 0.95rem;
  font-family: inherit;
  cursor: pointer;
  margin-bottom: -1px;
}

.tab:hover { color: var(--fg); }
.tab.active {
  color: var(--fg);
  border-bottom-color: var(--accent);
}

.view { animation: fade 0.15s ease-out; }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }

/* ─────── Project page ─────── */

.project {
  max-width: 720px;
  margin: 0 auto;
  color: var(--fg);
  font-size: 1rem;
  line-height: 1.7;
}

.project-hero {
  padding: 1.5rem 0 2rem;
  border-bottom: 1px solid var(--border);
  margin-bottom: 2.25rem;
}

.project-hero h1 {
  margin: 0;
  font-size: clamp(1.9rem, 4vw, 2.4rem);
  font-weight: 600;
  letter-spacing: -0.02em;
  line-height: 1.15;
}

.project-eyebrow {
  margin: 0.4rem 0 1.25rem;
  color: var(--fg-dim);
  font-size: 0.95rem;
  font-style: italic;
}

.project-tagline {
  margin: 0;
  font-size: 1.15rem;
  color: var(--fg);
  max-width: 600px;
  font-weight: 400;
  line-height: 1.5;
}

.project-intro p {
  margin: 0;
  font-size: 1.05rem;
  color: var(--fg);
}

.project-section {
  margin-top: 2.75rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border);
}

.project-section h2 {
  margin: 0 0 1.25rem;
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--fg);
  letter-spacing: -0.01em;
}

.project-section h3 {
  margin: 1.75rem 0 0.5rem;
  font-size: 1rem;
  font-weight: 500;
  color: var(--accent);
  letter-spacing: 0.01em;
}

.project-section h3:first-of-type { margin-top: 0; }

.project-section p {
  margin: 0 0 1rem;
  color: var(--fg);
}

.project-section em { color: var(--fg); font-style: italic; }

.project-manifesto p { color: #d8d9dc; }

.project-emphasis {
  margin-top: 1.25rem !important;
  padding-left: 1rem;
  border-left: 2px solid var(--accent);
  font-style: italic;
  color: var(--fg) !important;
}

.project-spec dl {
  margin: 0;
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: 0.6rem 1.25rem;
}

.project-spec dt {
  color: var(--fg-dim);
  font-size: 0.9rem;
  font-weight: 500;
  text-align: right;
  padding-top: 0.05rem;
}

.project-spec dd {
  margin: 0;
  color: var(--fg);
  font-size: 0.95rem;
}

.project-credits p {
  margin: 0 0 0.4rem;
  color: var(--fg-dim);
  font-size: 0.95rem;
}

.project-credits strong { color: var(--fg); font-weight: 600; }

.project a {
  color: var(--accent);
  text-decoration: none;
  border-bottom: 1px solid rgba(118, 225, 255, 0.3);
  transition: border-color 0.12s ease;
}

.project a:hover { border-bottom-color: var(--accent); }

@media (max-width: 600px) {
  .project { font-size: 0.97rem; }
  .project-spec dl { grid-template-columns: 1fr; gap: 0.25rem 0; }
  .project-spec dt { text-align: left; padding-top: 0.5rem; }
  .project-spec dt:first-child { padding-top: 0; }
}

/* ─────── Color map ─────── */

.map-help {
  margin: 0 0 1rem;
  color: var(--fg-dim);
  font-size: 0.9rem;
}

.colormap-wrap {
  border: 1px solid var(--border);
  border-radius: 6px;
  overflow: hidden;
}

.cm-grid {
  display: grid;
  gap: 1px;
  background: var(--border);
  /* First row (hour-label header) sizes to its content; data rows are forced
     to the cell size below so the day-label doesn't make the row tall. */
  grid-template-rows: auto;
  grid-auto-rows: 20px;
}

/* Header row + day-label cells use flex for text centering */
.cm-corner,
.cm-hour,
.cm-day {
  background: var(--bg-elev);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.72rem;
  color: var(--fg-dim);
}

.cm-corner,
.cm-hour {
  padding: 0.3rem 0.2rem;
  background: var(--bg);
  text-align: center;
}

.cm-day {
  padding: 0 0.5rem;
  font-variant-numeric: tabular-nums;
  background: var(--bg);
  font-weight: 500;
  color: var(--fg);
  justify-content: flex-end;
  font-size: 0.78rem;
}

/* Cells: explicit display:block so aspect-ratio drives both width and row height
   (with flex they were widening the row to fit phantom line-height). */
.cm-cell {
  display: block;
  background: var(--bg-elev);
  aspect-ratio: 1 / 1;
  cursor: pointer;
  transition: transform 0.08s ease;
}

.cm-cell.empty { background: var(--bg-elev); cursor: default; }

.cm-cell:not(.empty):hover {
  transform: scale(1.8);
  z-index: 2;
  outline: 1px solid var(--accent);
  border-radius: 2px;
}

/* ─────── Controls ─────── */

.controls {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
  margin-bottom: 1rem;
}

.controls label { font-size: 0.9rem; color: var(--fg-dim); }

.controls select {
  background: var(--bg-elev);
  color: var(--fg);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.4rem 0.6rem;
  font-size: 0.95rem;
  color-scheme: dark;
  min-width: 160px;
}

.controls button {
  background: transparent;
  color: var(--fg-dim);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.4rem 0.8rem;
  font-size: 0.9rem;
  cursor: pointer;
}

.controls button:hover {
  color: var(--fg);
  border-color: var(--accent);
}

.controls .count {
  color: var(--fg-dim);
  font-size: 0.9rem;
  margin-left: auto;
}

/* ─────── Table ─────── */

.table-wrap { overflow-x: auto; }

table.photos {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.95rem;
}

table.photos thead th {
  text-align: left;
  font-weight: 500;
  color: var(--fg-dim);
  padding: 0.6rem 0.9rem;
  border-bottom: 1px solid var(--border);
  background: var(--bg-elev);
}

table.photos tbody tr {
  background: var(--bg-row);
  border-bottom: 1px solid var(--border);
}

table.photos tbody tr:nth-child(even) { background: var(--bg-row-alt); }

table.photos tbody td {
  padding: 0.6rem 0.9rem;
  vertical-align: middle;
}

.col-img    { width: 220px; }
.col-time   { width: 180px; }
.col-color  { width: 120px; }

.thumb {
  width: 200px;
  height: 130px;
  object-fit: cover;
  display: block;
  border-radius: 6px;
  cursor: pointer;
  transition: transform 0.1s ease, outline-color 0.1s ease;
  outline: 1px solid transparent;
}

.thumb:hover,
.thumb:focus-visible {
  transform: translateY(-1px);
  outline-color: var(--accent);
}

.time-cell .time {
  font-variant-numeric: tabular-nums;
  color: var(--fg-dim);
  font-size: 0.9rem;
}

.color-placeholder { color: var(--fg-dim); }

.color-box {
  display: flex;
  align-items: center;
  gap: 0.55rem;
}

.swatch {
  width: 28px;
  height: 28px;
  border-radius: 5px;
  border: 1px solid var(--border);
  flex: none;
  display: inline-block;
}

.color-text {
  display: flex;
  flex-direction: column;
  line-height: 1.25;
  font-size: 0.82rem;
}

.color-hex {
  color: var(--fg);
  font-family: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
}

.color-rgb {
  color: var(--fg-dim);
  font-size: 0.78rem;
}

.empty {
  text-align: center;
  color: var(--fg-dim);
  padding: 2rem 0;
}

/* ─────── Pager ─────── */

.pager {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  margin: 1.5rem 0 0.5rem;
}

.pager button {
  background: var(--bg-elev);
  color: var(--fg);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.4rem 0.9rem;
  font-size: 0.9rem;
  cursor: pointer;
}

.pager button:hover:not(:disabled) { border-color: var(--accent); }
.pager button:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.pager #page-info {
  font-size: 0.9rem;
  color: var(--fg-dim);
  font-variant-numeric: tabular-nums;
}

.status {
  margin-top: 1rem;
  color: var(--fg-dim);
  font-size: 0.9rem;
}

/* ─────── Lightbox ─────── */

.lightbox {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.92);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10;
  padding: 1rem;
}

.lightbox[hidden] { display: none; }

.lightbox figure {
  margin: 0;
  max-width: 95vw;
  max-height: 95vh;
  display: flex;
  flex-direction: column;
  align-items: center;
}

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

.lightbox figcaption {
  color: var(--fg);
  padding-top: 0.5rem;
  font-size: 0.9rem;
}

.lb-close, .lb-prev, .lb-next {
  position: absolute;
  background: rgba(255,255,255,0.08);
  color: #fff;
  border: 1px solid rgba(255,255,255,0.15);
  border-radius: 50%;
  width: 44px;
  height: 44px;
  font-size: 1.5rem;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.lb-close:hover, .lb-prev:hover, .lb-next:hover { background: rgba(255,255,255,0.18); }
.lb-close { top: 1rem; right: 1rem; }
.lb-prev  { left: 1rem; top: 50%; transform: translateY(-50%); }
.lb-next  { right: 1rem; top: 50%; transform: translateY(-50%); }

/* ─────── Mobile ─────── */

@media (max-width: 640px) {
  .col-img   { width: 130px; }
  .col-time  { width: 130px; }
  .col-color { width: 80px; }
  .thumb { width: 120px; height: 80px; }
  table.photos { font-size: 0.85rem; }
  table.photos tbody td { padding: 0.45rem 0.55rem; }
  .controls select { min-width: 0; flex: 1; }
}
