.cx-mobile-recognition {
  --cx-recognition-page: var(--page, #eef8f5);
  --cx-recognition-card: var(--card, #fff);
  --cx-recognition-text: var(--text, #173f36);
  --cx-recognition-muted: var(--muted, #7a908b);
  --cx-recognition-line: var(--line, #e2eeea);
  --cx-recognition-green: var(--green, #0fb486);
  --cx-recognition-green-deep: var(--green-deep, #087e62);
  --cx-recognition-mint: var(--mint, #dff6ee);
  --cx-recognition-danger: var(--danger, #d85454);
  position: fixed;
  z-index: 195;
  top: 0;
  bottom: 0;
  left: 50%;
  display: grid;
  width: min(100%, 430px);
  height: 100dvh;
  grid-template-rows: auto minmax(0, 1fr);
  overflow: hidden;
  background: var(--cx-recognition-page);
  box-shadow: 0 0 70px rgba(20, 60, 47, .16);
  color: var(--cx-recognition-text);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "PingFang SC", "Microsoft YaHei", sans-serif;
  transform: translateX(-50%);
  isolation: isolate;
}

.cx-mobile-recognition[hidden],
.cx-mobile-recognition [hidden] { display: none !important; }
.cx-mobile-recognition * { box-sizing: border-box; }
.cx-mobile-recognition button,
.cx-mobile-recognition select { min-width: 0; max-width: 100%; margin: 0; border: 0; color: inherit; font: inherit; }
.cx-mobile-recognition button { padding: 0; background: transparent; cursor: pointer; -webkit-tap-highlight-color: transparent; }
.cx-mobile-recognition button:disabled { cursor: not-allowed; opacity: .48; }
.cx-mobile-recognition img { display: block; max-width: 100%; }

.cx-recognition-nav {
  position: relative;
  z-index: 20;
  display: grid;
  min-height: calc(48px + env(safe-area-inset-top));
  grid-template-columns: 52px minmax(0, 1fr) 52px;
  align-items: end;
  padding: env(safe-area-inset-top) 8px 6px;
  border-bottom: 1px solid rgba(226, 238, 234, .76);
  background: rgba(238, 248, 245, .96);
  backdrop-filter: blur(18px) saturate(145%);
}
.cx-recognition-nav > button { display: grid; width: 36px; height: 36px; place-items: center; align-self: center; border-radius: 50%; color: #111; font-size: 31px; font-weight: 300; line-height: 1; }
.cx-recognition-nav > button:active { background: rgba(15, 180, 134, .1); }
.cx-recognition-nav > h1 { align-self: center; overflow: hidden; margin: 0; color: #111; font-size: 17px; font-weight: 500; line-height: 36px; text-align: center; text-overflow: ellipsis; white-space: nowrap; }
.cx-recognition-nav > span { align-self: center; color: #658079; font-size: 10px; text-align: right; }

.cx-recognition-scroll { min-height: 0; overflow-x: hidden; overflow-y: auto; overscroll-behavior: contain; -webkit-overflow-scrolling: touch; }
.cx-recognition-page,
.cx-recognition-check-page { display: grid; width: 100%; min-width: 0; align-content: start; gap: 9px; padding: 10px 14px calc(22px + env(safe-area-inset-bottom)); overflow-x: hidden; }
.cx-recognition-card { width: 100%; min-width: 0; overflow: hidden; border: 1px solid var(--cx-recognition-line); border-radius: 21px; background: var(--cx-recognition-card); }

.cx-checking-card,
.cx-check-error { padding: 54px 18px; text-align: center; }
.cx-recognition-spinner { display: block; width: 35px; height: 35px; margin: 0 auto 13px; border: 4px solid #d9eee7; border-top-color: var(--cx-recognition-green); border-radius: 50%; animation: cx-recognition-spin 1s linear infinite; }
.cx-checking-card p,
.cx-check-error p { margin: 0; color: var(--cx-recognition-muted); font-size: 12px; line-height: 1.6; }
@keyframes cx-recognition-spin { to { transform: rotate(360deg); } }

.cx-check-success { display: flex; flex-direction: column; align-items: center; padding: 29px 15px; }
.cx-paper-stack { position: relative; width: 90px; height: 90px; }
.cx-paper-stack i { position: absolute; top: 3px; left: 15px; width: 58px; height: 71px; border: 1px solid #cce8df; border-radius: 7px; background: #fff; box-shadow: 0 4px 10px rgba(14, 174, 123, .08); }
.cx-paper-stack i:nth-child(2) { transform: translate(6px, 4px); }
.cx-paper-stack i:nth-child(3) { transform: translate(12px, 8px); }
.cx-paper-stack span { position: absolute; z-index: 2; right: 0; bottom: 0; left: 5px; padding: 5px; border-radius: 999px; background: var(--cx-recognition-green); color: #fff; font-size: 11px; font-weight: 700; text-align: center; }
.cx-check-success > b { display: flex; width: 55px; height: 55px; align-items: center; justify-content: center; margin-top: 12px; border-radius: 50%; background: var(--cx-recognition-green); color: #fff; font-size: 38px; line-height: 1; }
.cx-check-success h2 { margin: 11px 0 0; color: var(--cx-recognition-green-deep); font-size: 19px; font-weight: 800; }
.cx-check-status { padding: 19px 15px; text-align: center; }
.cx-check-status em { display: inline-flex; min-height: 25px; align-items: center; margin-bottom: 10px; padding: 0 9px; border: 1px solid #b7dfd2; border-radius: 999px; background: #eaf8f3; color: var(--cx-recognition-green-deep); font-size: 10px; font-style: normal; }
.cx-check-status p { margin: 0; font-size: 16px; }
.cx-check-status p strong { color: var(--cx-recognition-green); }
.cx-check-status button,
.cx-check-error button { display: flex; width: 100%; min-height: 46px; align-items: center; justify-content: center; margin-top: 14px; border-radius: 14px; background: var(--cx-recognition-green); color: #fff; font-size: 14px; font-weight: 750; }
.cx-check-error > i { display: flex; width: 45px; height: 45px; align-items: center; justify-content: center; margin: auto; border-radius: 50%; background: var(--cx-recognition-danger); color: #fff; font-size: 26px; font-style: normal; font-weight: 800; }
.cx-check-error h2 { margin: 14px 0 7px; font-size: 17px; }
.cx-check-rule-list { display: grid; gap: 9px; }
.cx-check-rule { display: flex; align-items: center; gap: 11px; padding: 12px; }
.cx-check-rule > i { display: flex; width: 24px; height: 24px; flex: 0 0 24px; align-items: center; justify-content: center; border: 2px solid currentColor; border-radius: 50%; font-style: normal; font-weight: 800; }
.cx-check-rule > i.warning { color: #c58a21; }
.cx-check-rule > i.danger { color: var(--cx-recognition-danger); }
.cx-check-rule span { min-width: 0; }
.cx-check-rule strong,
.cx-check-rule small { display: block; }
.cx-check-rule strong { font-size: 12px; line-height: 1.4; }
.cx-check-rule small { margin-top: 3px; color: var(--cx-recognition-muted); font-size: 10px; line-height: 1.45; }

.cx-scan-card { padding: 11px; }
.cx-scan-head { display: grid; min-width: 0; grid-template-columns: minmax(0, 1fr) auto; align-items: flex-start; gap: 7px; margin-bottom: 9px; }
.cx-scan-head > span { min-width: 0; }
.cx-scan-head h2,
.cx-scan-head p { margin: 0; }
.cx-scan-head h2 { color: var(--cx-recognition-green-deep); font-size: 17px; font-weight: 900; }
.cx-scan-head p { margin-top: 3px; color: var(--cx-recognition-muted); font-size: 11px; line-height: 1.45; }
.cx-scan-head > b { padding: 5px 9px; border-radius: 999px; background: #dcfbf0; color: var(--cx-recognition-green); font-size: 12px; }

.cx-academic-card { margin-bottom: 9px; padding: 10px; border: 1px solid #cfe9df; border-radius: 11px; background: linear-gradient(145deg, #f2fbf8, #fbfefd); }
.cx-academic-card > header { display: flex; min-width: 0; align-items: flex-start; justify-content: space-between; gap: 7px; }
.cx-academic-card > header > span { min-width: 0; }
.cx-academic-card > header strong,
.cx-academic-card > header small { display: block; }
.cx-academic-card > header strong { color: #214d40; font-size: 13.5px; line-height: 1.35; }
.cx-academic-card > header small { margin-top: 3px; color: var(--cx-recognition-muted); font-size: 10.5px; line-height: 1.45; }
.cx-academic-card > header > b { flex: 0 0 auto; padding: 4px 7px; border-radius: 999px; background: #dcf8ee; color: #078a66; font-size: 10px; font-weight: 500; white-space: nowrap; }
.cx-academic-card > header > b.is-manual { background: #fff3d8; color: #9b6a08; }
.cx-academic-card > div { display: grid; min-width: 0; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px; margin-top: 8px; }
.cx-academic-card label { position: relative; display: flex; min-width: 0; min-height: 42px; flex-direction: column; justify-content: center; gap: 2px; padding: 6px 8px; border: 1px solid #dcebe6; border-radius: 9px; background: #fff; }
.cx-academic-card label::after { position: absolute; right: 8px; bottom: 9px; color: var(--cx-recognition-green); content: "⌄"; font-size: 11px; pointer-events: none; }
.cx-academic-card label > span { color: var(--cx-recognition-muted); font-size: 10px; }
.cx-academic-card select { width: 100%; padding: 0 18px 0 0; outline: 0; background: transparent; color: var(--cx-recognition-green-deep); font-size: 13px; font-weight: 750; appearance: none; }

.cx-recognition-page-tabs { display: flex; gap: 6px; padding: 0 0 9px; overflow-x: auto; scrollbar-width: none; }
.cx-recognition-page-tabs::-webkit-scrollbar,
.cx-selected-chips::-webkit-scrollbar { display: none; }
.cx-recognition-page-tabs button { flex: 0 0 auto; min-height: 32px; padding: 0 11px; border: 1px solid var(--cx-recognition-line); border-radius: 999px; background: #f5f8f7; color: var(--cx-recognition-muted); font-size: 12px; }
.cx-recognition-page-tabs button.active { border-color: var(--cx-recognition-green); background: var(--cx-recognition-green); color: #fff; font-weight: 800; }

.cx-selection-toolbar { display: grid; min-width: 0; grid-template-columns: minmax(0, 1fr) 95px; align-items: center; gap: 7px; margin-bottom: 8px; padding: 10px; border: 1px solid #d5e9e2; border-radius: 9px; background: #f7fbfa; }
.cx-selection-toolbar > span { min-width: 0; }
.cx-selection-toolbar strong,
.cx-selection-toolbar small { display: block; }
.cx-selection-toolbar strong { color: #234c40; font-size: 13px; line-height: 1.35; }
.cx-selection-toolbar small { margin-top: 3px; color: var(--cx-recognition-muted); font-size: 11px; line-height: 1.45; }
.cx-selection-toolbar > button { display: flex; width: 95px; min-height: 42px; align-items: center; justify-content: center; padding: 0 6px; border: 1px solid #9fdcc7; border-radius: 9px; background: #e7f8f2; color: var(--cx-recognition-green-deep); font-size: 13px; font-weight: 700; white-space: nowrap; }
.cx-selection-toolbar.is-drawing { border-color: var(--cx-recognition-green); background: #eafaf4; }
.cx-selection-toolbar.is-drawing > button { background: var(--cx-recognition-green); color: #fff; }
.cx-selection-toolbar.is-associating { border-color: #9369d8; background: #f4effd; }
.cx-selection-toolbar.is-associating strong { color: #65469c; }
.cx-selection-toolbar.is-associating > button { border-color: #9369d8; background: #8055c8; color: #fff; }

.cx-document-editor { width: 100%; min-width: 0; overflow: hidden; border-radius: 11px; background: #65706c; }
.cx-document-viewport { width: 100%; height: min(58dvh, 490px); overflow-x: hidden; overflow-y: auto; overscroll-behavior: contain; background: #65706c; -webkit-overflow-scrolling: touch; }
.cx-document-canvas { width: 100%; min-width: 100%; min-height: 100%; padding: 7px; }
.cx-document-wrap { position: relative; width: 100%; overflow: hidden; border: 5px solid #68736f; border-radius: 11px; background: #e7ecea; touch-action: pan-y; }
.cx-document-wrap.is-placeholder { height: 430px; }
.cx-document-wrap.is-drawing { border-color: var(--cx-recognition-green); box-shadow: 0 0 0 3px rgba(15, 180, 134, .12); touch-action: none; }
.cx-document-wrap.is-associating { border-color: #8a5fd0; box-shadow: 0 0 0 3px rgba(128, 85, 200, .12); touch-action: none; }
.cx-recognition-paper-stage { position: relative; width: 100%; min-height: 100%; }
.cx-recognition-paper-image { width: 100%; height: auto; background: #fff; object-fit: contain; user-select: none; -webkit-user-drag: none; }
.cx-recognition-paper-image.filter-smart { filter: contrast(1.12) brightness(1.04) saturate(.9); }
.cx-recognition-paper-image.filter-document { filter: grayscale(1) contrast(1.45) brightness(1.08); }
.cx-recognition-paper-image.filter-shadow { filter: contrast(1.18) brightness(1.12); }
.cx-paper-placeholder { display: flex; height: 100%; min-height: 420px; flex-direction: column; align-items: center; justify-content: center; gap: 11px; background: linear-gradient(180deg, #fff, #f3f6f5); color: var(--cx-recognition-muted); font-size: 12px; text-align: center; }
.cx-paper-placeholder b { display: flex; width: 58px; height: 71px; align-items: center; justify-content: center; border-radius: 8px; background: #ef5548; color: #fff; font-size: 16px; }

.cx-question-box,
.cx-supplement-box { position: absolute; display: flex; align-items: center; justify-content: center; touch-action: none; user-select: none; }
.cx-question-box { z-index: 2; min-height: 31px; border: 2px solid rgba(38, 116, 255, .78); background: rgba(38, 116, 255, .08); }
.cx-question-box.selected { border-color: #16c796; background: rgba(22, 199, 150, .16); }
.cx-question-box.editing { z-index: 6; border-style: solid; border-color: #0b9f76; background: rgba(15, 180, 134, .2); box-shadow: 0 0 0 3px rgba(15, 180, 134, .16); }
.cx-question-box > span { position: absolute; top: -14px; left: 50%; min-width: 26px; height: 26px; padding: 0 5px; border-radius: 999px; background: #2674ff; color: #fff; font-size: 13px; font-weight: 900; line-height: 26px; text-align: center; transform: translateX(-50%); }
.cx-question-box.selected > span { background: var(--cx-recognition-green); }
.cx-question-box > b { padding: 3px 7px; border-radius: 5px; background: rgba(38, 116, 255, .86); color: #fff; font-size: 12px; font-weight: 800; white-space: nowrap; }
.cx-question-box.selected > b { background: var(--cx-recognition-green); }
.cx-supplement-box { z-index: 4; min-width: 19px; min-height: 18px; border: 2px dashed #8a5fd0; background: rgba(128, 85, 200, .12); }
.cx-supplement-box.editing { z-index: 7; border-style: solid; box-shadow: 0 0 0 3px rgba(128, 85, 200, .16); }
.cx-supplement-box > span { padding: 3px 6px; border-radius: 4px; background: #8055c8; color: #fff; font-size: 11px; white-space: nowrap; }

.cx-resize-handle { position: absolute; z-index: 9; display: block; width: 26px; height: 26px; border: 3px solid #fff; border-radius: 50%; background: #0b9f76; box-shadow: 0 1px 6px rgba(10, 54, 42, .38); touch-action: none; }
.cx-supplement-box .cx-resize-handle { background: #8055c8; }
.cx-resize-handle.handle-nw { top: 0; left: 0; transform: translate(-50%, -50%); }
.cx-resize-handle.handle-n { top: 0; left: 50%; transform: translate(-50%, -50%); }
.cx-resize-handle.handle-ne { top: 0; right: 0; transform: translate(50%, -50%); }
.cx-resize-handle.handle-e { top: 50%; right: 0; transform: translate(50%, -50%); }
.cx-resize-handle.handle-se { right: 0; bottom: 0; transform: translate(50%, 50%); }
.cx-resize-handle.handle-s { bottom: 0; left: 50%; transform: translate(-50%, 50%); }
.cx-resize-handle.handle-sw { bottom: 0; left: 0; transform: translate(-50%, 50%); }
.cx-resize-handle.handle-w { top: 50%; left: 0; transform: translate(-50%, -50%); }
.cx-selection-input-layer { position: absolute; z-index: 8; inset: 0; cursor: crosshair; touch-action: none; }
.cx-manual-draft-box { position: absolute; z-index: 10; min-width: 2px; min-height: 2px; border: 2px dashed var(--cx-recognition-green); background: rgba(15, 180, 134, .12); pointer-events: none; }
.cx-manual-draft-box > span { position: absolute; top: 4px; left: 4px; padding: 3px 6px; border-radius: 4px; background: var(--cx-recognition-green); color: #fff; font-size: 11px; white-space: nowrap; }
.cx-manual-draft-box.related { border-color: #8055c8; background: rgba(128, 85, 200, .13); }
.cx-manual-draft-box.related > span { background: #8055c8; }

.cx-box-editor { display: grid; min-width: 0; gap: 9px; margin-top: 8px; padding: 10px; border: 1px solid #a8dfcd; border-radius: 10px; background: #f1fbf7; }
.cx-box-editor.is-related { border-color: #c8b6e8; background: #f7f3fd; }
.cx-box-editor > span { min-width: 0; }
.cx-box-editor strong,
.cx-box-editor small { display: block; }
.cx-box-editor strong { color: #17493a; font-size: 14.5px; line-height: 1.35; }
.cx-box-editor.is-related strong { color: #65469c; }
.cx-box-editor small { margin-top: 4px; color: var(--cx-recognition-muted); font-size: 11.5px; line-height: 1.5; }
.cx-box-editor > div { display: flex; width: 100%; min-width: 0; gap: 6px; }
.cx-box-editor button { display: flex; min-width: 0; min-height: 38px; flex: 1; align-items: center; justify-content: center; padding: 0 5px; border: 1px solid #c5e5da; border-radius: 8px; background: #fff; color: #286453; font-size: 12px; font-weight: 700; white-space: nowrap; }
.cx-box-editor button.related { border-color: #ccb9e9; color: #704ca8; }
.cx-box-editor button.delete { border-color: #f0c2bd; color: #c84d45; }
.cx-scan-tip { margin: 10px 0 0; padding: 10px 11px; border-radius: 8px; background: #f1fbf7; color: var(--cx-recognition-green-deep); font-size: 12px; line-height: 1.65; }

.cx-selected-panel { padding: 13px 11px; }
.cx-selected-panel > header { display: grid; min-width: 0; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 7px; }
.cx-selected-panel > header > span { min-width: 0; }
.cx-selected-panel > header strong,
.cx-selected-panel > header small { display: block; }
.cx-selected-panel > header strong { color: var(--cx-recognition-green-deep); font-size: 17px; line-height: 1.4; white-space: nowrap; }
.cx-selected-panel > header strong b { color: var(--cx-recognition-green); }
.cx-selected-panel > header small { margin-top: 2px; color: var(--cx-recognition-muted); font-size: 12px; white-space: nowrap; }
.cx-selected-panel > header > div { display: grid; grid-template-columns: repeat(2, 56px); gap: 6px; }
.cx-selected-panel > header button { width: 56px; height: 34px; padding: 0 4px; border-radius: 999px; background: #e7fbf3; color: var(--cx-recognition-green); font-size: 12px; font-weight: 700; white-space: nowrap; }
.cx-selected-panel > header button.muted { background: #f4f7f6; color: var(--cx-recognition-muted); }
.cx-selected-chips { display: flex; width: 100%; gap: 6px; margin-top: 10px; padding: 1px; overflow-x: auto; white-space: nowrap; scrollbar-width: none; }
.cx-selected-chips button { display: inline-flex; width: auto; min-width: 0; height: 31px; flex: 0 0 auto; align-items: center; gap: 4px; padding: 0 9px; border-radius: 999px; background: #e7f8f2; color: var(--cx-recognition-green-deep); font-size: 11.5px; white-space: nowrap; }
.cx-selected-chips button b { color: var(--cx-recognition-green); font-size: 15px; }
.cx-submit-selected { display: flex !important; width: 100%; min-height: 46px; align-items: center; justify-content: center; margin-top: 11px !important; border-radius: 14px !important; background: var(--cx-recognition-green) !important; color: #fff !important; font-size: 15px !important; font-weight: 800 !important; }

.cx-recognition-toast { position: absolute; z-index: 40; right: 18px; bottom: calc(28px + env(safe-area-inset-bottom)); left: 18px; width: max-content; max-width: calc(100% - 36px); margin: auto; padding: 11px 15px; border-radius: 13px; background: rgba(20, 48, 40, .95); box-shadow: 0 12px 35px rgba(5, 25, 19, .22); color: #fff; font-size: 11px; line-height: 1.45; text-align: center; }
.cx-recognition-dialog-layer { position: absolute; z-index: 50; inset: 0; display: grid; place-items: center; padding: 22px; background: rgba(14, 33, 28, .42); backdrop-filter: blur(3px); }
.cx-recognition-dialog-layer > section { width: min(100%, 310px); overflow: hidden; border-radius: 18px; background: #fff; box-shadow: 0 22px 60px rgba(8, 35, 27, .24); text-align: center; }
.cx-recognition-dialog-layer h2 { margin: 0; padding: 23px 22px 0; color: #182f29; font-size: 17px; font-weight: 650; }
.cx-recognition-dialog-layer p { margin: 10px 0 0; padding: 0 22px 22px; color: #637873; font-size: 13px; line-height: 1.6; }
.cx-recognition-dialog-layer footer { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); border-top: 1px solid #e5ece9; }
.cx-recognition-dialog-layer footer button { min-height: 49px; border-right: 1px solid #e5ece9; color: #536b64; font-size: 14px; }
.cx-recognition-dialog-layer footer button:last-child { border: 0; }
.cx-recognition-dialog-layer footer button.danger { color: var(--cx-recognition-danger); font-weight: 650; }

@media (max-width: 350px) {
  .cx-recognition-page,
  .cx-recognition-check-page { padding-right: 10px; padding-left: 10px; }
  .cx-selection-toolbar { grid-template-columns: minmax(0, 1fr) 82px; }
  .cx-selection-toolbar > button { width: 82px; font-size: 12px; }
  .cx-box-editor > div { flex-wrap: wrap; }
  .cx-box-editor button { flex-basis: calc(50% - 3px); }
}

@media (prefers-reduced-motion: reduce) {
  .cx-mobile-recognition *,
  .cx-mobile-recognition *::before,
  .cx-mobile-recognition *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}
