:root {
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "PingFang SC", "Helvetica Neue", sans-serif;
  color: #1d1d1f; background: #f5f5f3; font-synthesis: none;
  --sidebar: #ececea; --line: rgba(0,0,0,.09); --muted: #777775; --soft: #f1f1ef;
  --accent: #1d1d1f; --inspector: 400px; --gap: 14px; --columns: 244px;
}
* { box-sizing: border-box; }
html, body { margin: 0; min-width: 960px; height: 100%; overflow: hidden; }
button, input, textarea { font: inherit; }
button { color: inherit; }
[hidden] { display: none !important; }
.app-shell { display: grid; grid-template-columns: 210px minmax(0, 1fr); height: 100vh; background: #f7f7f5; transition: grid-template-columns .2s ease; }
.app-shell.has-inspector { grid-template-columns: 210px minmax(0, 1fr) var(--inspector); }

.sidebar { display: flex; flex-direction: column; min-width: 0; padding: 18px 12px 12px; background: var(--sidebar); border-right: 1px solid var(--line); }
.brand { display: flex; align-items: center; gap: 10px; padding: 3px 9px 24px; font-size: 14px; font-weight: 650; letter-spacing: -.1px; }
.brand-mark { display: grid; place-items: center; width: 24px; height: 24px; border-radius: 7px; color: white; background: #222; font-size: 12px; }
nav { display: grid; gap: 3px; }
.nav-item { display: flex; align-items: center; gap: 10px; width: 100%; padding: 8px 10px; border: 0; border-radius: 7px; background: transparent; text-align: left; cursor: default; }
.nav-item b { font-size: 13px; font-weight: 520; }
.nav-item.active { background: rgba(0,0,0,.075); }
.nav-item.disabled { opacity: .38; }
.nav-icon { width: 16px; text-align: center; font-size: 16px; }
.sidebar-foot { margin-top: auto; }
.library-location { display: flex; align-items: center; width: 100%; gap: 9px; padding: 9px; border: 0; border-radius: 8px; background: transparent; text-align: left; }
.library-location:hover { background: rgba(0,0,0,.045); }
.library-location > i { width: 8px; height: 8px; border-radius: 50%; background: #2f9b54; box-shadow: 0 0 0 3px rgba(47,155,84,.12); }
.library-location span:nth-child(2) { display: grid; gap: 2px; min-width: 0; }
.library-location b { font-size: 12px; font-weight: 550; }
.library-location small { color: var(--muted); font-size: 11px; }
.sidebar-disclosure { margin-left: auto; color: #999; font-size: 18px; }

.workspace { min-width: 0; overflow: auto; background: #f8f8f6; }
.topbar { position: sticky; z-index: 20; top: 0; display: flex; align-items: center; justify-content: space-between; min-height: 70px; padding: 14px 24px 10px; background: rgba(248,248,246,.96); border-bottom: 1px solid transparent; }
.heading { display: flex; align-items: baseline; gap: 10px; }
.heading h1 { margin: 0; font-size: 25px; line-height: 1; letter-spacing: -.7px; }
.heading span { color: var(--muted); font-size: 12px; }
.toolbar { display: flex; align-items: center; gap: 8px; }
.search { display: flex; align-items: center; width: min(340px, 31vw); height: 34px; padding: 0 9px; border: 1px solid var(--line); border-radius: 8px; background: #efefed; transition: background .15s, box-shadow .15s; }
.search:focus-within { background: #fff; box-shadow: 0 0 0 3px rgba(0,0,0,.07); }
.search-icon { margin-right: 6px; color: #777; font-size: 19px; transform: rotate(-15deg); }
.search input { width: 100%; border: 0; outline: 0; background: transparent; font-size: 13px; }
.search input::placeholder { color: #898987; }
kbd { min-width: 22px; padding: 2px 5px; border: 0; border-radius: 4px; background: rgba(0,0,0,.06); color: #7a7a78; font-family: inherit; font-size: 10px; text-align: center; }
.toolbar-button { height: 34px; border: 1px solid var(--line); border-radius: 8px; background: #fff; cursor: pointer; }
.toolbar-button:hover { background: #f1f1ef; }
.icon-button { width: 36px; font-weight: 700; letter-spacing: 1px; }
.import-button { display: flex; align-items: center; gap: 6px; padding: 0 13px; background: var(--db-accent, #8176d8); color: #fff; border-color: var(--db-accent, #8176d8); box-shadow: 0 8px 18px rgba(129, 118, 216, .2); }
.import-button:hover, .import-button:focus-visible { background: var(--db-accent-strong, #6d61c7); border-color: var(--db-accent-strong, #6d61c7); outline: 2px solid var(--db-accent-2, #a9a0e9); outline-offset: 2px; }
.import-button:disabled { opacity: .52; cursor: not-allowed; }
.import-button b { font-size: 13px; }
.import-button span { font-size: 18px; font-weight: 350; line-height: 1; }
.view-options-wrap { position: relative; }
.popover { position: absolute; z-index: 100; border: 1px solid rgba(0,0,0,.12); border-radius: 10px; background: #fff; box-shadow: 0 12px 32px rgba(0,0,0,.14), 0 2px 7px rgba(0,0,0,.06); }
.view-menu { top: 40px; right: 0; width: 230px; padding: 12px; }
.menu-group + .menu-group { margin-top: 13px; }
.menu-group > span { display: block; margin-bottom: 7px; color: var(--muted); font-size: 11px; }
.segmented { display: grid; grid-auto-flow: column; padding: 2px; border-radius: 7px; background: #efefed; }
.segmented button { padding: 6px 9px; border: 0; border-radius: 5px; background: transparent; font-size: 12px; }
.segmented button.active { background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.1); }

.filter-row { position: sticky; z-index: 15; top: 70px; display: flex; gap: 5px; padding: 6px 24px 14px; background: rgba(248,248,246,.96); }
.filter-row button { padding: 6px 11px; border: 0; border-radius: 7px; background: transparent; color: #6c6c6a; font-size: 12px; cursor: pointer; }
.filter-row button:hover { background: rgba(0,0,0,.045); }
.filter-row button.active { background: #e5e5e2; color: #1d1d1f; font-weight: 560; }
.result-note { margin: 0 24px 2px; padding: 9px 11px; border-top: 1px solid var(--line); color: #696967; font-size: 12px; }
.result-note b { color: #222; font-weight: 560; }

.masonry { padding: 12px 24px 60px; column-width: var(--columns); column-gap: var(--gap); }
.masonry.size-small { --columns: 190px; }
.masonry.size-large { --columns: 310px; }
.masonry.density-compact { --gap: 7px; }
.asset-card { display: inline-block; width: 100%; margin: 0 0 var(--gap); break-inside: avoid; border: 0; padding: 0; background: transparent; vertical-align: top; text-align: left; cursor: pointer; }
.asset-thumb { position: relative; width: 100%; aspect-ratio: var(--ratio); overflow: hidden; background: #e9e9e6; outline: 0 solid #1d1d1f; transition: transform .16s ease, box-shadow .16s ease, outline-width .08s; }
.asset-card:hover .asset-thumb { transform: translateY(-1px); box-shadow: 0 5px 16px rgba(0,0,0,.09); }
.asset-card.selected .asset-thumb { outline: 2px solid #1d1d1f; outline-offset: 2px; }
.asset-thumb img { display: block; width: 100%; height: 100%; object-fit: contain; }
.asset-thumb.transparent { background-color: #eee; background-image: linear-gradient(45deg,#d8d8d6 25%,transparent 25%),linear-gradient(-45deg,#d8d8d6 25%,transparent 25%),linear-gradient(45deg,transparent 75%,#d8d8d6 75%),linear-gradient(-45deg,transparent 75%,#d8d8d6 75%); background-size: 18px 18px; background-position: 0 0,0 9px,9px -9px,-9px 0; }
.asset-thumb.transparent img { object-fit: contain; padding: 8%; }
.card-badge { position: absolute; left: 8px; bottom: 8px; padding: 4px 6px; border-radius: 5px; background: rgba(20,20,20,.78); color: white; font-size: 9px; font-weight: 620; letter-spacing: .3px; }
.card-meta { display: flex; align-items: center; gap: 7px; padding: 7px 1px 1px; color: #5f5f5d; }
.card-meta span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 11px; }
.card-meta i { flex: 0 0 auto; width: 5px; height: 5px; border-radius: 50%; background: #1d1d1f; opacity: 0; }
.asset-card.selected .card-meta i { opacity: 1; }
.masonry.density-compact .card-meta { display: none; }
.masonry.density-compact .asset-card { margin-bottom: var(--gap); }
.source-placeholder { display: grid; place-items: center; height: 100%; background: #e8e8e5; color: #676765; }
.source-placeholder > div { text-align: center; }
.source-placeholder strong { display: grid; place-items: center; width: 48px; height: 48px; margin: 0 auto 10px; border: 1px solid #a7a7a2; border-radius: 10px; color: #333; font-size: 18px; }
.source-placeholder span { font-size: 11px; }
.prompt-preview { display: flex; flex-direction: column; justify-content: space-between; height: 100%; padding: 14%; background: #20201f; color: #f2f2ef; }
.prompt-preview small { color: #aaa; font-size: 9px; letter-spacing: .8px; }
.prompt-preview p { margin: 0; font-size: clamp(12px, 1.25vw, 21px); line-height: 1.55; letter-spacing: -.2px; }
.document-preview:after { content: "PDF · 37页"; position: absolute; right: 8px; bottom: 8px; padding: 4px 6px; border-radius: 5px; background: rgba(20,20,20,.78); color: #fff; font-size: 9px; }
.empty-state { padding-top: 14vh; text-align: center; color: #6b6b69; }
.empty-state > span { font-size: 34px; }
.empty-state h2 { margin: 12px 0 5px; color: #333; font-size: 16px; }
.empty-state p { margin: 0 0 14px; font-size: 12px; }
.empty-state button { padding: 7px 12px; border: 1px solid var(--line); border-radius: 7px; background: #fff; }

.inspector { display: none; min-width: 0; background: #fbfbfa; border-left: 1px solid var(--line); }
.app-shell.has-inspector .inspector { display: flex; flex-direction: column; }
.inspector-head { display: flex; align-items: flex-start; justify-content: space-between; min-height: 70px; padding: 16px 18px 10px; border-bottom: 1px solid var(--line); }
.inspector-head > div { min-width: 0; }
.inspector-head span { display: block; color: var(--muted); font-size: 10px; margin-bottom: 4px; }
.inspector-head h2 { overflow: hidden; margin: 0; text-overflow: ellipsis; white-space: nowrap; font-size: 14px; font-weight: 610; letter-spacing: -.1px; }
.close-button { width: 28px; height: 28px; border: 0; border-radius: 6px; background: transparent; color: #777; font-size: 20px; line-height: 1; }
.close-button:hover { background: #ececea; color: #222; }
.inspector-scroll { overflow-y: auto; overscroll-behavior: contain; }
.preview-stage { position: relative; display: grid; place-items: center; aspect-ratio: 16 / 11; margin: 16px 16px 0; overflow: hidden; background: #ededeb; transition: background-color .15s; }
.preview-art { width: 100%; height: 100%; }
.preview-art img { display: block; width: 100%; height: 100%; object-fit: contain; }
.preview-art .source-placeholder { min-height: 100%; }
.preview-stage[data-bg="checker"] { background-color: #eee; background-image: linear-gradient(45deg,#d6d6d3 25%,transparent 25%),linear-gradient(-45deg,#d6d6d3 25%,transparent 25%),linear-gradient(45deg,transparent 75%,#d6d6d3 75%),linear-gradient(-45deg,transparent 75%,#d6d6d3 75%); background-size: 22px 22px; background-position: 0 0,0 11px,11px -11px,-11px 0; }
.preview-stage[data-bg="white"] { background: #fff; }
.preview-stage[data-bg="black"] { background: #070707; }
.background-switch { display: flex; justify-content: space-between; align-items: center; padding: 9px 17px 5px; }
.background-switch > span { color: var(--muted); font-size: 10px; }
.background-switch > div { display: flex; padding: 2px; border-radius: 7px; background: #efefed; }
.background-switch button { display: flex; align-items: center; gap: 4px; padding: 5px 7px; border: 0; border-radius: 5px; background: transparent; color: #686866; font-size: 10px; }
.background-switch button.active { background: #fff; color: #222; box-shadow: 0 1px 3px rgba(0,0,0,.1); }
.background-switch i { width: 9px; height: 9px; border: 1px solid rgba(0,0,0,.18); border-radius: 2px; }
.background-switch [data-bg="checker"] i { background: repeating-conic-gradient(#bbb 0 25%,#eee 0 50%) 50%/5px 5px; }
.background-switch [data-bg="white"] i { background: #fff; }
.background-switch [data-bg="black"] i { background: #111; }

.inspector-content { padding: 5px 16px 0; }
.inspector-section { position: relative; padding: 18px 2px; border-bottom: 1px solid var(--line); }
.section-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.section-heading h3 { margin: 0; font-size: 12px; font-weight: 620; }
.section-heading p { margin: 3px 0 0; color: var(--muted); font-size: 10px; }
.section-add, .subtle-action { border: 0; background: transparent; color: #777; cursor: pointer; }
.section-add { width: 24px; height: 24px; border-radius: 6px; font-size: 19px; line-height: 1; }
.section-add:hover, .subtle-action:hover { background: #ececea; color: #222; }
.subtle-action { padding: 3px 6px; border-radius: 5px; font-size: 10px; }
.facet-list { display: flex; flex-wrap: wrap; gap: 6px; }
.facet-chip { display: inline-flex; align-items: center; gap: 5px; max-width: 100%; padding: 6px 8px; border: 1px solid transparent; border-radius: 7px; background: #eeeeec; font-size: 11px; cursor: pointer; }
.facet-chip:hover { border-color: #c8c8c5; background: #f7f7f5; }
.facet-chip.suggested { border-color: #b9b9b5; border-style: dashed; background: transparent; }
.facet-chip small { color: #777; font-size: 8px; }
.facet-chip .suggestion-dot { width: 5px; height: 5px; border-radius: 50%; background: #777; }
.rejected-summary { margin-top: 10px; padding: 0; border: 0; background: transparent; color: #8b8b88; font-size: 10px; cursor: pointer; }
.rejected-summary:hover { color: #333; }
.facet-editor { top: 50px; right: 0; left: 0; padding: 13px; }
.facet-editor-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 11px; }
.facet-editor-head b { font-size: 12px; }
.facet-editor-head button { width: 22px; height: 22px; border: 0; border-radius: 5px; background: transparent; color: #777; font-size: 16px; }
.facet-editor input, .inline-editor input, .inline-editor textarea { width: 100%; border: 1px solid #cfcfcb; border-radius: 7px; outline: 0; background: #fff; color: #222; }
.facet-editor input, .inline-editor input { height: 34px; padding: 0 9px; font-size: 12px; }
.facet-editor input:focus, .inline-editor input:focus, .inline-editor textarea:focus { border-color: #8b8b87; box-shadow: 0 0 0 3px rgba(0,0,0,.06); }
.facet-kind-label { display: block; margin: 11px 0 7px; color: var(--muted); font-size: 10px; }
.facet-kind { display: flex; flex-wrap: wrap; gap: 5px; }
.facet-kind button { padding: 5px 8px; border: 1px solid var(--line); border-radius: 6px; background: #f4f4f2; color: #666; font-size: 10px; }
.facet-kind button.active { border-color: #222; background: #222; color: #fff; }
.facet-origin { margin: 11px 0 0; color: #777; font-size: 10px; line-height: 1.45; }
.facet-actions { display: flex; justify-content: flex-end; gap: 6px; margin-top: 13px; }
.facet-actions button, .inline-editor > div button { padding: 6px 9px; border: 0; border-radius: 6px; background: #ededeb; font-size: 10px; }
.facet-actions button.primary, .inline-editor > div .primary-small { background: #222; color: #fff; }
.facet-actions button.danger { margin-right: auto; color: #9e3131; background: transparent; }
.rejected-list { margin-top: 12px; max-height: 150px; overflow: auto; border-top: 1px solid var(--line); }
.rejected-item { display: flex; align-items: center; gap: 6px; padding: 8px 0; border-bottom: 1px solid var(--line); }
.rejected-item span { flex: 1; color: #686866; font-size: 11px; text-decoration: line-through; }
.rejected-item small { color: #999; font-size: 9px; }
.rejected-item button { border: 0; background: transparent; font-size: 10px; }

.preference-control { display: grid; grid-template-columns: repeat(4, 1fr); padding: 2px; border-radius: 8px; background: #efefed; }
.preference-control button { padding: 7px 2px; border: 0; border-radius: 6px; background: transparent; color: #6d6d6b; font-size: 10px; }
.preference-control button.active { background: #fff; color: #222; font-weight: 570; box-shadow: 0 1px 3px rgba(0,0,0,.11); }
.preference-control [data-preference="DISLIKE"].active { color: #8e3535; }
.learning-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 15px; }
.learning-row span { display: grid; gap: 3px; }
.learning-row b { font-size: 11px; font-weight: 560; }
.learning-row small { max-width: 285px; color: var(--muted); font-size: 9px; line-height: 1.4; }
.switch { position: relative; flex: 0 0 auto; width: 34px; height: 20px; padding: 0; border: 0; border-radius: 99px; background: #c9c9c5; transition: background .16s; }
.switch i { position: absolute; left: 2px; top: 2px; width: 16px; height: 16px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.25); transition: transform .16s ease; }
.switch[aria-checked="true"] { background: #2f2f2e; }
.switch[aria-checked="true"] i { transform: translateX(14px); }
.reading-copy { width: 100%; padding: 0; border: 0; background: transparent; text-align: left; color: #3d3d3b; font-size: 11px; line-height: 1.65; cursor: text; }
.reading-copy.empty { color: #9a9a96; }
.judgment-value { min-height: 24px; }
.inline-editor textarea { display: block; padding: 8px 9px; resize: vertical; font-size: 11px; line-height: 1.55; }
.inline-editor > div { display: flex; justify-content: flex-end; gap: 6px; margin-top: 7px; }
.source-row { display: grid; grid-template-columns: 55px minmax(0,1fr); align-items: baseline; gap: 8px; margin-bottom: 11px; }
.source-row > span { color: var(--muted); font-size: 10px; }
.one-line { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-info { display: grid; grid-template-columns: 55px minmax(0,1fr); gap: 7px 8px; margin: 0; }
.file-info dt { color: var(--muted); font-size: 10px; }
.file-info dd { overflow: hidden; margin: 0; text-overflow: ellipsis; white-space: nowrap; color: #444; font-size: 10px; }
.source-note { margin-top: 12px; padding: 9px 10px; border-left: 2px solid #a6a6a2; background: #f1f1ef; color: #5e5e5c; font-size: 10px; line-height: 1.45; }
.management-section { padding: 14px 2px; }
.management-section summary { display: flex; align-items: center; gap: 7px; list-style: none; cursor: pointer; }
.management-section summary::-webkit-details-marker { display: none; }
.management-section summary:before { content: "›"; color: #888; font-size: 16px; transition: transform .14s; }
.management-section[open] summary:before { transform: rotate(90deg); }
.management-section summary span { font-size: 11px; font-weight: 560; }
.management-section summary small { padding: 2px 5px; border-radius: 4px; background: #efefed; color: #858582; font-size: 8px; }
.management-section > p { margin: 10px 0 13px 17px; color: var(--muted); font-size: 9px; line-height: 1.45; }
.management-fields { display: grid; gap: 2px; }
.read-field { display: grid; grid-template-columns: 80px minmax(0,1fr); align-items: center; min-height: 34px; }
.read-field > span { color: var(--muted); font-size: 10px; }
.field-value { display: flex; justify-content: space-between; align-items: center; min-width: 0; padding: 6px 7px; border: 0; border-radius: 6px; background: transparent; text-align: left; }
.field-value:hover { background: #eee; }
.field-value b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 10px; font-weight: 500; }
.field-value i { color: #999; font-style: normal; }
.management-popover { right: 0; bottom: 48px; width: 210px; padding: 5px; }
.management-popover button { display: flex; justify-content: space-between; width: 100%; padding: 7px 8px; border: 0; border-radius: 6px; background: transparent; text-align: left; font-size: 11px; }
.management-popover button:hover { background: #efefed; }
.management-popover button i { opacity: 0; font-style: normal; }
.management-popover button[aria-checked="true"] i { opacity: 1; }
.quicklook-note { padding: 15px 0 24px; color: #aaa; text-align: center; font-size: 9px; }
.quicklook-note span { margin: 0 5px; }
.quicklook-note kbd { font-size: 8px; }

.drop-overlay { position: fixed; z-index: 500; inset: 0; display: grid; place-items: center; background: rgba(245,245,242,.92); }
.drop-overlay > div { display: grid; gap: 8px; text-align: center; }
.drop-overlay span { font-size: 36px; }
.drop-overlay strong { font-size: 16px; }
.drop-overlay small { color: #777; }
.toast { position: fixed; z-index: 700; left: 50%; bottom: 25px; padding: 9px 13px; border-radius: 8px; background: #242423; color: #fff; opacity: 0; transform: translate(-50%, 8px); pointer-events: none; font-size: 11px; transition: opacity .15s, transform .15s; }
.toast.show { opacity: 1; transform: translate(-50%,0); }

@media (max-width: 1180px) {
  :root { --inspector: 380px; }
  .app-shell, .app-shell.has-inspector { grid-template-columns: 184px minmax(0,1fr) var(--inspector); }
  .app-shell:not(.has-inspector) { grid-template-columns: 184px minmax(0,1fr); }
  .search { width: 245px; }
  .masonry { padding-inline: 18px; }
  .topbar, .filter-row { padding-inline: 18px; }
}
@media (prefers-reduced-motion: reduce) { *, *:before, *:after { scroll-behavior: auto !important; transition-duration: .01ms !important; } }
