:root {
  --bg: #14110f;
  --surface: #211c19;
  --line: #3a322c;
  --ink: #f3ece4;
  --muted: #a2948a;
  --accent: #e5442e;
  --pad: 10px;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  height: 100%;
}

body {
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.55 "Iowan Old Style", Palatino, Georgia, serif;
  -webkit-text-size-adjust: 100%;
}

.view[hidden] {
  display: none;
}

.filters {
  position: sticky;
  top: 0;
  z-index: 2;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 6px;
  padding: var(--pad);
  background: rgba(20, 17, 15, 0.94);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
  padding-top: max(var(--pad), env(safe-area-inset-top));
}

.filters button {
  flex: 0 0 auto;
  padding: 7px 14px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  color: var(--muted);
  font: inherit;
  font-size: 14px;
  cursor: pointer;
}

.filters button[aria-pressed="true"] {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--pad);
  padding: var(--pad);
}

.grid button {
  padding: 0;
  border: 0;
  background: none;
  cursor: pointer;
}

.grid img {
  display: block;
  width: 100%;
  height: auto;
  border-radius: 3px;
  background: var(--surface);
}

.attribution {
  padding: 20px var(--pad) calc(28px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 13px;
  text-align: center;
}

.attribution p {
  margin: 0 0 8px;
}

.attribution p:last-child {
  margin-bottom: 0;
}

.attribution a {
  color: var(--muted);
}

.card {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  background: var(--bg);
}

.back {
  position: absolute;
  top: max(10px, env(safe-area-inset-top));
  left: 10px;
  z-index: 3;
  width: 38px;
  height: 38px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(20, 17, 15, 0.75);
  color: var(--ink);
  font-size: 18px;
  cursor: pointer;
  backdrop-filter: blur(8px);
}

.art {
  flex: 0 0 50%;
  min-height: 0;
  margin: 0;
  padding: 0;
  cursor: zoom-in;
}

.art img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.text {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 18px var(--pad) 24px;
  border-top: 1px solid var(--line);
}

.text h1 {
  margin: 0 0 14px;
  font-size: 24px;
  font-weight: 600;
}

.text h2,
.text h3 {
  margin: 24px 0 8px;
  color: var(--accent);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.09em;
  text-transform: uppercase;
}

.text h3 {
  color: var(--muted);
}

.text p {
  margin: 0 0 12px;
}

.text p:last-child {
  margin-bottom: 0;
}

.keywords {
  display: block;
  width: 100%;
  margin: 20px 0 12px;
  padding: 6px 0;
  border: 0;
  background: none;
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
}

.keywords::before {
  content: "\25b8";
  display: inline-block;
  width: 14px;
  color: var(--accent);
  font-size: 11px;
  vertical-align: 1px;
}

.keywords[aria-expanded="true"]::before {
  content: "\25be";
}

.label {
  color: var(--accent);
  font-weight: 600;
}

.hint {
  transition: filter 0.2s ease;
}

.keywords[aria-expanded="false"] .hint {
  filter: blur(4px);
  user-select: none;
}

.reading {
  margin-bottom: 12px;
  padding-left: 14px;
}

.card[data-mode="art"] .art {
  flex: 1 1 auto;
  cursor: default;
}

.card[data-mode="art"] .text {
  display: none;
}

.card[data-mode="description"] .art {
  display: none;
}

.card[data-mode="description"] .text {
  padding-top: calc(max(10px, env(safe-area-inset-top)) + 50px);
}

.modes {
  display: flex;
  flex: 0 0 auto;
  border-top: 1px solid var(--line);
  background: var(--surface);
  padding-bottom: env(safe-area-inset-bottom);
}

.modes button {
  flex: 1;
  padding: 13px 4px;
  border: 0;
  background: none;
  color: var(--muted);
  font: inherit;
  font-size: 14px;
  cursor: pointer;
}

.modes button[aria-pressed="true"] {
  color: var(--accent);
  box-shadow: inset 0 2px 0 var(--accent);
}

@media (min-width: 700px) {
  .grid,
  .filters,
  .attribution {
    max-width: 640px;
    margin-inline: auto;
  }

  .card {
    max-width: 640px;
    margin-inline: auto;
    border-inline: 1px solid var(--line);
  }
}
