:root {
  --paper: #f6f3ec;
  --paper-deep: #efe9dc;
  --panel: #fbf9f3;
  --card: #fffdf8;
  --ink: #22261f;
  --ink-soft: #4b5147;
  --muted: #747a70;
  --faint: #a0a49a;
  --line: #e4dfd3;
  --line-strong: #d5cebe;
  --accent: #2f6b57;
  --accent-deep: #245444;
  --accent-soft: #e6efe9;
  --accent-pale: #f1f6f2;
  --gold: #a97824;
  --gold-soft: #f6ecd8;
  --danger: #a5483b;
  --danger-soft: #f8e9e5;
  --shadow-sm: 0 1px 2px rgba(34, 38, 31, 0.04);
  --shadow-md: 0 18px 45px -28px rgba(34, 38, 31, 0.38);
  --serif: "Songti SC", "STSong", "Noto Serif CJK SC", "SimSun", serif;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  --radius: 14px;
}

* {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 14px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  opacity: 0.5;
  background:
    radial-gradient(circle at 78% 6%, rgba(47, 107, 87, 0.055), transparent 32%),
    radial-gradient(circle at 8% 92%, rgba(169, 120, 36, 0.045), transparent 36%);
}

body.lock-scroll {
  overflow: hidden;
}

::selection {
  background: var(--accent-soft);
  color: var(--accent-deep);
}

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

button {
  cursor: pointer;
}

a {
  color: var(--accent);
}

.icon-sprite {
  position: absolute;
  width: 0;
  height: 0;
  overflow: hidden;
}

.icon {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
  flex: none;
}

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

[hidden] {
  display: none !important;
}

/* ---------- layout ---------- */

.app-shell {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: 248px minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  position: sticky;
  top: 0;
  z-index: 40;
  display: flex;
  flex-direction: column;
  height: 100vh;
  padding: 26px 16px 16px;
  border-right: 1px solid var(--line);
  background: rgba(250, 248, 242, 0.94);
  backdrop-filter: blur(8px);
}

.brand {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 0 8px 24px;
}

.brand-mark {
  display: grid;
  align-content: center;
  gap: 3px;
  width: 34px;
  height: 34px;
  padding: 0 8px;
  border-radius: 9px;
  background: var(--accent);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.14);
}

.brand-mark span {
  display: block;
  height: 2px;
  border-radius: 2px;
  background: #f4f0e6;
}

.brand-mark span:nth-child(2) {
  width: 70%;
}

.brand-mark span:nth-child(3) {
  width: 85%;
}

.brand-name {
  font-family: var(--serif);
  font-size: 20px;
  font-weight: 700;
  letter-spacing: 0.04em;
  line-height: 1.2;
}

.brand-sub {
  margin-top: 2px;
  color: var(--faint);
  font-size: 8.5px;
  font-weight: 600;
  letter-spacing: 0.18em;
}

.nav {
  flex: 1;
  overflow-y: auto;
  padding: 0 2px;
  scrollbar-width: thin;
  scrollbar-color: var(--line-strong) transparent;
}

.nav-group-label {
  padding: 18px 10px 7px;
  color: var(--faint);
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.16em;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-height: 37px;
  padding: 7px 10px;
  border: 0;
  border-radius: 9px;
  background: transparent;
  color: var(--ink-soft);
  text-align: left;
  transition: background 150ms ease, color 150ms ease;
}

.nav-item:hover {
  background: rgba(47, 107, 87, 0.055);
  color: var(--ink);
}

.nav-item.active {
  background: var(--accent-soft);
  color: var(--accent-deep);
  font-weight: 600;
}

.nav-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  flex: none;
  background: var(--cat-color, var(--faint));
}

.nav-dot-all {
  background: var(--ink);
}

.nav-fav .icon {
  width: 16px;
  height: 16px;
  color: var(--gold);
}

.nav-fav.active {
  background: var(--gold-soft);
  color: #76531b;
}

.nav-label {
  flex: 1;
  font-size: 13.5px;
  line-height: 1.3;
  white-space: nowrap;
}

.nav-count {
  color: var(--faint);
  font-size: 11px;
  font-variant-numeric: tabular-nums;
}

.nav-item.active .nav-count {
  color: currentColor;
  opacity: 0.65;
}

.nav-divider {
  height: 1px;
  margin: 14px 10px;
  background: var(--line);
}

.sidebar-foot {
  padding: 16px 8px 2px;
  border-top: 1px solid var(--line);
}

.sync-line {
  display: flex;
  align-items: center;
  gap: 7px;
  color: var(--muted);
  font-size: 11.5px;
}

.sync-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--faint);
  flex: none;
}

.sync-dot.ok {
  background: #4b8b69;
  box-shadow: 0 0 0 3px rgba(75, 139, 105, 0.12);
}

.sync-dot.err {
  background: var(--danger);
  box-shadow: 0 0 0 3px rgba(165, 72, 59, 0.12);
}

.sync-dot.loading {
  background: var(--gold);
  animation: pulse 1.4s infinite;
}

.sidebar-note {
  margin-top: 7px;
  color: var(--faint);
  font-size: 10.5px;
  line-height: 1.6;
}

.unlock-state {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 10px;
  padding: 7px 9px;
  border-radius: 8px;
  background: var(--accent-pale);
  color: var(--accent-deep);
  font-size: 11px;
}

.unlock-state .icon {
  width: 13px;
  height: 13px;
}

.unlock-state button {
  margin-left: auto;
  padding: 2px 4px;
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 10.5px;
  text-decoration: underline;
  text-underline-offset: 2px;
}

/* ---------- topbar ---------- */

.main {
  display: flex;
  flex-direction: column;
  width: 100%;
  min-width: 0;
  padding: 0 36px 30px;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  gap: 14px;
  margin: 0 -36px;
  padding: 16px 36px;
  background: rgba(246, 243, 236, 0.86);
  border-bottom: 1px solid transparent;
  backdrop-filter: blur(14px);
  transition: border-color 180ms ease;
}

.topbar.scrolled {
  border-bottom-color: var(--line);
}

.icon-btn.mobile-menu,
.mobile-brand {
  display: none;
}

.search-box {
  position: relative;
  display: flex;
  align-items: center;
  flex: 1 1 420px;
  max-width: 620px;
  height: 42px;
  border: 1px solid var(--line-strong);
  border-radius: 11px;
  background: rgba(255, 253, 248, 0.9);
  transition: border-color 160ms ease, box-shadow 160ms ease, background 160ms ease;
}

.search-box:focus-within {
  border-color: var(--accent);
  background: var(--card);
  box-shadow: 0 0 0 3px rgba(47, 107, 87, 0.1);
}

.search-icon {
  position: absolute;
  left: 13px;
  width: 17px;
  height: 17px;
  color: var(--faint);
  pointer-events: none;
}

.search-box input {
  width: 100%;
  height: 100%;
  padding: 0 74px 0 39px;
  border: 0;
  outline: 0;
  background: transparent;
  font-size: 13.5px;
}

.search-box input::placeholder {
  color: var(--faint);
}

.search-box input::-webkit-search-cancel-button {
  display: none;
}

.search-kbd {
  position: absolute;
  right: 12px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 22px;
  height: 22px;
  border: 1px solid var(--line);
  border-radius: 5px;
  background: var(--paper);
  color: var(--faint);
  font-family: var(--sans);
  font-size: 11px;
  line-height: 1;
}

.search-clear {
  position: absolute;
  right: 7px;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border: 0;
  border-radius: 50%;
  background: var(--paper-deep);
  color: var(--muted);
}

.search-clear .icon {
  width: 14px;
  height: 14px;
}

.top-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-left: auto;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 38px;
  padding: 0 14px;
  border: 1px solid transparent;
  border-radius: 9px;
  font-size: 12.5px;
  font-weight: 600;
  white-space: nowrap;
  transition: background 150ms ease, border-color 150ms ease, color 150ms ease, transform 100ms ease;
}

.btn:active {
  transform: translateY(1px);
}

.btn .icon {
  width: 15px;
  height: 15px;
}

.btn-primary {
  background: var(--accent);
  color: #fff;
  box-shadow: 0 1px 1px rgba(36, 84, 68, 0.25);
}

.btn-primary:hover {
  background: var(--accent-deep);
}

.btn-quiet {
  border-color: var(--line-strong);
  background: rgba(255, 253, 248, 0.6);
  color: var(--ink-soft);
}

.btn-quiet:hover {
  border-color: var(--accent);
  color: var(--accent-deep);
  background: var(--card);
}

.btn.is-faved {
  border-color: #dcc395;
  background: var(--gold-soft);
  color: #76531b;
}

.btn.is-faved .icon {
  fill: currentColor;
}

.btn.copied {
  background: var(--accent-soft);
  color: var(--accent-deep);
}

.btn-danger {
  background: var(--danger);
  color: #fff;
}

.btn-danger:hover {
  background: #8c392e;
}

.btn[disabled] {
  opacity: 0.55;
  cursor: default;
}

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  padding: 0;
  border: 1px solid transparent;
  border-radius: 9px;
  background: transparent;
  color: var(--muted);
  transition: background 150ms ease, color 150ms ease, border-color 150ms ease;
}

.icon-btn:hover {
  background: var(--paper-deep);
  color: var(--ink);
}

.menu-wrap {
  position: relative;
}

.menu-pop {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  z-index: 60;
  width: 206px;
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--card);
  box-shadow: 0 20px 50px -22px rgba(34, 38, 31, 0.45);
  animation: popIn 130ms ease both;
}

.menu-pop button {
  display: flex;
  align-items: center;
  gap: 9px;
  width: 100%;
  height: 35px;
  padding: 0 9px;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: var(--ink-soft);
  font-size: 12.5px;
  text-align: left;
}

.menu-pop button:hover {
  background: var(--accent-pale);
  color: var(--accent-deep);
}

.menu-pop .icon {
  width: 15px;
  height: 15px;
}

.menu-hint {
  margin-left: auto;
  color: var(--faint);
  font-size: 10px;
}

.menu-sep {
  height: 1px;
  margin: 5px 6px;
  background: var(--line);
}

.sync-banner {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 14px;
  padding: 9px 12px;
  border: 1px solid #ead9b6;
  border-radius: 9px;
  background: #fbf3df;
  color: #7b5a1b;
  font-size: 12px;
}

.sync-banner .icon {
  width: 14px;
  height: 14px;
}

.sync-banner button {
  margin-left: auto;
  border: 0;
  background: transparent;
  color: inherit;
  font-size: 12px;
  text-decoration: underline;
  text-underline-offset: 2px;
}

/* ---------- page head ---------- */

.page-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
  padding: 26px 0 0;
}

.eyebrow {
  margin: 0 0 7px;
  color: var(--accent);
  font-size: 9.5px;
  font-weight: 700;
  letter-spacing: 0.2em;
}

.page-head h1 {
  margin: 0;
  font-family: var(--serif);
  font-size: 34px;
  font-weight: 700;
  letter-spacing: 0.015em;
  line-height: 1.22;
}

.page-desc {
  margin: 7px 0 0;
  color: var(--muted);
  font-size: 12.5px;
}

.head-tools {
  display: flex;
  align-items: center;
  gap: 8px;
  padding-bottom: 4px;
}

.chip-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 32px;
  padding: 0 11px;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  font-size: 11.5px;
  transition: all 150ms ease;
}

.chip-btn .icon {
  width: 13px;
  height: 13px;
}

.chip-btn:hover {
  border-color: var(--gold);
  color: var(--gold);
}

.chip-btn.active {
  border-color: #dcc395;
  background: var(--gold-soft);
  color: #76531b;
}

.chip-btn.active .icon {
  fill: currentColor;
}

.sort-wrap select {
  height: 32px;
  padding: 0 28px 0 11px;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  outline: 0;
  background: transparent;
  color: var(--muted);
  font-size: 11.5px;
  appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, var(--faint) 50%),
    linear-gradient(135deg, var(--faint) 50%, transparent 50%);
  background-position: calc(100% - 14px) 14px, calc(100% - 10px) 14px;
  background-size: 4px 4px, 4px 4px;
  background-repeat: no-repeat;
  cursor: pointer;
}

.sort-wrap select:hover,
.sort-wrap select:focus {
  border-color: var(--accent);
}

.subcat-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 18px;
  padding-bottom: 2px;
}

.subcat-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 28px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: transparent;
  color: var(--muted);
  font-size: 11.5px;
  transition: all 140ms ease;
}

.subcat-chip small {
  color: var(--faint);
  font-size: 10px;
}

.subcat-chip:hover {
  border-color: var(--line-strong);
  color: var(--ink);
}

.subcat-chip.active {
  border-color: var(--ink);
  background: var(--ink);
  color: #f8f5ed;
}

.subcat-chip.active small {
  color: rgba(248, 245, 237, 0.6);
}

.result-line {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 24px;
  margin: 17px 0 11px;
  color: var(--faint);
  font-size: 11.5px;
}

.result-sep {
  color: var(--line-strong);
}

.text-btn {
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--accent);
  font-size: 11.5px;
  text-decoration: underline;
  text-underline-offset: 3px;
}

/* ---------- cards ---------- */

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 13px;
  align-items: start;
}

.card {
  position: relative;
  display: flex;
  flex-direction: column;
  min-height: 176px;
  padding: 16px 17px 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--card);
  box-shadow: var(--shadow-sm);
  cursor: pointer;
  transition: transform 170ms ease, border-color 170ms ease, box-shadow 170ms ease;
}

.card:hover {
  transform: translateY(-2px);
  border-color: #cdc5b5;
  box-shadow: var(--shadow-md);
}

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

.card-top {
  display: flex;
  align-items: flex-start;
  gap: 8px;
}

.card-cat {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
  padding-top: 3px;
  color: var(--muted);
  font-size: 10.5px;
  line-height: 1.4;
}

.card-cat .dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  flex: none;
  background: var(--cat-color, var(--faint));
}

.card-cat .slash {
  color: var(--line-strong);
}

.card-cat .sub {
  overflow: hidden;
  color: var(--faint);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.card-actions {
  display: flex;
  align-items: center;
  gap: 1px;
  margin-left: auto;
}

.star-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  padding: 0;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: var(--faint);
  transition: color 140ms ease, background 140ms ease;
}

.star-btn .icon {
  width: 15px;
  height: 15px;
}

.star-btn:hover {
  background: var(--gold-soft);
  color: var(--gold);
}

.star-btn.faved {
  color: var(--gold);
}

.star-btn.faved .icon {
  fill: currentColor;
}

.copy-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  height: 28px;
  padding: 0 8px;
  border: 1px solid transparent;
  border-radius: 7px;
  background: transparent;
  color: var(--muted);
  font-size: 10.5px;
  font-weight: 600;
  transition: all 140ms ease;
}

.copy-btn .icon {
  width: 13px;
  height: 13px;
}

.copy-btn:hover {
  border-color: var(--line);
  background: var(--accent-pale);
  color: var(--accent-deep);
}

.copy-btn.copied {
  color: var(--accent);
  background: var(--accent-soft);
}

.card-title {
  display: -webkit-box;
  margin: 9px 0 6px;
  overflow: hidden;
  font-size: 16px;
  font-weight: 650;
  letter-spacing: 0.005em;
  line-height: 1.48;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.card-excerpt {
  display: -webkit-box;
  margin: 0;
  overflow: hidden;
  color: #63695f;
  font-size: 12px;
  line-height: 1.72;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 3;
  white-space: pre-line;
}

.card-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 11px;
}

.tag {
  display: inline-block;
  max-width: 150px;
  overflow: hidden;
  padding: 1px 6px;
  border-radius: 5px;
  background: var(--paper);
  color: var(--muted);
  font-size: 10px;
  line-height: 1.7;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tag-more {
  background: transparent;
  color: var(--faint);
}

.card-foot {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: auto;
  padding-top: 12px;
  border-top: 1px solid rgba(228, 223, 211, 0.7);
  color: var(--faint);
  font-size: 9.5px;
}

.tool-list {
  display: flex;
  flex-wrap: wrap;
  gap: 3px;
  min-width: 0;
}

.tool {
  display: inline-flex;
  align-items: center;
  height: 18px;
  padding: 0 5px;
  border: 1px solid var(--line);
  border-radius: 4px;
  color: var(--muted);
  font-size: 9px;
  line-height: 1;
  white-space: nowrap;
}

.card-time {
  margin-left: auto;
  flex: none;
  font-variant-numeric: tabular-nums;
}

.card-new {
  position: absolute;
  top: 0;
  left: 18px;
  width: 22px;
  height: 2px;
  border-radius: 0 0 2px 2px;
  background: var(--accent);
}

/* ---------- empty / footer ---------- */

.empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 300px;
  padding: 40px 20px;
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius);
  text-align: center;
}

.empty-mark {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 46px;
  height: 46px;
  border-radius: 50%;
  background: var(--paper-deep);
  color: var(--faint);
  font-family: var(--serif);
  font-size: 20px;
}

.empty h2 {
  margin: 14px 0 5px;
  font-family: var(--serif);
  font-size: 20px;
}

.empty p {
  margin: 0 0 17px;
  color: var(--muted);
  font-size: 12px;
}

.page-foot {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-top: 40px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
  color: var(--faint);
  font-size: 10px;
}

/* ---------- skeleton ---------- */

.skeleton {
  min-height: 176px;
  padding: 16px 17px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--card);
}

.sk-line {
  height: 9px;
  margin-bottom: 10px;
  border-radius: 4px;
  background: linear-gradient(90deg, var(--paper-deep) 25%, #f8f5ee 37%, var(--paper-deep) 63%);
  background-size: 400% 100%;
  animation: shimmer 1.4s ease infinite;
}

.sk-line.w40 { width: 40%; }
.sk-line.w75 { width: 75%; }
.sk-line.w95 { width: 95%; }
.sk-line.w60 { width: 60%; }

/* ---------- layers ---------- */

.layer {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  justify-content: flex-end;
}

.layer[aria-hidden="true"] {
  visibility: hidden;
  pointer-events: none;
}

.backdrop {
  position: absolute;
  inset: 0;
  background: rgba(28, 31, 25, 0.36);
  opacity: 0;
  backdrop-filter: blur(2px);
  transition: opacity 220ms ease;
}

.layer.open .backdrop {
  opacity: 1;
}

.layer.modal-layer {
  align-items: center;
  justify-content: center;
  padding: 24px;
}

/* ---------- drawer ---------- */

.drawer {
  position: relative;
  display: flex;
  flex-direction: column;
  width: min(720px, 100%);
  height: 100%;
  background: var(--panel);
  box-shadow: -20px 0 60px -30px rgba(28, 31, 25, 0.5);
  transform: translateX(28px);
  opacity: 0;
  transition: transform 240ms cubic-bezier(0.2, 0.7, 0.2, 1), opacity 180ms ease;
}

.layer.open .drawer {
  transform: none;
  opacity: 1;
}

.drawer-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 58px;
  padding: 0 22px 0 30px;
  border-bottom: 1px solid var(--line);
  flex: none;
}

.drawer-kicker {
  color: var(--faint);
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.2em;
}

.drawer-scroll {
  display: flex;
  flex: 1;
  flex-direction: column;
  overflow-y: auto;
  padding: 28px 30px 0;
  overscroll-behavior: contain;
}

.detail-head {
  padding-bottom: 21px;
  border-bottom: 1px solid var(--line);
}

.detail-cat {
  display: flex;
  align-items: center;
  gap: 7px;
  color: var(--muted);
  font-size: 11px;
}

.detail-cat .dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--cat-color, var(--faint));
}

.detail-cat .sep {
  color: var(--line-strong);
}

.detail-cat .date {
  margin-left: auto;
  color: var(--faint);
  font-size: 10.5px;
}

.detail-title {
  margin: 13px 0 0;
  font-family: var(--serif);
  font-size: 27px;
  font-weight: 700;
  line-height: 1.42;
  letter-spacing: 0.005em;
  overflow-wrap: anywhere;
}

.detail-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  margin-top: 15px;
}

.detail-meta .tag {
  padding: 2px 7px;
  font-size: 10.5px;
}

.detail-meta .tool {
  height: 21px;
  padding: 0 7px;
  border-color: #cad9cf;
  background: var(--accent-pale);
  color: var(--accent-deep);
  font-size: 9.5px;
}

.detail-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-top: 20px;
}

.detail-actions .btn {
  height: 34px;
  padding: 0 12px;
  font-size: 12px;
}

.detail-actions .icon-btn {
  width: 34px;
  height: 34px;
  border-color: var(--line);
  background: var(--card);
}

.detail-actions .spacer {
  flex: 1;
}

.detail-content-label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 26px 0 9px;
  color: var(--faint);
  font-size: 9.5px;
  font-weight: 700;
  letter-spacing: 0.16em;
}

.content-box {
  position: relative;
  padding: 20px 21px;
  border: 1px solid var(--line);
  border-left: 3px solid var(--accent);
  border-radius: 0 11px 11px 0;
  background: var(--card);
  color: #343a31;
  font-size: 14px;
  line-height: 1.9;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  word-break: break-word;
  user-select: text;
}

.detail-copy-bar {
  position: sticky;
  bottom: 0;
  display: flex;
  flex: none;
  gap: 8px;
  margin: auto -30px 0;
  padding: 14px 30px calc(16px + env(safe-area-inset-bottom));
  background: linear-gradient(to top, var(--panel) 72%, rgba(251, 249, 243, 0.7));
  border-top: 1px solid var(--line);
}

.detail-copy-bar .btn {
  flex: 1;
  height: 42px;
}

.detail-foot {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-top: 18px;
  color: var(--faint);
  font-size: 10px;
}

.detail-loading {
  padding: 60px 0;
  color: var(--muted);
  text-align: center;
}

/* ---------- modals ---------- */

.modal {
  position: relative;
  display: flex;
  flex-direction: column;
  width: min(680px, 100%);
  max-height: min(90vh, 900px);
  border: 1px solid rgba(213, 206, 190, 0.8);
  border-radius: 18px;
  background: var(--panel);
  box-shadow: 0 30px 80px -30px rgba(28, 31, 25, 0.55);
  transform: translateY(14px) scale(0.99);
  opacity: 0;
  transition: transform 220ms cubic-bezier(0.2, 0.7, 0.2, 1), opacity 180ms ease;
  overflow: hidden;
}

.layer.open .modal {
  transform: none;
  opacity: 1;
}

.modal-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  padding: 22px 24px 16px;
  flex: none;
}

.modal-head .eyebrow {
  margin-bottom: 4px;
}

.modal-head h2 {
  margin: 0;
  font-family: var(--serif);
  font-size: 23px;
  line-height: 1.3;
}

.modal-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 24px;
  border-top: 1px solid var(--line);
  background: rgba(251, 249, 243, 0.92);
  flex: none;
}

.foot-actions {
  display: flex;
  gap: 8px;
  margin-left: auto;
}

.foot-note {
  color: var(--faint);
  font-size: 10.5px;
}

/* ---------- form ---------- */

.form-modal {
  width: min(720px, 100%);
}

#promptForm {
  display: flex;
  flex-direction: column;
  min-height: 0;
  flex: 1;
}

.form-body {
  flex: 1;
  overflow-y: auto;
  padding: 4px 24px 22px;
  overscroll-behavior: contain;
}

.field {
  display: block;
  margin-bottom: 16px;
}

.field-label {
  display: flex;
  align-items: baseline;
  gap: 7px;
  margin-bottom: 7px;
  color: var(--ink-soft);
  font-size: 11.5px;
  font-weight: 600;
}

.field-label em {
  color: var(--faint);
  font-size: 10px;
  font-style: normal;
  font-weight: 400;
}

.field input,
.field select,
.field textarea {
  width: 100%;
  border: 1px solid var(--line-strong);
  border-radius: 9px;
  outline: 0;
  background: var(--card);
  color: var(--ink);
  font-size: 13px;
  transition: border-color 150ms ease, box-shadow 150ms ease;
}

.field input,
.field select {
  height: 40px;
  padding: 0 12px;
}

.field textarea {
  min-height: 230px;
  padding: 12px;
  line-height: 1.75;
  resize: vertical;
}

.field input:focus,
.field select:focus,
.field textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(47, 107, 87, 0.1);
}

.field input::placeholder,
.field textarea::placeholder {
  color: #b0b2a9;
}

.field-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

.field-foot {
  display: block;
  margin-top: 5px;
  color: var(--faint);
  font-size: 10px;
  text-align: right;
}

fieldset.field {
  padding: 0;
  border: 0;
}

.tool-picks {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}

.tool-pick input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.tool-pick span {
  display: inline-flex;
  align-items: center;
  height: 31px;
  padding: 0 12px;
  border: 1px solid var(--line-strong);
  border-radius: 7px;
  background: var(--card);
  color: var(--muted);
  font-size: 11.5px;
  cursor: pointer;
  transition: all 140ms ease;
}

.tool-pick input:checked + span {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent-deep);
  font-weight: 600;
}

.tool-pick input:focus-visible + span {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.check-line {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 11.5px;
  cursor: pointer;
}

.check-line input {
  width: 15px;
  height: 15px;
  accent-color: var(--gold);
}

.form-error {
  color: var(--danger);
  font-size: 11px;
  line-height: 1.5;
}

/* ---------- unlock / confirm / about ---------- */

.unlock-modal {
  width: min(440px, 100%);
}

.unlock-modal form {
  padding: 0 24px;
}

.unlock-copy {
  margin: 0 0 18px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.75;
}

.unlock-modal .modal-foot {
  margin: 18px -24px 0;
}

.confirm-modal {
  width: min(440px, 100%);
}

.confirm-copy {
  margin: 2px 24px 20px;
  color: var(--ink-soft);
  font-size: 12.5px;
  line-height: 1.75;
  overflow-wrap: anywhere;
}

.about-modal {
  width: min(520px, 100%);
}

.about-body {
  padding: 4px 24px 26px;
  overflow-y: auto;
}

.about-step {
  display: flex;
  gap: 13px;
  padding: 12px 0;
  border-bottom: 1px solid var(--line);
}

.about-step span {
  flex: none;
  color: var(--accent);
  font-family: var(--serif);
  font-size: 13px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.about-step p {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.8;
}

.about-step b {
  color: var(--ink);
}

.about-tip {
  margin-top: 16px;
  padding: 11px 13px;
  border-radius: 8px;
  background: var(--accent-pale);
  color: var(--accent-deep);
  font-size: 11.5px;
  line-height: 1.7;
}

/* ---------- toast ---------- */

.toast {
  position: fixed;
  bottom: 28px;
  left: 50%;
  z-index: 300;
  max-width: calc(100vw - 32px);
  padding: 9px 17px;
  border-radius: 999px;
  background: var(--ink);
  color: #faf8f1;
  box-shadow: 0 12px 30px -12px rgba(28, 31, 25, 0.5);
  font-size: 11.5px;
  line-height: 1.5;
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, 10px);
  transition: opacity 180ms ease, transform 180ms ease;
}

.toast.show {
  opacity: 1;
  transform: translate(-50%, 0);
}

.toast.err {
  background: #7f352b;
}

/* ---------- mobile scrim ---------- */

.scrim {
  position: fixed;
  inset: 0;
  z-index: 35;
  background: rgba(28, 31, 25, 0.38);
  backdrop-filter: blur(2px);
}

/* ---------- responsive ---------- */

@media (max-width: 1180px) {
  .app-shell {
    grid-template-columns: 224px minmax(0, 1fr);
  }

  .main {
    padding: 0 26px 28px;
  }

  .topbar {
    margin: 0 -26px;
    padding: 14px 26px;
  }

  .grid {
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  }
}

@media (max-width: 900px) {
  .app-shell {
    display: block;
  }

  .sidebar {
    position: fixed;
    left: 0;
    top: 0;
    z-index: 45;
    width: 272px;
    transform: translateX(-100%);
    transition: transform 230ms cubic-bezier(0.2, 0.7, 0.2, 1);
    box-shadow: 20px 0 50px -30px rgba(28, 31, 25, 0.4);
  }

  .sidebar.open {
    transform: none;
  }

  .icon-btn.mobile-menu {
    display: inline-flex;
    flex: none;
  }

  .mobile-brand {
    display: block;
    margin-right: auto;
    font-family: var(--serif);
    font-size: 18px;
    font-weight: 700;
    letter-spacing: 0.03em;
  }

  .search-box {
    order: 5;
    flex-basis: 100%;
    max-width: none;
  }

  .topbar {
    flex-wrap: wrap;
    gap: 10px;
    padding-top: 12px;
    padding-bottom: 12px;
  }

  .main {
    padding: 0 20px 26px;
  }

  .topbar {
    margin: 0 -20px;
    padding-left: 20px;
    padding-right: 20px;
  }

  .page-head {
    padding-top: 22px;
  }

  .page-head h1 {
    font-size: 30px;
  }

  .grid {
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  }
}

@media (max-width: 680px) {
  .main {
    padding: 0 15px 22px;
  }

  .topbar {
    margin: 0 -15px;
    padding: 11px 15px;
  }

  .top-actions {
    gap: 5px;
  }

  .btn {
    height: 36px;
    padding: 0 11px;
  }

  .top-actions .btn-quiet span,
  .top-actions .btn-primary span {
    display: none;
  }

  .top-actions .btn-quiet,
  .top-actions .btn-primary {
    width: 36px;
    padding: 0;
  }

  .icon-btn {
    width: 34px;
    height: 34px;
  }

  .search-kbd {
    display: none;
  }

  .search-box input {
    padding-right: 38px;
  }

  .page-head {
    display: block;
    padding-top: 19px;
  }

  .page-head h1 {
    font-size: 27px;
  }

  .page-desc {
    font-size: 11.5px;
  }

  .head-tools {
    margin-top: 14px;
    padding-bottom: 0;
  }

  .subcat-bar {
    flex-wrap: nowrap;
    overflow-x: auto;
    margin: 14px -15px 0;
    padding: 0 15px 4px;
    scrollbar-width: none;
  }

  .subcat-bar::-webkit-scrollbar {
    display: none;
  }

  .subcat-chip {
    flex: none;
  }

  .grid {
    grid-template-columns: 1fr;
    gap: 10px;
  }

  .card {
    min-height: 0;
    padding: 14px 14px 12px;
  }

  .card-title {
    font-size: 15.5px;
  }

  .card-excerpt {
    -webkit-line-clamp: 3;
    font-size: 11.5px;
  }

  .card-foot {
    padding-top: 10px;
  }

  .page-foot {
    margin-top: 28px;
    font-size: 9.5px;
  }

  .drawer-scroll {
    padding: 22px 18px 0;
  }

  .drawer-top {
    padding: 0 14px 0 18px;
  }

  .detail-title {
    font-size: 23px;
  }

  .detail-actions {
    gap: 6px;
  }

  .detail-actions .btn span {
    display: inline;
  }

  .content-box {
    padding: 16px;
    font-size: 13.5px;
    line-height: 1.85;
  }

  .detail-copy-bar {
    margin: auto -18px 0;
    padding: 12px 18px calc(14px + env(safe-area-inset-bottom));
  }

  .layer.modal-layer {
    align-items: flex-end;
    padding: 0;
  }

  .modal {
    width: 100%;
    max-height: 92dvh;
    border-radius: 18px 18px 0 0;
    border-bottom: 0;
    transform: translateY(24px);
  }

  .modal-head {
    padding: 18px 18px 14px;
  }

  .form-body {
    padding: 2px 18px 18px;
  }

  .modal-foot {
    padding: 12px 18px calc(12px + env(safe-area-inset-bottom));
  }

  .field-row {
    grid-template-columns: 1fr;
    gap: 0;
  }

  .unlock-modal form {
    padding: 0 18px;
  }

  .unlock-modal .modal-foot {
    margin: 16px -18px 0;
  }

  .confirm-copy {
    margin: 0 18px 16px;
  }

  .about-body {
    padding: 2px 18px 24px;
  }

  .form-modal .modal-head h2 {
    font-size: 20px;
  }

  .toast {
    bottom: calc(18px + env(safe-area-inset-bottom));
  }

  .skeleton {
    min-height: 150px;
  }
}

@media (max-width: 380px) {
  .mobile-brand {
    font-size: 16px;
  }

  .page-head h1 {
    font-size: 25px;
  }

  .card-actions .copy-btn span {
    display: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

@keyframes shimmer {
  0% { background-position: 100% 0; }
  100% { background-position: 0 0; }
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.45; }
}

@keyframes popIn {
  from { opacity: 0; transform: translateY(-4px); }
  to { opacity: 1; transform: none; }
}
