/* Sunny Knoll — light theme, built on the Sunny Knoll design system.
   Cream ground, deep green words, one orange sun for the main action, Georgia, square edges,
   and the hills running into the footer. (The library uses the darker version of this theme.) */
:root {
  /* brand palette */
  --sk-cream: #faf6ee; --sk-green: #2f3a2f; --sk-muted: #6b766b; --sk-sun: #e8a33d;
  --sk-hill: #8fae7e; --sk-hill-dark: #6f9160; --sk-on-hill: #eef3ea;
  /* shades derived for small text */
  --sk-green-ink: #4f6e42;   /* hill-dark, darkened: 5.3:1 on cream */
  --sk-green-deep: #232c23;

  --bg: var(--sk-cream);
  --card: #fffdf8;
  --ink: var(--sk-green);
  --muted: #5c675c;          /* 5.5:1 on cream */
  --line: #e4dfd2;
  --accent: var(--sk-green-ink);       /* links, chips */
  --accent-ink: var(--sk-cream);
  --accent-soft: var(--sk-on-hill);
  --leaf: var(--sk-green-ink);
  --danger: #a3262a;
  --brass: var(--sk-sun); --on-brass: var(--sk-green);
  --forest: var(--sk-green); --forest-deep: var(--sk-green-deep);
  --footer: var(--sk-green-ink); --footer-ink: var(--sk-cream);
  --ok-bg: var(--sk-on-hill);  --ok-ink: var(--sk-green);
  --warn-bg: #fbeed6;          --warn-ink: #7a5212;
  --err-bg: #f8e3e1;           --err-ink: #7a1d1f;   --err-line: #e2a7a4;
  --cover-shadow: rgba(35, 44, 35, .2);
  --radius: 0px; --radius-ctl: 2px;
  --shadow: 0 1px 0 rgba(35, 44, 35, .03), 0 8px 24px -16px rgba(35, 44, 35, .25);
  --serif: Georgia, "Times New Roman", serif;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #1e261e; --card: #263026; --ink: var(--sk-cream); --muted: #b8c2b2; --line: #3a463a;
    --accent: #a9c49a; --accent-ink: var(--sk-green); --accent-soft: #2f3a2f; --leaf: #a9c49a;
    --danger: #ef7b7f; --footer: #161c16; --forest-deep: #141914;
    --ok-bg: #2f3a2f; --ok-ink: #d6dfd0; --warn-bg: #3a3020; --warn-ink: #f1dca8;
    --err-bg: #3d2224; --err-ink: #f3c7c8; --err-line: #6a3a3a;
    --cover-shadow: rgba(0, 0, 0, .45); --shadow: none;
  }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 18px/1.65 "Source Sans 3", system-ui, -apple-system, Segoe UI, sans-serif;
}
h1, h2, h3, .brand { font-family: var(--serif); font-weight: 600; line-height: 1.2; }
a { color: var(--accent); }
img { max-width: 100%; display: block; }
.wrap { max-width: 1080px; margin: 0 auto; padding: 0 16px; }
body.narrow main { max-width: 460px; }
body.editor-page main { max-width: 760px; }

/* header / footer */
.site-header { background: var(--card); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 10; }
.site-header .wrap { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 60px; flex-wrap: wrap; }
.brand { font-size: 1.35rem; color: var(--ink); text-decoration: none; }
.site-header nav { display: flex; align-items: center; gap: 16px; font-size: .95rem; }
.site-header nav a:not(.btn) { color: var(--muted); text-decoration: none; }
.site-header nav a:not(.btn):hover { color: var(--accent); }
.site-footer { color: var(--muted); font-size: .85rem; padding: 40px 0; text-align: center; }

/* hero */
.hero { text-align: center; padding: 48px 0 28px; }
.hero h1 { font-size: clamp(2.1rem, 6vw, 3.4rem); margin: 0 0 6px; }
.hero p { color: var(--muted); margin: 0; font-size: 1.1rem; }

/* layout */
.layout { display: grid; grid-template-columns: minmax(0, 1fr) 260px; gap: 36px; align-items: start; }
@media (max-width: 820px) { .layout { grid-template-columns: 1fr; } .sidebar { order: -1; } }

/* buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  background: var(--accent); color: var(--accent-ink); border: 0; border-radius: 999px;
  padding: 10px 20px; font: 600 1rem/1.2 inherit; font-family: inherit; text-decoration: none; cursor: pointer;
}
.btn:hover { filter: brightness(1.06); }
.btn:disabled { opacity: .6; cursor: wait; }
.btn-big { padding: 14px 28px; font-size: 1.08rem; }
.btn-small { padding: 7px 14px; font-size: .9rem; }
.btn-ghost { background: transparent; color: var(--ink); border: 1px solid var(--line); }
.btn-danger { background: transparent; color: var(--danger); border: 1px solid currentColor; }

/* tags */
.tags { display: flex; flex-wrap: wrap; gap: 6px; }
.tag {
  display: inline-block; background: var(--accent-soft); color: var(--accent); border: 0;
  border-radius: 999px; padding: 3px 11px; font-size: .88rem; text-decoration: none; font-family: inherit; cursor: pointer;
}
.tag:hover, .tag.active { background: var(--accent); color: var(--accent-ink); }
.tag small { opacity: .7; }

/* forms */
input[type=text], input[type=password], input[type=search], input[type=datetime-local], textarea {
  width: 100%; font: inherit; color: var(--ink); background: var(--bg);
  border: 1px solid var(--line); border-radius: 10px; padding: 11px 14px; margin-top: 6px;
}
input:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: 1px; border-color: transparent; }
textarea { resize: vertical; min-height: 220px; line-height: 1.6; }
label, .field { display: block; margin-bottom: 22px; font-weight: 600; }
.label { display: block; }
label small, .label small { font-weight: 400; color: var(--muted); }
label.big input { font-size: 1.3rem; font-family: var(--serif); }
.sublabel { font-weight: 400; color: var(--muted); margin: 14px 0 8px; font-size: .95rem; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 26px; box-shadow: var(--shadow); }
.login { margin-top: 48px; }
.login h1 { margin-top: 0; }
.login .btn { width: 100%; }
.hint { text-align: center; font-size: .95rem; }
.notice { background: var(--ok-bg); color: var(--ok-ink); border-radius: 10px; padding: 12px 16px; margin: 16px 0; }
.notice.error { background: var(--err-bg); color: var(--err-ink); }
.empty { text-align: center; color: var(--muted); padding: 40px 0; }
.filtering { color: var(--muted); }


/* ===== library ===== */
.site-footer a { color: var(--muted); }
.back { margin: 22px 0 10px; } .back a { text-decoration: none; }
.page-title { margin: 28px 0 14px; }
.finder { margin: 24px 0 14px; padding: 18px; }
.search-row { display: flex; gap: 10px; }
.search-row input { margin-top: 0; font-size: 1.1rem; }
.filters { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 12px; margin-top: 14px; }
.filters label { margin: 0; font-size: .85rem; color: var(--muted); }
@media (max-width: 760px) { .filters { grid-template-columns: 1fr 1fr; } }
select { width: 100%; font: inherit; font-size: 1rem; color: var(--ink); background: var(--bg); border: 1px solid var(--line); border-radius: 10px; padding: 9px 10px; margin-top: 4px; }
.results-bar { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; color: var(--muted); margin: 6px 2px 16px; }
.view-toggle a { color: var(--muted); text-decoration: none; padding: 5px 10px; border-radius: 8px; }
.view-toggle a.on { background: var(--accent-soft); color: var(--accent); font-weight: 600; }

.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 22px 18px; }
@media (max-width: 480px) { .grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px 12px; } }
.book { text-decoration: none; color: var(--ink); display: flex; flex-direction: column; gap: 2px; }
.cover { position: relative; aspect-ratio: 2 / 3; border-radius: 6px; overflow: hidden; background: var(--line); box-shadow: 0 2px 8px var(--cover-shadow); margin-bottom: 8px; transition: transform .2s; }
.book:hover .cover { transform: translateY(-3px); }
.cover img { width: 100%; height: 100%; object-fit: cover; }
.nocover { display: grid; place-items: center; height: 100%; padding: 12px; text-align: center; font-family: var(--serif); font-size: .95rem; color: #fff; background: linear-gradient(170deg, var(--forest), var(--forest-deep)); }
.nocover.big { height: auto; width: 100%; aspect-ratio: 2/3; font-size: 1.4rem; border-radius: 8px; }
.lent { position: absolute; top: 8px; left: 8px; background: var(--brass); color: #fff; font-size: .72rem; font-weight: 600; padding: 2px 8px; border-radius: 999px; }
.lent-inline { background: var(--brass); color: #fff; font-size: .72rem; padding: 1px 7px; border-radius: 999px; }
.book .t { font-weight: 600; line-height: 1.25; }
.book .a { color: var(--muted); font-size: .9rem; line-height: 1.3; }
.book .shelf { color: var(--leaf); font-size: .82rem; margin-top: 2px; }

.table-wrap { padding: 0; overflow-x: auto; }
table.list { width: 100%; border-collapse: collapse; font-size: .98rem; }
.list th { text-align: left; font-size: .8rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); padding: 12px; border-bottom: 1px solid var(--line); }
.list td { padding: 8px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.list tr:hover td { background: var(--accent-soft); cursor: pointer; }
.list td a { color: var(--ink); font-weight: 600; text-decoration: none; }
.list .mini { width: 46px; } .list .mini img { width: 34px; height: 50px; object-fit: cover; border-radius: 3px; }
@media (max-width: 640px) { .list th:nth-child(4), .list td:nth-child(4) { display: none; } }

.detail { display: grid; grid-template-columns: 260px 1fr; gap: 32px; }
@media (max-width: 680px) { .detail { grid-template-columns: 1fr; } .detail-cover { max-width: 220px; margin: 0 auto; } }
.detail-cover img { width: 100%; border-radius: 8px; box-shadow: 0 4px 16px var(--cover-shadow); }
.detail h1 { margin: 0 0 4px; font-size: clamp(1.7rem, 4.5vw, 2.4rem); }
.subtitle { color: var(--muted); margin: 0 0 6px; font-size: 1.1rem; }
.by { margin: 0 0 18px; font-size: 1.1rem; }
.where { display: flex; flex-direction: column; background: var(--ok-bg); color: var(--ok-ink); border-radius: 12px; padding: 12px 16px; text-decoration: none; margin-bottom: 14px; }
.where span { font-size: .85rem; } .where strong { font-size: 1.25rem; }
.lent-box { background: var(--warn-bg); color: var(--warn-ink); border-radius: 12px; padding: 10px 16px; }
.chips-row { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 14px; }
.facts { display: grid; grid-template-columns: max-content 1fr; gap: 4px 18px; margin: 10px 0 16px; }
.facts dt { color: var(--muted); } .facts dd { margin: 0; }
.notes { background: var(--bg); border-radius: 10px; padding: 12px 16px; margin-bottom: 16px; }
.actions { display: flex; gap: 12px; flex-wrap: wrap; }

/* editor */
body.editor-page main { max-width: 820px; }
.scan-box { text-align: center; background: var(--accent-soft); border-radius: 12px; padding: 20px 16px; margin-bottom: 22px; }
.scan-box .btn { width: 100%; max-width: 360px; }
.scan-box .tip { margin: 10px 0 0; }
.tip { color: var(--muted); font-size: .9rem; font-weight: 400; }
.linkish { display: inline; margin: 0; font-weight: 400; color: var(--accent); cursor: pointer; }
#scanner { margin-top: 14px; } #reader { max-width: 480px; margin: 0 auto 10px; border-radius: 10px; overflow: hidden; }
#reader video { border-radius: 10px; }
.isbn-row { display: flex; gap: 10px; align-items: flex-end; }
.isbn-row label { flex: 1; margin-bottom: 0; } .isbn-row .btn { margin-bottom: 1px; height: 47px; }
.lookup-msg { margin: 12px 0 0; padding: 10px 14px; border-radius: 10px; background: var(--bg); font-size: .95rem; }
.lookup-msg.ok { background: var(--ok-bg); color: var(--ok-ink); } .lookup-msg.error { background: var(--err-bg); color: var(--err-ink); } .lookup-msg.warn { background: var(--warn-bg); color: var(--warn-ink); }
.two-col { display: grid; grid-template-columns: 170px 1fr; gap: 24px; margin-top: 22px; }
@media (max-width: 600px) { .two-col { grid-template-columns: 1fr; } .cover-field { display: flex; flex-direction: column; align-items: center; } }
.cover-preview { width: 150px; aspect-ratio: 2/3; border: 2px dashed var(--line); border-radius: 8px; display: grid; place-items: center; overflow: hidden; color: var(--muted); font-weight: 400; font-size: .9rem; margin: 8px 0 10px; }
.cover-preview img { width: 100%; height: 100%; object-fit: cover; }
.file-btn { margin: 0 0 8px; font-weight: 600; }
.check { display: flex; gap: 6px; align-items: center; font-weight: 400; font-size: .9rem; }
.suggest { margin: -12px 0 20px; font-weight: 400; font-size: .88rem; color: var(--muted); display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.shelf-field input { font-size: 1.1rem; }
input.filled { background: var(--ok-bg); transition: background 1.2s; }
details.more { border-top: 1px solid var(--line); padding-top: 14px; margin-bottom: 20px; }
details.more summary { cursor: pointer; font-weight: 600; margin-bottom: 14px; }
.grid-fields { display: grid; grid-template-columns: 2fr 1fr 1fr 2fr; gap: 0 12px; }
@media (max-width: 600px) { .grid-fields { grid-template-columns: 1fr 1fr; } }
.sticky-actions { position: sticky; bottom: 0; background: var(--card); padding: 12px 0 4px; }
.danger { margin-top: 24px; text-align: right; }

/* shelves */
.shelf-list { display: grid; gap: 16px; }
.shelf-card { padding: 18px 20px; }
.shelf-head { display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap; }
.shelf-head h2 { margin: 0; font-size: 1.25rem; }
.shelf-head .count { color: var(--muted); }
.small-link { margin-left: auto; font-weight: 600; text-decoration: none; }
.spines { display: flex; gap: 8px; overflow-x: auto; padding: 14px 0 6px; }
.spine { flex: none; width: 56px; aspect-ratio: 2/3; border-radius: 4px; overflow: hidden; background: linear-gradient(170deg, var(--forest), var(--forest-deep)); color: #fff; font-size: .6rem; text-decoration: none; display: grid; place-items: center; text-align: center; }
.spine img { width: 100%; height: 100%; object-fit: cover; }
.spine span { padding: 4px; overflow: hidden; max-height: 100%; }
.spine.more { background: var(--accent-soft); color: var(--accent); font-size: 1rem; font-weight: 600; }
.rename summary { cursor: pointer; color: var(--muted); font-size: .9rem; }
.rename form { display: flex; gap: 8px; align-items: center; margin-top: 8px; }
.rename input { margin: 0; }

/* ===== accounts & loans ===== */
.badge { display: inline-block; min-width: 20px; padding: 0 6px; border-radius: 999px; background: var(--brass); color: #fff; font-size: .75rem; font-weight: 600; text-align: center; line-height: 20px; }
.account-menu { position: relative; }
.account-menu summary { cursor: pointer; list-style: none; color: var(--muted); }
.account-menu summary::-webkit-details-marker { display: none; }
.account-menu .menu { position: absolute; right: 0; top: calc(100% + 10px); background: var(--card); border: 1px solid var(--line); border-radius: 12px; box-shadow: 0 8px 28px rgba(0,0,0,.12); padding: 6px; min-width: 210px; display: flex; flex-direction: column; z-index: 20; }
.account-menu .menu a { padding: 9px 12px; border-radius: 8px; color: var(--ink) !important; }
.account-menu .menu a:hover { background: var(--accent-soft); }
@media (max-width: 560px) { .site-header nav { gap: 12px; font-size: .9rem; } }

.loan-box { display: flex; justify-content: space-between; align-items: center; gap: 14px; flex-wrap: wrap; background: var(--warn-bg); color: var(--warn-ink); border-radius: 12px; padding: 14px 16px; margin-bottom: 8px; }
.loan-box.overdue { background: var(--err-bg); color: var(--err-ink); }
.loan-main { display: flex; flex-direction: column; }
.loan-main > span:first-child { font-size: .85rem; }
.loan-main strong { font-size: 1.3rem; }
.loan-meta { font-size: .9rem; } .loan-note { font-size: .9rem; font-style: italic; margin-top: 2px; }
.home-shelf { margin: 0 0 12px; font-size: .95rem; color: var(--muted); }
details.lend { margin: 4px 0 18px; }
details.lend summary { list-style: none; display: inline-flex; }
details.lend summary::-webkit-details-marker { display: none; }
details.lend[open] summary { margin-bottom: 12px; }
.lend-form { background: var(--bg); border: 1px solid var(--line); border-radius: 12px; padding: 16px; }
.lend-form label { margin-bottom: 14px; }
.quick-due { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; font-size: .88rem; color: var(--muted); margin: -6px 0 14px; }
.grid-fields.two { grid-template-columns: 1fr 1fr; }
@media (max-width: 520px) { .grid-fields.two { grid-template-columns: 1fr; } }
input[type=date] { width: 100%; font: inherit; color: var(--ink); background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; margin-top: 6px; }
.history { margin: 0 0 18px; } .history summary { cursor: pointer; color: var(--muted); }
.history ul { margin: 8px 0 0; padding-left: 20px; }
.lent.od, .od-text { color: var(--danger); } .lent.od { background: var(--danger); color: #fff; }
.lent { max-width: calc(100% - 16px); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.page-title.small { font-size: 1.2rem; margin-top: 34px; }
.person-title { font-size: 1.15rem; margin: 22px 0 8px; }
.loan-list { list-style: none; padding: 0; margin: 0 0 10px; display: grid; gap: 10px; }
.loan-list li { display: flex; align-items: center; gap: 14px; padding: 10px 14px 10px 10px; }
.loan-list li.overdue { border-color: var(--err-line); }
.loan-list .thumb { width: 48px; height: 72px; border-radius: 4px; overflow: hidden; flex: none; background: var(--bg); display: grid; place-items: center; font-size: 1.4rem; }
.loan-list .thumb img { width: 100%; height: 100%; object-fit: cover; }
.loan-list .info { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.loan-list .t { font-weight: 600; color: var(--ink); text-decoration: none; }
.loan-list .m { font-size: .9rem; color: var(--muted); }
.returned { color: var(--muted); padding-left: 20px; }

.people { display: grid; gap: 10px; margin: 18px 0 28px; }
.person { padding: 14px 18px; }
.person-head { display: flex; gap: 12px; align-items: center; }
.avatar { width: 42px; height: 42px; border-radius: 50%; background: var(--accent-soft); color: var(--accent); display: grid; place-items: center; font-weight: 600; font-size: 1.1rem; flex: none; }
.you { background: var(--accent-soft); color: var(--accent); font-size: .75rem; padding: 1px 8px; border-radius: 999px; }
.person details { margin-top: 10px; } .person summary { cursor: pointer; color: var(--muted); font-size: .9rem; }
.inline-form { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-top: 10px; }
.inline-form input, .inline-form select { margin: 0; width: auto; flex: 1; min-width: 160px; }
#add-person h2 { margin-top: 0; }

/* ===== research ===== */
.layout { grid-template-columns: 240px minmax(0, 1fr); gap: 28px; }
.filters-side { position: sticky; top: 80px; max-height: calc(100vh - 100px); overflow-y: auto; }
#filter-toggle { display: none; width: 100%; margin-bottom: 10px; }
@media (max-width: 820px) {
  .layout { grid-template-columns: minmax(0, 1fr); }
  .filters-side { position: static; max-height: none; }
  #filter-toggle { display: inline-flex; }
  .filter-body { display: none; } body.show-filters .filter-body { display: block; }
}
.fgroup h3 { font-size: .95rem; margin: 18px 0 6px; }
.fopt { display: flex; justify-content: space-between; gap: 8px; padding: 5px 10px; border-radius: 8px; color: var(--ink); text-decoration: none; font-size: .93rem; }
.fopt:hover { background: var(--accent-soft); }
.fopt.on { background: var(--accent); color: var(--accent-ink); }
.fopt small { color: inherit; opacity: .6; }
.star-opt { border: 1px solid var(--line); margin-bottom: 4px; }
.active-filters { display: flex; flex-wrap: wrap; gap: 6px; margin: -4px 0 14px; }

/* facet colours */
.t-era     { --tc: #8a5a14; --tb: #f6ecd9; }
.t-culture { --tc: #2f6a55; --tb: #e2f0ea; }
.t-type    { --tc: #7a3e8a; --tb: #f1e6f4; }
.t-source  { --tc: #2c5a8f; --tb: #e3edf8; }
.t-project { --tc: #8f2f3c; --tb: #f8e4e7; }
@media (prefers-color-scheme: dark) {
  .t-era { --tc: #e8c27e; --tb: #3a2f1d; } .t-culture { --tc: #9fd6bf; --tb: #1f3a30; } .t-type { --tc: #d9b1e4; --tb: #36263b; }
  .t-source { --tc: #a7c8ef; --tb: #1f2e40; } .t-project { --tc: #f0a7b1; --tb: #3e2328; }
}
.tag[class*="t-"] { background: var(--tb); color: var(--tc); }
.tag[class*="t-"]:hover { background: var(--tc); color: var(--card); }

.clip { display: grid; grid-template-columns: 150px minmax(0, 1fr); gap: 20px; padding: 18px; margin-bottom: 16px; scroll-margin-top: 90px; }
.clip:not(:has(.clip-img)) { grid-template-columns: 1fr; }
.clip.highlight { outline: 3px solid var(--accent); outline-offset: 2px; }
@media (max-width: 560px) { .clip { grid-template-columns: 1fr; } .clip-img { max-height: 200px; } }
.clip-img { display: block; border-radius: 8px; overflow: hidden; background: var(--bg); align-self: start; }
.clip-img img { width: 100%; height: 100%; max-height: 220px; object-fit: cover; }
.clip h2 { font-size: 1.25rem; margin: 0 0 4px; }
.clip h2 a { color: var(--ink); text-decoration: none; } .clip h2 a:hover { color: var(--accent); }
.clip .meta { color: var(--muted); font-size: .88rem; margin: 0 0 10px; }
.clip .tags { display: flex; flex-wrap: wrap; gap: 5px; margin-bottom: 10px; }
.clip .tag { font-size: .8rem; padding: 2px 9px; }
blockquote { margin: 8px 0 10px; padding: 8px 14px; border-left: 3px solid var(--accent); background: var(--bg); border-radius: 0 8px 8px 0; font-style: italic; font-size: .97rem; }
.note { margin: 6px 0 10px; font-size: .97rem; }
.clip-actions { display: flex; flex-wrap: wrap; gap: 6px 18px; align-items: flex-start; font-size: .9rem; }
.clip-actions a, .cite summary { color: var(--muted); text-decoration: none; cursor: pointer; }
.clip-actions a:hover, .cite summary:hover { color: var(--accent); }
.cite { flex-basis: 100%; } .cite summary { display: inline; list-style: none; } .cite summary::-webkit-details-marker { display: none; }
.cite[open] { margin-top: 4px; } .cite textarea { min-height: 0; font-size: .9rem; margin: 8px 0; }
.clip-actions:has(.cite:not([open])) .cite { flex-basis: auto; }

/* clip form */
body.popup main { max-width: 640px; padding-top: 14px; }
body.clip-page:not(.popup) main { max-width: 780px; }
.clip-h { font-size: 1.5rem; margin: 6px 0 12px; }
body.popup .card.editor { padding: 18px; }
.clip-top { display: grid; grid-template-columns: 110px minmax(0, 1fr); gap: 16px; margin: 10px 0 8px; }
.clip-thumb { width: 110px; aspect-ratio: 1; border-radius: 8px; overflow: hidden; background: var(--bg); border: 1px solid var(--line); }
.clip-thumb.none, .clip-thumb:empty { display: none; }
.clip-top:has(.clip-thumb:empty), .clip-top:has(.clip-thumb.none) { grid-template-columns: 1fr; }
.clip-thumb img { width: 100%; height: 100%; object-fit: cover; }
.clip-fields label { margin-bottom: 6px; }
.url-line { margin: 0 0 6px; font-size: .82rem; word-break: break-all; } .url-line a { color: var(--muted); }
.facet { margin-bottom: 16px; }
.facet .label { font-weight: 600; margin-bottom: 6px; }
.pick { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.opt { border: 1px solid var(--line); background: var(--card); color: var(--ink); border-radius: 999px; padding: 5px 12px; font: inherit; font-size: .88rem; cursor: pointer; }
.opt:hover { border-color: var(--accent); }
.opt.on { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.opt.on::before { content: '✓ '; }
.new-tag { width: 150px !important; margin: 0 !important; padding: 5px 12px !important; border-radius: 999px !important; font-size: .88rem !important; }
.star { margin: 4px 0 14px; font-weight: 600; }
.saved { text-align: center; margin-top: 40px; }
.big-check { width: 72px; height: 72px; margin: 0 auto 6px; border-radius: 50%; background: var(--sk-green-ink); color: #fff; font-size: 2.6rem; display: grid; place-items: center; }
.saved h1 { margin: 6px 0; }

/* setup */
.setup { margin-bottom: 20px; }
.setup h2 { margin-top: 0; font-size: 1.35rem; } .setup h2 small { font-family: "Source Sans 3", sans-serif; font-weight: 400; color: var(--muted); font-size: .9rem; }
.steps { padding-left: 22px; } .steps li { margin-bottom: 10px; }
kbd { background: var(--bg); border: 1px solid var(--line); border-bottom-width: 2px; border-radius: 5px; padding: 0 6px; font: inherit; font-size: .85rem; }
.bm-wrap { margin: 12px 0 4px; }
.bookmarklet { display: inline-block; background: var(--accent); color: var(--accent-ink); padding: 12px 22px; border-radius: 999px; font-weight: 600; text-decoration: none; cursor: grab; box-shadow: 0 3px 10px rgba(181,83,47,.35); }
.copy-row { display: flex; gap: 8px; margin: 8px 0; } .copy-row input { margin: 0; font-size: .9rem; }
.tip-box summary { cursor: pointer; color: var(--muted); }
.tip-box textarea { min-height: 0; font-size: .8rem; font-family: ui-monospace, monospace; }
.share-icon { display: inline-block; border: 1px solid currentColor; border-radius: 4px; padding: 0 4px; font-size: .8rem; }
.notice.warn { background: var(--warn-bg); color: var(--warn-ink); }
.note.private { background: var(--warn-bg); color: var(--warn-ink); border-radius: 8px; padding: 6px 10px; }
.private-field textarea { border-style: dashed; }

/* record page */
body.view-page main { max-width: 1000px; }
.view-nav { display: flex; justify-content: space-between; margin: 22px 0 12px; }
.view-nav a { text-decoration: none; font-weight: 600; margin-left: 16px; } .view-nav > a { margin-left: 0; }
.record { display: grid; grid-template-columns: minmax(0, 5fr) minmax(0, 6fr); gap: 28px; align-items: start; }
.record:not(:has(.record-img)) { grid-template-columns: 1fr; }
@media (max-width: 760px) { .record { grid-template-columns: 1fr; } }
.record-img { display: block; border-radius: 10px; overflow: hidden; background: var(--bg); position: sticky; top: 80px; }
@media (max-width: 760px) { .record-img { position: static; } }
.record-img img { width: 100%; height: auto; }
.record h1 { margin: 0 0 4px; font-size: clamp(1.6rem, 4vw, 2.2rem); }
.record .meta { color: var(--muted); margin: 0 0 16px; }
.record h2 { font-size: 1.05rem; margin: 22px 0 6px; }
.record-buttons { display: flex; flex-wrap: wrap; gap: 10px; }
.record .url-line { margin: 8px 0 18px; color: var(--muted); }
.record-facet { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-bottom: 8px; }
.record-facet > span { width: 150px; color: var(--muted); font-size: .9rem; }
@media (max-width: 480px) { .record-facet > span { width: 100%; } }
.record textarea { min-height: 0; font-size: .92rem; margin-bottom: 8px; }
.clip-actions .visit { color: var(--accent); font-weight: 600; }

/* =====================================================================
   Sunny Knoll theme — light
   ===================================================================== */
body { font: 17px/1.65 var(--sans); }
h1, h2, h3 { font-family: var(--serif); font-weight: 400; letter-spacing: .01em; }
a { color: var(--accent); text-decoration-color: var(--sk-hill); text-underline-offset: 3px; }
a:hover { color: var(--ink); }

/* header: light, with the deep green wordmark on wide screens and the badge alone on phones */
.site-header { background: var(--card); border-bottom: 1px solid var(--line); }
.site-header .wrap { min-height: 72px; }
.brand { display: flex; align-items: center; gap: 14px; color: var(--ink); text-decoration: none; }
.brand img { display: block; height: auto; }
.brand-wordmark { width: 160px; }
.brand-badge { width: 40px; display: none !important; }
.brand-section { font-family: var(--serif); font-style: italic; font-size: 1.05rem; color: var(--muted);
  padding-left: 14px; border-left: 1px solid var(--line); line-height: 1.6; }
@media (max-width: 600px) {
  .brand-wordmark { display: none !important; }
  .brand-badge { display: block !important; }
  .brand-section { padding-left: 0; border-left: 0; }
}
.site-header nav { gap: 20px; }
.site-header nav a:not(.btn), .account-menu summary { color: var(--muted); font-size: .92rem; white-space: nowrap; }
.site-header nav a:not(.btn):hover, .account-menu summary:hover { color: var(--ink); }
.site-header .btn { white-space: nowrap; }
@media (max-width: 600px) {
  .site-header .wrap { padding-top: 10px; padding-bottom: 10px; row-gap: 8px; min-height: 0; }
  .site-header nav { width: 100%; justify-content: space-between; gap: 10px; font-size: .88rem; }
}

/* buttons: the sun is the main action; everything else is quiet */
.btn { background: var(--sk-sun); color: var(--sk-green); border-radius: var(--radius-ctl); letter-spacing: .02em; }
.btn-ghost { background: transparent; color: var(--ink); border: 1px solid var(--line); }
.btn-ghost:hover { background: var(--accent-soft); filter: none; }
.btn-danger { background: transparent; color: var(--danger); border: 1px solid currentColor; }
.badge { background: var(--sk-sun); color: var(--sk-green); }

/* fields */
input[type=text], input[type=password], input[type=search], input[type=datetime-local], input[type=date], input[type=url], textarea, select {
  border-radius: var(--radius-ctl); background: var(--card); }
input:focus, textarea:focus, select:focus { outline: 2px solid var(--sk-hill-dark); outline-offset: 1px; border-color: transparent; }
@media (prefers-color-scheme: dark) { input:focus, textarea:focus, select:focus { outline-color: var(--sk-sun); } }

/* square edges; softness comes from the hills */
.card, .post, .notice, .account-menu .menu { border-radius: 0; }
.tag { border-radius: 1px; }
.notice { background: var(--ok-bg); color: var(--ok-ink); }
.notice.error { background: var(--err-bg); color: var(--err-ink); }
.notice.warn { background: var(--warn-bg); color: var(--warn-ink); }

/* hero: the sun over the title */
.hero h1 { font-weight: 400; letter-spacing: .02em; }
.hero h1::before { content: ""; display: block; width: 34px; height: 34px; margin: 0 auto 22px; border-radius: 50%;
  background: var(--sk-sun); box-shadow: 0 0 0 10px rgba(232, 163, 61, .15), 0 0 0 22px rgba(232, 163, 61, .07); }
.hero p { font-family: var(--serif); font-style: italic; }

.empty-badge { width: 96px; height: 96px; margin: 0 auto 10px; display: block; }

/* hills along the bottom, running into the footer */
.hills { display: block; width: 100%; height: 72px; margin-top: 64px; color: var(--footer); }
@media (max-width: 600px) { .hills { height: 44px; } }
.site-footer { background: var(--footer); color: var(--footer-ink); padding: 22px 0 34px; margin-top: -1px; font-size: .88rem; }
.site-footer a { color: var(--footer-ink); text-decoration-color: var(--sk-sun); }
.site-nav { display: flex; justify-content: center; flex-wrap: wrap; gap: 6px 22px; margin-bottom: 8px; font-family: var(--serif); font-size: 1rem; }
.site-nav a { text-decoration: none; }
.site-nav a:hover, .site-nav a[aria-current] { text-decoration: underline; }
.site-footer small { opacity: .85; }

/* favourites: a plain star in sun orange */
.fav { color: var(--sk-sun); font-family: var(--sans); }
@media (prefers-color-scheme: light) { .fav { color: #c27d16; } }

/* =====================================================================
   Research — greens as a counterpoint to the cream and the sun
   ===================================================================== */
body { overflow-x: clip; }

/* the search sits in a full-width cream band (no green up top) */
.finder.card { background: var(--card); border: 0; box-shadow: inset 0 -1px 0 var(--line);
  margin: 0 calc(50% - 50vw) 0; padding: 30px max(16px, calc(50vw - 524px)) 34px; }
.finder-head h1 { font-size: clamp(1.9rem, 4.5vw, 2.6rem); line-height: 1.15; letter-spacing: .015em; color: var(--ink); margin: 0 0 4px; }
.finder-head p { font-family: var(--serif); font-style: italic; color: var(--muted); margin: 0; font-size: 1.05rem; }
.finder .search-row { margin-top: 18px; }
.finder .search-row input { background: var(--bg); color: var(--ink); border-color: var(--line); }
.finder input:focus { outline-color: var(--sk-hill-dark); }
.layout { margin-top: 28px; }

/* sidebar: green headings, green selected state */
.fgroup h3 { font-family: var(--sans); font-size: .72rem; font-weight: 600; text-transform: uppercase; letter-spacing: .12em;
  color: var(--leaf); margin: 22px 0 6px; padding-bottom: 6px; border-bottom: 1px solid var(--sk-hill); }
.fopt { border-radius: var(--radius-ctl); }
.fopt:hover { background: var(--sk-on-hill); }
.fopt.on { background: var(--sk-green); color: var(--sk-cream); }
.star-opt { background: var(--sk-on-hill); border: 0; }
.star-opt.on { background: var(--sk-green); color: var(--sk-cream); }
.view-toggle a.on { background: var(--sk-green-ink); color: var(--sk-cream); border-radius: var(--radius-ctl); }

/* clips: a sage rule across the top of each card */
.clip { border-top: 3px solid var(--sk-hill); }
.clip h2 a:hover { color: var(--leaf); }

/* tag groups: a family of greens, with the sun as the one warm note */
.t-era     { --tb: #fbeed6; --tc: #7a5212; }              /* sun tint */
.t-culture { --tb: var(--sk-on-hill); --tc: var(--sk-green); }   /* palest green */
.t-type    { --tb: var(--sk-hill); --tc: var(--sk-green); }      /* sage */
.t-source  { --tb: transparent; --tc: var(--sk-green-ink); }     /* outlined */
.t-project { --tb: var(--sk-green); --tc: var(--sk-cream); }     /* deep green */
.tag.t-source { box-shadow: inset 0 0 0 1px var(--sk-hill-dark); }
.tag[class*="t-"]:hover { background: var(--sk-green-ink); color: var(--sk-cream); box-shadow: none; }

@media (prefers-color-scheme: dark) {
  .finder.card { background: var(--card); box-shadow: inset 0 -1px 0 var(--line); }
  .finder input:focus { outline-color: var(--sk-sun); }
  .fgroup h3 { border-bottom-color: #3a463a; }
  .fopt:hover, .star-opt { background: #2f3a2f; }
  .fopt.on, .star-opt.on { background: var(--sk-hill); color: #1e261e; }
  .view-toggle a.on { background: var(--sk-hill); color: #1e261e; }
  .clip { border-top-color: var(--sk-hill-dark); }
  .t-era     { --tb: #3a3020; --tc: #f1dca8; }
  .t-culture { --tb: #2f3a2f; --tc: #d6dfd0; }
  .t-type    { --tb: var(--sk-hill); --tc: #1e261e; }
  .t-source  { --tb: transparent; --tc: #a9c49a; }
  .t-project { --tb: var(--sk-on-hill); --tc: #2f3a2f; }
  .tag[class*="t-"]:hover { background: var(--sk-hill); color: #1e261e; }
}
@media (max-width: 600px) { .site-header nav { justify-content: flex-end; } .site-header nav:has(> :nth-child(2)) { justify-content: space-between; } }

/* =====================================================================
   Attached files (PDFs, photos, documents)
   ===================================================================== */
fieldset.attach { border: 0; border-top: 1px solid var(--line); padding: 18px 0 4px; margin: 6px 0 18px; min-width: 0; }
fieldset.attach legend { font-weight: 600; padding: 0 8px 0 0; }
fieldset.attach legend small { font-weight: 400; color: var(--muted); }

/* the type badge: a small square tag instead of an icon */
.ftype { display: inline-grid; place-items: center; min-width: 40px; height: 22px; padding: 0 5px; font: 600 .66rem/1 var(--sans);
  letter-spacing: .06em; border-radius: 1px; background: var(--sk-on-hill); color: var(--sk-green); box-shadow: inset 0 0 0 1px var(--sk-hill); flex: none; }
.ftype-pdf { background: var(--sk-green); color: var(--sk-cream); box-shadow: none; }
.ftype-jpg, .ftype-png, .ftype-gif, .ftype-webp { background: #fbeed6; color: #7a5212; box-shadow: none; }

.file-list { list-style: none; padding: 0; margin: 4px 0 16px; display: grid; gap: 8px; }
.file-list li { display: flex; align-items: center; gap: 12px; padding: 10px 12px; background: var(--card); border: 1px solid var(--line); border-top: 2px solid var(--sk-hill); }
.file-list .finfo { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.file-list .finfo a { color: var(--ink); font-weight: 600; text-decoration: none; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-list .finfo a:hover { color: var(--leaf); text-decoration: underline; }
.file-list .finfo small { color: var(--muted); font-size: .82rem; }
.file-list .check { margin: 0; font-size: .88rem; white-space: nowrap; }
.file-list .remove { color: var(--danger); }
@media (max-width: 560px) { .file-list.editing li { flex-wrap: wrap; } .file-list.editing .finfo { flex-basis: calc(100% - 60px); } }

.file-drop { position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; text-align: center;
  padding: 22px 16px; margin: 0 0 10px; border: 1px dashed var(--sk-hill-dark); background: var(--sk-on-hill); color: var(--ink); cursor: pointer; font-weight: 400; }
.file-drop input[type=file] { position: absolute; inset: 0; opacity: 0; cursor: pointer; width: 100%; }
.file-drop-text strong { color: var(--leaf); text-decoration: underline; text-decoration-color: var(--sk-hill); text-underline-offset: 3px; }
.file-drop-names { font-size: .88rem; color: var(--muted); word-break: break-word; }
.file-drop.drag, .file-drop:focus-within { border-style: solid; outline: 2px solid var(--sk-hill-dark); outline-offset: 1px; }
.file-drop.has-files { border-style: solid; }

.file-photos { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 8px; margin: 4px 0 18px; }
.file-photos a { position: relative; display: block; aspect-ratio: 1; overflow: hidden; background: var(--line); }
.file-photos img { width: 100%; height: 100%; object-fit: cover; transition: transform .25s; }
.file-photos a:hover img { transform: scale(1.03); }
.private-chip { position: absolute; left: 6px; top: 6px; background: var(--sk-green); color: var(--sk-cream); font-size: .7rem; font-weight: 600; letter-spacing: .04em; padding: 2px 7px; }

.clip-actions .file-link { display: inline-flex; align-items: center; gap: 6px; color: var(--ink); text-decoration: none; }
.clip-actions .file-link:hover { color: var(--leaf); text-decoration: underline; }
.clip-actions .file-link .ftype { height: 18px; min-width: 34px; font-size: .6rem; }

@media (prefers-color-scheme: dark) {
  .ftype { background: #2f3a2f; color: #d6dfd0; box-shadow: inset 0 0 0 1px #3a463a; }
  .ftype-pdf { background: var(--sk-hill); color: #1e261e; box-shadow: none; }
  .ftype-jpg, .ftype-png, .ftype-gif, .ftype-webp { background: #3a3020; color: #f1dca8; box-shadow: none; }
  .file-list li { border-top-color: var(--sk-hill-dark); }
  .file-drop { background: #1e261e; border-color: var(--sk-hill-dark); }
  .file-drop.drag, .file-drop:focus-within { outline-color: var(--sk-sun); }
}
