:root {
  --bg: #f6f4ef;
  --card-bg: #ffffff;
  --ink: #1a1613;
  --ink-soft: #5a5348;
  --accent: #e2461c;
  --accent-dark: #b23414;
  --accent-soft: #fbe3d5;
  --border: #e7e0d4;
  --radius: 10px;
  --font-serif: "Iowan Old Style", Georgia, "Times New Roman", serif;
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
  /* Subtle paper-grain texture, reused wherever a page-level (rather than
     card-level) background is needed, so full-screen views match the body. */
  --grain: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='180' height='180'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='0.35'/%3E%3C/svg%3E");
  font-family: var(--font-serif);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background-color: var(--bg);
  background-image: var(--grain);
  color: var(--ink);
  font-family: var(--font-sans);
  line-height: 1.4;
}

.site-header {
  position: relative;
  padding: 2.5rem 20px 0.5rem;
  max-width: 780px;
  margin: 0 auto;
  text-align: center;
}

/* Sticky search + quick filters: slides out of view while scrolling down
   the list, and slides back in as soon as the user scrolls up even a
   little, without needing to scroll all the way back to the top. */
.controls-bar {
  position: sticky;
  top: 0;
  z-index: 30;
  max-width: 780px;
  margin: 0 auto;
  padding: max(0.5rem, env(safe-area-inset-top)) 20px 0.75rem;
  background-color: var(--bg);
  background-image: var(--grain);
  transition: transform 0.25s ease;
}

.controls-bar.controls-hidden {
  transform: translateY(-100%);
}

.site-header h1 {
  font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
  font-weight: 600;
  font-size: 2rem;
  margin: 0 0 0.25rem;
  letter-spacing: -0.025em;
  line-height: 1.15;
}

/* Mixed-type lockup, echoing a bold sans-serif statement paired with a
   lighter italic serif flourish underneath -- e.g. site title, "in Berlin". */
.site-header h1 .title-sans {
  display: block;
  font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
  font-weight: 700;
  color: var(--ink);
}

.site-header h1 .title-serif {
  display: block;
  font-family: var(--font-serif);
  font-style: italic;
  font-weight: 400;
  font-size: 1.15em;
  color: var(--accent);
  letter-spacing: -0.01em;
}

.subtitle {
  color: var(--ink-soft);
  margin: 0 0 1.5rem;
  font-size: 0.95rem;
}

.search-bar {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.9rem 0.9rem;
  margin: 1rem 0 1.5rem;
}

.search-bar input {
  flex: 1;
  min-width: 0;
  border: none;
  outline: none;
  font-size: 1rem;
  background: transparent;
  color: var(--ink);
  padding: 0.1rem;
}

.search-bar input::placeholder { color: #9b9385; }

.result-count {
  flex: 0 0 auto;
  font-size: 0.8rem;
  color: var(--ink-soft);
  white-space: nowrap;
}

.quick-filters {
  display: flex;
  gap: 0.5rem;
  margin: 0.9rem 0 0;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
.quick-filters::-webkit-scrollbar { display: none; }

.quick-filters a {
  flex: 0 0 auto;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--ink-soft);
  text-decoration: none;
  padding: 0.3rem 0.75rem;
  border-radius: 999px;
  border: 1px solid var(--border);
}

.quick-filters a:hover { border-color: var(--accent); color: var(--accent); }

.quick-filters a.active {
  background: var(--accent);
  border-color: var(--accent);
  color: white;
}

@media (max-width: 640px) {
  .site-header h1 { font-size: 1.7rem; }
}

main {
  max-width: 780px;
  margin: 0 auto;
  padding: 20px 20px 3rem;
}

.event-list {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.date-heading {
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--ink);
  margin: 1.6rem 0 0.4rem;
}

.date-heading:first-child { margin-top: 0.5rem; }

.event-card {
  display: flex;
  width: 100%;
  gap: 0.9rem;
  align-items: flex-start;
  background: none;
  border: none;
  border-radius: var(--radius);
  padding: 0;
  cursor: pointer;
  transition: transform 0.15s ease;
  text-align: left;
  font: inherit;
  color: inherit;
  -webkit-appearance: none;
  appearance: none;
}

.event-card:hover {
  transform: translateY(-1px);
}

.event-card .cover-thumb {
  flex: 0 0 auto;
  width: 40px;
  height: 56px;
  object-fit: cover;
  border-radius: 4px;
  background: var(--accent-soft);
  box-shadow: 0 1px 3px rgba(0,0,0,0.15);
}

.cover-thumb.placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
}

.event-main { flex: 1; min-width: 0; }

.event-title {
  font-family: var(--font-sans);
  font-weight: 300;
  font-size: 0.98rem;
  margin: 0 0 0.15rem;
  color: var(--accent);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.event-meta {
  font-family: var(--font-serif);
  font-size: 0.84rem;
  color: var(--ink-soft);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.event-meta .sep { margin: 0 0.35rem; opacity: 0.5; }

@media (max-width: 640px) {
  .event-title,
  .event-meta {
    white-space: normal;
    overflow: visible;
    text-overflow: clip;
  }
}

.publisher-tag {
  flex: 0 0 auto;
  font-size: 0.7rem;
  color: var(--accent);
  background: var(--accent-soft);
  padding: 0.2rem 0.55rem;
  border-radius: 999px;
  white-space: nowrap;
}

.empty-state {
  text-align: center;
  color: var(--ink-soft);
  padding: 3rem 1rem;
}

/* --- Detail overlay --- */

.overlay[hidden] {
  display: none;
}

.overlay {
  position: fixed;
  inset: 0;
  background: rgba(20, 17, 12, 0.45);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 4vh 20px;
  overflow-y: auto;
  z-index: 50;
}

.detail-panel {
  background: var(--card-bg);
  border-radius: 14px;
  max-width: 640px;
  width: 100%;
  padding: 2rem;
  position: relative;
  box-shadow: 0 20px 60px rgba(0,0,0,0.25);
}

.close-btn {
  position: absolute;
  top: 0.9rem;
  right: 0.9rem;
  border: none;
  background: var(--accent-soft);
  color: var(--ink);
  width: 32px;
  height: 32px;
  border-radius: 50%;
  font-size: 1.3rem;
  line-height: 1;
  cursor: pointer;
}
.close-btn:hover { background: #e6d3c4; }

/* --- Full-screen event detail (not a centered modal) -- back arrow top
   left is the standard mobile "drill-in" pattern, and leaves room for
   swipe-up-for-next-event without a dialog box getting in the way. --- */

.detail-overlay {
  background-color: var(--bg);
  background-image: var(--grain);
  padding: 0;
}

.detail-overlay .detail-panel {
  background: transparent;
  max-width: none;
  width: 100%;
  min-height: 100%;
  border-radius: 0;
  box-shadow: none;
  padding: 4.5rem 20px 3rem;
}

/* Transition lives on #detail-content, a sibling of .back-btn, not an
   ancestor of it -- transforming an ancestor of a position:fixed element
   would reset that element's containing block and make it jump. */
.detail-overlay #detail-content {
  transition: opacity 0.18s ease, transform 0.18s ease;
}

.detail-overlay #detail-content.detail-leaving {
  opacity: 0;
  transform: translateY(-16px);
}

.back-btn {
  position: fixed;
  top: max(16px, env(safe-area-inset-top));
  left: 16px;
  border: none;
  background: none;
  color: var(--ink);
  width: 36px;
  height: 36px;
  font-size: 1.5rem;
  line-height: 1;
  cursor: pointer;
  z-index: 2;
  transition: color 0.15s ease;
}
.back-btn:hover { color: var(--accent); }

.detail-header {
  display: flex;
  gap: 1.25rem;
  margin-bottom: 1.25rem;
}

.detail-cover {
  flex: 0 0 auto;
  width: 110px;
  height: 156px;
  object-fit: cover;
  border-radius: 6px;
  background: var(--accent-soft);
  box-shadow: 0 3px 10px rgba(0,0,0,0.2);
}

.detail-cover.placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2.4rem;
}

.detail-heading h2 {
  margin: 0 0 0.35rem;
  font-family: var(--font-sans);
  font-weight: 300;
  font-size: 1.75rem;
  line-height: 1.2;
  color: var(--accent);
}

.detail-heading .detail-author {
  font-size: 1rem;
  color: var(--ink-soft);
  margin: 0 0 0.5rem;
}

.detail-heading .publisher-tag { margin-top: 0.3rem; display: inline-block; }

.detail-facts {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 0.4rem 0.9rem;
  font-size: 0.92rem;
  margin: 1rem 0;
  padding: 1rem 0;
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
}

.detail-facts dt { color: var(--ink-soft); }
.detail-facts dd { margin: 0; }
.detail-facts a { color: var(--accent); }

.detail-description {
  font-family: var(--font-serif);
  font-size: 0.95rem;
  line-height: 1.6;
  color: var(--ink);
  white-space: pre-line;
  margin: 1rem 0;
}
.detail-description a { color: var(--accent); }

.detail-link {
  display: inline-block;
  margin-top: 0.5rem;
  padding: 0.6rem 1.1rem;
  background: var(--accent);
  color: white;
  text-decoration: none;
  border-radius: 999px;
  font-size: 0.9rem;
  font-weight: 600;
}
.detail-link:hover { background: var(--accent-dark); }

.site-footer {
  text-align: center;
  color: var(--ink-soft);
  font-size: 0.8rem;
  padding: 1.5rem;
}

/* --- Suggest-a-reading FAB + form --- */

.fab-add {
  position: absolute;
  top: 20px;
  right: 20px;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: none;
  background: none;
  color: var(--ink);
  font-size: 1.6rem;
  font-weight: 300;
  line-height: 1;
  cursor: pointer;
  z-index: 2;
  transition: color 0.15s ease, transform 0.15s ease;
}
.fab-add:hover { color: var(--accent); transform: scale(1.1); }

.suggest-intro {
  font-size: 0.9rem;
  color: var(--ink-soft);
  line-height: 1.5;
  margin: 0.25rem 0 1.25rem;
}
.suggest-intro a { color: var(--accent); }

#suggest-form,
#event-form {
  display: flex;
  flex-direction: column;
  gap: 0.9rem;
}

#suggest-form label,
#event-form label {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  font-size: 0.85rem;
  color: var(--ink-soft);
  font-weight: 600;
}

#suggest-form input,
#suggest-form textarea,
#event-form input,
#event-form textarea {
  font: inherit;
  font-weight: 400;
  color: var(--ink);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.55rem 0.7rem;
  background: var(--bg);
}

#suggest-form input:focus,
#suggest-form textarea:focus,
#event-form input:focus,
#event-form textarea:focus {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

#suggest-form textarea { resize: vertical; }

.suggest-form-row {
  display: flex;
  gap: 0.9rem;
}
.suggest-form-row label { flex: 1; }

.suggest-submit {
  border: none;
  cursor: pointer;
  align-self: flex-start;
  margin-top: 0.25rem;
}
.suggest-submit:disabled { opacity: 0.6; cursor: default; }

.suggest-status {
  font-size: 0.85rem;
  margin: 0.5rem 0 0;
}
.suggest-status--ok { color: #2d7a3e; }
.suggest-status--error { color: var(--accent); }

@media (max-width: 480px) {
  .detail-header { flex-direction: column; }
  .detail-cover { width: 100%; height: 200px; }
  .detail-panel { padding: 20px; }
  .suggest-form-row { flex-direction: column; }
}

