/* ==========================================================================
   纪检部 · EX表便捷APP —— 掌上工作台（方案 C）
   结构：紧凑顶栏 + 大标题 + 编辑器卡片 + 工具入口卡片
   说明：只改视觉与布局，模块脚本、必需 id、脚本顺序与动画时序不变。
   ========================================================================== */

:root {
  --bg: #EEF2F6;
  --surface: #FFFFFF;
  --ink: #1B2430;
  --muted: #677482;
  --steel: #2E4A66;
  --steel-deep: #223850;
  --steel-soft: #E4EBF2;
  --teal: #2F6F63;
  --teal-deep: #24574E;
  --teal-soft: #E3F0EC;
  --seal: #C0442F;
  --line: #DCE3EA;
  --input-bg: #F7F9FB;
  --seg-bg: #EDF1F5;
  --placeholder: #A7B2BE;
  --hint: #93A0AD;
  --shadow: 0 12px 28px rgba(30, 50, 70, .08);
  --font-ui: "HarmonyOS Sans SC", "PingFang SC", "Microsoft YaHei UI", "Microsoft YaHei", system-ui, -apple-system, sans-serif;
  --weekly-dark-surface:
    radial-gradient(circle at 100% 0, rgba(93, 143, 190, .28), transparent 55%),
    linear-gradient(150deg, #142331 0%, #0C141B 76%);
  --weekly-light-surface:
    radial-gradient(circle at 100% 0, rgba(46, 74, 102, .10), transparent 55%),
    linear-gradient(150deg, #F7FAFD 0%, #EAF0F6 76%);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; min-height: 100%; }
body {
  font-family: var(--font-ui);
  color: var(--ink);
  background: #DCE3EA;
  -webkit-font-smoothing: antialiased;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}
button, textarea, input { font: inherit; }
button { cursor: pointer; }
button:focus-visible, textarea:focus-visible, input:focus-visible {
  outline: 3px solid rgba(46, 74, 102, .22);
  outline-offset: 2px;
}

/* ===== 画布 ===== */
.app {
  width: 100%;
  max-width: 460px;
  min-height: 100vh;
  margin: 0 auto;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-ui);
  position: relative;
  overflow: hidden;
}

/* ===== 顶栏 ===== */
.topbar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: calc(18px + env(safe-area-inset-top)) 18px 8px;
}
.app-mark {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: var(--steel);
  color: #fff;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: .04em;
  display: grid;
  place-items: center;
  position: relative;
  flex: 0 0 auto;
  box-shadow: 0 6px 14px rgba(46, 74, 102, .24);
}
.app-mark::after {
  content: "";
  position: absolute;
  right: 5px;
  top: 5px;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--seal);
}
.app-name {
  flex: 1;
  min-width: 0;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: .02em;
  color: #33404E;
}
.night-toggle {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, .8);
  color: #51606F;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  transition: color .25s ease, background-color .25s ease, border-color .25s ease, transform .18s ease;
}
.night-toggle:active { transform: scale(.94); }
.night-toggle svg { width: 16px; height: 16px; }
.night-toggle .sun-icon { display: none; }
.night-toggle:disabled { cursor: default; opacity: .78; }

/* ===== 标题区 ===== */
.hero { padding: 10px 20px 18px; }
.hero h1 {
  margin: 0;
  font-size: clamp(26px, 7.6vw, 32px);
  line-height: 1.24;
  font-weight: 800;
  letter-spacing: -.01em;
  color: var(--ink);
}
.hero-sub {
  display: flex;
  align-items: center;
  gap: 7px;
  margin: 10px 0 0;
  font-size: 11.5px;
  color: var(--muted);
}
.status-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #3E9B77;
  flex: 0 0 auto;
}

main { padding: 0 16px; }

/* ===== 卡片 ===== */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 15px;
  box-shadow: var(--shadow);
  transform-origin: top center;
  transition: border-color .45s ease, box-shadow .45s ease, opacity .45s ease;
}
.card + .card { margin-top: 14px; }
.card.convert-card { margin-top: 30px; }
.optimize-card { overflow: hidden; }
.convert-card { padding: 0; overflow: hidden; }

.card-morph { display: grid; }
.card-section {
  display: grid;
  grid-template-rows: 0fr;
  opacity: 0;
  pointer-events: none;
}
.card-section.is-open {
  grid-template-rows: 1fr;
  opacity: 1;
  pointer-events: auto;
}
.card.mode-animating {
  overflow: hidden;
  will-change: height;
}
.section-inner {
  min-height: 0;
  overflow: hidden;
}
.card-section:not(.is-open) .section-inner {
  visibility: hidden;
}

/* ===== 每日 / 每周分段控件 ===== */
.segmented {
  display: grid;
  grid-template-columns: 1fr 1fr;
  background: var(--seg-bg);
  border-radius: 12px;
  padding: 4px;
  margin-bottom: 13px;
}
.seg-btn {
  height: 34px;
  border: 0;
  border-radius: 9px;
  background: transparent;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
  transition: background-color .2s ease, color .2s ease, box-shadow .2s ease;
}
.seg-btn.is-active {
  background: var(--surface);
  color: var(--steel);
  box-shadow: 0 1px 3px rgba(30, 50, 70, .12);
}
.seg-btn:disabled { cursor: default; opacity: .7; }
.app.convert-mode .segmented { margin-bottom: 0; }

/* ===== 编辑器 ===== */
.editor-fade { transition: opacity 140ms ease; }
.optimize-card.weekly-fade-out .editor-fade { opacity: .24; }

.editor-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 7px;
}
.editor-label {
  font-size: 10.5px;
  letter-spacing: .1em;
  font-weight: 700;
  color: var(--muted);
}
.editor-count { font-size: 10px; color: var(--hint); }

textarea {
  display: block;
  width: 100%;
  height: 158px;
  resize: none;
  border: 0;
  border-radius: 12px;
  background: var(--input-bg);
  padding: 14px;
  font: 15px/1.7 var(--font-ui);
  color: var(--ink);
  outline: none;
  appearance: none;
  -webkit-appearance: none;
  box-shadow: none;
  transition: background-color .2s ease;
}
textarea::placeholder { color: var(--placeholder); }
textarea:focus { box-shadow: none; }

/* 主输入框左右向内缩进 */
#sourceText,
#convertText,
#optimizeOutput {
  width: calc(100% - 16px);
  margin-left: 8px;
  margin-right: 8px;
}

.editor-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 8px;
}
.editor-hint { font-size: 10.5px; color: var(--hint); }
.clear-link {
  border: 0;
  background: none;
  color: var(--steel);
  font-size: 12px;
  font-weight: 700;
  padding: 4px 2px;
}

/* ===== 按钮 ===== */
.btn { font-family: var(--font-ui); border: 0; }
.btn-primary {
  background: var(--steel);
  color: #fff;
  border-radius: 11px;
  font-weight: 700;
  box-shadow: 0 8px 18px rgba(46, 74, 102, .20);
}
.btn-secondary {
  background: var(--steel-soft);
  color: var(--steel);
  border: 1px solid var(--line);
  border-radius: 11px;
  font-weight: 700;
}
.btn-ghost {
  background: transparent;
  color: var(--muted);
  border: 1px solid var(--line);
  border-radius: 11px;
  font-weight: 700;
}
.btn-convert {
  background: var(--teal);
  color: #fff;
  border-radius: 13px;
  font-weight: 700;
  box-shadow: 0 8px 18px rgba(47, 111, 99, .22);
}
.btn:active { transform: scale(.99); }
.btn:disabled { cursor: wait; opacity: .65; }

.cta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  height: 50px;
  margin-top: 11px;
  padding: 0 18px;
  font-size: 15px;
  font-weight: 700;
}
.cta-arrow { font-size: 19px; font-weight: 400; line-height: 1; }

/* ===== 优化结果 ===== */
.optimize-result {
  display: none;
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px dashed var(--line);
}
.optimize-result.open {
  display: block;
  animation: resultIn .28s ease;
}
.result-tabs { display: flex; align-items: center; gap: 6px; margin: 0 0 8px; }
.result-tab {
  border: 0;
  background: none;
  padding: 0;
  color: var(--hint);
  font-size: 12px;
  font-weight: 700;
}
.result-tab.is-active { color: var(--steel); }
.result-tab-sep { color: #C6D0DA; font-size: 12px; }
.result-text { height: 150px; background: var(--input-bg); }
.result-actions {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  margin-top: 8px;
}
.result-actions .btn {
  height: 40px;
  min-height: 40px;
  padding: 0 14px;
  font-size: 12.5px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}
.result-actions .btn svg { width: 15px; height: 15px; }

.compare-pane { margin-top: 2px; }
.compare-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 8px;
  max-height: 420px;
  overflow-y: auto;
  padding-right: 2px;
}
.compare-col { min-width: 0; }
.compare-caption { font-size: 11px; color: var(--muted); margin-bottom: 4px; }
.compare-col canvas {
  display: block;
  width: 100%;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--surface);
  box-shadow: 0 4px 12px rgba(30, 50, 70, .05);
}
@keyframes resultIn {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ===== 收起态 ===== */
.optimize-compact { cursor: pointer; }
.optimize-compact .section-inner { padding: 0; }
.card-desc {
  margin: 8px 0 10px;
  font-size: 12.5px;
  line-height: 1.65;
  color: var(--muted);
}

/* ===== 工具入口（表格转换） ===== */
.tool-entry {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 15px;
  border: 0;
  background: transparent;
  text-align: left;
  color: var(--ink);
}
.tool-icon {
  width: 40px;
  height: 40px;
  border-radius: 11px;
  background: var(--teal-soft);
  color: var(--teal);
  display: grid;
  place-items: center;
  flex: 0 0 auto;
}
.tool-icon svg { width: 20px; height: 20px; }
.tool-text {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 3px;
}
.tool-title { font-size: 13.5px; font-weight: 700; line-height: 1.35; }
.tool-desc { font-size: 10.5px; color: var(--muted); }
.tool-chev { font-size: 22px; color: #9AA7B4; line-height: 1; flex: 0 0 auto; }

/* ===== 转换工作区 ===== */
.convert-workspace .section-inner { padding: 15px; }

.convert-meta { align-items: center; }
.convert-controls {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}
.mini-select {
  height: 42px;
  border: 0;
  border-radius: 13px;
  font-size: 13px;
  font-weight: 700;
  outline: none;
  appearance: none;
  -webkit-appearance: none;
  box-shadow: none;
  cursor: pointer;
  padding: 0 32px 0 14px;
  background-repeat: no-repeat;
  background-position: right 13px center;
  background-size: 14px 14px;
}
.mini-select.period {
  width: 86px;
  color: #fff;
  background-image:
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none'%3E%3Cpath d='m6 9 6 6 6-6' stroke='%23FFFFFF' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E"),
    linear-gradient(135deg, #4FB3AF 0%, #2F8F8B 100%);
  background-position: right 13px center, center;
  background-size: 14px 14px, cover;
  background-repeat: no-repeat, no-repeat;
  box-shadow: 0 8px 16px rgba(63, 158, 154, .24);
}
.period-toggle {
  position: relative;
  display: flex;
  align-items: center;
  width: 92px;
  height: 42px;
  padding: 3px;
  border-radius: 13px;
  background: linear-gradient(135deg, #4FB3AF 0%, #2F8F8B 100%);
  box-shadow: 0 8px 16px rgba(63, 158, 154, .24);
  touch-action: pan-y;
  user-select: none;
  overflow: hidden;
}
.period-thumb {
  position: absolute;
  top: 3px;
  left: 3px;
  width: calc(50% - 3px);
  height: calc(100% - 6px);
  border-radius: 10px;
  background: rgba(255, 255, 255, .92);
  box-shadow: 0 2px 6px rgba(20, 70, 68, .18);
  transition: transform .26s cubic-bezier(.22, .61, .36, 1);
  pointer-events: none;
}
.period-toggle[data-value="下午"] .period-thumb {
  transform: translateX(100%);
}
.period-option {
  position: relative;
  z-index: 1;
  flex: 1;
  height: 100%;
  border: 0;
  background: transparent;
  color: rgba(255, 255, 255, .78);
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  transition: color .2s ease;
  padding: 0;
}
.period-option.is-active {
  color: #1F6F6B;
}
.period-option:focus-visible {
  outline: 2px solid rgba(255, 255, 255, .8);
  outline-offset: -3px;
  border-radius: 9px;
}
.date-pill {
  position: relative;
  display: flex;
  align-items: center;
  min-width: 0;
  height: 42px;
  border: 1px solid var(--line);
  border-radius: 13px;
  background: var(--surface);
  overflow: visible;
}
.date-pill-divider {
  width: 1px;
  height: 20px;
  background: var(--line);
  flex: 0 0 auto;
}
.seg {
  width: auto;
  min-width: 76px;
  white-space: nowrap;
  height: 42px;
  padding: 0 12px;
  justify-content: center;
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
}
.seg.active { background: #DDF0EE; color: #2F8F8B; }
.seg .chev {
  width: 7px;
  height: 7px;
  border-right: 1.5px solid currentColor;
  border-bottom: 1.5px solid currentColor;
  transform: rotate(45deg) translateY(-1px);
  transition: transform .18s ease;
  flex: 0 0 auto;
}
.seg[aria-expanded="true"] .chev {
  transform: rotate(225deg) translateY(-1px);
}
.date-pill > .date-picker:first-child .seg { border-radius: 12px 0 0 12px; }
.date-pill > .date-picker:nth-of-type(2) .seg { border-radius: 0 12px 12px 0; }
.date-picker { position: relative; display: flex; flex: 0 0 auto; }
.mini-select.period:focus { box-shadow: 0 0 0 3px rgba(63, 158, 154, .18); }
.seg:focus-visible { outline: 2px solid rgba(63, 158, 154, .5); outline-offset: -2px; }
.picker-panel {
  position: absolute;
  top: calc(100% + 8px);
  z-index: 30;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: 0 18px 40px rgba(30, 50, 70, .18);
  padding: 11px;
}
.picker-panel[hidden] { display: none; }
.month-panel { left: 0; width: 200px; }
.day-panel { left: 0; right: auto; width: 210px; }
.picker-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 1px 4px 8px;
  font-size: 11px;
  font-weight: 700;
  color: var(--muted);
}
.picker-close {
  border: 0;
  background: transparent;
  color: var(--hint);
  font-size: 16px;
  line-height: 1;
  cursor: pointer;
  padding: 0 2px;
}
.picker-grid { display: grid; gap: 6px; }
.month-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.day-grid { grid-template-columns: repeat(7, minmax(0, 1fr)); }
.picker-opt {
  height: 31px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: var(--input-bg);
  color: var(--ink);
  font-size: 11.5px;
  font-weight: 600;
  cursor: pointer;
  padding: 0 2px;
}
.picker-opt:hover { border-color: var(--line); }
.picker-opt.is-selected {
  background: #3E9E9A;
  color: #fff;
  border-color: #3E9E9A;
}
.workspace-top {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  margin-bottom: 10px;
}

.workspace-tag {
  font-size: 9.5px;
  letter-spacing: .1em;
  color: var(--teal);
  background: var(--teal-soft);
  border-radius: 999px;
  padding: 3px 8px;
  font-weight: 700;
}
.workspace-title {
  margin: 0 0 4px;
  font-size: 16px;
  font-weight: 800;
  line-height: 1.35;
}
.workspace-desc {
  margin: 0 0 10px;
  font-size: 11.5px;
  line-height: 1.5;
  color: var(--muted);
}
.convert-workspace .btn-ghost {
  display: block;
  width: 100%;
  height: 40px;
  margin-top: 8px;
  font-size: 12.5px;
}
.app.convert-mode .convert-card {
  border-color: rgba(47, 111, 99, .35);
  box-shadow: 0 16px 34px rgba(47, 111, 99, .10);
}
.app.convert-mode .optimize-card { opacity: .92; }
.app.convert-mode .convert-card { cursor: pointer; }
.app.convert-mode .convert-card textarea { cursor: text; }

/* ===== 转换结果与表格预览 ===== */
.convert-result {
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}
.convert-result[hidden] { display: none; }
.convert-result:not([hidden]) {
  animation: convertResultReveal .32s cubic-bezier(.22, .61, .36, 1);
}
@keyframes convertResultReveal {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}
.convert-result-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}
.convert-result-heading { min-width: 0; }
.convert-result-kicker {
  display: block;
  margin-bottom: 3px;
  font-size: 9.5px;
  line-height: 1.3;
  letter-spacing: .09em;
  font-weight: 800;
  color: var(--teal);
}
.convert-result-title {
  margin: 0;
  font-size: 13px;
  line-height: 1.45;
  font-weight: 800;
  color: var(--ink);
}
.convert-status-badge {
  flex: 0 0 auto;
  padding: 4px 8px;
  border-radius: 999px;
  background: var(--teal-soft);
  color: var(--teal);
  font-size: 9.5px;
  font-weight: 800;
  white-space: nowrap;
}
.convert-result-summary {
  margin: 8px 0 0;
  font-size: 10.5px;
  line-height: 1.55;
  color: var(--muted);
}
.convert-result-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 11px 0 10px;
}
.convert-download-btn {
  width: auto;
  min-width: 126px;
  height: 40px;
  margin: 0;
  padding: 0 14px;
  gap: 8px;
  justify-content: center;
  font-size: 12px;
}
.convert-download-btn svg { width: 16px; height: 16px; }
.convert-filename {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 9.5px;
  color: var(--hint);
}
.convert-preview-scroll {
  overflow-x: auto;
  overscroll-behavior-inline: contain;
  border: 1px solid #D9E1E8;
  border-radius: 11px;
  background: #fff;
  -webkit-overflow-scrolling: touch;
}
.convert-preview {
  width: 100%;
  min-width: 760px;
  border-collapse: collapse;
  background: #fff;
  color: #1B2430;
  font-family: "Microsoft YaHei UI", "Microsoft YaHei", "PingFang SC", sans-serif;
  font-size: 9.5px;
  line-height: 1.35;
}
.convert-preview th,
.convert-preview td {
  padding: 6px 7px;
  border-right: 1px solid #DCE3EA;
  border-bottom: 1px solid #DCE3EA;
  text-align: center;
  vertical-align: middle;
  white-space: nowrap;
}
.convert-preview th {
  background: #EEF2F6;
  color: #33404E;
  font-weight: 800;
}
.convert-preview th:first-child,
.convert-preview td:first-child {
  position: sticky;
  left: 0;
  z-index: 1;
  min-width: 82px;
  text-align: left;
  background: #fff;
}
.convert-preview th:first-child { z-index: 2; background: #EEF2F6; }
.convert-preview tbody tr:nth-child(even) td:not(:first-child) { background: #FAFBFC; }
.convert-preview tbody tr:last-child td { border-bottom: 0; }
.convert-preview th:last-child,
.convert-preview td:last-child { border-right: 0; }
.convert-preview .is-critical {
  color: #C00000;
  font-weight: 800;
}
.convert-preview .preview-note td {
  text-align: left;
  white-space: pre-line;
  background: #F6FAF9;
  color: #40515D;
}
.convert-warnings {
  margin-top: 10px;
  padding: 9px 11px;
  border: 1px solid #EAD9C9;
  border-radius: 10px;
  background: #FFF9F2;
  color: #7A5132;
  font-size: 10px;
  line-height: 1.55;
}
.convert-warnings[hidden] { display: none; }
.convert-warnings-title { font-weight: 800; margin-bottom: 3px; }
.convert-warnings ul { margin: 0; padding-left: 16px; }
.app.dark .convert-result { border-top-color: #33424F; }
.app.dark .convert-result-title { color: #E5EDF4; }
.app.dark .convert-status-badge { background: rgba(79, 179, 175, .16); color: #8FD5D1; }
.app.dark .convert-filename { color: #7E8C98; }
.app.dark .convert-preview-scroll { border-color: #44515C; }
.app.dark .convert-warnings {
  border-color: rgba(218, 167, 105, .34);
  background: rgba(120, 76, 33, .2);
  color: #F0C99A;
}
@media (prefers-reduced-motion: reduce) {
  .convert-result:not([hidden]) { animation: none; }
}

/* ===== 底部保密提示 ===== */
.footnote {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  margin: 16px 0 26px;
  font-size: 10px;
  color: #94A1AE;
}
.footnote svg { width: 12px; height: 12px; }

/* ===== Toast ===== */
.toast {
  position: fixed;
  z-index: 20;
  left: 50%;
  bottom: calc(24px + env(safe-area-inset-bottom));
  transform: translate(-50%, 20px);
  max-width: calc(100vw - 48px);
  padding: 11px 16px;
  border-radius: 999px;
  color: #F6FAFD;
  background: rgba(27, 36, 48, .94);
  box-shadow: 0 12px 28px rgba(15, 23, 42, .22);
  font-size: 12.5px;
  line-height: 1.4;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity .22s ease, transform .22s ease;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ===== 每周模块（日间为深色） ===== */
.optimize-card.is-weekly {
  --surface: #142331;
  --ink: #EEF4F9;
  --muted: #9FB0BF;
  --line: #2A3B49;
  --input-bg: #0F1A24;
  --seg-bg: #0F1A24;
  --placeholder: #6E8497;
  --hint: #8FA3B5;
  --steel: #8AB6DD;
  --steel-deep: #6E9FC8;
  --steel-soft: #1C3141;
  background: var(--weekly-dark-surface);
  border-color: rgba(138, 182, 221, .24);
  box-shadow: 0 16px 34px rgba(6, 12, 18, .28);
}
.optimize-card.is-weekly .seg-btn.is-active {
  background: var(--steel);
  color: #0C141B;
}
.optimize-card.is-weekly .cta.btn-primary {
  background: #4E7FA8;
  color: #FFFFFF;
}

/* ===== 深夜模式 ===== */
body.dark { background: #0B1117; }
.app.dark {
  --bg: #0E141B;
  --surface: #17202A;
  --ink: #E8EEF4;
  --muted: #93A3B3;
  --steel: #5B87B0;
  --steel-deep: #3E6488;
  --steel-soft: #1E2B37;
  --teal: #6FBFAE;
  --teal-deep: #4E9C8A;
  --teal-soft: #1A2C28;
  --line: #27323D;
  --input-bg: #111A23;
  --seg-bg: #111A23;
  --placeholder: #6E7C8A;
  --hint: #7C8B99;
  --shadow: 0 14px 32px rgba(0, 0, 0, .24);
  background: var(--bg);
}
.app.dark .app-name { color: #C9D6E2; }
.app.dark .night-toggle {
  background: rgba(23, 32, 42, .8);
  color: #F4C95D;
  border-color: #2A3641;
}
.app.dark .night-toggle .moon-icon { display: none; }
.app.dark .night-toggle .sun-icon { display: block; }
.app.dark textarea:focus { box-shadow: none; }
.app.dark .toast {
  background: rgba(36, 46, 58, .9);
  border: 1px solid rgba(255, 255, 255, .07);
  backdrop-filter: blur(12px);
}
.app.dark .dict-fab { box-shadow: 0 8px 18px rgba(0, 0, 0, .3); }

/* ===== 深夜模式下的每周模块：反相浅色 ===== */
.app.dark .optimize-card.is-weekly {
  --surface: #F7FAFD;
  --ink: #1B2430;
  --muted: #677482;
  --line: #DCE3EA;
  --input-bg: #FFFFFF;
  --seg-bg: #E7EDF3;
  --placeholder: #A7B2BE;
  --hint: #93A0AD;
  --steel: #2E4A66;
  --steel-deep: #223850;
  --steel-soft: #E4EBF2;
  background: var(--weekly-light-surface);
  border-color: rgba(46, 74, 102, .24);
  box-shadow: 0 16px 34px rgba(0, 0, 0, .28);
}
.app.dark .optimize-card.is-weekly .seg-btn.is-active {
  background: #FFFFFF;
  color: var(--steel);
}
.app.dark .optimize-card.is-weekly .cta.btn-primary {
  background: var(--steel);
  color: #FFFFFF;
}

/* ===== 背景与主题过渡（只模糊背景和卡片） ===== */
.app-bg {
  position: absolute;
  inset: 0;
  z-index: 0;
  overflow: hidden;
  pointer-events: none;
  background:
    radial-gradient(circle at 88% 6%, rgba(46, 74, 102, .08), transparent 30%),
    linear-gradient(180deg, #F7FAFD 0 200px, var(--bg) 200px 100%);
}
.app.dark .app-bg {
  background:
    radial-gradient(circle at 88% 6%, rgba(91, 135, 176, .14), transparent 32%),
    linear-gradient(180deg, #111A23 0 200px, #0E141B 200px 100%);
}
.app-content {
  position: relative;
  z-index: 1;
  min-height: 100vh;
}
.theme-bg-wash {
  position: absolute;
  inset: -90px;
  opacity: 0;
  filter: blur(34px);
  transform: scale(1.04);
  transition:
    opacity 420ms ease,
    filter 760ms cubic-bezier(.22, .61, .36, 1);
  will-change: opacity, filter;
}
.theme-bg-wash.to-dark {
  background:
    radial-gradient(circle at 88% 8%, rgba(91, 135, 176, .18), transparent 34%),
    linear-gradient(180deg, #111A23 0 170px, #0E141B 100%);
}
.theme-bg-wash.to-light {
  background:
    radial-gradient(circle at 88% 8%, rgba(46, 74, 102, .10), transparent 32%),
    linear-gradient(180deg, #F7FAFD 0 170px, #EEF2F6 100%);
}
.theme-bg-wash.active { opacity: 1; filter: blur(14px); }
.app.theme-switching .card {
  animation: moduleThemeBlur 880ms cubic-bezier(.32, 0, .2, 1) both;
  will-change: filter, transform;
}
.app.theme-switching .convert-card { animation-delay: 60ms; }
@keyframes moduleThemeBlur {
  0% { filter: blur(0); transform: translateY(0) scale(1); }
  44% { filter: blur(6.5px); transform: translateY(2px) scale(.997); }
  100% { filter: blur(0); transform: translateY(0) scale(1); }
}
.app.theme-switching .card,
.app.theme-switching .btn,
.app.theme-switching textarea,
.app.theme-switching .seg-btn,
.app.theme-switching .night-toggle,
.app.theme-switching .tool-icon {
  transition: none !important;
}

/* ===== 响应式 ===== */
@media (min-width: 600px) {
  body { padding: 28px 0; }
  .app { min-height: 860px; border-radius: 30px; box-shadow: 0 28px 70px rgba(20, 35, 50, .22); }
  .toast { bottom: 40px; }
}
@media (max-width: 365px) {
  main { padding-left: 12px; padding-right: 12px; }
  .hero { padding-left: 16px; padding-right: 16px; }
  .card { padding: 13px; }
  .tool-entry { padding: 13px; }
  .convert-workspace .section-inner { padding: 13px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    scroll-behavior: auto !important;
    transition-duration: 1ms !important;
    animation-duration: 1ms !important;
  }
}

/* ===== 原因词库浮窗 ===== */
.dict-fab {
  position: fixed;
  right: 16px;
  bottom: calc(18px + env(safe-area-inset-bottom));
  z-index: 30;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 0;
  background: var(--steel);
  color: #fff;
  box-shadow: 0 8px 18px rgba(46, 74, 102, .28);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform .18s ease, opacity .2s ease;
}
.dict-fab svg { width: 20px; height: 20px; }
.dict-fab:active { transform: scale(.94); }
.dict-fab.is-hidden { display: none; }

.dict-modal {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: none;
  justify-content: center;
  align-items: flex-start;
  padding: calc(76px + env(safe-area-inset-top)) 16px 16px;
  pointer-events: none;
}
.dict-modal.open { display: flex; }
.dict-modal-card {
  position: relative;
  width: 100%;
  max-width: 360px;
  max-height: 62vh;
  overflow-y: auto;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 16px;
  box-shadow: 0 20px 48px rgba(20, 35, 50, .26);
  pointer-events: auto;
  animation: dictModalIn .2s ease;
}
@keyframes dictModalIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}
.dict-modal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.dict-modal-title { margin: 0; font-size: 17px; font-weight: 750; color: var(--ink); }
.dict-close {
  flex: 0 0 auto;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: var(--seg-bg);
  color: var(--muted);
  font-size: 18px;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}
.dict-close:hover { background: var(--steel-soft); color: var(--steel); }
.dict-modal-desc { margin: 0 0 10px; font-size: 12px; line-height: 1.6; color: var(--muted); }

.dict-admin { margin-bottom: 10px; }
.dict-admin-input { display: grid; grid-template-columns: minmax(0, 1fr) 64px; gap: 8px; }
.dict-password-wrap { position: relative; min-width: 0; }
#dictAdminPassword {
  width: 100%;
  height: 38px;
  padding: 0 36px 0 10px;
  border-radius: 9px;
  border: 1px solid var(--line);
  background: var(--input-bg);
  color: var(--ink);
  font-size: 13px;
}
.dict-eye-btn {
  position: absolute;
  right: 5px;
  top: 50%;
  transform: translateY(-50%);
  width: 26px;
  height: 26px;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--hint);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}
.dict-eye-btn:hover { color: var(--steel); }
.dict-eye-btn svg { width: 17px; height: 17px; }
#dictAdminPassword:focus { outline: none; box-shadow: 0 0 0 3px rgba(46, 74, 102, .12); }
.dict-admin-confirm {
  height: 38px;
  border-radius: 9px;
  border: 1px solid var(--line);
  background: var(--steel-soft);
  color: var(--steel);
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
}
.dict-admin-confirm:hover { filter: brightness(.98); }
.dict-admin-active {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border-radius: 9px;
  background: var(--teal-soft);
  border: 1px solid rgba(47, 111, 99, .28);
  color: var(--teal);
  font-size: 12px;
}
.dict-admin-active[hidden] { display: none; }
.dict-admin-badge { font-weight: 700; }
.dict-admin-hint { color: var(--teal); }
.dict-admin-exit {
  margin-left: auto;
  padding: 3px 9px;
  border-radius: 7px;
  border: 1px solid rgba(47, 111, 99, .3);
  background: var(--surface);
  color: var(--teal);
  font-size: 12px;
  cursor: pointer;
}
.dict-admin-exit:hover { background: var(--teal-soft); }
.dict-status-text {
  margin: 7px 0 0;
  font-size: 11px;
  line-height: 1.5;
  color: var(--hint);
}

.dict-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.dict-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 8px 4px 10px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--seg-bg);
  color: var(--muted);
  font-size: 13px;
}
.dict-chip.is-pending {
  border-color: rgba(47, 111, 99, .35);
  background: var(--teal-soft);
  color: var(--teal);
  font-weight: 600;
}
.dict-chip-lock { font-size: 11px; opacity: .55; margin-left: 2px; }
.dict-chip-countdown {
  font-size: 11px;
  color: var(--teal);
  background: rgba(47, 111, 99, .10);
  border-radius: 999px;
  padding: 1px 6px;
}
.dict-chip-x {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 0;
  background: var(--teal);
  color: #fff;
  font-size: 14px;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  cursor: pointer;
}
.dict-chip-x:hover { background: var(--teal-deep); }

.dict-add-row { display: grid; grid-template-columns: minmax(0, 1fr) 72px; gap: 8px; margin-top: 12px; }
#dictNewWord {
  width: 100%;
  height: 44px;
  padding: 0 12px;
  border-radius: 11px;
  border: 1px solid var(--line);
  background: var(--input-bg);
  color: var(--ink);
  font-size: 14px;
}
#dictNewWord:focus { outline: none; box-shadow: 0 0 0 3px rgba(46, 74, 102, .12); }
.dict-add-btn { min-height: 44px; height: 44px; border-radius: 9px; font-size: 14px; }

/* ===== 账号授权门禁 ===== */
.app.license-locked .app-content {
  filter: blur(10px);
  pointer-events: none;
  user-select: none;
}
.app.license-locked { overflow: hidden; }

.boot-overlay {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: grid;
  place-items: center;
  background: linear-gradient(160deg, #223850 0%, #0F1720 100%);
  color: #F4EFE3;
  transition: opacity .55s ease, filter .55s ease;
}
.boot-overlay.boot-exit {
  opacity: 0;
  filter: blur(14px);
  pointer-events: none;
}
.boot-inner { text-align: center; }
.boot-mark {
  width: 64px;
  height: 64px;
  margin: 0 auto 16px;
  border-radius: 16px;
  background: #2E4A66;
  border: 1px solid rgba(79, 179, 175, .55);
  color: #fff;
  font-size: 20px;
  font-weight: 800;
  display: grid;
  place-items: center;
  box-shadow: 0 12px 30px rgba(0, 0, 0, .3);
}
.boot-name { margin: 0; font-size: 16px; font-weight: 700; letter-spacing: .04em; }
.boot-status { margin: 10px 0 14px; font-size: 12px; color: #9FB8AE; }
.boot-bar {
  width: 160px;
  height: 3px;
  margin: 0 auto;
  border-radius: 999px;
  background: rgba(244, 239, 227, .15);
  overflow: hidden;
}
.boot-bar span {
  display: block;
  width: 40%;
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, #4FB3AF, #2F8F8B);
  animation: bootBar 1.1s ease-in-out infinite;
}
@keyframes bootBar {
  0% { transform: translateX(-100%); }
  100% { transform: translateX(350%); }
}

.license-modal {
  position: fixed;
  inset: 0;
  z-index: 1100;
  display: none;
  background: rgba(238, 242, 246, .72);
  backdrop-filter: blur(18px);
}
.license-modal.open { display: block; }

.license-card {
  width: 100%;
  max-width: 460px;
  min-height: 100vh;
  min-height: 100dvh;
  margin: 0 auto;
  padding: 32px 24px calc(32px + env(safe-area-inset-bottom));
  background:
    radial-gradient(circle at 88% 4%, rgba(63, 158, 154, .12), transparent 30%),
    linear-gradient(180deg, #F7FAFD 0%, #EEF2F6 100%);
  color: #1B2430;
  text-align: center;
  box-shadow: 0 0 0 1px rgba(46, 74, 102, .06);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}
.license-card::before {
  content: "纪检部 · EX表便捷APP";
  display: block;
  width: 100%;
  max-width: 360px;
  margin-bottom: 26px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: .08em;
  color: #2E4A66;
}
.license-card > * {
  width: 100%;
  max-width: 360px;
}
.license-icon {
  width: 64px;
  height: 64px;
  margin: 0 auto 14px;
  border-radius: 18px;
  background: #E4EBF2;
  display: grid;
  place-items: center;
  font-size: 28px;
}
.license-card h2 { margin: 0 0 8px; font-size: 24px; }
.license-desc { margin: 0 0 18px; font-size: 13px; line-height: 1.7; color: #677482; }
.license-input {
  width: 100%;
  height: 52px;
  padding: 0 14px;
  border-radius: 14px;
  border: 1px solid #DCE3EA;
  background: #FFFDF8;
  color: #1B2430;
  font-size: 16px;
  font-weight: 700;
  letter-spacing: .06em;
  text-align: center;
  outline: none;
  -webkit-appearance: none;
  appearance: none;
}
.license-input:focus { border-color: #2E4A66; box-shadow: 0 0 0 3px rgba(46, 74, 102, .14); }
.license-error { margin: 8px 0 0; font-size: 12px; line-height: 1.5; color: #C0442F; }
.license-submit {
  width: 100%;
  height: 52px;
  margin-top: 16px;
  border: 0;
  border-radius: 14px;
  background: #2E4A66;
  color: #fff;
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 10px 22px rgba(46, 74, 102, .24);
}
.license-submit:active { transform: scale(.99); }
.license-note { margin: 14px 0 0; font-size: 11px; line-height: 1.6; color: #98A2B3; }

@media (prefers-reduced-motion: reduce) {
  .boot-bar span { animation-duration: 1ms; }
}
