@font-face {
  font-family: "LexiFlip Sans SC";
  src: url("./fonts/lexiflip-sans-sc.woff2") format("woff2");
  font-style: normal;
  font-weight: 400;
  font-display: swap;
}

@font-face {
  font-family: "Noto Sans SC Subset";
  src: url("./fonts/site-text-woff2.woff2") format("woff2");
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  unicode-range: U+306E, U+4E92, U+5373, U+53E5, U+6D4F, U+89C8;
}

:root {
  color-scheme: light;
  --canvas: #f7f7f7;
  --paper: #ffffff;
  --ink: #171717;
  --muted: #555555;
  --wash: #eeeeee;
  --line: #cccccc;
  --edge: #171717;
  --solid: #171717;
  --solid-hover: #393939;
  --solid-text: #ffffff;
  --outline: 2px solid var(--edge);
  --lift: 0 4px 0 var(--edge);
  --radius: 24px;
  font-family: Inter, "PingFang SC", "Microsoft YaHei", "Noto Sans CJK SC", "LexiFlip Sans SC", "Noto Sans SC Subset", system-ui, sans-serif;
  font-synthesis: weight;
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --canvas: #161616;
  --paper: #222222;
  --ink: #f5f5f5;
  --muted: #bdbdbd;
  --wash: #2c2c2c;
  --line: #575757;
  --edge: #a8a8a8;
  --solid: #f0f0f0;
  --solid-hover: #cccccc;
  --solid-text: #161616;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme]) {
    color-scheme: dark;
    --canvas: #161616;
    --paper: #222222;
    --ink: #f5f5f5;
    --muted: #bdbdbd;
    --wash: #2c2c2c;
    --line: #575757;
    --edge: #a8a8a8;
    --solid: #f0f0f0;
    --solid-hover: #cccccc;
    --solid-text: #161616;
  }
}

*, *::before, *::after { box-sizing: border-box; }

body {
  min-width: 0;
  min-height: 100vh;
  margin: 0;
  color: var(--ink);
  background: var(--canvas);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, p { margin: 0; }
a { color: inherit; text-decoration: none; }
a, .theme-option { -webkit-tap-highlight-color: transparent; }
input { font: inherit; }

:focus-visible {
  outline: 2px dashed var(--ink);
  outline-offset: 4px;
}

.frame {
  width: calc(100% - 3rem);
  max-width: 65rem;
  margin-inline: auto;
}

.skip-link {
  position: fixed;
  z-index: 3;
  top: .75rem;
  left: .75rem;
  transform: translateY(-180%);
  padding: .6rem .9rem;
  border-radius: 10px;
  background: var(--solid);
  color: var(--solid-text);
}

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

.site-header {
  position: sticky;
  z-index: 2;
  top: 0;
  border-bottom: 1px solid var(--line);
  background: var(--canvas);
}

.header-inner {
  display: flex;
  min-height: 5rem;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding-block: .75rem;
}

.wordmark {
  display: inline-flex;
  align-items: center;
  gap: .625rem;
  width: fit-content;
  font-size: 1.075rem;
  font-weight: 800;
  white-space: nowrap;
}

.brand-mark {
  display: grid;
  width: 2.375rem;
  height: 2.375rem;
  place-items: center;
  flex: none;
  border-radius: 11px;
  background: var(--solid);
  color: var(--solid-text);
  font-size: 1.25rem;
  line-height: 1;
}

.top-nav {
  display: flex;
  gap: .25rem;
  padding: .25rem;
  border: var(--outline);
  border-radius: 15px;
  background: var(--paper);
}

.top-nav a {
  display: grid;
  min-height: 2.5rem;
  min-width: 4.3rem;
  place-items: center;
  padding-inline: .8rem;
  border-radius: 9px;
  color: var(--muted);
  font-size: .9375rem;
  font-weight: 750;
  white-space: nowrap;
  transition: background-color .15s, color .15s;
}

.top-nav a[aria-current="page"] {
  color: var(--solid-text);
  background: var(--solid);
}

.page {
  padding-block: clamp(2.875rem, 8vw, 6.5rem) 4.5rem;
  scroll-margin-top: 7rem;
}

.home-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.12fr) minmax(17rem, .88fr);
  align-items: center;
  gap: clamp(1.75rem, 5.5vw, 4.5rem);
}

.hero h1 {
  font-size: clamp(3rem, 7.3vw, 6.25rem);
  font-weight: 850;
  line-height: 1.09;
  letter-spacing: -.065em;
}

.lead {
  max-width: 30ch;
  margin-block: .9rem 1.55rem;
  color: var(--muted);
  font-size: clamp(1rem, 2vw, 1.225rem);
}

.button {
  display: inline-flex;
  min-height: 3.125rem;
  align-items: center;
  justify-content: center;
  padding: .65rem 1.2rem;
  border: var(--outline);
  border-radius: 12px;
  background: var(--paper);
  font-size: 1rem;
  font-weight: 750;
  transition: background-color .15s;
}

.button-primary {
  background: var(--solid);
  color: var(--solid-text);
  box-shadow: var(--lift);
}

.page-title {
  margin-bottom: 1.65rem;
  font-size: clamp(2.75rem, 6vw, 4.75rem);
  line-height: 1.12;
  letter-spacing: -.055em;
  font-weight: 850;
}

.section-title {
  font-size: 1.25rem;
  line-height: 1.35;
  font-weight: 800;
}

.directory {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: clamp(1.3rem, 4vw, 2.75rem);
}

.project-list {
  display: grid;
  gap: .8rem;
  margin-top: .75rem;
}

.tool-card {
  display: block;
  overflow: hidden;
  border: var(--outline);
  border-radius: var(--radius);
  background: var(--paper);
  transition: background-color .15s;
}

.tool-card-featured { box-shadow: var(--lift); }

.tool-art {
  display: grid;
  min-height: clamp(10rem, 20vw, 13rem);
  align-items: center;
  border-bottom: var(--outline);
  background: var(--wash);
}

.flashcard-stack {
  position: relative;
  isolation: isolate;
  width: 65%;
  max-width: 15rem;
  height: clamp(5.6rem, 10vw, 7rem);
  margin-inline: auto;
  margin-bottom: .75rem;
}

.flashcard-stack::before,
.flashcard-stack::after {
  content: "";
  position: absolute;
  inset: 0;
  border: var(--outline);
  border-radius: 17px;
  background: var(--paper);
}

.flashcard-stack::before { z-index: -2; transform: translateY(14px) scale(.91); }
.flashcard-stack::after { z-index: -1; transform: translateY(7px) scale(.955); }

.flashcard {
  display: grid;
  height: 100%;
  place-content: center;
  gap: .1rem;
  border: var(--outline);
  border-radius: 17px;
  background: var(--paper);
  text-align: center;
}

.flashcard span { font-size: clamp(1.4rem, 3vw, 2rem); font-weight: 800; letter-spacing: -.035em; }
.flashcard small { color: var(--muted); font-size: .875rem; }

.tool-copy {
  display: flex;
  min-height: 7.5rem;
  align-items: center;
  justify-content: space-between;
  gap: .8rem;
  padding: clamp(.95rem, 2.9vw, 1.5rem);
}

.tool-copy h2, .tool-copy h3 { font-size: 1.26rem; font-weight: 800; }
.tool-name { font-size: .95rem; color: var(--muted); font-weight: 650; }
.tool-copy p { margin-top: .28rem; color: var(--muted); font-size: 1rem; }

.tool-action {
  display: inline-flex;
  min-height: 2.65rem;
  align-items: center;
  flex: none;
  padding: .4rem .7rem;
  border: 1px solid var(--edge);
  border-radius: 9px;
  font-weight: 750;
  white-space: nowrap;
}

.empty-state {
  display: grid;
  min-height: 7.5rem;
  align-items: center;
  padding: 1rem 1.5rem;
  border: 1px dashed var(--edge);
  border-radius: var(--radius);
  color: var(--muted);
}

.settings-panel {
  max-width: 42rem;
  padding: clamp(1.1rem, 4vw, 1.75rem);
  border: var(--outline);
  border-radius: var(--radius);
  background: var(--paper);
  box-shadow: var(--lift);
}

.settings-panel fieldset { min-width: 0; padding: 0; margin: 0; border: 0; }
.settings-panel legend { padding: 0; }

.theme-options {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: .55rem;
  margin-top: .75rem;
}

.theme-option {
  display: flex;
  position: relative;
  min-height: 3rem;
  align-items: center;
  gap: .55rem;
  padding: .55rem .7rem;
  border: 1px solid var(--edge);
  border-radius: 11px;
  font-size: .97rem;
  font-weight: 700;
  cursor: pointer;
}

.theme-option input {
  width: 1rem;
  height: 1rem;
  margin: 0;
  flex: none;
  accent-color: var(--solid);
}

.theme-option:focus-within { outline: 2px dashed var(--ink); outline-offset: 3px; }
.help-text { margin-top: .85rem; color: var(--muted); font-size: .9375rem; }

.example-section {
  max-width: 42rem;
  margin-top: 2rem;
  scroll-margin-top: 8rem;
}

.example-section > .section-title { margin-bottom: .75rem; }

@media (hover: hover) and (pointer: fine) {
  .top-nav a:not([aria-current]):hover { background: var(--wash); color: var(--ink); }
  .button-primary:hover { background: var(--solid-hover); }
  a.tool-card:hover, .theme-option:hover { background: var(--wash); }
}

@media (max-width: 720px) {
  .frame { width: calc(100% - 2rem); }
  .home-grid, .directory { grid-template-columns: minmax(0, 1fr); }
  .home-grid { align-items: start; }
  .tool-card-featured { max-width: 34rem; }
}

@media (max-width: 440px) {
  .header-inner { flex-direction: column; align-items: stretch; gap: .65rem; }
  .top-nav { display: grid; grid-template-columns: repeat(3, 1fr); }
  .top-nav a { min-width: 0; }
  .tool-copy { flex-wrap: wrap; }
  .theme-options { grid-template-columns: minmax(0, 1fr); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; }
}
