:root {
  --bg: #f3f3f3;
  --ink: #111;
  --muted: #888;
  --accent: #0f6e56;
  --font: BlinkMacSystemFont, -apple-system, "Segoe UI", "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: var(--bg); color: var(--ink); font-family: var(--font); }
button { font: inherit; cursor: pointer; }
a { color: inherit; }

#scene { position: fixed; inset: 0; width: 100%; height: 100%; display: block; }

.topbar { position: fixed; top: 0; left: 0; right: 0; height: 100px; display: flex; align-items: center; padding: 0 64px; pointer-events: none; z-index: 5; }
.topbar > * { pointer-events: auto; }
.logo { font-weight: 900; font-size: 22px; letter-spacing: -0.5px; text-decoration: none; }
.view-toggle { position: absolute; left: 50%; transform: translateX(-90px); display: flex; background: #e4e4e4; border-radius: 6px; padding: 3px; }
.view-toggle button { border: 0; background: transparent; padding: 7px 16px; border-radius: 4px; color: var(--muted); font-size: 14px; }
.view-toggle button.active { background: #fff; color: var(--ink); box-shadow: 0 1px 3px rgba(0,0,0,.12); }
.share { position: absolute; left: 50%; transform: translateX(140px); border: 0; background: #111; color: #fff; padding: 9px 18px; border-radius: 4px; font-size: 14px; }

.focus { position: fixed; top: 128px; left: 64px; width: 360px; z-index: 4; transition: opacity .3s; }
.focus-meta { color: var(--muted); font-size: 14px; }
.focus-date { color: var(--accent); font-size: 44px; font-weight: 800; margin: 6px 0 22px; letter-spacing: -1px; }
.focus-title { font-size: 22px; line-height: 1.35; margin: 0 0 6px; }
.focus-type { color: var(--muted); font-size: 13px; margin-bottom: 18px; }
.btn { border: 0; background: #111; color: #fff; padding: 11px 18px; border-radius: 4px; font-size: 14px; font-weight: 600; text-decoration: none; display: inline-flex; align-items: center; gap: 8px; }
.btn.ghost { background: transparent; color: var(--ink); box-shadow: inset 0 0 0 1px #111; }

.side { position: fixed; right: 64px; bottom: 36px; display: flex; align-items: flex-end; gap: 28px; z-index: 4; }
.years { list-style: none; margin: 0; padding: 0; text-align: right; }
.years li { color: var(--muted); font-size: 15px; line-height: 2; cursor: pointer; }
.years li.active { color: var(--ink); font-weight: 700; }
.years sup { font-size: 9px; margin-left: 2px; }
.tabs { display: flex; background: #e9e9e9; border-radius: 6px; padding: 3px; }
.tabs button { border: 0; background: transparent; color: var(--muted); padding: 7px 14px; border-radius: 4px; font-size: 14px; letter-spacing: 1px; }
.tabs button.active { background: #fff; color: var(--ink); box-shadow: 0 1px 3px rgba(0,0,0,.12); }

.grid { position: fixed; inset: 100px 0 0; overflow-y: auto; padding: 24px 64px 80px; display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 28px; z-index: 6; background: var(--bg); }
.grid[hidden] { display: none; }
.grid .cell { cursor: pointer; transition: transform .2s, opacity .2s; }
.grid .cell:hover { transform: translateY(-4px); }
.grid .cell.dim { opacity: .3; }
.grid img, .grid .poster { width: 100%; aspect-ratio: 3/4; object-fit: cover; display: block; box-shadow: 0 6px 18px rgba(0,0,0,.15); background: #fff; }
.grid .cell-title { font-size: 13px; margin-top: 10px; line-height: 1.4; }
.grid .cell-meta { font-size: 12px; color: var(--muted); margin-top: 2px; }

.modal { position: fixed; inset: 0; z-index: 20; background: rgba(243,243,243,.55); backdrop-filter: blur(22px); -webkit-backdrop-filter: blur(22px); display: flex; align-items: center; justify-content: center; animation: fade .3s ease; }
.modal[hidden] { display: none; }
@keyframes fade { from { opacity: 0; } }
.close { position: absolute; top: 40px; right: 56px; border: 0; background: none; font-size: 26px; }
.modal-body { display: flex; gap: 100px; align-items: center; width: min(1200px, 86vw); max-height: 86vh; }
.modal-image { flex: 0 0 42%; }
.modal-image img, .modal-image canvas { width: 100%; display: block; box-shadow: 0 10px 40px rgba(0,0,0,.18); background: #fff; }
.modal-text { flex: 1; max-height: 80vh; overflow-y: auto; padding-right: 8px; }
.modal-meta { color: var(--muted); font-size: 14px; }
.modal-text h1 { font-size: 32px; line-height: 1.3; margin: 14px 0 22px; }
.rule { width: 30px; height: 3px; background: var(--accent); margin-bottom: 22px; }
.modal-date { font-size: 22px; font-weight: 700; margin-bottom: 12px; }
.modal-authors { color: #444; font-size: 14px; line-height: 1.6; margin-bottom: 18px; }
.modal-authors b { color: var(--ink); }
.modal-cite { color: var(--muted); font-size: 13px; margin-bottom: 18px; }
.modal-links { display: flex; flex-wrap: wrap; gap: 10px; }

.toast { position: fixed; left: 50%; top: 110px; transform: translate(-50%, -10px); background: #111; color: #fff; padding: 8px 16px; border-radius: 4px; font-size: 13px; opacity: 0; transition: .25s; z-index: 30; pointer-events: none; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }

@media (max-width: 760px) {
  .topbar { padding: 0 16px; height: 64px; }
  .view-toggle { transform: translateX(-30%); }
  .view-toggle button { padding: 6px 10px; }
  .share { left: auto; right: 16px; transform: none; padding: 7px 12px; }
  .focus { top: 80px; left: 16px; width: calc(100% - 32px); }
  .focus-date { font-size: 30px; margin-bottom: 12px; }
  .focus-title { font-size: 17px; }
  .side { right: 16px; bottom: 60px; }
  .years { display: none; }
  .grid { inset: 64px 0 0; padding: 16px; grid-template-columns: repeat(2, 1fr); gap: 16px; }
  .modal-body { flex-direction: column; gap: 24px; overflow-y: auto; padding: 70px 0 30px; max-height: 100vh; }
  .modal-text { max-height: none; }
  .modal-text h1 { font-size: 22px; }
  .close { top: 16px; right: 16px; }
}
