* { box-sizing: border-box; }

/* Elements styled with display: flex would otherwise ignore the hidden attribute. */
[hidden] { display: none !important; }

/* The same page runs in the extension and on the website (where web.js adds the "web" class). */
html:not(.web) .web-only, html.web .ext-only { display: none !important; }

html, body { margin: 0; }

/* The book title font (Bricolage Grotesque ExtraBold, SIL Open Font License: fonts/OFL.txt). */
@font-face {
  font-family: "Bricolage";
  src: url("fonts/bricolage-800.woff2") format("woff2");
  font-weight: 800;
  font-display: swap;
}

/* Clean and minimal: one neutral ink color, one soft gray for secondary text, and the Stampy
   orange only for small accents. */
:root {
  --ink: #1f1d1a;
  --muted: #8b857c;
  --line: rgba(31, 29, 26, .1);
  --hover: rgba(31, 29, 26, .05);
  --accent: #f26a3d;
  --panel: #fff;
}

body {
  min-height: 100vh;
  background: var(--book-bg, #f3ead8);
  color: var(--ink);
  font: 14px/1.45 -apple-system, BlinkMacSystemFont, "Inter", "Segoe UI", system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
}

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

/* ---------- sign in ---------- */

.signin {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 24px;
  padding: 16px;
}

.signin-logo { width: min(250px, 70vw); height: auto; }

.signin form { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; }

.signin input {
  padding: 9px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  min-width: 240px;
}

.primary {
  border: none;
  border-radius: 8px;
  padding: 10px 18px;
  background: var(--ink);
  color: #fff;
  font-weight: 500;
  cursor: pointer;
}

.primary:hover { background: #3a3631; }

/* ---------- top bar: logo | book name ▾ ⚙ · count · status ........ avatar ---------- */

.bar {
  max-width: 1200px;
  margin: 0 auto;
  padding: 20px 32px 0;
  display: flex;
  align-items: center;
  gap: 16px;
  color: var(--ink);
  /* Menus open over the stamps. */
  position: relative;
  z-index: 20;
}

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

.site-logo { flex: none; display: block; line-height: 0; transition: opacity .15s; }
.site-logo:hover { opacity: .75; }
.site-logo img { display: block; height: 36px; width: auto; }

.bar-divider { flex: none; width: 1px; height: 22px; background: var(--line); }

.bar-title { flex: 1; min-width: 0; display: flex; align-items: center; gap: 12px; }
.title-row { display: flex; align-items: center; gap: 2px; min-width: 0; }

.book-switch { min-width: 0; }

.book-switch > summary {
  display: flex;
  align-items: center;
  gap: 4px;
  min-width: 0;
  padding: 5px 6px 5px 10px;
  border-radius: 8px;
  cursor: pointer;
  transition: background .15s;
}

.book-switch > summary:hover, .book-switch[open] > summary { background: var(--hover); }
.book-switch > summary:focus { outline: none; }
.book-switch > summary:focus-visible { box-shadow: 0 0 0 2px var(--accent); }
.book-switch[open] .chevron { transform: rotate(180deg); }

.book-name {
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  font-family: "Bricolage", -apple-system, BlinkMacSystemFont, "Inter", system-ui, sans-serif;
  font-size: 20px;
  font-weight: 800;
  letter-spacing: -.025em;
}

.book-switch .chevron { width: 16px; height: 16px; stroke-width: 2; color: var(--muted); transition: transform .2s; }

/* The list of books. */
.book-list { left: 0; right: auto; width: 280px; max-width: calc(100vw - 24px); transform-origin: top left; }
.book-list-items { display: flex; flex-direction: column; max-height: min(60vh, 420px); overflow-y: auto; }

.menu-items .book-item, .menu-items .book-list-new {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 8px;
  text-align: left;
}

.book-swatch {
  flex: none;
  width: 26px;
  height: 32px;
  border-radius: 4px;
  background: #f3ead8;
  box-shadow: inset 0 0 0 1px var(--line);
}

.book-swatch.new { display: grid; place-items: center; background: none; box-shadow: inset 0 0 0 1px var(--line); color: var(--muted); }
.book-swatch.new .icon { width: 14px; height: 14px; stroke-width: 2; }

.book-item-text { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.book-item-title { font-weight: 500; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.book-item-count { font-size: 12px; color: var(--muted); }

.book-item .check { width: 16px; height: 16px; stroke-width: 2.2; color: var(--ink); visibility: hidden; }
.book-item[aria-current="true"] .check { visibility: visible; }
.menu-items .book-list-new { color: var(--muted); }
.menu-items .book-list-new:hover { color: var(--ink); }

/* Count and status, quiet, after the name. */
.book-meta {
  margin: 0;
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
  color: var(--muted);
  white-space: nowrap;
}

.status-badge { display: inline-flex; align-items: center; gap: 6px; }
.status-badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: .45; }
.status-badge.public { color: #2b8a57; }
.status-badge.public::before { opacity: 1; }

.ghost-button {
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  color: var(--muted);
  cursor: pointer;
  transition: background .15s, color .15s;
}

.ghost-button:hover, .menu[open] > .ghost-button { background: var(--hover); color: var(--ink); }
.ghost-button .icon { width: 18px; height: 18px; }

/* Right side: your avatar. */
.dock { flex: none; display: flex; align-items: center; margin-left: auto; }

.dock-avatar { display: block; border-radius: 50%; cursor: pointer; }

.avatar {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  font-size: 14px;
  font-weight: 600;
  transition: box-shadow .15s;
}

.dock-avatar .avatar { box-shadow: 0 0 0 1px var(--line); }
.dock-avatar:hover .avatar, .menu[open] > .dock-avatar .avatar { box-shadow: 0 0 0 3px var(--hover), 0 0 0 1px var(--line); }

.menu summary::-webkit-details-marker { display: none; }
.menu > summary { list-style: none; }
.menu > summary:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.spacer { flex: 1; }

/* A dark book background: light text in the bar and around the stamps. */
body.dark-bg .bar, body.dark-bg .pager { --ink: #fafaf9; --muted: rgba(250, 250, 249, .55); --line: rgba(250, 250, 249, .16); --hover: rgba(250, 250, 249, .1); }
body.dark-bg .status-badge.public { color: #6fd6a0; }

/* ---------- menus: white cards ---------- */

.menu { position: relative; }

.menu-items {
  --ink: #1f1d1a;
  --muted: #8b857c;
  --line: rgba(31, 29, 26, .1);
  --hover: rgba(31, 29, 26, .05);
  position: absolute;
  right: 0;
  top: calc(100% + 8px);
  z-index: 10;
  min-width: 220px;
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--panel);
  box-shadow: 0 12px 32px rgba(31, 29, 26, .12), 0 2px 6px rgba(31, 29, 26, .06);
  display: flex;
  flex-direction: column;
  color: var(--ink);
  transform-origin: top right;
  animation: menu-in .14s ease-out;
}

@keyframes menu-in {
  from { opacity: 0; transform: translateY(-4px); }
}

.menu-items button, .menu-link {
  border: none;
  background: none;
  text-align: left;
  padding: 8px 10px;
  border-radius: 7px;
  cursor: pointer;
  color: inherit;
  text-decoration: none;
}

.menu-items button:hover, .menu-link:hover { background: var(--hover); }
.menu-items .danger { color: #d0452a; }
.menu-items .danger:hover { background: rgba(208, 69, 42, .08); }

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

.menu-title { margin: 0; padding: 6px 10px 4px; font-size: 12px; font-weight: 500; color: var(--muted); }

.menu-note { margin: 0; padding: 2px 10px 6px; font-size: 12px; color: var(--muted); }

/* ---------- one screen: bar, stamp grid, pager strip ---------- */

#app {
  height: 100vh;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.bar { width: 100%; flex: none; }
#app .error { flex: none; }

/* scrapbook.js sets the column count and fills every slot (stamp or empty) that fits. */
.book {
  flex: 1;
  min-height: 0;
  width: 100%;
  max-width: 1200px;
  margin: 0 auto;
  padding: 32px 32px 0;
  overflow: hidden;
  display: grid;
  grid-template-columns: repeat(auto-fill, 136px);
  grid-auto-rows: 168px;
  gap: 20px;
  justify-content: center;
  align-content: start;
}

.book a { display: block; line-height: 0; }

.book img {
  display: block;
  width: 136px;
  height: 168px;
  filter: drop-shadow(0 1px 1px rgba(60, 40, 20, .25)) drop-shadow(0 4px 6px rgba(60, 40, 20, .18));
}

.slot { display: block; width: 136px; height: 168px; }
.slot path { fill: rgba(59, 47, 34, .06); }

/* Always reserved, so the grid never jumps when pagination appears. */
.pager {
  flex: none;
  height: 64px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  color: var(--muted);
  font-size: 13px;
}

.pager p { margin: 0; }
.pager a { color: var(--ink); }

.pager button {
  width: 30px;
  height: 30px;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: transparent;
  color: var(--ink);
  font-size: 17px;
  line-height: 1;
  cursor: pointer;
  transition: background .15s;
}

.pager button:hover:not(:disabled) { background: var(--hover); }
.pager button:disabled { opacity: .35; cursor: default; }

#page-info { min-width: 56px; text-align: center; font-variant-numeric: tabular-nums; }

@media (max-width: 600px) {
  .book { padding: 20px 16px 0; }
}

#page-nav { display: flex; align-items: center; gap: 12px; }

/* ---------- help popover ---------- */

.help-text {
  width: 300px;
  max-width: calc(100vw - 16px);
  padding: 6px 12px 12px;
  gap: 8px;
  font-size: 13px;
  line-height: 1.5;
  color: #5e5951;
}

.help-text .menu-title { padding: 4px 0 2px; }
.help-text p { margin: 0; }
.help-text b { color: var(--ink); font-weight: 600; }
.help-text a { color: var(--ink); }

.no-shadow .book img { filter: none; }

/* ---------- book settings ---------- */

.settings { left: 0; right: auto; width: 270px; transform-origin: top left; }

.toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 38px;
  padding: 4px 8px 4px 10px;
  border-radius: 7px;
  cursor: pointer;
  user-select: none;
}

.toggle:hover { background: var(--hover); }
.toggle.disabled { opacity: .4; cursor: default; }
.toggle.disabled:hover { background: none; }
.toggle a { margin-left: 6px; font-size: 12px; color: var(--muted); text-decoration: none; }
.toggle a:hover { color: var(--ink); text-decoration: underline; }

/* Checkboxes drawn as switches. */
.toggle input[type="checkbox"] {
  appearance: none;
  -webkit-appearance: none;
  flex: none;
  position: relative;
  width: 32px;
  height: 18px;
  margin: 0;
  border-radius: 999px;
  background: #ddd9d3;
  cursor: inherit;
  transition: background .2s;
}

.toggle input[type="checkbox"]::before {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 2px rgba(0, 0, 0, .2);
  transition: transform .18s ease;
}

.toggle input[type="checkbox"]:checked { background: var(--ink); }
.toggle input[type="checkbox"]:checked::before { transform: translateX(14px); }
.toggle input[type="checkbox"]:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.color-field { display: flex; align-items: center; gap: 8px; }

#bg-color {
  width: 32px;
  height: 20px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: none;
  cursor: pointer;
}
#bg-color::-webkit-color-swatch-wrapper { padding: 0; }
#bg-color::-webkit-color-swatch { border: none; border-radius: 999px; }
#bg-color::-moz-color-swatch { border: none; border-radius: 999px; }

.menu-items .link-button { padding: 0; background: none; color: var(--muted); font-size: 12px; }
.menu-items .link-button:hover { background: none; color: var(--ink); text-decoration: underline; }

body.dark-bg .slot path { fill: rgba(255, 250, 240, .07); }

@media (max-width: 760px) {
  .book-meta { display: none; }
}

@media (max-width: 600px) {
  .bar { padding: 14px 16px 0; gap: 10px; }
  .site-logo, .bar-divider { display: none; }
  .title-row .book-switch > summary { margin-left: -10px; }
}

/* ---------- help button (lower-left corner) ---------- */

.help-fab {
  position: fixed;
  left: 20px;
  bottom: 16px;
  z-index: 20;
}

.help-fab > summary {
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  border: none;
  background: var(--accent);
  color: #fff;
  font-size: 15px;
  font-weight: 600;
  line-height: 1;
  cursor: pointer;
  box-shadow: 0 0 0 1px rgba(31, 29, 26, .1);
  transition: background .15s;
}

.help-fab > summary:hover, .help-fab[open] > summary { background: #e05a2e; }

.help-fab .menu-items {
  top: auto;
  bottom: calc(100% + 8px);
  left: 0;
  right: auto;
  transform-origin: bottom left;
}

@media (max-width: 600px) {
  .help-fab { left: 12px; bottom: 16px; }
}

.avatar.has-picture { background-size: cover; background-position: center; }

/* Account menu: your picture and handle on top; click the picture to change it. */
#more-menu .menu-items { min-width: 250px; }
.me { display: flex; align-items: center; gap: 12px; padding: 8px 8px 6px; }
.menu-items .me-avatar { position: relative; flex: none; padding: 0; border-radius: 50%; }
.menu-items .me-avatar:hover { background: none; }
.me-avatar .avatar { width: 44px; height: 44px; font-size: 17px; box-shadow: 0 0 0 1px var(--line); }
.me-camera {
  position: absolute;
  right: -3px;
  bottom: -3px;
  width: 20px;
  height: 20px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--ink);
  color: #fff;
  box-shadow: 0 0 0 2px var(--panel);
}
.me-camera .icon { width: 11px; height: 11px; stroke-width: 2.2; }
.me-avatar:hover .avatar { box-shadow: 0 0 0 2px var(--ink); }
.me-text { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
#handle { font-weight: 600; font-size: 14px; }
.me-actions { display: flex; gap: 10px; }
.me-actions .link-button { font-size: 12px; }

/* ---------- feedback dialog ---------- */

.help-text .help-feedback { margin: 0 -8px; color: var(--ink); font-weight: 500; }

.dialog {
  width: min(440px, calc(100vw - 32px));
  border: none;
  border-radius: 14px;
  padding: 20px;
  background: var(--panel);
  color: #1f1d1a;
  box-shadow: 0 20px 50px rgba(0, 0, 0, .2);
}
.dialog::backdrop { background: rgba(31, 29, 26, .35); }
.dialog form { display: flex; flex-direction: column; gap: 12px; }
.dialog h2 { margin: 0; font-size: 17px; }
.kind-switch { display: flex; gap: 6px; }
.kind-switch label { flex: 1; display: flex; align-items: center; justify-content: center; gap: 6px; padding: 8px; border: 1px solid rgba(31, 29, 26, .14); border-radius: 8px; cursor: pointer; font-size: 13px; }
.kind-switch label:has(input:checked) { border-color: #1f1d1a; box-shadow: inset 0 0 0 1px #1f1d1a; }
.kind-switch input { accent-color: #1f1d1a; margin: 0; }
.dialog textarea { width: 100%; box-sizing: border-box; resize: vertical; min-height: 120px; padding: 10px 12px; border: 1px solid rgba(31, 29, 26, .14); border-radius: 8px; font: inherit; color: inherit; }
.dialog textarea:focus { outline: 2px solid #1f1d1a; outline-offset: -1px; }
.dialog-note { margin: 0; font-size: 12px; color: #8b857c; }
.dialog .error { margin: 0; color: #c2410c; font-size: 13px; }
.dialog .error:empty { display: none; }
.dialog-actions { display: flex; align-items: center; justify-content: flex-end; gap: 8px; }
.dialog-sent { margin-right: auto; color: #2d6a2d; font-weight: 500; font-size: 13px; }
.secondary { border: 1px solid rgba(31, 29, 26, .14); border-radius: 8px; padding: 9px 16px; background: #fff; cursor: pointer; }
.secondary:hover { background: rgba(31, 29, 26, .05); }
.primary:disabled { opacity: .5; cursor: default; }

.signin-note { margin: 0; font-size: 12px; color: var(--muted); text-align: center; }
.signin-note a { color: inherit; }
.help-text .help-privacy { font-size: 12px; color: var(--muted); }
