/* Lumi on the web — same palette and type as the landing (css/style.css). */
:root {
  --bg: #fffaf6;
  --bg-2: #f7f1fb;
  --surface: #ffffff;
  --surface-2: #faf6ff;
  --ink: #3b3355;
  --ink-2: #6b6487;
  --line: rgba(91, 74, 158, .14);
  --line-2: rgba(91, 74, 158, .24);
  --lav: #c9bdf5;
  --lav-l: #efe9ff;
  --lav-d: #7c67c9;
  --peach: #ffd3c2;
  --peach-d: #e98d6f;
  --mint: #c4ecdc;
  --accent: #7c67c9;
  --accent-ink: #ffffff;
  --danger: #d64545;
  --desk: #efe8f6;
  --shadow: 0 10px 30px rgba(91, 74, 158, .12);
  --shadow-sm: 0 2px 8px rgba(91, 74, 158, .10);
  --radius: 18px;
  --top-h: 56px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #1c1930; --bg-2: #221e3a; --surface: #2a2544; --surface-2: #2f2a4c;
    --ink: #efeafd; --ink-2: #b8b0d8; --line: rgba(201, 189, 245, .16); --line-2: rgba(201, 189, 245, .28);
    --lav: #4b3f86; --lav-l: #3a3266; --lav-d: #b9a7f0; --peach: #6b4250; --peach-d: #f6b9a5; --mint: #2f5a4f;
    --accent: #b9a7f0; --accent-ink: #1c1930; --danger: #ff8a8a; --desk: #15132a;
    --shadow: 0 10px 30px rgba(0, 0, 0, .35); --shadow-sm: 0 2px 8px rgba(0, 0, 0, .3);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: 'Nunito', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  font-size: 16px; line-height: 1.5;
  color: var(--ink); background: var(--bg);
  overflow: hidden; overflow: clip; /* clip: scrollIntoView must never scroll the app shell */
  -webkit-tap-highlight-color: transparent;
}
a { color: var(--accent); }
h1, h2, h3, .hand { font-family: 'Patrick Hand', 'Caveat', 'Comic Sans MS', cursive; font-weight: 400; line-height: 1.15; }
.small { font-size: .85rem; }
.muted { color: var(--ink-2); }
.spacer { flex: 1; }
.row { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.row.center { justify-content: center; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
button:disabled { opacity: .4; cursor: default; }
:focus-visible { outline: 2.5px solid var(--accent); outline-offset: 2px; }

/* ── buttons ── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border: 1px solid transparent; border-radius: 999px; padding: 9px 18px;
  font-weight: 800; font-size: .95rem; text-decoration: none; white-space: nowrap;
  background: var(--surface); color: var(--ink); transition: transform .12s, box-shadow .12s, background .12s;
}
.btn:hover { transform: translateY(-1px); }
.btn:active { transform: none; }
.btn-primary { background: var(--accent); color: var(--accent-ink); box-shadow: 0 6px 16px rgba(124, 103, 201, .28); }
.btn-soft { background: var(--lav-l); color: var(--lav-d); }
.btn-ghost { background: transparent; border-color: var(--line-2); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-sm { padding: 7px 14px; font-size: .88rem; }
.btn-xs { padding: 4px 10px; font-size: .78rem; }
.danger { color: var(--danger); }
.btn svg { width: 18px; height: 18px; }

.tb-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-width: 38px; height: 38px; padding: 0 8px; border-radius: 12px;
  border: 0; background: transparent; color: var(--ink);
}
.tb-btn:hover:not(:disabled) { background: var(--lav-l); }
.tb-btn.on { background: var(--lav); color: #2b2546; }
.tb-btn.sm { min-width: 32px; height: 32px; border-radius: 10px; }
.tb-btn.sm svg { width: 17px; height: 17px; }
.tb-txt { font-weight: 800; font-size: .9rem; }

.chip { border: 1px solid var(--line-2); background: var(--surface); border-radius: 999px; padding: 6px 12px; font-size: .88rem; font-weight: 700; display: inline-flex; align-items: center; gap: 6px; }
.chip.on { background: var(--accent); color: var(--accent-ink); border-color: transparent; }

.seg { display: inline-flex; background: var(--bg-2); border: 1px solid var(--line); border-radius: 999px; padding: 3px; gap: 2px; }
.seg button { border: 0; background: transparent; border-radius: 999px; padding: 6px 14px; font-weight: 800; font-size: .88rem; display: inline-flex; align-items: center; gap: 6px; color: var(--ink-2); }
.seg button.on { background: var(--surface); color: var(--ink); box-shadow: var(--shadow-sm); }
.seg svg { width: 17px; height: 17px; }

.swatch { width: 26px; height: 26px; border-radius: 50%; border: 2px solid var(--surface); box-shadow: 0 0 0 1px var(--line-2); background: var(--c); padding: 0; flex: none; position: relative; }
.swatch.on { box-shadow: 0 0 0 2.5px var(--accent); }
.swatch.custom { background: var(--c); overflow: hidden; cursor: pointer; }
.swatch.custom input { position: absolute; inset: 0; opacity: 0; cursor: pointer; width: 100%; height: 100%; }

/* ── top bar ── */
.topbar {
  height: var(--top-h); display: flex; align-items: center; gap: 10px; padding: 0 14px;
  padding-left: max(14px, env(safe-area-inset-left)); padding-right: max(14px, env(safe-area-inset-right));
  border-bottom: 1px solid var(--line); background: color-mix(in srgb, var(--bg) 85%, transparent);
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); position: relative; z-index: 30;
}
.brand { display: flex; align-items: center; gap: 8px; text-decoration: none; color: var(--ink); font-weight: 800; }
.brand img { border-radius: 9px; }
.brand-name { font-size: 1.05rem; }
.brand-name .hand { font-size: 1.25rem; color: var(--lav-d); margin-left: 2px; }
.local-badge { display: inline-flex; align-items: center; gap: 6px; font-size: .78rem; font-weight: 700; color: var(--ink-2); background: var(--bg-2); border: 1px solid var(--line); border-radius: 999px; padding: 4px 10px; }
.local-badge svg { width: 15px; height: 15px; }
.lang { font-weight: 800; font-size: .85rem; border: 1px solid var(--line-2); border-radius: 999px; height: 32px; }

.menu-wrap { position: relative; }
.menu {
  position: absolute; top: calc(100% + 6px); right: 0; min-width: 230px; z-index: 50;
  background: var(--surface); border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow); padding: 6px;
  display: flex; flex-direction: column;
}
.menu.right { right: 0; }
.menu > button, .menu > a { text-align: left; border: 0; background: transparent; padding: 9px 12px; border-radius: 10px; font-size: .92rem; font-weight: 700; color: var(--ink); text-decoration: none; display: flex; align-items: center; gap: 10px; }
.menu > button:hover, .menu > a:hover { background: var(--lav-l); }
.menu hr { border: 0; border-top: 1px solid var(--line); margin: 4px 6px; }
.menu .danger { color: var(--danger); }
.mood-menu { left: 0; right: auto; display: grid; grid-template-columns: repeat(2, 1fr); min-width: 260px; }
.mood-menu svg { width: 26px; height: 26px; }

/* ── layout ── */
.layout { display: flex; height: calc(100% - var(--top-h)); overflow: hidden; overflow: clip; }
.sidebar { width: 330px; flex: none; border-right: 1px solid var(--line); display: flex; flex-direction: column; background: var(--bg); min-height: 0; }
.side-top { padding: 12px 12px 6px; display: flex; flex-direction: column; gap: 10px; }
.search { display: flex; align-items: center; gap: 8px; background: var(--surface); border: 1px solid var(--line-2); border-radius: 999px; padding: 0 14px; height: 40px; }
.search input { border: 0; background: transparent; flex: 1; outline: none; min-width: 0; }
.search svg { color: var(--ink-2); width: 18px; }
.side-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.side-actions .btn { padding: 9px 10px; font-size: .88rem; }
.side-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.sort select { border: 1px solid var(--line-2); background: var(--surface); border-radius: 999px; padding: 5px 10px; font-size: .84rem; font-weight: 700; }
.note-list { flex: 1; overflow-y: auto; padding: 4px 8px 12px; }
.list-label { font-family: 'Nunito', sans-serif; font-size: .74rem; font-weight: 800; letter-spacing: .1em; text-transform: uppercase; color: var(--ink-2); margin: 12px 8px 4px; }
.list-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 8px; }
.list-empty { padding: 28px 16px; text-align: center; }
.note-row { border-radius: 14px; margin: 2px 0; display: flex; flex-direction: column; }
.note-row:hover { background: var(--bg-2); }
.note-row.on { background: var(--lav-l); }
.row-main { display: flex; gap: 10px; text-align: left; border: 0; background: transparent; padding: 10px; border-radius: 14px; width: 100%; }
.row-mood { width: 22px; flex: none; padding-top: 2px; }
.row-mood svg { width: 22px; height: 22px; }
.row-text { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.row-title { font-weight: 800; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; display: flex; align-items: center; gap: 4px; }
.pin-ic { width: 14px; height: 14px; color: var(--lav-d); }
.row-snip { color: var(--ink-2); font-size: .88rem; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.row-meta { display: flex; flex-wrap: wrap; gap: 4px 6px; font-size: .76rem; color: var(--ink-2); margin-top: 3px; }
.tag { color: var(--lav-d); font-weight: 700; }
.row-acts { display: flex; gap: 6px; padding: 0 10px 10px 42px; }
.side-foot { padding: 8px 16px 14px; margin: 0; border-top: 1px solid var(--line); }

.main { flex: 1; min-width: 0; min-height: 0; display: flex; flex-direction: column; position: relative; overflow: hidden; overflow: clip; }

/* ── welcome ── */
.welcome { margin: auto; padding: 32px 20px; max-width: 560px; text-align: center; }
.welcome h1 { font-size: clamp(1.9rem, 4vw, 2.6rem); margin: .3em 0; }
.welcome .lead { color: var(--ink-2); }
.doodle { width: 200px; height: 146px; }
.doodle * { stroke-width: 3; }
.app-hint { margin-top: 26px; }

/* ── editor ── */
.editor { display: flex; flex-direction: column; flex: 1; min-height: 0; }
.ed-head { display: flex; align-items: center; gap: 8px; padding: 10px 16px 4px; }
.back { display: none; }
.title-input { flex: 1; min-width: 0; border: 0; background: transparent; font-family: 'Patrick Hand', 'Caveat', cursive; font-size: 1.9rem; padding: 2px 4px; outline: none; border-radius: 8px; }
.title-input:focus { background: var(--bg-2); }
.title-input::placeholder { color: var(--ink-2); opacity: .6; }
.ed-actions { display: flex; align-items: center; gap: 4px; }
.meta-row { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; padding: 2px 16px 8px; }
.mood-btn svg { width: 20px; height: 20px; }
.tags { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.tag-chip { display: inline-flex; align-items: center; gap: 2px; background: var(--lav-l); color: var(--lav-d); border-radius: 999px; padding: 3px 4px 3px 10px; font-size: .84rem; font-weight: 800; }
.tag-chip button { border: 0; background: transparent; color: inherit; font-size: 1rem; line-height: 1; padding: 0 6px; border-radius: 50%; }
#tagInput { border: 1px dashed var(--line-2); background: transparent; border-radius: 999px; padding: 4px 12px; font-size: .85rem; width: 130px; outline: none; }
#tagInput:focus { border-style: solid; border-color: var(--accent); }
.save-state.err { color: var(--danger); font-weight: 700; }
.ed-tabs { margin: 0 16px 8px; align-self: flex-start; }
.count { color: var(--ink-2); font-weight: 700; }

.tab-panel { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.fmt-bar, .ink-bar {
  display: flex; flex-wrap: wrap; align-items: center; gap: 4px; padding: 6px 12px; margin: 0 12px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 16px; box-shadow: var(--shadow-sm); position: relative; z-index: 5;
}
.tb-group { display: flex; align-items: center; gap: 2px; padding-right: 6px; margin-right: 2px; border-right: 1px solid var(--line); }
.tb-group:last-of-type { border-right: 0; }
.tb-split { display: inline-flex; }
.tb-more { min-width: 22px !important; padding: 0 2px !important; }
.tb-more svg { width: 14px; }
.hl-bar { stroke: var(--hl-color); }
.color-bar { stroke: var(--text-color); }
.color-pop { position: absolute; top: calc(100% + 6px); left: 40%; display: flex; gap: 8px; padding: 10px; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow); }

.body-scroll { flex: 1; overflow-y: auto; padding: 18px 16px 60px; }
.body-edit {
  max-width: 760px; margin: 0 auto; min-height: 60vh; outline: none; font-size: 1.06rem; line-height: 1.7;
  background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow-sm); border: 1px solid var(--line);
  padding: 28px clamp(18px, 4vw, 44px);
  background-image: repeating-linear-gradient(transparent 0 calc(1.7em - 1px), var(--line) calc(1.7em - 1px) 1.7em);
  background-position: 0 28px; background-attachment: local;
}
.body-edit:empty::before { content: attr(data-placeholder); color: var(--ink-2); opacity: .6; pointer-events: none; }
.body-edit h1 { font-size: 2rem; margin: .3em 0; }
.body-edit h2 { font-size: 1.55rem; margin: .3em 0; }
.body-edit p { margin: 0; }
.body-edit ul, .body-edit ol { margin: 0; padding-left: 1.6em; }
.body-edit ul.checklist { list-style: none; padding-left: 0; }
.body-edit ul.checklist > li { position: relative; padding-left: 30px; }
.body-edit ul.checklist > li::before {
  content: ''; position: absolute; left: 2px; top: .38em; width: 18px; height: 18px; border-radius: 6px;
  border: 2px solid var(--lav-d); background: var(--surface); cursor: pointer;
}
.body-edit ul.checklist > li[data-checked="true"]::before { background: var(--lav-d) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M5 12.5l4.5 4.5L19 7.5' fill='none' stroke='white' stroke-width='3.2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") center/14px no-repeat; }
.body-edit ul.checklist > li[data-checked="true"] { color: var(--ink-2); text-decoration: line-through; text-decoration-color: color-mix(in srgb, var(--ink-2) 60%, transparent); }
.body-edit mark { background: #fff1a8; }
.dates { max-width: 760px; margin: 12px auto 0; text-align: right; }

/* ── pages ── */
.pages-panel { position: relative; }
.ink-bar .pen-only { display: inline-flex; align-items: center; gap: 6px; font-size: .8rem; font-weight: 800; color: var(--ink-2); padding: 0 6px; cursor: pointer; }
.ink-bar .colors { gap: 6px; padding: 0 8px; }
.ink-bar .width i { display: block; border-radius: 50%; background: currentColor; }
.zoom-label { font-size: .8rem; font-weight: 800; min-width: 52px !important; }
.pages-scroll { flex: 1; overflow: auto; padding: 16px 24px 80px; background: var(--desk); margin-top: -26px; padding-top: 42px; overscroll-behavior: contain; }
.pages-stack { display: flex; flex-direction: column; align-items: center; gap: 22px; width: max-content; min-width: 100%; transform-origin: 0 0; }
.page-wrap { display: flex; flex-direction: column; gap: 6px; }
.page-head { display: flex; align-items: center; gap: 4px; padding: 0 2px; font-size: .82rem; color: var(--ink-2); min-height: 32px; }
.page-num { font-weight: 800; color: var(--ink); }
.page-tpl { margin-left: 6px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 40vw; }
.page-wrap.active .page-num { color: var(--lav-d); }
.date-btn { position: relative; cursor: pointer; }
.date-btn input { position: absolute; inset: 0; opacity: 0; cursor: pointer; width: 100%; }
.sheet { position: relative; border-radius: 4px; box-shadow: 0 6px 22px rgba(43, 37, 70, .14), 0 0 0 1px rgba(43, 37, 70, .06); background: #fff; touch-action: none; user-select: none; -webkit-user-select: none; overflow: hidden; }
.page-wrap.active .sheet { box-shadow: 0 8px 26px rgba(43, 37, 70, .18), 0 0 0 2px var(--lav); }
.layer { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.pages-panel[data-tool="hand"] .sheet { touch-action: auto; cursor: grab; }
.pages-panel[data-tool="pen"] .sheet { cursor: crosshair; }
.pages-panel[data-tool="marker"] .sheet { cursor: crosshair; }
.pages-panel[data-tool="eraser"] .sheet { cursor: cell; }
.pages-panel[data-tool="text"] .sheet { cursor: text; }
.lasso { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.lasso path { fill: rgba(124, 103, 201, .08); stroke: var(--lav-d); stroke-dasharray: 4 3; vector-effect: non-scaling-stroke; stroke-width: 1.4; }
.selection { position: absolute; border: 1.5px dashed var(--lav-d); border-radius: 4px; background: rgba(124, 103, 201, .06); pointer-events: none; }
.pages-empty { text-align: center; padding: 60px 20px; }

.items { position: absolute; inset: 0; pointer-events: none; }
.item { position: absolute; pointer-events: auto; }
.item-image img { width: 100%; height: 100%; display: block; object-fit: fill; user-select: none; -webkit-user-drag: none; pointer-events: none; }
.tb { font-family: 'Patrick Hand', 'Caveat', 'Nunito', system-ui, sans-serif; line-height: 1.3; outline: none; white-space: pre-wrap; word-break: break-word; min-height: 1.3em; border-radius: 4px; cursor: text; }
.it-grip, .it-del, .it-resize { position: absolute; display: none; z-index: 2; }
.it-grip, .it-del { width: 28px; height: 28px; border-radius: 50%; border: 0; background: var(--accent); color: #fff; padding: 0; align-items: center; justify-content: center; box-shadow: var(--shadow-sm); }
.it-grip svg, .it-del svg { width: 15px; height: 15px; stroke-width: 2.2; }
.it-grip { top: -14px; left: -14px; cursor: move; touch-action: none; }
.it-del { top: -14px; right: -14px; background: var(--danger); }
.it-resize { right: -7px; bottom: -7px; width: 16px; height: 16px; border-radius: 4px; background: var(--surface); border: 2px solid var(--accent); cursor: nwse-resize; touch-action: none; }
.item:hover, .item.editing, .item:focus-within { outline: 1.5px dashed var(--lav-d); outline-offset: 2px; }
.item:hover .it-grip, .item.editing .it-grip, .item:focus-within .it-grip,
.item:hover .it-del, .item.editing .it-del, .item:focus-within .it-del,
.item:hover .it-resize, .item.editing .it-resize, .item:focus-within .it-resize { display: inline-flex; }
.pages-panel[data-tool="select"] .item { cursor: move; touch-action: none; }
.pages-panel[data-tool="select"] .item .it-grip, .pages-panel[data-tool="select"] .item .it-del, .pages-panel[data-tool="select"] .item .it-resize { display: inline-flex; }
.pages-panel:is([data-tool="pen"], [data-tool="marker"], [data-tool="eraser"]) .item { pointer-events: none; }
.pages-panel:is([data-tool="pen"], [data-tool="marker"], [data-tool="eraser"]) .item .it-grip { pointer-events: auto; }

/* ── dialogs ── */
.dlg { border: 0; padding: 0; border-radius: 22px; background: var(--surface); color: var(--ink); box-shadow: 0 24px 60px rgba(30, 20, 60, .3); max-width: min(760px, calc(100vw - 24px)); width: 100%; max-height: calc(100dvh - 24px); }
.dlg::backdrop { background: rgba(28, 25, 48, .42); backdrop-filter: blur(2px); }
.dlg-inner { padding: 18px 20px 20px; display: flex; flex-direction: column; gap: 12px; max-height: calc(100dvh - 24px); }
.dlg-head { display: flex; align-items: center; justify-content: space-between; }
.dlg-head h2 { margin: 0; font-size: 1.7rem; }
.dlg-foot { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.confirm { max-width: 420px; }
.confirm-msg { font-size: 1.02rem; margin: 6px 0; }
.cat-tabs { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 2px; scrollbar-width: none; }
.tpl-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(124px, 1fr)); gap: 12px; overflow-y: auto; min-height: 180px; padding: 4px; }
.tpl-card { display: flex; flex-direction: column; align-items: center; gap: 6px; border: 2px solid transparent; background: var(--bg-2); border-radius: 14px; padding: 8px 6px; font-size: .82rem; font-weight: 700; text-align: center; }
.tpl-card .thumb { border-radius: 3px; box-shadow: 0 2px 8px rgba(43, 37, 70, .16); max-width: 100%; height: auto !important; }
.tpl-card.on { border-color: var(--accent); background: var(--lav-l); }
.picker-opts { display: flex; flex-wrap: wrap; gap: 12px 24px; }
.opt { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.opt-l { font-weight: 800; font-size: .85rem; color: var(--ink-2); }
.paper-colors { display: flex; flex-wrap: wrap; gap: 6px; }
.size-sel { border: 1px solid var(--line-2); border-radius: 999px; padding: 5px 10px; background: var(--surface); font-weight: 700; }

.openapp .oa-body { display: grid; grid-template-columns: 240px 1fr; gap: 18px; align-items: start; }
.qr-box { background: #fff; border-radius: 16px; padding: 10px; border: 1px solid var(--line); min-height: 240px; display: flex; flex-direction: column; align-items: center; justify-content: center; }
.qr-box canvas { width: 220px; height: 220px; image-rendering: pixelated; }
.qr-note { color: #6b6487; text-align: center; padding: 0 10px; }
.oa-kind { font-weight: 800; margin: 0 0 6px; }
.oa-link textarea { width: 100%; border: 1px solid var(--line-2); border-radius: 12px; padding: 8px 10px; font: 12px/1.4 ui-monospace, Menlo, monospace; background: var(--bg-2); resize: vertical; word-break: break-all; }
.oa-link .row { margin-top: 8px; }
.warn { color: var(--danger); font-weight: 700; }
.small-h { font-family: 'Nunito', sans-serif; font-weight: 800; font-size: .8rem; letter-spacing: .08em; text-transform: uppercase; color: var(--ink-2); margin: 6px 0 0; }
.quick { display: flex; flex-wrap: wrap; gap: 8px; }
.quick .chip { text-align: left; }

/* ── toasts ── */
.toasts { position: fixed; left: 50%; bottom: max(18px, env(safe-area-inset-bottom)); transform: translateX(-50%); display: flex; flex-direction: column; gap: 8px; z-index: 100; align-items: center; pointer-events: none; }
.toast { background: #2b2546; color: #fff; padding: 10px 16px; border-radius: 14px; box-shadow: var(--shadow); font-weight: 700; font-size: .9rem; display: flex; align-items: center; gap: 14px; pointer-events: auto; animation: tin .2s ease-out; max-width: calc(100vw - 32px); transition: opacity .4s, transform .4s; }
.toast button { border: 0; background: transparent; color: #c9bdf5; font-weight: 800; text-transform: uppercase; font-size: .8rem; }
.toast.out { opacity: 0; transform: translateY(8px); }
@keyframes tin { from { opacity: 0; transform: translateY(8px); } }

#print-root { display: none; }

/* ── responsive ── */
@media (max-width: 1020px) {
  .local-badge span { display: none; }
  .sidebar { width: 290px; }
}
@media (max-width: 760px) {
  :root { --top-h: 52px; }
  .brand-name .hand { display: none; }
  .local-badge { padding: 4px 7px; }
  .sidebar { width: 100%; border-right: 0; }
  .main { display: none; }
  body.view-editor .sidebar { display: none; }
  body.view-editor .main { display: flex; }
  .welcome { display: none; }
  .back { display: inline-flex; }
  .ed-head { padding: 8px 8px 2px; }
  .title-input { font-size: 1.55rem; }
  #openAppBtn span { display: none; }
  #openAppBtn { padding: 8px 10px; }
  .meta-row { padding: 2px 10px 6px; }
  .ed-tabs { margin: 0 10px 6px; }
  .fmt-bar, .ink-bar { margin: 0 6px; padding: 4px 6px; flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; border-radius: 14px; }
  .fmt-bar::-webkit-scrollbar, .ink-bar::-webkit-scrollbar { display: none; }
  .tb-group { flex: none; }
  .color-pop { position: fixed; top: auto; left: 10px; right: 10px; bottom: 80px; justify-content: center; flex-wrap: wrap; }
  .body-scroll { padding: 10px 8px 60px; }
  .body-edit { padding: 18px 16px; border-radius: 14px; }
  .pages-scroll { padding: 36px 8px 80px; }
  .ink-bar .pen-only span { display: none; }
  .openapp .oa-body { grid-template-columns: 1fr; }
  .qr-box { margin: 0 auto; width: 240px; }
  .tpl-grid { grid-template-columns: repeat(auto-fill, minmax(100px, 1fr)); gap: 8px; }
  .dlg-inner { padding: 14px; }
  .page-tpl { max-width: 34vw; }
}

/* ── print: only the prepared #print-root ── */
@media print {
  @page { margin: 12mm; }
  html, body { height: auto; overflow: visible; background: #fff !important; color: #222; }
  #app, .toasts, dialog { display: none !important; }
  #print-root { display: block; --print-w: 186mm; }
  .print-text { page-break-after: always; break-after: page; font-family: 'Nunito', system-ui, sans-serif; color: #222; }
  .print-text:last-child { page-break-after: auto; break-after: auto; }
  .print-text h1 { font-family: 'Patrick Hand', cursive; font-size: 28pt; margin: 0 0 4pt; }
  .print-meta { color: #666; font-size: 10pt; margin: 0 0 14pt; }
  .print-body { font-size: 12pt; line-height: 1.6; }
  .print-body p { margin: 0; }
  .print-body ul.checklist { list-style: none; padding-left: 0; }
  .print-body ul.checklist > li::before { content: '☐  '; }
  .print-body ul.checklist > li[data-checked="true"]::before { content: '☑  '; }
  .print-page { position: relative; width: var(--pw, 186mm); margin: 0 auto; page-break-after: always; break-after: page; break-inside: avoid; overflow: hidden; }
  .print-page:last-child { page-break-after: auto; break-after: auto; }
  .print-page canvas { width: 100%; height: 100%; display: block; }
  .print-item { position: absolute; font-family: 'Patrick Hand', 'Caveat', sans-serif; line-height: 1.3; white-space: pre-wrap; word-break: break-word; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; scroll-behavior: auto !important; }
}
