@font-face {
  font-family: Outfit;
  src: url("../fonts/Outfit-Latin-500-800.woff2") format("woff2");
  font-weight: 500 800;
  font-style: normal;
  font-display: swap;
}

:root {
  --primary: #111111;
  --secondary: #FFF4CC;
  --ink: #111111;
  --ink-2: #111111;
  --muted: rgba(17, 17, 17, 0.55);
  --teal: #111111;
  --teal-deep: #000000;
  --teal-soft: rgba(17, 17, 17, 0.08);
  --line: rgba(17, 17, 17, 0.12);
  --card: transparent;
  --paper: #ffffff;
  --sidebar: #0fc6b4;
  --surface: #ffffff;
  --danger: #d92d20;
  --radius: 12px;
  --shadow: none;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body { height: 100%; }

body {
  font-family: "Microsoft YaHei UI", "Microsoft YaHei", Outfit, sans-serif;
  color: var(--ink);
  background: var(--paper);
}

button, input, select {
  font: inherit;
  color: inherit;
  color-scheme: light;
}

option {
  background: #fff;
  color: var(--ink);
}

.app-shell {
  display: grid;
  grid-template-columns: 240px 1fr;
  min-height: 100vh;
  background: transparent;
}

/* 侧栏青绿底白字；未选项贴底，只有选中项浮起突起 */
.sidebar {
  background: var(--sidebar);
  color: #fff;
  display: flex;
  flex-direction: column;
  padding: 20px 14px 16px;
  border-right: 1px solid rgba(255, 255, 255, 0.22);
}

.side-brand {
  display: block;
  padding: 8px 10px 16px;
  text-decoration: none;
  color: inherit;
  border-bottom: 1px solid rgba(255, 255, 255, 0.28);
  margin-bottom: 10px;
}

.side-brand-copy {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.side-brand-copy strong {
  font-family: Outfit, sans-serif;
  font-size: 22px;
  font-weight: 800;
  color: #fff;
  letter-spacing: 0.2px;
  line-height: 1.15;
}

.side-nav {
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex: 1;
}

.side-link {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px 12px;
  border-radius: 12px;
  text-decoration: none;
  color: #fff;
  background: transparent;
  box-shadow: none;
  transition: background 0.15s ease, box-shadow 0.15s ease, transform 0.15s ease;
}

.side-link:hover {
  background: rgba(255, 255, 255, 0.18);
  color: #fff;
}

.side-link.is-on {
  background: #0fc6b4;
  color: #fff;
  box-shadow: 0 12px 28px rgba(42, 53, 63, 0.16);
  transform: translateY(-2px);
}

.side-link svg,
.side-link .nav-ico {
  width: 28px;
  height: 28px;
  flex-shrink: 0;
  display: block;
  color: inherit;
}

.side-link .nav-ico {
  object-fit: contain;
}

.side-link.is-on svg {
  color: #fff;
}

.side-link b {
  display: block;
  font-size: 16px;
  font-weight: 800;
  line-height: 1.2;
}

.side-foot {
  display: flex;
  justify-content: space-between;
  padding: 12px 10px 4px;
  font-size: 11px;
  color: rgba(255, 255, 255, 0.78);
  border-top: 1px solid rgba(255, 255, 255, 0.28);
  margin-top: 12px;
}

/* —— 工作区顶栏 —— */
.workspace {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 100vh;
  background: #ffffff;
}

.chrome-sticky {
  position: -webkit-sticky;
  position: sticky;
  top: 0;
  z-index: 34;
  background: #fff;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  padding: 14px 24px;
  background: #ffffff;
  border: 1px solid var(--line);
  color: var(--ink);
}

.topbar h1 {
  font-size: 32px;
  font-weight: 800;
  letter-spacing: 0.2px;
  line-height: 1.15;
}

.top-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.action-group {
  display: flex;
  align-items: center;
  gap: 6px;
  padding-right: 10px;
  margin-right: 2px;
  border-right: 1px solid var(--line);
}

.action-group:last-of-type {
  border-right: 0;
  padding-right: 0;
}

.tpl-picker {
  position: relative;
  display: flex;
  align-items: center;
  gap: 8px;
}

.tpl-trigger {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 248px;
  max-width: 320px;
  height: 44px;
  padding: 0 12px 0 14px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: transparent;
  cursor: pointer;
  text-align: left;
  box-shadow: none;
  color: var(--ink);
}

.tpl-trigger:hover { border-color: rgba(17, 17, 17, 0.32); }

.tpl-picker.is-open .tpl-trigger {
  border-color: rgba(17, 17, 17, 0.4);
  box-shadow: 0 0 0 3px rgba(17, 17, 17, 0.08);
}

.tpl-trigger-copy {
  display: flex;
  flex-direction: column;
  gap: 1px;
  min-width: 0;
  flex: 1;
}

.tpl-trigger-copy strong {
  font-size: 16px;
  font-weight: 700;
  line-height: 1.2;
  color: var(--ink);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tpl-trigger-copy small {
  font-size: 10px;
  font-weight: 400;
  line-height: 1.2;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tpl-caret {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  display: grid;
  place-items: center;
  color: inherit;
}

.tpl-caret svg {
  width: 16px;
  height: 16px;
  display: block;
  transition: transform 0.15s ease;
}

.tpl-picker.is-open .tpl-caret svg {
  transform: rotate(180deg);
}

.tpl-menu {
  position: absolute;
  top: calc(100% + 8px);
  left: 36px;
  width: 320px;
  max-height: min(420px, 70vh);
  overflow: auto;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: 0 16px 40px rgba(17, 17, 17, 0.12);
  padding: 6px;
  z-index: 35;
  color: var(--ink);
}

.tpl-menu[hidden] { display: none; }

.tpl-empty {
  padding: 18px 14px;
  font-size: 13px;
  color: var(--muted);
}

.tpl-option {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 10px 10px;
  border: 0;
  border-radius: 9px;
  background: transparent;
  cursor: pointer;
  text-align: left;
  color: var(--ink);
}

.tpl-option:hover { background: rgba(17, 17, 17, 0.05); }

.tpl-option.is-on {
  background: rgba(255, 244, 204, 0.9);
}

/* 模板选项左侧：标准小勾选框 */
.tpl-shape {
  width: 14px;
  height: 14px;
  border-radius: 3px;
  border: 1.5px solid rgba(17, 17, 17, 0.45);
  background: #fff;
  flex-shrink: 0;
  display: grid;
  place-items: center;
}

.tpl-option.is-on .tpl-shape {
  border-color: #0fc6b4;
  background: #0fc6b4;
}

.tpl-option.is-on .tpl-shape::after {
  content: "√";
  color: #fff;
  font-size: 11px;
  font-weight: 800;
  line-height: 1;
}

.tpl-option-copy { min-width: 0; flex: 1; }

.tpl-option-copy strong {
  display: block;
  font-size: 13px;
  font-weight: 800;
  color: var(--ink);
}

.tpl-option-copy small {
  display: block;
  margin-top: 3px;
  font-size: 11px;
  color: var(--muted);
  line-height: 1.45;
}

.field-mini {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--ink);
  background: transparent;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 10px;
  height: 36px;
}

.field-mini span { white-space: nowrap; }

.field-mini input {
  width: 64px;
  border: 0;
  background: transparent;
  font-family: Outfit, sans-serif;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--ink);
}

.select-wrap select {
  border: 0;
  background: transparent;
  min-width: 132px;
  max-width: 200px;
  font-weight: 700;
  outline: none;
  color: var(--ink);
}

.btn {
  height: 36px;
  padding: 0 14px;
  border-radius: 8px;
  border: 1px solid transparent;
  cursor: pointer;
  font-size: 13px;
  font-weight: 700;
  transition: background 0.12s ease, border-color 0.12s ease, color 0.12s ease;
}

.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn.is-busy:disabled { cursor: wait; opacity: 0.7; }

.btn:focus-visible,
.tpl-trigger:focus-visible,
.date-trigger:focus-visible,
.side-link:focus-visible,
.bottom-link:focus-visible,
.mobile-stage-btn:focus-visible,
.cal-nav:focus-visible,
.ori-btn:focus-visible {
  outline: 2px solid var(--ink);
  outline-offset: 2px;
}

.btn-primary {
  background: var(--ink);
  color: #fff;
}

.btn-primary:hover { background: #000; color: #fff; }

.btn-ghost {
  background: transparent;
  border-color: var(--line);
  color: var(--ink);
}

.btn-ghost:hover { border-color: rgba(17, 17, 17, 0.35); background: rgba(17, 17, 17, 0.04); }

/* 顶栏按钮异色，一眼能分开 */
.topbar .tpl-trigger {
  background: #e7f8f5;
  border-color: #8fd4cb;
  color: #145c54;
}
.topbar .tpl-trigger:hover {
  background: #d4f3ee;
  border-color: #0fc6b4;
}
.topbar .tpl-picker.is-open .tpl-trigger {
  border-color: #0fc6b4;
  box-shadow: 0 0 0 3px rgba(15, 198, 180, 0.22);
}
.topbar .tpl-trigger-copy strong {
  color: #145c54;
}
.topbar .tpl-trigger-copy small {
  color: rgba(20, 92, 84, 0.58);
}

.topbar #btnTplNew {
  background: #e8f1ff;
  border-color: #9dbef0;
  color: #1a4a8a;
}
.topbar #btnTplNew:hover {
  background: #d6e6ff;
  border-color: #5b8fd9;
}

.topbar #btnTplEdit {
  background: #f3e8ff;
  border-color: #c9a8e8;
  color: #5b2d91;
}
.topbar #btnTplEdit:hover {
  background: #ead6ff;
  border-color: #b07ad9;
}

.topbar #btnTplDel {
  background: #fdeeee;
  border-color: #efb4b4;
  color: #9b1c1c;
}
.topbar #btnTplDel:hover {
  background: #f8dede;
  border-color: #e07a7a;
}

.topbar .date-trigger {
  background: #fff6e5;
  border-color: #ecc98a;
  color: #7a4e00;
}
.topbar .date-trigger:hover {
  background: #ffefd1;
  border-color: #e0b45c;
}
.topbar #dateLabel {
  color: inherit;
}

.topbar #btnPng,
.topbar .btn-primary {
  background: #0fc6b4;
  border-color: #0fc6b4;
  color: #083832;
}
.topbar #btnPng:hover,
.topbar .btn-primary:hover {
  background: #0db3a3;
  border-color: #0db3a3;
  color: #062e2a;
}

.icon-btn, .danger-btn {
  border: 0;
  background: transparent;
  cursor: pointer;
  font-size: 12px;
  font-weight: 700;
  color: var(--muted);
  padding: 2px 6px;
  border-radius: 6px;
}

.icon-btn:hover, .danger-btn:hover { color: var(--danger); background: rgba(217, 45, 32, 0.1); }

/* —— 内容区 —— */
.layout {
  display: grid;
  grid-template-columns: minmax(400px, 0.92fr) minmax(460px, 1.08fr);
  gap: 16px;
  padding: 16px 20px 24px;
  flex: 1;
  align-items: stretch;
  background: transparent;
}

.layout-single { grid-template-columns: 1fr; }

.panel {
  background: transparent;
  border-radius: var(--radius);
  padding: 18px 18px 16px;
  box-shadow: none;
  border: 1px solid var(--line);
  color: var(--ink);
}

/* 编辑区 / 预览区不要整块卡片：内容直接铺在工作区上 */
.edit-panel,
.preview-panel {
  background: transparent;
  border: 0;
  border-radius: 0;
  box-shadow: none;
  padding: 4px 0 0;
}

.layout .btn-primary,
.modal .btn-primary {
  background: var(--ink);
  color: #fff;
}

.layout .btn-primary:hover,
.modal .btn-primary:hover {
  background: #000;
}

.section-head {
  margin-bottom: 14px;
}

.section-head.tight { margin-top: 22px; padding-top: 18px; border-top: 1px solid var(--line); }

.section-head h2 {
  font-size: 15px;
  font-weight: 800;
}

.drop {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  min-height: 148px;
  padding: 22px 20px;
  border: 3px dashed rgba(15, 198, 180, 0.88);
  border-radius: 14px;
  background:
    radial-gradient(ellipse 90% 80% at 50% -10%, rgba(15, 198, 180, 0.1), transparent 58%),
    linear-gradient(180deg, #fcfefd 0%, #f6faf9 100%);
  cursor: pointer;
  text-align: center;
  transition: border-color 0.18s ease, background 0.18s ease, box-shadow 0.18s ease;
}
.drop:hover {
  border-style: solid;
  border-color: #0fc6b4;
  background:
    radial-gradient(ellipse 90% 80% at 50% -10%, rgba(15, 198, 180, 0.14), transparent 60%),
    #f3fbf9;
  box-shadow: 0 10px 28px rgba(15, 198, 180, 0.1);
}
.drop.drag {
  border-style: solid;
  border-color: #0fc6b4;
  background: #e8f8f5;
  box-shadow:
    inset 0 0 0 1px rgba(15, 198, 180, 0.45),
    0 12px 30px rgba(15, 198, 180, 0.14);
}
.drop.has-file {
  border-style: solid;
  border-color: rgba(15, 198, 180, 0.55);
  background: #f7fcfb;
}

.drop input,
.file-input { display: none; }

.drop-visual {
  width: 52px;
  height: 52px;
  border-radius: 14px;
  display: grid;
  place-items: center;
  background: rgba(15, 198, 180, 0.12);
  color: #0b8f82;
  box-shadow: inset 0 0 0 1px rgba(15, 198, 180, 0.12);
  font-size: 28px;
  font-weight: 300;
  line-height: 1;
}
.drop.has-file .drop-visual {
  background: rgba(15, 198, 180, 0.18);
  color: #08756b;
}

.drop-copy {
  display: flex;
  flex-direction: column;
  max-width: 380px;
}
.drop strong {
  font-size: 15px;
  font-weight: 800;
  letter-spacing: 0.2px;
  color: var(--ink);
  word-break: break-all;
}

.upload-actions {
  display: none;
  gap: 8px;
  margin-top: 10px;
}

.upload-actions .btn {
  flex: 1;
  min-height: 44px;
}

.ios-save-sheet .ios-save-tip {
  font-size: 13px;
  line-height: 1.55;
  color: var(--muted);
  margin-bottom: 12px;
}

.ios-save-preview {
  border: 1px solid var(--line);
  border-radius: 10px;
  overflow: auto;
  max-height: min(48dvh, 420px);
  background: rgba(17, 17, 17, 0.03);
  -webkit-overflow-scrolling: touch;
}

.ios-save-preview img {
  display: block;
  width: 100%;
  height: auto;
  -webkit-touch-callout: default;
  pointer-events: auto;
  user-select: none;
}

.ios-save-actions {
  flex-wrap: wrap;
}

.ios-save-actions .btn,
.ios-save-actions a.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
}

.row-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 12px 0 0;
  flex-wrap: wrap;
}

.hint { color: var(--muted); font-size: 12px; }

.table-toolbar {
  display: flex;
  gap: 8px;
  margin: 18px 0 10px;
}

.table-wrap {
  overflow: auto;
  max-height: 46vh;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  overscroll-behavior: contain;
}

#grid {
  width: 100%;
  min-width: 640px;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 12px;
}

#grid thead {
  position: sticky;
  top: 0;
  z-index: 3;
}

#grid th {
  position: sticky;
  top: 0;
  z-index: 3;
  background: var(--sidebar);
  color: #fff;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.4px;
  text-align: left;
  padding: 11px 10px;
  white-space: nowrap;
  border-bottom: 1px solid rgba(255, 255, 255, 0.28);
  border-right: 1px solid rgba(255, 255, 255, 0.22);
  box-shadow: 0 1px 0 var(--sidebar);
}

#grid th:last-child,
#grid td:last-child {
  border-right: 0;
}

#grid td {
  padding: 0;
  background: #fff;
  border-bottom: 1px solid var(--line);
  border-right: 1px solid var(--line);
  vertical-align: middle;
}

#grid tbody tr:nth-child(even) td {
  background: #fafafa;
}

#grid tbody tr:hover td {
  background: #fff9e0;
}

#grid td:nth-child(n+2):not(.row-op) input {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

#grid input {
  width: 100%;
  min-width: 76px;
  border: 0;
  background: transparent;
  padding: 10px 10px;
  font-family: Outfit, "Microsoft YaHei UI", sans-serif;
  color: var(--ink);
}

#grid input:focus {
  outline: none;
  background: rgba(255, 244, 204, 0.7);
}

#grid input.cell-bad {
  background: rgba(217, 45, 32, 0.12);
}

/* 盈利列跟海报预览同一套：正 #0fc6b4，负 #e40014 */
#grid input.pos {
  color: #0fc6b4;
  font-weight: 800;
}
#grid input.neg {
  color: #e40014;
  font-weight: 800;
}

#grid td.row-op {
  width: 56px;
  text-align: center;
  padding: 4px;
  background: #fff;
}

.audit {
  margin-top: 12px;
  padding: 10px 12px;
  border-radius: 10px;
  font-size: 12px;
  max-height: 160px;
  overflow: auto;
  background: transparent;
  border: 1px solid var(--line);
}

.audit.ok { background: transparent; border-color: var(--ink); color: var(--ink); }
.audit.bad { background: transparent; border-color: var(--danger); color: var(--danger); }
.audit p { margin: 0 0 4px; }

.preview-panel {
  overflow: visible;
  min-height: 100%;
  border-left: 1px solid var(--line);
  padding-left: 20px;
}

.preview-frame {
  position: relative;
  background: transparent;
  border-radius: 0;
  padding: 0;
  overflow: hidden;
  border: 0;
}

.preview-empty {
  position: absolute;
  inset: 0;
  z-index: 2;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  text-align: center;
  padding: 24px;
  background: transparent;
  border-radius: 0;
}

.preview-empty[hidden] { display: none; }

.preview-empty p {
  font-size: 15px;
  font-weight: 800;
}

.preview-empty span {
  font-size: 12px;
  color: var(--muted);
}

#posterFrame {
  width: 1080px;
  height: 1100px;
  border: 0;
  display: block;
  background: transparent;
  border-radius: 6px;
}

/* 预览图下方的分享文案；复制图标叠在文案框右上角，不再套标题栏 */
.caption-box {
  position: relative;
  display: grid;
  grid-template-columns: 1fr;
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
}

.caption-text {
  margin: 0;
  padding: 12px 40px 12px 14px;
  border: 3px dashed rgba(15, 198, 180, 0.88);
  border-radius: 14px;
  background: #fff;
  font-size: 13px;
  line-height: 1.6;
  white-space: pre-wrap;
  word-break: break-word;
  user-select: text;
  color: var(--ink);
  grid-row: 1;
}

.caption-copy {
  grid-row: 1;
  justify-self: end;
  align-self: start;
  z-index: 1;
  width: 32px;
  height: 32px;
  margin: 6px 6px 0 0;
  padding: 0;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  display: grid;
  place-items: center;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}

.caption-copy svg {
  width: 18px;
  height: 18px;
  display: block;
}

.caption-copy:hover {
  color: var(--ink);
  background: rgba(17, 17, 17, 0.06);
}

.coming {
  min-height: calc(100vh - 140px);
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: center;
  padding: 48px;
}

.coming-mark {
  width: 48px;
  height: 48px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  background: var(--secondary);
  color: var(--ink);
  font-family: Outfit, sans-serif;
  font-weight: 800;
  margin-bottom: 16px;
}

.coming h2 { font-size: 22px; margin-bottom: 8px; }

.coming-note {
  color: var(--muted);
  font-size: 14px;
  line-height: 1.7;
  max-width: 420px;
}

.coming-go {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-top: 20px;
  text-decoration: none;
}

.modal {
  position: fixed;
  inset: 0;
  background: rgba(17, 17, 17, 0.28);
  display: grid;
  place-items: center;
  z-index: 40;
}

.modal[hidden] { display: none; }

.modal-card {
  width: min(440px, calc(100vw - 32px));
  max-height: min(90vh, 860px);
  overflow: auto;
  background: #fff;
  color: var(--ink);
  border-radius: 14px;
  padding: 22px 22px 18px;
  box-shadow: 0 18px 50px rgba(17, 17, 17, 0.12);
  border: 1px solid var(--line);
}

.modal-kicker {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.8px;
  color: var(--muted);
  margin-bottom: 4px;
}

.modal-card h2 { font-size: 18px; margin-bottom: 16px; }

.field-block {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 10px;
}

.field-block input[type="text"] {
  height: 38px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 10px;
  background: transparent;
  color: var(--ink);
}

.field-block input[type="file"] { font-size: 12px; }

.tpl-file-hint {
  font-size: 11px;
  color: var(--muted);
}

.field-note {
  font-size: 11px;
  color: var(--muted);
}

.field-block textarea {
  min-height: 120px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 10px;
  background: transparent;
  color: var(--ink);
  font-size: 12px;
  line-height: 1.5;
  resize: vertical;
  font-family: inherit;
}

.field-block select {
  height: 38px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 10px;
  background: transparent;
  color: var(--ink);
}

.ori-seg {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
}

.ori-btn {
  height: 36px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: transparent;
  cursor: pointer;
  font-size: 13px;
  font-weight: 700;
  color: var(--ink);
}

.ori-btn:hover { border-color: rgba(17, 17, 17, 0.4); }

.ori-btn.is-on {
  background: var(--ink);
  border-color: var(--ink);
  color: #fff;
}

.date-picker { position: relative; }

.date-trigger {
  min-width: 140px;
  height: 36px;
  padding: 0 12px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: transparent;
  color: var(--ink);
  cursor: pointer;
  text-align: left;
  display: flex;
  align-items: center;
}

.date-trigger:hover { border-color: rgba(17, 17, 17, 0.35); }

#dateLabel {
  font-family: Outfit, sans-serif;
  font-weight: 800;
  font-size: 13px;
  letter-spacing: 0.5px;
}

.cal-pop {
  position: absolute;
  right: 0;
  top: calc(100% + 8px);
  width: 292px;
  background: #fff;
  color: var(--ink);
  border-radius: 12px;
  box-shadow: 0 16px 40px rgba(17, 17, 17, 0.12);
  border: 1px solid var(--line);
  padding: 12px;
  z-index: 30;
}

.cal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}

.cal-head strong {
  font-family: Outfit, sans-serif;
  font-size: 13px;
  font-weight: 800;
}

.cal-nav {
  width: 32px;
  height: 32px;
  border: 0;
  background: transparent;
  color: var(--ink);
  border-radius: 8px;
  cursor: pointer;
  font-size: 18px;
  line-height: 1;
}

.cal-nav:hover { background: var(--teal-soft); color: var(--ink); }

.cal-week {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  text-align: center;
  font-size: 11px;
  color: var(--muted);
  margin-bottom: 4px;
}

.cal-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 2px;
}

.cal-grid button {
  height: 34px;
  border: 0;
  background: transparent;
  border-radius: 8px;
  cursor: pointer;
  font-family: Outfit, sans-serif;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  color: var(--ink);
}

.cal-grid button:hover { background: var(--secondary); color: var(--ink); }
.cal-grid button.muted { color: rgba(17, 17, 17, 0.28); }
.cal-grid button.today { box-shadow: inset 0 0 0 1px var(--ink); }
.cal-grid button.selected {
  background: var(--ink);
  color: #fff;
}
.cal-today { width: 100%; margin-top: 8px; height: 34px; }

.bottom-nav { display: none; }
.mobile-stage { display: none; }

@media (max-width: 1100px) {
  .layout { grid-template-columns: 1fr; }
  .preview-panel {
    max-height: none;
    border-left: 0;
    padding-left: 0;
  }
}

@media (max-width: 860px) {
  html, body {
    overflow-x: hidden;
    overflow-x: clip;
    max-width: 100%;
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
    overscroll-behavior-y: contain;
    overflow-anchor: none;
    background: #fff;
  }

  button, a, input, select, label {
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
  }

  input, select, textarea, #grid input {
    font-size: 16px;
  }

  .app-shell {
    display: block;
    min-height: 100svh;
  }
  .sidebar { display: none; }
  .workspace {
    min-height: 100svh;
    max-width: 100%;
    overflow-x: visible;
    padding-bottom: calc(64px + env(safe-area-inset-bottom, 0px));
  }

  .chrome-sticky {
    position: -webkit-sticky;
    position: sticky;
    top: 0;
    z-index: 34;
    background: #fff;
    box-shadow: 0 1px 0 var(--line);
  }

  .topbar {
    display: grid;
    grid-template-columns: 1fr 1fr;
    grid-template-areas:
      "head png"
      "picker new"
      "edit del"
      "date date";
    align-items: stretch;
    gap: 8px;
    padding: max(10px, env(safe-area-inset-top)) 12px 12px;
    width: 100%;
    min-width: 0;
  }

  .page-head {
    grid-area: head;
    min-width: 0;
    display: flex;
    align-items: center;
  }
  .topbar h1 {
    font-size: 24px;
    line-height: 1.2;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .top-actions,
  .action-group {
    display: contents;
  }

  .tpl-picker {
    grid-area: picker;
    min-width: 0;
    width: 100%;
    display: block;
  }

  .tpl-picker .tpl-trigger-copy small { display: none; }

  .tpl-trigger,
  .date-trigger,
  #btnTplNew,
  #btnTplEdit,
  #btnTplDel {
    width: 100%;
    min-width: 0;
    height: 44px;
    box-sizing: border-box;
  }

  .tpl-trigger {
    max-width: none;
    justify-content: space-between;
  }

  .tpl-menu {
    position: fixed;
    left: 12px;
    right: 12px;
    top: auto;
    width: auto;
    max-width: none;
    max-height: min(360px, 50svh);
  }

  #btnTplNew { grid-area: new; }
  #btnTplEdit { grid-area: edit; }
  #btnTplDel { grid-area: del; }
  #btnPng {
    grid-area: png;
    width: 100%;
    white-space: nowrap;
    height: 44px;
    min-height: 44px;
    padding: 0 12px;
  }

  .date-picker {
    grid-area: date;
    min-width: 0;
    width: 100%;
  }

  .date-trigger {
    justify-content: center;
  }

  .topbar .btn-ghost {
    height: 44px;
    padding: 0 10px;
    font-size: 13px;
  }

  .cal-pop {
    position: fixed;
    left: 12px;
    right: 12px;
    top: max(72px, env(safe-area-inset-top));
    width: auto;
    z-index: 36;
  }

  .mobile-stage {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 6px;
    padding: 8px 12px 10px;
    background: #fff;
    border-bottom: 1px solid var(--line);
  }

  .mobile-stage-btn {
    height: 40px;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: transparent;
    color: var(--ink);
    font-size: 14px;
    font-weight: 800;
    cursor: pointer;
  }

  .mobile-stage-btn.is-on {
    background: var(--ink);
    border-color: var(--ink);
    color: #fff;
  }
  .mobile-stage-btn:active {
    opacity: 0.82;
  }

  .layout {
    display: block;
    width: 100%;
    min-width: 0;
    padding: 10px 12px 16px;
  }

  .layout[data-stage="edit"] .preview-panel { display: none; }
  .layout[data-stage="preview"] .edit-panel { display: none; }

  .panel {
    min-width: 0;
    max-width: 100%;
    padding: 14px 12px 12px;
  }

  .edit-panel,
  .preview-panel {
    padding: 0;
    border: 0;
    border-radius: 0;
  }

  .preview-panel {
    border-left: 0;
    padding-left: 0;
  }

  .drop {
    min-height: 118px;
    padding: 16px 12px;
    gap: 8px;
  }
  .drop-visual {
    width: 44px;
    height: 44px;
    border-radius: 12px;
    font-size: 24px;
  }
  .drop strong { font-size: 14px; }
  .upload-actions {
    display: flex;
  }
  .row-actions { gap: 8px; }
  .row-actions .btn { min-height: 44px; }

  .table-wrap {
    overflow: hidden;
    max-height: min(52svh, 480px);
    max-width: 100%;
    display: flex;
    flex-direction: column;
    overscroll-behavior: contain;
  }

  #grid {
    display: block;
    width: 100%;
    min-width: 0;
    height: 100%;
  }
  #grid thead {
    display: block;
    flex: 0 0 auto;
    position: relative;
    top: auto;
    z-index: 4;
    background: var(--sidebar);
  }
  #grid thead tr {
    display: table;
    width: 100%;
    table-layout: fixed;
  }
  #grid th {
    position: static;
    white-space: normal;
    line-height: 1.25;
    font-size: 10px;
    padding: 10px 6px;
  }
  #grid tbody {
    display: block;
    overflow-y: auto;
    overflow-x: hidden;
    flex: 1 1 auto;
    max-height: calc(min(52svh, 480px) - 46px);
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
    touch-action: pan-y;
  }
  #grid tbody tr {
    display: table;
    width: 100%;
    table-layout: fixed;
  }
  #grid thead th,
  #grid tbody td {
    width: 22%;
  }
  #grid thead th:last-child,
  #grid tbody td.row-op {
    width: 48px;
  }
  #grid input {
    min-width: 0;
    padding: 12px 6px;
  }

  #grid td.row-op { width: 48px; }
  .icon-btn, .danger-btn { padding: 8px; font-size: 14px; }

  .preview-panel {
    max-height: none;
    overflow: visible;
  }

  .preview-frame {
    padding: 0;
    max-width: 100%;
    width: 100%;
    overflow: hidden;
    border: 0;
    border-radius: 0;
    contain: layout;
  }
  .preview-frame.is-fitting {
    opacity: 0;
  }

  .coming {
    min-height: calc(100svh - 180px);
    padding: 28px 20px;
  }

  .modal {
    align-items: end;
    justify-items: stretch;
    padding: 0;
    background: rgba(17, 17, 17, 0.28);
  }

  .modal-card {
    width: 100%;
    max-height: min(92dvh, 100%);
    overflow: auto;
    border-radius: 16px 16px 0 0;
    padding: 18px 16px calc(18px + env(safe-area-inset-bottom));
    -webkit-overflow-scrolling: touch;
  }

  .ori-btn { height: 44px; }
  .field-block input[type="text"],
  .field-block select,
  #uiDialogInput { height: 44px; }

  .bottom-nav {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 28;
    background: var(--sidebar);
    padding: 6px 8px calc(8px + env(safe-area-inset-bottom, 0px));
    transform: translateZ(0);
    -webkit-user-select: none;
    user-select: none;
  }
  .bottom-link {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    text-decoration: none;
    color: rgba(255, 255, 255, 0.78);
    min-height: 48px;
    padding: 6px 4px;
    border-radius: 12px;
    background: transparent;
    box-shadow: none;
  }
  .bottom-link b { font-size: 12px; font-weight: 700; }
  .bottom-link svg,
  .bottom-link .nav-ico {
    width: 22px;
    height: 22px;
    display: block;
    color: inherit;
  }
  .bottom-link .nav-ico {
    object-fit: contain;
  }
  .bottom-link.is-on {
    color: #fff;
    background: #0fc6b4;
    box-shadow: 0 8px 18px rgba(42, 53, 63, 0.14);
  }
  .bottom-link.is-on svg {
    color: #fff;
  }

  body.modal-open {
    position: fixed;
    width: 100%;
    left: 0;
    right: 0;
    overflow: hidden;
  }

  .ios-save-preview {
    max-height: min(48svh, 420px);
  }
}

body.modal-open {
  overflow: hidden;
}

.mode-wash .top-actions,
.mode-monthly .top-actions {
  display: none;
}

.pop-backdrop {
  position: fixed;
  inset: 0;
  z-index: 32;
  background: rgba(17, 17, 17, 0.28);
}

.pop-backdrop[hidden] { display: none; }

.toast-host {
  position: fixed;
  left: 50%;
  bottom: 28px;
  transform: translateX(-50%);
  z-index: 50;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  pointer-events: none;
  width: min(420px, calc(100vw - 24px));
}

.toast {
  pointer-events: none;
  width: 100%;
  padding: 12px 14px;
  border-radius: 10px;
  background: #111;
  color: #fff;
  font-size: 13px;
  font-weight: 700;
  line-height: 1.45;
  box-shadow: 0 10px 28px rgba(17, 17, 17, 0.2);
  animation: toast-in 0.18s ease;
}

.toast-ok { background: #111; }
.toast-bad { background: #d92d20; }
.toast.is-out { opacity: 0; transform: translateY(6px); transition: opacity 0.22s ease, transform 0.22s ease; }

@keyframes toast-in {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

.ui-dialog-card #uiDialogInput {
  width: 100%;
  height: 40px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 10px;
  margin: 8px 0 4px;
  background: #fff;
}

@media (min-width: 861px) {
  .preview-dock {
    position: sticky;
    top: 88px;
    max-height: calc(100vh - 88px);
    overflow: auto;
  }
}

@media (max-width: 860px) {
  .toast-host {
    bottom: calc(72px + env(safe-area-inset-bottom, 0px));
  }
  .caption-text {
    padding-right: 56px;
  }
  .caption-copy {
    width: 44px;
    height: 44px;
  }
  .caption-copy svg {
    width: 20px;
    height: 20px;
  }
}

/* 触摸屏不要留下 :hover 粘滞高亮 */
@media (hover: none) {
  .btn-primary:hover { background: var(--ink); color: #fff; }
  .btn-ghost:hover { background: transparent; border-color: var(--line); }
  .tpl-trigger:hover { border-color: var(--line); }
  .tpl-option:hover { background: transparent; }
  .topbar .tpl-trigger:hover {
    background: #e7f8f5;
    border-color: #8fd4cb;
  }
  .topbar #btnTplNew:hover {
    background: #e8f1ff;
    border-color: #9dbef0;
  }
  .topbar #btnTplEdit:hover {
    background: #f3e8ff;
    border-color: #c9a8e8;
  }
  .topbar #btnTplDel:hover {
    background: #fdeeee;
    border-color: #efb4b4;
  }
  .topbar .date-trigger:hover {
    background: #fff6e5;
    border-color: #ecc98a;
  }
  .topbar #btnPng:hover,
  .topbar .btn-primary:hover {
    background: #0fc6b4;
    border-color: #0fc6b4;
    color: #083832;
  }
  .icon-btn:hover, .danger-btn:hover {
    color: var(--muted);
    background: transparent;
  }
  .caption-copy:hover {
    color: var(--muted);
    background: transparent;
  }
  .side-link:hover {
    background: transparent;
    color: #fff;
    box-shadow: none;
    transform: none;
  }
  .side-link.is-on:hover {
    background: #0fc6b4;
    color: #fff;
    box-shadow: 0 12px 28px rgba(42, 53, 63, 0.16);
    transform: translateY(-2px);
  }
  #grid tbody tr:hover td {
    background: #fff;
  }
  #grid tbody tr:nth-child(even):hover td {
    background: #fafafa;
  }
  .layout .btn-primary:hover,
  .modal .btn-primary:hover {
    background: var(--ink);
    color: #fff;
  }
  .drop:hover {
    border-style: dashed;
    border-color: rgba(15, 198, 180, 0.88);
    background:
      radial-gradient(ellipse 90% 80% at 50% -10%, rgba(15, 198, 180, 0.1), transparent 58%),
      linear-gradient(180deg, #fcfefd 0%, #f6faf9 100%);
    box-shadow: none;
  }
  .drop.drag, .drop.has-file {
    border-style: solid;
    border-color: #0fc6b4;
    background: #e8f8f5;
  }
  #grid tbody tr:hover td { background: #fff; }
  #grid tbody tr:nth-child(even):hover td { background: #fafafa; }
  .ori-btn:hover { border-color: var(--line); }
  .date-trigger:hover { border-color: var(--line); }
  .cal-nav:hover { background: transparent; color: var(--ink); }
  .cal-grid button:hover { background: transparent; color: var(--ink); }
  .cal-grid button.selected:hover { background: var(--ink); color: #fff; }
}
