/* VS-KnowledgeBase
   Layout: helpdesk split view. Searchable note list on the left, the open note on the right; stacks on phones. */
:root {
  --bg: #f2f4f7; --surface: #ffffff; --sunk: #e8ecf2; --ink: #162030; --muted: #5a6578; --faint: #8b95a6; --line: #d5dbe4;
  --accent: #1d58b8; --accent-soft: #e2ebfa; --accent-ink: #ffffff;
  --fix: #1c7448; --fix-bg: #dff1e6;
  --danger: #b42318; --danger-bg: #fde4e1; --mark: #ffe17a; --code-bg: #f5f7fa;
  --shadow: 0 1px 2px rgba(22,32,48,.06), 0 8px 24px rgba(22,32,48,.08);
  --f-display: "Segoe UI Variable Display", "Segoe UI", system-ui, -apple-system, sans-serif;
  --f-body: "Segoe UI Variable Text", "Segoe UI", system-ui, -apple-system, sans-serif;
  --f-mono: "Cascadia Mono", "Cascadia Code", Consolas, ui-monospace, Menlo, monospace;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0e131b; --surface: #151c27; --sunk: #1c2532; --ink: #e5eaf1; --muted: #9aa5b7; --faint: #6c788b; --line: #29323f;
    --accent: #7aa8ff; --accent-soft: #1c2c48; --accent-ink: #0b1424;
    --fix: #62d49b; --fix-bg: #133524;
    --danger: #ff8f85; --danger-bg: #3d1714; --mark: #6a5712; --code-bg: #111821;
    --shadow: 0 1px 2px rgba(0,0,0,.3), 0 8px 24px rgba(0,0,0,.35);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font-family: var(--f-body); font-size: 15px; line-height: 1.55; -webkit-font-smoothing: antialiased; }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
mark { background: var(--mark); color: inherit; border-radius: 2px; padding: 0 1px; }
[hidden] { display: none !important; }
img { max-width: 100%; }

.app { display: grid; grid-template-rows: auto auto 1fr; height: 100%; max-width: 1440px; margin: 0 auto; padding-inline: 16px; }

/* ---------- top bar ---------- */
.top { display: flex; align-items: center; gap: 16px; padding-block: 16px 12px; flex-wrap: wrap; }
.brand { display: flex; align-items: baseline; gap: 10px; flex: 0 0 auto; }
.brand h1, .brand .name { font-family: var(--f-display); font-weight: 700; font-size: 1.5rem; letter-spacing: -.02em; margin: 0; line-height: 1; white-space: nowrap; }
.brand .vs { display: inline-block; background: var(--accent); color: var(--accent-ink); border-radius: 6px; padding: 2px 6px 3px; margin-right: 4px; font-size: .95em; }
.brand small { color: var(--muted); font-size: .8rem; font-variant-numeric: tabular-nums; }
.search { flex: 1 1 320px; position: relative; min-width: 0; }
.search input { width: 100%; height: 46px; border: 1px solid var(--line); background: var(--surface); border-radius: 10px; padding: 0 44px 0 42px; font-size: 1rem; }
.search input:focus { border-color: var(--accent); outline: none; box-shadow: 0 0 0 3px var(--accent-soft); }
.search svg { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); color: var(--faint); }
.search kbd { position: absolute; right: 12px; top: 50%; transform: translateY(-50%); font-family: var(--f-mono); font-size: .72rem; color: var(--faint); border: 1px solid var(--line); border-radius: 5px; padding: 1px 6px; background: var(--bg); }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 7px; height: 40px; padding: 0 16px; border-radius: 9px; border: 1px solid var(--line); background: var(--surface); cursor: pointer; font-weight: 500; white-space: nowrap; text-decoration: none; }
.btn:hover { border-color: var(--faint); }
a.btn { color: var(--ink); }
a.btn.primary { color: var(--accent-ink); }
a.btn.danger { color: var(--danger); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 600; }
.btn.primary:hover { filter: brightness(1.07); }
.btn.ghost { background: transparent; border-color: transparent; }
.btn.ghost:hover { background: var(--sunk); }
.btn.danger { color: var(--danger); }
.btn.danger.solid { background: var(--danger); border-color: var(--danger); color: var(--surface); }
.btn.sm { height: 32px; padding: 0 11px; font-size: .86rem; border-radius: 7px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.top .btn.primary { height: 46px; padding: 0 20px; }

/* user menu */
.user { position: relative; }
.user-btn { display: inline-flex; align-items: center; gap: 8px; height: 46px; padding: 0 12px 0 6px; border-radius: 10px; border: 1px solid var(--line); background: var(--surface); cursor: pointer; }
.avatar { width: 34px; height: 34px; border-radius: 50%; background: var(--accent-soft); color: var(--accent); display: grid; place-items: center; font-weight: 700; font-size: .85rem; }
.user-btn .who { font-weight: 500; max-width: 140px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.menu { position: absolute; right: 0; top: calc(100% + 6px); background: var(--surface); border: 1px solid var(--line); border-radius: 10px; box-shadow: var(--shadow); min-width: 220px; padding: 6px; z-index: 12; }
.menu .head { padding: 8px 10px 10px; border-bottom: 1px solid var(--line); margin-bottom: 4px; }
.menu .head strong { display: block; }
.menu .head span { font-size: .8rem; color: var(--muted); }
.menu button { display: block; width: 100%; text-align: left; border: 0; background: none; padding: 9px 10px; border-radius: 7px; cursor: pointer; }
.menu button:hover { background: var(--sunk); }
.role { display: inline-flex; height: 20px; align-items: center; padding: 0 7px; border-radius: 5px; font-size: .72rem; font-weight: 600; letter-spacing: .03em; background: var(--sunk); color: var(--muted); }
.role.Admin { background: var(--accent-soft); color: var(--accent); }

/* ---------- filters ---------- */
.filters { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; padding-bottom: 14px; }
.sel { height: 36px; border: 1px solid var(--line); background-color: var(--surface); border-radius: 8px; padding: 0 30px 0 10px; font-size: .88rem; max-width: 220px; appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: calc(100% - 15px) 50%, calc(100% - 10px) 50%; background-size: 5px 5px; background-repeat: no-repeat; }
.filters .spacer { flex: 1; }
.linkbtn { font-size: .85rem; color: var(--accent); background: none; border: 0; cursor: pointer; padding: 4px; }

/* ---------- list + detail ---------- */
.main { display: grid; grid-template-columns: minmax(300px, 400px) 1fr; gap: 16px; min-height: 0; padding-bottom: 16px; }
.list, .detail { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; overflow: auto; min-height: 0; min-width: 0; }
.list-head { position: sticky; top: 0; background: var(--surface); padding: 10px 16px; border-bottom: 1px solid var(--line); font-size: .78rem; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; font-weight: 600; z-index: 1; display: flex; justify-content: space-between; gap: 8px; }
.item { display: grid; grid-template-columns: 1fr auto; gap: 2px 10px; padding: 13px 16px; border: 0; border-bottom: 1px solid var(--line); cursor: pointer; position: relative; width: 100%; text-align: left; background: none; }
.item:hover { background: var(--bg); }
.item[aria-current="true"] { background: var(--accent-soft); }
.item[aria-current="true"]::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 3px; background: var(--accent); }
.item .id { font-family: var(--f-mono); font-size: .75rem; color: var(--faint); }
.item .date { font-size: .78rem; color: var(--faint); font-variant-numeric: tabular-nums; }
.item .t { grid-column: 1 / -1; font-weight: 600; line-height: 1.35; min-width: 0; overflow-wrap: anywhere; }
.item .meta { grid-column: 1 / -1; font-size: .82rem; color: var(--muted); display: flex; gap: 6px; flex-wrap: wrap; align-items: center; min-width: 0; }
.item .meta .dot { color: var(--faint); }
.item .snip { grid-column: 1 / -1; font-size: .82rem; color: var(--muted); overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow-wrap: anywhere; }
.pic { display: inline-flex; align-items: center; gap: 3px; color: var(--faint); }
.more { padding: 12px 16px; font-size: .82rem; color: var(--muted); text-align: center; }

.tag { display: inline-flex; height: 24px; align-items: center; padding: 0 9px; border-radius: 6px; background: var(--sunk); font-size: .8rem; color: var(--muted); font-family: var(--f-mono); }

.d-wrap { padding: 24px 28px 40px; max-width: 880px; }
.d-top { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 10px; }
.d-top .id { font-family: var(--f-mono); color: var(--muted); font-size: .85rem; }
.d-top .actions { margin-left: auto; display: flex; gap: 6px; flex-wrap: wrap; }
.d-title { font-family: var(--f-display); font-weight: 700; font-size: 1.75rem; line-height: 1.2; letter-spacing: -.015em; margin: 0 0 18px; text-wrap: balance; overflow-wrap: anywhere; }
.facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 1px; background: var(--line); border: 1px solid var(--line); border-radius: 10px; overflow: hidden; margin: 0 0 18px; }
.facts div { background: var(--surface); padding: 10px 14px; min-width: 0; }
.facts dt { font-size: .7rem; text-transform: uppercase; letter-spacing: .07em; color: var(--faint); font-weight: 600; }
.facts dd { margin: 2px 0 0; font-weight: 500; overflow-wrap: anywhere; font-variant-numeric: tabular-nums; }
.tags { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 22px; }
.sec { margin-bottom: 24px; }
.sec h3 { font-size: .74rem; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); margin: 0 0 8px; font-weight: 600; display: flex; align-items: center; gap: 8px; }
.sec h3::after { content: ""; flex: 1; height: 1px; background: var(--line); }
.sec .body { white-space: pre-wrap; overflow-wrap: anywhere; max-width: 72ch; }
.sec .body code { font-family: var(--f-mono); font-size: .88em; background: var(--code-bg); border: 1px solid var(--line); padding: 1px 5px; border-radius: 4px; }
.sec.fix .body { background: var(--fix-bg); border-radius: 10px; padding: 14px 16px; max-width: none; }
.err { position: relative; background: var(--code-bg); border: 1px solid var(--line); border-radius: 10px; padding: 14px 72px 14px 16px; font-family: var(--f-mono); font-size: .84rem; white-space: pre-wrap; overflow-wrap: anywhere; margin: 0; }
.err .btn { position: absolute; top: 8px; right: 8px; font-family: var(--f-body); }
.shots { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 10px; }
.shots button { padding: 0; border: 1px solid var(--line); border-radius: 9px; overflow: hidden; cursor: zoom-in; background: var(--sunk); aspect-ratio: 4 / 3; max-width: 100%; }
.shots img { width: 100%; height: 100%; object-fit: cover; display: block; }
.stamp { font-size: .8rem; color: var(--faint); margin-top: 28px; font-variant-numeric: tabular-nums; }
.confirm { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; background: var(--danger-bg); color: var(--danger); border-radius: 9px; padding: 8px 12px; font-size: .88rem; font-weight: 500; margin-bottom: 14px; }
.confirm .grow { flex: 1; }
.back { display: none; }

.empty { display: grid; place-items: center; text-align: center; padding: 48px 24px; color: var(--muted); height: 100%; }
.empty h2 { font-family: var(--f-display); color: var(--ink); font-size: 1.25rem; margin: 0 0 6px; }
.empty p { margin: 0 auto 16px; max-width: 42ch; }
.empty .big { font-family: var(--f-mono); font-size: .8rem; color: var(--faint); margin-bottom: 12px; letter-spacing: .1em; }

/* ---------- dialogs ---------- */
.overlay { position: fixed; inset: 0; background: rgba(10,15,24,.55); z-index: 20; display: flex; justify-content: center; align-items: flex-start; padding: 24px 16px; overflow: auto; }
.sheet { background: var(--surface); border-radius: 14px; width: 100%; max-width: 820px; box-shadow: var(--shadow); border: 1px solid var(--line); }
.sheet.narrow { max-width: 460px; }
.sheet.wide { max-width: 900px; }
.sheet header { display: flex; align-items: center; justify-content: space-between; padding: 18px 22px; border-bottom: 1px solid var(--line); gap: 12px; }
.sheet header h2 { font-family: var(--f-display); margin: 0; font-size: 1.2rem; }
.sheet header .mono { color: var(--muted); font-size: .85rem; font-family: var(--f-mono); }
.form { padding: 20px 22px; display: grid; grid-template-columns: repeat(6, 1fr); gap: 14px; }
.f { display: flex; flex-direction: column; gap: 5px; grid-column: span 6; min-width: 0; }
.f.c2 { grid-column: span 2; } .f.c3 { grid-column: span 3; }
.f label, .f .lbl { font-size: .78rem; font-weight: 600; color: var(--muted); }
.f label i, .f .lbl i { font-weight: 400; font-style: normal; color: var(--faint); }
.f input, .f select, .f textarea { border: 1px solid var(--line); background: var(--bg); border-radius: 8px; padding: 9px 11px; width: 100%; min-width: 0; }
.f input:focus, .f select:focus, .f textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); background: var(--surface); }
.f textarea { resize: vertical; min-height: 84px; line-height: 1.5; }
.f textarea.mono { font-family: var(--f-mono); font-size: .85rem; }
.f input.title { font-size: 1.05rem; font-weight: 600; }
.check { display: flex; align-items: center; gap: 8px; font-size: .9rem; color: var(--muted); cursor: pointer; }
.check input { width: 16px; height: 16px; accent-color: var(--accent); }
.drop { border: 1.5px dashed var(--line); border-radius: 10px; padding: 16px; text-align: center; color: var(--muted); font-size: .88rem; background: var(--bg); cursor: pointer; }
.drop.over { border-color: var(--accent); background: var(--accent-soft); color: var(--ink); }
.drop strong { color: var(--accent); }
.thumbs { display: grid; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: 8px; margin-top: 10px; }
.thumb { position: relative; aspect-ratio: 4 / 3; border-radius: 8px; overflow: hidden; border: 1px solid var(--line); background: var(--sunk); max-width: 100%; }
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.thumb .x { position: absolute; top: 4px; right: 4px; width: 24px; height: 24px; border-radius: 50%; border: 0; background: rgba(0,0,0,.65); color: #fff; cursor: pointer; display: grid; place-items: center; font-size: 14px; line-height: 1; }
.thumb .mv { position: absolute; bottom: 4px; left: 4px; display: flex; gap: 3px; }
.thumb .mv button { width: 24px; height: 22px; border: 0; border-radius: 5px; background: rgba(0,0,0,.6); color: #fff; cursor: pointer; font-size: 12px; }
.thumb .st { position: absolute; inset: auto 0 0 0; font-size: .7rem; padding: 3px 6px; background: rgba(0,0,0,.65); color: #fff; }
.thumb.error { border-color: var(--danger); }
.sheet footer { display: flex; gap: 10px; justify-content: flex-end; align-items: center; padding: 14px 22px; border-top: 1px solid var(--line); flex-wrap: wrap; }
.sheet footer .hint { margin-right: auto; font-size: .8rem; color: var(--faint); }
.ferr { color: var(--danger); font-size: .85rem; }
.fok { color: var(--fix); font-size: .85rem; }

/* users table */
.users-body { padding: 18px 22px 22px; display: grid; gap: 18px; }
.add-user { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)) auto; gap: 10px; align-items: end; background: var(--bg); border: 1px solid var(--line); border-radius: 10px; padding: 14px; }
.add-user .f { grid-column: auto; }
.add-user .note { grid-column: 1 / -1; font-size: .8rem; color: var(--muted); }
.add-user .f input, .add-user .f select { background: var(--surface); }
.tbl-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 10px; }
table.users { width: 100%; border-collapse: collapse; font-size: .9rem; }
table.users th { text-align: left; font-size: .72rem; text-transform: uppercase; letter-spacing: .06em; color: var(--faint); font-weight: 600; padding: 10px 12px; border-bottom: 1px solid var(--line); background: var(--surface); white-space: nowrap; }
table.users td { padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
table.users tr:last-child td { border-bottom: 0; }
table.users td .sub { display: block; font-size: .8rem; color: var(--muted); font-family: var(--f-mono); }
table.users select { height: 32px; border: 1px solid var(--line); background: var(--bg); border-radius: 7px; padding: 0 8px; }
table.users .acts { display: flex; gap: 6px; justify-content: flex-end; flex-wrap: wrap; }
table.users .inline { display: flex; gap: 6px; align-items: center; justify-content: flex-end; flex-wrap: wrap; }
table.users .inline input { height: 32px; border: 1px solid var(--line); background: var(--bg); border-radius: 7px; padding: 0 8px; width: 170px; }
.muted { color: var(--muted); }
.off { opacity: .55; }
.locked { color: var(--danger); font-size: .78rem; font-weight: 600; }

/* lightbox */
.lb { position: fixed; inset: 0; background: rgba(5,8,12,.92); z-index: 30; display: grid; grid-template-rows: auto 1fr; }
.lb .bar { display: flex; justify-content: space-between; align-items: center; padding: 12px 16px; color: #e8edf3; font-family: var(--f-mono); font-size: .85rem; gap: 8px; }
.lb .bar a, .lb .bar button { background: rgba(255,255,255,.12); border: 0; color: #fff; height: 36px; padding: 0 14px; border-radius: 8px; cursor: pointer; display: inline-flex; align-items: center; text-decoration: none; font-family: var(--f-body); }
.lb .stage { display: grid; place-items: center; padding: 0 16px 16px; min-height: 0; position: relative; }
.lb img { max-width: 100%; max-height: 100%; object-fit: contain; border-radius: 6px; }
.lb .nav { position: absolute; top: 50%; transform: translateY(-50%); background: rgba(255,255,255,.14); border: 0; color: #fff; width: 44px; height: 44px; border-radius: 50%; cursor: pointer; font-size: 20px; }
.lb .prev { left: 16px; } .lb .next { right: 16px; }

.toast { position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%); background: var(--ink); color: var(--bg); padding: 10px 16px; border-radius: 9px; font-size: .88rem; z-index: 40; box-shadow: var(--shadow); max-width: calc(100% - 32px); }

/* ---------- sign-in pages ---------- */
.auth-page { min-height: 100%; display: grid; place-items: center; padding: 32px 16px; }
.auth-card { width: 100%; max-width: 400px; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow); padding: 28px; }
.auth-card .brand { margin-bottom: 22px; }
.auth-card h2 { font-family: var(--f-display); font-size: 1.25rem; margin: 0 0 4px; }
.auth-card p.lead { margin: 0 0 20px; color: var(--muted); font-size: .92rem; }
.auth-card form { display: grid; gap: 14px; }
.auth-card .f { grid-column: auto; }
.auth-card .f input { height: 42px; }
.auth-card .btn.primary { height: 44px; width: 100%; }
.auth-card .msg { border-radius: 8px; padding: 10px 12px; font-size: .88rem; background: var(--danger-bg); color: var(--danger); }
.auth-foot { margin-top: 16px; font-size: .8rem; color: var(--faint); text-align: center; }

/* ---------- narrow screens ---------- */
@media (max-width: 860px) {
  .app { height: auto; min-height: 100%; display: block; }
  .main { grid-template-columns: 1fr; }
  .list { overflow: visible; }
  .detail { display: none; }
  .app.show-detail .detail { display: block; position: fixed; inset: 0; border-radius: 0; border: 0; z-index: 15; }
  .back { display: inline-flex; }
  .d-wrap { padding: 16px 16px 40px; }
  .d-title { font-size: 1.4rem; }
  .search kbd { display: none; }
  .f.c2, .f.c3 { grid-column: span 6; }
  .form { padding: 16px; }
  .sheet header, .sheet footer, .users-body { padding-inline: 16px; }
  .top .btn.primary { flex: 1 1 auto; }
  .user-btn .who { display: none; }
  .add-user { grid-template-columns: 1fr; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }

/* ---------- documents ---------- */
.docs { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.docs.edit { margin-top: 10px; }
.docs.edit:empty { display: none; }
.doc { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); min-width: 0; }
.doc.error { border-color: var(--danger); }
.doc-ic { flex: 0 0 auto; width: 40px; height: 40px; border-radius: 8px; display: grid; place-items: center; font-size: .68rem; font-weight: 700; letter-spacing: .04em; color: #fff; background: var(--faint); }
.doc-ic.word { background: #2b579a; } .doc-ic.excel { background: #217346; } .doc-ic.ppt { background: #c43e1c; } .doc-ic.pdf { background: #b30b00; } .doc-ic.txt { background: #5a6578; }
.doc-name { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; }
.doc-name a, .doc-title { font-weight: 600; color: var(--ink); text-decoration: none; overflow-wrap: anywhere; }
.doc-name a:hover { color: var(--accent); text-decoration: underline; }
.doc-meta { font-size: .8rem; color: var(--muted); }
.doc.error .doc-meta { color: var(--danger); }
.doc-acts { flex: 0 0 auto; display: flex; gap: 6px; }
.drop-sub { font-size: .78rem; color: var(--faint); }

/* ---------- storage panel ---------- */
.panel { border: 1px solid var(--line); border-radius: 10px; padding: 16px; display: grid; gap: 12px; }
.panel h3 { margin: 0; font-size: .74rem; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); }
.panel-row { display: flex; gap: 12px; align-items: flex-start; flex-wrap: wrap; }
.panel-row > span:last-child { flex: 1 1 260px; min-width: 0; overflow-wrap: anywhere; }
.panel-row code { font-family: var(--f-mono); font-size: .85em; background: var(--code-bg); border: 1px solid var(--line); border-radius: 4px; padding: 0 4px; }
.panel-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.hint-text { margin: 0; font-size: .82rem; color: var(--muted); }
.pill { display: inline-flex; align-items: center; gap: 6px; height: 24px; padding: 0 10px; border-radius: 99px; font-size: .76rem; font-weight: 600; white-space: nowrap; }
.pill::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.pill.ok { color: var(--fix); background: var(--fix-bg); }
.pill.warn { color: var(--danger); background: var(--danger-bg); }
.pill.neutral { color: var(--muted); background: var(--sunk); }
@media (max-width: 860px) { .doc { flex-wrap: wrap; } .doc-acts { width: 100%; justify-content: flex-end; } }

/* code blocks inside notes (```...```) */
.codeblock { position: relative; margin: 8px 0; max-width: 100%; }
.codeblock pre { margin: 0 0 8px; background: var(--code-bg); border: 1px solid var(--line); border-radius: 8px; padding: 12px 14px; padding-right: 72px; font-family: var(--f-mono); font-size: .8rem; line-height: 1.5; white-space: pre; overflow-x: auto; max-height: 520px; overflow-y: auto; color: var(--ink); }
.codeblock .btn { position: absolute; top: 6px; right: 18px; font-family: var(--f-body); }
.sec.fix .body .codeblock pre { background: var(--surface); }

/* pictures placed inside the text */
/* same size and style as pictures in the editor (.rte-pic) */
.inline-pic { display: block; margin: 10px 0; padding: 0; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; background: var(--sunk); cursor: zoom-in; max-width: min(100%, 720px); }
.inline-pic img { display: block; width: 100%; height: auto; }
.err .inline-pic { white-space: normal; }
.pic-missing { color: var(--faint); font-style: italic; }
.thumb .in-text { position: absolute; top: 4px; left: 4px; font-size: .68rem; font-weight: 600; padding: 1px 6px; border-radius: 4px; background: var(--accent); color: var(--accent-ink); }
.codeblock .code-pic { margin: 0 0 8px; }
.codeblock .code-pic .inline-pic { margin: 0; }
.codeblock pre + .code-pic, .codeblock .code-pic + pre { margin-top: 0; }

/* Issue / Resolution boxes in the editor: text with pictures shown in place */
.rte { border: 1px solid var(--line); background: var(--bg); border-radius: 8px; padding: 9px 11px; min-height: 110px; overflow: visible; white-space: pre-wrap; overflow-wrap: anywhere; line-height: 1.5; cursor: text; position: relative; }
.rte.tall { min-height: 160px; }
.rte:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); background: var(--surface); }
.rte.is-blank::before { content: attr(data-placeholder); color: var(--faint); position: absolute; left: 11px; top: 9px; pointer-events: none; }
/* same size and style as pictures in the note view (.inline-pic) */
.rte-pic { display: block; position: relative; margin: 10px 0; max-width: min(100%, 720px); border: 1px solid var(--line); border-radius: 8px; overflow: hidden; background: var(--sunk); user-select: none; cursor: default; }
.rte-pic img { display: block; width: 100%; height: auto; }
.rte-pic .rte-x { position: absolute; top: 6px; right: 6px; width: 26px; height: 26px; border-radius: 50%; border: 0; background: rgba(0,0,0,.65); color: #fff; cursor: pointer; font-size: 14px; line-height: 1; opacity: 0; transition: opacity .15s; }
.rte-pic:hover .rte-x, .rte-pic .rte-x:focus-visible { opacity: 1; }
.rte-pic.uploading img { opacity: .55; }
.rte-pic .rte-st { position: absolute; left: 0; right: 0; bottom: 0; padding: 4px 8px; font-size: .75rem; background: rgba(0,0,0,.65); color: #fff; }
@media (hover: none) { .rte-pic .rte-x { opacity: 1; } }

/* code between ``` lines, shown as a code box while editing (same look as the note view) */
.rte-code { display: block; margin: 6px 0; background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 10px 14px; font-family: var(--f-mono); font-size: .8rem; line-height: 1.5; white-space: pre; overflow-x: auto; color: var(--ink); }
.rte-code .rte-fence { color: var(--faint); }
.rte-code .rte-pic { font-family: var(--f-body); white-space: normal; }

/* ---------- share dialog ---------- */
.share-row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.share-row input { flex: 1 1 260px; min-width: 0; height: 40px; border: 1px solid var(--line); background: var(--bg); border-radius: 8px; padding: 0 10px; font-family: var(--f-mono); font-size: .82rem; color: var(--ink); }
.share-list { list-style: none; margin: 4px 0 0; padding: 0; display: grid; gap: 12px; }
.share-item { display: grid; gap: 6px; padding-top: 12px; border-top: 1px solid var(--line); }
.share-meta { font-size: .8rem; color: var(--muted); }
.d-top .actions .btn { white-space: nowrap; }

/* ---------- public page ---------- */
.public-bar { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; padding-block: 16px 12px; }
.public-bar .spacer { flex: 1; }
.public-note { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; margin-bottom: 24px; }
.public-wrap { max-width: 980px; margin: 0 auto; padding-inline: 16px; }
.public-foot { font-size: .8rem; color: var(--faint); text-align: center; padding-bottom: 32px; }

/* ---------- print: only the note ---------- */
@media print {
  @page { margin: 14mm; }
  :root { color-scheme: light; --bg: #fff; --surface: #fff; --sunk: #f3f4f6; --ink: #111; --muted: #444; --faint: #666; --line: #ccc; --code-bg: #f6f7f9; --fix-bg: #fff; --mark: transparent; }
  html, body { height: auto !important; background: #fff !important; font-size: 11pt; }
  .top, .filters, .list, .back, .d-top .actions, #layer, .toast, .public-bar, .public-foot, .codeblock .btn, .err .btn { display: none !important; }
  .app, .main { display: block !important; height: auto !important; max-width: none !important; padding: 0 !important; }
  .detail, .app.show-detail .detail, .public-note { display: block !important; position: static !important; overflow: visible !important; border: 0 !important; height: auto !important; }
  .d-wrap { padding: 0 !important; max-width: none !important; }
  .d-title { font-size: 18pt; }
  .sec { break-inside: auto; }
  .sec h3 { break-after: avoid; }
  .sec.fix .body { background: none; border: 1px solid #ccc; }
  .codeblock pre, .err { white-space: pre-wrap !important; overflow: visible !important; max-height: none !important; padding-right: 14px !important; font-size: 8.5pt; }
  .inline-pic, .shots button, .rte-pic { break-inside: avoid; max-width: 100% !important; border-color: #ccc; }
  .shots { grid-template-columns: repeat(2, 1fr); }
  .shots button { aspect-ratio: auto; }
  .shots img { height: auto; object-fit: contain; }
  .docs .doc { break-inside: avoid; }
  .doc-acts { display: none !important; }
  a { color: inherit; text-decoration: none; }
  mark { background: none; }
}
.shots .shot-link { display: block; border: 1px solid var(--line); border-radius: 9px; overflow: hidden; background: var(--sunk); aspect-ratio: 4 / 3; }
.shots .shot-link img { width: 100%; height: 100%; object-fit: cover; display: block; }
.public-note .d-wrap { max-width: none; }
