/* Shared action hierarchy for authenticated workspaces. */
.action-icon { display:inline-flex; align-items:center; justify-content:center; gap:8px; }
.action-icon::before { content:""; display:block; width:18px; height:18px; flex:0 0 18px; background:currentColor; mask:var(--action-icon) center / contain no-repeat; -webkit-mask:var(--action-icon) center / contain no-repeat; }
.action-camera { --action-icon:url('/static/assets/lucide/camera.svg'); }
.action-upload { --action-icon:url('/static/assets/lucide/upload.svg'); }
.action-list { --action-icon:url('/static/assets/lucide/clipboard-list.svg'); }
.action-storage { --action-icon:url('/static/assets/lucide/hard-drive.svg'); }
.action-more { --action-icon:url('/static/assets/lucide/ellipsis.svg'); }
.action-delete { --action-icon:url('/static/assets/lucide/trash-2.svg'); }
.action-save { --action-icon:url('/static/assets/lucide/save.svg'); }
.action-add { --action-icon:url('/static/assets/lucide/plus.svg'); }
.action-refresh { --action-icon:url('/static/assets/lucide/refresh-cw.svg'); }
.action-download { --action-icon:url('/static/assets/lucide/download.svg'); }
.action-review { --action-icon:url('/static/assets/lucide/clipboard-list.svg'); }
.action-patients { --action-icon:url('/static/assets/lucide/users.svg'); }
.action-up { --action-icon:url('/static/assets/lucide/arrow-right.svg'); }
.action-up::before { transform:rotate(-90deg); }
.action-prev,.action-next { --action-icon:url('/static/assets/lucide/arrow-right.svg'); }
.action-prev::before { transform:rotate(180deg); }
.action-next::before { order:1; }
.icon-control { width:44px; height:44px; min-width:44px; padding:10px; }
.workspace-actions { display:flex; align-items:center; gap:8px; flex-wrap:wrap; }
.preview-downloads > .action-download { min-height:44px; padding:10px 14px; border:1px solid var(--line); background:#fff; color:#315b52; font-size:14px; }
.action-menu { position:relative; flex-shrink:0; }
.action-menu > summary { list-style:none; cursor:pointer; min-height:44px; padding:10px 14px; border:1px solid var(--line); border-radius:6px; background:#fff; color:#315b52; font-size:14px; font-weight:600; }
.action-menu > summary::-webkit-details-marker { display:none; }
.action-menu > summary:hover,.action-menu[open] > summary { background:#edf5f3; }
.action-menu > summary.icon-control { padding:10px; }
.action-menu-items { position:absolute; top:calc(100% + 6px); right:0; z-index:30; width:238px; max-width:calc(100vw - 32px); padding:6px; border:1px solid var(--line); border-radius:8px; background:white; box-shadow:0 8px 28px #173d2b1a; }
.action-menu .action-menu-items :is(button,a) { display:flex; justify-content:flex-start; gap:10px; width:100%; min-height:44px; height:auto; margin:0; padding:10px 12px; border:0; border-radius:4px; background:transparent; color:var(--ink); font-size:14px; font-weight:500; text-decoration:none; text-align:left; white-space:normal; overflow-wrap:anywhere; }
.action-menu .action-menu-items :is(button,a):hover { background:#edf5f3; }
.action-menu-items hr { border:0; border-top:1px solid var(--line); margin:6px; }
.action-menu .action-menu-items .danger { color:#b42318; border-top:1px solid var(--line); border-radius:0; margin-top:6px; }
.action-menu .action-menu-items .danger:hover { background:#fff1ee; }
.action-menu :is(button,a)[hidden],.action-menu.hidden { display:none!important; }
.workspace-filter { display:flex; align-items:center; gap:8px; margin-top:10px; font-size:12px; color:var(--muted); }
.workspace-filter select { flex:1; min-width:0; min-height:40px; padding:6px 10px; font-size:13px; color:var(--ink); }
.workspace-dialog { width:min(580px,calc(100% - 24px)); max-height:85dvh; overflow:auto; border:1px solid var(--line); border-radius:8px; padding:20px; color:var(--ink); }
.workspace-dialog::backdrop { background:#10231c66; }
.workspace-dialog label { display:grid; gap:8px; margin:18px 0; }
.workspace-dialog .photo-muted { line-height:1.9; white-space:pre-line; }
.workspace-dialog .photo-dialog-head { gap:12px; }
.workspace-dialog h2 { margin:0; font-size:18px; }
.workspace-dialog .photo-dialog-head button { flex-shrink:0; }
.baseline-source-details { border-bottom:1px solid var(--line); }
.baseline-source-details > summary { padding:12px 20px; min-height:44px; color:#527368; font-size:13px; cursor:pointer; }
.baseline-source-details .baseline-provenance { border-bottom:0; }
.baseline-browser { display:flex; flex-direction:column; }
.baseline-browser-head { flex-shrink:0; }
.baseline-list { height:auto; flex:1; }
.baseline-footer,.user-editor-footer { background:#fff; }
.user-editor-footer { position:sticky; bottom:0; padding-block:12px; border-top:1px solid var(--line); }
.preview-head { overflow:visible; gap:16px; }
.preview-head > div:first-child { min-width:0; }
.preview-head h2 { overflow-wrap:anywhere; white-space:normal; }
.preview-head .preview-downloads { position:relative; flex-shrink:0; flex-wrap:wrap; gap:8px; }
#historyDownloadMenu { position:static; }
.preview-head .preview-downloads > button { min-height:44px; font-size:14px; }
.history-workspace { border-radius:8px; }
.history-browser { display:flex; flex-direction:column; }
.history-browser-head { flex-shrink:0; }
.history-list { height:auto; flex:1; min-height:0; grid-auto-rows:max-content; align-content:start; }
.history-row { grid-template-columns:minmax(0,1fr); gap:6px; }
.history-row-title { white-space:normal; overflow-wrap:anywhere; overflow:visible; }
.history-row-meta { display:flex; flex-wrap:wrap; align-items:baseline; gap:4px 12px; color:#526761; font-size:12px; font-weight:400; }
.history-row time { color:#526761; font-size:12px; }
.history-row-detail { white-space:normal; overflow-wrap:anywhere; }
.baseline-item strong { font-size:15px; white-space:normal; overflow-wrap:anywhere; }
.baseline-item > span { color:#526761; font-size:12px; }
.baseline-item .baseline-identity { color:#405d55; font-size:13px; font-weight:500; white-space:normal; overflow-wrap:anywhere; }
.baseline-item .baseline-source-file { color:#63756e; font-size:12px; }
#baselineSource { color:#405d55; font-size:13px; line-height:1.6; overflow-wrap:anywhere; }
.preview-pane { overflow:visible; }
#previewContent { min-height:0; height:100%; display:flex; flex-direction:column; }
#previewContent.hidden { display:none; }
.preview-head,.preview-tabs { flex-shrink:0; }
.word-preview,.excel-preview { flex:1; min-height:0; }
body.authenticated #aiConfig { border:0; border-radius:0; background:transparent; padding:0; box-shadow:none; }
#aiConfig .actions { border-top:1px solid var(--line); padding-top:16px; justify-content:flex-end; }
#aiConfig .actions button { flex:0 1 auto; min-height:44px; }
#testAiBtn,#testBailianBtn { background:#fff; border:1px solid var(--line); color:#315b52; }
.bulk-actions .icon-control { flex:0 0 44px; }
.section-kicker { letter-spacing:0; }
@media(min-width:981px) {
  body.authenticated:has(:is(#history,#baselines):not(.hidden)) { height:100dvh; overflow:hidden; }
  body.authenticated:has(:is(#history,#baselines):not(.hidden)) :is(.app-shell,.app) { height:100dvh; min-height:0; overflow:hidden; }
  body.authenticated :is(#history,#baselines):not(.hidden) { display:flex; flex-direction:column; flex:1; min-height:0; margin:16px 20px 0; }
  :is(#history,#baselines) > .list-head { flex-shrink:0; }
  :is(.history-workspace,.baseline-workspace) { height:auto; min-height:0; flex:1; }
  /* Bound the grid row so long previews scroll inside the fixed workspace. */
  .history-workspace { grid-template-rows:minmax(0,1fr); align-items:stretch; overflow:visible; }
  .history-browser { min-height:0; overflow:hidden; border-radius:8px 0 0 8px; }
  .baseline-detail-head { position:sticky; top:0; background:#fff; z-index:2; }
  .baseline-footer { z-index:3; }
  body.authenticated:has(:is(#history,#baselines):not(.hidden)) .site-footer { padding:10px 20px; flex-shrink:0; }
}
@media(max-width:980px) {
  body.authenticated .sidebar { position:relative; }
  .baseline-list { flex:auto; max-height:240px; }
  .baseline-workspace { min-height:0; }
  .preview-head { flex-wrap:wrap; }
  #previewContent { height:auto; }
  .word-preview,.excel-preview { min-height:300px; }
}
@media(max-width:640px) {
  .preview-head .preview-downloads { width:100%; }
  .preview-head .preview-downloads > button { flex:1; }
  .baseline-detail-head { flex-wrap:wrap; gap:12px; }
  .baseline-footer,.user-editor-footer { gap:8px; padding:12px; flex-wrap:wrap; }
  .baseline-footer p,.user-editor-footer p { flex-basis:100%; }
  .baseline-footer button,.user-editor-footer button { width:100%; }
  #aiConfig .actions { gap:8px; }
  #aiConfig .actions button { flex:1; }
  .workspace-filter select { font-size:16px; }
}
