:root {
  --paper: #f4efe6;
  --paper-deep: #ebe3d4;
  --ink: #1c1712;
  --muted: #6b6258;
  --accent: #6b2d2d;
  --accent-dark: #4e1f1f;
  --gold: #a6854d;
  --card: #fffcf7;
  --line: #e4dcd0;
  --shadow: 0 8px 24px rgba(44, 29, 20, 0.08);
  --radius: 16px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  font-family: "Iowan Old Style", "Palatino Linotype", Palatino, "Times New Roman",
    "New York", ui-serif, Georgia, serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
html { background: var(--paper); }
body {
  color: var(--ink);
  background:
    radial-gradient(1200px 500px at 50% -10%, #fffaf1 0%, transparent 60%),
    var(--paper);
  min-height: 100dvh;
  -webkit-font-smoothing: antialiased;
}

.app {
  max-width: 42rem;
  margin: 0 auto;
  min-height: 100dvh;
  padding: calc(12px + var(--safe-top)) 16px calc(88px + var(--safe-bottom));
}

.topbar {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 18px;
}
.logo {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  box-shadow: var(--shadow);
}
.titles h1 {
  font-size: 1.35rem;
  letter-spacing: 0.01em;
  margin: 0;
  line-height: 1.1;
}
.subtitle {
  margin: 2px 0 0;
  color: var(--muted);
  font-size: 0.8rem;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.view[hidden] { display: none !important; }
.view { display: block; }

.search-bar {
  display: flex;
  gap: 8px;
  align-items: stretch;
}
.search-bar input,
input[type="search"],
input[type="file"] {
  font-size: 16px; /* iOS zoom-prevention */
}
.search-bar input {
  flex: 1;
  min-width: 0;
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--ink);
  border-radius: 999px;
  padding: 12px 16px;
  outline: none;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.8);
}
.search-bar input:focus {
  border-color: var(--gold);
  box-shadow: 0 0 0 3px rgba(166, 133, 77, 0.22);
}

button, .btn-primary, .btn-secondary, .as-file, .file-drop span {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 15px;
  font-weight: 600;
  border: 0;
  cursor: pointer;
}
.btn-primary,
.search-bar button {
  background: var(--accent);
  color: #fff8f0;
  border-radius: 999px;
  padding: 12px 16px;
  white-space: nowrap;
}
.btn-primary:active, .search-bar button:active { background: var(--accent-dark); }
.btn-primary:disabled { opacity: 0.5; }

.btn-secondary, .as-file, .btn-ghost {
  background: transparent;
  color: var(--accent);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 11px 16px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.btn-ghost {
  color: var(--muted);
  font-weight: 500;
}
.btn-danger {
  background: transparent;
  color: var(--accent);
  border: 1px solid #e4c8c8;
  border-radius: 999px;
  padding: 8px 12px;
  font-size: 14px;
}

.btn-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 8px;
}
.as-file { position: relative; overflow: hidden; }
.as-file input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }

.file-drop {
  display: block;
  margin: 12px 0;
  border: 1.5px dashed var(--gold);
  border-radius: var(--radius);
  background: rgba(255, 252, 247, 0.7);
  text-align: center;
  position: relative;
  overflow: hidden;
}
.file-drop input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.file-drop span {
  display: block;
  padding: 28px 16px;
  color: var(--accent);
}

.meta, .lead {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--muted);
  font-size: 0.92rem;
  line-height: 1.45;
}
.meta { margin: 10px 2px 16px; }
.lead { margin: 0 0 8px; }

.panel {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow);
  margin-bottom: 14px;
}
.panel h2 {
  margin: 0 0 8px;
  font-size: 1.15rem;
}

.stack { display: flex; flex-direction: column; gap: 10px; }

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px 16px 16px;
  box-shadow: var(--shadow);
}
.card + .card { margin-top: 0; }
.kicker {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 0.75rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--gold);
  margin: 0 0 4px;
}
.card h3 {
  margin: 0 0 8px;
  font-size: 1.12rem;
  line-height: 1.25;
}
.kv {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 0.92rem;
  margin: 3px 0;
  color: var(--ink);
  display: grid;
  grid-template-columns: 6.4rem 1fr;
  column-gap: 0.6rem;
  align-items: start;
}
.kv span.label {
  color: var(--muted);
  min-width: 0;
}
.concerts {
  list-style: none;
  margin: 10px 0 0;
  padding: 0;
}
.concerts li {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 0.95rem;
  padding: 7px 0;
  border-top: 1px solid var(--line);
}
.concerts li:first-child { border-top: 0; padding-top: 2px; }
.concerts .when { font-weight: 600; }
.concerts .where { color: var(--muted); display: block; font-size: 0.86rem; margin-top: 1px; }

details.rehearsals {
  margin-top: 8px;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 0.9rem;
}
details.rehearsals summary {
  cursor: pointer;
  color: var(--accent);
  font-weight: 600;
  list-style: none;
}
details.rehearsals summary::-webkit-details-marker { display: none; }
details.rehearsals ul {
  margin: 6px 0 0;
  padding: 0;
  list-style: none;
}
details.rehearsals li {
  padding: 4px 0;
  color: var(--muted);
  border-top: 1px solid var(--line);
}

.bassoon {
  margin-top: 10px;
  padding: 8px 10px;
  background: var(--paper-deep);
  border-radius: 10px;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 0.88rem;
}

.empty {
  text-align: center;
  padding: 36px 16px;
  color: var(--muted);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}
.empty strong { display: block; color: var(--ink); font-size: 1.05rem; margin-bottom: 6px; font-family: inherit; }

.season-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: flex-start;
}
.season-row .info h3 { margin: 0 0 4px; font-size: 1.05rem; }

.tabbar {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  display: flex;
  justify-content: center;
  gap: 6px;
  padding: 8px 16px calc(8px + var(--safe-bottom));
  background: rgba(244, 239, 230, 0.92);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-top: 1px solid var(--line);
  z-index: 20;
}
.tab {
  flex: 1;
  max-width: 10rem;
  background: transparent;
  color: var(--muted);
  border-radius: 12px;
  padding: 10px 8px 8px;
  font-size: 13px;
  font-weight: 600;
}
.tab.is-active {
  color: var(--accent);
  background: rgba(107, 45, 45, 0.08);
}

.modal {
  position: fixed;
  inset: 0;
  background: rgba(28, 23, 18, 0.45);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  z-index: 40;
  padding: 16px 16px calc(16px + var(--safe-bottom));
}
.modal[hidden] { display: none; }
.modal-card {
  width: min(28rem, 100%);
  background: var(--card);
  border-radius: 20px;
  padding: 20px 18px 16px;
  box-shadow: 0 16px 48px rgba(28, 23, 18, 0.25);
}
.modal-card h3 { margin: 0 0 8px; font-size: 1.15rem; }
.modal-card p {
  margin: 0 0 14px;
  color: var(--muted);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  line-height: 1.45;
}

.sr-only {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0,0,0,0);
  border: 0;
}

@media (min-width: 720px) {
  .modal { align-items: center; }
}
