:root {
  --brand-blue: #781926;
  --brand-blue-dark: #5d1520;
  --brand-blue-soft: #f8eef0;
  --page: #f4f8fb;
  --paper: #ffffff;
  --ink: #173042;
  --muted: #6e8290;
  --line: #dce8ef;
  --danger: #bf3c48;
  --shadow: 0 18px 48px rgba(34, 89, 120, .10);
  font-family: "Microsoft YaHei", "PingFang SC", system-ui, sans-serif;
  color: var(--ink);
  background: var(--page);
}

* { box-sizing: border-box; }
body { margin: 0; min-width: 320px; background: var(--page); }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; transition: .18s ease; }
button:disabled { cursor: not-allowed; opacity: .45; }
.hidden { display: none !important; }
.muted { color: var(--muted); }

.boot-view { min-height: 100vh; display: grid; place-content: center; justify-items: center; gap: 8px; color: var(--brand-blue-dark); background: linear-gradient(145deg, #eef7fc, #f8fbfd); }
.boot-view strong { font-size: 24px; letter-spacing: .08em; }
.boot-view span { color: var(--muted); font-size: 13px; }

.login-view { min-height: 100vh; display: grid; place-items: center; padding: 24px; background: linear-gradient(145deg, #eef7fc, #f8fbfd); }
.login-card { width: min(430px, 100%); padding: 42px; border: 1px solid var(--line); border-radius: 24px; background: var(--paper); box-shadow: var(--shadow); }
.brand-mark { width: 64px; height: 64px; display: grid; place-items: center; border-radius: 18px; color: #fff; background: var(--brand-blue); font-weight: 800; letter-spacing: .08em; }
.login-brand-logo { width: 180px; height: auto; display: block; }
.brand-mark--small { width: 44px; height: 44px; border-radius: 13px; font-size: 13px; }
.eyebrow { margin: 24px 0 8px; color: var(--brand-blue); font-size: 12px; font-weight: 800; letter-spacing: .18em; }
.login-card h1 { margin: 0 0 10px; font-size: 28px; }
.stack-form { display: grid; gap: 17px; margin-top: 28px; }
label { display: grid; gap: 8px; color: #405765; font-size: 14px; font-weight: 700; }
input, select, textarea { width: 100%; min-height: 46px; padding: 0 14px; border: 1px solid var(--line); border-radius: 11px; color: var(--ink); background: #fff; outline: none; }
textarea { min-height: 92px; padding: 12px 14px; resize: vertical; line-height: 1.65; }
input:focus, select:focus, textarea:focus { border-color: var(--brand-blue); box-shadow: 0 0 0 3px rgba(38,127,181,.12); }
.form-error { min-height: 18px; margin: 0; color: var(--danger); font-size: 13px; }

.primary-button, .secondary-button { min-height: 44px; padding: 0 20px; border-radius: 10px; font-weight: 750; }
.primary-button { border: 1px solid var(--brand-blue); color: #fff; background: var(--brand-blue); }
.primary-button:hover { border-color: var(--brand-blue-dark); background: var(--brand-blue-dark); }
.secondary-button { border: 1px solid var(--line); color: var(--ink); background: #fff; }
.secondary-button:hover { border-color: #9dc9df; color: var(--brand-blue-dark); }
.compact { min-height: 40px; }
.text-button, .back-button, .icon-button { border: 0; color: var(--muted); background: transparent; }
.text-button { padding: 7px 4px; text-align: left; }
.text-button:hover, .back-button:hover { color: var(--brand-blue-dark); }
.danger-text { color: var(--danger); }

.admin-view { min-height: 100vh; }
.admin-layout { min-height: 100vh; display: grid; grid-template-columns: 236px minmax(0, 1fr); }
.app-sidebar { position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; padding: 26px 18px 20px; border-right: 1px solid var(--line); background: #fff; }
.brand-lockup { display: flex; align-items: center; gap: 12px; padding: 0 6px 27px; }
.brand-lockup strong, .brand-lockup span { display: block; }
.brand-lockup strong { font-size: 17px; }
.brand-lockup span { margin-top: 3px; color: var(--muted); font-size: 11px; }
.side-nav { display: grid; gap: 8px; }
.side-nav__item { min-height: 48px; padding: 0 16px; border: 0; border-radius: 11px; color: #536b7a; background: transparent; text-align: left; font-weight: 750; }
.side-nav__item:hover { color: var(--brand-blue-dark); background: #f1f8fc; }
.side-nav__item.active { color: #fff; background: var(--brand-blue); box-shadow: 0 9px 22px rgba(38,127,181,.2); }
.sidebar-account { margin-top: auto; display: grid; gap: 4px; padding: 18px 8px 0; border-top: 1px solid var(--line); }
.user-name { margin-bottom: 4px; color: var(--ink); font-size: 13px; font-weight: 750; }

.app-workspace { min-width: 0; padding: 42px clamp(24px, 4vw, 58px) 70px; }
.mobile-topbar { display: none; }
.workspace-panel { width: min(1180px, 100%); margin: 0 auto; }
.workspace-heading { margin-bottom: 24px; }
.workspace-heading h1 { margin: 0 0 8px; font-size: 30px; letter-spacing: -.02em; }
.workspace-heading p { margin: 0; color: var(--muted); line-height: 1.7; }
.case-toolbar { display: flex; align-items: end; justify-content: space-between; gap: 18px; margin-bottom: 20px; padding: 18px 20px; border: 1px solid var(--line); border-radius: 15px; background: #fff; }
.category-picker { width: min(480px, 100%); }
.toolbar-actions { display: flex; gap: 10px; flex: none; }
.content-card { padding: clamp(22px, 3vw, 34px); border: 1px solid var(--line); border-radius: 18px; background: #fff; box-shadow: var(--shadow); }
.section-title { display: flex; align-items: start; justify-content: space-between; gap: 18px; margin-bottom: 20px; }
.section-title h2 { margin: 0 0 5px; font-size: 21px; }
.section-title p { margin: 0; color: var(--muted); font-size: 13px; line-height: 1.6; }
.section-title--media { margin-top: 26px; }
.media-visibility-panel { margin-bottom: 20px; }
.media-visibility-actions { display: grid; gap: 12px; }
.media-visibility-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 14px 16px; border: 1px solid var(--line); border-radius: 12px; }
.media-visibility-row strong, .media-visibility-row span { display: block; }
.media-visibility-row span { margin-top: 4px; color: var(--muted); font-size: 13px; }
.media-visibility-note { margin: 14px 0 0; color: var(--muted); font-size: 12px; }
@media (max-width: 520px) { .media-visibility-row { align-items: stretch; flex-direction: column; } }
.count-pill { padding: 6px 10px; border-radius: 999px; color: var(--brand-blue-dark); background: var(--brand-blue-soft); font-size: 12px; white-space: nowrap; }

.case-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 15px; }
.patient-case-card { padding: 0; overflow: hidden; border: 1px solid var(--line); border-radius: 14px; color: var(--ink); background: #fff; text-align: left; }
.patient-case-card:hover { border-color: #9dc9df; transform: translateY(-2px); box-shadow: 0 12px 26px rgba(34,89,120,.1); }
.patient-case-card img, .patient-case-card__empty { width: 100%; aspect-ratio: 4 / 3; display: flex; align-items: center; justify-content: center; object-fit: contain; background: #eef5f8; }
.patient-case-card__empty { color: var(--muted); font-size: 13px; }
.patient-case-card__body { display: grid; gap: 5px; padding: 14px; }
.patient-case-card__body strong { font-size: 15px; }
.patient-case-card__body small { color: var(--muted); font-size: 12px; line-height: 1.45; }

.editor-bar { min-height: 58px; display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 14px; padding-bottom: 18px; border-bottom: 1px solid var(--line); }
.editor-bar > div { display: grid; justify-items: center; gap: 3px; }
.editor-bar > div span { color: var(--muted); font-size: 12px; }
.editor-bar .danger-text { justify-self: end; }
.back-button { padding: 8px 0; text-align: left; }
.case-summary-editor { margin-top: 18px; padding: 18px; border: 1px solid var(--line); border-radius: 14px; background: #f8fcfe; }
.case-summary-editor__heading { display: flex; align-items: center; justify-content: space-between; gap: 14px; margin-bottom: 15px; }
.case-summary-editor__heading strong, .case-summary-editor__heading span { display: block; }
.case-summary-editor__heading strong { font-size: 16px; }
.case-summary-editor__heading span { margin-top: 4px; color: var(--muted); font-size: 12px; line-height: 1.55; }
.case-summary-editor__grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; margin-bottom: 14px; }
.case-summary-editor__hint { margin: 9px 0 0; color: var(--muted); font-size: 12px; line-height: 1.5; }
.upload-zone { min-height: 104px; margin-top: 20px; display: flex; align-items: center; justify-content: center; flex-direction: column; gap: 6px; padding: 18px; border: 1.5px dashed #92c5dd; border-radius: 13px; color: var(--brand-blue-dark); background: #f5fbfe; text-align: center; cursor: pointer; }
.upload-zone--home { min-height: 132px; margin-top: 0; }
.upload-zone:hover, .upload-zone.dragging { border-color: var(--brand-blue); background: #edf8fd; }
.upload-zone input { display: none; }
.upload-zone strong { font-size: 17px; }
.upload-zone > span:last-child { color: var(--muted); font-size: 13px; line-height: 1.6; }
.upload-status { margin: 14px 0 0; padding: 12px 14px; border-radius: 10px; color: var(--brand-blue-dark); background: var(--brand-blue-soft); font-size: 13px; }

.media-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 15px; }
.media-items { display: contents; }
.media-card { position: relative; overflow: hidden; aspect-ratio: 4 / 3; border: 1px solid var(--line); border-radius: 13px; background: #edf3f6; }
.media-add-card { display: flex; align-items: center; justify-content: center; flex-direction: column; gap: 7px; padding: 16px; border: 1.5px dashed #92c5dd; color: var(--brand-blue-dark); background: #f5fbfe; text-align: center; cursor: pointer; }
.media-add-card:hover, .media-add-card.dragging { border-color: var(--brand-blue); background: #eaf6fc; }
.media-add-card input { display: none; }
.media-add-card strong { font-size: 15px; }
.media-add-card span { color: var(--muted); font-size: 12px; }
.media-card img, .media-card video { width: 100%; height: 100%; display: block; object-fit: contain; }
.media-card video { background: #173042; }
.media-card__processing { width: 100%; height: 100%; display: grid; place-content: center; justify-items: center; gap: 9px; color: var(--muted); }
.media-card__error { max-width: 86%; overflow: hidden; color: var(--danger); font-size: 11px; line-height: 1.35; text-align: center; text-overflow: ellipsis; white-space: nowrap; }
.media-card__spinner { width: 27px; height: 27px; border: 3px solid #c8dbe5; border-top-color: var(--brand-blue); border-radius: 50%; animation: media-spin .8s linear infinite; }
@keyframes media-spin { to { transform: rotate(360deg); } }
.media-card__badge, .media-card__meta { position: absolute; left: 9px; padding: 4px 7px; border-radius: 7px; color: #fff; background: rgba(23,48,66,.74); font-size: 10px; }
.media-card__badge { top: 9px; }
.media-card__badge--cover { color: #fff; background: var(--brand-blue); }
.media-card__meta { bottom: 9px; }
.media-card__delete { position: absolute; right: 9px; top: 9px; width: 32px; height: 32px; border: 0; border-radius: 9px; color: #fff; background: rgba(23,48,66,.76); font-size: 18px; }
.media-card__delete:hover { background: var(--danger); }
.media-card:not(.media-add-card) > img,
.media-card:not(.media-add-card) > video,
.media-card:not(.media-add-card) > .media-card__processing { position: absolute; inset: 0 0 42px; width: 100%; height: calc(100% - 42px); }
.media-card__actions { position: absolute; right: 0; bottom: 0; left: 0; height: 42px; display: flex; align-items: center; justify-content: center; gap: 5px; padding: 5px; border-top: 1px solid var(--line); background: #fff; }
.media-card__actions button { min-height: 30px; padding: 0 7px; border: 1px solid #bcd8e6; border-radius: 7px; color: var(--brand-blue-dark); background: #fff; font-size: 11px; font-weight: 700; }
.media-card__actions button:hover { color: #fff; background: var(--brand-blue); }
.media-card__actions button:disabled { opacity: .35; }
.home-photo-card__actions { position: absolute; right: 9px; bottom: 9px; display: flex; gap: 6px; }
.home-photo-card__actions button { width: 32px; height: 32px; padding: 0; border: 0; border-radius: 8px; color: #fff; background: rgba(23,48,66,.8); }
.home-photo-card__actions button.danger:hover { background: var(--danger); }

.empty-state { min-height: 180px; display: flex; align-items: center; justify-content: center; flex-direction: column; gap: 7px; padding: 20px; color: var(--muted); text-align: center; }
.empty-state strong { color: var(--ink); }
.empty-state span { max-width: 560px; font-size: 13px; line-height: 1.65; }
.empty-state--page { min-height: 300px; border: 1px dashed #bcd8e6; border-radius: 16px; background: #fff; }

.modal { width: min(460px, calc(100% - 30px)); padding: 0; border: 0; border-radius: 18px; background: transparent; }
.modal::backdrop { background: rgba(18,43,58,.48); backdrop-filter: blur(3px); }
.modal-card { display: grid; gap: 16px; padding: 28px; border-radius: 18px; background: #fff; box-shadow: var(--shadow); }
.modal-card h2 { margin: 0; font-size: 23px; }
.modal-heading { display: flex; align-items: start; justify-content: space-between; gap: 14px; }
.modal-heading p { margin: 5px 0 0; color: var(--muted); font-size: 13px; }
.icon-button { width: 34px; height: 34px; border-radius: 8px; font-size: 20px; }
.icon-button:hover { color: var(--ink); background: #edf5f9; }
.current-category { display: grid; gap: 6px; padding: 15px; border-radius: 11px; background: var(--brand-blue-soft); }
.current-category span { color: var(--muted); font-size: 12px; }
.settings-actions { display: grid; gap: 9px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; }
.toast { position: fixed; z-index: 30; left: 50%; bottom: 28px; transform: translateX(-50%); padding: 12px 20px; border-radius: 10px; color: #fff; background: #173042; box-shadow: var(--shadow); font-size: 13px; }

@media (max-width: 980px) {
  .case-grid, .media-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

@media (max-width: 760px) {
  .admin-layout { display: block; }
  .app-sidebar { position: sticky; z-index: 10; width: 100%; height: auto; display: grid; grid-template-columns: auto 1fr; align-items: center; gap: 12px; padding: 10px 14px; border-right: 0; border-bottom: 1px solid var(--line); }
  .brand-lockup { padding: 0; }
  .brand-lockup > div:last-child, .sidebar-account { display: none; }
  .side-nav { display: flex; justify-content: flex-end; gap: 6px; }
  .side-nav__item { min-height: 40px; padding: 0 14px; text-align: center; }
  .app-workspace { padding: 24px 12px 50px; }
  .mobile-topbar { display: flex; justify-content: space-between; margin-bottom: 20px; color: var(--muted); font-size: 12px; }
  .workspace-heading h1 { font-size: 25px; }
  .case-toolbar { align-items: stretch; flex-direction: column; padding: 15px; }
  .category-picker { width: 100%; }
  .toolbar-actions { display: grid; grid-template-columns: 1fr 1fr; }
  .content-card { padding: 18px 13px; }
  .case-grid, .media-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .editor-bar { grid-template-columns: 1fr auto; }
  .editor-bar > div { display: none; }
  .editor-bar .danger-text { justify-self: end; }
  .case-summary-editor__heading { align-items: stretch; flex-direction: column; }
  .case-summary-editor__grid { grid-template-columns: 1fr; }
  .upload-zone { min-height: 145px; }
  .login-card { padding: 32px 24px; }
}

/* 2026 clinical content workbench */
:root {
  --brand-pink: #781926;
  --brand-pink-soft: #f8eef0;
  --page: #f5f6f8;
  --paper: #ffffff;
  --ink: #1f2d38;
  --muted: #687783;
  --line: #dde3e8;
  --shadow: 0 12px 32px rgba(31, 45, 56, .07);
}

* { letter-spacing: 0; }
body, .boot-view, .login-view { background: var(--page); }
.admin-layout { grid-template-columns: 264px minmax(0, 1fr); }
.app-sidebar { padding: 24px 18px 20px; }
.brand-lockup { gap: 12px; padding: 0 6px 24px; }
.brand-logo { width: 76px; height: 60px; flex: 0 0 76px; display: block; object-fit: contain; background: #fff; }
.brand-lockup strong { font-size: 18px; }
.brand-lockup span { font-size: 12px; }
.side-nav__item { border-radius: 6px; }
.side-nav__item.active { box-shadow: none; }
.app-workspace { padding-top: 32px; }
.workspace-panel { width: min(1440px, 100%); }
.workspace-heading { margin-bottom: 18px; }
.workspace-heading > div { display: grid; gap: 4px; }
.workspace-kicker { color: var(--brand-pink); font-size: 11px; font-weight: 800; }
.workspace-heading h1 { margin: 0; font-size: 28px; }
.case-toolbar { margin-bottom: 16px; padding: 16px 18px; border-radius: 8px; box-shadow: 0 4px 16px rgba(31, 45, 56, .04); }
.content-card { padding: 24px; border-radius: 8px; box-shadow: var(--shadow); }
.primary-button, .secondary-button { border-radius: 6px; }
.primary-button { box-shadow: none; }
input, select, textarea { border-radius: 6px; }
.count-pill { border-radius: 999px; }
.case-grid { grid-template-columns: repeat(4, minmax(190px, 1fr)); }
.patient-case-card { min-width: 0; border-radius: 8px; }
.patient-case-card__body { gap: 7px; padding: 13px 14px 14px; }
.patient-case-card__meta { min-width: 0; display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.patient-case-card__body small { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.status-badge { display: inline-flex; align-items: center; min-height: 24px; padding: 3px 8px; border-radius: 999px; font-size: 11px; font-style: normal; font-weight: 750; white-space: nowrap; }
.status-badge--draft { color: #78642b; background: #fff7d9; }
.status-badge--published { color: #16744b; background: #e9f8f0; }
.editor-bar { grid-template-columns: minmax(180px, 1fr) auto minmax(280px, 1fr); padding: 4px 0 18px; }
.editor-identity { display: flex !important; align-items: center; justify-content: center; gap: 8px !important; }
.editor-actions { display: flex !important; align-items: center; justify-content: flex-end; gap: 10px !important; }
.editor-actions .danger-text { order: 2; }
.case-editor-layout { display: grid; grid-template-columns: minmax(0, 1fr) 286px; align-items: start; gap: 20px; margin-top: 20px; }
.case-editor-main { min-width: 0; display: grid; gap: 18px; }
.case-summary-editor { margin: 0; padding: 22px; border-radius: 8px; background: #fff; }
.case-summary-editor__heading { margin-bottom: 18px; }
.case-summary-editor__heading > div { display: grid; grid-template-columns: auto 1fr; column-gap: 10px; align-items: center; }
.case-summary-editor__heading > div > span:last-child { grid-column: 2; }
.section-index { color: var(--brand-pink) !important; font-size: 11px !important; font-weight: 800; }
.case-summary-editor__divider { height: 1px; margin: 22px 0; background: var(--line); }
.case-summary-editor__heading--subsection { margin-bottom: 14px; }
/* Mini-program card cover focus editor.
   The whole original image is drawn "contain" (fully visible, never cropped) and a
   focus frame sits on top of it; everything outside the frame is dimmed by the frame's
   oversized box-shadow, so no clipping or overflow hack is involved.
   The frame itself is locked to the mini-program card window ratio 334:458 (--cover-focus-ar):
   dragging / resizing that frame is exactly what the mini-program crops with. The edit area
   does NOT use that ratio, otherwise the frame could never move inside it and focusX/focusY
   would be stuck at 50. */
.case-cover-focus {
  --cover-focus-ar: 334 / 458;
  --cover-focus-max-w: 300px;
  --cover-focus-max-h: 420px;
  display: flex; flex-wrap: wrap; align-items: flex-start; gap: 18px;
}
/* viewport 是「框外压暗」的裁剪边界：.case-cover-focus__frame 用
   `box-shadow: 0 0 0 9999px rgba(0,0,0,.45)` 压暗框外，如果没有东西裁剪它，
   这层 45% 黑会糊满整个后台（侧边栏和导航全被压暗，看起来像功能没了）。
   这里用 padding+负 margin：既把裁剪框撑到取景框把手之外 12px（把手在框外 9px），
   又保持 stage 的视觉位置不变。 */
.case-cover-focus__viewport { flex: 0 0 auto; max-width: 100%; overflow: hidden; padding: 12px; margin: -12px; }
.case-cover-focus__stage { position: relative; overflow: visible; border: 1px solid var(--line); border-radius: 8px; background: #eef4f7; touch-action: none; user-select: none; -webkit-user-select: none; }
.case-cover-focus__image { position: absolute; inset: 0; display: block; border-radius: 7px; pointer-events: none; user-select: none; -webkit-user-drag: none; }
.case-cover-focus__frame { position: absolute; left: 0; top: 0; width: 120px; height: 120px; box-shadow: 0 0 0 1px rgba(255, 255, 255, .85), 0 0 0 9999px rgba(0, 0, 0, .45); cursor: grab; touch-action: none; }
.case-cover-focus__frame::after { content: ''; position: absolute; inset: 0; border: 1px solid rgba(255, 255, 255, .75); pointer-events: none; }
.case-cover-focus__frame.is-dragging { cursor: grabbing; }
.case-cover-focus__frame.is-resizing { cursor: nwse-resize; }
.case-cover-focus__ratio { position: absolute; top: 6px; left: 6px; padding: 2px 6px; border-radius: 4px; color: #fff; background: rgba(23, 48, 66, .66); font-size: 10px; letter-spacing: .5px; pointer-events: none; }
.case-cover-focus__handle { position: absolute; right: -9px; bottom: -9px; width: 18px; height: 18px; border: 2px solid #fff; border-radius: 50%; background: var(--brand-blue); box-shadow: 0 1px 5px rgba(0, 0, 0, .4); cursor: nwse-resize; touch-action: none; }
.case-cover-focus__handle::after { content: ''; position: absolute; inset: 4px; border-right: 1.5px solid #fff; border-bottom: 1.5px solid #fff; }
.case-cover-focus__badge { position: absolute; bottom: 8px; left: 8px; padding: 4px 8px; border-radius: 6px; color: #fff; background: rgba(23, 48, 66, .74); font-size: 10px; pointer-events: none; }
.case-cover-focus__message { flex: 0 0 100%; margin: 0; color: var(--muted); font-size: 12px; line-height: 1.8; overflow-wrap: anywhere; }
.case-cover-focus__message.is-error { color: var(--danger); }
.case-cover-focus__controls { flex: 1 1 220px; min-width: 200px; display: grid; gap: 9px; align-content: start; }
.case-cover-focus__slider input[type="range"] { padding: 0; border: 0; accent-color: var(--brand-blue); }
.case-cover-focus__meta { margin-top: 0; }
.case-cover-focus__meta strong { font-variant-numeric: tabular-nums; }
.case-cover-focus__hint { margin: 3px 0 0; color: var(--muted); font-size: 11px; line-height: 1.7; }
.case-action-editor { display: grid; grid-template-columns: minmax(0, 1fr) minmax(240px, 340px); gap: 18px; align-items: end; }
.case-action-editor__field { min-width: 0; }
.field-meta { display: flex; justify-content: space-between; gap: 12px; margin-top: 7px; color: var(--muted); font-size: 12px; }
.field-meta strong { color: var(--ink); }
.case-action-preview { display: grid; gap: 7px; }
.case-action-preview__eyebrow { color: var(--muted); font-size: 11px; font-weight: 750; }
.case-action-preview__card { min-height: 64px; display: grid; grid-template-columns: minmax(0, 1fr) 24px; align-items: center; gap: 10px; padding: 10px 13px 10px 15px; border: 1px solid #f4bfd6; border-radius: 8px; color: var(--brand-pink); background: var(--brand-pink-soft); }
.case-action-preview__card > span:first-child { display: -webkit-box; overflow: hidden; line-height: 1.35; -webkit-box-orient: vertical; -webkit-line-clamp: 2; overflow-wrap: anywhere; }
.case-action-preview__card > span:last-child { width: 24px; text-align: center; font-size: 22px; }
.form-footer { min-height: 24px; display: flex; align-items: center; justify-content: space-between; gap: 14px; }
.save-status { margin: 9px 0 0; font-size: 12px; font-weight: 750; text-align: right; }
.save-status.is-saving { color: var(--brand-blue); }
.save-status.is-success { color: #16744b; }
.save-status.is-error { color: var(--danger); }
.media-workbench { padding: 22px; border: 1px solid var(--line); border-radius: 8px; background: #fff; }
.section-title--media { margin: 0 0 18px; }
.section-title--media > div { display: grid; grid-template-columns: auto 1fr; column-gap: 10px; align-items: center; }
.section-title--media > div > p { grid-column: 2; }
.media-grid { grid-template-columns: repeat(3, minmax(170px, 1fr)); }
.media-card { border-radius: 8px; }
.publish-checklist { position: sticky; top: 24px; padding: 20px; border: 1px solid var(--line); border-radius: 8px; background: #fff; box-shadow: 0 8px 24px rgba(31, 45, 56, .06); }
.publish-checklist__header h2 { margin: 7px 0 4px; font-size: 18px; }
.publish-checklist__header p { margin: 0; color: var(--muted); font-size: 12px; line-height: 1.6; }
.publish-checklist__items { display: grid; gap: 4px; margin: 18px 0; padding: 0; list-style: none; }
.publish-checklist__item { display: grid; grid-template-columns: 24px minmax(0, 1fr); align-items: center; gap: 9px; min-height: 38px; color: var(--muted); font-size: 13px; }
.publish-checklist__icon { width: 22px; height: 22px; display: grid; place-items: center; border-radius: 50%; color: #fff; background: #a9b4bc; font-size: 12px; font-weight: 800; }
.publish-checklist__item.is-complete { color: #16744b; }
.publish-checklist__item.is-complete .publish-checklist__icon { background: #24a46d; }
.publish-checklist__item.is-blocked { color: #8b5c24; }
.publish-checklist__item.is-blocked .publish-checklist__icon { background: #d79b43; }
.publish-checklist__notice { margin: 0; padding-top: 16px; border-top: 1px solid var(--line); color: var(--muted); font-size: 11px; line-height: 1.7; }
.upload-status { border-radius: 6px; }
.modal, .modal-card, .current-category { border-radius: 8px; }
.toast { max-width: min(560px, calc(100vw - 32px)); border-radius: 6px; overflow-wrap: anywhere; }

@media (max-width: 1100px) {
  .admin-layout { grid-template-columns: 224px minmax(0, 1fr); }
  .app-workspace { padding-inline: 24px; }
  .case-grid { grid-template-columns: repeat(3, minmax(170px, 1fr)); }
  .editor-bar { grid-template-columns: minmax(130px, 1fr) auto minmax(220px, 1fr); }
  .editor-actions { gap: 4px !important; }
  .editor-actions .primary-button { padding-inline: 12px; }
  .editor-actions .danger-text { font-size: 12px; }
  .content-card, .case-editor, .case-editor-layout, .case-editor-main, .case-summary-editor, .media-workbench { min-width: 0; }
  .case-editor-layout { grid-template-columns: minmax(0, 1fr); }
  .media-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .publish-checklist { position: static; }
  .publish-checklist__items { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 900px) {
  .case-action-editor { grid-template-columns: 1fr; align-items: stretch; }
  .case-cover-focus { --cover-focus-max-w: 260px; --cover-focus-max-h: 360px; }
  .case-cover-focus__controls { flex-basis: 100%; }
}

@media (max-width: 760px) {
  .admin-layout { display: block; }
  .app-sidebar { grid-template-columns: auto 1fr; }
  .brand-logo { width: 54px; height: 42px; flex-basis: 54px; }
  .app-workspace { padding: 20px 12px 48px; }
  .workspace-kicker { display: none; }
  .case-toolbar, .content-card, .case-summary-editor, .media-workbench, .publish-checklist { border-radius: 8px; }
  .content-card { padding: 16px 12px; }
  .case-grid, .media-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .editor-bar { grid-template-columns: 1fr; gap: 10px; }
  .editor-bar > .editor-identity { display: flex !important; grid-row: 1; }
  .editor-bar > .back-button { grid-row: 2; }
  .editor-actions { grid-row: 3; justify-content: stretch; }
  .editor-actions > button { flex: 1; min-width: 0; }
  .case-action-editor { grid-template-columns: 1fr; }
  .case-summary-editor { padding: 17px 14px; }
  .case-summary-editor__heading > .primary-button { width: 100%; }
  .form-footer { align-items: start; flex-direction: column; }
  .save-status { text-align: left; }
  .publish-checklist__items { grid-template-columns: 1fr; }
}

/* Mini-program ordering workbench */
.ordering-heading { display: flex; align-items: end; justify-content: space-between; gap: 24px; }
.ordering-save-status { min-width: 220px; margin: 0 0 4px; color: var(--muted); font-size: 13px; font-weight: 750; text-align: right; }
.ordering-save-status.is-saving { color: var(--brand-blue); }
.ordering-save-status.is-success { color: #16744b; }
.ordering-save-status.is-error { color: var(--danger); }
.ordering-workbench { min-width: 0; display: grid; grid-template-columns: minmax(300px, .72fr) minmax(0, 1.6fr); gap: 18px; }
.ordering-column { min-width: 0; padding: 22px; border: 1px solid var(--line); border-radius: 8px; background: #fff; box-shadow: var(--shadow); }
.ordering-column__header { min-height: 74px; display: flex; align-items: start; justify-content: space-between; gap: 14px; padding-bottom: 18px; border-bottom: 1px solid var(--line); }
.ordering-column__header h2 { margin: 4px 0 5px; font-size: 19px; }
.ordering-column__header p { margin: 0; color: var(--muted); font-size: 12px; line-height: 1.6; }
.ordering-category-list { display: grid; gap: 8px; margin-top: 14px; }
.ordering-category-row { min-width: 0; display: grid; grid-template-columns: 34px minmax(0, 1fr) auto; align-items: center; gap: 10px; min-height: 72px; padding: 10px; border: 1px solid var(--line); border-radius: 8px; background: #fff; }
.ordering-category-row.is-selected { border-color: #83bcd9; background: #f2f9fc; box-shadow: inset 3px 0 0 var(--brand-blue); }
.ordering-position { width: 30px; height: 30px; display: grid; place-items: center; border-radius: 6px; color: var(--brand-blue-dark); background: var(--brand-blue-soft); font-size: 11px; font-weight: 800; }
.ordering-category-select { min-width: 0; display: grid; gap: 5px; padding: 4px 0; border: 0; color: var(--ink); background: transparent; text-align: left; }
.ordering-category-select strong, .ordering-category-select span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ordering-category-select strong { font-size: 14px; }
.ordering-category-select span { color: var(--muted); font-size: 11px; }
.ordering-controls { display: flex; gap: 5px; }
.ordering-controls button { width: 34px; height: 34px; padding: 0; border: 1px solid #bad6e4; border-radius: 6px; color: var(--brand-blue-dark); background: #fff; font-size: 16px; font-weight: 800; }
.ordering-controls button:hover:not(:disabled) { color: #fff; border-color: var(--brand-blue); background: var(--brand-blue); }
.ordering-case-grid { min-width: 0; display: grid; grid-template-columns: repeat(3, minmax(150px, 1fr)); gap: 12px; margin-top: 14px; }
.ordering-case-card { min-width: 0; overflow: hidden; border: 1px solid var(--line); border-radius: 8px; background: #fff; }
.ordering-case-cover { position: relative; aspect-ratio: 4 / 3; display: grid; place-items: center; overflow: hidden; color: var(--muted); background: #eef4f7; font-size: 12px; }
.ordering-case-cover img { width: 100%; height: 100%; display: block; object-fit: contain; }
.ordering-position--cover { position: absolute; top: 8px; left: 8px; color: #fff; background: rgba(23, 48, 66, .78); }
.ordering-case-card__body { display: grid; gap: 9px; padding: 12px; }
.ordering-case-card__body > div:first-child { min-width: 0; display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.ordering-case-card__body strong { min-width: 0; overflow: hidden; font-size: 13px; text-overflow: ellipsis; white-space: nowrap; }
.ordering-case-card__body small { color: var(--muted); font-size: 11px; }
.ordering-case-card__body .ordering-controls { justify-content: flex-end; padding-top: 8px; border-top: 1px solid var(--line); }
.ordering-empty { min-height: 160px; display: grid; place-items: center; color: var(--muted); font-size: 13px; }

@media (max-width: 1100px) {
  .ordering-workbench { grid-template-columns: 1fr; }
  .ordering-category-list { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .ordering-case-grid { grid-template-columns: repeat(3, minmax(150px, 1fr)); }
}

@media (max-width: 760px) {
  .ordering-heading { align-items: stretch; flex-direction: column; gap: 8px; }
  .ordering-save-status { min-width: 0; text-align: left; }
  .ordering-column { padding: 16px 12px; }
  .ordering-category-list { grid-template-columns: 1fr; }
  .ordering-case-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 9px; }
  .ordering-category-row { grid-template-columns: 30px minmax(0, 1fr) auto; gap: 7px; padding: 8px; }
  .ordering-controls button { width: 32px; height: 32px; }
}


/* ============================================================================
   2026 后台傻瓜化改版（规格 3 / 4 / 5）
   - 统一圆角 12px / 内边距 20-24px / 块间距 20px / 边框 1px solid #e6ecf2
   - 字号阶梯：页面标题 20px / 区块标题 15px / 正文 14px / 辅助 12.5px
   - 红色只给危险操作；状态色 绿✓ 橙! 灰○；主按钮实心、次按钮描边、文字按钮无边框
   - 输入框统一 38px 高、8px 圆角、聚焦主色描边
   注意：.case-cover-focus 那一整块是取景契约锁定的样式，下面只做增量覆盖，不改语义。
   ============================================================================ */
:root {
  --card-radius: 12px;
  --card-gap: 20px;
  --card-border: #e6ecf2;
  --panel-padding: 22px;
  --ok: #24a46d;
  --warn: #d79b43;
  --ok-text: #16744b;
  --warn-text: #8b5c24;
  --fs-page: 20px;
  --fs-section: 15px;
  --fs-body: 14px;
  --fs-help: 12.5px;
}

.workspace-heading h1 { font-size: var(--fs-page); }
.section-title h2,
.media-workbench .section-title h2,
.publish-checklist__header h2,
.ordering-column__header h2,
.step-block__title { font-size: var(--fs-section); }
.workspace-heading p,
.section-title p,
.step-block__hint,
.ordering-column__header p { font-size: var(--fs-help); }
label,
.publish-checklist__item,
.ordering-category-select strong { font-size: var(--fs-body); }
.form-error,
.save-status,
.ordering-save-status,
.field-meta,
.count-pill,
.publish-checklist__notice,
.case-cover-focus__hint { font-size: var(--fs-help); }

input, select, textarea { min-height: 38px; border-radius: 8px; }
.case-toolbar, .content-card, .media-workbench, .publish-checklist, .ordering-column,
.case-summary-editor, .patient-case-card, .media-card, .ordering-category-row,
.ordering-case-card, .modal-card { border-radius: var(--card-radius); border-color: var(--card-border); }
.case-editor-layout { gap: var(--card-gap); }
.case-editor-main { gap: var(--card-gap); }
.content-card { padding: var(--panel-padding); }
.primary-button.toolbar-primary { min-height: 46px; padding-inline: 24px; font-size: var(--fs-section); }

/* ---- 顶部操作条：吸顶，滚动时始终可见（规格 2.1） ---- */
.editor-bar {
  position: sticky; top: 0; z-index: 6;
  grid-template-columns: minmax(150px, 1fr) auto minmax(320px, 1.4fr);
  gap: 12px; padding: 10px 2px 12px; background: #fff;
}
.editor-actions { flex-wrap: wrap; row-gap: 8px; }
.editor-actions > button, .editor-actions > .editor-more { flex: none; }
#saveCaseContentButton.has-unsaved { box-shadow: 0 0 0 3px rgba(38, 127, 181, .2); }

/* ---- 「⋯ 更多」菜单：删除案例收纳在这里，仍然是红色 + 二次确认 ---- */
.editor-more { position: relative; }
.editor-more__summary { display: inline-flex; align-items: center; list-style: none; cursor: pointer; }
.editor-more__summary::-webkit-details-marker { display: none; }
.editor-more[open] > .editor-more__summary { border-color: #9dc9df; color: var(--brand-blue-dark); }
.editor-more__menu {
  position: absolute; right: 0; top: calc(100% + 6px); z-index: 12;
  min-width: 168px; padding: 6px; border: 1px solid var(--card-border);
  border-radius: 10px; background: #fff; box-shadow: 0 14px 32px rgba(31, 45, 56, .16);
}
.editor-more__menu .text-button { display: block; width: 100%; padding: 10px 12px; border-radius: 8px; text-align: left; }
.editor-more__menu .text-button:hover { background: #fdf2f3; }

/* ---- 流水线四个步骤块（规格 2） ---- */
.step-block { padding: 18px; border: 1px solid var(--card-border); border-radius: var(--card-radius); background: #fff; }
.step-block--media { padding: var(--panel-padding); }
.step-block + .step-block { margin-top: 0; }
.step-block__header { display: flex; align-items: flex-start; justify-content: space-between; gap: 14px; margin-bottom: 14px; }
.step-block__titles { display: grid; grid-template-columns: auto minmax(0, 1fr); column-gap: 10px; align-items: center; }
.step-block__no { color: var(--brand-pink); font-size: 15px; font-weight: 800; }
.step-block__title { display: block; margin: 0 0 4px; }
.step-block__hint { display: block; color: var(--muted); line-height: 1.6; }
.step-block__status {
  flex: none; min-height: 26px; display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 10px; border-radius: 999px; font-size: 12.5px; font-weight: 750; white-space: nowrap;
}
.step-block__status.is-done { color: var(--ok-text); background: #e9f8f0; }
.step-block__status.is-todo,
.step-block__status.is-warn { color: var(--warn-text); background: #fdf3e3; }
.step-block__status.is-optional { color: var(--muted); background: #f2f5f7; }
.step-block.is-flashing { animation: step-flash 1.5s ease; }
@keyframes step-flash {
  0% { box-shadow: 0 0 0 0 rgba(38, 127, 181, 0); border-color: var(--card-border); }
  22% { box-shadow: 0 0 0 4px rgba(38, 127, 181, .26); border-color: var(--brand-blue); }
  100% { box-shadow: 0 0 0 0 rgba(38, 127, 181, 0); border-color: var(--card-border); }
}

/* ---- 患者端实时预览卡（规格 2.2）：尺寸模拟小程序卡片 ---- */
.case-patient-preview { flex: 0 0 auto; margin: 0; display: grid; gap: 8px; justify-items: start; }
.case-patient-preview__caption strong { display: block; color: var(--ink); font-size: var(--fs-help); font-weight: 800; }
.case-patient-preview__caption span { display: block; margin-top: 2px; color: var(--muted); font-size: 11.5px; }
/* 底 #fff6fa、边 #f4dce8、圆角 11px —— 与小程序卡片一致；封面区比例恒为 334:458。 */
.case-patient-preview__card {
  width: 182px; max-width: 100%; overflow: hidden; border: 1px solid #f4dce8;
  border-radius: 11px; background: #fff6fa; box-shadow: 0 8px 20px rgba(214, 132, 165, .16);
}
.case-patient-preview__window {
  position: relative; width: 160px; max-width: 100%; aspect-ratio: 334 / 458;
  margin: 0 auto; overflow: hidden; background: #f3e7ec;
}
.case-patient-preview__image { position: absolute; left: 0; top: 0; width: 100%; height: 100%; object-fit: cover; pointer-events: none; }
.case-patient-preview__empty {
  position: absolute; inset: 0; display: grid; place-items: center;
  color: #b98aa0; background: #f8eef3; font-size: 12px;
}
.case-patient-preview__bar {
  min-height: 28px; display: flex; align-items: center; justify-content: space-between; gap: 6px;
  padding: 0 10px; color: #fff; background: rgba(31, 45, 56, .62); font-size: 12px; line-height: 1.3;
}
.case-patient-preview__bar > span:first-child {
  min-width: 0; display: -webkit-box; overflow: hidden; text-shadow: 0 1px 2px rgba(0, 0, 0, .55);
  -webkit-box-orient: vertical; -webkit-line-clamp: 2; overflow-wrap: anywhere;
}
.case-patient-preview__bar > span:last-child { flex: none; font-size: 16px; }
.case-patient-preview__hint { max-width: 220px; margin: 0; color: var(--muted); font-size: 11.5px; line-height: 1.6; }
.readout-hint { color: var(--muted); font-size: 11.5px; font-style: normal; font-weight: 500; }

/* ---- 发布就绪度（规格 2.3） ---- */
.publish-checklist__summary { color: var(--muted); font-size: var(--fs-help); line-height: 1.6; }
.publish-checklist__summary.is-ready { color: var(--ok-text); font-weight: 750; }
.publish-checklist__summary.is-blocked { color: var(--warn-text); font-weight: 750; }
.publish-checklist__item { grid-template-columns: 24px minmax(0, 1fr) auto; }
.publish-checklist__jump {
  min-height: 26px; padding: 0 9px; border: 1px solid #ecd3b0; border-radius: 999px;
  color: var(--warn-text); background: #fffaf2; font-size: 11.5px; font-weight: 750;
}
.publish-checklist__jump:hover { color: #fff; border-color: var(--warn); background: var(--warn); }

/* ---- 列表页（规格 3）：9:10 取景缩略图 + 案例名 + 状态徽标 + 文件数 ---- */
.patient-case-card img, .patient-case-card__empty { aspect-ratio: 9 / 10; }
.patient-case-card img { object-fit: cover; }
.patient-case-card__body strong { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.status-badge--offline { color: #5b6873; background: #eef1f4; }
.home-photo-card__broken { display: grid; place-items: center; width: 100%; height: 100%; color: var(--muted); background: #eef5f8; font-size: 12px; }

/* ---- 侧边栏账号区：桌面端摊开，≤760px 折进「账号」下拉（规格 5 的真 bug 修复） ---- */
.account-menu__summary { display: none; }
/* 桌面上 .account-menu__body 必须是正常布局的块，否则修改密码 / 退出登录会被折进未展开的 details 里点不到。 */
.account-menu__body { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.account-menu__body .user-name { margin: 0; }
.account-menu__caret { display: none; }

@media (max-width: 1100px) {
  .editor-bar { grid-template-columns: minmax(120px, 1fr) auto minmax(220px, 1.4fr); }
  .case-patient-preview__hint { max-width: 180px; }
}

@media (max-width: 900px) {
  .case-patient-preview { justify-items: stretch; }
}

@media (max-width: 760px) {
  /* 账号入口：原来 .sidebar-account 被 display:none 藏掉，手机上完全点不到改密/退出。
     现在折叠成顶部条右上角的「账号」下拉，点开就能改密/退出。 */
  .app-sidebar { overflow: visible; }
  .sidebar-account { position: relative; display: block; margin: 0; padding: 0; border-top: 0; }
  .account-menu { position: relative; }
  .account-menu > .account-menu__summary {
    display: inline-flex; align-items: center; gap: 4px; min-height: 38px; padding: 0 12px;
    border: 1px solid var(--card-border); border-radius: 999px; color: var(--ink);
    background: #fff; font-size: 12.5px; font-weight: 750; cursor: pointer; list-style: none;
  }
  .account-menu > .account-menu__summary::-webkit-details-marker { display: none; }
  .account-menu[open] > .account-menu__summary { border-color: #9dc9df; color: var(--brand-blue-dark); }
  .account-menu__caret { display: inline; font-size: 10px; }
  .account-menu > .account-menu__body {
    position: absolute; right: 0; top: calc(100% + 6px); z-index: 16;
    min-width: 168px; display: grid; gap: 2px; padding: 8px; border: 1px solid var(--card-border);
    border-radius: 12px; background: #fff; box-shadow: 0 16px 34px rgba(31, 45, 56, .18);
  }
  .account-menu > .account-menu__body .user-name,
  .account-menu > .account-menu__body .account-menu__hint { padding: 0 10px 6px; color: var(--muted); }
  .account-menu > .account-menu__body .account-menu__hint { font-size: 11.5px; }
  .account-menu > .account-menu__body .text-button {
    display: block; width: 100%; min-height: 40px; padding: 0 12px; border-radius: 8px;
    color: var(--ink); text-align: left; font-weight: 700;
  }
  .account-menu > .account-menu__body .text-button:hover { color: var(--brand-blue-dark); background: #f1f8fc; }
  .account-menu > .account-menu__body #logoutButton { color: var(--danger); }
  .account-menu > .account-menu__body #logoutButton:hover { background: #fdf2f3; }

  /* 编辑条：窄屏不横向溢出，按钮可换行，仍然吸顶 */
  .editor-bar { top: 0; grid-template-columns: minmax(0, 1fr) auto; padding: 8px; }
  .editor-actions { grid-column: 1 / -1; justify-content: stretch; }
  .editor-actions > button { flex: 1 1 auto; min-width: 0; }
  .editor-actions > .editor-more { flex: 0 0 auto; }
  .step-block { padding: 14px; }
  .step-block__header { flex-direction: column; gap: 8px; }
  .case-patient-preview__card { width: min(182px, 100%); }
  .case-patient-preview__window { width: min(160px, 100%); }
  .case-patient-preview__hint { max-width: none; }
  .publish-checklist__item { grid-template-columns: 24px minmax(0, 1fr) auto; }
}

/* 放在文件最后：把旧媒体查询里针对编辑条的定位规则按新结构收口（旧规则在源码里更靠后，必须压过来）。 */
@media (max-width: 1100px) {
  .editor-bar { grid-template-columns: minmax(120px, 1fr) auto minmax(220px, 1.4fr); }
}

@media (max-width: 760px) {
  .editor-bar { grid-template-columns: minmax(0, 1fr) auto; }
  .editor-bar > .editor-identity { grid-row: 1; grid-column: 2; display: flex !important; justify-content: flex-end; }
  .editor-bar > .back-button { grid-row: 1; grid-column: 1; }
  .editor-actions { grid-row: 2; grid-column: 1 / -1; display: flex !important; justify-content: stretch; }
  .editor-actions > button { flex: 1 1 0; min-width: 0; }
  .editor-actions > .editor-more { flex: 0 0 auto; }
}
/* 最后的兜底：窄屏账号区必须可见。
   源码里更靠前的那条 `.brand-lockup > div:last-child, .sidebar-account { display: none; }`
   就是「手机上改密/退出点不到」的真 bug；这里用同权重、更靠后的规则把它压回来。 */
@media (max-width: 760px) {
  .app-sidebar .brand-lockup > div:last-child { display: none; }
  .app-sidebar .sidebar-account { display: block; }
}

.home-tooth-preview-wrap { margin-bottom: 24px; padding: 20px; border: 1px solid var(--line); border-radius: 14px; background: #fff; }
.home-tooth-preview { position: relative; width: min(100%, 340px); aspect-ratio: 1280 / 1451; margin: 18px auto 4px; overflow: hidden; background: #fff; }
.home-tooth-preview__photos { position: absolute; inset: 2px; display: grid; grid-template-columns: repeat(9, 1fr); grid-template-rows: repeat(11, 1fr); gap: 1px; }
.home-tooth-preview__cell { position: relative; width: 100%; height: 100%; min-width: 0; min-height: 0; overflow: hidden; box-sizing: border-box; border: 0; padding: 0; background: #f7f4f2; cursor: pointer; }
.home-tooth-preview__cell img, .home-display-card img { position: absolute; display: block; max-width: none; }
.home-tooth-preview__cell--empty { background: #f2eeeb; }
.home-tooth-preview__overlay { position: absolute; inset: 0; z-index: 2; width: 100%; height: 100%; pointer-events: none; }
.home-tooth-preview__half { position: absolute; top: 0; width: 50%; height: 100%; overflow: hidden; }
.home-tooth-preview__half--left { left: 0; }
.home-tooth-preview__half--right { right: 0; transform: scaleX(-1); }
.home-tooth-preview__half img { position: absolute; top: 0; left: 0; display: block; width: 200%; height: 100%; max-width: none; }
.home-display-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(112px, 1fr)); gap: 10px; margin-top: 15px; }
.home-display-card { position: relative; aspect-ratio: 72.89 / 67.55; overflow: hidden; padding: 0; border: 1px solid var(--line); border-radius: 8px; background: #f7f4f2; cursor: pointer; }
.home-display-card span { position: absolute; left: 5px; top: 5px; padding: 2px 5px; border-radius: 4px; color: #fff; background: rgba(45, 24, 28, .75); font-size: 11px; }
.home-display-card:hover, .home-display-card:focus-visible { outline: 2px solid #781926; outline-offset: 1px; }
.home-crop-dialog { width: min(92vw, 520px); }
.home-crop-frame { position: relative; width: min(100%, 400px); aspect-ratio: 72.89 / 67.55; margin: 18px auto; overflow: hidden; background: #f7f4f2; border: 2px solid #781926; border-radius: 8px; cursor: grab; touch-action: none; }
.home-crop-frame:active { cursor: grabbing; }
.home-crop-frame img { position: absolute; display: block; max-width: none; pointer-events: none; user-select: none; }
.home-crop-zoom { display: flex; align-items: center; gap: 12px; }
.home-crop-zoom input { flex: 1; accent-color: #781926; }
.home-crop-zoom output { min-width: 58px; text-align: right; }

/* Donghao admin: quiet white surfaces with restrained burgundy accents. */
:root {
  --brand-blue: #781926;
  --brand-blue-dark: #5d1520;
  --brand-blue-soft: #f8eef0;
  --brand-pink: #781926;
  --brand-pink-soft: #f8eef0;
  --page: #faf9f8;
  --paper: #fff;
  --ink: #30292b;
  --muted: #786e70;
  --line: #e9e3e3;
  --card-border: #e9e3e3;
  --shadow: 0 8px 26px rgba(64, 31, 36, .045);
}
.app-sidebar { background: #fff; }
.side-nav__item { color: #62585a; }
.side-nav__item:hover { color: var(--brand-blue); background: #faf3f4; }
.side-nav__item.active { color: var(--brand-blue); background: #f8eef0; box-shadow: inset 3px 0 0 var(--brand-blue); }
.count-pill { color: var(--brand-blue); background: var(--brand-blue-soft); }
.upload-zone, .media-add-card { border-color: #d9b8bf; color: var(--brand-blue); background: #fffaf9; }
.upload-zone:hover, .upload-zone.dragging, .media-add-card:hover, .media-add-card.dragging { border-color: var(--brand-blue); background: #fcf2f3; }
input:focus, select:focus, textarea:focus { box-shadow: 0 0 0 3px rgba(120,25,38,.12); }
.secondary-button:hover, .icon-button:hover { border-color: #d7b9bf; color: var(--brand-blue); background: #fff8f8; }
.modal::backdrop { background: rgba(42, 27, 31, .38); }

.home-workbench { display: grid; grid-template-columns: minmax(0, 1fr); align-items: start; gap: 26px; }
.home-tooth-preview-wrap { margin: 0; padding: 24px; border-color: var(--line); background: #fff; }
.home-tooth-preview { width: min(100%, 680px); margin: 22px auto 14px; }
.home-tooth-toolbar { display: flex; align-items: center; justify-content: center; flex-wrap: wrap; gap: 12px; margin-top: 14px; color: var(--muted); font-size: 13px; }
.home-tooth-toolbar button[aria-pressed="true"] { color: #fff; border-color: var(--brand-blue); background: var(--brand-blue); }
.home-tooth-preview__cell--empty { color: #bdaeb0; font-size: 20px; font-weight: 300; }
.home-tooth-preview__cell:hover, .home-tooth-preview__cell:focus-visible, .home-tooth-preview__cell.is-drop-target, .home-tooth-preview__cell.is-swap-source { outline: 2px solid var(--brand-blue); outline-offset: -2px; z-index: 1; }
.home-tooth-preview__cell.is-dragging { opacity: .55; }
.home-preview-note { margin: 0; color: var(--muted); font-size: 13px; line-height: 1.7; text-align: center; }
.home-manage-panel { min-width: 0; }
.home-manage-panel .section-title { align-items: center; margin-bottom: 12px; }
.home-manage-panel .upload-zone { margin-top: 0; min-height: 116px; }
.home-manage-panel .upload-zone.is-full { cursor: default; border-style: solid; border-color: var(--line); color: var(--muted); background: #faf9f8; }
.home-photo-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(166px, 1fr)); gap: 14px; margin-top: 20px; }
.home-photo-card { min-width: 0; overflow: hidden; border: 1px solid var(--line); border-radius: 12px; background: #fff; }
.home-photo-card__preview { position: relative; display: block; width: 100%; padding: 0; border: 0; background: #f7f4f2; }
.home-photo-card__preview img { display: block; width: 100%; aspect-ratio: 1.12; object-fit: cover; }
.home-photo-card__preview:hover img { opacity: .88; }
.home-photo-card__number { position: absolute; top: 8px; left: 8px; display: grid; place-items: center; min-width: 24px; height: 24px; padding: 0 5px; border-radius: 6px; color: #fff; background: rgba(55, 35, 39, .78); font-size: 11px; }
.home-photo-card__actions { position: static; display: flex; align-items: center; gap: 5px; padding: 8px; border-top: 1px solid var(--line); background: #fff; }
.home-photo-card__actions button { display: grid; place-items: center; width: 30px; height: 30px; flex: none; padding: 0; border: 1px solid var(--line); border-radius: 7px; color: var(--ink); background: #fff; }
.home-photo-card__actions button:hover:not(:disabled) { border-color: #cba5ae; color: var(--brand-blue); background: #fff7f8; }
.home-photo-card__actions .home-photo-card__edit { display: block; width: auto; min-width: 0; flex: 1; padding: 0 5px; border-color: #ead2d7; color: var(--brand-blue); background: #fbf2f3; font-size: 12px; font-weight: 700; }
.home-photo-card__actions .danger { color: #aa4248; }
.home-crop-modal { width: min(900px, calc(100% - 28px)); max-height: calc(100dvh - 28px); overflow: auto; }
.home-crop-dialog { width: 100%; padding: clamp(18px, 3vw, 30px); gap: 20px; }
.home-crop-workspace { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, .9fr); align-items: start; gap: 18px; }
.home-crop-live { display: flex; flex-direction: column; align-items: center; gap: 4px; color: var(--muted); font-size: 13px; }
.home-tooth-preview--crop { width: min(100%, 320px); margin: 6px auto 0; }
.home-tooth-preview--crop .home-tooth-preview__cell { pointer-events: none; }
.home-crop-dialog .modal-heading { align-items: start; }
.home-crop-dialog .modal-heading h2 { font-size: 21px; }
.home-crop-dialog .modal-heading p { line-height: 1.55; }
.home-crop-workspace { padding: 18px; border: 1px solid var(--line); border-radius: 12px; background: #faf8f7; }
.home-crop-frame { width: min(100%, 490px); margin: 0 auto; border: 2px solid var(--brand-blue); border-radius: 8px; box-shadow: 0 9px 20px rgba(64,31,36,.08); }
.home-crop-hint { margin: 13px 0 0; color: var(--muted); font-size: 12px; text-align: center; }
.home-crop-zoom { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: 14px; margin: 0; }
.home-crop-zoom input { width: 100%; min-width: 0; min-height: 30px; padding: 0; border: 0; accent-color: var(--brand-blue); box-shadow: none; }
.home-crop-zoom output { min-width: 64px; font-variant-numeric: tabular-nums; }
.home-crop-dialog .modal-actions { flex-wrap: wrap; padding-top: 15px; border-top: 1px solid var(--line); }
@media (max-width: 1080px) { .home-workbench { grid-template-columns: 1fr; } }
@media (max-width: 600px) {
  .home-workbench { gap: 18px; padding: 14px; }
  .home-tooth-preview-wrap { padding: 14px; }
  .home-tooth-preview { width: min(100%, 420px); }
  .home-crop-workspace { grid-template-columns: 1fr; }
  .home-tooth-preview--crop { width: min(100%, 300px); }
  .home-photo-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 9px; }
  .home-photo-card__actions { gap: 3px; padding: 5px; }
  .home-photo-card__actions button { width: 26px; height: 28px; }
  .home-photo-card__actions .home-photo-card__edit { font-size: 11px; }
  .home-crop-modal { width: calc(100% - 16px); max-height: calc(100dvh - 16px); }
  .home-crop-dialog { padding: 18px 14px; }
  .home-crop-workspace { padding: 10px; }
  .home-crop-dialog .modal-actions { display: grid; grid-template-columns: 1fr 1fr; }
  .home-crop-dialog .modal-actions .primary-button { grid-column: 1 / -1; }
}

