/* The Kindle highlights viewer (TL3 in Paper, page "Blog"): the drop card, the loaded library and the Export sheet.
   tool.css comes first: the steps reuse .measures, the drop card .start-card, the formats .option. */
.k-sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }

/* ---------- 1. Start ---------- */
/* The title wraps before "viewer", as drawn: the head's text column is 720 wide. */
.kh .tool-title h1 { max-width: 720px; }
.k-app { display: flex; gap: 20px; padding-top: 22px; border-top: 1px solid #E2E2DE; }
.k-app-icon { display: flex; width: 36px; flex-shrink: 0; padding-top: 2px; }
.k-app div { flex: 1; display: flex; flex-direction: column; gap: 4px; }
.measures .k-app b { font-size: 17px; line-height: 25px; letter-spacing: 0; font-weight: 700; }
.k-zone { align-self: stretch; display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 32px 24px; border: 2px dashed var(--pencil); border-radius: 18px; background: var(--canvas); cursor: pointer; transition: border-color .15s, background .15s; }
.k-zone svg { display: block; margin-bottom: 6px; }
.k-zone b { font-size: 26px; line-height: 31px; letter-spacing: -0.02em; font-weight: 800; text-wrap: balance; }
.k-zone span { font-size: 17px; line-height: 25px; color: var(--graphite); }
.k-zone:hover { border-color: var(--graphite); }
/* A file dragged anywhere over the page: dropping it opens it. */
.tool.dragging .k-zone { border-color: var(--ink); background: var(--lilac-soft); }
.k-drop .k-error { font-size: 15px; line-height: 21px; font-weight: 600; color: #D13438; text-wrap: balance; }
.k-drop .big { align-self: stretch; }
.k-sample { font-size: 16px; line-height: 22px; font-weight: 600; color: var(--violet); text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 3px; }
.k-sample:disabled { color: var(--graphite); cursor: default; }

/* ---------- 2. Loaded ---------- */
.st-loaded { display: flex; flex-direction: column; gap: 28px; padding: 32px 40px 40px; }
.k-bar { display: flex; align-items: center; justify-content: space-between; gap: 24px; }
.k-sum { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.k-sum strong { font-size: 26px; line-height: 31px; letter-spacing: -0.02em; font-weight: 800; outline: none; }
.k-sub { display: flex; align-items: center; flex-wrap: wrap; gap: 6px; font-size: 15px; line-height: 20px; color: var(--graphite); }
.k-sub svg { flex-shrink: 0; }
.k-dot { padding: 0 4px; color: var(--pencil); }
.k-link { font-size: 15px; line-height: 20px; font-weight: 600; color: var(--violet); text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 3px; }
.k-actions { display: flex; align-items: center; gap: 10px; flex-shrink: 0; }
.k-search { display: flex; align-items: center; gap: 10px; width: 340px; height: 52px; padding: 0 18px; border: 1.5px solid var(--hairline); border-radius: 26px; background: #FFFFFF; cursor: text; transition: border-color .15s; }
.k-search svg { flex-shrink: 0; }
.k-search input { flex: 1; min-width: 0; height: 100%; font-size: 16px; line-height: 22px; }
.k-search input::placeholder { color: var(--pencil); opacity: 1; }
.k-search input::-webkit-search-cancel-button { -webkit-appearance: none; width: 18px; height: 18px; margin-left: 8px; background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M6 6l12 12M18 6L6 18' fill='none' stroke='%236B6B6B' stroke-width='2.4' stroke-linecap='round'/%3E%3C/svg%3E") center / 14px no-repeat; cursor: pointer; }
.k-search:focus-within { border-color: var(--pencil); }
.big.k-export { gap: 8px; height: 52px; padding: 0 22px; border-radius: 26px; font-size: 17px; line-height: 22px; }
.k-none { padding: 24px 0 16px; font-size: 17px; line-height: 25px; color: var(--graphite); text-align: center; text-wrap: balance; }
.k-lib { display: flex; align-items: flex-start; gap: 24px; }
.k-lib[hidden] { display: none; }

/* The book list scrolls inside its card and stays under the top bar. */
.k-books { position: sticky; top: 96px; width: 360px; max-height: calc(100vh - 120px); flex-shrink: 0; display: flex; flex-direction: column; gap: 4px; padding: 20px 12px 12px; border-radius: 20px; background: #FFFFFF; }
.k-books-head { display: flex; justify-content: space-between; gap: 12px; padding: 0 12px 8px; }
.k-books-head span:last-child { font-size: 13px; line-height: 18px; font-weight: 600; color: var(--graphite); }
.k-rows { display: flex; flex-direction: column; gap: 2px; min-height: 0; margin: -4px; padding: 4px; overflow-y: auto; overscroll-behavior: contain; }
.k-row { display: flex; align-items: center; gap: 12px; flex-shrink: 0; width: 100%; min-height: 62px; padding: 8px 12px; border: 1.5px solid transparent; border-radius: 14px; transition: background .15s; }
.k-row:hover { background: var(--canvas); }
.k-row-text { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 1px; }
/* Long titles wrap to two lines at most. */
.k-row-text b { display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; overflow: hidden; overflow-wrap: anywhere; font-size: 16px; line-height: 21px; font-weight: 600; }
.k-row-text span { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; font-size: 14px; line-height: 19px; color: var(--graphite); }
.k-row-n { width: 40px; flex-shrink: 0; text-align: right; font-size: 15px; line-height: 20px; font-weight: 600; color: var(--graphite); }
.k-chev { display: flex; justify-content: flex-end; width: 16px; flex-shrink: 0; visibility: hidden; }
/* The open book: ink border, bold text and the chevron, not only the tint. */
.k-row[aria-current="true"] { border-color: var(--ink); background: var(--lilac-soft); }
.k-row[aria-current="true"] b { font-weight: 800; }
.k-row[aria-current="true"] .k-row-text span { color: var(--ink); }
.k-row[aria-current="true"] .k-row-n { font-weight: 800; color: var(--ink); }
.k-row[aria-current="true"] .k-chev { visibility: visible; }

/* The phone's book picker: a native select over the drawn face. */
.k-pick { position: relative; display: none; align-items: center; gap: 12px; height: 64px; padding: 0 16px; border: 1.5px solid var(--ink); border-radius: 16px; background: #FFFFFF; }
.k-pick > div { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.k-pick b, .k-pick span { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.k-pick b { font-size: 17px; line-height: 22px; font-weight: 800; }
.k-pick span { font-size: 14px; line-height: 19px; color: var(--graphite); }
.k-pick svg { flex-shrink: 0; }
.k-pick select { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; font-size: 16px; cursor: pointer; appearance: none; }

.k-book { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 14px; }
.k-book-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; padding: 8px 4px 10px; }
.k-book-head > div { min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.k-book-head strong { font-size: 34px; line-height: 40px; letter-spacing: -0.03em; font-weight: 800; text-wrap: balance; overflow-wrap: anywhere; }
.k-book-head > div > span { font-size: 17px; line-height: 24px; color: var(--graphite); }
.outline.k-copy-all { flex-shrink: 0; gap: 8px; height: 44px; padding: 0 18px; border-radius: 22px; font-size: 15px; line-height: 20px; font-weight: 700; }
.k-cards { display: flex; flex-direction: column; gap: 14px; }
.k-card { display: flex; gap: 16px; padding: 24px 20px 24px 28px; border-radius: 20px; background: #FFFFFF; }
.k-card-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 14px; }
.k-quote { font-family: "Literata", Georgia, serif; font-size: 19px; line-height: 31px; font-weight: 400; white-space: pre-line; overflow-wrap: anywhere; }
.k-limit { font-size: 16px; line-height: 23px; color: var(--graphite); }
.k-note { display: flex; flex-direction: column; gap: 4px; padding: 12px 16px; border-left: 3px solid var(--ink); border-radius: 4px 12px 12px 4px; background: var(--canvas); }
.k-note .lbl { font-size: 12px; line-height: 16px; }
.k-note p { font-size: 16px; line-height: 23px; white-space: pre-line; overflow-wrap: anywhere; }
.k-where { font-size: 14px; line-height: 19px; color: var(--graphite); }
.k-copy { display: flex; align-items: center; justify-content: center; width: 40px; height: 40px; flex-shrink: 0; border-radius: 20px; background: var(--canvas); transition: background .15s; }
.k-copy:hover { background: #E8E8E5; }
span.k-copy { visibility: hidden; }
/* Copied: a check in place of the copy icon for two seconds, and the button's name says Copied. */
.k-i-done { display: none; }
.done .k-i-copy { display: none; }
.done .k-i-done { display: block; }
.k-copy.done { background: var(--lilac); }

.k-link:focus-visible, .k-sample:focus-visible, .k-row:focus-visible, .k-copy:focus-visible, .k-close:focus-visible, .k-cancel:focus-visible,
.k-search:focus-within, .k-pick:has(select:focus-visible), .k-scope label:has(input:focus-visible), .k-check:has(input:focus-visible) i { outline: 2px solid var(--violet); outline-offset: 2px; }

/* ---------- Export ---------- */
html:has(.k-sheet[open]) { overflow: hidden; }
.k-sheet { width: min(560px, calc(100% - 32px)); max-width: none; max-height: calc(100dvh - 32px); margin: clamp(16px, calc(50dvh - 312px), 168px) auto auto; padding: 0; border: 0; border-radius: 28px; background: #FFFFFF; color: var(--ink); box-shadow: 0 20px 50px #0A0A0A24, 0 1px 3px #0A0A0A0F; overflow-y: auto; overscroll-behavior: contain; }
.k-sheet::backdrop { background: rgba(243, 243, 241, .82); }
.k-sheet[open] { animation: k-pop .3s cubic-bezier(.2, .8, .2, 1); }
@keyframes k-pop { from { opacity: 0; transform: translateY(8px) scale(.98); } }
.k-sheet-form { display: flex; flex-direction: column; gap: 22px; padding: 32px; }
.k-sheet-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.k-sheet-head strong { font-size: 28px; line-height: 33px; letter-spacing: -0.025em; font-weight: 800; }
.k-close { display: flex; align-items: center; justify-content: center; width: 40px; height: 40px; flex-shrink: 0; border-radius: 20px; background: var(--canvas); }
.k-scope { display: flex; gap: 4px; padding: 4px; border-radius: 16px; background: var(--canvas); }
.k-scope label { position: relative; flex: 1 1 0; min-width: 0; display: flex; align-items: center; justify-content: center; gap: 6px; height: 44px; padding: 0 14px; border: 1.5px solid transparent; border-radius: 12px; cursor: pointer; }
.k-scope input, .k-check input { position: absolute; opacity: 0; pointer-events: none; }
.k-scope b { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; font-size: 16px; line-height: 22px; font-weight: 500; }
.k-scope i { flex-shrink: 0; font-style: normal; font-size: 15px; line-height: 20px; font-weight: 600; color: var(--graphite); }
.k-scope label:has(input:checked) { border-color: var(--ink); background: #FFFFFF; }
.k-scope label:has(input:checked) b { font-weight: 800; }
.k-formats { display: flex; flex-direction: column; gap: 10px; }
.k-formats .lbl { padding-bottom: 2px; }
.option .k-fmt { display: flex; flex-direction: column; gap: 2px; font-size: 17px; line-height: 22px; font-weight: 500; }
.k-fmt b { font-weight: 500; }
.option:has(input:checked) .k-fmt { font-weight: 500; }
.option:has(input:checked) .k-fmt b { font-weight: 700; }
.k-fmt small { font-size: 15px; line-height: 20px; font-weight: 400; color: var(--graphite); }
/* Graphite on lilac-soft is 4.4:1, a shade darker passes. */
.option:has(input:checked) .k-fmt small { color: #666666; }
.k-check { position: relative; align-self: flex-start; display: flex; align-items: center; gap: 12px; font-size: 16px; line-height: 22px; font-weight: 500; cursor: pointer; }
.k-check i { display: flex; align-items: center; justify-content: center; width: 22px; height: 22px; flex-shrink: 0; border: 2px solid var(--pencil); border-radius: 6px; background: #FFFFFF; }
.k-check svg { visibility: hidden; }
.k-check:has(input:checked) i { border: 0; background: var(--ink); }
.k-check:has(input:checked) svg { visibility: visible; }
.k-sheet-acts { display: flex; align-items: center; justify-content: flex-end; gap: 8px; padding-top: 6px; }
.k-cancel { display: flex; align-items: center; justify-content: center; height: 56px; padding: 0 20px; border-radius: 28px; font-size: 17px; line-height: 22px; font-weight: 700; transition: background .15s; }
.k-cancel:hover { background: var(--canvas); }
.big.k-download { min-width: 0; gap: 8px; height: 56px; padding: 0 28px; border-radius: 28px; font-size: 17px; line-height: 22px; }
.k-download svg { flex-shrink: 0; }
.k-download span { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }

@media (prefers-reduced-motion: reduce) {
  .k-sheet[open] { animation: none; }
}

@media (max-width: 1180px) {
  .k-books { width: 320px; }
  .k-search { width: 300px; }
}
@media (max-width: 980px) {
  .st-loaded { gap: 24px; padding: 28px 32px 32px; }
  .k-bar { flex-direction: column; align-items: stretch; gap: 16px; }
  .k-search { flex: 1; width: auto; min-width: 0; }
  .k-books { width: 280px; }
}
@media (max-width: 760px) {
  /* The drop card sits in its own grey frame, as in the reading test (tool.css). */
  .k-drop { gap: 16px; padding: 18px 16px 22px; border-radius: 20px; }
  .k-drop::before { border-radius: 28px; }
  .k-zone { padding: 24px 16px; }
  .k-zone b { font-size: 21px; line-height: 26px; }
  .k-zone span { font-size: 16px; line-height: 23px; }
  .k-drop small { font-size: 13px; line-height: 18px; }
  .k-app { gap: 14px; }
  .k-app-icon { width: 22px; }
  .measures .k-app b { font-size: 16px; line-height: 22px; }

  .tool[data-state="loaded"] .panel { margin-top: 16px; }
  .st-loaded { gap: 12px; padding: 18px 12px 12px; }
  .k-bar { gap: 12px; }
  .k-sum { padding: 0 6px 4px; }
  .k-sum strong { font-size: 22px; line-height: 27px; }
  .k-sub, .k-link { font-size: 14px; line-height: 19px; }
  .k-sub svg { width: 14px; height: 14px; }
  .k-dot { padding: 0; }
  .k-actions { gap: 8px; }
  .k-search { gap: 8px; height: 48px; padding: 0 14px; border-radius: 24px; }
  .k-search svg { width: 16px; height: 16px; }
  .big.k-export { gap: 6px; height: 48px; padding: 0 16px; border-radius: 24px; font-size: 16px; }
  .k-export svg { width: 16px; height: 16px; }
  .k-lib { flex-direction: column; align-items: stretch; gap: 12px; }
  .k-books, .k-book-head { display: none; }
  .k-pick { display: flex; }
  .k-book, .k-cards { gap: 12px; }
  .k-card { gap: 10px; padding: 18px 12px 18px 18px; }
  .k-card-body { gap: 12px; }
  .k-quote { font-size: 17px; line-height: 28px; }
  .k-limit { font-size: 15px; line-height: 22px; }
  .k-note p { font-size: 15px; line-height: 22px; }
  .k-copy { width: 36px; height: 36px; border-radius: 18px; }

  /* Export is a sheet from the bottom. */
  .k-sheet { width: 100%; max-height: calc(100dvh - 24px); margin: auto 0 0; border-radius: 28px 28px 0 0; }
  .k-sheet[open] { animation: k-up .35s cubic-bezier(.2, .8, .2, 1); }
  @keyframes k-up { from { transform: translateY(40px); opacity: 0; } }
  .k-sheet-form { gap: 18px; padding: 24px 20px calc(20px + env(safe-area-inset-bottom, 0px)); }
  .k-sheet-head strong { font-size: 24px; line-height: 29px; }
  .k-scope label { padding: 0 10px; }
  .option .k-fmt { font-size: 16px; line-height: 21px; }
  .k-fmt small { font-size: 14px; line-height: 19px; }
  .k-sheet-acts { flex-direction: column-reverse; align-items: stretch; gap: 4px; padding-top: 2px; }
  .k-cancel { height: 52px; }
}
