:root {
  color-scheme: dark;
  --pine: #0d1c15;
  --pine-light: #1b3226;
  --paper: #f7ecd4;
  --muted: #c4c8b3;
  --gold: #dbbd7e;
  --light-gold: #f6d99a;
  --line: #b692545c;
  --serif: Iowan Old Style, Georgia, "Noto Serif TC", "Songti TC", serif;
  --sans: system-ui, -apple-system, "PingFang TC", "Hiragino Sans", sans-serif;
}

* { box-sizing: border-box; }
html { min-width: 0; }
body {
  min-height: 100vh;
  margin: 0;
  color: var(--paper);
  background: radial-gradient(ellipse at 30% 0%, #294334 0%, #14291f 38%, var(--pine) 76%);
  font: 15px/1.5 var(--sans);
}
body::before {
  content: "";
  position: fixed;
  z-index: 3;
  inset: 9px;
  border: 1px solid #c8a7694d;
  border-radius: 12px;
  box-shadow: inset 0 0 0 3px #101f1780, inset 0 0 0 4px #c8a76924;
  pointer-events: none;
}
a { color: inherit; }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
button:disabled { cursor: default; }
button, input, select, a { -webkit-tap-highlight-color: transparent; }
:focus-visible { outline: 2px solid var(--light-gold); outline-offset: 3px; }
[hidden] { display: none !important; }
.wrap {
  width: min(1300px, calc(100% - 100px));
  margin-inline: auto;
}
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

.atlas-header {
  min-height: 75px;
  display: flex;
  gap: 20px;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--line);
}
.wordmark {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  font: 600 20px/1.1 var(--serif);
  letter-spacing: .105em;
  text-decoration: none;
  white-space: nowrap;
}
.wordmark i { color: var(--gold); font-weight: 400; }
.crest {
  display: grid;
  place-items: center;
  width: 31px;
  height: 31px;
  border: 1px solid var(--line);
  border-radius: 5px 10px 5px 10px;
  color: var(--light-gold);
  font: 20px/1 var(--serif);
}
.header-actions { display: flex; align-items: center; gap: 21px; }
.home-link { color: var(--muted); text-decoration: none; white-space: nowrap; }
.home-link:hover { color: var(--light-gold); }
.header-actions select {
  min-height: 40px;
  max-width: 134px;
  padding: 0 9px;
  border: 1px solid var(--line);
  border-radius: 5px;
  background: var(--pine);
  color: var(--paper);
  cursor: pointer;
}

.masthead {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(265px, 360px);
  align-items: end;
  gap: 24px;
  padding-block: 37px 29px;
}
.masthead h1 {
  margin: 0;
  font: 600 67px/1.13 var(--serif);
  text-wrap: balance;
}
.masthead p { margin: 12px 0 0; color: var(--muted); font-size: 16px; }
.search-field {
  min-width: 0;
  min-height: 52px;
  display: flex;
  gap: 13px;
  align-items: center;
  padding: 0 12px 0 16px;
  border: 1px solid #c6aa6d89;
  border-radius: 6px;
  background: #0b1b14a8;
}
.search-field:focus-within { border-color: var(--light-gold); }
.search-icon {
  position: relative;
  width: 15px;
  height: 15px;
  flex: none;
  border: 1.5px solid var(--gold);
  border-radius: 50%;
}
.search-icon::after {
  content: "";
  position: absolute;
  width: 7px;
  height: 1.5px;
  right: -5px;
  bottom: -2px;
  transform: rotate(45deg);
  background: var(--gold);
}
.search-field input {
  flex: 1;
  min-width: 0;
  min-height: 49px;
  padding: 0 4px;
  border: none;
  outline: none;
  background: transparent;
  font-size: 16px;
}
.search-field input::placeholder { color: #aeb69f; opacity: 1; }
.search-field input::-webkit-search-cancel-button { display: none; }
.icon-button {
  width: 44px;
  height: 44px;
  display: inline-grid;
  place-items: center;
  flex: none;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 5px;
  background: #1a2e23;
  color: var(--gold);
  font-size: 20px;
}
.icon-button:hover:not(:disabled) { border-color: var(--gold); background: #2b4333; color: var(--light-gold); }
.icon-button:disabled { opacity: .4; }
#clear-search { border-color: transparent; background: transparent; }

.collection { padding-block: 0 37px; }
.controls {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px 24px;
  padding: 10px 0 17px;
  border-top: 1px solid var(--line);
}
.categories { display: flex; align-items: center; flex-wrap: wrap; gap: 7px; }
.category {
  min-height: 44px;
  padding: 6px 15px;
  border: 1px solid transparent;
  border-radius: 5px;
  background: transparent;
  color: var(--muted);
}
.category:hover { color: var(--light-gold); border-color: var(--line); }
.category[aria-pressed="true"] {
  border-color: #c8a76988;
  background: #302f21;
  color: var(--light-gold);
}
.browse-controls { display: flex; gap: 16px; align-items: center; }
.browse-controls p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  white-space: nowrap;
}
.arrows { display: flex; gap: 8px; }

.cards {
  --tile-width: clamp(232px, 25vw, 305px);
  --spread: clamp(95px, 13.8vw, 182px);
  --tilt: 8deg;
  --drop: 19px;
  position: relative;
  height: calc(var(--tile-width) * 1.12 + 164px);
  margin: 0;
  padding: 0;
  list-style: none;
  overflow: hidden;
  isolation: isolate;
  touch-action: pan-y pinch-zoom;
}
.card-slot {
  position: absolute;
  top: 9px;
  left: 50%;
  width: var(--tile-width);
  z-index: var(--stack);
  transform: translate(calc(-50% + var(--offset) * var(--spread)), calc(var(--depth) * var(--drop))) rotate(calc(var(--offset) * var(--tilt)));
  transform-origin: 50% 84%;
  transition: transform .36s cubic-bezier(.22,.75,.25,1);
}
.card-slot:not(.selected) .card-actions { visibility: hidden; }
.card-slot:not(.selected) .card { background: #172b21; }
.card-slot:not(.selected) .card-art img { filter: brightness(.83); }
.card-slot.selected .card {
  border-color: #efd69a;
  box-shadow: 0 14px 38px #010905a8, 0 0 0 3px #c8a76e25;
}
.atlas-footer {
  display: flex;
  justify-content: flex-end;
  padding-block: 11px 29px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 13px;
}
.atlas-footer a { padding: 4px 0; text-decoration: none; }
.atlas-footer a:hover { color: var(--light-gold); text-decoration: underline; }
.catalog-notice { margin: 8px 0 0; color: var(--muted); }
.card {
  display: flex;
  flex-direction: column;
  height: 100%;
  overflow: hidden;
  border: 1px solid #c4a36780;
  border-radius: 7px;
  background: linear-gradient(150deg, #1e382b, #14271e 85%);
  box-shadow: 0 10px 20px #02080540;
}
.card-art {
  position: relative;
  display: block;
  width: 100%;
  aspect-ratio: 4 / 4.45;
  padding: 0;
  border: 0;
  overflow: hidden;
  background: #263e2e;
  text-align: left;
}
.card-art::after {
  content: "";
  position: absolute;
  inset: 7px;
  border: 1px solid #ecd4a164;
  border-radius: 3px;
  pointer-events: none;
}
.card-art:focus-visible { outline-offset: -4px; z-index: 1; }
.card-art img, .detail-image img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
}
.card-art img { transition: transform .32s ease; }
@media (hover: hover) { .card-art:hover img { transform: scale(1.035); } }
.card-category, .card-open {
  position: absolute;
  top: 16px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 33px;
  padding: 3px 10px;
  border: 1px solid #c4a367a6;
  border-radius: 4px;
  background: #102019eb;
  color: #f5dfad;
  font-size: 13px;
}
.card-category { left: 16px; }
.card-open { right: 16px; min-width: 33px; padding: 3px; font-size: 17px; }
.card-copy {
  display: flex;
  flex-direction: column;
  flex-grow: 1;
  gap: 8px;
  padding: 14px 15px 15px;
  border-top: 1px solid var(--line);
}
.card-copy h3 {
  display: -webkit-box;
  overflow: hidden;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  overflow-wrap: anywhere;
  margin: 0;
  font: 600 25px/1.25 var(--serif);
}
.card-tags { margin: 0 0 3px; color: var(--muted); font-size: 13px; }
.copy-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-height: 46px;
  padding: 7px 12px;
  border: 1px solid #efd394;
  border-radius: 5px;
  background: linear-gradient(#f1d794, #cfab65);
  color: #20251a;
  font-weight: 700;
}
.card-actions {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 44px;
  gap: 7px;
  margin-top: auto;
}
.card-copy .copy-button { width: 100%; padding-inline: 6px; gap: 8px; }
.share-button { min-height: 46px; }
.link-symbol { width: 19px; height: 19px; position: relative; }
.link-symbol::before, .link-symbol::after {
  content: "";
  position: absolute;
  width: 12px;
  height: 7px;
  border: 1.5px solid currentColor;
  border-radius: 6px;
  transform: rotate(-43deg);
}
.link-symbol::before { top: 2px; right: -1px; }
.link-symbol::after { bottom: 2px; left: -1px; }
.share-button[data-copied] .link-symbol { display: none; }
.share-button[data-copied]::after { content: "✓"; }
.detail-actions { display: flex; align-items: center; gap: 8px; }
.manual-share-url {
  width: 100%;
  margin-top: 10px;
  padding: 7px 9px;
  border: 1px solid var(--line);
  border-radius: 5px;
  color: var(--paper);
  background: var(--pine);
}

.copy-button:hover, .copy-button:focus-visible { background: #f7dfaa; }
.copy-button[data-copied] { color: #f4e5bf; background: #284636; border-color: #bfb383; }
.copy-symbol {
  position: relative;
  flex: none;
  width: 13px;
  height: 15px;
  border: 1.5px solid currentColor;
  border-radius: 2px;
}
.copy-symbol::before {
  content: "";
  position: absolute;
  left: -5px;
  top: -5px;
  width: 10px;
  height: 12px;
  border: solid currentColor;
  border-width: 1.5px 0 0 1.5px;
  border-radius: 2px 0 0;
}
.empty {
  display: grid;
  align-content: center;
  justify-items: center;
  min-height: 258px;
  padding: 28px 16px;
  border: 1px dashed var(--line);
  color: var(--muted);
  text-align: center;
}
.empty > span { color: var(--gold); font-size: 35px; line-height: 1; }
.plain-button { padding: 10px 15px; border: 1px solid var(--line); border-radius: 5px; background: var(--pine-light); color: var(--light-gold); }

.details {
  width: min(790px, calc(100% - 30px));
  max-height: calc(100dvh - 32px);
  padding: 0;
  border: 1px solid var(--gold);
  border-radius: 8px;
  color: var(--paper);
  background: #172c22;
  box-shadow: 0 20px 72px #0008;
}
.details::backdrop { background: #07110dda; }
.detail-layout { position: relative; display: grid; grid-template-columns: minmax(0, 44%) minmax(0, 1fr); }
.detail-image { min-height: 100%; background: var(--pine-light); }
.detail-content { padding: 31px 26px 24px; }
.detail-category { margin: 0 34px 7px 0; color: var(--light-gold); font-size: 13px; }
.detail-content h2 { margin: 0 20px 0 0; font: 600 35px/1.2 var(--serif); overflow-wrap: anywhere; }
.detail-prompt { margin: 17px 0 20px; color: var(--paper); line-height: 1.85; white-space: pre-wrap; overflow-wrap: anywhere; }
.detail-status:empty { margin: 0; }
.detail-status { margin: 11px 0 0; color: var(--muted); }
.detail-close { position: absolute; inset: 8px 8px auto auto; background: #102019f2; }

@media (max-width: 900px) {
  .wrap { width: calc(100% - 58px); }
  .masthead h1 { font-size: 57px; }
  .masthead { padding-block: 32px 24px; }
}
@media (min-width: 681px) and (max-height: 790px) {
  .atlas-header { min-height: 64px; }
  .masthead { padding-block: 24px 18px; }
  .masthead h1 { font-size: 58px; }
  .controls { padding-block: 8px 11px; }
  .card-art { aspect-ratio: 4 / 4.15; }
  .cards { height: calc(var(--tile-width) * 1.04 + 156px); }
}
@media (max-width: 680px) {
  body::before { inset: 5px; border-radius: 8px; }
  .wrap { width: calc(100% - 36px); }
  .atlas-header { min-height: 60px; gap: 8px; }
  .header-actions { gap: 9px; font-size: 12px; }
  .header-actions select { max-width: 96px; padding-inline: 4px; }
  .wordmark { gap: 6px; font-size: 13px; }
  .crest { width: 24px; height: 24px; font-size: 15px; }
  .masthead { grid-template-columns: 1fr; gap: 13px; padding-block: 21px 12px; }
  .masthead h1 { font-size: 44px; }
  .masthead p { margin-top: 8px; font-size: 14px; }
  .controls { flex-wrap: wrap; padding: 6px 0 9px; gap: 2px 8px; }
  .categories { gap: 3px 4px; }
  .category { padding-inline: 8px; font-size: 13px; }
  .browse-controls { width: 100%; justify-content: space-between; }
  .cards {
    --tile-width: min(68vw, 282px);
    --spread: min(26vw, 114px);
    --tilt: 7deg;
    --drop: 12px;
    height: calc(var(--tile-width) + 188px);
  }
  .collection { padding-bottom: 15px; }
  .card-copy h3 { font-size: 23px; }
  .card-art { aspect-ratio: 1; }
  .detail-layout { display: block; }
  .detail-image { height: min(34dvh, 258px); }
  .detail-content { padding: 21px 19px 19px; }
  .detail-content h2 { font-size: 30px; }
  .detail-close { inset: 9px 9px auto auto; }
}
@media (max-width: 360px) {
  .wordmark { letter-spacing: .055em; }
  .masthead h1 { font-size: 40px; }
  .home-link span:first-child { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  .card-art img, .card-slot { transition: none; }
}
