:root {
  --ink: #172923;
  --ink-soft: #395149;
  --muted: #74847e;
  --line: #d7e1dd;
  --line-strong: #bdcdc7;
  --paper: #ffffff;
  --surface: #f2f6f4;
  --surface-strong: #e8efec;
  --mint: #2f947b;
  --mint-dark: #1c6f5d;
  --mint-pale: #e2f2ed;
  --coral: #ef5d51;
  --coral-pale: #fff0ed;
  --shadow: 0 18px 44px rgba(25, 57, 48, 0.09);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
}

* { box-sizing: border-box; }
html { color-scheme: light; }
body { margin: 0; min-width: 320px; color: var(--ink); background: var(--surface); }
button, input, textarea, select { font: inherit; }
button, label { -webkit-tap-highlight-color: transparent; }
button { cursor: pointer; }
button:focus-visible, input:focus-visible, textarea:focus-visible, select:focus-visible, label:focus-within { outline: 2px solid var(--mint); outline-offset: 2px; }
h1, h2, p { margin-top: 0; }
.hidden { display: none !important; }
.eyebrow { margin: 0 0 7px; color: var(--mint); font-size: 10px; font-weight: 900; letter-spacing: 0; }

.brand { display: flex; align-items: center; gap: 10px; font-size: 19px; font-weight: 900; }
.brand small { margin-left: 2px; color: var(--muted); font-size: 10px; font-weight: 700; }
.brand-mark { position: relative; display: inline-grid; place-items: center; width: 30px; height: 30px; border: 2px solid currentColor; color: var(--mint); }
.brand-mark::before, .brand-mark::after { content: ""; position: absolute; background: currentColor; }
.brand-mark::before { width: 8px; height: 2px; }
.brand-mark::after { width: 2px; height: 8px; }
.brand-mark i { position: absolute; inset: 5px; border: 1px solid currentColor; transform: rotate(45deg); }

/* Login */
.login-screen { min-height: 100vh; display: grid; grid-template-columns: minmax(480px, 1.08fr) minmax(420px, .92fr); background: var(--paper); }
.login-screen.auth-gate { position: fixed; inset: 0; z-index: 80; overflow-y: auto; box-shadow: 0 0 0 9999px rgba(8,31,24,.42); }
.login-card { position: relative; }
.login-close { position: absolute; top: -8px; right: 0; padding: 7px 9px; border: 1px solid var(--line); border-radius: 4px; background: #fff; color: var(--muted); font-size: 11px; }
.login-close:hover { border-color: var(--mint); color: var(--mint-dark); }
.login-showcase { position: relative; min-height: 720px; overflow: hidden; padding: 46px 58px; color: #fff; background: #173d34; }
.login-showcase::before { content: ""; position: absolute; top: 0; right: 76px; bottom: 0; width: 1px; background: rgba(255,255,255,.16); }
.login-showcase::after { content: ""; position: absolute; left: 58px; right: 58px; bottom: 46px; height: 1px; background: rgba(255,255,255,.16); }
.login-showcase-brand { position: relative; z-index: 2; }
.login-showcase-brand .brand-mark { color: #a5ddcc; }
.showcase-copy { position: relative; z-index: 2; margin-top: 92px; }
.showcase-copy .eyebrow { color: #a5ddcc; }
.showcase-copy h1 { margin-bottom: 18px; font-size: 48px; line-height: 1.14; font-weight: 900; }
.showcase-copy > p:last-child { color: #bcd1ca; font-size: 14px; }
.showcase-board { position: absolute; right: 34px; bottom: 98px; width: min(64%, 540px); aspect-ratio: 1.32; border: 1px solid rgba(255,255,255,.28); background: #f0f5f3; box-shadow: 20px 22px 0 rgba(0,0,0,.13); }
.board-image { position: absolute; left: 7%; top: 9%; width: 59%; height: 74%; overflow: hidden; background: #bad7ce; border: 1px solid #fff; }
.board-image::before { content: ""; position: absolute; inset: 15% 10% 19%; border: 15px solid #e5ece9; background: #4e897a; }
.board-image::after { content: ""; position: absolute; left: 16%; right: 16%; bottom: 9%; height: 12%; background: #fff; }
.board-label { position: absolute; top: 8px; left: 10px; z-index: 2; color: #173d34; font-size: 9px; font-weight: 900; }
.board-image i { position: absolute; z-index: 3; width: 12px; height: 12px; border-radius: 50%; background: #e9d8b7; }
.board-image i:nth-of-type(1) { left: 24%; top: 39%; }
.board-image i:nth-of-type(2) { left: 43%; top: 37%; }
.board-image i:nth-of-type(3) { left: 62%; top: 40%; }
.board-frame { position: absolute; left: 14%; top: 26%; width: 43%; height: 39%; border: 3px solid var(--coral); }
.board-arrow { position: absolute; left: 50%; top: 44%; width: 27%; height: 2px; background: var(--coral); transform: rotate(-12deg); transform-origin: left center; }
.board-arrow::after { content: ""; position: absolute; right: -1px; top: -5px; width: 9px; height: 9px; border-top: 2px solid var(--coral); border-right: 2px solid var(--coral); transform: rotate(45deg); }
.board-note { position: absolute; right: 4%; top: 29%; width: 28%; color: #183b33; }
.board-note b { display: block; margin-bottom: 13px; color: var(--coral); font-size: 11px; }
.board-note span { display: block; color: #74847e; font-size: 9px; }
.board-note strong { display: block; margin-top: 6px; font-size: 14px; line-height: 1.4; }
.board-chip { position: absolute; right: 4%; bottom: 6%; padding: 6px 8px; border: 1px solid #98b6ad; color: #335c51; font-size: 8px; font-weight: 900; }
.showcase-index { position: absolute; left: 58px; bottom: 57px; color: #a5c8bd; font-size: 10px; font-weight: 800; }
.login-panel { display: grid; place-items: center; padding: 60px; background: var(--paper); }
.login-card { width: min(420px, 100%); }
.login-mobile-brand { display: none; }
.login-card h2 { margin-bottom: 8px; font-size: 34px; }
.login-copy { margin-bottom: 34px; color: var(--muted); font-size: 13px; }
.login-card form { display: grid; }
.login-card input { width: 100%; height: 48px; padding: 0 14px; border: 1px solid var(--line); border-radius: 4px; background: #fbfcfc; color: var(--ink); }
.login-card input:focus { border-color: var(--mint); box-shadow: 0 0 0 3px rgba(47,148,123,.11); outline: none; }
.login-card .primary-action { margin-top: 24px; }
.demo-hint { margin: 20px 0 0; color: #a0aaa6; font-size: 11px; text-align: center; }
.login-error { min-height: 20px; margin-top: 12px; color: #c64d43; font-size: 12px; text-align: center; }
.password-modal { position: fixed; inset: 0; z-index: 95; display: grid; place-items: center; padding: 24px; background: rgba(8,31,24,.58); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); }
.password-card { position: relative; width: min(430px, 100%); padding: 34px; border: 1px solid var(--line); border-radius: 9px; background: #fff; box-shadow: 0 24px 72px rgba(7,35,27,.24); }
.password-card h2 { margin: 0 0 9px; font-size: 27px; }
.password-card > p:not(.eyebrow) { margin-bottom: 24px; color: var(--muted); font-size: 12px; line-height: 1.7; }
.password-card label { display: block; margin: 14px 0 7px; font-size: 12px; font-weight: 800; }
.password-card input { width: 100%; height: 46px; padding: 0 13px; border: 1px solid var(--line); border-radius: 4px; background: #fbfcfc; color: var(--ink); }
.password-card input:focus { border-color: var(--mint); box-shadow: 0 0 0 3px rgba(47,148,123,.11); outline: none; }
.password-close { position: absolute; top: 18px; right: 18px; padding: 6px 8px; border: 1px solid var(--line); border-radius: 4px; background: #fff; color: var(--muted); font-size: 11px; }
.password-error { min-height: 18px; margin-top: 10px; color: #c64d43; font-size: 11px; }
.password-card .primary-action { min-height: 48px; }

/* App frame */
.topbar { position: sticky; top: 0; z-index: 8; min-height: 72px; display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 22px; padding: 0 34px; border-bottom: 1px solid var(--line); background: rgba(255,255,255,.96); }
.topbar-center { display: flex; align-items: center; gap: 9px; color: #879690; font-size: 8px; font-weight: 900; }
.topbar-center i { width: 22px; height: 1px; background: var(--line-strong); }
.account-bar { display: flex; align-items: center; justify-content: flex-end; gap: 12px; color: var(--muted); font-size: 11px; }
.account-bar > span + span { padding-left: 12px; border-left: 1px solid var(--line); }
.account-bar button, .admin-link { padding: 7px 9px; border: 1px solid var(--line); border-radius: 4px; background: #fff; color: var(--ink); font-size: 11px; text-decoration: none; }
.admin-link { color: var(--mint-dark); font-weight: 800; }
.app-shell { width: min(1840px, 100%); display: grid; grid-template-columns: minmax(0, 1fr) 500px; gap: 24px; margin: 0 auto; padding: 24px; }
.workspace, .control-panel { border: 1px solid var(--line); border-radius: 8px; background: var(--paper); }
.workspace { min-width: 0; padding: 26px; }
.control-panel { position: static; align-self: start; max-height: none; overflow: visible; padding: 14px; border-color: var(--line-strong); background: #edf3f0; box-shadow: 0 10px 28px rgba(29, 69, 58, .08); }
.section-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; margin-bottom: 22px; }
.section-heading h1 { margin-bottom: 6px; font-size: 27px; line-height: 1.2; }
.section-subtitle { margin-bottom: 0; color: var(--muted); font-size: 12px; }
.status-pill { flex: 0 0 auto; padding: 8px 12px; border: 1px solid #cfe4dc; border-radius: 99px; background: var(--mint-pale); color: var(--mint-dark); font-size: 11px; font-weight: 800; }

/* Canvas */
.canvas-wrap { position: relative; min-height: 570px; display: grid; place-items: center; overflow: auto; padding: 18px; border: 1px solid var(--line-strong); background: var(--surface-strong); }
.canvas-wrap::before { content: ""; position: absolute; top: 0; left: 0; right: 0; height: 9px; border-bottom: 1px solid rgba(40,76,66,.12); background: #dfe8e4; }
.canvas-wrap::after { content: "01"; position: absolute; right: 12px; bottom: 9px; color: #9caaa5; font-size: 9px; font-weight: 900; }
.canvas-corner { position: absolute; z-index: 1; width: 24px; height: 24px; pointer-events: none; }
.canvas-corner-a { top: 14px; left: 14px; border-top: 2px solid var(--mint); border-left: 2px solid var(--mint); }
.canvas-corner-b { right: 14px; bottom: 14px; border-right: 2px solid var(--mint); border-bottom: 2px solid var(--mint); }
#canvas { display: none; max-width: 100%; height: auto; box-shadow: 0 10px 28px rgba(28,58,50,.09); touch-action: none; }
#canvas.ready { display: block; }
.inline-annotation-editor { position: absolute; z-index: 6; width: clamp(220px, 31vw, 390px); min-height: 64px; padding: 10px 12px; border: 2px solid var(--coral); border-radius: 6px; outline: 0; background: rgba(255,255,255,.98); color: var(--ink); box-shadow: 0 12px 30px rgba(28,58,50,.22); font-family: inherit; font-size: 18px; font-weight: 750; line-height: 1.45; resize: both; }
.inline-annotation-editor:focus { box-shadow: 0 0 0 4px rgba(240,90,79,.16), 0 12px 30px rgba(28,58,50,.22); }
.canvas-wrap.zoomed { display: block; overflow: auto !important; text-align: center; }
.canvas-wrap.zoomed #canvas { max-width: none !important; max-height: none !important; margin: 0 auto; object-fit: fill !important; }
.canvas-heading-actions { display: flex; align-items: center; gap: 10px; }
.canvas-zoom-button { padding: 8px 12px; border: 1px solid var(--line-strong); border-radius: 5px; background: #fff; color: var(--mint-strong); font-size: 12px; font-weight: 800; cursor: pointer; }
.canvas-zoom-button:hover { background: #e5f3ee; }
.empty-state { min-height: 540px; width: 100%; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 9px; color: var(--muted); text-align: center; }
.empty-state strong { color: var(--ink); font-size: 17px; }
.empty-state > span { font-size: 11px; }
.empty-art { position: relative; width: 92px; height: 72px; margin-bottom: 12px; border: 1px solid #8eaaa0; background: #f7faf9; }
.empty-art::before { content: ""; position: absolute; inset: 9px; border: 1px solid #b8cdc5; }
.empty-art span { position: absolute; left: 21px; bottom: 18px; width: 20px; height: 27px; background: #b9d8ce; transform: rotate(-12deg); }
.empty-art i { position: absolute; left: 39px; bottom: 18px; width: 27px; height: 36px; background: #6aa792; transform: rotate(10deg); }
.empty-art b { position: absolute; right: -14px; top: -14px; width: 30px; height: 30px; display: grid; place-items: center; border-radius: 50%; background: var(--coral); color: #fff; font-size: 20px; }

.toolbar { display: flex; align-items: center; gap: 7px; flex-wrap: wrap; padding-top: 16px; }
.toolbar-label { margin-right: 5px; color: #94a29d; font-size: 9px; font-weight: 900; }
.tool { min-height: 34px; padding: 7px 11px; border: 1px solid var(--line); border-radius: 4px; background: #fff; color: #53655f; font-size: 12px; }
.tool:hover { border-color: #8db7aa; color: var(--mint-dark); }
.tool.active { border-color: var(--mint); background: var(--mint-pale); color: var(--mint-dark); font-weight: 800; }
.color-label { display: flex; align-items: center; gap: 7px; margin-left: auto; color: var(--muted); font-size: 11px; }
.color-label input { width: 28px; height: 28px; padding: 0; border: 1px solid var(--line); background: transparent; }
.upload-button { display: inline-flex; align-items: center; justify-content: center; margin-top: 12px; padding: 10px 17px; border: 1px solid var(--ink); border-radius: 4px; background: var(--ink); color: #fff; font-size: 12px; font-weight: 800; cursor: pointer; }
.upload-button input { display: none; }
.upload-button.secondary { margin: 0; border-color: var(--line); background: #fff; color: var(--ink); }
.generation-display { min-height: 560px; flex: 1; overflow: hidden; border: 1px solid var(--line-strong); background: #eef1f0; }
.generation-empty { min-height: 560px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px; padding: 28px; color: var(--muted); text-align: center; }
.generation-empty-icon { width: 74px; height: 74px; display: grid; place-items: center; margin-bottom: 7px; border: 1px solid #b9cec7; border-radius: 18px; background: #f7fbf9; }
.generation-empty-icon img { width: 34px; height: 34px; filter: invert(48%) sepia(31%) saturate(833%) hue-rotate(112deg) brightness(91%); }
.generation-empty strong { color: var(--ink); font-size: 18px; }
.generation-empty > span:last-child { font-size: 11px; }
.generation-results { min-height: 560px; padding: 22px; }
.generation-results-heading { display: flex; align-items: center; justify-content: space-between; gap: 18px; margin-bottom: 18px; }
.generation-results-heading span, .generation-results-heading strong { display: block; }
.generation-results-heading span { margin-bottom: 4px; color: var(--mint); font-size: 9px; font-weight: 900; }
.generation-results-heading strong { font-size: 20px; }
.generation-download-actions { display: flex; align-items: center; justify-content: flex-end; gap: 8px; flex-wrap: wrap; }
.generation-results-heading button { min-height: 39px; display: inline-flex; align-items: center; gap: 7px; padding: 0 13px; border: 1px solid var(--mint); border-radius: 5px; background: #fff; color: var(--mint-dark); font-size: 11px; font-weight: 800; }
.generation-results-heading button:hover { background: var(--mint-pale); }
.generation-results-heading button img { width: 17px; height: 17px; }
.generation-main-image { min-height: 420px; display: grid; place-items: center; overflow: hidden; border: 1px solid var(--line); background: #f8faf9; }
.generation-main-image img { display: block; max-width: 100%; max-height: 640px; object-fit: contain; }
.generation-gallery { display: flex; gap: 9px; overflow-x: auto; margin-top: 12px; padding-bottom: 2px; }
.generation-gallery button { width: 74px; height: 74px; flex: 0 0 74px; overflow: hidden; padding: 3px; border: 2px solid transparent; border-radius: 5px; background: #fff; }
.generation-gallery button:hover, .generation-gallery button.active { border-color: var(--mint); }
.generation-gallery img { width: 100%; height: 100%; display: block; object-fit: cover; border-radius: 2px; }

/* Controls */
.panel-tabs { position: static; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 7px; padding: 7px; border: 1px solid var(--line-strong); border-radius: 7px; background: #f8fbfa; box-shadow: 0 5px 14px rgba(29, 69, 58, .06); }
.tab { min-width: 0; min-height: 68px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 5px; padding: 10px 5px; border: 1px solid transparent; border-radius: 5px; background: transparent; color: #62756e; font-size: 15px; font-weight: 900; line-height: 1.2; }
.tab:hover { border-color: #abc5bc; background: #edf4f1; color: var(--ink); }
.tab small { color: #879a93; font-size: 12px; font-weight: 950; line-height: 1; }
.tab.active { border-color: var(--mint-dark); background: var(--mint-dark); color: #fff; box-shadow: 0 5px 12px rgba(28, 111, 93, .2); }
.tab.active small { color: #aee1d2; }
.mode-content { margin-top: 12px; padding: 24px; border: 1px solid var(--line); border-radius: 7px; background: #fff; }
.mode-heading { display: flex; align-items: center; gap: 11px; margin-bottom: 16px; }
.mode-symbol { width: 38px; height: 38px; display: grid; place-items: center; border: 1px solid var(--mint); color: var(--mint-dark); font-size: 15px; font-weight: 900; }
.mode-heading p { margin: 0 0 2px; color: var(--coral); font-size: 8px; font-weight: 900; }
.mode-heading h2 { margin: 0; font-size: 18px; }
.panel-intro { margin: 0 0 20px; color: var(--muted); font-size: 12px; line-height: 1.75; }
.field-label { display: flex; justify-content: space-between; margin: 16px 0 8px; color: var(--ink); font-size: 12px; font-weight: 800; }
.field-label span { color: #9ca8a4; font-weight: 500; }
textarea, select, .admin-form input, .admin-user-row input { width: 100%; border: 1px solid var(--line); border-radius: 4px; background: #fbfcfc; color: var(--ink); }
textarea { padding: 12px 13px; resize: vertical; font-size: 13px; line-height: 1.65; }
select { height: 43px; padding: 0 11px; font-size: 12px; }
textarea:focus, select:focus { border-color: var(--mint); box-shadow: 0 0 0 3px rgba(47,148,123,.1); outline: none; }
.option-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 10px; }
.upload-drop { position: relative; min-height: 110px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 5px; overflow: hidden; border: 1px dashed #94b6ab; border-radius: 5px; background: #f4faf7; color: var(--ink); cursor: pointer; }
.upload-drop::after { content: ""; position: absolute; right: -14px; bottom: -14px; width: 52px; height: 52px; border: 1px solid #bad5cc; transform: rotate(45deg); }
.upload-drop strong { font-size: 13px; }
.upload-drop > span:not(.drop-index) { color: var(--muted); font-size: 10px; }
.upload-drop input { display: none; }
.drop-index { position: absolute; top: 8px; left: 9px; color: var(--coral); font-size: 8px; font-weight: 900; }
.reference-preview { width: 100%; max-height: 190px; object-fit: contain; display: block; margin-top: 10px; border: 1px solid var(--line); border-radius: 4px; background: var(--surface); }
.reference-list-head { display: flex; align-items: center; justify-content: space-between; margin: 12px 0 8px; color: var(--muted); font-size: 11px; }
.reference-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 7px; }
.reference-item { position: relative; aspect-ratio: 1; overflow: hidden; border: 1px solid var(--line); border-radius: 4px; background: var(--surface); cursor: grab; transition: border-color .15s ease, opacity .15s ease, transform .15s ease; }
.reference-item:active { cursor: grabbing; }
.reference-item.dragging { opacity: .42; }
.reference-item.drag-target { border-color: var(--mint); box-shadow: 0 0 0 2px rgba(47,148,123,.16); transform: translateY(-2px); }
.reference-item:focus-visible { outline: 2px solid var(--mint); outline-offset: 2px; }
.reference-item img { width: 100%; height: 100%; object-fit: contain; display: block; }
.reference-index { position: absolute; left: 5px; bottom: 5px; min-width: 20px; height: 20px; display: grid; place-items: center; border-radius: 50%; background: var(--ink); color: #fff; font-size: 10px; font-weight: 800; }
.reference-remove { position: absolute; top: 4px; right: 4px; width: 23px; height: 23px; padding: 0; border: 1px solid rgba(255,255,255,.65); border-radius: 3px; background: rgba(23,41,35,.86); color: #fff; }
.text-button { border: 0; background: transparent; color: var(--mint-dark); font-size: 11px; font-weight: 800; }

.quality-toggle { display: flex; align-items: center; justify-content: space-between; gap: 14px; margin-top: 13px; padding: 12px; border: 1px solid var(--line); border-radius: 5px; background: #f8fbfa; cursor: pointer; }
.quality-toggle:hover { border-color: #9bbdb2; }
.quality-copy { min-width: 0; }
.quality-copy strong { display: block; margin-bottom: 3px; font-size: 12px; }
.quality-copy small { display: block; color: var(--muted); font-size: 10px; line-height: 1.5; }
.switch { position: relative; flex: 0 0 38px; height: 22px; }
.switch input { position: absolute; opacity: 0; pointer-events: none; }
.switch i { position: absolute; inset: 0; border: 1px solid #aebdb8; border-radius: 99px; background: #dce4e1; transition: .18s ease; }
.switch i::after { content: ""; position: absolute; top: 3px; left: 3px; width: 14px; height: 14px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.15); transition: .18s ease; }
.switch input:checked + i { border-color: var(--mint); background: var(--mint); }
.switch input:checked + i::after { transform: translateX(16px); }

.generation-notice { margin: 11px 0 0; color: #98a49f; font-size: 10px; line-height: 1.6; }
.primary-action { width: 100%; min-height: 48px; display: flex; align-items: center; justify-content: center; gap: 10px; margin-top: 16px; padding: 11px 14px; border: 0; border-radius: 4px; background: var(--mint); color: #fff; font-size: 13px; font-weight: 900; }
.primary-action:hover { background: var(--mint-dark); }
.primary-action b { margin-left: auto; font-size: 18px; font-weight: 500; }
.primary-action:disabled { opacity: .52; cursor: wait; }
.step-badge { flex: 0 0 27px; height: 27px; display: grid; place-items: center; border: 1px solid rgba(255,255,255,.8); border-radius: 50%; background: #fff; color: var(--mint-dark); font-size: 14px; font-weight: 900; }
.ghost-action { width: 100%; margin-top: 10px; padding: 10px; border: 1px solid var(--line); border-radius: 4px; background: #fff; color: var(--ink); font-size: 11px; font-weight: 700; }
.understood { margin-top: 24px; padding-top: 18px; border-top: 1px solid var(--line); }
.recognized-edit-help { margin: -2px 0 10px; color: var(--muted); font-size: 10px; line-height: 1.55; }
.recognized-edits { display: grid; gap: 9px; }
.recognized-edit-row { display: grid; grid-template-columns: 28px minmax(0,1fr); gap: 8px; padding: 10px; border: 1px solid var(--line); border-left: 3px solid var(--coral); border-radius: 5px; background: #f7faf9; }
.recognized-edit-index { width: 27px; height: 27px; display: grid; place-items: center; border-radius: 50%; background: var(--mint-dark); color: #fff; font-size: 11px; font-weight: 850; }
.recognized-edit-fields { min-width: 0; display: grid; gap: 8px; }
.recognized-edit-fields label { display: grid; gap: 4px; color: var(--muted); font-size: 9px; font-weight: 750; }
.recognized-edit-fields input, .recognized-edit-fields textarea { width: 100%; border: 1px solid var(--line); border-radius: 4px; background: #fff; color: var(--ink); font-family: inherit; font-size: 11px; }
.recognized-edit-fields input { min-height: 34px; padding: 7px 9px; font-weight: 750; }
.recognized-edit-fields textarea { min-height: 62px; padding: 8px 9px; line-height: 1.55; resize: vertical; }
.recognized-edit-kind { align-self: start; width: fit-content; padding: 3px 6px; border-radius: 99px; background: #e3f1ec; color: var(--mint-dark); font-size: 9px; font-weight: 800; }
.recognized-edits-empty { padding: 12px; border-left: 3px solid var(--coral); background: #f6f9f8; color: var(--muted); font-size: 11px; line-height: 1.6; }
.result-card, .history-section, .admin-section { margin-top: 12px; padding: 18px; border: 1px solid var(--line); border-radius: 7px; background: #fff; }
.mini-heading { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; font-size: 12px; font-weight: 900; }
.mini-heading button { border: 0; background: transparent; color: var(--mint-dark); padding: 0; font-size: 10px; font-weight: 800; }
pre { margin: 0; padding: 12px; white-space: pre-wrap; border-left: 3px solid var(--coral); background: #f6f9f8; color: #4c5f58; font-family: inherit; font-size: 11px; line-height: 1.7; }
.result-card > img { width: 100%; display: block; border: 1px solid var(--line); border-radius: 4px; }
.result-gallery { display: flex; gap: 7px; overflow: auto; margin-top: 8px; }
.result-gallery img { width: 62px; height: 62px; object-fit: cover; border: 2px solid transparent; border-radius: 3px; cursor: pointer; }
.result-gallery img:hover { border-color: var(--mint); }
.history-list { display: grid; gap: 6px; max-height: 210px; overflow: auto; }
.history-item { display: flex; align-items: center; gap: 7px; padding: 9px; border: 1px solid var(--line); border-radius: 4px; background: #fbfcfc; cursor: pointer; }
.history-item:hover { border-color: #94b8ad; }
.history-dot { width: 7px; height: 7px; flex: 0 0 auto; border-radius: 50%; background: #c8d0cd; }
.history-dot.completed { background: var(--mint); }
.history-dot.partial { background: #d4932c; }
.history-dot.failed { background: var(--coral); }
.history-image-details { margin: -1px 4px 4px; padding: 6px 9px; border: 1px solid var(--line); border-radius: 0 0 4px 4px; background: #fff; color: #52645e; font-size: 10px; }
.history-image-details summary { cursor: pointer; color: var(--mint-dark); font-weight: 700; }
.history-image-row { padding: 7px 0; border-top: 1px solid var(--line); line-height: 1.5; }
.history-image-row:first-of-type { margin-top: 6px; }
.history-image-row strong { display: block; }
.history-image-row span { color: var(--muted); }
.history-image-row p, .history-image-legacy { margin: 3px 0 0; overflow-wrap: anywhere; color: #ad4e45; }
.history-title { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: #52645e; font-size: 10px; }
.history-time { margin-left: auto; color: #9aa6a2; font-size: 9px; }
.history-item { width: 100%; text-align: left; }
.history-time { flex: 0 0 auto; white-space: nowrap; font-variant-numeric: tabular-nums; font-size: 11px; color: var(--muted); }
.history-heading-actions { margin-left: auto; display: flex; gap: 14px; }
.history-heading-actions button { margin: 0 !important; }
.history-view { margin-left: 2px; padding: 4px 6px; border: 1px solid var(--line); border-radius: 3px; background: #fff; color: var(--mint-dark); font-size: 9px; white-space: nowrap; }
.history-note { margin-top: 12px; padding: 13px 15px; border: 1px dashed #b9cac4; border-radius: 6px; background: #f8fbfa; color: #899791; font-size: 10px; line-height: 1.6; }

/* Fullscreen task history keeps previews separate from the current workspace. */
body.history-open { overflow: hidden; }
.history-dialog { position: fixed; z-index: 20; inset: 0; display: none; min-width: 0; width: auto; height: auto; max-width: none; max-height: none; overflow: hidden; margin: 0; padding: 0; border: 0; color: var(--ink); background: var(--surface); }
.history-dialog[open] { display: flex; flex-direction: column; }
.history-dialog::backdrop { background: rgba(23, 41, 35, .3); }
.history-dialog-header { flex: 0 0 auto; display: flex; align-items: center; justify-content: space-between; gap: 20px; padding: 20px 28px; border-bottom: 1px solid var(--line); background: #fff; }
.history-dialog-header h2 { margin: 0 0 6px; font-size: 22px; }
.history-dialog-header p { margin: 0; color: var(--muted); font-size: 12px; }
.history-dialog-actions, .history-download-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.history-dialog button:not(.history-task):not(.history-image-thumbnails button) { min-height: 36px; padding: 7px 12px; border: 1px solid var(--line-strong); border-radius: 6px; background: #fff; color: var(--mint-dark); font-size: 12px; font-weight: 700; }
.history-dialog #closeHistoryDialog { background: var(--mint-dark); border-color: var(--mint-dark); color: #fff; }
.history-dialog-layout { min-width: 0; min-height: 0; flex: 1; display: grid; grid-template-columns: minmax(240px, 310px) minmax(0, 1fr); overflow: hidden; }
.history-dialog-sidebar { min-width: 0; min-height: 0; display: flex; flex-direction: column; overflow: hidden; border-right: 1px solid var(--line); background: #fff; }
.history-filters { display: flex; flex: 0 0 auto; gap: 7px; padding: 18px 18px 10px; }
.history-dialog .history-filters button[aria-pressed="true"] { color: var(--mint-dark); background: var(--mint-pale); border-color: var(--mint); }
.history-dialog-notice { flex: 0 0 auto; padding: 0 18px; color: #a94539; font-size: 12px; line-height: 1.6; overflow-wrap: anywhere; }
.history-dialog-notice:not(:empty) { padding-bottom: 10px; }
.history-dialog-list { min-width: 0; min-height: 0; flex: 1 1 0; overflow-y: auto; overflow-x: hidden; display: flex; flex-direction: column; gap: 9px; padding: 8px 18px 20px; }
.history-task { min-width: 0; min-height: 112px; max-width: 100%; width: 100%; flex: 0 0 auto; display: grid; grid-template-columns: 68px minmax(0, 1fr); align-items: center; gap: 12px; padding: 12px; border: 1px solid var(--line); border-radius: 8px; color: var(--ink); background: #fff; text-align: left; }
.history-task > * { min-width: 0; max-width: 100%; }
.history-task-thumbnail { width: 68px; height: 84px; display: grid; place-items: center; padding: 3px; border-radius: 5px; overflow: hidden; background: var(--surface); color: var(--muted); font-size: 10px; line-height: 1.5; text-align: center; }
.history-task-thumbnail img { width: 100%; height: 100%; object-fit: contain; }
.history-task-meta { min-width: 0; display: flex; flex-direction: column; align-items: stretch; gap: 8px; }
.history-task:hover { background: #f7faf8; border-color: var(--mint); }
.history-task[aria-current="true"] { background: #eef7f3; border-color: var(--mint); box-shadow: inset 3px 0 var(--mint); }
.history-task-heading { display: flex; align-items: center; justify-content: space-between; gap: 10px; font-size: 14px; }
.history-task .history-time { margin-left: 0; white-space: normal; line-height: 1.5; font-size: 12px; }
.history-task-count { color: var(--mint-dark); font-size: 12px; }
.history-detail { min-width: 0; min-height: 0; display: flex; flex-direction: column; gap: 14px; overflow-y: auto; overflow-x: hidden; padding: 24px; }
.history-detail-heading { display: flex; flex: 0 0 auto; align-items: flex-start; justify-content: space-between; gap: 18px; }
.history-detail-heading > div { min-width: 0; }
.history-detail-heading h3 { margin: 0 0 8px; font-size: 17px; overflow-wrap: anywhere; }
.history-detail-heading p { margin: 4px 0 0; color: var(--muted); font-size: 12px; overflow-wrap: anywhere; }
.history-image-stage { position: relative; flex: 1 0 50dvh; min-height: 300px; display: grid; place-items: center; overflow: hidden; border: 1px solid var(--line); border-radius: 9px; background: #e7eeea; }
.history-image-stage > img { position: absolute; inset: 12px; width: calc(100% - 24px); height: calc(100% - 24px); object-fit: contain; }
.history-image-thumbnails { display: flex; flex: 0 0 auto; flex-wrap: wrap; gap: 10px; padding: 2px; }
.history-image-thumbnails button { flex: 0 0 82px; display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 6px; border: 2px solid transparent; border-radius: 7px; background: #fff; color: var(--muted); font-size: 11px; }
.history-image-thumbnails button[aria-pressed="true"] { border-color: var(--mint); color: var(--mint-dark); }
.history-image-thumbnails img { width: 66px; height: 64px; object-fit: contain; }
.history-empty { margin: auto; padding: 32px 20px; color: var(--muted); text-align: center; font-size: 14px; line-height: 1.8; }
.history-detail-error, .history-detail-warning { flex: 0 0 auto; margin: 0; padding: 12px; border-radius: 6px; background: #fff0ed; color: #a94539; overflow-wrap: anywhere; font-size: 13px; line-height: 1.7; }
.history-detail-warning { color: #8a6618; background: #fff8e8; }
.history-image-error { padding: 20px; color: #a94539; font-size: 13px; }
.history-task-description, .history-detail .history-image-details { min-width: 0; max-width: 100%; flex: 0 0 auto; margin: 0; padding: 12px; border: 1px solid var(--line); border-radius: 6px; background: #fff; font-size: 12px; }
.history-task-description summary { min-width: 0; display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: 10px; cursor: pointer; color: var(--mint-dark); font-weight: 700; }
.history-description-preview { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--muted); font-size: 12px; font-weight: 400; }
.history-description-action { white-space: nowrap; font-size: 11px; }
.history-task-description[open] .history-description-preview, .history-task-description[open] .history-description-action { display: none; }
.history-task-description[open] summary::after { content: '收起详情'; justify-self: end; grid-column: 3; font-size: 11px; }
.history-task-description p { margin: 12px 0 0; white-space: pre-wrap; overflow-wrap: anywhere; line-height: 1.7; }
@media (max-width: 760px) {
  .history-item { flex-wrap: wrap; }
  .history-title { flex: 1; font-size: 11px; }
  .history-item .history-time { order: 2; width: 100%; margin: 0 0 0 14px; }
  .history-dialog-header { padding: 12px 14px; gap: 12px; flex-wrap: wrap; }
  .history-dialog-header h2 { font-size: 18px; }
  .history-dialog-header p { font-size: 10px; }
  .history-dialog-actions { flex: 0 0 auto; }
  .history-dialog-layout { grid-template-columns: 1fr; grid-template-rows: minmax(135px, 28dvh) minmax(0, 1fr); }
  .history-dialog-sidebar { border-right: 0; border-bottom: 1px solid var(--line); }
  .history-filters { padding: 8px 12px 4px; }
  .history-dialog-list { padding: 6px 12px; gap: 6px; }
  .history-task { padding: 10px 12px; gap: 5px; }
  .history-detail { padding: 14px; gap: 12px; }
  .history-detail-heading { flex-wrap: wrap; gap: 10px; }
  .history-image-stage { flex-basis: 210px; min-height: 210px; }
}
@media (min-width: 761px) and (max-width: 1100px) {
  .history-dialog-layout { grid-template-columns: minmax(210px, 260px) minmax(0, 1fr); }
  .history-detail { padding: 16px; }
  .history-detail-heading { flex-wrap: wrap; gap: 12px; }
  .history-dialog-header { padding: 16px; }
  .history-download-actions button { padding-inline: 8px !important; }
}
.muted { color: #98a49f; font-size: 10px; }

/* Embedded admin summary */
.stats-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 7px; }
.stat { padding: 9px; border: 1px solid var(--line); background: #fbfcfc; }
.stat strong { display: block; font-size: 18px; }
.stat span { color: var(--muted); font-size: 9px; }
.admin-subsection { margin-top: 18px; padding-top: 15px; border-top: 1px solid var(--line); }
.admin-form { display: grid; gap: 7px; }
.admin-form input, .admin-user-row input { padding: 8px 9px; font-size: 10px; }
.admin-form .primary-action { min-height: 38px; margin-top: 4px; font-size: 10px; }
.admin-users, .admin-jobs { display: grid; gap: 7px; }
.admin-user-row, .admin-job-row { padding: 9px; border: 1px solid var(--line); background: #fbfcfc; font-size: 10px; color: #52645e; }
.admin-user-meta { display: flex; justify-content: space-between; gap: 8px; margin-bottom: 7px; }
.admin-user-meta small { color: #91a09a; }
.admin-user-fields { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.admin-user-fields input[type=password] { grid-column: 1 / -1; }
.admin-user-row button { width: 100%; margin-top: 7px; padding: 7px; border: 1px solid var(--line); background: #fff; color: var(--mint-dark); font-size: 10px; font-weight: 800; }
.admin-jobs { max-height: 300px; overflow: auto; }
.admin-job-row { line-height: 1.5; }
.admin-job-error { color: #c14d47; }

.task-progress { position: fixed; z-index: 30; left: 50%; bottom: max(24px, env(safe-area-inset-bottom)); min-width: 142px; display: flex; align-items: center; justify-content: center; gap: 10px; padding: 11px 18px; border: 1px solid rgba(255,255,255,.18); border-radius: 99px; background: rgba(23,41,35,.82); color: #fff; box-shadow: 0 12px 34px rgba(15,31,26,.2); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); opacity: 0; visibility: hidden; transform: translateX(-50%) translateY(12px); pointer-events: none; transition: opacity .2s ease, transform .2s ease, visibility .2s ease; }
.task-progress.show { opacity: 1; visibility: visible; transform: translateX(-50%) translateY(0); }
.task-progress strong { font-size: 13px; font-weight: 850; letter-spacing: 0; }
.task-progress-indicator { width: 10px; height: 10px; flex: 0 0 auto; border-radius: 50%; background: #c7d5d0; }
.task-progress[data-state="recognizing"] .task-progress-indicator, .task-progress[data-state="generating"] .task-progress-indicator { width: 14px; height: 14px; border: 2px solid rgba(255,255,255,.35); border-top-color: #fff; background: transparent; animation: task-progress-spin .8s linear infinite; }
.task-progress[data-state="success"] { background: rgba(28,111,93,.84); }
.task-progress[data-state="success"] .task-progress-indicator { background: #bdf1df; }
.task-progress[data-state="failed"] { background: rgba(157,55,47,.84); }
.task-progress[data-state="failed"] .task-progress-indicator { background: #ffd0cb; }
@keyframes task-progress-spin { to { transform: rotate(360deg); } }

.toast { position: fixed; z-index: 20; left: 50%; bottom: 28px; max-width: min(720px, calc(100vw - 32px)); transform: translateX(-50%) translateY(14px); padding: 12px 16px; border-radius: 5px; background: var(--ink); color: #fff; opacity: 0; pointer-events: none; transition: .18s ease; font-size: 12px; line-height: 1.5; }
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.task-progress.show + .toast { bottom: 82px; }

@media (max-width: 1180px) {
  .topbar { grid-template-columns: 1fr auto; }
  .topbar-center { display: none; }
  .app-shell { grid-template-columns: 1fr 430px; padding: 18px; }
  .workspace { padding: 20px; }
  .control-panel { padding: 11px; }
  .mode-content { padding: 20px; }
}

@media (max-width: 900px) {
  .login-screen { grid-template-columns: 1fr; }
  .login-showcase { display: none; }
  .login-panel { min-height: 100vh; padding: 32px; background: var(--surface); }
  .login-card { padding: 28px; border: 1px solid var(--line); border-radius: 8px; background: #fff; box-shadow: var(--shadow); }
  .login-mobile-brand { display: flex; margin-bottom: 54px; }
  .topbar { position: static; padding: 14px 18px; }
  .account-bar { gap: 7px; flex-wrap: wrap; }
  .brand small, .account-bar > span + span { display: none; }
  .app-shell { grid-template-columns: 1fr; padding: 12px; }
  .control-panel { padding: 10px; }
  .canvas-wrap, .empty-state { min-height: 410px; }
}

@media (max-width: 560px) {
  .login-panel { padding: 18px; }
  .login-card { padding: 22px; }
  .login-mobile-brand { margin-bottom: 38px; }
  .topbar { display: flex; align-items: flex-start; justify-content: space-between; }
  .brand { font-size: 16px; }
  .brand-mark { width: 26px; height: 26px; }
  .account-bar { max-width: 58%; justify-content: flex-end; font-size: 9px; }
  .workspace { padding: 15px; }
  .section-heading { align-items: flex-start; }
  .section-heading h1 { font-size: 22px; }
  .section-subtitle { display: none; }
  .status-pill { padding: 6px 8px; font-size: 9px; }
  .canvas-wrap { min-height: 330px; padding: 10px; }
  .empty-state { min-height: 320px; }
  .toolbar-label { width: 100%; }
  .color-label { margin-left: 0; }
  .panel-tabs { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 4px; padding: 5px; }
  .tab { min-height: 62px; padding: 8px 2px; font-size: 12px; }
  .tab small { font-size: 11px; }
  .mode-content { padding: 18px 15px; }
  .option-grid { grid-template-columns: 1fr; }
  .reference-grid { grid-template-columns: repeat(2, 1fr); }
  .task-progress { bottom: max(16px, env(safe-area-inset-bottom)); min-width: 132px; padding: 10px 15px; }
  .task-progress.show + .toast { bottom: 70px; }
}

/* Department portal shell — selected dark-green sidebar direction */
.brand-logo { width: 46px; height: 46px; display: block; object-fit: cover; }
.button-icon { width: 19px; height: 19px; margin-left: auto; filter: brightness(0) invert(1); }
.legacy-account-controls { display: none; }

.portal-login-showcase { padding: 48px 64px; background: #063f31; }
.portal-login-showcase::before, .portal-login-showcase::after { display: none; }
.portal-login-showcase .brand-logo { width: 38px; height: 38px; }
.portal-login-showcase .showcase-copy { top: 160px; }
.portal-login-showcase .showcase-copy h1 { max-width: 620px; font-size: clamp(46px, 5vw, 76px); letter-spacing: -.045em; }
.portal-login-showcase .showcase-copy p:last-child { max-width: 520px; color: #bed3cc; line-height: 1.8; }
.login-project-list { position: absolute; left: 64px; right: 64px; bottom: 92px; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 9px; max-width: 650px; max-height: 280px; overflow-y: auto; }
.login-project-item { min-height: 58px; display: grid; grid-template-columns: 38px minmax(0, 1fr) 18px; align-items: center; gap: 10px; padding: 9px 12px; border: 1px solid rgba(255,255,255,.16); border-radius: 7px; color: #f5fbf8; background: rgba(255,255,255,.06); }
.login-project-item > span:not(.portal-project-icon) { min-width: 0; }
.login-project-item strong, .login-project-item small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.login-project-item strong { font-size: 12px; }
.login-project-item small { margin-top: 3px; color: #a9c5bc; font-size: 9px; }
.login-project-loading { grid-column: 1 / -1; color: #bed3cc; font-size: 11px; }
.login-project-list .lock-icon { width: 15px; height: 15px; opacity: .48; filter: brightness(0) invert(1); }
.portal-login-showcase .showcase-index { left: 64px; bottom: 47px; }

.portal-project-icon { --project-icon-bg: #447a68; width: 34px; height: 34px; display: grid; place-items: center; flex: 0 0 34px; overflow: hidden; border-radius: 9px; background: var(--project-icon-bg); }
.portal-project-icon img { width: 18px; height: 18px; object-fit: contain; filter: brightness(0) invert(1); }
.portal-project-icon.has-custom-icon { padding: 3px; }
.portal-project-icon.has-custom-icon img { width: 100%; height: 100%; border-radius: 6px; background: #fff; filter: none; }
.portal-project-icon.has-preset-icon { padding: 0; }
.portal-project-icon .project-preset-icon { display: grid; place-items: center; color: #fff; font-size: 18px; font-weight: 850; line-height: 1; }
.portal-project-icon.detail-project-icon .project-preset-icon { font-size: 23px; }

.portal-frame { min-height: 100vh; display: grid; grid-template-columns: 240px minmax(0, 1fr); background: #fff; transition: grid-template-columns .2s ease; }
.portal-stage { min-width: 0; min-height: 100vh; display: flex; flex-direction: column; background: #fff; }
.portal-sidebar { position: sticky; top: 0; z-index: 14; height: 100vh; display: flex; flex-direction: column; overflow: hidden; padding: 28px 14px 18px; color: #fff; background: #063f31; }
.sidebar-heading { min-height: 46px; display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 0 13px 24px; }
.sidebar-heading strong { white-space: nowrap; font-size: 23px; letter-spacing: -.04em; }
.sidebar-heading button, .sidebar-account button { flex: 0 0 34px; height: 34px; display: grid; place-items: center; padding: 0; border: 0; border-radius: 6px; background: transparent; }
.sidebar-heading button:hover, .sidebar-account button:hover { background: rgba(255,255,255,.12); }
.sidebar-heading img, .sidebar-account img, .sidebar-action img { width: 20px; height: 20px; filter: brightness(0) invert(1); }
.project-nav { display: grid; gap: 7px; overflow-y: auto; padding-top: 9px; }
.project-nav-row { position: relative; display: grid; grid-template-columns: minmax(0, 1fr) 34px; border-radius: 8px; }
.project-nav-row:hover { background: rgba(255,255,255,.08); }
.project-nav-row.active { color: #08614d; background: #edf6f2; }
.project-nav-button, .favorite-button { border: 0; background: transparent; color: inherit; }
.project-nav-button { min-width: 0; min-height: 70px; display: grid; grid-template-columns: 34px minmax(0, 1fr); align-items: center; gap: 10px; padding: 8px 3px 8px 10px; text-align: left; }
.project-nav-copy { min-width: 0; display: block; }
.project-nav-title { display: flex; align-items: center; gap: 5px; }
.project-nav-title strong { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13px; font-weight: 700; line-height: 1.3; }
.project-nav-title em { flex: 0 0 auto; padding: 1px 4px; border-radius: 3px; color: #c1d7d0; background: rgba(255,255,255,.1); font-size: 8px; font-style: normal; }
.project-nav-copy > small { display: -webkit-box; overflow: hidden; margin-top: 4px; color: #9fbdb4; font-size: 9px; font-weight: 500; line-height: 1.35; -webkit-box-orient: vertical; -webkit-line-clamp: 2; }
.project-nav-row.active .project-nav-title em { color: #557f74; background: #dbece6; }
.project-nav-row.active .project-nav-copy > small { color: #6e8f86; }
.favorite-button { width: 34px; display: grid; place-items: center; padding: 0; opacity: 0; }
.project-nav-row:hover .favorite-button, .favorite-button.selected { opacity: 1; }
.favorite-button img { width: 17px; height: 17px; filter: brightness(0) invert(1); opacity: .72; }
.favorite-button.selected img { filter: none; opacity: 1; }
.sidebar-bottom { margin-top: auto; padding-top: 18px; border-top: 1px solid rgba(255,255,255,.26); }
.sidebar-action, .sidebar-account { min-height: 48px; display: flex; align-items: center; gap: 11px; padding: 8px 13px; color: #fff; font-size: 13px; font-weight: 700; text-decoration: none; }
.sidebar-action:hover { border-radius: 7px; background: rgba(255,255,255,.09); }
.sidebar-account { margin-top: 10px; }
.sidebar-account > span { min-width: 0; flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
body.portal-guest .portal-sidebar { box-shadow: inset 0 0 0 1px rgba(255,255,255,.04); }
body.portal-guest .portal-stage { position: relative; }
body.portal-guest .portal-stage::after { content: "预览模式 · 点击功能后登录"; position: fixed; z-index: 18; right: 20px; bottom: 20px; padding: 9px 13px; border: 1px solid #c9ddd6; border-radius: 99px; background: rgba(247,251,249,.94); color: var(--mint-dark); box-shadow: 0 8px 24px rgba(18,53,43,.12); font-size: 11px; font-weight: 800; pointer-events: none; }
body.portal-guest #appView button, body.portal-guest #appView a, body.portal-guest #appView label { cursor: pointer; }

.portal-frame.sidebar-collapsed { grid-template-columns: 74px minmax(0, 1fr); }
.sidebar-collapsed .portal-sidebar { padding-inline: 10px; }
.sidebar-collapsed .sidebar-heading { justify-content: center; padding-inline: 0; }
.sidebar-collapsed .sidebar-heading strong, .sidebar-collapsed .project-nav-copy, .sidebar-collapsed .favorite-button, .sidebar-collapsed .sidebar-action span, .sidebar-collapsed .sidebar-account > span { display: none; }
.sidebar-collapsed .project-nav-row { display: block; }
.sidebar-collapsed .project-nav-button { width: 100%; grid-template-columns: 1fr; place-items: center; padding: 8px; }
.sidebar-collapsed .sidebar-action, .sidebar-collapsed .sidebar-account { justify-content: center; padding-inline: 0; }
.sidebar-collapsed .sidebar-account button { display: none; }

.portal-stage .topbar { position: sticky; min-height: 100px; padding: 0 34px; grid-template-columns: minmax(220px, 1fr) auto minmax(150px, 1fr); background: rgba(255,255,255,.98); }
.portal-stage .topbar .brand { font-size: 28px; letter-spacing: -.04em; }
.portal-stage .topbar .brand small { align-self: center; font-size: 11px; letter-spacing: 0; }
.workspace-brand-copy { min-width: 0; display: grid; gap: 4px; }
.workspace-brand-copy > div { display: flex; align-items: baseline; gap: 8px; }
.workspace-credits { overflow: hidden; color: var(--muted); font-size: 11px; font-weight: 650; letter-spacing: 0; line-height: 1.35; text-overflow: ellipsis; white-space: nowrap; }
.portal-stage .topbar-center { display: none; }
.portal-stage .panel-tabs { width: auto; display: flex; gap: 0; padding: 0; border-radius: 6px; box-shadow: none; overflow: hidden; }
.portal-stage .panel-tabs .tab { min-width: 114px; min-height: 50px; flex-direction: row; padding: 10px 17px; border: 0; border-right: 1px solid var(--line); border-radius: 0; font-size: 14px; }
.portal-stage .panel-tabs .tab small { display: none; }
.portal-stage .panel-tabs .tab.active { background: #e4f1ec; color: #08715a; box-shadow: none; }
body[data-portal-project="ai-edit"] .panel-tabs [data-mode="generate"], body[data-portal-project="ai-edit"] .panel-tabs [data-mode="img2img"], body[data-portal-project="ai-generate"] .panel-tabs [data-mode="edit"], body[data-portal-project="ai-generate"] .panel-tabs [data-mode="replace"] { display: none; }
.top-history-button { justify-self: end; min-height: 44px; display: inline-flex; align-items: center; gap: 9px; padding: 0 15px; border: 1px solid var(--line-strong); border-radius: 6px; color: var(--ink); background: #fff; font-size: 13px; font-weight: 750; }
.top-history-button img { width: 19px; height: 19px; }

.portal-stage > .toolbar { min-height: 82px; flex-wrap: nowrap; padding: 0 34px; border-bottom: 1px solid var(--line); background: #fff; }
.portal-stage > .toolbar .toolbar-label { display: none; }
.portal-stage > .toolbar .tool { min-height: 39px; display: inline-flex; align-items: center; gap: 8px; border-color: transparent; background: transparent; }
.portal-stage > .toolbar .tool img { width: 18px; height: 18px; }
.portal-stage > .toolbar .tool.active { border-color: #d8ebe5; background: #e5f3ee; }
.portal-stage > .toolbar .color-label { margin-left: 10px; padding-left: 20px; border-left: 1px solid var(--line); }

.portal-stage .app-shell { width: 100%; flex: 1; display: grid; grid-template-columns: minmax(520px, 1fr) 373px; gap: 0; margin: 0; padding: 0; border-bottom: 1px solid var(--line); }
.portal-stage .workspace, .portal-stage .control-panel { border: 0; border-radius: 0; }
.portal-stage .workspace { display: flex; flex-direction: column; padding: 27px 34px 38px; }
.portal-stage .section-heading { order: 0; margin-bottom: 18px; }
.portal-stage .section-heading .eyebrow, .portal-stage .section-subtitle, .portal-stage .status-pill { display: none; }
.portal-stage .section-heading h1 { margin: 0; font-size: 23px; }
.portal-stage .canvas-wrap { order: 1; min-height: 560px; flex: 1; padding: 22px; border-style: dashed; background: #eef1f0; }
.portal-stage .canvas-wrap::before, .portal-stage .canvas-wrap::after, .portal-stage .canvas-corner { display: none; }
.portal-stage .empty-state { min-height: 500px; }
.empty-upload-icon { width: 170px; height: 170px; margin: -26px 0 -21px; object-fit: contain; }
.portal-stage .toolbar:not(.portal-stage > .toolbar) { display: none; }
.portal-stage .control-panel { padding: 30px 33px; border-left: 1px solid var(--line); background: #fff; box-shadow: none; }
.portal-stage .control-panel > .panel-tabs { display: none; }
.portal-stage .mode-content { margin-top: 0; padding: 0; border: 0; }
.portal-stage .mode-heading .mode-symbol, .portal-stage .mode-heading p { display: none; }
.portal-stage .mode-heading h2 { font-size: 23px; }
.portal-stage .panel-intro { font-size: 12px; }
.portal-stage .quality-toggle { border-width: 1px 0 0; border-radius: 0; padding: 24px 0 8px; background: #fff; }
.portal-stage .primary-action { min-height: 70px; border-radius: 5px; font-size: 15px; }
.portal-stage .history-note, .portal-stage .admin-section { display: none !important; }
.portal-stage > .history-section { min-height: 82px; flex: 0 0 auto; margin: 14px 34px; padding: 0; border-radius: 7px; box-shadow: none; }
.portal-stage > .history-section .mini-heading { min-height: 80px; margin: 0; padding: 0 20px; }
.portal-stage > .history-section .mini-heading::before { content: ""; width: 20px; height: 20px; margin-right: 10px; background: url('/assets/icons/history.svg') center / contain no-repeat; }
.portal-stage > .history-section .mini-heading button { margin-left: auto; }
.portal-stage > .history-section .history-list { display: none; padding: 0 20px 16px; }
.portal-stage > .history-section.open .history-list { display: grid; }

.project-detail { flex: 1; min-height: calc(100dvh - 100px); height: calc(100dvh - 100px); display: grid; grid-template-columns: minmax(300px, .82fr) minmax(420px, 1.18fr); align-items: center; gap: clamp(28px, 5vw, 84px); overflow: hidden; padding: clamp(32px, 5vw, 76px); background: #f5f8f7; }
.project-detail-summary, .project-detail-panels { min-width: 0; }
.project-detail-panels { display: grid; gap: 14px; }
.project-detail .detail-kicker { display: flex; align-items: center; gap: 10px; color: var(--mint-dark); font-size: 12px; font-weight: 850; }
.project-detail .detail-kicker .detail-project-icon { width: 42px; height: 42px; border-radius: 11px; }
.project-detail .detail-kicker .detail-project-icon img { width: 21px; height: 21px; }
.project-detail .detail-kicker .detail-project-icon.has-custom-icon img { width: 100%; height: 100%; }
.project-tagline-detail { margin: 7px 0 0; color: var(--mint-strong); font-size: 13px; font-weight: 700; }
.project-guide-copy { white-space: pre-wrap; }
.guide-download { width: fit-content; display: inline-flex; align-items: center; gap: 7px; margin-top: 12px; padding: 9px 12px; border: 1px solid var(--line); border-radius: 5px; color: var(--mint-strong); background: #fff; font-size: 11px; font-weight: 750; text-decoration: none; }
.guide-download img { width: 17px; height: 17px; }
.project-detail h1 { margin: 18px 0 12px; font-size: clamp(36px, 5vw, 64px); letter-spacing: -.045em; }
.project-description { color: var(--muted); font-size: 17px; line-height: 1.8; }
.project-credits { display: flex; gap: 10px; flex-wrap: wrap; margin: 22px 0 10px; }
.project-credits > div { min-width: 190px; display: grid; gap: 5px; padding: 13px 15px; border: 1px solid var(--line); border-radius: 7px; background: #fff; }
.project-credits span { color: var(--muted); font-size: 11px; font-weight: 700; }
.project-credits strong { color: var(--ink); font-size: 14px; line-height: 1.5; }
.project-status { display: inline-flex; margin: 10px 0 0; padding: 7px 11px; border-radius: 99px; background: #e0ede8; color: var(--mint-dark); font-size: 11px; font-weight: 800; }
.project-detail section, .project-guide-section { margin: 0; padding: 22px 24px; border: 1px solid var(--line); border-radius: 8px; background: #fff; }
.project-detail section h2 { font-size: 17px; }
.project-detail section p { margin: 0; color: var(--muted); font-size: 13px; line-height: 1.8; white-space: pre-wrap; }
.project-guide-section > summary { display: flex; align-items: center; justify-content: space-between; gap: 16px; color: var(--ink); cursor: pointer; list-style: none; }
.project-guide-section > summary::-webkit-details-marker { display: none; }
.project-guide-section > summary span { font-size: 17px; font-weight: 800; }
.project-guide-section > summary small { color: var(--mint-strong); font-size: 11px; font-weight: 750; }
.project-guide-section[open] > summary small { font-size: 0; }
.project-guide-section[open] > summary small::after { content: "收起"; font-size: 11px; }
.project-guide-body { max-height: 42vh; overflow-y: auto; margin-top: 16px; padding-top: 16px; border-top: 1px solid var(--line); }
.resource-download { display: inline-flex; align-items: center; gap: 8px; margin-top: 5px; padding: 11px 14px; border: 1px solid var(--mint); border-radius: 5px; background: var(--mint); color: #fff; font-size: 12px; font-weight: 800; text-decoration: none; }
.resource-download img { width: 18px; height: 18px; filter: brightness(0) invert(1); }
.download-code { margin-top: 12px !important; }
.locked-project-action { cursor: pointer; }
.locked-project-action img { filter: none; }
.revealed-download-link { display: inline-block; margin-top: 14px; color: var(--mint-strong); font-size: 13px; font-weight: 800; }

@media (min-width: 1051px) {
  /* Long recognition lists stay in the side panel instead of stretching the canvas row. */
  body[data-portal-project="ai-edit"] .portal-stage .app-shell { height: calc(100dvh - 182px); min-height: 520px; max-height: 1050px; grid-template-rows: minmax(0, 1fr); overflow: hidden; }
  body[data-portal-project="ai-edit"] .portal-stage .workspace { min-height: 0; overflow: hidden; }
  body[data-portal-project="ai-edit"] .portal-stage .canvas-wrap:not(.zoomed) { min-height: 0; overflow: hidden; }
  body[data-portal-project="ai-edit"] .portal-stage #canvas { height: auto; }
  body[data-portal-project="ai-edit"] .portal-stage .control-panel { align-self: stretch; min-height: 0; max-height: none; overflow-y: auto; }
}

@media (max-width: 1050px) {
  .portal-stage .topbar { grid-template-columns: minmax(170px, 1fr) auto; min-height: 82px; }
  .portal-stage .panel-tabs { order: 3; grid-column: 1 / -1; width: 100%; }
  .portal-stage .panel-tabs .tab { flex: 1; }
  .portal-stage .app-shell { grid-template-columns: 1fr; }
  .portal-stage .control-panel { border-top: 1px solid var(--line); border-left: 0; }
  .project-detail { height: auto; min-height: calc(100dvh - 82px); grid-template-columns: 1fr; align-items: start; overflow: visible; }
  .project-detail-panels { width: 100%; }
  .project-guide-body { max-height: none; }
}

@media (max-width: 760px) {
  .portal-frame, .portal-frame.sidebar-collapsed { grid-template-columns: 1fr; }
  .portal-sidebar { position: static; width: 100%; height: auto; min-height: 0; padding: 12px; }
  .sidebar-heading { min-height: 42px; padding: 0 4px; }
  .sidebar-heading strong { font-size: 18px; }
  .sidebar-heading button { display: none; }
  .project-nav { display: flex; overflow-x: auto; }
  .project-nav-row, .sidebar-collapsed .project-nav-row { flex: 0 0 auto; display: block; }
  .project-nav-button, .sidebar-collapsed .project-nav-button { width: auto; min-height: 42px; display: flex; padding: 8px 11px; }
  .sidebar-collapsed .project-nav-button span { display: block; }
  .project-nav-button em, .favorite-button, .sidebar-bottom { display: none !important; }
  .portal-stage .topbar { position: static; padding: 12px 16px; }
  .portal-stage .topbar .brand { font-size: 20px; }
  .workspace-credits { max-width: 58vw; font-size: 10px; }
  .brand-logo { width: 38px; height: 38px; }
  .top-history-button { padding: 0 10px; font-size: 0; }
  .portal-stage > .toolbar { min-height: 62px; padding: 8px 12px; overflow-x: auto; }
  .portal-stage > .toolbar .color-label, .portal-stage > .toolbar .upload-button { flex: 0 0 auto; }
  .portal-stage .app-shell { display: block; }
  .portal-stage .workspace, .portal-stage .control-panel { padding: 20px 16px; }
  .portal-stage .canvas-wrap, .portal-stage .empty-state { min-height: 360px; }
  .inline-annotation-editor { width: min(280px, calc(100% - 28px)); font-size: 17px; }
  .generation-display, .generation-empty, .generation-results { min-height: 360px; }
  .generation-results { padding: 15px; }
  .generation-results-heading { align-items: flex-start; flex-direction: column; }
  .generation-download-actions { justify-content: flex-start; }
  .generation-main-image { min-height: 280px; }
  .portal-stage > .history-section { margin: 10px 12px; }
  .project-detail { padding: 36px 20px; }
  .login-project-list { display: none; }
}
