/* Pagetta boards (pagetta.app/view/): the phone board viewer. Same look as the
   library and the website: Geist, the Pagetta blue, pale panels. */
@font-face { font-family: 'Geist'; src: url('../fonts/geist-latin.woff2') format('woff2'); font-weight: 100 900; font-display: swap; }

:root {
  --accent: #2D5BE3; --accent-ink: #1E44B8; --accent-soft: #EEF2FD; --on-accent: #fff;
  --bg: #F5F6F8; --panel: #FFFFFF; --ink: #15171C; --ink-2: #2E333D; --muted: #5B6270; --line: #E3E6EB;
  --thumb-bg: #E9ECF1; --note-bg: #FFF8E1; --note-ink: #4A3B00; --error: #B42318; --error-bg: #FEF3F2;
  --shadow: 0 1px 2px rgba(16, 24, 40, .05);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --accent: #7D9BF7; --accent-ink: #A7BCFA; --accent-soft: #1C2747; --on-accent: #0B1020;
    --bg: #111318; --panel: #1A1D24; --ink: #EEF0F4; --ink-2: #CDD2DB; --muted: #9AA2B1; --line: #2C313B;
    --thumb-bg: #232832; --note-bg: #2E2914; --note-ink: #F1E3A6; --error: #FDA29B; --error-bg: #3A1A17;
    --shadow: none;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: 'Geist', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif; color: var(--ink); background: var(--bg);
  font-size: 16px; line-height: 1.5; -webkit-font-smoothing: antialiased; -webkit-text-size-adjust: 100%;
  padding: 0 max(16px, env(safe-area-inset-right)) max(32px, env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left));
}
a { color: var(--accent); }
[hidden] { display: none !important; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap; }

.bar, main { max-width: 1080px; margin: 0 auto; }
/* v0.23.0 (B4): a slim bar that stays at the top: Pagetta · Sync · ⋯ */
.bar { position: sticky; top: 0; z-index: 6; display: flex; align-items: center; gap: 8px; padding: max(8px, env(safe-area-inset-top)) 0 8px; background: var(--bg); }
.bar-acts { margin-left: auto; display: inline-flex; align-items: center; gap: 6px; }
.bar-acts .btn.small { gap: 6px; }
.brand { display: inline-flex; align-items: center; gap: 9px; font-weight: 700; font-size: 18px; color: var(--ink); text-decoration: none; letter-spacing: -.01em; min-height: 44px; }
.brand img { width: 28px; height: 28px; border-radius: 7px; }

h1 { font-size: clamp(26px, 6.4vw, 38px); line-height: 1.12; letter-spacing: -.025em; margin: 0 0 10px; overflow-wrap: anywhere; }
h2 { font-size: 17px; letter-spacing: -.01em; margin: 0 0 10px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 10px; min-height: 48px; padding: 0 20px;
  border-radius: 12px; font: inherit; font-weight: 600; border: 1px solid var(--line); background: var(--panel); color: var(--ink); cursor: pointer;
}
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.btn.primary:hover { background: var(--accent-ink); border-color: var(--accent-ink); }
.btn:focus-visible, .pick:focus-within, a:focus-visible, input:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }

/* Start */
.intro { background: var(--panel); border: 1px solid var(--line); border-radius: 18px; padding: 22px 20px; margin-top: 6px; box-shadow: var(--shadow); }
.lede { color: var(--ink-2); margin: 0 0 18px; font-size: 17px; }
.pick { width: 100%; max-width: 360px; }
.drop-hint { display: none; }
@media (hover: hover) and (pointer: fine) { .drop-hint { display: inline; } }
.error { margin: 14px 0 0; padding: 10px 12px; border-radius: 10px; background: var(--error-bg); color: var(--error); font-weight: 500; }
.private { display: flex; gap: 8px; align-items: flex-start; margin: 18px 0 0; color: var(--muted); font-size: 14px; }
.private svg { flex: none; margin-top: 3px; }

.kept { margin-top: 26px; }
.kept-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.kept-item { display: flex; align-items: center; gap: 12px; background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 10px; box-shadow: var(--shadow); }
.kept-open { flex: 1; min-width: 0; display: flex; align-items: center; gap: 12px; color: inherit; text-decoration: none; min-height: 56px; }
.kept-thumb { flex: none; width: 64px; height: 50px; border-radius: 8px; background: var(--thumb-bg); object-fit: cover; object-position: top; }
.kept-text { min-width: 0; }
.kept-name { display: block; font-weight: 600; overflow-wrap: anywhere; }
.kept-meta { display: block; color: var(--muted); font-size: 14px; }
.kept-remove { flex: none; min-height: 44px; padding: 0 12px; border: 0; background: none; color: var(--muted); font: inherit; font-size: 14px; cursor: pointer; border-radius: 10px; }
.kept-remove:hover { color: var(--error); background: var(--error-bg); }

.install { margin-top: 22px; padding: 14px 16px; border-radius: 14px; background: var(--accent-soft); color: var(--ink-2); font-size: 15px; }
.install p { margin: 0; }
.install .btn { margin-top: 10px; }
.about { margin-top: 26px; color: var(--muted); font-size: 15px; }
.about b { color: var(--ink-2); }

/* Board */
.back { display: inline-flex; align-items: center; min-height: 44px; text-decoration: none; font-weight: 500; }
.board-head { display: flex; gap: 16px; align-items: flex-start; margin: 2px 0 14px; }
.cover { flex: none; width: 112px; height: 84px; border-radius: 12px; object-fit: cover; object-position: top; background: var(--thumb-bg); border: 1px solid var(--line); }
.meta { margin: 0; color: var(--muted); font-size: 15px; }
.notice { margin: 10px 0 0; padding: 8px 12px; border-radius: 10px; background: var(--accent-soft); color: var(--ink-2); font-size: 14px; }
.message { margin: 10px 0 0; color: var(--ink-2); white-space: pre-wrap; overflow-wrap: anywhere; }
@media (max-width: 480px) { .cover { width: 84px; height: 64px; } }

.find { position: sticky; top: 0; z-index: 2; display: flex; align-items: center; gap: 8px; padding: 10px 14px; margin: 0 -2px; background: var(--panel); border: 1px solid var(--line); border-radius: 12px; color: var(--muted); }
.find input { flex: 1; min-width: 0; border: 0; outline: 0; background: transparent; font: inherit; font-size: 17px; color: var(--ink); min-height: 28px; }
.find input::placeholder { color: var(--muted); }
.find:focus-within { border-color: var(--accent); }
.count { margin: 8px 2px 4px; color: var(--muted); font-size: 14px; }
.count:empty { margin: 0; }

.group { margin-top: 18px; }
.group h2 { display: flex; align-items: baseline; gap: 8px; padding-bottom: 8px; border-bottom: 1px solid var(--line); overflow-wrap: anywhere; }
.group h2 span { color: var(--muted); font-weight: 500; font-size: 14px; }
.cards { list-style: none; margin: 12px 0 0; padding: 0; display: grid; gap: 10px; grid-template-columns: 1fr; }

.card { display: flex; gap: 12px; background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 10px; box-shadow: var(--shadow); min-width: 0; }
.card-thumb { flex: none; display: block; width: 104px; height: 80px; border-radius: 9px; overflow: hidden; background: var(--thumb-bg); }
.card-thumb img { width: 100%; height: 100%; object-fit: cover; object-position: top; display: block; }
.card-thumb .no-pic { display: grid; place-items: center; height: 100%; color: var(--muted); font-size: 12px; }
.card-body { min-width: 0; flex: 1; }
.card-title { display: block; color: var(--ink); font-weight: 600; text-decoration: none; overflow-wrap: anywhere; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.card-title:hover { text-decoration: underline; }
.card-site { display: block; color: var(--muted); font-size: 14px; margin-top: 2px; overflow-wrap: anywhere; }
.card-note { margin: 8px 0 0; padding: 7px 10px; border-radius: 9px; background: var(--note-bg); color: var(--note-ink); font-size: 15px; white-space: pre-wrap; overflow-wrap: anywhere; }

@media (min-width: 680px) {
  .cards { grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 14px; }
  .card { flex-direction: column; padding: 0; overflow: hidden; }
  .card-thumb { width: 100%; height: 150px; border-radius: 0; }
  .card-body { padding: 4px 14px 14px; }
}

.empty { margin: 24px 2px; color: var(--muted); }
.have { margin-top: 30px; padding: 14px 16px; border-radius: 14px; background: var(--accent-soft); color: var(--ink-2); font-size: 15px; }
.have p { margin: 0; }
.have p + p { margin-top: 6px; color: var(--muted); font-size: 14px; }
.have b { color: var(--ink); }

.dropzone { position: fixed; inset: 0; z-index: 10; display: grid; place-items: center; background: color-mix(in srgb, var(--accent) 18%, transparent); border: 3px dashed var(--accent); }
.dropzone div { background: var(--panel); padding: 16px 22px; border-radius: 14px; font-weight: 600; }

/* ---------- v0.19.0: pages sent from the computer (D27) ---------- */
.btn.small { min-height: 44px; padding: 0 14px; border-radius: 12px; font-size: 15px; }
.btn.ghost { background: transparent; }
.btn:disabled { opacity: .55; cursor: default; }
.start-notice { margin-top: 14px; }
.kept-h { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 10px; }
.kept-h h2 { margin: 0; }
.kept .find { margin-bottom: 10px; position: static; }
.locked-box { margin-top: 10px; display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; padding: 12px 14px; border-radius: 14px; background: var(--accent-soft); color: var(--ink-2); font-size: 15px; }
.unlock-box { max-width: 520px; margin: 0 auto; }
.unlock-box input[type=password] { width: 100%; min-height: 50px; border: 1px solid var(--line); border-radius: 12px; padding: 0 14px; font: inherit; font-size: 18px; background: var(--panel); color: var(--ink); }
.unlock-acts { display: flex; gap: 10px; margin-top: 14px; flex-wrap: wrap; }
.unlock-acts .btn { flex: 1 1 140px; }

.page .p-head { margin: 2px 0 10px; }
.page .p-head h1 { font-size: clamp(20px, 5vw, 28px); letter-spacing: -.015em; }
.p-acts { display: flex; flex-wrap: wrap; gap: 4px 18px; margin: 6px 0 0; font-size: 15px; }
.p-acts a, .linkish { min-height: 36px; display: inline-flex; align-items: center; }
.linkish { border: 0; background: none; padding: 0; font: inherit; color: var(--muted); cursor: pointer; text-decoration: underline; text-underline-offset: 2px; }
.linkish:hover { color: var(--error); }
.page .p-head .card-note { margin-top: 10px; }
.p-bar { position: sticky; top: 0; z-index: 3; display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding: 8px 0; background: var(--bg); }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 999px; padding: 2px; background: var(--panel); }
.seg button { border: 0; background: transparent; border-radius: 999px; min-height: 34px; padding: 0 14px; font: inherit; font-size: 14px; cursor: pointer; color: var(--ink-2); }
.seg button[aria-pressed="true"] { background: var(--accent-soft); color: var(--accent-ink); font-weight: 600; }
.p-prefs-w { display: inline-flex; }   /* (the panel is placed against the bar, so it fits a phone) */
#p-prefs span { font-weight: 700; letter-spacing: -.02em; }
.p-panel { position: absolute; left: 0; right: 0; margin: 0 auto; width: min(360px, 100%); top: calc(100% + 2px); z-index: 5; background: var(--panel); border: 1px solid var(--line); border-radius: 14px; box-shadow: 0 16px 40px rgba(16, 24, 40, .18); }
.p-find { flex: 1 1 100px; min-width: 0; display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--line); border-radius: 10px; background: var(--panel); padding: 0 10px; min-height: 38px; }
.p-find input { flex: 1; min-width: 0; border: 0; outline: 0; background: transparent; font: inherit; font-size: 16px; color: var(--ink); }
.p-find .n { font-size: 13px; color: var(--muted); white-space: nowrap; }
.stage { margin: 4px -16px 0; padding: 8px 8px 24px; min-height: 50vh; border-radius: 0; }
@media (min-width: 720px) { .stage { margin: 4px 0 0; border-radius: 14px; } }
.stage .rf { border-radius: 12px; box-shadow: var(--shadow); }
.rf h1, .rf h2, .rf h3, .rf h4 { letter-spacing: normal; }
@media (prefers-color-scheme: dark) {
  .stage .rf:not([data-rf-theme]) { --rf-bg: #1A1D23; --rf-ink: #E3E5E9; --rf-muted: #9AA1AD; --rf-line: #2C313A; --rf-tint: #242932; --rf-link: #A9BEFF; }
}
.cp-wrap { position: relative; margin: 0 auto; background: #fff; box-shadow: 0 1px 6px rgba(16,24,40,.12); overflow: hidden; }
.p-picture { display: block; width: 100%; height: auto; border-radius: 8px; background: #fff; }
.p-text { margin-top: 14px; font-size: 15px; color: var(--ink-2); }
.p-text summary { cursor: pointer; font-weight: 600; min-height: 40px; display: flex; align-items: center; }
.p-text-body { white-space: pre-wrap; overflow-wrap: anywhere; }
.p-quote { margin: 8px; padding: 6px 0 6px 18px; border-left: 4px solid #F59E0B; font: 19px/1.6 Georgia, 'Times New Roman', serif; white-space: pre-wrap; overflow-wrap: anywhere; color: var(--ink); }
.p-quote mark, .p-text mark { background: rgba(255, 213, 0, .55); border-radius: 2px; color: inherit; }
.p-quote mark.cur, .p-text mark.cur { background: rgba(255, 140, 0, .65); }

/* Sync with a code (D40, v0.21.0) */
.or-file { margin: 18px 0 10px; color: var(--muted); font-size: 15px; }
.kept-h-acts { display: inline-flex; gap: 8px; }
.synced-line { margin: -4px 0 10px; color: var(--muted); font-size: 14px; }
.chips { display: flex; gap: 8px; margin: 10px -16px 6px; padding: 0 16px 4px; overflow-x: auto; scrollbar-width: none; -webkit-overflow-scrolling: touch; }
.chips::-webkit-scrollbar { display: none; }
.chip { flex: none; min-height: 44px; padding: 0 16px; border-radius: 22px; border: 1px solid var(--line); background: var(--panel); color: var(--ink-2); font: inherit; font-size: 15px; cursor: pointer; max-width: 70vw; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chip[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.kept-name .dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--accent); vertical-align: middle; }
.sync-label { display: block; margin: 18px 0 6px; font-weight: 600; }
#sync-code { width: 100%; min-height: 50px; border: 1px solid var(--line); border-radius: 12px; padding: 0 14px; font: inherit; font-size: 19px; background: var(--panel); color: var(--ink); letter-spacing: .01em; }
#sync-scan { margin-top: 4px; }
.sync-cam { margin: 6px 0 12px; }
.sync-cam video { display: block; width: 100%; max-height: 52vh; object-fit: cover; border-radius: 14px; background: #000; }
.sync-cam p { margin: 8px 0 0; color: var(--muted); font-size: 14px; }
.sync-bar { height: 8px; border-radius: 4px; background: var(--line); overflow: hidden; margin: 10px 0 0; }
.sync-bar span { display: block; height: 100%; width: 0; background: var(--accent); transition: width .2s; }
a.btn { text-decoration: none; }
/* (A grid column would otherwise grow to a long title and push the page sideways.) */
.kept-list { grid-template-columns: minmax(0, 1fr); }
.kept-item { min-width: 0; }
.synced-foot { margin: 10px 0 0; font-size: 14px; }
.synced-foot .linkish { color: var(--muted); }

/* ---------- v0.23.0 (B4): content first ---------- */
.icon-btn { flex: none; display: inline-grid; place-items: center; width: 44px; height: 44px; border-radius: 12px; border: 0; background: transparent; color: var(--ink-2); cursor: pointer; font: inherit; text-decoration: none; }
.icon-btn:hover, .icon-btn[aria-expanded="true"] { background: var(--panel); }
.icon-btn span { font-weight: 700; font-size: 17px; letter-spacing: -.02em; }
.menu { position: absolute; right: 0; top: calc(100% - 2px); z-index: 8; min-width: 250px; max-width: calc(100vw - 32px); padding: 6px; background: var(--panel); border: 1px solid var(--line); border-radius: 14px; box-shadow: 0 16px 40px rgba(16, 24, 40, .18); display: grid; }
.mi { display: flex; align-items: center; min-height: 44px; padding: 0 12px; border: 0; border-radius: 10px; background: none; font: inherit; font-size: 16px; color: var(--ink); text-align: left; text-decoration: none; cursor: pointer; }
.mi:hover, .mi:focus-visible { background: var(--accent-soft); }
#sync-forget, #p-remove { color: var(--error); }
.mi-seg { margin: 2px 4px 6px; display: flex; }
.mi-seg button { flex: 1; min-height: 44px; }
.toast { position: fixed; left: 50%; bottom: max(18px, env(safe-area-inset-bottom)); transform: translateX(-50%); z-index: 9; max-width: min(520px, calc(100vw - 32px)); padding: 12px 16px; border-radius: 12px; background: var(--ink); color: var(--bg); font-size: 15px; box-shadow: 0 10px 30px rgba(16, 24, 40, .25); }
.start-notice.warn { background: var(--error-bg); color: var(--error); font-weight: 500; }
.status-line { margin: 2px 0 10px; color: var(--muted); font-size: 14px; }
.status-line.stale { color: var(--error); font-weight: 500; }
.status-line a { font-weight: 600; }
.how { margin: 12px 0 0; color: var(--muted); font-size: 15px; }
.or-file { margin: 18px 0 0; color: var(--muted); font-size: 15px; }
.or-file .linkish { color: var(--accent); font-weight: 600; text-decoration: none; display: inline-block; padding: 11px 4px; margin: -11px -4px; cursor: pointer; }
.linkish:hover { color: var(--accent-ink); }
.when-h { margin: 18px 2px 8px; font-size: 13px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.when-h:first-child { margin-top: 8px; }
.when-h span { font-weight: 500; letter-spacing: normal; text-transform: none; }
.kept-thumb { width: 72px; height: 72px; border-radius: 10px; }
.kept-name { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; line-height: 1.3; }
.kept-meta { margin-top: 3px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.kept-item.unread .kept-name { font-weight: 700; }
.chip .n { margin-left: 6px; font-weight: 600; opacity: .8; }
.board-strip { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin: 4px 0 6px; font-weight: 600; font-size: 17px; }
.more-rows { display: flex; width: 100%; margin: 14px 0 0; color: var(--ink-2); }
.tiles { list-style: none; margin: 10px 0 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.tile { display: grid; gap: 4px; align-content: start; min-height: 96px; padding: 14px; border-radius: 14px; border: 1px solid var(--line); background: var(--panel); box-shadow: var(--shadow); color: inherit; text-decoration: none; font: inherit; text-align: left; cursor: pointer; width: 100%; }
.tile b { font-size: 16px; overflow-wrap: anywhere; }
.tile span { color: var(--muted); font-size: 14px; }
#boards-view .kept { margin-top: 22px; }
#boards-view .kept h2 { font-size: 13px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.find { margin: 0; }
#pages-find { position: static; }
.board .find { top: calc(max(8px, env(safe-area-inset-top)) + 52px); }

/* The open page: one slim bar (sticky) */
.page .p-bar { position: sticky; top: 0; z-index: 7; display: flex; flex-wrap: wrap; align-items: center; gap: 2px; padding: max(4px, env(safe-area-inset-top)) max(8px, env(safe-area-inset-right)) 4px max(8px, env(safe-area-inset-left)); margin: 0 calc(-1 * max(16px, env(safe-area-inset-left))); background: var(--bg); }
.page.has-bar-title .p-bar { border-bottom: 1px solid var(--line); }
body.on-page .bar { display: none; }
.p-bar-title { flex: 1; min-width: 0; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; opacity: 0; transition: opacity .15s; padding: 0 4px; }
.page.has-bar-title .p-bar-title { opacity: 1; }
.p-bar .menu { right: 8px; top: 52px; }
.p-prefs-w { position: static; }
.p-findbar { flex: 1 0 100%; display: flex; align-items: center; gap: 4px; padding: 2px 0 2px; }
#fq::-webkit-search-cancel-button { display: none; }
.p-find { flex: 1; min-height: 44px; }
.page .p-head { margin: 6px 0 10px; }
.page .p-head h1 { font-size: clamp(19px, 4.8vw, 26px); line-height: 1.2; margin-bottom: 4px; }
.page .p-head .meta { font-size: 14px; }
.note-strip { margin: 8px 0 0; padding: 6px 10px; border-left: 3px solid #E0B400; border-radius: 4px; background: var(--note-bg); color: var(--note-ink); font-size: 14px; white-space: pre-wrap; overflow-wrap: anywhere; }

/* Sync */
.sync-screen h1 { font-size: clamp(24px, 6vw, 32px); margin-top: 8px; }
.sync-screen .lede { font-size: 16px; }
.btn.wide { width: 100%; }
.sync-cam { position: relative; margin: 0 0 12px; }
.sync-cam video { display: block; width: 100%; aspect-ratio: 1; max-height: 60vh; object-fit: cover; border-radius: 16px; background: #000; }
.sync-cam .frame { position: absolute; inset: 18%; border: 3px solid rgba(255, 255, 255, .9); border-radius: 18px; box-shadow: 0 0 0 999px rgba(0, 0, 0, .25); pointer-events: none; }
.code-row { display: flex; gap: 8px; }
.code-row #sync-code { flex: 1; min-width: 0; }
.code-row .btn { flex: none; }
.sync-screen.busy #sync-pick { display: none; }
.sync-screen.busy #sync-status { font-size: 17px; padding: 14px 16px; }
.how-sync { margin-top: 22px; color: var(--muted); font-size: 15px; }
.how-sync summary { min-height: 44px; display: flex; align-items: center; cursor: pointer; font-weight: 600; color: var(--ink-2); }
.how-sync summary::-webkit-details-marker { display: none; }
.how-sync summary::after { content: ''; width: 8px; height: 8px; margin-left: 10px; border: solid currentColor; border-width: 0 2px 2px 0; transform: rotate(45deg) translateY(-3px); }
.how-sync[open] summary::after { transform: rotate(-135deg) translate(-2px, -1px); }
.how-sync p { margin: 6px 0 0; }
#about .intro p { color: var(--ink-2); }
