/* Keep the original card palette and hierarchy; place the catalogue under one masthead. */
:root {
  --paper: #f6f3ed;
  --surface: #fffdf8;
  --surface-strong: #fffefa;
  --ink: #202b2a;
  --muted: #586764;
  --line: #d7dfd9;
  --accent: #247b68;
  --accent-dark: #155d4e;
  --accent-soft: #e6f1eb;
  --sidebar: 264px;
  --serif: "Songti SC", "STSong", serif;
}
html { scroll-behavior: smooth; scroll-padding-top: 20px; }
body { background: var(--paper); }
a { color: inherit; text-decoration: none; }
button, a, input { -webkit-tap-highlight-color: transparent; }
button:focus-visible, a:focus-visible { outline: 3px solid var(--accent); outline-offset: 4px; }
[hidden] { display: none !important; }
.skip-link { position: fixed; top: -70px; left: 20px; padding: 14px; background: white; z-index: 100; }
.skip-link:focus { top: 12px; }
.site-header { min-height: 76px; display: flex; justify-content: space-between; align-items: center; gap: 20px; padding: 14px clamp(24px,4vw,64px); background: var(--surface); border-bottom: 1px solid var(--line); }
.site-identity, .site-actions { display: flex; align-items: center; gap: 14px; }
.site-identity { font-size: 13px; letter-spacing: 1.2px; font-weight: 500; }
.site-identity .wordmark { font-family: Georgia,serif; font-size: 35px; line-height: 1; letter-spacing: -1.5px; }
.site-identity img { display: block; }
.site-identity span span { font-family: -apple-system,BlinkMacSystemFont,"PingFang SC",sans-serif; font-size: 11px; font-weight: 400; letter-spacing: 2px; margin-left: 18px; padding-left: 18px; border-left: 1px solid var(--line); vertical-align: middle; }
.site-actions { gap: 30px; }
.home-link { font-size: 13px; color: var(--muted); }
.home-link:hover { color: var(--accent); }
.account-button { background: var(--accent-dark); font-weight: 550; min-height: 38px; }
/* One full-width painted cover, followed by the working library. */
.masthead { position: relative; isolation: isolate; overflow: hidden; height: min(700px,calc(100svh - 134px)); min-height: 540px; color: #fffdf3; background: #697249; }
.masthead-art { position: absolute; inset: 0; z-index: -2; width: 100%; height: 100%; object-fit: cover; object-position: center center; animation: cover-arrive 1.6s cubic-bezier(.16,1,.3,1) both; }
.masthead::after { content: ""; position: absolute; inset: 0; z-index: -1; background: linear-gradient(90deg,rgba(19,39,30,.36),rgba(19,39,30,.13) 35%,transparent 65%),linear-gradient(0deg,rgba(19,39,30,.32),transparent 40%),linear-gradient(180deg,rgba(19,39,30,.13),transparent 18%); }
.masthead-top { position: absolute; top: 27px; left: clamp(24px,4vw,64px); right: clamp(24px,4vw,64px); display: flex; justify-content: space-between; gap: 20px; font-size: 10px; letter-spacing: 2.5px; }
.masthead-copy { position: absolute; left: clamp(24px,4vw,64px); top: 84px; bottom: 47px; display: flex; flex-direction: column; align-items: flex-start; animation: cover-rise 1s .12s both; }
.masthead-copy .eyebrow { font-family: Georgia,serif; font-size: 17px; letter-spacing: 7px; margin: 0 0 7px 6px; color: #f2ead5; }
.masthead-copy h1 { position: relative; font-family: var(--serif); font-size: clamp(114px,12.6vw,184px); letter-spacing: .09em; font-weight: 400; line-height: 1.15; margin: 0 0 20px; }
.title-seal { display: inline-block; vertical-align: top; font-size: 12px; line-height: 1.4; letter-spacing: 0; padding: 6px 5px; border: 1px solid #f2ead5b3; margin: 21px 0 0 13px; color: #f2ead5; }
.masthead-copy .masthead-line { font-family: var(--serif); font-size: clamp(25px,2.45vw,36px); line-height: 1.7; letter-spacing: 3px; margin: auto 0 25px; color: #fffdf3; }
.reading-link { display: inline-flex; align-items: center; justify-content: space-between; gap: 42px; padding: 15px 23px; min-height: 52px; background: #f5f2e8; color: #263d35; font-size: 13px; letter-spacing: 1px; transition: background .2s,transform .2s; }
.reading-link span { font-size: 21px; line-height: 1; transition: transform .2s; }
.reading-link:hover { background: #fffdf7; transform: translateY(-2px); }
.reading-link:hover span { transform: translateY(3px); }
.masthead a:focus-visible { outline-color: #fffdf3; }
.masthead-credit { position: absolute; right: clamp(24px,4vw,64px); bottom: 46px; text-align: right; font-size: 10px; letter-spacing: 1px; line-height: 1.8; color: #fff9e9; }
.masthead-credit > span:first-child { font-size: 9px; letter-spacing: 2px; }
.masthead-credit p { font-family: Georgia,serif; font-size: 21px; margin: 8px 0 5px; letter-spacing: 0; }
.reading-divider { display: flex; align-items: center; justify-content: space-between; gap: 20px; min-height: 58px; padding: 16px clamp(24px,4vw,64px); background: var(--paper); border-bottom: 1px solid var(--line); color: var(--muted); font-size: 11px; letter-spacing: 2px; }
.reading-divider > span:first-child { color: var(--accent-dark); }
.reading-divider a { display: inline-flex; align-items: center; gap: 22px; letter-spacing: 1px; }
.reading-divider a:hover { color: var(--accent-dark); }
@keyframes cover-arrive { from { transform: scale(1.045); } to { transform: scale(1); } }
@keyframes cover-rise { from { transform: translateY(16px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }
.app-shell { display: grid; grid-template-columns: var(--sidebar) minmax(0,1fr); align-items: start; min-height: 0; }
.sidebar { position: sticky; top: 0; height: 100dvh; overflow: auto; background: #f1f5ef; padding: 28px 20px; border-right: 1px solid var(--line); backdrop-filter: none; scrollbar-width: thin; scrollbar-color: #adc4b7 transparent; }
.sidebar-title { font-size: 20px; margin: 0 0 20px; line-height: 1.5; }
.sidebar-section { padding: 20px 0; }
.sidebar .section-label { display: flex; align-items: baseline; justify-content: space-between; color: #475d56; font-size: 12px; }
.section-label > span { font-size: 9px; letter-spacing: 1px; font-weight: 400; }
.learning-tab, .tree-parent { background: #ffffffb3; min-height: 38px; font-weight: 550; }
.learning-tab.is-active, .tree-parent.is-active, .filter-chip.is-active { background: var(--accent); color: white; }
.tree-parent small, .learning-tab small { opacity: .9; }
.tree-children { border-color: var(--line); }
.category-tree { max-height: 390px; scrollbar-width: thin; }
.filter-chip { font-weight: 500; font-size: 12px; }
.tags-panel .tag-cloud { max-height: 220px; overflow: auto; scrollbar-width: thin; }
.workspace { padding: 28px clamp(20px,3vw,44px) 32px; width: 100%; min-width: 0; margin: 0; }
.topbar { display: grid; grid-template-columns: auto minmax(0,1fr); align-items: center; gap: 20px; }
.desktop-location { font-size: 14px; font-weight: 600; }
.search-wrap input { background: var(--surface-strong); box-shadow: none; min-height: 46px; font-size: 14px; }
.summary-strip { margin: 22px 0; background: var(--line); border-radius: 6px; }
.summary-strip div { min-height: 74px; background: var(--surface); padding: 15px 18px; display: flex; align-items: baseline; gap: 12px; }
.summary-strip strong { font-size: 25px; margin: 0; font-weight: 650; font-variant-numeric: tabular-nums; }
.summary-strip span { color: var(--muted); font-size: 12px; white-space: nowrap; }
.library-toolbar { display: flex; justify-content: space-between; align-items: center; gap: 20px; margin: 24px 0 14px; scroll-margin-top: 24px; }
.library-toolbar h2 { font-size: 23px; font-weight: 650; line-height: 1.4; }
.segmented { display: flex; background: #ecf2ee; padding: 4px; }
.segment { padding: 0 17px; font-size: 13px; font-weight: 600; min-height: 36px; }
.segment.is-active { background: var(--accent); color: white; }
.active-filters { margin-bottom: 16px; }
.active-pill { font-weight: 500; }
.masonry { columns: 3 250px; column-gap: 18px; }
.note-card { padding: 20px; margin-bottom: 18px; background: var(--surface-strong); border: 1px solid #d5dfd8; box-shadow: 0 3px 12px #253d2d06; overflow-wrap: anywhere; }
.note-card::before { display: block; content: ""; width: 46px; height: 4px; margin: 0 0 14px; border-radius: 999px; background: var(--accent); }
.note-card:hover { border-color: #77a893; transform: translateY(-3px); box-shadow: 0 8px 22px #253d2d0b; }
.note-card .learning-state-row { float: right; margin: -21px 0 10px 10px; }
.note-card .meta-row { clear: both; margin-bottom: 13px; }
.meta-badge { color: #4d655c; background: #eff5ef; font-size: 10px; font-weight: 500; border: 0; border-radius: 4px; }
.note-card h3 { font-size: 21px; font-weight: 650; line-height: 1.5; margin-bottom: 10px; }
.note-card p { font-size: 14px; color: #414e4b; line-height: 1.8; display: -webkit-box; -webkit-line-clamp: 5; -webkit-box-orient: vertical; overflow: hidden; }
.tag { font-weight: 500; font-size: 11px; background: var(--accent-soft); color: var(--accent-dark); }
.relation-line { font-size: 11px; color: var(--muted); font-weight: 500; }
.learning-badge { font-weight: 500; }
.learning-badge.unread { color: #5e6f66; background: #edf1ec; }
.load-more-card { background: #eaf3ed; }
.empty-state { border-radius: 8px; padding: 30px; text-align: center; }
.reset-filters { margin-top: 18px; border: 0; border-radius: 5px; background: var(--accent); color: white; padding: 12px 18px; font-size: 13px; }
.library-footer { display: flex; justify-content: space-between; flex-wrap: wrap; gap: 16px; padding: 24px 0 0; margin-top: 24px; border-top: 1px solid var(--line); font-size: 12px; color: var(--muted); }
.library-footer a { color: var(--accent-dark); }
.nav-toggle, .nav-close, .nav-backdrop { display: none; }
@media (max-width:1100px) {
  :root { --sidebar: 240px; }
  .summary-strip div { display: block; }
  .summary-strip strong { margin-bottom: 7px; }
  .workspace { padding-left: 24px; padding-right: 24px; }
}
@media (max-width:800px) {
  .site-header { padding: 15px 20px; gap: 12px; }
  .site-actions { gap: 16px; }
  .site-identity span span { display: none; }
  .app-shell { display: block; }
  .sidebar { position: fixed; inset: 0 auto 0 0; width: min(320px,88vw); height: 100dvh; z-index: 50; transform: translateX(-105%); transition: transform .25s; padding: 32px 22px; box-shadow: 12px 0 40px #213c271f; border: 0; }
  .sidebar.is-open { transform: none; }
  .sidebar-title { padding-right: 35px; }
  .sidebar .tags-panel { display: block; }
  .nav-backdrop:not([hidden]) { display: block; position: fixed; inset: 0; background: #12281d70; border: 0; z-index: 49; }
  .nav-close { display: block; position: absolute; right: 16px; top: 22px; width: 36px; height: 36px; border: 0; background: transparent; color: var(--ink); font-size: 28px; }
  .nav-toggle { display: flex; align-items: center; gap: 8px; background: transparent; color: var(--ink); border: 1px solid var(--line); border-radius: 6px; min-height: 46px; padding: 0 12px; font-size: 14px; }
  .desktop-location { display: none; }
  .workspace { padding: 24px; }
  .topbar { grid-template-columns: auto minmax(0,1fr); gap: 12px; }
  .summary-strip { grid-template-columns: repeat(4,minmax(0,1fr)); }
  .library-toolbar { gap: 12px; }
  .segment { padding: 0 13px; }
}
@media (max-width:560px) {
  .site-header { min-height: 64px; padding: 12px 18px; }
  .site-identity .wordmark { font-size: 29px; }
  .site-identity { gap: 8px; font-size: 11px; }
  .site-identity img { width: 28px; height: 28px; }
  .site-actions { gap: 14px; }
  .home-link { font-size: 11px; }
  .account-button { font-size: 11px; min-height: 34px; padding: 0 10px; }
  .account-menu { min-width: 0; gap: 5px; padding: 5px; }
  .account-menu strong { max-width: 70px; }
  .account-menu small { display: none; }
  .workspace { padding: 20px 16px; }
  .search-wrap input { font-size: 12px; padding-right: 8px; }
  .summary-strip { margin: 18px 0; }
  .summary-strip div { padding: 12px 8px; min-height: 70px; }
  .summary-strip strong { font-size: 22px; }
  .summary-strip span { font-size: 10px; }
  .library-toolbar { margin: 20px 0 12px; flex-wrap: wrap; }
  .library-toolbar h2 { font-size: 22px; }
  .segmented { width: 100%; }
  .segment { flex: 1; min-height: 40px; font-size: 13px; padding: 0 8px; }
  .masonry { columns: 1; }
  .note-card { padding: 20px; }
  .note-card h3 { font-size: 21px; }
  .note-dialog { width: calc(100% - 24px); max-height: 92dvh; }
  .note-panel { padding: 28px 20px; }
  .library-footer { font-size: 11px; }
}
@media (max-width:800px) {
  .masthead { height: min(680px,calc(100svh - 124px)); min-height: 530px; }
  .masthead-copy { top: 87px; bottom: 40px; }
  .masthead-copy h1 { font-size: clamp(108px,19vw,150px); }
  .masthead-credit { bottom: 40px; }
  .masthead-credit p { font-size: 17px; }
  .masthead-copy .masthead-line { font-size: 29px; }
}
@media (max-width:560px) {
  .masthead { height: calc(100svh - 116px); max-height: 720px; min-height: 570px; }
  .masthead-art { object-position: center center; }
  .masthead::after { background: linear-gradient(90deg,rgba(19,39,30,.34),rgba(19,39,30,.10) 85%),linear-gradient(0deg,rgba(12,39,36,.5),transparent 48%); }
  .masthead-top { top: 22px; font-size: 8px; letter-spacing: 1.5px; }
  .masthead-copy { top: 87px; bottom: 86px; }
  .masthead-copy .eyebrow { font-size: 13px; letter-spacing: 5px; margin-left: 4px; }
  .masthead-copy h1 { font-size: clamp(100px,27vw,145px); letter-spacing: .07em; margin-top: 6px; }
  .title-seal { font-size: 10px; margin: 13px 0 0 6px; padding: 4px; }
  .masthead-copy .masthead-line { font-size: 27px; line-height: 1.7; letter-spacing: 2px; margin-bottom: 25px; }
  .reading-link { padding: 14px 19px; min-height: 50px; font-size: 12px; gap: 36px; }
  .masthead-credit { left: 24px; right: 24px; bottom: 23px; text-align: left; display: flex; gap: 12px; align-items: baseline; font-size: 9px; }
  .masthead-credit > span:first-child { display: none; }
  .masthead-credit p { font-size: 15px; margin: 0; }
  .reading-divider { min-height: 52px; font-size: 10px; letter-spacing: 1px; padding: 15px 24px; }
  .reading-divider > span:nth-child(2) { display: none; }
}
@media(prefers-reduced-motion:reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
