:root {
  color-scheme: light;
  --ink: #17212b;
  --muted: #5d6975;
  --paper: #f5f2ea;
  --white: #fffefb;
  --line: #d8d2c6;
  --accent: #b4422f;
  --navy: #17324d;
  --font-sans: "Zen Kaku Gothic New", "Hiragino Kaku Gothic ProN", "Yu Gothic", sans-serif;
  --font-serif: "Shippori Mincho B1", "Hiragino Mincho ProN", "Yu Mincho", serif;
  --font-attribute: "Zen Kurenaido", "Hiragino Mincho ProN", "Yu Mincho", cursive;
  font-family: var(--font-sans);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  color: var(--ink);
  background: var(--paper);
  line-height: 1.8;
}

a { color: inherit; }

.skip-link {
  position: fixed;
  z-index: 20;
  top: 12px;
  left: 12px;
  padding: 10px 14px;
  color: var(--white);
  background: var(--navy);
  transform: translateY(-160%);
}

.skip-link:focus {
  transform: translateY(0);
}

:focus-visible {
  outline: 3px solid var(--navy);
  outline-offset: 4px;
}

.site-header :focus-visible {
  outline-color: var(--white);
}

.site-header {
  background: var(--navy);
  color: var(--white);
  border-bottom: 6px solid var(--accent);
}

.header-inner,
main,
footer {
  width: min(960px, calc(100% - 40px));
  margin-inline: auto;
}

.header-inner { padding: 72px 0 64px; }

.eyebrow,
.section-number {
  margin: 0 0 12px;
  color: #d9a99e;
  font-size: .75rem;
  font-weight: 700;
  letter-spacing: .16em;
}

h1,
h2,
h3,
p { margin-top: 0; }

h1 {
  margin-bottom: 14px;
  font-family: var(--font-serif);
  font-size: clamp(3rem, 10vw, 6.5rem);
  font-weight: 600;
  letter-spacing: .045em;
  line-height: 1.1;
}

.subtitle {
  max-width: 760px;
  margin-bottom: 18px;
  color: #f2c3b7;
  font-family: var(--font-serif);
  font-size: clamp(1rem, 2.8vw, 1.35rem);
  font-weight: 500;
  letter-spacing: .055em;
}

.title-attribute {
  font-family: var(--font-attribute);
  font-weight: 400;
}

.subtitle .title-attribute {
  display: inline-block;
  margin-left: 0.9em;
  color: #d9a99e;
  font-size: 0.82em;
  letter-spacing: .1em;
}

.lead {
  max-width: 670px;
  margin-bottom: 28px;
  color: #dfe8f0;
  font-size: 1.05rem;
}

.hatena-link,
.site-navigation a {
  text-underline-offset: 5px;
}

.header-links,
.site-navigation {
  display: flex;
  flex-wrap: wrap;
  gap: 14px 24px;
  align-items: center;
}

.site-navigation a {
  color: var(--white);
}

.site-navigation a[aria-current="page"] {
  text-decoration-thickness: 3px;
}

.header-action {
  display: inline-block;
  padding: 9px 18px;
  color: var(--white);
  background: var(--accent);
  text-decoration: none;
}

main { padding: 64px 0 80px; }

.portal-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 72px;
}

.portal-card {
  display: grid;
  gap: 8px;
  min-height: 180px;
  padding: clamp(24px, 5vw, 38px);
  border: 1px solid var(--line);
  background: var(--white);
  text-decoration: none;
}

.portal-card:hover,
.portal-card:focus-visible {
  border-color: var(--navy);
  box-shadow: 0 16px 40px rgb(23 33 43 / 9%);
}

.portal-card-primary {
  color: var(--white);
  background: var(--navy);
  border-color: var(--navy);
}

.portal-card-primary .section-number {
  color: #f2c3b7;
}

.portal-card strong {
  font-family: var(--font-serif);
  font-size: clamp(1.45rem, 4vw, 2rem);
  font-weight: 500;
}

.portal-card > span:last-child {
  color: var(--muted);
}

.portal-card-primary > span:last-child {
  color: #dfe8f0;
}

.latest-papers,
.archive-note {
  scroll-margin-top: 1rem;
}

.archive-note {
  max-width: 760px;
  margin-top: 72px;
  padding-top: 34px;
  border-top: 1px solid var(--line);
}

.archive-note h2,
.not-found-guide h2 {
  font-family: var(--font-serif);
  font-size: 2rem;
  font-weight: 500;
}

.archive-note p:last-child {
  color: var(--muted);
}

.section-heading {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 36px;
  align-items: end;
  margin-bottom: 24px;
}

.section-heading h2,
.workflow h2 {
  margin-bottom: 0;
  font-family: var(--font-serif);
  font-size: 2rem;
  font-weight: 500;
}

.section-heading > p { margin-bottom: 0; color: var(--muted); }

.paper-list {
  display: grid;
  gap: 22px;
}

.paper-search {
  margin: 0 0 2rem;
  padding: 1.25rem;
  border: 1px solid var(--line);
  background: var(--paper);
}

.paper-search > label {
  display: block;
  margin-bottom: 0.6rem;
  font-weight: 700;
}

.paper-search-controls {
  display: grid;
  grid-template-columns: minmax(0, 2fr) minmax(12rem, 1fr) minmax(9rem, 0.7fr) auto;
  gap: 0.75rem;
}

.paper-search input,
.paper-search select,
.paper-search button,
.paper-empty button {
  width: 100%;
  min-height: 2.75rem;
  padding: 0.65rem 0.75rem;
  border: 1px solid var(--line);
  border-radius: 0;
  background: #fff;
  color: var(--ink);
  font: inherit;
}

.paper-search button,
.paper-empty button {
  cursor: pointer;
  color: var(--navy);
  background: var(--white);
}

.paper-search button:hover,
.paper-empty button:hover {
  border-color: var(--navy);
}

.paper-count {
  min-height: 1.4em;
  margin: 0.65rem 0 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.paper-empty {
  margin-top: 1rem;
  padding: 1rem;
  border: 1px solid var(--accent);
  background: #fff7f3;
}

.paper-empty p {
  margin-bottom: 0.7rem;
}

.paper-empty button {
  width: auto;
}

.paper-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin: 0.9rem 0 0;
}

.paper-tag {
  display: inline-block;
  padding: 0.2rem 0.55rem;
  border: 1px solid var(--line);
  color: var(--muted);
  font-size: 0.78rem;
  text-decoration: none;
}

.paper-tag:hover,
.paper-tag:focus-visible {
  color: var(--ink);
  border-color: var(--ink);
}

.paper-card[hidden] {
  display: none;
}

.paper-card {
  padding: clamp(28px, 6vw, 52px);
  background: var(--white);
  border: 1px solid var(--line);
  box-shadow: 0 16px 40px rgb(23 33 43 / 7%);
}

.paper-meta {
  display: flex;
  gap: 12px;
  margin-bottom: 22px;
  color: var(--muted);
  font-size: .78rem;
  letter-spacing: .08em;
}

.paper-meta span + span::before { content: "·"; margin-right: 12px; }

.paper-year-link {
  text-underline-offset: 3px;
}

.paper-year-link:hover,
.paper-year-link:focus-visible {
  color: var(--ink);
}

.paper-card h3 {
  margin-bottom: 12px;
  font-family: var(--font-serif);
  font-size: clamp(1.8rem, 5vw, 3rem);
  font-weight: 500;
}

.paper-card h3 a {
  text-underline-offset: 7px;
}

.paper-card > p { max-width: 620px; color: var(--muted); }

.paper-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px 22px;
  align-items: center;
  margin-top: 30px;
}

.paper-actions a { text-underline-offset: 4px; }

.paper-actions .primary-action {
  padding: 10px 20px;
  color: white;
  background: var(--accent);
  border-radius: 2px;
  text-decoration: none;
}

.workflow {
  margin-top: 72px;
  padding-top: 34px;
  border-top: 1px solid var(--line);
}

.tag-directory,
.year-directory {
  margin-top: 72px;
  padding-top: 34px;
  border-top: 1px solid var(--line);
}

.year-groups {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.year-group {
  align-self: start;
  border: 1px solid var(--line);
  background: var(--paper);
  scroll-margin-top: 1rem;
}

.year-group summary {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.9rem 1rem;
  cursor: pointer;
  font-weight: 700;
}

.year-group summary span:last-child {
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 400;
}

.year-group ul {
  margin: 0;
  padding: 0 1rem 1rem 2.2rem;
}

.year-group li + li {
  margin-top: 0.45rem;
}

.year-group a {
  text-underline-offset: 3px;
}

.year-group time {
  color: var(--muted);
  font-size: 0.82rem;
}

.tag-index {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.tag-index-item {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.9rem 1rem;
  border: 1px solid var(--line);
  background: var(--paper);
  text-decoration: none;
}

.tag-index-item:hover,
.tag-index-item:focus-visible {
  border-color: var(--ink);
}

.tag-index-item span:last-child {
  color: var(--muted);
  font-size: 0.82rem;
  white-space: nowrap;
}

.tag-page h1 {
  font-size: clamp(2.5rem, 8vw, 5rem);
}

.archive-page h1 {
  font-size: clamp(2.5rem, 8vw, 5rem);
}

.tag-page .hatena-link {
  color: var(--white);
}

.tag-year-section + .tag-year-section {
  margin-top: 56px;
}

.tag-year-section > h2 {
  margin-bottom: 18px;
  font-family: var(--font-serif);
  font-size: 1.8rem;
  font-weight: 500;
}

.tag-year-section > h2 span {
  color: var(--muted);
  font-family: var(--font-sans);
  font-size: 0.82rem;
}

.tag-page-papers {
  display: grid;
  gap: 16px;
}

.tag-page-paper {
  padding: clamp(24px, 5vw, 40px);
  border: 1px solid var(--line);
  background: var(--white);
}

.tag-page-paper h3 {
  margin-bottom: 10px;
  font-family: var(--font-serif);
  font-size: clamp(1.4rem, 4vw, 2rem);
  font-weight: 500;
}

.tag-page-paper h3 a {
  text-underline-offset: 5px;
}

.tag-page-paper > p {
  max-width: 680px;
  color: var(--muted);
}

.paper-page h1 {
  max-width: 900px;
  font-size: clamp(2.2rem, 7vw, 4.5rem);
  line-height: 1.25;
}

.paper-page .hatena-link {
  color: var(--white);
}

.paper-detail {
  padding: clamp(28px, 6vw, 52px);
  border: 1px solid var(--line);
  background: var(--white);
  box-shadow: 0 16px 40px rgb(23 33 43 / 7%);
}

.paper-detail > section + section {
  margin-top: 48px;
  padding-top: 32px;
  border-top: 1px solid var(--line);
}

.paper-detail h2 {
  margin-bottom: 18px;
  font-family: var(--font-serif);
  font-size: 1.8rem;
  font-weight: 500;
}

.keyword-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.keyword-chip {
  display: inline-block;
  padding: 0.3rem 0.65rem;
  border: 1px solid var(--line);
  background: var(--paper);
  color: var(--muted);
  font-size: 0.82rem;
}

.math-page h1 {
  font-size: clamp(2.7rem, 9vw, 5.5rem);
}

.math-page .hatena-link {
  color: var(--white);
}

.math-directory-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 64px;
}

.math-directory-card {
  position: relative;
  display: grid;
  align-content: start;
  gap: 10px;
  min-height: 230px;
  padding: clamp(26px, 5vw, 42px);
  border: 1px solid var(--line);
  background: var(--white);
  text-decoration: none;
}

.math-directory-card:hover,
.math-directory-card:focus-visible {
  border-color: var(--ink);
  box-shadow: 0 16px 40px rgb(23 33 43 / 9%);
}

.math-directory-card strong {
  padding-right: 3.5rem;
  font-family: var(--font-serif);
  font-size: clamp(1.5rem, 4vw, 2.2rem);
  font-weight: 500;
}

.math-directory-card > span:nth-of-type(2) {
  color: var(--muted);
}

.math-directory-count {
  position: absolute;
  top: clamp(26px, 5vw, 42px);
  right: clamp(26px, 5vw, 42px);
  color: var(--accent);
  font-weight: 700;
}

.math-directory-tags {
  align-self: end;
  margin-top: auto;
  color: var(--muted);
  font-size: 0.82rem;
}

.math-index-heading > span,
.math-index-meta {
  color: var(--muted);
  font-size: 0.82rem;
}

.math-index-section + .math-index-section {
  margin-top: 64px;
}

.math-index-heading {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  align-items: baseline;
  padding-bottom: 12px;
  border-bottom: 2px solid var(--ink);
}

.math-index-heading h2 {
  margin-bottom: 0;
  font-family: var(--font-serif);
  font-size: 2rem;
  font-weight: 500;
}

.math-index-list {
  margin: 0;
  padding: 0;
  list-style: none;
}

.math-index-item {
  padding: 24px 4px;
  border-bottom: 1px solid var(--line);
}

.math-index-item h3 {
  margin-bottom: 6px;
  font-family: var(--font-serif);
  font-size: 1.35rem;
  font-weight: 500;
}

.math-index-item h3 a,
.math-index-meta a {
  text-underline-offset: 4px;
}

.math-index-item > p {
  margin-bottom: 8px;
  color: var(--muted);
}

.math-index-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 18px;
}

.math-index-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-top: 12px;
}

.directory-back {
  margin-bottom: 36px;
}

.directory-back a {
  text-underline-offset: 4px;
}

.math-empty {
  padding: clamp(28px, 6vw, 52px);
  border: 1px solid var(--line);
  background: var(--white);
}

.math-empty a {
  text-underline-offset: 4px;
}

.workflow ol {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1px;
  margin: 30px 0 0;
  padding: 1px;
  background: var(--line);
  list-style: none;
}

.workflow li {
  display: grid;
  gap: 6px;
  padding: 24px;
  background: var(--paper);
}

.workflow li span { color: var(--muted); font-size: .9rem; }

footer {
  padding: 24px 0 40px;
  color: var(--muted);
  border-top: 1px solid var(--line);
  font-size: .85rem;
}

footer p { margin: 0; }

footer .title-attribute {
  font-size: 0.82em;
}

.not-found-guide {
  max-width: 680px;
  padding: clamp(28px, 6vw, 52px);
  border: 1px solid var(--line);
  background: var(--white);
}

.not-found-guide > p:not(.section-number) {
  color: var(--muted);
}

@media (max-width: 680px) {
  .paper-search-controls {
    grid-template-columns: 1fr;
  }
  .header-inner { padding: 52px 0 46px; }
  .paper-meta { flex-wrap: wrap; }
  .section-heading { grid-template-columns: 1fr; gap: 8px; }
  .workflow ol { grid-template-columns: 1fr; }
  .tag-index,
  .year-groups,
  .portal-grid { grid-template-columns: 1fr; }
  .math-directory-grid { grid-template-columns: 1fr; }
}
