/* Reading Notes app (/work/tools/reading): the page is the app, laid out like Notion — a grey sidebar of books,
   a white page with properties, toggles and callouts, the highlights in one column and side notes in the next.
   The top bar and the gate are the Songbook's (body.sb-page in style.css); everything inside the app is here. */
.rd-page {
  --n-ink: #37352f; --n-soft: rgba(55, 53, 47, .65); --n-faint: rgba(55, 53, 47, .45); --n-line: rgba(55, 53, 47, .09);
  --n-hover: rgba(55, 53, 47, .06); --n-side: #f7f7f5; --n-blue: #2383e2;
  --n-sans: ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang TC", "Noto Sans TC", "Microsoft JhengHei", Helvetica, Arial, sans-serif;
  /* the four mark colours, Notion's highlight backgrounds and their dots */
  --vocab: rgba(251, 236, 168, .9); --vocab-dot: #dfab01;
  --key: rgba(253, 222, 222, .95); --key-dot: #e03e3e;
  --love: rgba(221, 235, 241, 1); --love-dot: #2f80c4;
  --ask: rgba(234, 228, 242, 1); --ask-dot: #9065b0;
}
.reading-app { flex: 1; display: grid; grid-template-columns: 260px minmax(0, 1fr); min-height: 0; color: var(--n-ink); font: 16px/1.6 var(--n-sans); }
.reading-app button, .reading-app select { font: inherit; color: inherit; }
.reading-app a { color: inherit; }
.reading-app :focus-visible { outline: 2px solid var(--n-blue); outline-offset: 1px; }

/* ---- Sidebar ---- */
.rd-lib { display: flex; flex-direction: column; min-height: 0; background: var(--n-side); border-right: 1px solid var(--n-line); }
.rd-lib-head { display: flex; gap: 6px; padding: 12px 10px 6px; }
.rd-find { flex: 1; }
.rd-search { width: 100%; height: 32px; padding: 0 10px; font: 14px var(--n-sans); color: var(--n-ink); background: rgba(55, 53, 47, .05); border: 0; border-radius: 6px; }
.rd-search:focus { outline: none; background: #fff; box-shadow: 0 0 0 1px rgba(35, 131, 226, .57), 0 0 0 3px rgba(35, 131, 226, .25); }
.rd-nav { flex: 1; overflow-y: auto; padding: 4px 6px 12px; }
.rd-lab { margin: 16px 8px 4px; font-size: 12px; font-weight: 500; color: var(--n-faint); }
.rd-item { display: flex; align-items: center; gap: 8px; min-height: 30px; padding: 3px 8px; border-radius: 6px; text-decoration: none; font-size: 14px; color: var(--n-soft); }
.rd-item:hover { background: var(--n-hover); }
.rd-item.on { background: rgba(55, 53, 47, .08); color: var(--n-ink); }
.rd-item b { flex: 1; min-width: 0; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rd-item small { font-size: 12px; color: var(--n-faint); }
.rd-ic { flex: none; display: inline-grid; place-items: center; width: 20px; height: 20px; font-size: 14px; color: var(--n-faint); }
.rd-tile { border-radius: 4px; color: #fff !important; font-size: 11px; font-weight: 600; line-height: 1; }
.rd-foot { display: flex; flex-direction: column; gap: 6px; padding: 10px 14px 14px; border-top: 1px solid var(--n-line); font-size: 12px; color: var(--n-faint); }
.rd-dl { align-self: flex-start; padding: 4px 10px; font-size: 13px !important; background: #fff; border: 1px solid var(--n-line); border-radius: 6px; cursor: pointer; box-shadow: 0 1px 2px rgba(15, 15, 15, .06); }
.rd-dl:hover { background: var(--n-hover); }
.rd-lib-close, .rd-lib-open, .rd-scrim { display: none; }

/* ---- Page ---- */
.rd-main { display: flex; flex-direction: column; min-width: 0; min-height: 0; background: #fff; }
.rd-bar { flex: none; display: flex; align-items: center; gap: 10px; height: 44px; padding: 0 16px; font-size: 14px; color: var(--n-soft); }
.rd-crumb { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rd-scroll { flex: 1; overflow-y: auto; outline: none; }
.rd-doc { max-width: 1080px; margin: 0 auto; padding: 36px 64px 120px; }
.rd-title { margin: 0 0 20px; font: 700 40px/1.2 var(--n-sans); letter-spacing: -.01em; color: var(--n-ink); }
.rd-page-ic { margin-top: 12px; }
.rd-big { display: inline-grid; place-items: center; width: 72px; height: 72px; margin-bottom: 12px; border-radius: 10px; color: #fff; font-size: 34px; font-weight: 600; }
.rd-h { margin: 36px 0 6px; font: 600 15px/1.4 var(--n-sans); color: var(--n-soft); }
.rd-empty { color: var(--n-faint); margin-top: 32px; }
.rd-faint { color: var(--n-faint); }

/* properties */
.rd-props { margin: 0 0 8px; padding-bottom: 16px; border-bottom: 1px solid var(--n-line); }
.rd-prop { display: grid; grid-template-columns: 160px 1fr; align-items: center; min-height: 34px; font-size: 14px; }
.rd-prop > span { color: var(--n-faint); }
.rd-prop > div { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.rd-pill { display: inline-block; padding: 0 6px; border-radius: 3px; background: rgba(227, 226, 224, .8); font-style: normal; font-size: 13px; line-height: 20px; white-space: nowrap; }
.rd-src { background: rgba(219, 237, 219, 1); color: #1c3829; }
.rd-st { padding: 2px 6px; font-size: 14px !important; border: 0; border-radius: 4px; background: transparent; cursor: pointer; }
.rd-st:hover { background: var(--n-hover); }

/* callout, toggles, Markdown */
.rd-callout { display: flex; gap: 12px; margin: 0 0 28px; padding: 16px 20px 14px 16px; background: rgba(241, 241, 239, 1); border-radius: 6px; }
.rd-callout-ic { font-size: 20px; line-height: 1.5; }
.rd-callout-lab { margin: 0; font-size: 12px; color: var(--n-faint); }
.rd-callout-q { margin: 4px 0 8px; font-size: 18px; line-height: 1.65; white-space: pre-wrap; }
.rd-callout-from { margin: 0; font-size: 14px; color: var(--n-soft); }
.rd-callout-from a { text-decoration: none; border-bottom: 1px solid var(--n-line); }
.rd-again { padding: 0; background: none; border: 0; color: var(--n-faint); cursor: pointer; font-size: 13px !important; }
.rd-again:hover { color: var(--n-ink); }
.rd-toggle { margin: 2px 0; }
.rd-toggle summary { display: flex; align-items: center; gap: 6px; padding: 3px 4px; border-radius: 4px; cursor: pointer; font-weight: 500; list-style: none; }
.rd-toggle summary::-webkit-details-marker { display: none; }
.rd-toggle summary::before { content: "▶"; font-size: 10px; color: var(--n-soft); transition: transform .15s; }
.rd-toggle[open] summary::before { transform: rotate(90deg); }
.rd-toggle summary:hover { background: var(--n-hover); }
.rd-toggle .rd-md { padding-left: 26px; }
.rd-md { font-size: 16px; }
.rd-md p { margin: 2px 0; min-height: 1em; }
.rd-md h3, .rd-md h4, .rd-md h5 { margin: 18px 0 4px; font-size: 18px; font-weight: 600; }
.rd-md blockquote { margin: 6px 0; padding: 0 14px; border-left: 3px solid currentColor; }
.rd-md ul, .rd-md ol { margin: 2px 0; padding-left: 24px; }
.rd-md img { max-width: 100%; border-radius: 4px; }
.rd-md hr { border: 0; border-top: 1px solid var(--n-line); margin: 12px 0; }

/* the database table of books */
.rd-tabs { display: flex; flex-wrap: wrap; gap: 2px; margin: 0 0 4px; border-bottom: 1px solid var(--n-line); }
.rd-tab { display: inline-flex; align-items: center; gap: 6px; padding: 6px 10px; font-size: 14px; color: var(--n-soft); text-decoration: none; background: none; border: 0; border-bottom: 2px solid transparent; margin-bottom: -1px; cursor: pointer; }
.rd-tab:hover { color: var(--n-ink); }
.rd-tab[aria-pressed="true"] { color: var(--n-ink); border-bottom-color: var(--n-ink); }
.rd-tab small { color: var(--n-faint); }
.rd-table { font-size: 14px; }
.rd-tr { display: grid; grid-template-columns: minmax(200px, 2.2fr) minmax(100px, 1.2fr) 100px 130px 84px 110px; text-decoration: none; border-bottom: 1px solid var(--n-line); }
.rd-tr > span { display: flex; align-items: center; gap: 6px; min-width: 0; padding: 7px 8px; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.rd-tr > span + span { border-left: 1px solid var(--n-line); }
.rd-th { color: var(--n-faint); }
a.rd-tr:hover { background: rgba(55, 53, 47, .03); }
.rd-tname b { font-weight: 500; overflow: hidden; text-overflow: ellipsis; border-bottom: 1px solid var(--n-line); }
.rd-num { justify-content: flex-end; font-variant-numeric: tabular-nums; }
.rd-links { display: flex; flex-direction: column; max-width: 480px; }

/* ---- Highlights and side notes, two columns ---- */
.rd-cols-head { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 40px; }
.rd-rows { border-top: 1px solid var(--n-line); }
.rd-row { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 40px; padding: 18px 0; border-bottom: 1px solid var(--n-line); }
.rd-q { margin: 0; font: 18px/1.8 var(--n-sans); white-space: pre-wrap; overflow-wrap: anywhere; }
.rd-where { margin: 6px 0 0; font-size: 12px; color: var(--n-faint); }
.rd-where a { color: var(--n-soft); }
.rd-notes { position: relative; padding-left: 14px; border-left: 2px solid var(--n-line); }
.rd-row:hover .rd-notes, .rd-notes:focus-within { border-left-color: rgba(55, 53, 47, .2); }
.rd-kn { margin: 0 0 6px; font-size: 14px; line-height: 1.6; white-space: pre-wrap; }
.rd-kn span { display: block; font-size: 11px; color: var(--n-faint); }
.rd-note { display: block; width: 100%; min-height: 26px; padding: 2px 0; font: 14px/1.6 var(--n-sans); color: var(--n-ink); background: none; border: 0; resize: none; overflow: hidden; }
.rd-note::placeholder { color: transparent; }
.rd-row:hover .rd-note::placeholder, .rd-note:focus::placeholder { color: var(--n-faint); }
.rd-note:focus { outline: none; }

/* marks */
.rd-m { color: inherit; border-radius: 3px; padding: 1px 0; cursor: pointer; }
.rd-vocab { background: var(--vocab); } .rd-key { background: var(--key); } .rd-love { background: var(--love); } .rd-ask { background: var(--ask); }
.rd-dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; }
.rd-dot.rd-vocab { background: var(--vocab-dot); } .rd-dot.rd-key { background: var(--key-dot); } .rd-dot.rd-love { background: var(--love-dot); } .rd-dot.rd-ask { background: var(--ask-dot); }
.rd-words { display: flex; flex-wrap: wrap; gap: 8px; margin: 20px 0 28px; }
.rd-words .rd-m { padding: 3px 8px; font-size: 16px; cursor: default; }
.rd-tool { position: fixed; z-index: 20; display: flex; gap: 2px; padding: 4px; background: #fff; border-radius: 8px;
  box-shadow: 0 0 0 1px rgba(15, 15, 15, .05), 0 3px 6px rgba(15, 15, 15, .1), 0 9px 24px rgba(15, 15, 15, .2); }
.rd-tool[hidden] { display: none; }
.rd-tool button { display: inline-flex; align-items: center; gap: 6px; padding: 5px 9px; font-size: 13px !important; white-space: nowrap; background: none; border: 0; border-radius: 4px; cursor: pointer; }
.rd-tool button:hover { background: var(--n-hover); }
.rd-tool button[data-c=""] { color: var(--n-soft); border-left: 1px solid var(--n-line); border-radius: 0 4px 4px 0; }

/* ---- Narrower: the side notes go under each highlight; on a phone the books become a drawer ---- */
@media (max-width: 1100px) {
  .rd-doc { padding: 28px 40px 100px; }
  .rd-row, .rd-cols-head { grid-template-columns: minmax(0, 1fr) 240px; gap: 28px; }
  .rd-tr { grid-template-columns: minmax(180px, 2fr) minmax(90px, 1fr) 90px 84px; }
  .rd-tr > span:nth-child(4), .rd-tr > span:nth-child(6) { display: none; }
}
@media (max-width: 899px) {
  .reading-app { grid-template-columns: minmax(0, 1fr); }
  .rd-lib { position: fixed; z-index: 30; top: 0; bottom: 0; left: 0; width: min(300px, 86vw); transform: translateX(-100%); transition: transform .2s ease; }
  .reading-app.lib-open .rd-lib { transform: none; box-shadow: 0 0 24px rgba(0, 0, 0, .15); }
  .rd-scrim:not([hidden]) { display: block; position: fixed; z-index: 25; inset: 0; background: rgba(15, 15, 15, .3); }
  .rd-lib-close { display: block; width: 32px; height: 32px; font-size: 20px !important; background: none; border: 0; cursor: pointer; color: var(--n-soft); }
  .rd-lib-open { display: inline-flex; align-items: center; gap: 4px; padding: 3px 8px; font-size: 14px !important; background: none; border: 0; border-radius: 4px; cursor: pointer; color: var(--n-soft); }
  .rd-lib-open:hover { background: var(--n-hover); }
  .rd-doc { padding: 16px 16px 80px; }
  .rd-title { font-size: 30px; }
  .rd-cols-head .rd-side-h { display: none; }
  .rd-cols-head, .rd-row { grid-template-columns: minmax(0, 1fr); gap: 10px; }
  .rd-q { font-size: 17px; }
  .rd-note::placeholder { color: var(--n-faint); }
  .rd-notes:not(:focus-within) .rd-note:placeholder-shown { min-height: 0; }
  .rd-prop { grid-template-columns: 110px 1fr; }
  .rd-table { margin: 0 -16px; }
  .rd-th { display: none; }
  .rd-tr { grid-template-columns: minmax(0, 1fr) auto; padding: 4px 8px; }
  .rd-tr > span + span { border-left: 0; }
  .rd-tr > span:nth-child(2) { grid-row: 2; padding-top: 0; font-size: 13px; color: var(--n-faint); }
  .rd-tr > span:nth-child(3), .rd-tr > span:nth-child(4), .rd-tr > span:nth-child(6) { display: none; }
  .rd-tr > .rd-num { grid-row: 1 / 3; grid-column: 2; color: var(--n-faint); }
  .rd-callout-q { font-size: 17px; }
}
