:root {
  --bg: #F7F5F0;
  --surface: #FFFFFF;
  --surface-2: #F1EEE7;
  --line: #E4DFD4;
  --ink: #1B1A17;
  --ink-2: #57534A;
  --ink-3: #8C877C;
  --accent: #1F5EFF;
  --accent-ink: #FFFFFF;
  --accent-soft: #E6EDFF;
  --danger: #D4380D;
  --paper-shadow: 0 1px 2px rgba(27,26,23,.05), 0 8px 30px rgba(27,26,23,.06);
  --s-yellow: #FFE58A; --s-pink: #FFC9DA; --s-blue: #BFE0FF; --s-green: #C6F0C2; --s-purple: #DCCBFF; --s-orange: #FFD3A8;
  --s-ink: #2A2619;
  --radius: 14px;
  --font-ui: 'Instrument Sans', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --font-serif: 'Newsreader', Georgia, serif;
  --font-mono: 'JetBrains Mono', ui-monospace, Consolas, monospace;
  --font-hand: 'Caveat', 'Segoe Print', cursive;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #141412; --surface: #1C1C19; --surface-2: #24241F; --line: #33322C;
    --ink: #EEEBE3; --ink-2: #B5B1A6; --ink-3: #7F7B71;
    --accent: #6E95FF; --accent-ink: #0E1220; --accent-soft: #1D2640; --danger: #FF7A52;
    --paper-shadow: 0 1px 2px rgba(0,0,0,.3), 0 8px 30px rgba(0,0,0,.25);
    --s-yellow: #E9CB5C; --s-pink: #E9A3BB; --s-blue: #8CBDE9; --s-green: #98D293; --s-purple: #B9A2EC; --s-orange: #EBB07A;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #141412; --surface: #1C1C19; --surface-2: #24241F; --line: #33322C;
  --ink: #EEEBE3; --ink-2: #B5B1A6; --ink-3: #7F7B71;
  --accent: #6E95FF; --accent-ink: #0E1220; --accent-soft: #1D2640; --danger: #FF7A52;
  --paper-shadow: 0 1px 2px rgba(0,0,0,.3), 0 8px 30px rgba(0,0,0,.25);
  --s-yellow: #E9CB5C; --s-pink: #E9A3BB; --s-blue: #8CBDE9; --s-green: #98D293; --s-purple: #B9A2EC; --s-orange: #EBB07A;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 15px/1.5 var(--font-ui); -webkit-font-smoothing: antialiased; }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; }
svg .fill { fill: currentColor; stroke: none; }
[hidden] { display: none !important; }
.muted { color: var(--ink-3); }
.small { font-size: 13px; }

.shell { display: flex; flex-direction: column; height: 100vh; height: 100dvh; }

/* ---------- top bar ---------- */
.topbar { display: flex; align-items: center; gap: 12px; padding: 10px 16px; border-bottom: 1px solid var(--line); background: var(--bg); position: relative; z-index: 5; }
.brand { display: flex; align-items: center; gap: 9px; text-decoration: none; color: inherit; font-weight: 700; letter-spacing: -.01em; font-size: 17px; }
.brand-mark { width: 22px; height: 24px; border-radius: 6px; background: #FFD84D; position: relative; box-shadow: inset 0 -3px 0 rgba(0,0,0,.08); }
.brand-mark::before, .brand-mark::after { content: ''; position: absolute; left: 5px; right: 5px; height: 2.4px; border-radius: 2px; background: #1B1A17; top: 8px; }
.brand-mark::after { top: 13.5px; right: 9px; }
.mode-switch { display: flex; gap: 2px; padding: 3px; background: var(--surface-2); border-radius: 11px; margin-left: 8px; }
.mode { display: flex; align-items: center; gap: 7px; border: 0; background: transparent; padding: 6px 13px; border-radius: 8px; font-weight: 600; font-size: 14px; color: var(--ink-2); }
.mode.active { background: var(--surface); color: var(--ink); box-shadow: 0 1px 2px rgba(0,0,0,.08); }
.top-right { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.save-state { font-size: 13px; color: var(--ink-3); min-width: 0; white-space: nowrap; }
.save-state.saving::before { content: ''; display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: var(--ink-3); margin-right: 6px; animation: pulse 1s infinite; }
@keyframes pulse { 50% { opacity: .3; } }

.icon-btn { display: inline-grid; place-items: center; width: 36px; height: 36px; border-radius: 10px; border: 0; background: transparent; color: var(--ink-2); }
.icon-btn:hover { background: var(--surface-2); color: var(--ink); }
.btn { text-decoration: none; color: inherit; display: inline-flex; align-items: center; justify-content: center; gap: 7px; padding: 8px 14px; border-radius: 10px; border: 1px solid var(--line); background: var(--surface); font-weight: 600; font-size: 14px; white-space: nowrap; }
.btn:hover { border-color: var(--ink-3); }
.btn.primary { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.btn.primary:hover { opacity: .88; }
.btn.danger { color: var(--danger); }
.btn.block { width: 100%; }
.link-btn { border: 0; background: none; padding: 0; color: var(--accent); font-weight: 600; text-decoration: underline; text-underline-offset: 3px; }
.avatar { width: 34px; height: 34px; border-radius: 50%; border: 0; background: var(--accent-soft); color: var(--accent); font-weight: 700; font-size: 14px; }

.guest-banner { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding: 8px 16px; font-size: 13.5px; background: #FFF4C7; color: #4A3D0A; border-bottom: 1px solid #F1E2A0; }
:root[data-theme="dark"] .guest-banner { background: #2E2810; color: #F2E3A6; border-color: #463C15; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .guest-banner { background: #2E2810; color: #F2E3A6; border-color: #463C15; } }
.guest-banner .link-btn { color: inherit; }

/* ---------- layout ---------- */
.body { flex: 1; display: flex; min-height: 0; position: relative; }
.sidebar { width: 272px; flex: none; border-right: 1px solid var(--line); display: flex; flex-direction: column; min-height: 0; background: var(--bg); }
.side-head { padding: 14px; display: grid; gap: 10px; }
.search { display: flex; align-items: center; gap: 8px; padding: 0 11px; height: 38px; border-radius: 10px; background: var(--surface-2); color: var(--ink-3); }
.search input { border: 0; outline: 0; background: transparent; flex: 1; min-width: 0; color: var(--ink); }
.note-list { list-style: none; margin: 0; padding: 0 8px 16px; overflow-y: auto; flex: 1; }
.note-item { display: block; width: 100%; text-align: left; border: 0; background: transparent; padding: 10px 12px; border-radius: 10px; margin-bottom: 2px; }
.note-item:hover { background: var(--surface-2); }
.note-item.active { background: var(--surface); box-shadow: 0 0 0 1px var(--line); }
.note-item .t { font-weight: 600; font-size: 14.5px; display: flex; gap: 6px; align-items: center; overflow: hidden; }
.note-item .t span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.note-item .t svg { width: 13px; height: 13px; color: var(--ink-3); }
.note-item .p { font-size: 13px; color: var(--ink-3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; margin-top: 2px; }
.note-item .d { font-size: 12px; color: var(--ink-3); margin-top: 3px; }
.empty-list { padding: 24px 14px; color: var(--ink-3); font-size: 13.5px; text-align: center; }
.scrim { display: none; }

.pane { flex: 1; display: flex; flex-direction: column; min-width: 0; min-height: 0; }

/* ---------- toolbar ---------- */
.toolbar { display: flex; align-items: center; gap: 4px; padding: 8px 12px; border-bottom: 1px solid var(--line); overflow-x: auto; scrollbar-width: none; background: var(--bg); }
.toolbar::-webkit-scrollbar { display: none; }
.tgroup { display: flex; align-items: center; gap: 2px; padding-right: 6px; margin-right: 2px; border-right: 1px solid var(--line); flex: none; }
.tgroup:last-child { border-right: 0; }
.tgroup.push { margin-left: auto; }
.toolbar button { display: inline-flex; align-items: center; gap: 6px; height: 32px; min-width: 32px; padding: 0 7px; justify-content: center; border: 0; border-radius: 8px; background: transparent; color: var(--ink-2); font-size: 15px; }
.toolbar button:hover { background: var(--surface-2); color: var(--ink); }
.toolbar button.on { background: var(--accent-soft); color: var(--accent); }
.toolbar .lbl { font-size: 13.5px; font-weight: 600; }
.serif-i { font-family: var(--font-serif); font-size: 17px; }
.toolbar select { height: 32px; border: 0; border-radius: 8px; background: var(--surface-2); padding: 0 8px; font-size: 13.5px; font-weight: 500; cursor: pointer; }
.color-btn { position: relative; display: inline-flex; flex-direction: column; align-items: center; justify-content: center; width: 32px; height: 32px; border-radius: 8px; cursor: pointer; color: var(--ink-2); }
.color-btn:hover { background: var(--surface-2); }
.color-btn svg { width: 16px; height: 16px; margin-top: -3px; }
.color-btn .swatch { width: 16px; height: 3px; border-radius: 2px; margin-top: 1px; }
.color-btn input { position: absolute; inset: 0; opacity: 0; cursor: pointer; width: 100%; height: 100%; }
.menu-wrap { position: relative; }
.menu { position: fixed; z-index: 30; min-width: 200px; padding: 6px; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; box-shadow: 0 12px 40px rgba(0,0,0,.14); }
.menu button { display: flex; width: 100%; justify-content: flex-start; height: 36px; padding: 0 10px; font-size: 14px; color: var(--ink); }
.menu .danger { color: var(--danger); }
.menu .menu-link { display: flex; align-items: center; height: 36px; padding: 0 10px; font-size: 14px; color: var(--ink); text-decoration: none; border-radius: 8px; }
.menu .menu-link:hover { background: var(--surface-2); }
.menu hr { border: 0; border-top: 1px solid var(--line); margin: 5px 2px; }

/* ---------- paper / editor ---------- */
.paper-wrap { flex: 1; overflow-y: auto; overflow-x: hidden; padding: 32px 24px 80px; }
.paper { position: relative; max-width: 780px; margin: 0 auto; background: var(--surface); border-radius: 18px; box-shadow: var(--paper-shadow); padding: 44px 56px 64px; min-height: calc(100% - 8px); }
.title-input { width: 100%; border: 0; outline: 0; background: transparent; font: 700 32px/1.2 var(--font-ui); letter-spacing: -.02em; padding: 0; margin-bottom: 18px; color: var(--ink); }
.title-input::placeholder { color: var(--ink-3); opacity: .6; }
.editor { outline: none; min-height: 50vh; font-size: 17px; line-height: 1.7; word-wrap: break-word; caret-color: var(--accent); }
.editor { position: relative; }
.editor.is-empty::before, .editor:empty::before { content: attr(data-placeholder); position: absolute; top: 0; left: 0; color: var(--ink-3); opacity: .7; pointer-events: none; }
.editor.font-sans { font-family: var(--font-ui); }
.editor.font-serif { font-family: var(--font-serif); font-size: 19px; }
.editor.font-mono { font-family: var(--font-mono); font-size: 15px; }
.editor.font-hand { font-family: var(--font-hand); font-size: 24px; line-height: 1.5; }
.editor p, .editor div { margin: 0 0 .25em; }
.editor h1 { font-size: 1.75em; line-height: 1.25; margin: .8em 0 .35em; letter-spacing: -.02em; }
.editor h2 { font-size: 1.4em; line-height: 1.3; margin: .8em 0 .3em; letter-spacing: -.01em; }
.editor h3 { font-size: 1.15em; margin: .7em 0 .25em; }
.editor ul, .editor ol { padding-left: 1.5em; margin: .3em 0 .6em; }
.editor li { margin: .15em 0; }
.editor blockquote { margin: .6em 0; padding: .2em 0 .2em 1em; border-left: 3px solid var(--accent); color: var(--ink-2); }
.editor pre { font-family: var(--font-mono); font-size: 14px; background: var(--surface-2); padding: 12px 14px; border-radius: 10px; white-space: pre-wrap; margin: .6em 0; }
.editor code { font-family: var(--font-mono); font-size: .88em; background: var(--surface-2); padding: 1px 5px; border-radius: 5px; }
.editor a { color: var(--accent); text-underline-offset: 3px; }
.editor hr { border: 0; border-top: 1px solid var(--line); margin: 1.2em 0; }
.editor img { max-width: 100%; height: auto; border-radius: 10px; }
.editor table { border-collapse: collapse; }
.editor td, .editor th { border: 1px solid var(--line); padding: 6px 10px; }
.editor ul.checklist { list-style: none; padding-left: .2em; }
.editor ul.checklist li { position: relative; padding-left: 1.7em; }
.editor ul.checklist li::before { content: ''; position: absolute; left: 0; top: .32em; width: 1.05em; height: 1.05em; border: 1.8px solid var(--ink-3); border-radius: 5px; cursor: pointer; box-sizing: border-box; }
.editor ul.checklist li.done { color: var(--ink-3); text-decoration: line-through; }
.editor ul.checklist li.done::before { background: var(--accent) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M4 8.5l2.5 2.5L12 5.5' fill='none' stroke='white' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") center/100% no-repeat; border-color: var(--accent); }

.statusbar { display: flex; align-items: center; gap: 8px; padding: 7px 18px; border-top: 1px solid var(--line); font-size: 12.5px; color: var(--ink-3); }
.statusbar .dot { width: 3px; height: 3px; border-radius: 50%; background: var(--ink-3); }
.statusbar .grow { flex: 1; }

body.focus .sidebar, body.focus .toolbar, body.focus .statusbar, body.focus .topbar, body.focus .guest-banner { display: none; }
body.focus .paper-wrap { padding-top: 64px; }
.focus-exit { position: fixed; top: 14px; right: 16px; z-index: 40; }

/* ---------- stickies ---------- */
.stickies-pane { overflow-y: auto; padding: 28px 28px 80px; }
.sticky-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 20px; flex-wrap: wrap; max-width: 1200px; width: 100%; margin: 0 auto 22px; }
.sticky-head h1 { margin: 0; font-size: 26px; letter-spacing: -.02em; }
.sticky-head p { margin: 4px 0 0; }
.new-sticky { display: flex; align-items: center; gap: 10px; }
.color-dots { display: flex; gap: 6px; }
.color-dot { width: 28px; height: 28px; border-radius: 9px; border: 0; display: grid; place-items: center; color: var(--s-ink); box-shadow: inset 0 0 0 1px rgba(0,0,0,.06); transition: transform .12s; }
.color-dot:hover { transform: translateY(-2px); }
.color-dot svg { width: 15px; height: 15px; stroke-width: 2.4; }
.sticky-board { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 18px; max-width: 1200px; margin: 0 auto; align-items: start; }
.sticky { position: relative; border-radius: 4px 4px 18px 4px; padding: 16px 16px 12px; min-height: 210px; display: flex; flex-direction: column; color: var(--s-ink); box-shadow: 0 1px 1px rgba(0,0,0,.06), 0 10px 24px -8px rgba(0,0,0,.18); transition: transform .15s, box-shadow .15s; }
.sticky:nth-child(3n+1) { transform: rotate(-.6deg); }
.sticky:nth-child(3n+2) { transform: rotate(.5deg); }
.sticky:hover, .sticky:focus-within { transform: none; box-shadow: 0 1px 1px rgba(0,0,0,.06), 0 16px 34px -10px rgba(0,0,0,.28); z-index: 2; }
.sticky.c-yellow { background: var(--s-yellow); } .sticky.c-pink { background: var(--s-pink); } .sticky.c-blue { background: var(--s-blue); }
.sticky.c-green { background: var(--s-green); } .sticky.c-purple { background: var(--s-purple); } .sticky.c-orange { background: var(--s-orange); }
.c-yellow.color-dot { background: var(--s-yellow); } .c-pink.color-dot { background: var(--s-pink); } .c-blue.color-dot { background: var(--s-blue); }
.c-green.color-dot { background: var(--s-green); } .c-purple.color-dot { background: var(--s-purple); } .c-orange.color-dot { background: var(--s-orange); }
.sticky-title { border: 0; outline: 0; background: transparent; font: 700 16px/1.3 var(--font-ui); color: inherit; padding: 0; margin-bottom: 6px; width: 100%; }
.sticky-title::placeholder { color: rgba(42,38,25,.45); }
.sticky textarea { flex: 1; border: 0; outline: 0; resize: none; background: transparent; color: inherit; font: 500 21px/1.35 var(--font-hand); min-height: 130px; padding: 0; field-sizing: content; }
.sticky textarea::placeholder { color: rgba(42,38,25,.45); }
.sticky-foot { display: flex; align-items: center; gap: 4px; margin-top: 8px; opacity: 0; transition: opacity .15s; font-size: 12px; }
.sticky:hover .sticky-foot, .sticky:focus-within .sticky-foot { opacity: 1; }
.sticky-foot .when { margin-right: auto; color: rgba(42,38,25,.6); }
.sticky-foot button { border: 0; background: rgba(255,255,255,.35); color: var(--s-ink); width: 28px; height: 28px; border-radius: 8px; display: grid; place-items: center; }
.sticky-foot button:hover { background: rgba(255,255,255,.65); }
.sticky-foot svg { width: 15px; height: 15px; }
.sticky .mini-dots { display: flex; gap: 3px; }
.sticky .mini-dots button { width: 16px; height: 16px; border-radius: 50%; box-shadow: inset 0 0 0 1.5px rgba(0,0,0,.15); }
.sticky-empty { grid-column: 1 / -1; text-align: center; padding: 60px 20px; color: var(--ink-3); }

/* ---------- modals ---------- */
.modal { border: 0; padding: 0; background: transparent; max-width: calc(100vw - 32px); width: 420px; color: var(--ink); }
.modal::backdrop { background: rgba(20,18,14,.45); backdrop-filter: blur(3px); }
.modal-card { position: relative; background: var(--surface); border-radius: 20px; padding: 28px; box-shadow: 0 30px 80px rgba(0,0,0,.25); display: grid; gap: 14px; }
.modal-card h2 { margin: 0; font-size: 21px; letter-spacing: -.01em; }
.modal-card h3 { margin: 4px 0 0; font-size: 15px; }
.modal-card p { margin: 0; }
.modal .close { position: absolute; top: 12px; right: 12px; }
.auth-tabs { display: flex; gap: 2px; padding: 3px; background: var(--surface-2); border-radius: 11px; margin-right: 36px; }
.auth-tabs button { flex: 1; border: 0; background: transparent; padding: 7px; border-radius: 8px; font-weight: 600; color: var(--ink-2); }
.auth-tabs button.active { background: var(--surface); color: var(--ink); box-shadow: 0 1px 2px rgba(0,0,0,.08); }
.field { display: grid; gap: 6px; font-size: 13.5px; font-weight: 600; }
.field input { height: 42px; border: 1px solid var(--line); border-radius: 10px; padding: 0 12px; background: var(--bg); font-weight: 400; font-size: 15px; outline: 0; }
.field input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.check { display: flex; gap: 8px; align-items: center; font-size: 13.5px; }
.form-error { color: var(--danger); font-size: 13.5px; min-height: 0; }
.form-error:empty { display: none; }
.stack { display: grid; gap: 10px; padding-top: 14px; border-top: 1px solid var(--line); }
.switch { display: flex; align-items: center; gap: 10px; font-weight: 600; font-size: 14px; cursor: pointer; }
.switch input { appearance: none; width: 38px; height: 22px; border-radius: 11px; background: var(--line); position: relative; cursor: pointer; transition: background .15s; margin: 0; }
.switch input::after { content: ''; position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; border-radius: 50%; background: #fff; transition: transform .15s; }
.switch input:checked { background: var(--accent); }
.switch input:checked::after { transform: translateX(16px); }
.share-row { display: flex; gap: 8px; }
.share-row input { flex: 1; min-width: 0; height: 40px; border: 1px solid var(--line); border-radius: 10px; padding: 0 10px; background: var(--bg); font-size: 13.5px; }
.danger-zone h3 { color: var(--danger); }

.toast { position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 20px); background: var(--ink); color: var(--bg); padding: 10px 16px; border-radius: 12px; font-size: 14px; font-weight: 500; opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s; z-index: 50; max-width: calc(100vw - 32px); }
.toast.show { opacity: 1; transform: translate(-50%, 0); }

.only-mobile { display: none; }

/* ---------- responsive ---------- */
@media (max-width: 860px) {
  .only-mobile { display: inline-grid; }
  .sidebar { position: absolute; inset: 0 auto 0 0; z-index: 20; width: min(300px, 86vw); transform: translateX(-102%); transition: transform .2s; box-shadow: 10px 0 40px rgba(0,0,0,.15); }
  .sidebar.open { transform: none; }
  .scrim.show { display: block; position: absolute; inset: 0; background: rgba(0,0,0,.3); z-index: 15; }
  .paper-wrap { padding: 12px 10px 60px; }
  .paper { padding: 26px 20px 48px; border-radius: 14px; }
  .title-input { font-size: 26px; }
  .brand-name { display: none; }
  .mode-switch { margin-left: 0; }
  .mode { padding: 6px 10px; }
  .save-state { display: none; }
  .stickies-pane { padding: 18px 16px 60px; }
  .sticky-board { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
  .sticky { min-height: 170px; }
  .sticky-foot { opacity: 1; }
  .toolbar .lbl { display: none; }
}
@media (max-width: 420px) { .mode span { display: none; } }
@media print {
  .topbar, .sidebar, .toolbar, .statusbar, .guest-banner, .toast { display: none !important; }
  body, .paper { background: #fff; color: #000; box-shadow: none; }
  .paper-wrap { overflow: visible; padding: 0; }
  .shell { height: auto; }
}

/* ---------- stickers ---------- */
.sticker-panel { position: fixed; z-index: 30; width: 340px; max-width: calc(100vw - 16px); background: var(--surface); border: 1px solid var(--line); border-radius: 16px; box-shadow: 0 16px 50px rgba(0,0,0,.18); padding: 10px; }
.sp-tabs { display: flex; gap: 2px; padding: 3px; background: var(--surface-2); border-radius: 10px; margin-bottom: 10px; }
.sp-tabs button { flex: 1; border: 0; background: transparent; padding: 6px; border-radius: 7px; font-weight: 600; font-size: 13.5px; color: var(--ink-2); }
.sp-tabs button.active { background: var(--surface); color: var(--ink); box-shadow: 0 1px 2px rgba(0,0,0,.08); }
.sp-body { max-height: 300px; overflow-y: auto; overflow-x: hidden; }
.sp-cat { font-size: 11.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--ink-3); margin: 6px 4px 4px; }
.sp-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 2px; }
.sp-grid button { border: 0; background: transparent; font-size: 26px; line-height: 1; height: 42px; border-radius: 9px; cursor: pointer; transition: transform .1s; }
.sp-grid button:hover { background: var(--surface-2); transform: scale(1.15); }
.sp-boxes { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.sp-boxes button { border: 0; height: 64px; border-radius: 4px 4px 12px 4px; font: 500 18px var(--font-hand); color: var(--s-ink); box-shadow: 0 4px 10px -4px rgba(0,0,0,.25); }
.sp-boxes button:hover { transform: translateY(-2px); }
.sp-boxes .c-yellow { background: var(--s-yellow); } .sp-boxes .c-pink { background: var(--s-pink); } .sp-boxes .c-blue { background: var(--s-blue); }
.sp-boxes .c-green { background: var(--s-green); } .sp-boxes .c-purple { background: var(--s-purple); } .sp-boxes .c-orange { background: var(--s-orange); }
.editor .sticker { font-size: 2.4em; line-height: 1.1; vertical-align: middle; display: inline-block; margin: 0 .05em; }
.editor .note-box { margin: .8em 0; padding: 14px 16px 16px; border-radius: 4px 4px 16px 4px; color: var(--s-ink); font-family: var(--font-hand); font-size: 22px; line-height: 1.4; box-shadow: 0 1px 1px rgba(0,0,0,.05), 0 10px 22px -10px rgba(0,0,0,.3); max-width: 420px; transform: rotate(-.4deg); }
.editor .note-box.c-yellow { background: var(--s-yellow); } .editor .note-box.c-pink { background: var(--s-pink); } .editor .note-box.c-blue { background: var(--s-blue); }
.editor .note-box.c-green { background: var(--s-green); } .editor .note-box.c-purple { background: var(--s-purple); } .editor .note-box.c-orange { background: var(--s-orange); }
.editor .note-box p { margin: 0; }

/* ---------- sharing / collaboration ---------- */
.access { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.access button { display: grid; gap: 2px; text-align: left; padding: 10px 12px; border: 1px solid var(--line); border-radius: 12px; background: var(--bg); }
.access button b { font-size: 14px; }
.access button span { font-size: 12px; color: var(--ink-3); }
.access button.on { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); background: var(--surface); }
.shared-tag { color: var(--accent); font-weight: 600; }
.collab-bar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding: 8px 16px; font-size: 13.5px; background: var(--accent-soft); color: var(--ink); border-bottom: 1px solid var(--line); }
.collab-bar svg { color: var(--accent); }
.cb-name { margin-left: auto; display: flex; align-items: center; gap: 8px; font-weight: 600; }
.cb-name input { height: 32px; border: 1px solid var(--line); border-radius: 8px; padding: 0 10px; background: var(--surface); font-weight: 400; width: 190px; outline: 0; }
.cb-name input:focus { border-color: var(--accent); }
body.collab .sidebar, body.collab .mode-switch, body.collab #menuBtn, body.collab #guestBanner, body.collab #accountArea,
body.collab [data-act="pin"], body.collab [data-act="share"], body.collab [data-act="delete"], body.collab #moreMenu hr { display: none !important; }
@media (max-width: 860px) { .access { grid-template-columns: 1fr; } .cb-name { margin-left: 0; } .cb-name input { width: 150px; } }

/* ---------- sticker wall ---------- */
.sticker-wall { position: absolute; inset: 0; pointer-events: none; z-index: 3; overflow: visible; }
.wall-item { position: absolute; pointer-events: auto; transform: rotate(var(--r, 0deg)); touch-action: none; user-select: none; -webkit-user-select: none; transition: transform .15s, filter .15s; }
.wall-emoji { line-height: 1; cursor: grab; filter: drop-shadow(0 4px 6px rgba(0,0,0,.18)); padding: .04em; }
.wall-emoji:hover, .wall-item.sel.wall-emoji { filter: drop-shadow(0 8px 14px rgba(0,0,0,.25)); }
.wall-item.dragging { cursor: grabbing; transform: rotate(var(--r, 0deg)) scale(1.06); transition: none; z-index: 10; filter: drop-shadow(0 16px 22px rgba(0,0,0,.3)); }
.wall-box { min-height: 110px; padding: 22px 14px 14px; border-radius: 3px 3px 18px 3px; color: var(--s-ink); box-shadow: 0 1px 1px rgba(0,0,0,.06), 0 12px 26px -10px rgba(0,0,0,.35); display: flex; flex-direction: column; }
.wall-box.c-yellow { background: var(--s-yellow); } .wall-box.c-pink { background: var(--s-pink); } .wall-box.c-blue { background: var(--s-blue); }
.wall-box.c-green { background: var(--s-green); } .wall-box.c-purple { background: var(--s-purple); } .wall-box.c-orange { background: var(--s-orange); }
.wall-tape { position: absolute; top: -9px; left: 50%; width: 74px; height: 22px; transform: translateX(-50%) rotate(-2deg); background: rgba(255,255,255,.55); border: 1px solid rgba(0,0,0,.05); box-shadow: 0 1px 2px rgba(0,0,0,.08); cursor: grab; }
.wall-tape::after { content: ''; position: absolute; inset: 0; background: repeating-linear-gradient(90deg, transparent 0 6px, rgba(0,0,0,.035) 6px 7px); }
.wall-text { flex: 1; outline: none; font: 500 21px/1.35 var(--font-hand); white-space: pre-wrap; word-break: break-word; cursor: text; user-select: text; -webkit-user-select: text; min-height: 70px; }
.wall-text:empty::before { content: attr(data-placeholder); color: rgba(42,38,25,.45); }
.wall-del { position: absolute; top: -10px; right: -10px; width: 24px; height: 24px; border-radius: 50%; border: 0; background: var(--ink); color: var(--bg); font-size: 16px; line-height: 1; display: grid; place-items: center; opacity: 0; transition: opacity .12s; padding: 0; z-index: 2; font-family: var(--font-ui); }
.wall-size { position: absolute; right: -6px; bottom: -6px; width: 16px; height: 16px; border-radius: 5px; background: var(--surface); border: 2px solid var(--accent); cursor: nwse-resize; opacity: 0; transition: opacity .12s; }
.wall-item:hover .wall-del, .wall-item.sel .wall-del, .wall-item:hover .wall-size, .wall-item.sel .wall-size { opacity: 1; }
@media print { .wall-del, .wall-size { display: none !important; } }

/* ---------- phones & small screens ---------- */
@media (max-width: 860px) {
  .topbar { padding: 8px 10px; gap: 8px; padding-left: max(10px, env(safe-area-inset-left)); padding-right: max(10px, env(safe-area-inset-right)); }
  /* most-used buttons first; Copy/More stay pinned on the right while the rest scrolls */
  .toolbar { padding: 6px 8px; gap: 2px; scroll-snap-type: x proximity; }
  .toolbar .tgroup { padding-right: 4px; }
  .toolbar .tgroup:nth-child(1) { order: 6; }  /* undo/redo */
  .toolbar .tgroup:nth-child(2) { order: 5; }  /* text style / font / size */
  .toolbar .tgroup:nth-child(3) { order: 1; }  /* bold, italic, colours */
  .toolbar .tgroup:nth-child(4) { order: 2; }  /* lists */
  .toolbar .tgroup:nth-child(6) { order: 3; }  /* link, sticker, date */
  .toolbar .tgroup:nth-child(5) { order: 4; }  /* align */
  .toolbar .tgroup.push { order: 9; position: sticky; right: -8px; background: var(--bg); padding-left: 6px; margin-left: auto; box-shadow: -10px 0 12px -6px var(--bg); }
  .toolbar button { min-width: 36px; height: 36px; }
  .toolbar select { height: 34px; }
  .paper-wrap { padding: 10px 8px 70px; }
  .paper { padding: 22px 18px 40px; }
  .editor { font-size: 17px; }
  .statusbar { padding: 6px 12px calc(6px + env(safe-area-inset-bottom)); }
  /* iOS zooms into inputs under 16px — keep them at 16 */
  .search input, .field input, .cb-name input, .share-row input, .sticky textarea, .tools input { font-size: 16px; }
  .collab-bar { padding: 7px 10px; gap: 8px; font-size: 13px; flex-wrap: nowrap; }
  .collab-bar .cb-more, .collab-bar .cb-label { display: none; }
  .collab-bar .cb-text { flex: 1; min-width: 0; line-height: 1.3; }
  .cb-name { margin-left: 0; flex: none; }
  .cb-name input { width: 120px; height: 34px; }
  .guest-banner { padding: 7px 10px; font-size: 12.5px; gap: 6px; }
  .sticker-panel { left: 8px !important; right: 8px; width: auto; }
  .sp-grid button { height: 44px; font-size: 24px; }
  .modal-card { padding: 22px 18px; border-radius: 18px; }
  .wall-del { width: 28px; height: 28px; top: -12px; right: -12px; }
  .wall-size { width: 20px; height: 20px; }
  .wall-text { font-size: 19px; }
}
@media (max-width: 420px) {
  .guest-banner > svg { display: none; }
  .collab-bar > svg { display: none; }
}

.paper-wrap { position: relative; }

/* ---------- history drawer ---------- */
.history { width: 340px; flex: none; border-left: 1px solid var(--line); background: var(--bg); display: flex; flex-direction: column; min-height: 0; }
.history-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; padding: 16px 16px 10px; border-bottom: 1px solid var(--line); }
.history-head h2 { margin: 0; font-size: 17px; }
.history-head p { margin: 2px 0 0; }
.history-list { flex: 1; overflow-y: auto; padding: 6px 14px 40px; }
.h-empty { padding: 20px 4px; }
.h-day { font-size: 11.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--ink-3); margin: 16px 2px 6px; }
.h-item { display: flex; gap: 10px; padding: 10px 4px; border-bottom: 1px solid var(--line); }
.h-item:last-child { border-bottom: 0; }
.h-av { width: 30px; height: 30px; border-radius: 50%; flex: none; display: grid; place-items: center; color: #fff; font-weight: 700; font-size: 13px; }
.h-body { min-width: 0; flex: 1; }
.h-who { font-size: 14px; }
.h-who .muted { font-size: 12.5px; }
.h-when { font-size: 12px; color: var(--ink-3); margin: 1px 0 6px; }
.h-changes { display: grid; gap: 3px; }
.h-line { font-size: 13px; line-height: 1.4; padding: 3px 8px; border-radius: 6px; word-break: break-word; display: flex; gap: 6px; }
.h-line span { font-weight: 700; flex: none; }
.h-add { background: color-mix(in srgb, #12917B 14%, transparent); }
.h-add span { color: #12917B; }
.h-del { background: color-mix(in srgb, #D4380D 12%, transparent); text-decoration: line-through; text-decoration-color: color-mix(in srgb, var(--ink) 40%, transparent); color: var(--ink-2); }
.h-del span { color: var(--danger); text-decoration: none; }
.h-meta { color: var(--ink-2); padding-left: 2px; }
.h-restore { margin-top: 8px; border: 1px solid var(--line); background: var(--surface); border-radius: 8px; padding: 5px 10px; font-size: 12.5px; font-weight: 600; }
.h-restore:hover { border-color: var(--ink-3); }
@media (max-width: 1100px) { .history { width: 300px; } }
@media (max-width: 860px) {
  .history { position: absolute; inset: 0; width: 100%; z-index: 25; border-left: 0; }
  .history-head { padding: 12px 14px 10px; }
}
body.focus .history { display: none; }

/* ---------- header note actions ---------- */
.note-actions { display: flex; align-items: center; gap: 2px; margin-left: 10px; min-width: 0; }
.hbtn { display: inline-flex; align-items: center; gap: 6px; height: 34px; padding: 0 10px; border: 0; border-radius: 9px; background: transparent; color: var(--ink-2); font-weight: 600; font-size: 13.5px; white-space: nowrap; }
.hbtn:hover { background: var(--surface-2); color: var(--ink); }
.hbtn svg { width: 17px; height: 17px; }
.hbtn .chev { width: 14px; height: 14px; margin-left: -3px; opacity: .7; }
.hbtn.icon { width: 34px; padding: 0; justify-content: center; }
.menu-label { font-size: 11.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--ink-3); padding: 6px 10px 4px; }
.menu-hint { font-size: 12px; color: var(--ink-3); padding: 4px 10px 6px; }
.menu { max-height: calc(100vh - 80px); overflow-y: auto; min-width: 230px; }
.only-narrow { display: none !important; }
@media (max-width: 1180px) { .note-actions .hbtn span { display: none; } .note-actions .hbtn { padding: 0 8px; } .note-actions .hbtn .chev { display: none; } }
@media (max-width: 860px) {
  .note-actions { margin-left: auto; }
  .note-actions > #historyBtn, .note-actions > #shareBtn { display: none !important; }
  .only-narrow { display: flex !important; }
  .top-right { margin-left: 4px; }
}
@media (max-width: 420px) { .note-actions .hbtn { padding: 0 6px; } #themeBtn { display: none; } }

/* ---------- attachments ---------- */
.editor .attach { display: inline-flex; align-items: center; gap: 10px; max-width: 100%; margin: 6px 0; padding: 8px 14px 8px 8px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface-2); cursor: pointer; user-select: none; vertical-align: middle; font-family: var(--font-ui); font-size: 14px; line-height: 1.3; }
.editor .attach:hover { border-color: var(--ink-3); }
.editor .att-ic { flex: none; width: 38px; height: 44px; border-radius: 6px; display: grid; place-items: center; font-size: 10.5px; font-weight: 800; letter-spacing: .03em; color: #fff; background: #57534A; }
.editor .attach[data-kind="PDF"] .att-ic { background: #C8371D; }
.editor .attach[data-kind="DOC"] .att-ic { background: #1F5EFF; }
.editor .attach[data-kind="XLS"] .att-ic { background: #12917B; }
.editor .attach[data-kind="PPT"] .att-ic { background: #C2621A; }
.editor .attach[data-kind="IMG"] .att-ic { background: #8B5CF6; }
.editor .att-name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 380px; }
.editor .att-meta { color: var(--ink-3); font-size: 12.5px; white-space: nowrap; }
#attachMenu { position: fixed; z-index: 40; }
#attachMenu .menu-label { text-transform: none; letter-spacing: 0; font-size: 12.5px; max-width: 260px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- tables (imported Excel / inserted) ---------- */
.editor table { border-collapse: collapse; margin: .6em 0; font-size: .92em; max-width: 100%; display: block; overflow-x: auto; }
.editor td, .editor th { border: 1px solid var(--line); padding: 6px 10px; min-width: 60px; vertical-align: top; }
.editor th { background: var(--surface-2); font-weight: 600; text-align: left; }
.editor td:focus-within, .editor th:focus-within { outline: 2px solid var(--accent-soft); }

/* ---------- drag & drop ---------- */
.drop-hint { position: fixed; inset: 0; z-index: 60; background: color-mix(in srgb, var(--accent) 12%, transparent); display: grid; place-items: center; pointer-events: none; border: 3px dashed var(--accent); }
.drop-hint div { background: var(--surface); padding: 18px 24px; border-radius: 16px; font-weight: 700; text-align: center; box-shadow: 0 20px 50px rgba(0,0,0,.2); }
.drop-hint small { display: block; font-weight: 500; color: var(--ink-3); margin-top: 4px; }

/* PDF export page (rendered off-screen in light colours) */
.pdf-page { width: 182mm; color: #1B1A17; background: #fff; font-size: 12pt; line-height: 1.55; }
.pdf-page h1 { font-size: 22pt; margin: 0 0 10pt; }
.pdf-page table { display: table; }
.pdf-page td, .pdf-page th { border: 1px solid #bbb; }
.pdf-page th { background: #f1eee7; }
.pdf-page tr, .pdf-page img { page-break-inside: avoid; }

/* menus live outside the toolbar now — reset their buttons here */
.menu button { display: flex; align-items: center; width: 100%; height: 36px; padding: 0 10px; border: 0; border-radius: 8px; background: transparent; color: var(--ink); font-size: 14px; text-align: left; cursor: pointer; white-space: nowrap; }
.menu button:hover { background: var(--surface-2); }
.menu button.danger { color: var(--danger); }

/* ---------- spreadsheet-style tables ---------- */
.editor td.num { text-align: right; font-variant-numeric: tabular-nums; }
.editor td.cell-active, .editor th.cell-active { outline: 2px solid var(--accent); outline-offset: -1px; background: color-mix(in srgb, var(--accent) 7%, transparent); }
.editor td[data-formula]:not(.cell-active), .editor th[data-formula]:not(.cell-active) { background-image: linear-gradient(225deg, color-mix(in srgb, var(--accent) 60%, transparent) 0 5px, transparent 5px); }
.editor .f-err { color: var(--danger) !important; font-weight: 600; }
.table-bar { position: fixed; z-index: 25; display: flex; align-items: center; gap: 8px; padding: 6px; max-width: min(860px, calc(100vw - 24px)); background: var(--surface); border: 1px solid var(--line); border-radius: 12px; box-shadow: 0 10px 30px rgba(0,0,0,.12); flex-wrap: wrap; }
.table-bar[hidden], .ruler[hidden] { display: none; }
.cell-addr { min-width: 42px; height: 30px; display: grid; place-items: center; padding: 0 8px; border-radius: 8px; background: var(--surface-2); font: 600 13px/1 ui-monospace, Menlo, Consolas, monospace; color: var(--ink-2); }
.fx-wrap { display: flex; align-items: center; gap: 6px; flex: 1 1 220px; min-width: 180px; height: 30px; padding: 0 8px; border: 1px solid var(--line); border-radius: 8px; background: var(--bg); }
.fx { font: italic 600 13px/1 Georgia, serif; color: var(--ink-3); }
#fxInput { flex: 1; min-width: 0; border: 0; outline: 0; background: transparent; color: var(--ink); font: 13.5px/1 ui-monospace, Menlo, Consolas, monospace; }
.tb-btns { display: flex; align-items: center; gap: 2px; flex-wrap: wrap; }
.tb-btns button { height: 30px; padding: 0 9px; border: 0; border-radius: 8px; background: transparent; color: var(--ink-2); font-size: 12.5px; font-weight: 600; white-space: nowrap; cursor: pointer; }
.tb-btns button:hover { background: var(--surface-2); color: var(--ink); }
.tb-btns button.danger { color: var(--danger); }
.tb-sep { width: 1px; height: 18px; background: var(--line); margin: 0 3px; }
.ruler span { position: fixed; z-index: 5; display: grid; place-items: center; font: 600 11px/1 ui-monospace, Menlo, Consolas, monospace; color: var(--ink-3); pointer-events: none; }
#rulerCols span { height: 18px; }
#rulerRows span { width: 22px; }
.ruler span.on { color: var(--accent); }
@media (max-width: 860px) {
  .table-bar { left: 0; right: 0; max-width: none; border-radius: 0; border-width: 0 0 1px; flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; gap: 6px; }
  .fx-wrap { flex: 0 0 200px; }
  .tb-btns { flex-wrap: nowrap; }
  #fxInput { font-size: 16px; }
}

/* ---------- pictures in the text ---------- */
.editor img { max-width: 100%; height: auto; border-radius: 4px; vertical-align: bottom; cursor: pointer; }
.editor img.img-left { float: left; margin: 4px 18px 10px 0; }
.editor img.img-right { float: right; margin: 4px 0 10px 18px; }
.editor img.img-center { display: block; margin: 10px auto; }
.editor img.img-sel { outline: 2px solid var(--accent); outline-offset: 2px; }
.editor::after { content: ""; display: block; clear: both; }
.img-bar { position: fixed; z-index: 26; display: flex; align-items: center; gap: 2px; padding: 5px; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; box-shadow: 0 10px 30px rgba(0,0,0,.14); max-width: calc(100vw - 16px); overflow-x: auto; scrollbar-width: none; }
.img-bar[hidden], .img-handle[hidden], .table-grip[hidden], .drop-line[hidden] { display: none; }
.img-bar button { height: 30px; padding: 0 9px; border: 0; border-radius: 8px; background: transparent; color: var(--ink-2); font-size: 12.5px; font-weight: 600; white-space: nowrap; cursor: pointer; }
.img-bar button:hover { background: var(--surface-2); color: var(--ink); }
.img-bar button.on { background: var(--accent-soft); color: var(--accent); }
.img-bar button.danger { color: var(--danger); }
.img-handle { position: fixed; z-index: 26; width: 18px; height: 18px; border-radius: 50%; background: var(--accent); border: 3px solid var(--surface); box-shadow: 0 2px 8px rgba(0,0,0,.25); cursor: nwse-resize; touch-action: none; }

/* ---------- table resize + move ---------- */
.editor.col-resize, .editor.col-resize td, .editor.col-resize th { cursor: col-resize; }
.table-grip { position: fixed; z-index: 24; width: 22px; height: 22px; padding: 0; display: grid; place-items: center; border: 1px solid var(--line); border-radius: 6px; background: var(--surface); color: var(--ink-3); cursor: grab; touch-action: none; }
.table-grip:hover { color: var(--accent); border-color: var(--accent); }
.table-grip:active { cursor: grabbing; }
.table-grip svg { width: 16px; height: 16px; }
.drop-line { position: fixed; z-index: 30; height: 4px; border-radius: 2px; background: var(--accent); pointer-events: none; }
.editor table.tbl-moving { opacity: .45; }

/* undo / redo with nothing left to step through */
.toolbar [data-cmd].dim { opacity: .35; }

/* ---------- AI assistant ---------- */
.ai-btn svg { color: #8B5CF6; }
.ai-body { flex: 1; overflow-y: auto; padding: 12px 14px 40px; display: grid; gap: 12px; align-content: start; }
.ai-tasks { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { height: 30px; padding: 0 11px; border: 1px solid var(--line); border-radius: 999px; background: var(--surface); color: var(--ink-2); font-size: 12.5px; font-weight: 600; cursor: pointer; }
.chip:hover { border-color: var(--ink-3); color: var(--ink); }
.chip.on { background: var(--ink); border-color: var(--ink); color: var(--bg); }
.ai-field { display: grid; gap: 5px; font-size: 12.5px; font-weight: 600; color: var(--ink-2); flex: 1; min-width: 0; }
.ai-field select, .ai-field input { height: 38px; border: 1px solid var(--line); border-radius: 10px; padding: 0 10px; background: var(--surface); color: var(--ink); font-size: 14px; font-weight: 400; min-width: 0; width: 100%; }
.ai-row { display: flex; gap: 8px; }
.ai-body textarea { width: 100%; resize: vertical; min-height: 64px; border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; background: var(--surface); color: var(--ink); font: inherit; font-size: 14.5px; line-height: 1.45; outline: 0; }
.ai-body textarea:focus, .ai-field select:focus, .ai-field input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); outline: 0; }
.ai-source { font-size: 12.5px; color: var(--ink-3); }
.ai-source:empty { display: none; }
.ai-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.ai-actions .grow { flex: 1; }
.ai-out { border: 1px solid var(--line); border-radius: 12px; background: var(--surface); padding: 12px 14px; font-size: 14.5px; line-height: 1.55; max-height: 46vh; overflow-y: auto; margin-bottom: 8px; }
.ai-out > :first-child { margin-top: 0; } .ai-out > :last-child { margin-bottom: 0; }
.ai-out h1, .ai-out h2 { font-size: 1.15em; } .ai-out h3 { font-size: 1.05em; }
.ai-out img { width: 100%; border-radius: 8px; cursor: default; }
.ai-loading { display: flex; align-items: center; gap: 10px; color: var(--ink-2); font-size: 13.5px; padding: 10px 2px; }
.dot-pulse { width: 10px; height: 10px; border-radius: 50%; background: #8B5CF6; animation: aiPulse 1s ease-in-out infinite; }
@keyframes aiPulse { 0%, 100% { transform: scale(.6); opacity: .5; } 50% { transform: scale(1.1); opacity: 1; } }
.ai-empty { display: grid; gap: 10px; justify-items: start; padding: 10px 2px; }
.ai-empty h3 { margin: 0; font-size: 16px; } .ai-empty p { margin: 0; font-size: 13.5px; }
.ai-spark { width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; background: color-mix(in srgb, #8B5CF6 15%, transparent); color: #8B5CF6; font-size: 20px; }
/* settings dialog */
.modal.wide { width: 620px; }
.modal.wide .modal-card { max-height: calc(100vh - 40px); overflow-y: auto; }
#aiDialogBody section { display: grid; gap: 10px; padding-top: 6px; }
#aiDialogBody section + section { border-top: 1px solid var(--line); padding-top: 16px; margin-top: 4px; }
.conn-list { display: grid; gap: 6px; }
.conn { display: flex; align-items: center; gap: 10px; padding: 9px 10px; border: 1px solid var(--line); border-radius: 12px; background: var(--bg); }
.conn-main { display: grid; gap: 1px; flex: 1; min-width: 0; }
.conn-main b { font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.conn-badge { flex: none; min-width: 52px; height: 26px; padding: 0 8px; display: grid; place-items: center; border-radius: 7px; font-size: 10.5px; font-weight: 800; letter-spacing: .02em; background: var(--surface-2); color: var(--ink-2); }
.conn-badge.p-openai { background: #12917B; color: #fff; } .conn-badge.p-anthropic { background: #C2621A; color: #fff; }
.conn-badge.p-bedrock { background: #1F5EFF; color: #fff; } .conn-badge.p-compatible { background: #8B5CF6; color: #fff; }
.link-btn.danger { color: var(--danger); }
.conn-add summary, .howto summary { cursor: pointer; font-weight: 700; font-size: 14px; padding: 4px 0; }
.conn-add form { margin-top: 10px; }
.seg { display: flex; flex-wrap: wrap; gap: 4px; padding: 4px; border-radius: 12px; background: var(--surface-2); }
.seg label { flex: 1; min-width: 90px; }
.seg input { position: absolute; opacity: 0; pointer-events: none; }
.seg span { display: block; text-align: center; padding: 7px 8px; border-radius: 9px; font-size: 13px; font-weight: 600; color: var(--ink-2); cursor: pointer; }
.seg input:checked + span { background: var(--surface); color: var(--ink); box-shadow: 0 1px 3px rgba(0,0,0,.12); }
.seg input:focus-visible + span { outline: 2px solid var(--accent); }
.token-row { display: flex; gap: 8px; }
.token-row input { flex: 1; min-width: 0; height: 40px; border: 1px solid var(--line); border-radius: 10px; padding: 0 12px; background: var(--bg); color: var(--ink); font-size: 14px; }
.token-new { border: 1px solid var(--accent); background: var(--accent-soft); border-radius: 12px; padding: 12px; display: grid; gap: 8px; }
.token-new input { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 13px; }
#aiDialogBody pre { margin: 4px 0 8px; padding: 10px 12px; border-radius: 10px; background: var(--surface-2); font-size: 12px; white-space: pre-wrap; word-break: break-all; }
.howto p { margin: 8px 0 0; }
@media (max-width: 860px) { .note-actions .ai-btn span { display: none; } .ai-row { flex-direction: column; } }

/* ---------- teacher marks + AI picture option ---------- */
.editor del.tutor-del, .ai-hint del.tutor-del, .ai-out del.tutor-del { color: #D23B2A; text-decoration: line-through 2px #D23B2A; background: color-mix(in srgb, #D23B2A 9%, transparent); border-radius: 3px; padding: 0 2px; }
.editor ins.tutor-ins, .ai-hint ins.tutor-ins, .ai-out ins.tutor-ins { color: #12804A; text-decoration: none; background: color-mix(in srgb, #12917B 14%, transparent); border-radius: 3px; padding: 0 2px; font-weight: 600; }
:root[data-theme="dark"] .editor ins.tutor-ins { color: #4CD39A; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .editor ins.tutor-ins { color: #4CD39A; } :root:not([data-theme="light"]) .editor del.tutor-del { color: #FF7A6B; text-decoration-color: #FF7A6B; } }
:root[data-theme="dark"] .editor del.tutor-del { color: #FF7A6B; text-decoration-color: #FF7A6B; }
.editor .tutor-note { margin: 12px 0 16px; padding: 12px 16px 10px; border-left: 4px solid #12917B; border-radius: 10px; background: color-mix(in srgb, #12917B 8%, var(--surface)); font-size: .93em; line-height: 1.5; }
.editor .tutor-note p { margin: 0 0 6px; }
.editor .tutor-note ul { margin: 2px 0 8px; padding-left: 20px; }
.editor .tutor-note .tn-head { font-weight: 600; }
.editor .tutor-note .tn-label { margin-top: 8px; font-size: .82em; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; color: var(--ink-3); }
.editor .tutor-note .tn-fixed { font-style: italic; }
.editor .tutor-note .tn-small { font-size: .9em; color: var(--ink-2); }
.ai-hint { margin: 0; font-size: 12.5px; color: var(--ink-2); line-height: 1.5; }
.ai-pic { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.ai-pic select { flex: 1; min-width: 140px; height: 34px; border: 1px solid var(--line); border-radius: 9px; padding: 0 8px; background: var(--surface); color: var(--ink); font-size: 13px; }
.ai-check { display: inline-flex; align-items: center; gap: 7px; font-size: 13px; font-weight: 600; color: var(--ink-2); cursor: pointer; }
.ai-check input { width: 16px; height: 16px; accent-color: #8B5CF6; }

/* ---------- note list actions + archive ---------- */
.note-list li { position: relative; }
.ni-more { position: absolute; top: 8px; right: 6px; width: 28px; height: 28px; border: 0; border-radius: 8px; background: transparent; color: var(--ink-3); display: grid; place-items: center; opacity: 0; transition: opacity .12s; cursor: pointer; }
.ni-more svg { width: 18px; height: 18px; }
.note-list li:hover .ni-more, .ni-more:focus-visible, .note-item.active + .ni-more { opacity: 1; }
.ni-more:hover { background: var(--surface-2); color: var(--ink); }
@media (hover: none) { .ni-more { opacity: 1; } }
.note-item .t { padding-right: 26px; }
.list-head { display: flex; align-items: center; justify-content: space-between; padding: 6px 8px 8px; font-size: 12.5px; font-weight: 700; color: var(--ink-3); }
.list-foot { padding: 8px 4px 16px; }
.archived-btn { display: flex; align-items: center; gap: 8px; width: 100%; height: 36px; padding: 0 10px; border: 1px dashed var(--line); border-radius: 10px; background: transparent; color: var(--ink-2); font-size: 13px; font-weight: 600; cursor: pointer; }
.archived-btn:hover { border-color: var(--ink-3); color: var(--ink); }
.archived-btn svg { width: 16px; height: 16px; }
#noteItemMenu { min-width: 210px; }
.ai-done { padding: 10px 12px; border-radius: 10px; background: color-mix(in srgb, #12917B 12%, transparent); color: var(--ink); font-weight: 600; font-size: 13.5px; }

/* ---------- selection bar ---------- */
.sel-bar { position: fixed; z-index: 60; background: var(--surface); color: var(--ink); border: 1px solid var(--line); border-radius: 12px; box-shadow: 0 10px 30px rgba(0,0,0,.18); padding: 4px; }
.sel-bar.wide { width: min(430px, calc(100vw - 16px)); }
.sb-row { display: flex; align-items: center; gap: 2px; }
.sb-row button { height: 32px; min-width: 32px; padding: 0 8px; border: 0; border-radius: 8px; background: transparent; color: var(--ink); font-size: 14px; display: inline-grid; place-items: center; cursor: pointer; }
.sb-row button:hover { background: var(--surface-2); }
.sb-row svg { width: 17px; height: 17px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.sb-row .sb-ai-btn { font-weight: 700; font-size: 13px; color: #7C4DFF; }
:root[data-theme="dark"] .sb-row .sb-ai-btn { color: #B69CFF; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .sb-row .sb-ai-btn { color: #B69CFF; } }
.sb-sep { width: 1px; height: 20px; background: var(--line); margin: 0 3px; }
.sb-ai { padding: 6px 4px 4px; display: grid; gap: 7px; }
.sb-ai input { height: 36px; border: 1px solid var(--line); border-radius: 9px; padding: 0 10px; background: var(--bg, var(--surface)); color: var(--ink); font-size: 14px; outline: none; }
.sb-ai input:focus { border-color: #8B5CF6; }
.sb-chips { display: flex; flex-wrap: wrap; gap: 5px; }
.sb-chips button { height: 27px; padding: 0 10px; border: 1px solid var(--line); border-radius: 999px; background: transparent; color: var(--ink-2); font-size: 12.5px; font-weight: 600; cursor: pointer; }
.sb-chips button:hover { border-color: #8B5CF6; color: var(--ink); }
.sb-status { font-size: 12.5px; color: var(--ink-2); display: flex; align-items: center; gap: 8px; min-height: 0; }
.sb-status:empty { display: none; }
.sel-bar.busy .sb-chips, .sel-bar.busy input { opacity: .5; pointer-events: none; }
::highlight(ai-pending) { background-color: rgba(139, 92, 246, .28); }

/* ---------- boxes, highlights, bookmarks ---------- */
.editor .callout { margin: 14px 0; padding: 12px 16px; border: 1px solid var(--line); border-left: 4px solid #8B5CF6; border-radius: 12px; background: color-mix(in srgb, #8B5CF6 6%, var(--surface)); }
.editor .callout > :first-child { margin-top: 0; }
.editor .callout > :last-child { margin-bottom: 0; }
.editor mark { background: #FFE58A; color: #1d1d1d; border-radius: 3px; padding: 0 2px; }
.editor .bookmarked { position: relative; }
.editor .bookmarked::before { content: ''; position: absolute; left: -24px; top: .25em; width: 11px; height: 16px; background: #E5484D; clip-path: polygon(0 0, 100% 0, 100% 100%, 50% 72%, 0 100%); }
.editor .flash { animation: bmflash 1.4s ease; }
@keyframes bmflash { 0%, 40% { background: color-mix(in srgb, #FFE58A 70%, transparent); } 100% { background: transparent; } }
.bm-btn { display: inline-flex; align-items: center; gap: 4px; height: 24px; padding: 0 8px; margin-right: 10px; border: 1px solid var(--line); border-radius: 999px; background: transparent; color: var(--ink-2); font-size: 12px; font-weight: 700; cursor: pointer; }
.bm-btn svg { width: 12px; height: 12px; fill: #E5484D; stroke: none; }
.bm-menu { position: fixed; max-width: 320px; max-height: 50vh; overflow: auto; }
.bm-menu .bm-head { margin: 4px 10px 6px; font-size: 11.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--ink-3); }
.bm-menu button { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }

/* ---------- Teacher mode ---------- */
.teach-btn.on { background: color-mix(in srgb, #12917B 16%, transparent); color: #12917B; }
:root[data-theme="dark"] .teach-btn.on { color: #4CD39A; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .teach-btn.on { color: #4CD39A; } }
.teach-bar { display: flex; align-items: center; gap: 8px; margin-right: 12px; min-width: 0; flex-wrap: wrap; font-size: 12.5px; }
.teach-bar .tb-name { font-weight: 700; color: #12917B; white-space: nowrap; }
.teach-bar .tb-state { color: var(--ink-2); display: inline-flex; align-items: center; gap: 6px; }
.teach-bar button { height: 24px; padding: 0 9px; border: 1px solid var(--line); border-radius: 999px; background: transparent; color: var(--ink-2); font-size: 12px; font-weight: 600; cursor: pointer; }
.teach-bar button:hover { color: var(--ink); border-color: var(--ink-3); }
.editor .tutor-pending { background: linear-gradient(90deg, transparent, color-mix(in srgb, #12917B 10%, transparent), transparent); background-size: 200% 100%; animation: tpend 1.4s linear infinite; border-radius: 6px; }
@keyframes tpend { from { background-position: 200% 0; } to { background-position: -200% 0; } }
.editor ins.tutor-ins, .editor del.tutor-del { cursor: pointer; }
.editor .tutor-why { margin: -2px 0 12px; padding: 6px 10px; border-left: 3px solid #12917B; border-radius: 0 8px 8px 0; background: color-mix(in srgb, #12917B 7%, transparent); font-size: .84em; line-height: 1.5; color: var(--ink-2); user-select: none; }
.editor li > .tutor-why { display: block; margin: 4px 0 6px; }
.editor .tutor-why > span { display: block; }
.editor .tutor-why del.tutor-del, .editor .tutor-why ins.tutor-ins { cursor: default; }
@media (max-width: 720px) { .teach-btn span { display: none; } }
