.gallery { display: flex; flex-direction: column; gap: 10px; min-width: 0; }
.gal-bar { flex-wrap: wrap; gap: 8px; }
.gal-pills { display: flex; flex-wrap: wrap; gap: 6px; }
.gal-pills:empty { display: none; }
.gal-all { font-size: var(--fs-sm); }
.gal-type { display: inline-flex; align-items: center; gap: 8px; font-size: var(--fs-sm); color: var(--text-2); }
.gal-pill { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--border); background: var(--surface); color: var(--text); border-radius: var(--r-pill, 999px); padding: 3px 10px; font-size: 12.5px; cursor: pointer; }
.gal-pill:hover { border-color: var(--border-strong); }
.gal-pill.on { background: var(--sel-bg); border-color: var(--sel-edge); color: var(--link); font-weight: 600; }
.gal-pill:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.gal-n { font-size: 11px; color: var(--muted); font-variant-numeric: tabular-nums; }
.gal-pill.on .gal-n { color: inherit; }
.gal-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 20px; }
.gal-empty { grid-column: 1 / -1; background: var(--surface); border: 1px dashed var(--border-strong); border-radius: var(--r-card, 8px); }
.gal-empty p { max-width: 560px; margin: 0 auto; }
.gal-empty .gal-empty-title { font-size: 1.17em; font-weight: 600; color: var(--text); margin: 0 auto .5em; }
.gal-card { display: flex; flex-direction: column; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); min-width: 0; overflow: hidden; transition: box-shadow .12s, border-color .12s; }
.gal-card:hover { border-color: var(--border-strong); box-shadow: var(--shadow); }
.gal-card.selected { border-color: var(--accent); box-shadow: 0 0 0 2px var(--sel-edge); background: var(--sel-bg); }
.gal-card.selecting .gc-open { cursor: pointer; }
.gc-open { display: flex; flex-direction: column; color: var(--text); text-decoration: none; }
.gc-open:hover { text-decoration: none; }
.gc-open:focus-visible { outline: 2px solid var(--focus); outline-offset: -2px; }
.gc-thumb { height: 140px; display: flex; align-items: stretch; justify-content: center; overflow: hidden; border-bottom: 1px solid var(--line); background: var(--surface-2, #f7f9fc); }
.gc-thumb > .thumb { height: 100%; width: 100%; border-bottom: 0; }
.gc-thumb > .dt-thumb { flex: 1; height: auto; margin: 0; border: 0; border-radius: 0; }
.gc-title { padding: 10px 12px 0; font-weight: 600; font-size: 13.5px; overflow-wrap: anywhere; }
.gc-meta { display: flex; align-items: center; gap: 6px; padding-block: 2px 0; padding-inline: 12px 6px; min-height: 28px; }
.gc-sub { font-size: 12px; color: var(--muted); min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.gc-sub { white-space: normal; display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; line-height: 1.3; }
.gc-checkwrap { display: inline-flex; }
.gc-check { margin: 0; }
.gc-detail { padding: 0 12px 10px; font-size: 12px; color: var(--text-2, var(--muted)); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.gc-tags { padding: 0 12px 10px; }
.gc-tag { font-size: 11px; border: 1px dashed var(--border-strong); border-radius: var(--r-pill, 999px); padding: 0 8px; color: var(--muted); }
.gal-foot { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.gal-selbar { display: flex; align-items: center; gap: 8px; padding: 6px 10px; border: 1px solid var(--sel-edge); background: var(--sel-bg); border-radius: var(--r-ctl, 6px); }
.rf-row { display: flex; gap: 8px; align-items: flex-start; }
.rf-box { position: relative; flex: 1; min-width: 0; }
.rf-box > .input { width: 100%; }
.rf-list { position: absolute; z-index: 30; inset-inline-start: 0; inset-inline-end: 0; top: calc(100% + 2px); margin: 0; padding: 4px 0; list-style: none; background: var(--panel); border: 1px solid var(--border-strong); border-radius: var(--r-ctl, 6px); box-shadow: var(--shadow); max-height: 260px; overflow: auto; }
.rf-opt { display: flex; align-items: center; gap: 6px; padding: 5px 10px; cursor: pointer; font-size: 13px; }
.rf-opt.active, .rf-opt:hover { background: var(--sel-bg); }
.rf-create { border-top: 1px solid var(--line); color: var(--link); }
.rf-note { margin-top: 4px; }
.nd-group { margin: 0 0 12px; }
.nd-group h3 { margin: 0 0 6px; font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--text-2, var(--muted)); }
.nd-types { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 8px; }
.nd-type { display: flex; flex-direction: column; align-items: flex-start; gap: 2px; text-align: start; border: 1px solid var(--border); background: var(--surface); border-radius: var(--r-ctl, 6px); padding: 8px 10px; color: var(--text); cursor: pointer; }
.nd-type[aria-checked="true"] { border-color: var(--accent); box-shadow: 0 0 0 2px var(--sel-edge); background: var(--sel-bg); }
.nd-type:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.nd-notation { font-size: 10.5px; border: 1px solid var(--border); border-radius: var(--r-pill, 999px); padding: 0 6px; color: var(--muted); }
.nd-scroll { max-height: 46vh; overflow: auto; padding-inline-end: 4px; }
.modal.nd-modal { height: 90vh; max-height: 90vh; }
.nd-modal .modal-body { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.nd-form { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.nd-field { flex: 1; min-height: 0; }
.nd-modal .nd-scroll { flex: 1; min-height: 140px; max-height: none; }
.nd-filter { max-width: 320px; }
.nd-type[hidden], .nd-group[hidden], .nd-none[hidden] { display: none; }
.nd-desc { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.nd-root-hint { margin: 0 0 2px; }
.doc-tpl-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 8px; padding: 4px 10px 8px; }
.doc-tpl-cards > .doc-tpl { flex-direction: column; align-items: stretch; gap: 4px; border: 1px solid var(--border); border-radius: var(--r-ctl, 6px); padding: 8px 10px; background: var(--surface); }
.doc-tpl-cards > .doc-tpl.active { border-color: var(--accent); box-shadow: 0 0 0 2px var(--sel-edge); }
.doc-tpl-head { display: flex; align-items: center; gap: 6px; font-weight: 600; font-size: 13px; }
.doc-tpl-head .muted { margin-inline-start: auto; font-weight: 400; }
.doc-tpl-prev { font-size: 11px; color: var(--muted); line-height: 1.45; }
.doc-tpl-prev-line { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.doc-tpl-filter { align-items: center; gap: 8px; margin-bottom: 6px; }
.doc-tpl-filter .input { width: auto; }
.gc-thumb > .doc-thumb { width: 100%; height: 100%; }
.doc-tpl-cards .doc-tpl-prev { margin-inline-start: 0; }
