:root {
  --bg: #f2f5f8;
  --panel: #fff;
  --ink: #202e40;
  --muted: #5e6d80;
  --line: #dbe3ec;
  --blue: #28669a;
  --soft: #eef3f8;
  --shadow: 0 3px 8px #243c5710, 0 12px 28px #243c5708;
  color-scheme: light;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body {
  margin: 0;
  min-height: 100vh;
  background: radial-gradient(ellipse at 8% 0, #dfeaf5 0, transparent 48rem),
    radial-gradient(ellipse at 95% 10%, #e9eee9 0, transparent 38rem), var(--bg);
  color: var(--ink);
  font: 16px/1.65 -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft JhengHei", sans-serif;
}
a { color: var(--blue); text-underline-offset: 4px; }
button, input { font: inherit; }
button {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 9px 16px;
  color: var(--ink);
  cursor: pointer;
  transition: background-color .2s ease, border-color .2s ease, color .2s ease, box-shadow .2s ease, transform .2s ease;
}
button:disabled { cursor: default; color: var(--muted); background: var(--soft); }
:focus-visible { outline: 3px solid var(--blue); outline-offset: 4px; }
::selection { background: #c5ddf2; color: var(--ink); }
.shell { width: min(1120px, 100%); margin: auto; padding: 0 32px; }
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 20px; padding: 24px 0; border-bottom: 1px solid var(--line); }
.brand { font-size: 20px; font-weight: 750; letter-spacing: -.04em; color: var(--ink); text-decoration: none; }
.brand::before { content: ""; display: inline-block; width: 9px; height: 9px; margin-right: 10px; border-radius: 50%; background: var(--blue); box-shadow: 0 0 0 5px #28669a0c; }
.topbar nav { display: flex; align-items: center; gap: 16px; }
.topbar button { background: #ffffff80; font-size: 14px; }
.intro { padding: 48px 0 32px; }
.intro h1 { font-size: clamp(32px, 5vw, 48px); line-height: 1.25; letter-spacing: -.035em; margin: 0 0 20px; }
.intro p { margin: 6px 0; max-width: 70ch; }
.intro .muted { font-size: 14px; }
.muted, footer, #summary, #worksSummary { color: var(--muted); }

.tabs { display: flex; gap: 28px; margin: 8px 0 26px; border-bottom: 1px solid var(--line); }
.tabs button { position: relative; background: transparent; border: 0; border-radius: 4px 4px 0 0; padding: 12px 2px 15px; color: var(--muted); font-weight: 600; }
.tabs button::after { content: ""; position: absolute; bottom: -1px; left: 0; right: 0; height: 3px; border-radius: 3px; background: var(--blue); transform: scaleX(0); transition: transform .24s ease; }
.tabs button[aria-selected="true"] { color: var(--blue); }
.tabs button[aria-selected="true"]::after { transform: scaleX(1); }
form { max-width: 650px; }
label { display: block; font-size: 14px; font-weight: 600; margin-bottom: 9px; }
.search-row { display: flex; gap: 10px; }
input { width: 100%; min-width: 0; border: 1px solid var(--line); border-radius: 10px; padding: 11px 14px; background: #ffffffd9; color: var(--ink); caret-color: var(--blue); box-shadow: 0 2px 6px #243c5705; transition: border-color .2s ease, box-shadow .2s ease; }
input::placeholder { color: var(--muted); }
input:focus { border-color: var(--blue); box-shadow: 0 0 0 4px #28669a0c; }
.search-row button { background: var(--blue); color: white; border-color: var(--blue); white-space: nowrap; box-shadow: 0 3px 8px #28669a20; }
.list-heading { display: flex; align-items: baseline; justify-content: space-between; gap: 16px; margin: 34px 0 16px; }
.list-heading h2 { font-size: 20px; letter-spacing: -.02em; margin: 0; }
#summary, #worksSummary { font-size: 14px; margin: 0; }

.works-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 20px; }
.work-card { min-width: 0; display: flex; flex-direction: column; align-items: stretch; gap: 0; padding: 0; background: var(--panel); border: 1px solid var(--line); border-radius: 14px; overflow: hidden; text-align: left; color: inherit; box-shadow: var(--shadow); }
.work-card img, .work-cover-fallback { width: 100%; aspect-ratio: 3 / 4; flex-shrink: 0; object-fit: cover; background: var(--soft); display: block; border-bottom: 1px solid #243c570a; }
.work-cover-fallback { display: grid; place-items: center; font-size: 48px; font-weight: 600; color: #647c96; background: radial-gradient(circle at 25% 20%, #ffffffa6, transparent 65%), linear-gradient(145deg, #e3edf6, #d7e2ed 65%, #e8eeea); }
.work-meta { padding: 15px 14px 17px; }
.work-meta h3 { font-size: 15px; line-height: 1.55; margin: 0 0 8px; overflow-wrap: anywhere; }
.work-meta p { font-size: 12px; line-height: 1.8; color: var(--muted); margin: 0; overflow-wrap: anywhere; font-variant-numeric: tabular-nums; }
#results { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; overflow: hidden; box-shadow: var(--shadow); }
.release { display: grid; grid-template-columns: minmax(0, 1fr) 140px 112px; gap: 22px; align-items: center; padding: 22px 24px; transition: background-color .2s ease; }
.release + .release { border-top: 1px solid var(--line); }
.release h3 { font-size: 17px; line-height: 1.5; margin: 0 0 6px; overflow-wrap: anywhere; }
.release p { font-size: 14px; color: var(--muted); margin: 0; overflow-wrap: anywhere; }
.release time { color: var(--muted); font-size: 14px; font-variant-numeric: tabular-nums; }
.source { font-size: 14px; white-space: nowrap; text-decoration-color: #28669a55; transition: text-decoration-color .2s ease; }
.release:focus-within { background: #f6f9fc; }
.empty { padding: 46px 24px; text-align: center; color: var(--muted); }
.works-empty { grid-column: 1 / -1; background: var(--panel); border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow); margin: 0; }
#notice, #worksNotice { padding: 12px 16px; background: #fff4dd; color: #684400; border: 1px solid #efdfbc; border-radius: 10px; }
.filter-chip { display: inline-flex; align-items: center; gap: 10px; max-width: 100%; padding: 8px 12px; background: #e4eef7; color: #245980; border: 1px solid #cedfeb; border-radius: 999px; font-size: 14px; width: fit-content; }
.filter-chip .chip-clear { padding: 4px 10px; font-size: 13px; border-radius: 999px; }
.pagination { display: flex; justify-content: center; align-items: center; gap: 20px; margin: 32px 0; }
.pagination span { color: var(--muted); font-size: 14px; font-variant-numeric: tabular-nums; }
footer { display: flex; justify-content: space-between; gap: 16px; border-top: 1px solid var(--line); padding: 24px 0 32px; font-size: 13px; }
.skip { position: absolute; top: -100px; left: 10px; }
.skip:focus { top: 10px; background: white; padding: 12px; z-index: 10; }

/* Existing request state drives loading feedback, including subsequent searches. */
[role="tabpanel"]:has([aria-busy="true"]) .list-heading p::before { content: ""; display: inline-block; width: 7px; height: 7px; margin-right: 9px; border-radius: 50%; background: var(--blue); animation: loading-pulse 1.6s ease-in-out infinite; }
#works[aria-busy="true"]:empty, #results[aria-busy="true"]:empty { min-height: 220px; border: 1px solid var(--line); border-radius: 14px; background: linear-gradient(110deg, #ffffff60, #ffffffb0, #ffffff60); }
.work-card, .release { animation: card-enter .45s ease backwards; }
/* Short, capped stagger; no inline styles required by the public CSP. */
:is(.work-card, .release):nth-child(2) { animation-delay: 35ms; }
:is(.work-card, .release):nth-child(3) { animation-delay: 70ms; }
:is(.work-card, .release):nth-child(4) { animation-delay: 105ms; }
:is(.work-card, .release):nth-child(5) { animation-delay: 140ms; }
:is(.work-card, .release):nth-child(n+6) { animation-delay: 175ms; }
@keyframes card-enter { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }
@keyframes loading-pulse { 0%, 100% { opacity: .35; } 50% { opacity: 1; } }

@media (hover: hover) and (pointer: fine) {
  button:hover:not(:disabled) { border-color: #8ba9c4; color: var(--blue); }
  .search-row button:hover:not(:disabled) { background: #205783; color: white; border-color: #205783; box-shadow: 0 5px 12px #28669a2b; }
  .tabs button:hover:not(:disabled) { background: #ffffff40; }
  .tabs button:hover::after { transform: scaleX(.45); }
  .tabs button[aria-selected="true"]:hover::after { transform: scaleX(1); }
  .work-card:hover:not(:disabled) { transform: translateY(-4px); border-color: #9eb6cc; color: var(--ink); box-shadow: 0 7px 14px #243c5714, 0 18px 34px #243c5712; }
  .release:hover { background: #f6f9fc; }
  .source:hover { text-decoration-color: currentColor; }
}
@media (max-width: 640px) {
  .shell { padding: 0 18px; }
  .topbar { padding: 18px 0; gap: 12px; }
  .topbar nav { gap: 10px; font-size: 14px; flex-wrap: wrap; justify-content: flex-end; }
  .topbar button { padding: 8px 10px; }
  .brand { flex-shrink: 0; }
  .intro { padding: 34px 0 24px; }
  .tabs { gap: 24px; }
  .works-grid { grid-template-columns: repeat(auto-fill, minmax(132px, 1fr)); gap: 14px; }
  .work-meta { padding: 12px; }
  .release { grid-template-columns: minmax(0, 1fr) auto; gap: 10px; padding: 18px; }
  .release .description { grid-column: 1 / -1; }
  .release time { grid-column: 1; }
  .source { grid-column: 2; }
  .list-heading { align-items: center; }
  footer { flex-direction: column; gap: 4px; }
  .pagination { gap: 14px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
  .work-card:hover:not(:disabled) { transform: none; }
}
