:root {
  color-scheme: light;
  --paper: #f3efe4;
  --paper-deep: #e9e2d2;
  --card: #fbf9f2;
  --ink: #17231f;
  --ink-soft: #58635d;
  --line: #d8d0bf;
  --accent: #b7432d;
  --accent-dark: #8f2f20;
  --moss: #3d5a4d;
  --gold: #bd8a35;
  --shadow: 0 16px 45px rgb(37 43 37 / 8%);
  --serif-zh: "Noto Serif SC", "Noto Serif CJK SC", "Source Han Serif SC", "Songti SC", "STSong", serif;
  --serif: "Noto Serif CJK JP", "Noto Serif JP", "Yu Mincho", "Hiragino Mincho ProN", serif;
  --sans: Inter, "Noto Sans SC", "Noto Sans CJK SC", "Noto Sans CJK JP", "Hiragino Sans", "Microsoft YaHei", sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  min-width: 320px;
  margin: 0;
  color: var(--ink);
  background:
    linear-gradient(rgb(23 35 31 / 2%) 1px, transparent 1px),
    var(--paper);
  background-size: 100% 32px;
  font-family: var(--sans);
  line-height: 1.65;
  text-rendering: optimizeLegibility;
}

button,
input,
select {
  color: inherit;
  font: inherit;
}

button,
select {
  cursor: pointer;
}

a {
  color: inherit;
}

.shell {
  width: min(1180px, calc(100% - 48px));
  margin-inline: auto;
}

.skip-link {
  position: fixed;
  z-index: 100;
  top: 12px;
  left: 12px;
  padding: 8px 14px;
  color: white;
  background: var(--ink);
  border-radius: 4px;
  transform: translateY(-160%);
}

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

.site-header {
  position: relative;
  overflow: hidden;
  background:
    radial-gradient(circle at 86% 28%, rgb(183 67 45 / 9%) 0 4px, transparent 5px),
    radial-gradient(circle at 86% 28%, transparent 0 118px, rgb(183 67 45 / 10%) 119px 120px, transparent 121px),
    linear-gradient(135deg, #f8f5ec 0%, var(--paper) 60%, #e8e0cf 100%);
  border-bottom: 1px solid var(--line);
}

.site-header::after {
  position: absolute;
  right: -90px;
  bottom: -210px;
  width: 430px;
  height: 430px;
  border: 1px solid rgb(23 35 31 / 9%);
  border-radius: 50%;
  content: "";
}

.nav {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 82px;
  border-bottom: 1px solid var(--line);
}

.brand {
  display: inline-flex;
  gap: 12px;
  align-items: center;
  text-decoration: none;
}

.brand-mark {
  display: grid;
  width: 42px;
  height: 42px;
  color: #fff8ee;
  background: var(--accent);
  border-radius: 3px 12px 3px 12px;
  font-family: var(--serif);
  font-size: 23px;
  line-height: 1;
  place-items: center;
  transform: rotate(-2deg);
}

.brand strong,
.brand small {
  display: block;
}

.brand strong {
  font-family: var(--serif);
  font-size: 17px;
  letter-spacing: 0.04em;
}

.brand small,
.nav-note {
  color: var(--ink-soft);
  font-size: 10px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.nav-note {
  margin: 0;
}

.hero {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 280px;
  gap: 70px;
  align-items: center;
  min-height: 510px;
  padding-block: 72px 100px;
}

.hero-copy {
  max-width: 780px;
}

.eyebrow {
  margin: 0 0 18px;
  color: var(--accent);
  font-size: 11px;
  font-weight: 750;
  letter-spacing: 0.2em;
}

.hero h1 {
  max-width: 760px;
  margin: 0;
  font-family: var(--serif-zh);
  font-size: clamp(43px, 6.5vw, 76px);
  font-weight: 600;
  letter-spacing: -0.055em;
  line-height: 1.2;
}

.hero h1 em {
  color: var(--accent);
  font-style: normal;
}

.hero-intro {
  max-width: 610px;
  margin: 28px 0 34px;
  color: var(--ink-soft);
  font-size: 16px;
}

.search-box {
  display: grid;
  grid-template-columns: 24px minmax(0, 1fr) auto;
  gap: 13px;
  align-items: center;
  max-width: 650px;
  min-height: 62px;
  padding: 0 18px;
  background: rgb(255 253 247 / 86%);
  border: 1px solid #cfc5b1;
  box-shadow: var(--shadow);
  transition: border-color 160ms ease, box-shadow 160ms ease;
}

.search-box:focus-within {
  border-color: var(--moss);
  box-shadow: 0 18px 50px rgb(37 43 37 / 13%);
}

.search-box svg {
  width: 22px;
  fill: none;
  stroke: var(--moss);
  stroke-linecap: round;
  stroke-width: 1.7;
}

.search-box input {
  width: 100%;
  padding: 16px 0;
  background: transparent;
  border: 0;
  outline: 0;
}

.search-box input::placeholder {
  color: #8b8f89;
}

kbd {
  padding: 1px 7px;
  color: #747b75;
  background: var(--paper);
  border: 1px solid var(--line);
  border-bottom-width: 2px;
  border-radius: 4px;
  font-size: 12px;
}

.hero-seal {
  position: relative;
  display: grid;
  width: 230px;
  height: 230px;
  justify-self: end;
  align-content: center;
  color: var(--accent);
  border: 2px solid currentcolor;
  border-radius: 50%;
  font-family: var(--serif);
  text-align: center;
  transform: rotate(3deg);
}

.hero-seal::before,
.hero-seal::after {
  position: absolute;
  border: 1px solid currentcolor;
  border-radius: 50%;
  content: "";
  inset: 8px;
}

.hero-seal::after {
  border-style: dashed;
  inset: 16px;
  opacity: 0.55;
}

.hero-seal span,
.hero-seal strong,
.hero-seal small {
  position: relative;
  z-index: 1;
  display: block;
  line-height: 1.15;
}

.hero-seal span {
  font-size: 18px;
  letter-spacing: 0.35em;
  text-indent: 0.35em;
}

.hero-seal strong {
  margin: 5px 0;
  font-size: 72px;
  font-weight: 500;
}

.hero-seal small {
  letter-spacing: 0.28em;
  text-indent: 0.28em;
}

.stats {
  position: relative;
  z-index: 2;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  margin-top: -42px;
  background: var(--card);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
}

.stat {
  min-height: 148px;
  padding: 26px 28px;
  border-right: 1px solid var(--line);
}

.stat:last-child {
  border-right: 0;
}

.stat-label {
  display: block;
  color: var(--ink-soft);
  font-size: 13px;
}

.stat strong {
  display: block;
  margin: 3px 0 -2px;
  font-family: var(--serif);
  font-size: 44px;
  font-weight: 500;
  line-height: 1.2;
}

.stat small {
  color: #8b8b81;
  font-size: 9px;
  letter-spacing: 0.16em;
}

.stat-primary {
  color: #fff9ed;
  background: var(--moss);
}

.stat-primary .stat-label,
.stat-primary small {
  color: rgb(255 249 237 / 68%);
}

.stat-quote {
  display: flex;
  flex-direction: column;
  justify-content: center;
  color: var(--accent);
  background:
    linear-gradient(135deg, transparent 49%, rgb(183 67 45 / 6%) 50% 51%, transparent 52%);
  font-family: var(--serif);
  text-align: center;
}

.stat-quote span {
  font-size: 22px;
  letter-spacing: 0.13em;
}

.stat-quote small {
  margin-top: 8px;
  font-family: var(--sans);
  letter-spacing: 0.04em;
}

.library {
  padding-block: 110px 130px;
}

.section-heading {
  display: flex;
  gap: 36px;
  align-items: end;
  justify-content: space-between;
  margin-bottom: 38px;
}

.section-heading .eyebrow {
  margin-bottom: 7px;
}

.section-heading h2 {
  margin: 0;
  font-family: var(--serif-zh);
  font-size: clamp(34px, 5vw, 50px);
  font-weight: 500;
  letter-spacing: -0.04em;
}

.section-heading > p {
  max-width: 360px;
  margin: 0 0 7px;
  color: var(--ink-soft);
  font-size: 13px;
  text-align: right;
}

.toolbar {
  display: flex;
  gap: 24px;
  align-items: end;
  justify-content: space-between;
  padding-block: 18px;
  border-block: 1px solid var(--line);
}

.filter-groups {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.filter-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.filter-button,
.text-button,
.button {
  border: 0;
}

.filter-button {
  padding: 8px 13px;
  color: var(--ink-soft);
  background: transparent;
  border-radius: 99px;
  font-size: 13px;
  transition: color 150ms ease, background 150ms ease;
}

.filter-button:hover {
  color: var(--ink);
  background: var(--paper-deep);
}

.filter-button[aria-pressed="true"] {
  color: white;
  background: var(--ink);
}

.filter-button span {
  margin-left: 5px;
  opacity: 0.65;
}

.due-filter {
  margin-left: 5px;
  border-left: 1px solid var(--line);
  border-radius: 0 99px 99px 0;
}

.due-filter[aria-pressed="true"] {
  color: white;
  background: var(--accent);
  border-left-color: var(--accent);
}

.selects {
  display: flex;
  gap: 12px;
  flex: 0 0 auto;
}

.selects label {
  display: grid;
  gap: 3px;
}

.selects label > span {
  color: var(--ink-soft);
  font-size: 10px;
  letter-spacing: 0.08em;
}

.selects select {
  min-width: 138px;
  padding: 7px 28px 7px 10px;
  background-color: transparent;
  border: 0;
  border-bottom: 1px solid #aaa18f;
  border-radius: 0;
  outline-offset: 3px;
}

.results-line {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 72px;
}

.results-line p {
  margin: 0;
  color: var(--ink-soft);
  font-size: 13px;
}

.text-button {
  padding: 5px 0;
  color: var(--accent);
  background: transparent;
  border-bottom: 1px solid currentcolor;
  font-size: 12px;
}

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

.note-card {
  position: relative;
  display: flex;
  min-width: 0;
  min-height: 305px;
  flex-direction: column;
  padding: 25px 25px 20px;
  overflow: hidden;
  background: var(--card);
  border: 1px solid var(--line);
  box-shadow: 0 5px 20px rgb(37 43 37 / 3%);
  transition: border-color 180ms ease, box-shadow 180ms ease, transform 180ms ease;
}

.note-card::after {
  position: absolute;
  top: 0;
  right: 0;
  width: 46px;
  height: 46px;
  background: linear-gradient(225deg, var(--paper) 0 49%, var(--line) 50% 51%, transparent 52%);
  content: "";
}

.note-card:hover {
  border-color: #bcb3a2;
  box-shadow: 0 16px 38px rgb(37 43 37 / 8%);
  transform: translateY(-2px);
}

.card-topline {
  display: flex;
  gap: 10px;
  align-items: center;
  justify-content: space-between;
  padding-right: 28px;
}

.kind-badge {
  color: var(--accent);
  font-size: 10px;
  font-weight: 750;
  letter-spacing: 0.13em;
  text-transform: uppercase;
}

.mastery {
  display: inline-flex;
  gap: 4px;
  align-items: center;
}

.mastery-dot {
  width: 5px;
  height: 5px;
  background: #d4ccbc;
  border-radius: 50%;
}

.mastery-dot.is-filled {
  background: var(--gold);
}

.note-card h3 {
  margin: 19px 0 13px;
  padding-right: 16px;
  font-family: var(--serif-zh);
  font-size: 25px;
  font-weight: 600;
  letter-spacing: -0.02em;
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.explanation {
  display: -webkit-box;
  margin: 0;
  overflow: hidden;
  color: #3f4a44;
  font-size: 14px;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 4;
}

.note-card.is-expanded .explanation {
  display: block;
  overflow: visible;
  -webkit-line-clamp: unset;
}

.tag-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 18px;
}

.tag {
  padding: 2px 7px;
  color: #68716b;
  background: #efeadf;
  border-radius: 2px;
  font-size: 10px;
}

.note-details {
  margin-top: auto;
  padding-top: 20px;
}

.note-details summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-top: 13px;
  color: var(--accent);
  border-top: 1px solid var(--line);
  font-size: 12px;
  list-style: none;
  user-select: none;
}

.note-details summary::-webkit-details-marker {
  display: none;
}

.note-details summary::after {
  font-size: 18px;
  line-height: 1;
  content: "＋";
}

.note-details[open] summary::after {
  content: "−";
}

.detail-content {
  display: grid;
  gap: 17px;
  padding-top: 20px;
}

.detail-block h4 {
  margin: 0 0 7px;
  color: var(--ink-soft);
  font-size: 10px;
  letter-spacing: 0.13em;
  text-transform: uppercase;
}

.example-list {
  display: grid;
  gap: 10px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.example-list li {
  padding-left: 12px;
  border-left: 2px solid var(--gold);
  font-family: var(--serif);
  font-size: 13px;
}

.example-list small {
  display: block;
  margin-top: 2px;
  color: var(--ink-soft);
  font-family: var(--sans);
}

.detail-notes {
  margin: 0;
  color: var(--ink-soft);
  font-size: 13px;
  white-space: pre-line;
}

.card-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 17px;
  color: #8a8d86;
  font-size: 10px;
}

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

.empty-state {
  margin-top: 10px;
  padding: 78px 24px;
  background: rgb(251 249 242 / 65%);
  border: 1px dashed #bfb6a5;
  text-align: center;
}

.empty-state > span {
  display: inline-grid;
  width: 70px;
  height: 70px;
  color: var(--accent);
  border: 1px solid currentcolor;
  border-radius: 50%;
  font-family: var(--serif);
  font-size: 18px;
  place-items: center;
}

.empty-state h3 {
  margin: 18px 0 4px;
  font-family: var(--serif-zh);
  font-size: 23px;
}

.empty-state p {
  margin: 0;
  color: var(--ink-soft);
  font-size: 13px;
}

.button {
  margin-top: 20px;
  padding: 10px 18px;
  color: white;
  background: var(--ink);
}

.error-state > span {
  font-family: var(--sans);
  font-weight: 700;
}

.site-footer {
  color: rgb(255 250 240 / 72%);
  background: var(--ink);
}

.site-footer .shell {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 105px;
}

.site-footer p {
  margin: 0;
  font-size: 11px;
  letter-spacing: 0.05em;
}

.noscript {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 20;
  padding: 12px 16px;
  color: white;
  background: var(--accent-dark);
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

[hidden] {
  display: none !important;
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}

@media (max-width: 940px) {
  .hero {
    grid-template-columns: minmax(0, 1fr) 190px;
    gap: 35px;
  }

  .hero-seal {
    width: 175px;
    height: 175px;
  }

  .hero-seal strong {
    font-size: 53px;
  }

  .stats {
    grid-template-columns: repeat(2, 1fr);
  }

  .stat:nth-child(2) {
    border-right: 0;
  }

  .stat:nth-child(-n + 2) {
    border-bottom: 1px solid var(--line);
  }

  .notes-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .toolbar {
    align-items: stretch;
    flex-direction: column;
  }
}

@media (max-width: 640px) {
  .shell {
    width: min(100% - 28px, 1180px);
  }

  .nav {
    min-height: 68px;
  }

  .nav-note {
    display: none;
  }

  .hero {
    display: block;
    min-height: auto;
    padding-block: 58px 88px;
  }

  .hero h1 {
    font-size: clamp(39px, 12vw, 58px);
  }

  .hero-intro {
    margin-block: 22px 28px;
    font-size: 14px;
  }

  .hero-seal {
    display: none;
  }

  .search-box {
    min-height: 56px;
  }

  .stats {
    grid-template-columns: 1fr 1fr;
    margin-top: -30px;
  }

  .stat {
    min-height: 123px;
    padding: 20px;
  }

  .stat strong {
    font-size: 35px;
  }

  .stat-quote span {
    font-size: 16px;
  }

  .library {
    padding-block: 78px 90px;
  }

  .section-heading {
    display: block;
  }

  .section-heading > p {
    margin-top: 10px;
    text-align: left;
  }

  .selects {
    display: grid;
    grid-template-columns: 1fr 1fr;
  }

  .selects select {
    width: 100%;
    min-width: 0;
  }

  .notes-grid {
    grid-template-columns: 1fr;
  }

  .note-card {
    min-height: 280px;
  }

  .site-footer .shell {
    align-items: flex-start;
    flex-direction: column;
    justify-content: center;
  }
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
  }
}
