:root {
  --ink: #1e1b18;
  --muted: #776f67;
  --line: #e6ded4;
  --paper: #f7f2eb;
  --white: #fffefa;
  --accent: #e65b31;
  --accent-soft: #fbe9df;
  --font: "Microsoft YaHei UI", "PingFang SC", "Noto Sans SC", sans-serif;
  --serif: "DFYaSongW9-GB", "Songti SC", serif;
}

* { box-sizing: border-box; }
html { min-height: 100%; }
body {
  min-height: 100%;
  margin: 0;
  color: var(--ink);
  background:
    radial-gradient(circle at 82% 0%, rgba(230, 91, 49, 0.13), transparent 24rem),
    radial-gradient(circle at 5% 24%, rgba(45, 138, 86, 0.07), transparent 20rem),
    var(--paper);
  font-family: var(--font);
  -webkit-font-smoothing: antialiased;
}

button, input, textarea { font: inherit; }
button { color: inherit; }
a { color: inherit; }

.library-topbar {
  display: flex;
  width: min(1240px, calc(100% - 40px));
  margin: 0 auto;
  padding: 24px 0 18px;
  align-items: center;
  justify-content: space-between;
}

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

.library-brand-mark {
  display: grid;
  width: 38px;
  height: 38px;
  place-items: center;
  border-radius: 11px;
  color: #fff;
  background: var(--ink);
  font: italic 700 26px Georgia, serif;
}

.library-brand > span:last-child {
  display: grid;
  gap: 2px;
}

.library-brand strong { font: 700 18px Georgia, var(--serif); }
.library-brand small { color: var(--muted); font-size: 10px; letter-spacing: 0.08em; }

.library-back {
  padding: 9px 14px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 254, 250, 0.72);
  color: #5d554e;
  font-size: 12px;
  text-decoration: none;
}

.library-shell {
  width: min(1240px, calc(100% - 40px));
  margin: 0 auto;
  padding: 34px 0 70px;
}

.library-hero {
  max-width: 860px;
  padding: 38px 0 26px;
}

.library-kicker {
  margin: 0 0 18px;
  color: var(--accent);
  font: 700 11px Georgia, serif;
  letter-spacing: 0.16em;
}

.library-hero h1 {
  margin: 0;
  font: 700 clamp(42px, 6vw, 76px) / 1.08 var(--serif);
  letter-spacing: -0.035em;
}

.library-hero > p:not(.library-kicker) {
  max-width: 720px;
  margin: 20px 0 0;
  color: #615950;
  font-size: 16px;
  line-height: 1.85;
}

.library-stats {
  display: flex;
  gap: 20px;
  margin-top: 24px;
  color: var(--muted);
  font-size: 12px;
}

.library-stats b {
  margin-right: 3px;
  color: var(--ink);
  font: 700 22px Georgia, serif;
}

.library-controls {
  position: sticky;
  top: 0;
  z-index: 8;
  display: grid;
  grid-template-columns: minmax(260px, 390px) minmax(0, 1fr);
  gap: 14px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: rgba(255, 254, 250, 0.92);
  box-shadow: 0 14px 42px rgba(49, 38, 28, 0.07);
  backdrop-filter: blur(15px);
}

.library-search {
  display: flex;
  min-height: 44px;
  padding: 0 14px;
  align-items: center;
  gap: 9px;
  border: 1px solid #ded4c8;
  border-radius: 12px;
  background: #fff;
}

.library-search span { color: #8b8178; font-size: 22px; }
.library-search input { width: 100%; border: 0; outline: 0; background: transparent; font-size: 13px; }

.library-filters {
  display: flex;
  align-items: center;
  gap: 8px;
  overflow-x: auto;
  scrollbar-width: none;
}

.library-filters::-webkit-scrollbar { display: none; }
.library-filters button {
  padding: 9px 13px;
  flex: 0 0 auto;
  border: 1px solid transparent;
  border-radius: 999px;
  background: #f4efe8;
  color: #6f665e;
  font-size: 12px;
  cursor: pointer;
}
.library-filters button.active {
  border-color: #efbda8;
  background: var(--accent-soft);
  color: #a43d20;
  font-weight: 700;
}

.library-result-head {
  display: flex;
  margin: 34px 0 16px;
  align-items: end;
  justify-content: space-between;
}
.library-result-head strong { font: 700 24px var(--serif); }
.library-result-head span { color: var(--muted); font-size: 12px; }

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

.font-card {
  position: relative;
  overflow: hidden;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--white);
  box-shadow: 0 10px 28px rgba(53, 40, 28, 0.06);
  cursor: default;
  text-align: left;
  transition: transform 180ms ease, box-shadow 180ms ease, border-color 180ms ease;
}
.font-card:hover {
  transform: translateY(-4px);
  border-color: #d7bfae;
  box-shadow: 0 18px 42px rgba(53, 40, 28, 0.12);
}
.font-card img {
  display: block;
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
  background: #fff;
}
.font-card-body { padding: 14px 15px 16px; }
.font-card-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  color: #9a5a43;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.06em;
}
.font-card-meta span:last-child {
  overflow: hidden;
  color: var(--muted);
  font-weight: 500;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.font-card h2 { margin: 8px 0 7px; font-size: 15px; }
.font-card p {
  display: -webkit-box;
  overflow: hidden;
  margin: 0;
  color: #746b63;
  font-size: 11px;
  line-height: 1.65;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.font-card-prompt {
  min-height: 52px;
  padding: 9px 10px;
  border: 1px solid #eee5db;
  border-radius: 10px;
  background: #fbf8f3;
  color: #554e48 !important;
  -webkit-line-clamp: 3 !important;
}

.font-card-copy {
  width: 100%;
  margin-top: 11px;
  padding: 9px 12px;
  border: 1px solid #edc8b8;
  border-radius: 10px;
  color: #a44122;
  background: #fff2eb;
  font-size: 11px;
  font-weight: 800;
  cursor: pointer;
  transition: 160ms ease;
}

.font-card-copy:hover,
.font-card-copy.is-copied {
  color: #fff;
  border-color: var(--accent);
  background: var(--accent);
}

.font-card-empty {
  grid-column: 1 / -1;
  padding: 70px 20px;
  border: 1px dashed #d9cbbd;
  border-radius: 18px;
  color: var(--muted);
  text-align: center;
}

.font-modal {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: none;
  padding: 24px;
  align-items: center;
  justify-content: center;
  background: rgba(29, 24, 20, 0.62);
  backdrop-filter: blur(8px);
}
.font-modal.open { display: flex; }
.font-modal-dialog {
  position: relative;
  display: grid;
  width: min(960px, 100%);
  max-height: calc(100dvh - 48px);
  grid-template-columns: minmax(320px, 1fr) minmax(320px, 0.9fr);
  overflow: hidden;
  border-radius: 24px;
  background: #fffdf9;
  box-shadow: 0 30px 100px rgba(0, 0, 0, 0.28);
}
.font-modal-close {
  position: absolute;
  top: 12px;
  right: 14px;
  z-index: 2;
  width: 34px;
  height: 34px;
  border: 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.86);
  cursor: pointer;
  font-size: 24px;
}
.font-modal-media { padding: 22px; background: #f1ebe3; }
.font-modal-media img { display: block; width: 100%; border-radius: 16px; background: #fff; }
.font-modal-copy {
  overflow-y: auto;
  padding: 42px 32px 28px;
}
.font-modal-kicker { margin: 0 0 8px; color: var(--accent); font-size: 11px; font-weight: 800; letter-spacing: 0.08em; }
.font-modal-copy h2 { margin: 0; font: 700 28px var(--serif); }
.font-modal-desc { margin: 10px 0 14px; color: #6f665d; font-size: 13px; line-height: 1.75; }
.font-modal-tags { display: flex; gap: 7px; flex-wrap: wrap; margin-bottom: 20px; }
.font-modal-tags span { padding: 5px 9px; border-radius: 999px; background: #f2eee7; color: #6b6259; font-size: 10px; }
.font-text-field, .font-prompt-field { display: grid; gap: 8px; margin-top: 14px; }
.font-text-field span, .font-prompt-field span { color: #625a52; font-size: 11px; font-weight: 700; }
.font-text-field input {
  width: 100%;
  padding: 12px 13px;
  border: 1px solid #dcd2c6;
  border-radius: 11px;
  outline: none;
  background: #fff;
}
.font-prompt-field textarea {
  width: 100%;
  padding: 13px;
  resize: vertical;
  border: 1px solid #dcd2c6;
  border-radius: 11px;
  outline: none;
  background: #fbf8f3;
  color: #4f4943;
  font-size: 12px;
  line-height: 1.7;
}
.font-copy-button {
  width: 100%;
  margin-top: 14px;
  padding: 13px 18px;
  border: 0;
  border-radius: 12px;
  color: #fff;
  background: var(--accent);
  font-weight: 800;
  cursor: pointer;
}
.font-modal-note { margin: 10px 0 0; color: #8a8178; font-size: 10px; line-height: 1.6; }

.font-toast {
  position: fixed;
  left: 50%;
  bottom: 28px;
  z-index: 40;
  padding: 10px 16px;
  border-radius: 999px;
  color: #fff;
  background: #24201c;
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, 8px);
  transition: 180ms ease;
}
.font-toast.show { opacity: 1; transform: translate(-50%, 0); }

.library-footer {
  width: min(1240px, calc(100% - 40px));
  margin: 0 auto;
  padding: 26px 0 38px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 11px;
}

@media (max-width: 980px) {
  .font-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .library-controls { position: static; grid-template-columns: 1fr; }
}

@media (max-width: 720px) {
  .library-topbar, .library-shell, .library-footer { width: min(100% - 24px, 620px); }
  .library-shell { padding-top: 10px; }
  .library-hero { padding-top: 28px; }
  .library-hero h1 { font-size: 42px; }
  .library-stats { gap: 10px; justify-content: space-between; }
  .font-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
  .font-card-body { padding: 11px 12px 13px; }
  .font-card h2 { font-size: 13px; }
  .font-card p { font-size: 10px; }
  .font-modal { padding: 0; }
  .font-modal-dialog {
    width: 100%;
    height: 100dvh;
    max-height: none;
    grid-template-columns: 1fr;
    overflow-y: auto;
    border-radius: 0;
  }
  .font-modal-media { padding: 14px; }
  .font-modal-copy { overflow: visible; padding: 22px 18px 30px; }
}
