/* Shared reading and operation layer. No remote fonts or calculation rules. */
:root {
  --ui-ink: #1f2937;
  --ui-muted: #5b687a;
  --ui-accent: #17634e;
  --ui-accent-soft: #e9f3ee;
  --ui-border: #d7dee5;
  --ui-bg: #f3f5f7;
  --ui-surface: #fff;
  --ui-reading: 15px;
  --ui-label: 14px;
  --ui-input: 16px;
  --ui-small: 13px;
  --ui-title: 28px;
  --ink: var(--ui-ink);
  --muted: var(--ui-muted);
  --green: var(--ui-accent);
  --green-soft: var(--ui-accent-soft);
  --line: var(--ui-border);
  --bg: var(--ui-bg);
  --sidebar: 184px;
  font-family: "PingFang SC", "Microsoft YaHei", "Noto Sans CJK SC", system-ui, sans-serif;
}
:root[data-text-size="large"] {
  --ui-reading: 17px;
  --ui-label: 16px;
  --ui-input: 18px;
  --ui-small: 14px;
  --ui-title: 30px;
}
body { color: var(--ui-ink); }
button, input, select, textarea { font-family: inherit; }
input, .cw-output strong, .cw-rounded-table, .cw-noise-table, .ui-paste-preview { font-variant-numeric: tabular-nums; }
button:focus-visible, a:focus-visible, summary:focus-visible, select:focus-visible, textarea:focus-visible {
  outline: 3px solid var(--ui-accent); outline-offset: 3px;
}
input:focus-visible { outline: 2px solid var(--ui-accent); outline-offset: 2px; }
.shell { background: var(--ui-bg); }
.sidebar { background: #eef2f4; border-color: var(--ui-border); padding: 26px 12px 16px; }
.brand { gap: 9px; padding: 0 7px 34px; }
.brand strong { font-size: 17px; letter-spacing: .2px; }
.brand small { color: var(--ui-muted); font-size: 11px; letter-spacing: 0; }
.nav-label { font-size: 12px; color: var(--ui-muted); letter-spacing: .8px; }
.nav-item { min-height: 46px; padding: 12px; font-size: var(--ui-label); color: #465367; }
.nav-text { min-width: 0; line-height: 1.6; white-space: normal; }
.nav-tail { flex-shrink: 0; }
.nav-item.active { color: #11523f; background: #dfeee5; font-weight: 650; }
.nav-tail, .side-caption { font-size: 11px; color: var(--ui-muted); }
.side-note, .collapse-button { font-size: 12px; color: #526173; }
.topbar { height: 64px; padding: 0 28px; background: #fff; border-color: var(--ui-border); }
.breadcrumb, .account-button { font-size: var(--ui-small); }
.connection { color: #335a46; font-size: 12px; }
.top-actions { gap: 18px; }
.ui-text-size { display: inline-flex; gap: 2px; padding: 3px; border: 1px solid var(--ui-border); border-radius: 7px; background: #f5f7f9; }
.ui-text-size button { font-size: 13px; min-height: 34px; padding: 5px 11px; border-radius: 4px; color: #526173; }
.ui-text-size button[aria-pressed="true"] { background: #fff; color: #164e3c; box-shadow: 0 1px 3px #1f293719; font-weight: 650; }
.shell main { padding: 24px 28px 0; }
.page-heading { margin-bottom: 22px; align-items: center; }
.eyebrow { color: var(--ui-muted); letter-spacing: 1.8px; font-size: 10px; }
h1 { font-size: var(--ui-title); line-height: 1.35; letter-spacing: -.5px; margin-bottom: 9px; }
.page-heading p { color: var(--ui-muted); font-size: var(--ui-reading); line-height: 1.7; }
.heading-dot { color: var(--ui-accent); }
.button, .button.small, .cw-tool-heading .button { font-size: var(--ui-label); min-height: 42px; padding: 9px 15px; border-radius: 6px; }
.button.primary { background: var(--ui-accent); color: #fff; }
.button.subtle { background: #fff; color: #425168; border: 1px solid var(--ui-border); }
.button:hover:not(:disabled) { filter: brightness(.97); }
.notice { font-size: var(--ui-small); line-height: 1.8; background: #fff8e9; color: #76500f; border-color: #e4cfa1; }
.workspace-footer { font-size: 11px; color: var(--ui-muted); margin: 28px 28px 0; }

/* Manual: a narrow index and a generous reading column. */
.manual-toolbar { background: #fff; padding: 14px; border-color: var(--ui-border); }
.search-field { max-width: 620px; background: #f8fafb; border-color: var(--ui-border); min-height: 46px; }
.search-field input { font-size: var(--ui-input); color: var(--ui-ink); }
.search-field input::placeholder { color: #637084; }
.data-caption { font-size: var(--ui-small); color: var(--ui-muted); max-width: none; }
.manual-grid { grid-template-columns: 142px 216px minmax(0,1fr); height: max(620px, calc(100dvh - 290px)); border-color: var(--ui-border); }
.category-pane { background: #f8fafb; }
.pane-title { font-size: var(--ui-small); color: #465367; }
.pane-title > span:last-child, .category-button span { color: var(--ui-muted); font-size: 12px; }
.category-button { font-size: var(--ui-label); color: #465367; min-height: 43px; padding: 11px 10px; }
.category-button.active { color: #14533f; background: var(--ui-accent-soft); }
.category-foot { font-size: 12px; color: var(--ui-muted); line-height: 1.8; }
.factor-row { min-height: 68px; padding: 14px 12px; }
.factor-name { font-size: var(--ui-reading); color: var(--ui-ink); font-weight: 550; }
.factor-sub { font-size: 12px; color: var(--ui-muted); margin-top: 6px; }
.factor-row.active { background: var(--ui-accent-soft); }
.detail-content { padding: 24px; }
.detail-eyebrow { color: var(--ui-muted); font-size: 12px; }
.detail-header h2 { color: var(--ui-ink); font-size: 24px; }
.detail-header small { color: var(--ui-muted); font-size: 13px; }
.detail-summary { color: var(--ui-muted); font-size: var(--ui-reading); line-height: 1.8; }
.detail-tabs { margin: 18px 0 22px; }
.detail-tab { font-size: var(--ui-label); min-height: 42px; color: var(--ui-muted); }
.detail-tab.active { color: var(--ui-accent); border-color: var(--ui-accent); }
.standard-card { margin-bottom: 25px; border-color: var(--ui-border); }
.standard-card-head { background: #f7f9fb; }
.standard-order { color: var(--ui-muted); font-size: 11px; }
.standard-code { color: #134f3c; font-size: 17px; font-weight: 650; }
.standard-title { color: #465367; font-size: var(--ui-reading); line-height: 1.75; }
.scope-tag { color: #3e5367; background: #f0f4f7; font-size: 12px; }
.pdf-button { font-size: 13px; min-height: 40px; color: var(--ui-accent); background: #fff; border-color: #bacac0; }
.standard-info .info-row { font-size: var(--ui-reading); line-height: 1.85; grid-template-columns: 112px minmax(0,1fr); }
.info-row dt { color: #4b5b70; background: #f7f9fb; font-size: var(--ui-label); padding: 14px 12px; font-weight: 550; }
.info-row dd { color: var(--ui-ink); padding: 14px 16px; overflow-wrap: anywhere; }
.comparison, .comparison th, .comparison td { font-size: var(--ui-reading); line-height: 1.8; }
.standard-history, .manual-footer { color: var(--ui-muted); font-size: var(--ui-small); line-height: 1.8; }

/* Calculator: task tabs above an input/inspection split. */
.cw-layout { display: block; }
.cw-tool-nav { display: flex; gap: 5px; position: static; padding: 5px; margin: 0 0 24px; border-radius: 7px; background: #e9eef1; border: 1px solid #dbe2e7; overflow-x: auto; }
.cw-nav-heading, .cw-nav-foot, .cw-tool-number, .cw-tool-arrow { display: none; }
.cw-tool-nav > button { flex: 1 0 auto; width: auto; justify-content: center; min-height: 44px; margin: 0; padding: 11px 16px; font-size: var(--ui-label); color: #455468; border: 1px solid transparent; }
.cw-tool-nav > button.active { background: #fff; border-color: #cbd7cf; color: #14543f; box-shadow: 0 1px 3px #172c2110; }
.cw-tool-nav > button:hover { background: #f8faf9; }
.cw-tool-heading { margin: 0 0 18px; align-items: center; }
.cw-tool-heading h2 { font-size: 21px; color: var(--ui-ink); letter-spacing: 0; }
.cw-tool-heading p { color: var(--ui-muted); font-size: var(--ui-reading); line-height: 1.7; max-width: 760px; }
.cw-work-grid { grid-template-columns: minmax(0,1fr) 340px; gap: 24px; }
.cw-form-panel, .cw-result-panel { border: 1px solid var(--ui-border); border-radius: 8px; padding: 24px; background: #fff; }
.cw-form-panel { min-height: 400px; }
.cw-result-panel { top: 20px; max-height: calc(100dvh - 40px); border-top: 3px solid var(--ui-accent); }
.cw-group { padding: 22px 0; border-color: #e1e6ec; }
.cw-group legend { color: #334155; font-size: 15px; font-weight: 650; }
.cw-group-note, .cw-helper p, .cw-result-note, .cw-result-notes, .cw-output p, .cw-source p, .cw-source summary, .cw-volume-source { font-size: var(--ui-small); line-height: 1.85; color: var(--ui-muted); }
.cw-group-note { margin-bottom: 18px; }
.cw-fields { gap: 22px 20px; }
.cw-field label { font-size: var(--ui-label); color: #334155; font-weight: 550; line-height: 1.6; margin-bottom: 8px; }
.cw-field label span { color: var(--ui-muted); font-size: var(--ui-small); font-weight: 400; }
.cw-field input, .cw-field select, .cw-helper select, .cw-preset-box > select, .cw-preset-box input, .cw-prep-filter input, .cw-prep-filter select, .cw-noise-table input {
  font-size: var(--ui-input); color: var(--ui-ink); background: #fff; border-color: #b8c3cf; min-height: 46px; line-height: 1.5; padding: 10px 12px;
}
.cw-field select { height: auto; text-overflow: ellipsis; }
.cw-field input::placeholder, .cw-preset-box input::placeholder, .cw-prep-filter input::placeholder, .cw-noise-table input::placeholder { font-size: var(--ui-small); color: #68768a; }
.cw-input-shell { display: flex; align-items: stretch; border: 1px solid #b8c3cf; border-radius: 5px; background: #fff; overflow: hidden; }
.cw-input-shell:focus-within { border-color: var(--ui-accent); outline: 2px solid #17634e; outline-offset: 2px; }
.cw-input-shell input { flex: 1; width: 1%; min-width: 0; border: 0; border-radius: 0; background: transparent; outline: none; }
.cw-input-shell input:focus-visible { outline: none; }
.cw-unit { display: flex; align-items: center; padding: 0 12px; border-left: 1px solid #e3e8ed; background: #f7f9fb; color: #4b5b70; font-size: var(--ui-label); white-space: nowrap; pointer-events: none; }
.cw-sign { flex: 0 0 40px; min-height: 44px; font-size: 19px; color: #3c5364; background: #f4f7f9; border-left: 1px solid #e3e8ed; }
.ui-sr-only { position: absolute !important; width: 1px !important; height: 1px !important; padding: 0 !important; margin: -1px !important; overflow: hidden !important; clip-path: inset(50%); white-space: nowrap; border: 0 !important; }
.cw-field-help { display: block; margin-top: 7px; color: var(--ui-muted); font-size: var(--ui-small); line-height: 1.7; }
.cw-field-error { font-size: var(--ui-small); line-height: 1.6; color: #a32222; }
.cw-field-error:empty { display: none; }
.cw-field:has([aria-invalid="true"]) .cw-input-shell { border-color: #b42318; }
.cw-field [aria-invalid="true"] { border-color: #b42318; }
.cw-helper, .cw-preset-box { background: #f7f9fb; border-color: #e0e6ec; border-radius: 6px; }
.cw-helper > label, .cw-factor-search > span, .cw-prep-filter label { font-size: var(--ui-label); color: #334155; }
.cw-subtabs { gap: 6px; flex-wrap: wrap; }
.cw-subtabs button, .cw-quick button, .cw-text-button { font-size: var(--ui-small); min-height: 38px; color: #3e5367; }
.cw-subtabs button.active, .cw-quick button.active { background: var(--ui-accent-soft); color: #15563f; }
.cw-result-heading { padding-bottom: 17px; border-color: #e2e8ed; }
.cw-result-heading h3 { font-size: 17px; color: var(--ui-ink); }
.cw-result-heading > span { font-size: 12px; color: #516275; background: #f2f5f7; border-color: #dce3e8; white-space: normal; text-align: right; }
.cw-result-heading > span[data-state="ready"] { color: #12563f; background: #eaf4ee; }
.cw-result-heading > span[data-state="pending"] { color: #7c5619; background: #fff6e5; }
.cw-result-heading > span[data-state="error"] { color: #a32222; background: #fff0ed; }
.cw-output { border-color: #e2e8ed; padding: 19px 0; }
.cw-output > span { font-size: var(--ui-label); color: var(--ui-muted); }
.cw-output strong { font-size: 25px; color: var(--ui-ink); font-weight: 600; letter-spacing: -.4px; }
.cw-output small { font-size: var(--ui-label); color: #526173; }
.cw-output-main { text-align: left; padding: 22px 0; }
.cw-output-main strong { font-size: 38px; color: #153e30; letter-spacing: -.7px; overflow-wrap: anywhere; }
.cw-output-main > div { justify-content: flex-start; gap: 10px; }
.cw-copy-button { background: var(--ui-accent); color: #fff; min-height: 44px; font-size: var(--ui-label); }
.cw-copy-button:disabled { color: #627085; background: #e8edf1; opacity: 1; }
.cw-result-error { color: #9f2424; background: #fff1f0; font-size: var(--ui-small); line-height: 1.8; }
.cw-work-footer { margin-top: 18px; color: var(--ui-muted); font-size: 12px; line-height: 1.8; }
.cw-check-row, .cw-check-row summary, .cw-selected-prep p, .cw-prep-item p, .cw-rounded-table { font-size: var(--ui-reading); }
.cw-check-row summary > small { font-size: 12px; }
.cw-check-row p, .cw-check-row dd, .cw-check-row dt { font-size: var(--ui-small); line-height: 1.8; }
.cw-checkbox { font-size: var(--ui-label); line-height: 1.8; }
.cw-checkbox input[type="checkbox"] { width: 19px; height: 19px; accent-color: var(--ui-accent); }
.cw-noise-table th, .cw-rounded-table th { font-size: var(--ui-label); color: #465367; }
.cw-noise-table th, .cw-noise-table td { min-width: 105px; }
.cw-noise-table th:first-child, .cw-noise-table td:first-child { min-width: 150px; }
.cw-noise-actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 16px; }

/* Paste is an explicit preview/confirm workflow, never a silent overwrite. */
.ui-paste-dialog { width: min(760px, calc(100vw - 32px)); max-height: 88dvh; padding: 25px; border: 1px solid var(--ui-border); border-radius: 10px; color: var(--ui-ink); }
.ui-paste-dialog::backdrop { background: #15212b66; }
.ui-paste-dialog h2 { font-size: 21px; }
.ui-paste-dialog p, .ui-paste-dialog label { font-size: var(--ui-reading); line-height: 1.8; }
.ui-paste-dialog textarea { width: 100%; min-height: 155px; resize: vertical; border: 1px solid #b8c3cf; border-radius: 5px; padding: 12px; font-size: var(--ui-input); color: var(--ui-ink); }
.ui-paste-preview { max-height: 260px; overflow: auto; margin: 15px 0; }
.ui-paste-preview table { width: 100%; border-collapse: collapse; font-size: var(--ui-label); }
.ui-paste-preview th, .ui-paste-preview td { border: 1px solid #dce3e9; padding: 10px; text-align: left; overflow-wrap: anywhere; }
.ui-paste-preview th { background: #f2f5f8; }
.ui-paste-errors { color: #a32222; font-size: var(--ui-small); line-height: 1.8; }
.ui-paste-actions { display: flex; gap: 10px; justify-content: flex-end; flex-wrap: wrap; margin-top: 16px; }
.ui-paste-mode { display: flex; gap: 18px; margin-top: 14px; flex-wrap: wrap; }
.ui-paste-mode label { font-size: var(--ui-label); }

/* Watermark settings share the reading system; photo pixels/fonts are untouched. */
.wm-settings, .wm-photo-panel { color: var(--ui-ink); }
.wm-settings .panel h3, .wm-photo-panel .panel h3 { font-size: var(--ui-label); color: #334155; font-weight: 650; }
.wm-settings .field label { font-size: var(--ui-label); color: #465367; }
.wm-settings .field input, .wm-settings .field select { font-size: var(--ui-input); color: var(--ui-ink); min-height: 44px; background: #fff; border-color: #b8c3cf; }
.wm-settings .tpl-name { font-size: var(--ui-label); color: #334155; }
.wm-settings .tpl-desc, .wm-settings .hint, .wm-settings .row-val { font-size: 12px; color: var(--ui-muted); line-height: 1.8; }
.wm-settings .tpl-desc { white-space: normal; }
.wm-options { border: 1px solid var(--ui-border); border-radius: 7px; margin: 0 0 14px; background: #fff; }
.wm-options > summary { padding: 14px; min-height: 46px; font-size: var(--ui-label); color: #34465a; cursor: pointer; line-height: 1.7; }
.wm-options > .panel { border: 0; margin: 0; border-top: 1px solid var(--ui-border); }
.wm-options > .panel > h3 { display: none; }
.wm-settings .metadata-confirm { font-size: var(--ui-small); line-height: 1.85; padding: 12px; border: 1px solid var(--ui-border); border-radius: 6px; background: #f7f9fb; }
.wm-settings .btn-primary { background: var(--ui-accent); color: #fff; min-height: 46px; font-size: var(--ui-label); }
.wm-photo-panel #photoStatus, .wm-photo-panel .upload-box { color: var(--ui-muted); font-size: var(--ui-small); line-height: 1.85; }
.wm-photo-panel .upload-box span { color: var(--ui-muted) !important; font-size: 12px !important; }
.wm-preview { background: #edf1f4; border-color: #cbd5df; }
.watermark-toolbar { font-size: var(--ui-label); color: #465367; }
#watermarkFrame { height: 1040px; }

/* Dialogs remain readable without depending on page zoom. */
.auth-dialog, .account-dialog, .selection-dialog { color: var(--ui-ink); }
.auth-dialog p, .account-dialog p, .selection-dialog p, .selection-item p { font-size: var(--ui-reading); line-height: 1.85; }
.auth-dialog label { font-size: var(--ui-label); }
.auth-dialog input { font-size: var(--ui-input); min-height: 46px; }
.muted { color: var(--ui-muted); }

@media (min-width: 1700px) {
  .cw-work-grid { grid-template-columns: minmax(0,1fr) 380px; }
  .manual-grid { grid-template-columns: 156px 240px minmax(0,1fr); }
}
@media (max-width: 1200px) {
  :root { --sidebar: 168px; }
  .shell main { padding: 22px 22px 0; }
  .cw-work-grid { grid-template-columns: minmax(0,1fr) 300px; gap: 18px; }
  .cw-form-panel, .cw-result-panel { padding: 20px; }
  .manual-grid { grid-template-columns: 122px 185px minmax(0,1fr); }
  .category-button { font-size: 13px; }
  .detail-content { padding: 20px; }
}
@media (max-width: 980px) {
  :root { --sidebar: 76px; }
  .cw-work-grid { grid-template-columns: minmax(0,1fr) 280px; }
  .cw-fields { grid-template-columns: minmax(0,1fr); gap: 18px; }
  .cw-tool-heading { align-items: flex-start; }
  .top-actions { gap: 10px; }
  .ui-text-size button { min-height: 36px; padding: 5px 9px; }
}
@media (max-width: 740px) {
  .button, .button.small, .ui-text-size button, .pdf-button, .detail-tab, .cw-text-button, .cw-quick button, .account-button { min-height: 44px; }
  .cw-sign { flex-basis: 44px; }
  .cw-noise-table button[data-noise-remove] { min-height: 44px; min-width: 44px; }
  .shell main { padding: 20px 14px 0; }
  .topbar { padding: 0 14px; height: 60px; }
  .breadcrumb { display: none; }
  .top-actions { width: 100%; justify-content: space-between; }
  .ui-text-size button { min-height: 44px; }
  .page-heading { margin-bottom: 18px; }
  .page-heading p { font-size: var(--ui-reading); }
  .heading-actions { gap: 8px; }
  .heading-actions .button { font-size: 13px; padding: 9px 12px; }
  .cw-tool-nav { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 5px; padding: 5px; margin-bottom: 20px; }
  .cw-tool-nav > button { font-size: var(--ui-label); min-height: 44px; padding: 10px 7px; }
  .cw-tool-heading { display: block; }
  .cw-tool-heading .button { margin-top: 12px; }
  .cw-work-grid { grid-template-columns: minmax(0,1fr); }
  .cw-fields { grid-template-columns: minmax(0,1fr); }
  .cw-form-panel, .cw-result-panel { padding: 18px; }
  .cw-result-panel { position: static; max-height: none; }
  .cw-field label { display: flex; font-size: var(--ui-label); }
  .cw-output-main strong { font-size: 36px; }
  .manual-grid { grid-template-columns: minmax(0,1fr); height: auto; }
  .factor-pane { height: 220px; }
  .factor-name { font-size: var(--ui-reading); }
  .category-button { font-size: 14px; min-height: 44px; }
  .detail-content { padding: 20px 14px; }
  .standard-info .info-row { grid-template-columns: minmax(0,1fr); }
  .info-row dt { padding: 9px 12px; }
  .info-row dd { padding: 12px; }
  .manual-toolbar { padding: 12px; }
  .data-caption { font-size: var(--ui-small); }
  .detail-header { flex-wrap: wrap; gap: 12px; }
  .ui-paste-dialog { padding: 18px; }
  .workspace-footer { margin: 22px 14px 0; }
}
@media (max-width: 420px) {
  :root { --sidebar: 60px; }
  .sidebar { padding-left: 4px; padding-right: 4px; }
  .brand { padding-left: 5px; }
  .nav-item { min-height: 46px; }
  .shell main { padding-left: 12px; padding-right: 12px; }
  .heading-actions { flex-wrap: wrap; }
  .account-button { padding: 6px; }
}
@media print {
  .ui-text-size, .ui-paste-dialog { display: none !important; }
  .cw-tool-nav { display: none !important; }
  .cw-work-grid { display: block; }
  .cw-result-panel { position: static; max-height: none; border-top: 1px solid #777; }
  .shell main { padding: 0; }
}
