:root {
  --bg: #f3f4f8;
  --card: #ffffff;
  --text: #1f2330;
  --muted: #7a8194;
  --primary: #6c8cff;
  --primary-dark: #4f6ee0;
  --danger: #ff5d6c;
  --success: #3ecf8e;
  --border: #e6e8ef;
  --shadow: 0 4px 16px rgba(20, 30, 60, 0.08);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", sans-serif;
  color: var(--text);
  background: var(--bg);
  min-height: 100vh;
}

.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 24px;
  background: var(--card);
  border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 18px; }
.brand-logo { font-size: 22px; }

.tabs { display: flex; gap: 8px; }
.tab {
  border: none; background: transparent; cursor: pointer;
  padding: 8px 16px; border-radius: 999px; font-size: 14px; color: var(--muted);
  transition: all .2s;
}
.tab:hover { background: #eef1f9; color: var(--text); }
.tab.active { background: var(--primary); color: #fff; }

.page { max-width: 1100px; margin: 0 auto; padding: 24px; }
.page.hidden { display: none; }

.page-head {
  display: flex; align-items: flex-end; justify-content: space-between; margin-bottom: 20px;
}
.page-head h1 { margin: 0 0 4px; font-size: 24px; }
.subtitle { color: var(--muted); font-size: 13px; margin: 0; }

.btn {
  border: none; border-radius: 8px; padding: 8px 14px; font-size: 14px;
  cursor: pointer; transition: all .15s; font-weight: 500;
}
.btn.primary { background: var(--primary); color: #fff; }
.btn.primary:hover { background: var(--primary-dark); }
.btn.ghost { background: #eef1f9; color: var(--text); }
.btn.ghost:hover { background: #dfe4f3; }
.btn.danger { background: var(--danger); color: #fff; }
.btn.small { padding: 6px 10px; font-size: 13px; }

.icon-btn {
  border: none; background: transparent; cursor: pointer;
  font-size: 18px; color: var(--muted);
}
.icon-btn:hover { color: var(--text); }

/* 项目卡片 */
.project-grid {
  display: grid; gap: 16px;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
}
.project-card {
  background: var(--card); border-radius: 14px; padding: 18px; cursor: pointer;
  box-shadow: var(--shadow); position: relative; overflow: hidden;
  transition: transform .2s, box-shadow .2s;
}
.project-card:hover { transform: translateY(-2px); box-shadow: 0 8px 24px rgba(20,30,60,0.12); }
.project-card .accent {
  position: absolute; left: 0; top: 0; bottom: 0; width: 4px;
}
.project-card .pc-head {
  display: flex; align-items: center; gap: 10px; margin-bottom: 10px;
}
.project-card .pc-icon {
  width: 38px; height: 38px; border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-size: 20px; background: #eef1f9;
}
.project-card .pc-name { font-size: 16px; font-weight: 600; }
.project-card .pc-meta { font-size: 12px; color: var(--muted); }
.project-card .pc-desc {
  font-size: 13px; color: var(--muted);
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
  min-height: 34px; margin: 4px 0 12px;
}
.project-card .pc-stats {
  display: flex; gap: 12px; flex-wrap: wrap; font-size: 12px; color: var(--muted);
}
.project-card .pc-stat strong { color: var(--text); font-size: 15px; margin-right: 4px; }
.project-card .pc-tags { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 8px; }
.tag {
  font-size: 11px; padding: 2px 8px; border-radius: 999px;
  background: #eef1f9; color: var(--muted);
}

/* 统计 */
.summary-cards {
  display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); margin-bottom: 18px;
}
.summary-card {
  background: var(--card); border-radius: 12px; padding: 16px; box-shadow: var(--shadow);
}
.summary-card .label { font-size: 12px; color: var(--muted); }
.summary-card .value { font-size: 26px; font-weight: 700; margin-top: 6px; }

.stats-grid {
  display: grid; gap: 16px; grid-template-columns: 1fr 1fr; margin-bottom: 18px;
}
@media (max-width: 800px) { .stats-grid { grid-template-columns: 1fr; } }

.stats-card {
  background: var(--card); border-radius: 12px; padding: 16px; box-shadow: var(--shadow);
  margin-bottom: 16px;
}
.stats-card h3 { margin: 0 0 12px; font-size: 15px; }

.bar-chart { display: flex; flex-direction: column; gap: 8px; }
.bar-row { display: grid; grid-template-columns: 90px 1fr 40px; gap: 8px; align-items: center; font-size: 13px; }
.bar-row .bar-bg {
  background: #eef1f9; height: 10px; border-radius: 6px; overflow: hidden;
}
.bar-row .bar-fg {
  height: 100%; background: var(--primary); border-radius: 6px;
}

.reminder-list { display: flex; flex-direction: column; gap: 8px; }
.reminder-item {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px; background: #fafbff; border-radius: 10px;
  border-left: 3px solid var(--primary);
}
.reminder-item.done { opacity: .55; border-left-color: var(--success); }
.reminder-item .ri-time { margin-left: auto; font-weight: 600; color: var(--primary); }
.reminder-item.done .ri-time { color: var(--success); }
.reminder-item.idle { border-left-color: var(--muted); }
.reminder-empty { color: var(--muted); font-size: 13px; padding: 8px; }

.project-stats { display: grid; gap: 10px; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
.ps-item { padding: 14px; border: 1px solid var(--border); border-radius: 10px; }
.ps-item h4 { margin: 0 0 6px; font-size: 14px; }
.ps-item .ps-row { font-size: 12px; color: var(--muted); display: flex; justify-content: space-between; margin: 2px 0; }
.ps-item .ps-row b { color: var(--text); }
.trend { display: flex; gap: 3px; align-items: end; height: 32px; margin-top: 6px; }
.trend span {
  flex: 1; background: var(--primary); border-radius: 2px 2px 0 0; min-height: 2px;
  opacity: .8;
}

/* Modal */
.modal {
  position: fixed; inset: 0; background: rgba(20, 25, 50, 0.45);
  display: flex; align-items: center; justify-content: center; z-index: 50; padding: 16px;
}
.modal.hidden { display: none; }
.modal-content {
  background: var(--card); border-radius: 14px; width: 100%; max-width: 540px;
  max-height: 92vh; overflow: auto; box-shadow: 0 20px 60px rgba(0,0,0,0.2);
}
.modal-content.wide { max-width: 880px; }
.modal-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 20px; border-bottom: 1px solid var(--border);
}
.modal-head h2 { margin: 0; font-size: 18px; }
.modal-foot {
  display: flex; justify-content: flex-end; gap: 8px;
  padding: 14px 20px; border-top: 1px solid var(--border); background: #fafbff;
  position: sticky; bottom: 0;
}

.form { padding: 16px 20px; }
.form .row { display: flex; gap: 10px; margin-bottom: 12px; flex-wrap: wrap; }
.form label {
  display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--muted);
  flex: 1 1 140px;
}
.form label.grow { flex: 2 1 220px; }
.form label.inline { flex-direction: row; align-items: center; gap: 6px; color: var(--text); font-size: 13px; }
.form input[type="text"],
.form input[type="number"],
.form input[type="date"],
.form input[type="time"],
.form input:not([type]),
.form textarea,
.form select {
  border: 1px solid var(--border); border-radius: 8px; padding: 8px 10px; font-size: 14px;
  background: #fff; color: var(--text); width: 100%;
}
.form input[type="color"] { padding: 2px; height: 38px; width: 60px; border-radius: 8px; border: 1px solid var(--border); }
.form textarea { min-height: 70px; resize: vertical; }

.reminder-set {
  border: 1px solid var(--border); border-radius: 10px; padding: 10px 14px; margin-bottom: 14px;
}
.reminder-set legend { padding: 0 6px; font-size: 13px; color: var(--muted); }
.weekdays { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-top: 8px; }
.weekdays label { display: inline-flex; align-items: center; gap: 4px; flex: 0; color: var(--text); font-size: 13px; }

.fields-head {
  display: flex; justify-content: space-between; align-items: center; margin: 16px 0 10px;
}
.fields-head h3 { margin: 0; font-size: 15px; }
.add-field { display: flex; gap: 6px; }

.field-list { display: flex; flex-direction: column; gap: 8px; }
.field-item {
  background: #f7f8fc; border-radius: 10px; padding: 10px 12px;
  border: 1px solid var(--border);
}
.field-item .fi-head { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.field-item .fi-type {
  font-size: 11px; padding: 2px 8px; border-radius: 999px;
  background: var(--primary); color: #fff;
}
.field-item input, .field-item select {
  border: 1px solid var(--border); border-radius: 6px; padding: 6px 8px; font-size: 13px;
}
.field-item .fi-row { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 6px; }
.field-item .fi-row label { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; color: var(--muted); }
.field-item .fi-actions { margin-left: auto; display: flex; gap: 4px; }

/* 记录详情 */
.record-layout {
  display: grid; grid-template-columns: 1.2fr 1fr; gap: 0;
  max-height: calc(92vh - 60px);
}
@media (max-width: 720px) { .record-layout { grid-template-columns: 1fr; } }
.record-history {
  border-left: 1px solid var(--border); padding: 16px 20px; overflow: auto;
  background: #fafbff;
}
.record-history h3 { margin: 0 0 10px; font-size: 15px; }
.record-history-list { display: flex; flex-direction: column; gap: 8px; }
.record-item {
  background: #fff; border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px;
  font-size: 13px;
}
.record-item .ri-head {
  display: flex; justify-content: space-between; align-items: center;
  font-size: 12px; color: var(--muted); margin-bottom: 6px;
}
.record-item .ri-row { display: flex; gap: 6px; padding: 2px 0; }
.record-item .ri-row .k { color: var(--muted); min-width: 64px; }
.record-item .ri-row .v { color: var(--text); flex: 1; word-break: break-all; }
.record-item .ri-del {
  border: none; background: transparent; color: var(--danger); cursor: pointer; font-size: 12px;
}

.record-fields { display: flex; flex-direction: column; gap: 12px; }
.rf-item { display: flex; flex-direction: column; gap: 4px; }
.rf-item .rf-label { font-size: 13px; color: var(--muted); }
.rf-item .rf-label .req { color: var(--danger); margin-left: 2px; }
.rf-input { width: 100%; }
.rf-row-toggle { display: flex; align-items: center; gap: 10px; }
.switch {
  position: relative; width: 42px; height: 24px; background: #d2d6e3; border-radius: 999px;
  cursor: pointer; transition: .2s;
}
.switch.on { background: var(--success); }
.switch::after {
  content: ""; position: absolute; left: 2px; top: 2px; width: 20px; height: 20px;
  background: #fff; border-radius: 50%; transition: .2s;
}
.switch.on::after { left: 20px; }

.rating { display: inline-flex; gap: 4px; cursor: pointer; user-select: none; font-size: 22px; color: #d2d6e3; }
.rating .star.on { color: #ffb547; }

/* Toast */
.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%);
  background: #1f2330; color: #fff; padding: 10px 16px; border-radius: 8px;
  font-size: 13px; z-index: 100; box-shadow: 0 8px 20px rgba(0,0,0,0.25);
}
.toast.hidden { display: none; }

.empty {
  background: var(--card); border-radius: 14px; padding: 40px;
  text-align: center; color: var(--muted); box-shadow: var(--shadow);
}
.empty p { margin: 8px 0; }

.hidden { display: none !important; }

/* ====== 视觉升级：桌面端 ====== */
body {
  background:
    radial-gradient(circle at 10% 0%, rgba(108, 140, 255, 0.18), transparent 34vw),
    radial-gradient(circle at 90% 8%, rgba(62, 207, 142, 0.14), transparent 30vw),
    linear-gradient(180deg, #f8f9ff 0%, #eef2f8 100%);
}

.topbar {
  width: min(1180px, calc(100% - 32px));
  margin: 16px auto 0;
  border: 1px solid rgba(230, 232, 239, 0.9);
  border-radius: 20px;
  box-shadow: 0 18px 45px rgba(20, 30, 60, 0.08);
  backdrop-filter: blur(18px);
  background: rgba(255, 255, 255, 0.82);
}

.brand-logo {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border-radius: 13px;
  color: #fff;
  background: linear-gradient(135deg, var(--primary), #9a7cff);
  box-shadow: 0 10px 22px rgba(108, 140, 255, 0.28);
}

.tabs {
  padding: 4px;
  border-radius: 999px;
  background: #f0f3fb;
}

.tab {
  min-width: 112px;
  font-weight: 650;
}

.tab.active {
  color: #fff;
  background: linear-gradient(135deg, var(--primary), #8f7cff);
  box-shadow: 0 10px 22px rgba(108, 140, 255, 0.22);
}

.page {
  max-width: 1180px;
  padding: 30px 24px 44px;
}

.page-head {
  min-height: 116px;
  padding: 24px;
  align-items: center;
  border: 1px solid rgba(255, 255, 255, 0.72);
  border-radius: 28px;
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.88), rgba(255, 255, 255, 0.58)),
    radial-gradient(circle at 85% 20%, rgba(108, 140, 255, 0.16), transparent 260px);
  box-shadow: 0 24px 70px rgba(20, 30, 60, 0.1);
}

.page-head h1 {
  font-size: clamp(28px, 4vw, 42px);
  letter-spacing: -0.06em;
}

.subtitle {
  margin-top: 8px;
  font-size: 14px;
}

.btn {
  min-height: 40px;
  border-radius: 13px;
}

.btn.primary {
  background: linear-gradient(135deg, var(--primary), #8f7cff);
  box-shadow: 0 14px 28px rgba(108, 140, 255, 0.25);
}

.btn.ghost {
  background: rgba(255, 255, 255, 0.74);
  border: 1px solid rgba(230, 232, 239, 0.9);
}

.project-grid {
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
}

.project-card,
.summary-card,
.stats-card,
.ps-item {
  border: 1px solid rgba(255, 255, 255, 0.72);
  box-shadow: 0 18px 45px rgba(20, 30, 60, 0.08);
  background: rgba(255, 255, 255, 0.86);
  backdrop-filter: blur(18px);
}

.project-card {
  min-height: 190px;
  padding: 20px;
  border-radius: 24px;
}

.project-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 26px 65px rgba(20, 30, 60, 0.13);
}

.project-card .accent {
  width: 100%;
  height: 5px;
  bottom: auto;
  border-radius: 999px;
}

.project-card .pc-icon {
  width: 48px;
  height: 48px;
  border-radius: 16px;
  font-size: 24px;
}

.project-card .pc-name {
  font-size: 18px;
  letter-spacing: -0.02em;
}

.pc-stat {
  padding: 6px 10px;
  border-radius: 999px;
  background: #f3f6ff;
}

.tag {
  padding: 5px 10px;
  color: #59627a;
  background: #f1f4fb;
}

.summary-cards {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.summary-card {
  position: relative;
  overflow: hidden;
  min-height: 118px;
  padding: 20px;
  border-radius: 22px;
}

.summary-card::after {
  content: "";
  position: absolute;
  right: -24px;
  top: -24px;
  width: 92px;
  height: 92px;
  border-radius: 999px;
  background: rgba(108, 140, 255, 0.12);
}

.summary-card .value {
  font-size: 34px;
  letter-spacing: -0.04em;
}

.stats-card {
  border-radius: 24px;
  padding: 20px;
}

.stats-card h3 {
  font-size: 17px;
  letter-spacing: -0.02em;
}

.bar-row {
  grid-template-columns: 98px 1fr 44px;
  padding: 8px 0;
}

.bar-row .bar-bg {
  height: 12px;
  background: #edf1fb;
}

.bar-row .bar-fg {
  background: linear-gradient(90deg, var(--primary), #8f7cff);
}

.reminder-item {
  min-height: 62px;
  border: 1px solid #eef1f8;
  border-left: 4px solid var(--primary);
  border-radius: 16px;
  background: #fbfcff;
}

.project-stats {
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
}

.ps-item {
  border-radius: 18px;
  background: linear-gradient(180deg, rgba(255,255,255,0.96), rgba(250,252,255,0.92));
}

.trend {
  height: 42px;
  padding-top: 4px;
}

.trend span {
  border-radius: 6px 6px 0 0;
}

/* ====== 弹窗美化 ====== */
.modal {
  backdrop-filter: blur(10px);
}

.modal-content {
  border: 1px solid rgba(255, 255, 255, 0.72);
  border-radius: 26px;
  background: rgba(255, 255, 255, 0.96);
}

.modal-head {
  position: sticky;
  top: 0;
  z-index: 3;
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(12px);
}

.modal-foot {
  background: rgba(250, 251, 255, 0.94);
  backdrop-filter: blur(12px);
}

.form input[type="text"],
.form input[type="number"],
.form input[type="date"],
.form input[type="time"],
.form input:not([type]),
.form textarea,
.form select {
  min-height: 42px;
  border-radius: 12px;
  transition: border-color .15s, box-shadow .15s;
}

.form input:focus,
.form textarea:focus,
.form select:focus {
  outline: none;
  border-color: rgba(108, 140, 255, 0.75);
  box-shadow: 0 0 0 4px rgba(108, 140, 255, 0.12);
}

.field-item,
.record-item {
  border-radius: 16px;
}

/* ====== 移动端：App 化布局 ====== */
@media (max-width: 760px) {
  body {
    background: linear-gradient(180deg, #f7f8ff 0%, #eef2f8 100%);
  }

  .topbar {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    top: auto;
    width: auto;
    margin: 0;
    padding: 8px 10px calc(8px + env(safe-area-inset-bottom));
    border-radius: 22px 22px 0 0;
    border-left: 0;
    border-right: 0;
    border-bottom: 0;
    z-index: 40;
  }

  .brand {
    display: none;
  }

  .tabs {
    width: 100%;
    gap: 6px;
    padding: 4px;
  }

  .tab {
    flex: 1;
    min-width: 0;
    padding: 10px 8px;
    font-size: 13px;
  }

  .page {
    padding: 14px 14px 92px;
  }

  .page-head {
    display: grid;
    gap: 16px;
    min-height: auto;
    padding: 20px;
    margin-bottom: 14px;
    border-radius: 24px;
  }

  .page-head h1 {
    font-size: 30px;
  }

  .subtitle {
    font-size: 13px;
    line-height: 1.6;
  }

  .page-head .btn {
    width: 100%;
    min-height: 48px;
  }

  .project-grid {
    grid-template-columns: 1fr;
    gap: 12px;
  }

  .project-card {
    min-height: 164px;
    padding: 18px;
    border-radius: 22px;
  }

  .project-card:hover {
    transform: none;
  }

  .project-card .pc-icon {
    width: 44px;
    height: 44px;
    border-radius: 15px;
  }

  .summary-cards {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
  }

  .summary-card {
    min-height: 104px;
    padding: 16px;
    border-radius: 20px;
  }

  .summary-card .value {
    font-size: 30px;
  }

  .stats-grid,
  .project-stats {
    grid-template-columns: 1fr;
    gap: 12px;
  }

  .stats-card {
    padding: 16px;
    border-radius: 22px;
  }

  .bar-row {
    grid-template-columns: 72px 1fr 34px;
    gap: 8px;
    font-size: 12px;
  }

  .reminder-item {
    min-height: 58px;
  }

  .modal {
    align-items: flex-end;
    padding: 0;
  }

  .modal-content,
  .modal-content.wide {
    width: 100%;
    max-width: none;
    max-height: 92vh;
    border-radius: 26px 26px 0 0;
  }

  .modal-head {
    padding: 16px;
  }

  .form {
    padding: 16px;
  }

  .form .row {
    display: grid;
    grid-template-columns: 1fr;
  }

  .fields-head {
    display: grid;
    gap: 10px;
    align-items: stretch;
  }

  .add-field {
    display: grid;
    grid-template-columns: 1fr auto;
  }

  .field-item .fi-head {
    display: grid;
    grid-template-columns: auto 1fr;
  }

  .field-item .fi-actions {
    grid-column: 1 / -1;
    margin-left: 0;
    justify-content: flex-end;
  }

  .record-layout {
    display: block;
    max-height: none;
  }

  .record-history {
    border-left: 0;
    border-top: 1px solid var(--border);
    max-height: 42vh;
  }

  .modal-foot {
    display: grid;
    grid-template-columns: 1fr 1fr;
    padding: 12px 16px calc(12px + env(safe-area-inset-bottom));
  }

  .modal-foot .btn.primary {
    grid-column: 1 / -1;
    order: -1;
  }

  .toast {
    bottom: calc(76px + env(safe-area-inset-bottom));
    width: calc(100% - 32px);
    text-align: center;
  }
}

@media (max-width: 390px) {
  .summary-cards {
    grid-template-columns: 1fr;
  }

  .pc-stats,
  .pc-tags {
    gap: 6px;
  }

  .tab {
    font-size: 12px;
  }
}

/* ====== v5 布局修正：减少错位、提升桌面和平板显示 ====== */
html {
  width: 100%;
  overflow-x: hidden;
}

body {
  width: 100%;
  overflow-x: hidden;
}

button,
input,
textarea,
select {
  font: inherit;
}

.topbar,
.page,
.modal-content {
  box-sizing: border-box;
}

.topbar {
  min-height: 68px;
}

.tabs {
  flex: 0 0 auto;
}

.page-head {
  gap: 18px;
}

.page-head > div {
  min-width: 0;
}

.project-grid {
  align-items: stretch;
}

.project-card {
  display: flex;
  flex-direction: column;
}

.project-card .pc-desc {
  flex: 1;
}

.project-card .pc-tags {
  margin-top: 12px;
}

.summary-cards {
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
}

.stats-grid {
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
}

.stats-card,
.summary-card,
.project-card,
.ps-item {
  min-width: 0;
}

.bar-row > span:first-child {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.reminder-item > div {
  min-width: 0;
}

.reminder-item > div > div:first-child {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.project-stats {
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
}

.modal-content.wide {
  width: min(960px, calc(100vw - 32px));
  max-width: none;
}

.record-layout {
  grid-template-columns: minmax(0, 1fr) minmax(300px, 360px);
  min-height: 0;
}

.record-history {
  min-width: 0;
}

.form {
  min-width: 0;
}

.form .row > label,
.form label.grow {
  min-width: 0;
}

.field-item .fi-head input[data-k="label"] {
  min-width: 0 !important;
}

.field-item .fi-row label {
  min-width: 0;
}

.error-card {
  grid-column: 1 / -1;
  border: 1px solid rgba(255, 93, 108, 0.24);
  background: linear-gradient(180deg, rgba(255,255,255,.96), rgba(255,246,247,.96));
}

.error-detail {
  display: inline-block;
  margin-top: 8px !important;
  padding: 6px 10px;
  border-radius: 10px;
  color: #b5424e;
  background: rgba(255, 93, 108, 0.1);
  font-size: 12px;
}

/* 641-760 宽度通常还是电脑窄窗/平板横向，保持顶部导航，避免底部导航造成错位 */
@media (min-width: 641px) and (max-width: 760px) {
  .topbar {
    position: sticky;
    top: 0;
    bottom: auto;
    display: flex;
    width: min(1180px, calc(100% - 24px));
    margin: 12px auto 0;
    padding: 10px 16px;
    border-radius: 18px;
  }

  .brand {
    display: flex;
  }

  .brand-name {
    display: none;
  }

  .tabs {
    width: auto;
  }

  .tab {
    min-width: 104px;
  }

  .page {
    padding: 22px 16px 36px;
  }

  .page-head {
    display: flex;
    align-items: center;
  }

  .page-head .btn {
    width: auto;
  }

  .summary-cards {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .modal {
    align-items: center;
    padding: 16px;
  }

  .modal-content,
  .modal-content.wide {
    width: min(920px, calc(100vw - 32px));
    border-radius: 24px;
  }

  .modal-foot {
    display: flex;
    grid-template-columns: none;
  }

  .modal-foot .btn.primary {
    grid-column: auto;
    order: 0;
  }
}

/* ====== v7：emoji 选择器 / 分类下拉 / 设置页 / 必填横排 ====== */

/* 图标选择按钮（绿框） */
.icon-picker {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
}
.icon-picker .icon-preview {
  flex: 0 0 auto;
  width: 42px;
  height: 42px;
  padding: 0;
  font-size: 22px;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(180deg, #ffffff, #f5f7fc);
  border: 1px solid var(--border);
  border-radius: 12px;
  cursor: pointer;
  transition: all .15s;
}
.icon-picker .icon-preview:hover {
  border-color: rgba(108, 140, 255, 0.6);
  box-shadow: 0 4px 14px rgba(108, 140, 255, 0.18);
  transform: translateY(-1px);
}
.icon-picker input {
  flex: 1;
  min-width: 0;
  text-align: center;
  font-size: 18px;
}

/* 分类下拉框（红框）继承通用 select 样式 */
.form select {
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'><path d='M2 4l4 4 4-4' stroke='%237a8194' stroke-width='1.6' fill='none' stroke-linecap='round' stroke-linejoin='round'/></svg>");
  background-repeat: no-repeat;
  background-position: right 12px center;
  background-size: 12px;
  padding-right: 32px;
  cursor: pointer;
}

/* 必填横排（黄框）—— 覆盖 .form label 的列向布局 */
.field-item .fi-head > label,
.field-item .fi-row > label,
.reminder-set > label,
.weekdays > label {
  flex-direction: row !important;
  align-items: center;
  gap: 6px;
}

/* Emoji 选择面板 */
.emoji-picker {
  position: fixed;
  inset: 0;
  display: grid;
  grid-template-rows: auto auto auto;
  align-content: center;
  justify-items: center;
  background: rgba(20, 25, 50, 0.45);
  backdrop-filter: blur(8px);
  z-index: 60;
  padding: 16px;
}
.emoji-picker.hidden { display: none; }
.emoji-picker-head,
.emoji-tabs,
.emoji-grid {
  width: min(420px, calc(100vw - 32px));
  background: #fff;
  border-left: 1px solid var(--border);
  border-right: 1px solid var(--border);
}
.emoji-picker-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  border-top: 1px solid var(--border);
  border-radius: 18px 18px 0 0;
  font-size: 15px;
  font-weight: 700;
}
.emoji-tabs {
  display: flex;
  gap: 4px;
  padding: 8px 12px;
  overflow-x: auto;
}
.emoji-tab {
  flex: 0 0 auto;
  padding: 6px 12px;
  font-size: 12px;
  font-weight: 500;
  color: var(--muted);
  background: #f3f6ff;
  border: none;
  border-radius: 999px;
  cursor: pointer;
  white-space: nowrap;
  transition: all .15s;
}
.emoji-tab:hover { background: #e7ecff; color: var(--text); }
.emoji-tab.active {
  color: #fff;
  background: linear-gradient(135deg, var(--primary), #8f7cff);
  box-shadow: 0 4px 10px rgba(108, 140, 255, 0.25);
}
.emoji-grid {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  gap: 4px;
  max-height: 280px;
  padding: 12px;
  overflow-y: auto;
  border-bottom: 1px solid var(--border);
  border-radius: 0 0 18px 18px;
  box-shadow: 0 24px 60px rgba(20, 30, 60, 0.2);
  align-self: start;
}
.emoji-cell {
  aspect-ratio: 1;
  font-size: 22px;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 10px;
  cursor: pointer;
  transition: all .12s;
}
.emoji-cell:hover {
  background: #f3f6ff;
  border-color: rgba(108, 140, 255, 0.4);
  transform: scale(1.1);
}

/* 设置页：分类编辑器 */
.settings-hint {
  margin: -4px 0 14px;
  font-size: 13px;
  color: var(--muted);
  line-height: 1.6;
}
.category-editor {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 14px;
}
.cat-item {
  display: grid;
  grid-template-columns: 28px minmax(0, 1fr) auto auto auto;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 12px;
}
.cat-handle {
  color: var(--muted);
  font-size: 14px;
  letter-spacing: -1px;
  cursor: grab;
  user-select: none;
}
.cat-input {
  width: 100%;
  min-height: 36px;
  padding: 6px 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #fafbff;
  font-size: 14px;
}
.cat-input:focus {
  outline: none;
  background: #fff;
  border-color: rgba(108, 140, 255, 0.65);
  box-shadow: 0 0 0 3px rgba(108, 140, 255, 0.12);
}
.cat-item .btn.small {
  min-height: 34px;
  min-width: 36px;
  border-radius: 8px;
}

.category-add {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
}
.category-add input {
  flex: 1;
  min-height: 40px;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #fff;
  font-size: 14px;
}
.category-add input:focus {
  outline: none;
  border-color: rgba(108, 140, 255, 0.65);
  box-shadow: 0 0 0 3px rgba(108, 140, 255, 0.12);
}

.settings-foot {
  display: flex;
  justify-content: flex-end;
  padding-top: 8px;
  border-top: 1px dashed var(--border);
}

/* 移动端适配 */
@media (max-width: 640px) {
  .cat-item {
    grid-template-columns: 24px minmax(0, 1fr) auto auto;
  }
  .cat-item .btn[data-act="del"] {
    grid-column: 1 / -1;
    width: 100%;
    margin-top: 4px;
  }
  .emoji-grid {
    grid-template-columns: repeat(6, 1fr);
  }
}


/* 整体 */
.modal-content.wide {
  width: min(960px, calc(100vw - 32px));
}
.modal-head {
  padding: 18px 24px;
}
.modal-head h2 {
  font-size: 19px;
  font-weight: 700;
  letter-spacing: -0.01em;
}
.form {
  padding: 22px 24px 4px;
}
.form > .row + .row {
  margin-top: 4px;
}

/* —— 项目表单第一行：名称 / 图标 / 颜色 —— */
#projectForm > .row:nth-of-type(1) {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 110px 120px;
  gap: 12px;
  margin-bottom: 14px;
}
#projectForm > .row:nth-of-type(2) {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 2fr);
  gap: 12px;
  margin-bottom: 14px;
}
@media (max-width: 640px) {
  #projectForm > .row:nth-of-type(1),
  #projectForm > .row:nth-of-type(2) {
    grid-template-columns: 1fr;
  }
}

/* 标签更精致 */
.form label {
  gap: 6px;
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  letter-spacing: 0.02em;
}
.form label.grow {
  flex: none;
}
.form label.inline {
  font-size: 13px;
  font-weight: 500;
}

/* 颜色选择器更协调 */
.form input[type="color"] {
  width: 100%;
  height: 42px;
  padding: 4px;
  border-radius: 12px;
  border: 1px solid var(--border);
  cursor: pointer;
  background: #fff;
}

/* —— 提醒设置卡片 —— */
.reminder-set {
  position: relative;
  margin: 6px 0 18px;
  padding: 16px 18px;
  border: 1px solid var(--border);
  border-radius: 16px;
  background: linear-gradient(180deg, rgba(247, 249, 255, 0.92), rgba(255, 255, 255, 0.85));
}
.reminder-set legend {
  padding: 2px 10px;
  font-size: 12px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: 0.02em;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 999px;
}
.reminder-set > .inline {
  display: inline-flex;
  margin-right: 16px;
}
.reminder-set > label:not(.inline) {
  display: inline-flex;
  flex-direction: row;
  align-items: center;
  gap: 8px;
  vertical-align: middle;
  font-size: 13px;
  color: var(--text);
}
.reminder-set > label:not(.inline) input[type="time"] {
  width: 150px;
  min-height: 38px;
}
.weekdays {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px dashed var(--border);
}
.weekdays > span {
  margin-right: 6px;
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
}
.weekdays label {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 38px;
  padding: 6px 10px;
  font-size: 12px;
  font-weight: 500;
  color: var(--muted);
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 999px;
  cursor: pointer;
  user-select: none;
  transition: all .15s;
  flex: 0 0 auto;
}
.weekdays label input[type="checkbox"] {
  position: absolute;
  opacity: 0;
  pointer-events: none;
  width: 0; height: 0;
}
.weekdays label:hover {
  border-color: rgba(108, 140, 255, 0.5);
  color: var(--text);
}
.weekdays label:has(input:checked) {
  color: #fff;
  border-color: transparent;
  background: linear-gradient(135deg, var(--primary), #8f7cff);
  box-shadow: 0 6px 14px rgba(108, 140, 255, 0.28);
}

/* —— 组件字段头部 —— */
.fields-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 22px 0 14px;
  padding-bottom: 12px;
  border-bottom: 1px dashed var(--border);
}
.fields-head h3 {
  margin: 0;
  font-size: 16px;
  font-weight: 700;
  letter-spacing: -0.01em;
}
.add-field {
  display: flex;
  gap: 8px;
  align-items: center;
  flex: 0 0 auto;
}
.add-field select {
  min-height: 38px;
  padding: 6px 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #fff;
  font-size: 13px;
  cursor: pointer;
}
.add-field .btn.small {
  min-height: 38px;
  padding: 6px 14px;
  border-radius: 10px;
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
}

/* —— 字段卡片 —— */
.field-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.field-item {
  padding: 14px 14px 12px;
  border-radius: 14px;
  background: #fff;
  border: 1px solid var(--border);
  box-shadow: 0 2px 8px rgba(20, 30, 60, 0.04);
}
.field-item .fi-head {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto auto;
  gap: 10px;
  align-items: center;
}
.field-item .fi-type {
  padding: 5px 12px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.02em;
  background: linear-gradient(135deg, var(--primary), #8f7cff);
  border-radius: 999px;
  white-space: nowrap;
}
.field-item .fi-head input[data-k="label"] {
  width: 100% !important;
  min-width: 0 !important;
  min-height: 36px;
  padding: 7px 12px;
  font-size: 13px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #fafbff;
}
.field-item .fi-head input[data-k="label"]:focus {
  background: #fff;
  border-color: rgba(108, 140, 255, 0.65);
  box-shadow: 0 0 0 3px rgba(108, 140, 255, 0.12);
  outline: none;
}
.field-item .fi-head > label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  background: #f3f6ff;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 500;
  color: var(--muted);
  white-space: nowrap;
  cursor: pointer;
  transition: all .15s;
}
.field-item .fi-head > label:hover {
  background: #e7ecff;
  color: var(--text);
}
.field-item .fi-head > label input[type="checkbox"] {
  width: 14px;
  height: 14px;
  margin: 0;
  cursor: pointer;
  accent-color: var(--primary);
}
.field-item .fi-actions {
  display: inline-flex;
  gap: 4px;
  margin-left: 0;
}
.field-item .fi-actions .btn {
  min-height: 32px;
  min-width: 34px;
  padding: 4px 10px;
  font-size: 12px;
  font-weight: 600;
  border-radius: 8px;
}
.field-item .fi-row {
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px dashed var(--border);
}
.field-item .fi-row label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 500;
  color: var(--muted);
  margin: 0;
}
.field-item .fi-row label input[type="number"] {
  width: 70px;
  min-height: 32px;
  padding: 4px 10px;
  font-size: 13px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fff;
}
.field-item .fi-row label input[type="checkbox"] {
  width: 14px;
  height: 14px;
  margin: 0;
  accent-color: var(--success);
  cursor: pointer;
}
.field-item .fi-row > label[style*="flex:1"] {
  flex: 1 1 240px;
}
.field-item .fi-row > label[style*="flex:1"] input[data-k="placeholder"],
.field-item .fi-row > label[style*="flex:1"] input[data-k="options"] {
  width: 100%;
  min-height: 34px;
  padding: 6px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 13px;
  background: #fff;
}

/* @640px field-item 折行优化 */
@media (max-width: 640px) {
  .field-item .fi-head {
    grid-template-columns: auto 1fr;
    gap: 8px;
  }
  .field-item .fi-head > label {
    grid-column: 1 / -1;
    justify-self: start;
  }
  .field-item .fi-actions {
    grid-column: 1 / -1;
    justify-content: flex-end;
    width: 100%;
  }
}

/* —— 项目编辑底部按钮：删除靠左 —— */
.modal-foot {
  padding: 16px 24px;
  gap: 10px;
}
#btnDeleteProject:not(.hidden) {
  margin-right: auto;
}

/* —— 记录弹窗：添加记录表单 —— */
.record-layout {
  grid-template-columns: minmax(0, 1.15fr) minmax(300px, 360px);
}
.record-history {
  padding: 18px 20px;
  background: linear-gradient(180deg, #fafbff 0%, #f4f6fc 100%);
}
#recordForm > h3#recordFormTitle {
  margin: 0 0 14px;
  padding-bottom: 10px;
  font-size: 15px;
  font-weight: 700;
  letter-spacing: -0.01em;
  border-bottom: 1px dashed var(--border);
}

.record-fields {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 14px;
}
.rf-item {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin: 0;
}
.rf-item .rf-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  letter-spacing: 0.02em;
}
.rf-item .rf-label .req {
  margin-left: 3px;
  color: var(--danger);
  font-weight: 700;
}
.rf-input {
  width: 100%;
  min-height: 42px;
}

/* textarea / select 占满整行 */
.rf-item[data-type="textarea"],
.rf-item[data-type="select"] {
  grid-column: 1 / -1;
}
.rf-item[data-type="textarea"] textarea {
  min-height: 80px;
}

/* 复选框 / 开关：标签和控件同行 */
.rf-item[data-type="checkbox"],
.rf-item[data-type="switch"] {
  flex-direction: row;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  background: #f7f8fc;
  border: 1px solid var(--border);
  border-radius: 12px;
  gap: 12px;
}
.rf-item[data-type="checkbox"] .rf-label,
.rf-item[data-type="switch"] .rf-label,
.rf-item[data-type="rating"] .rf-label {
  margin: 0;
  flex: 1;
  min-width: 0;
}
.rf-item[data-type="checkbox"] .rf-row-toggle,
.rf-item[data-type="switch"] .rf-row-toggle {
  margin: 0;
  flex: 0 0 auto;
}
.rf-item[data-type="checkbox"] .rf-row-toggle {
  font-size: 13px;
  color: var(--text);
}
.rf-item[data-type="checkbox"] .rf-row-toggle input[type="checkbox"] {
  width: 18px;
  height: 18px;
  margin: 0;
  accent-color: var(--primary);
  cursor: pointer;
}
.rf-item[data-type="rating"] {
  flex-direction: row;
  align-items: center;
  justify-content: space-between;
  padding: 8px 14px;
  background: #f7f8fc;
  border: 1px solid var(--border);
  border-radius: 12px;
  gap: 12px;
}
.rf-item[data-type="rating"] .rating {
  flex: 0 0 auto;
}

/* 数字 / 日期 / 时间：宽度自适应 */
.rf-item[data-type="number"] .rf-input,
.rf-item[data-type="date"] .rf-input,
.rf-item[data-type="time"] .rf-input {
  width: 100%;
}

/* 历史记录卡片 */
.record-history-list .record-item {
  border-radius: 12px;
  box-shadow: 0 2px 6px rgba(20, 30, 60, 0.04);
}

/* 移动端：record-fields 单列 */
@media (max-width: 760px) {
  .record-fields {
    grid-template-columns: 1fr;
  }
  .modal-head {
    padding: 14px 18px;
  }
  .form {
    padding: 18px 18px 4px;
  }
  .modal-foot {
    padding: 14px 18px calc(14px + env(safe-area-inset-bottom));
  }
  #btnDeleteProject:not(.hidden) {
    margin-right: 0;
  }
  /* 提醒区时间输入更紧凑 */
  .reminder-set > label:not(.inline) input[type="time"] {
    width: 130px;
  }
}

/* ====== 原有 640px 媒体查询继续 ====== */
@media (max-width: 640px) {
  .project-card,
  .summary-card,
  .stats-card,
  .ps-item {
    box-shadow: 0 12px 30px rgba(20, 30, 60, 0.08);
  }

  .pc-head {
    min-width: 0;
  }

  .project-card .pc-head > div:last-child {
    min-width: 0;
  }

  .project-card .pc-name,
  .project-card .pc-meta {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .add-field {
    grid-template-columns: 1fr;
  }

  .add-field .btn {
    width: 100%;
  }

  .field-item .fi-head {
    grid-template-columns: 1fr;
  }

  .field-item .fi-type {
    justify-self: start;
  }

  .field-item .fi-head input[data-k="label"] {
    width: 100%;
  }

  .field-item .fi-actions {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    width: 100%;
  }

  .field-item .fi-actions .btn {
    width: 100%;
  }

  .weekdays {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .weekdays span {
    grid-column: 1 / -1;
  }

  .record-item .ri-row {
    display: grid;
    grid-template-columns: 72px minmax(0, 1fr);
  }

  .record-item .ri-row .k {
    min-width: 0;
  }

  .modal-foot {
    grid-template-columns: 1fr;
  }

  .modal-foot .btn {
    width: 100%;
  }
}

/* ====== v8：弹窗比例和复选框细节修正 ====== */

/* 图 1：新建项目弹窗减窄，避免内容横向铺得过散 */
#projectModal .modal-content.wide {
  width: min(860px, calc(100vw - 48px));
}

#projectModal .modal-head {
  padding: 16px 22px;
}

#projectForm.form {
  padding: 20px 22px 4px;
}

#projectForm > .row:nth-of-type(1) {
  grid-template-columns: minmax(0, 1fr) 118px 118px;
}

#projectForm > .row:nth-of-type(2) {
  grid-template-columns: minmax(180px, 0.72fr) minmax(0, 1.28fr);
}

#projectModal .reminder-set {
  padding: 15px 18px;
}

#projectModal .field-item {
  padding: 12px 14px;
}

#projectModal .field-item .fi-head {
  grid-template-columns: auto minmax(0, 1fr) auto auto;
}

/* 图 2：记录弹窗左右互换比例，左侧表单单列，右侧历史列表变宽 */
#recordModal .modal-content.wide {
  width: min(980px, calc(100vw - 48px));
}

#recordModal .record-layout {
  grid-template-columns: minmax(320px, 0.78fr) minmax(420px, 1.22fr);
}

#recordModal #recordForm {
  padding: 22px 24px 0;
}

#recordModal .record-history {
  padding: 22px 24px;
}

#recordModal .record-fields {
  grid-template-columns: 1fr;
  gap: 14px;
}

#recordModal .rf-item[data-type="textarea"],
#recordModal .rf-item[data-type="select"] {
  grid-column: auto;
}

#recordModal .record-history-list {
  gap: 10px;
}

#recordModal .record-item {
  padding: 12px 14px;
  border-radius: 14px;
}

#recordModal .record-item .ri-row {
  display: grid;
  grid-template-columns: 88px minmax(0, 1fr);
  gap: 10px;
  align-items: start;
}

#recordModal .record-item .ri-row .k {
  min-width: 0;
  color: var(--muted);
}

/* 图 3：记录表单里的复选框和说明文字横向对齐、美化 */
#recordModal .rf-item[data-type="checkbox"] {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  min-height: 64px;
  padding: 12px 14px;
  background:
    linear-gradient(180deg, rgba(255,255,255,.94), rgba(247,248,252,.94));
  border: 1px solid var(--border);
  border-radius: 14px;
}

#recordModal .rf-item[data-type="checkbox"] .rf-label {
  font-size: 13px;
  font-weight: 700;
  color: #6f7689;
}

#recordModal .rf-item[data-type="checkbox"] .rf-row-toggle {
  display: inline-flex !important;
  flex-direction: row !important;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  margin: 0;
  padding: 6px 8px;
  color: var(--text);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0;
  white-space: nowrap;
  background: rgba(255,255,255,.7);
  border: 1px solid rgba(230, 232, 239, .9);
  border-radius: 999px;
}

#recordModal .rf-item[data-type="checkbox"] .rf-row-toggle input[type="checkbox"] {
  width: 18px;
  height: 18px;
  margin: 0;
  flex: 0 0 auto;
  accent-color: var(--primary);
}

#recordModal .rf-item[data-type="checkbox"] .rf-row-toggle span {
  display: inline-block;
  line-height: 1;
}

#recordModal .rf-item[data-type="switch"],
#recordModal .rf-item[data-type="rating"] {
  min-height: 56px;
}

/* 窄屏仍保持单列和底部弹窗体验 */
@media (max-width: 760px) {
  #projectModal .modal-content.wide,
  #recordModal .modal-content.wide {
    width: 100%;
  }

  #projectForm > .row:nth-of-type(1),
  #projectForm > .row:nth-of-type(2) {
    grid-template-columns: 1fr;
  }

  #recordModal .record-layout {
    display: block;
  }

  #recordModal .record-history {
    border-top: 1px solid var(--border);
  }

  #recordModal .rf-item[data-type="checkbox"] {
    grid-template-columns: 1fr;
    gap: 10px;
  }

  #recordModal .rf-item[data-type="checkbox"] .rf-row-toggle {
    justify-self: start;
  }
}

/* ====== v9：弹窗内部滚动、按钮美化、移动端操作优化 ====== */

/* 1. 弹窗滚动条收回到弹窗内部右侧 */
.modal {
  overflow: hidden;
}

.modal-content,
.modal-content.wide {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  max-height: 92vh;
}

.modal-head {
  flex: 0 0 auto;
}

#projectModal .modal-content.wide {
  max-height: min(92vh, 860px);
}

#projectForm {
  overflow-y: auto;
  overflow-x: hidden;
  max-height: calc(92vh - 64px);
  scrollbar-gutter: stable;
}

#recordModal .record-layout {
  min-height: 0;
  max-height: calc(92vh - 64px);
  overflow: hidden;
}

#recordModal #recordForm,
#recordModal .record-history {
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  scrollbar-gutter: stable;
}

/* 让滚动条更轻，不再像“贴在弹窗外” */
.modal-content *::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}

.modal-content *::-webkit-scrollbar-track {
  background: transparent;
}

.modal-content *::-webkit-scrollbar-thumb {
  background: rgba(122, 129, 148, 0.24);
  border: 3px solid transparent;
  border-radius: 999px;
  background-clip: content-box;
}

.modal-content *::-webkit-scrollbar-thumb:hover {
  background: rgba(122, 129, 148, 0.42);
  border: 3px solid transparent;
  background-clip: content-box;
}

/* 4. “添加组件”按钮美化 */
#btnAddField {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 40px;
  padding: 0 16px;
  color: #fff;
  font-weight: 800;
  letter-spacing: 0.01em;
  border: 0;
  border-radius: 999px;
  background:
    radial-gradient(circle at 18% 18%, rgba(255,255,255,.35), transparent 28px),
    linear-gradient(135deg, #6c8cff 0%, #8f7cff 54%, #a977ff 100%);
  box-shadow:
    0 12px 24px rgba(108, 140, 255, 0.28),
    inset 0 1px 0 rgba(255,255,255,.32);
}

#btnAddField::before {
  content: "+";
  display: inline-grid;
  place-items: center;
  width: 18px;
  height: 18px;
  color: #6c8cff;
  font-size: 14px;
  font-weight: 900;
  line-height: 1;
  background: #fff;
  border-radius: 999px;
  box-shadow: 0 2px 8px rgba(20, 30, 60, 0.12);
}

#btnAddField {
  font-size: 0;
}

#btnAddField::after {
  content: "添加属性";
  font-size: 13px;
}

#btnAddField:hover {
  transform: translateY(-1px);
  box-shadow:
    0 16px 30px rgba(108, 140, 255, 0.36),
    inset 0 1px 0 rgba(255,255,255,.35);
}

#btnAddField:active {
  transform: translateY(0);
  box-shadow: 0 8px 18px rgba(108, 140, 255, 0.24);
}

.fields-head {
  align-items: center;
}

.fields-head h3 {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.fields-head h3::before {
  content: "";
  width: 8px;
  height: 18px;
  border-radius: 999px;
  background: linear-gradient(180deg, var(--primary), #9a7cff);
  box-shadow: 0 4px 10px rgba(108, 140, 255, 0.24);
}

/* 5. 移动端：按手机操作习惯优化弹窗、底部按钮和字段列表 */
@media (max-width: 760px) {
  .modal {
    align-items: flex-end;
    padding: 0;
  }

  .modal-content,
  .modal-content.wide,
  #projectModal .modal-content.wide,
  #recordModal .modal-content.wide {
    width: 100%;
    max-width: none;
    height: min(92dvh, calc(100dvh - 10px));
    max-height: none;
    border-radius: 26px 26px 0 0;
  }

  .modal-head {
    min-height: 56px;
    padding: 14px 18px;
  }

  .modal-head::before {
    content: "";
    position: absolute;
    left: 50%;
    top: 7px;
    width: 42px;
    height: 4px;
    transform: translateX(-50%);
    border-radius: 999px;
    background: rgba(122, 129, 148, 0.24);
  }

  #projectForm {
    max-height: calc(min(92dvh, 100dvh - 10px) - 56px);
    padding: 18px 16px 0;
  }

  #recordModal .record-layout {
    display: grid;
    grid-template-rows: minmax(0, auto) minmax(180px, 36vh);
    max-height: calc(min(92dvh, 100dvh - 10px) - 56px);
    overflow-y: auto;
  }

  #recordModal #recordForm {
    overflow: visible;
    padding: 18px 16px 0;
  }

  #recordModal .record-history {
    max-height: 36vh;
    padding: 16px;
    border-left: 0;
    border-top: 1px solid var(--border);
  }

  .fields-head {
    display: grid;
    grid-template-columns: 1fr;
    gap: 10px;
    align-items: stretch;
  }

  .add-field {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 8px;
    width: 100%;
  }

  .add-field select {
    width: 100%;
  }

  #btnAddField {
    min-width: 124px;
    padding: 0 14px;
  }

  .field-item {
    padding: 12px;
    border-radius: 16px;
  }

  .field-item .fi-head {
    grid-template-columns: auto minmax(0, 1fr);
  }

  .field-item .fi-head > label {
    grid-column: 1 / -1;
    justify-self: start;
  }

  .field-item .fi-actions {
    grid-column: 1 / -1;
    display: grid;
    grid-template-columns: 1fr 1fr 1.2fr;
    width: 100%;
    gap: 8px;
  }

  .field-item .fi-actions .btn {
    width: 100%;
    min-height: 36px;
  }

  .modal-foot {
    position: sticky;
    bottom: 0;
    z-index: 5;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    padding: 12px 16px calc(12px + env(safe-area-inset-bottom));
    background: rgba(250, 251, 255, 0.96);
    border-top: 1px solid var(--border);
    backdrop-filter: blur(16px);
  }

  .modal-foot .btn {
    width: 100%;
    min-height: 46px;
  }

  .modal-foot .btn.primary {
    grid-column: 1 / -1;
    order: -1;
  }

  #recordModal .modal-foot {
    grid-template-columns: 1fr 1fr;
  }

  #recordModal .modal-foot #btnEditProject {
    grid-column: 1 / -1;
    order: 2;
  }

  #recordModal .record-item .ri-row {
    grid-template-columns: 74px minmax(0, 1fr);
    gap: 8px;
  }
}

@media (max-width: 420px) {
  .modal-content,
  .modal-content.wide,
  #projectModal .modal-content.wide,
  #recordModal .modal-content.wide {
    height: 94dvh;
  }

  .add-field {
    grid-template-columns: 1fr;
  }

  #btnAddField {
    width: 100%;
  }

  #recordModal .record-layout {
    grid-template-rows: minmax(0, auto) minmax(170px, 34vh);
  }
}

/* ====== v10：统计按钮、移动端表单布局、记录弹窗三分页 ====== */

/* 1. 统计与提醒刷新按钮美化 */
.refresh-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-width: 104px;
  min-height: 44px;
  padding: 0 18px;
  color: #fff;
  font-weight: 800;
  border: 0;
  border-radius: 999px;
  background:
    radial-gradient(circle at 20% 15%, rgba(255,255,255,.36), transparent 30px),
    linear-gradient(135deg, #6c8cff, #8f7cff 58%, #a977ff);
  box-shadow: 0 14px 28px rgba(108, 140, 255, 0.28);
}

.refresh-btn span {
  display: inline-grid;
  place-items: center;
  width: 22px;
  height: 22px;
  border-radius: 999px;
  color: #6c8cff;
  background: #fff;
  font-size: 15px;
  font-weight: 900;
  line-height: 1;
}

.refresh-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 18px 34px rgba(108, 140, 255, 0.36);
}

/* 新建项目结构：桌面端更紧凑 */
#projectForm > .project-name-row {
  display: grid;
  grid-template-columns: 1fr;
}

#projectForm > .project-meta-row {
  display: grid;
  grid-template-columns: minmax(120px, .85fr) 118px minmax(160px, 1fr);
  gap: 12px;
}

#projectForm > .project-desc-row {
  display: grid;
  grid-template-columns: 1fr;
}

/* 7. 记录弹窗改为三分页 */
#recordModal .modal-content.wide {
  width: min(900px, calc(100vw - 48px));
}

#recordModal .modal-head {
  gap: 12px;
}

.modal-actions {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-left: auto;
}

.edit-top-btn {
  min-height: 34px;
  padding: 0 12px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}

#recordModal .record-layout {
  display: flex;
  flex-direction: column;
  min-height: 0;
  max-height: calc(92vh - 64px);
  overflow: hidden;
}

.record-tabs {
  flex: 0 0 auto;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  padding: 14px 18px 10px;
  background: rgba(250, 251, 255, .96);
  border-bottom: 1px solid var(--border);
}

.record-tab {
  min-height: 40px;
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--muted);
  background: #fff;
  font-size: 13px;
  font-weight: 800;
  cursor: pointer;
  transition: all .15s;
}

.record-tab:hover {
  border-color: rgba(108, 140, 255, .48);
  color: var(--text);
}

.record-tab.active {
  color: #fff;
  border-color: transparent;
  background: linear-gradient(135deg, var(--primary), #8f7cff);
  box-shadow: 0 10px 22px rgba(108, 140, 255, 0.22);
}

.record-panel {
  display: none;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  scrollbar-gutter: stable;
}

.record-panel.active {
  display: block;
  flex: 1 1 auto;
}

#recordModal #recordForm {
  min-height: 100%;
  padding: 20px 22px 0;
}

#recordModal .record-history,
#recordModal .record-event-stats {
  padding: 20px 22px;
  border-left: 0;
  border-top: 0;
  background: linear-gradient(180deg, #fafbff 0%, #f4f6fc 100%);
}

.record-event-stats h3,
.record-history h3 {
  margin: 0 0 14px;
  font-size: 16px;
}

.record-event-stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
}

.record-stat-card {
  display: grid;
  gap: 8px;
  min-height: 104px;
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: 18px;
  background: #fff;
  box-shadow: 0 8px 22px rgba(20, 30, 60, 0.06);
}

.record-stat-card span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.record-stat-card strong {
  align-self: end;
  color: var(--text);
  font-size: 24px;
  line-height: 1.2;
  word-break: break-word;
}

.record-stat-card.wide {
  grid-column: span 2;
}

/* 8. 新增记录底部按钮一行，编辑项目在右上角 */
#recordModal .modal-foot {
  grid-template-columns: 1fr 1fr;
}

#recordModal .modal-foot .btn.primary {
  grid-column: auto;
  order: 0;
}

#recordModal .modal-foot .btn {
  min-height: 44px;
}

/* 移动端细化 */
@media (max-width: 760px) {
  /* 2. 图标、颜色、分类一行 */
  #projectForm > .project-name-row {
    grid-template-columns: 1fr;
  }

  #projectForm > .project-meta-row {
    grid-template-columns: minmax(82px, 1.05fr) minmax(58px, .68fr) minmax(104px, 1.35fr);
    gap: 8px;
    align-items: end;
  }

  #projectForm > .project-meta-row > label {
    min-width: 0;
    font-size: 11px;
    gap: 5px;
  }

  #projectForm > .project-meta-row .icon-picker {
    gap: 6px;
  }

  #projectForm > .project-meta-row .icon-preview {
    width: 38px;
    height: 38px;
    border-radius: 12px;
    font-size: 20px;
  }

  #projectForm > .project-meta-row #iconInput {
    min-width: 0;
    height: 38px;
    padding: 6px;
    font-size: 16px;
  }

  #projectForm > .project-meta-row input[type="color"],
  #projectForm > .project-meta-row select {
    min-height: 38px;
    height: 38px;
  }

  #projectForm > .project-meta-row select {
    padding-left: 8px;
    padding-right: 24px;
    font-size: 12px;
    background-position: right 8px center;
  }

  #projectForm > .project-desc-row {
    grid-template-columns: 1fr;
  }

  /* 3. 提醒设置中的复选框选项和时间横向对齐、字号一致 */
  #projectModal .reminder-set {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 10px 12px;
    align-items: center;
    padding: 14px;
  }

  #projectModal .reminder-set legend {
    grid-column: 1 / -1;
  }

  #projectModal .reminder-set > label.inline,
  #projectModal .reminder-set > label:not(.inline) {
    display: inline-flex;
    flex-direction: row !important;
    align-items: center;
    gap: 6px;
    margin: 0;
    font-size: 12px;
    font-weight: 700;
    line-height: 38px;
    white-space: nowrap;
  }

  #projectModal .reminder-set input[type="checkbox"] {
    width: 15px;
    height: 15px;
    margin: 0;
    accent-color: var(--primary);
  }

  #projectModal .reminder-set > label:not(.inline) input[type="time"] {
    width: 112px;
    min-height: 38px;
    height: 38px;
    font-size: 12px;
  }

  #projectModal .weekdays {
    grid-column: 1 / -1;
    display: grid;
    grid-template-columns: auto repeat(7, minmax(0, 1fr));
    gap: 6px;
    margin-top: 4px;
    padding-top: 12px;
  }

  #projectModal .weekdays span {
    grid-column: auto;
    align-self: center;
    margin: 0;
    font-size: 12px;
  }

  #projectModal .weekdays label {
    min-width: 0;
    padding: 6px 0;
    font-size: 12px;
  }

  /* 4. 属性选择框和添加属性按钮一行 */
  #projectModal .fields-head {
    display: grid;
    grid-template-columns: 1fr;
    gap: 10px;
  }

  #projectModal .add-field {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 8px;
    width: 100%;
  }

  #projectModal .add-field select {
    width: 100%;
    min-width: 0;
  }

  #projectModal #btnAddField {
    min-width: 118px;
    width: auto;
    padding: 0 12px;
  }

  /* 5. 属性卡片：类型、输入框、必填在一行 */
  #projectModal .field-item .fi-head {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    gap: 8px;
    align-items: center;
  }

  #projectModal .field-item .fi-type {
    padding: 5px 9px;
    font-size: 10px;
  }

  #projectModal .field-item .fi-head input[data-k="label"] {
    min-height: 36px;
    padding: 6px 9px;
  }

  #projectModal .field-item .fi-head > label {
    grid-column: auto;
    justify-self: end;
    padding: 6px 9px;
    font-size: 11px;
  }

  #projectModal .field-item .fi-actions {
    grid-column: 1 / -1;
    display: grid;
    grid-template-columns: 1fr 1fr 1.2fr;
    gap: 8px;
    width: 100%;
  }

  /* 6. 下方保存和取消放在一行 */
  #projectModal .modal-foot {
    grid-template-columns: 1fr 1fr;
  }

  #projectModal .modal-foot .btn.primary {
    grid-column: auto;
    order: 0;
  }

  #projectModal .modal-foot [data-close="projectModal"] {
    order: 0;
  }

  #projectModal #btnDeleteProject:not(.hidden) {
    grid-column: 1 / -1;
    order: 2;
    margin-right: 0;
  }

  /* 7/8. 记录弹窗移动端三分页 */
  #recordModal .modal-head {
    align-items: center;
  }

  #recordModal .modal-actions {
    gap: 6px;
  }

  #recordModal .edit-top-btn {
    min-height: 32px;
    padding: 0 10px;
    font-size: 11px;
  }

  #recordModal .record-layout {
    display: flex;
    flex-direction: column;
    max-height: calc(min(92dvh, 100dvh - 10px) - 56px);
    overflow: hidden;
  }

  #recordModal .record-tabs {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 6px;
    padding: 10px 12px 8px;
  }

  #recordModal .record-tab {
    min-height: 36px;
    padding: 0 4px;
    font-size: 12px;
  }

  #recordModal .record-panel.active {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
  }

  #recordModal #recordForm {
    padding: 16px 14px 0;
    min-height: 100%;
  }

  #recordModal .record-history,
  #recordModal .record-event-stats {
    max-height: none;
    padding: 16px 14px;
  }

  #recordModal .modal-foot {
    grid-template-columns: 1fr 1fr;
  }

  #recordModal .modal-foot .btn.primary {
    grid-column: auto;
    order: 0;
  }

  #recordModal .record-event-stats-grid {
    grid-template-columns: 1fr 1fr;
    gap: 10px;
  }

  #recordModal .record-stat-card {
    min-height: 92px;
    padding: 14px;
  }

  #recordModal .record-stat-card strong {
    font-size: 20px;
  }
}

@media (max-width: 420px) {
  #projectForm > .project-meta-row {
    grid-template-columns: minmax(76px, 1fr) minmax(54px, .62fr) minmax(96px, 1.25fr);
    gap: 6px;
  }

  #projectModal .add-field {
    grid-template-columns: minmax(0, 1fr) auto;
  }

  #projectModal #btnAddField {
    min-width: 108px;
  }

  #projectModal .weekdays {
    grid-template-columns: auto repeat(7, minmax(24px, 1fr));
    gap: 4px;
  }

  #projectModal .weekdays label {
    font-size: 11px;
  }

  #recordModal .record-event-stats-grid {
    grid-template-columns: 1fr;
  }

  .record-stat-card.wide {
    grid-column: auto;
  }
}

/* v10.1：提升移动端“图标/颜色/分类同排”的优先级，覆盖旧 nth-of-type 规则 */
#projectForm > .row.project-meta-row {
  display: grid;
  grid-template-columns: minmax(120px, .85fr) 118px minmax(160px, 1fr);
}

@media (max-width: 760px) {
  #projectForm > .row.project-meta-row {
    grid-template-columns: minmax(82px, 1.05fr) minmax(58px, .68fr) minmax(104px, 1.35fr) !important;
  }

  #projectForm > .row.project-name-row,
  #projectForm > .row.project-desc-row {
    grid-template-columns: 1fr !important;
  }
}

@media (max-width: 420px) {
  #projectForm > .row.project-meta-row {
    grid-template-columns: minmax(76px, 1fr) minmax(54px, .62fr) minmax(96px, 1.25fr) !important;
  }
}

/* ====== v11：锁定背景滚动、记录弹窗图标按钮、移动端复选框同行 ====== */
body.modal-open {
  position: fixed;
  left: 0;
  right: 0;
  width: 100%;
  overflow: hidden;
}

.modal,
.emoji-picker {
  overscroll-behavior: contain;
}

.modal-content,
#projectForm,
#recordModal .record-panel,
#recordModal #recordForm,
#recordModal .record-history,
#recordModal .record-event-stats {
  overscroll-behavior: contain;
}

/* 右上角编辑和关闭按钮统一为图标按钮 */
#recordModal .modal-actions {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.modal-action-btn {
  display: inline-grid;
  place-items: center;
  width: 36px;
  height: 36px;
  padding: 0;
  border: 1px solid rgba(230, 232, 239, 0.96);
  border-radius: 13px;
  color: #66708a;
  background:
    linear-gradient(180deg, rgba(255,255,255,.98), rgba(245,247,252,.94));
  box-shadow:
    0 8px 18px rgba(20, 30, 60, 0.08),
    inset 0 1px 0 rgba(255,255,255,.8);
  cursor: pointer;
  font-size: 16px;
  font-weight: 900;
  line-height: 1;
  transition: all .15s ease;
}

.modal-action-btn:hover {
  color: #fff;
  border-color: transparent;
  transform: translateY(-1px);
  background: linear-gradient(135deg, var(--primary), #8f7cff);
  box-shadow: 0 12px 24px rgba(108, 140, 255, 0.28);
}

.modal-action-btn:active {
  transform: translateY(0);
  box-shadow: 0 6px 14px rgba(108, 140, 255, 0.18);
}

.close-top-btn:hover {
  background: linear-gradient(135deg, #ff6b7a, #ff8792);
  box-shadow: 0 12px 24px rgba(255, 93, 108, 0.26);
}

.edit-top-btn {
  min-width: 36px;
  font-size: 17px;
}

/* 第三页标题统一为“统计”后，保留统计页样式 */
.record-event-stats h3 {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.record-event-stats h3::before {
  content: "";
  width: 8px;
  height: 18px;
  border-radius: 999px;
  background: linear-gradient(180deg, var(--primary), #9a7cff);
}

/* 移动端记录事件中：复选框标题和选项保持同一行 */
@media (max-width: 760px) {
  #recordModal .rf-item[data-type="checkbox"] {
    display: grid !important;
    grid-template-columns: minmax(0, 1fr) auto !important;
    align-items: center !important;
    gap: 10px !important;
  }

  #recordModal .rf-item[data-type="checkbox"] .rf-label {
    min-width: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  #recordModal .rf-item[data-type="checkbox"] .rf-row-toggle {
    justify-self: end !important;
    min-width: auto;
    white-space: nowrap;
  }

  #recordModal .modal-actions {
    gap: 6px;
  }

  #recordModal .modal-action-btn {
    width: 34px;
    height: 34px;
    border-radius: 12px;
  }
}

/* ====== v12：移动端记录弹窗加宽、日期输入防溢出、右上角图标放大 ====== */

/* 右上角图标按钮放大并增强质感 */
#recordModal .modal-action-btn {
  width: 42px;
  height: 42px;
  border-radius: 15px;
  font-size: 21px;
  color: #5f6b84;
  background:
    radial-gradient(circle at 22% 18%, rgba(255,255,255,.9), transparent 24px),
    linear-gradient(180deg, rgba(255,255,255,1), rgba(242,245,252,.96));
  box-shadow:
    0 10px 22px rgba(20, 30, 60, 0.10),
    inset 0 1px 0 rgba(255,255,255,.9);
}

#recordModal .edit-top-btn {
  min-width: 42px;
  font-size: 22px;
}

#recordModal .close-top-btn {
  font-size: 22px;
}

#recordModal .modal-action-btn:hover {
  color: #fff;
}

@media (max-width: 760px) {
  /* 1. 记录事件弹窗加宽：移动端贴满屏幕宽度 */
  #recordModal.modal {
    left: 0;
    right: 0;
    width: 100dvw;
    padding-left: 0;
    padding-right: 0;
  }

  #recordModal .modal-content.wide {
    width: 100dvw !important;
    max-width: 100dvw !important;
    min-width: 100dvw !important;
    margin: 0;
    border-radius: 22px 22px 0 0;
  }

  #recordModal .modal-head,
  #recordModal .record-tabs,
  #recordModal #recordForm,
  #recordModal .record-history,
  #recordModal .record-event-stats {
    box-sizing: border-box;
    width: 100%;
  }

  #recordModal #recordForm {
    padding-left: 14px;
    padding-right: 14px;
  }

  /* 2. 日期框和所有记录输入控件禁止撑出右侧 */
  #recordModal .record-fields,
  #recordModal .rf-item,
  #recordModal .rf-input,
  #recordModal input,
  #recordModal textarea,
  #recordModal select {
    max-width: 100% !important;
    min-width: 0 !important;
    box-sizing: border-box !important;
  }

  #recordModal .rf-item {
    width: 100%;
    overflow: hidden;
  }

  #recordModal .rf-input,
  #recordModal input[type="date"],
  #recordModal input[type="time"],
  #recordModal input[type="number"],
  #recordModal input[type="text"],
  #recordModal select,
  #recordModal textarea {
    display: block;
    width: 100% !important;
  }

  #recordModal input[type="date"],
  #recordModal input[type="time"] {
    -webkit-appearance: none;
    appearance: none;
    padding-right: 10px;
  }

  /* 3. 移动端右上角编辑/关闭按钮继续放大，点击更舒服 */
  #recordModal .modal-actions {
    gap: 8px;
  }

  #recordModal .modal-action-btn {
    width: 40px !important;
    height: 40px !important;
    border-radius: 14px !important;
    font-size: 22px !important;
  }

  #recordModal .edit-top-btn {
    min-width: 40px !important;
    font-size: 23px !important;
  }

  #recordModal .close-top-btn {
    font-size: 23px !important;
  }
}

@media (max-width: 420px) {
  #recordModal #recordForm {
    padding-left: 12px;
    padding-right: 12px;
  }

  #recordModal .record-tabs {
    padding-left: 10px;
    padding-right: 10px;
  }
}

/* ====== v13：桌面记录左右布局、桌面新建事件行布局、移动端按钮继续美化 ====== */

/* 2. 桌面端新建事件：名称/图标/颜色一行，分类/简介一行 */
@media (min-width: 761px) {
  #projectForm {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 118px 118px;
    gap: 14px 12px;
  }

  #projectForm > .project-name-row,
  #projectForm > .project-meta-row,
  #projectForm > .project-desc-row {
    display: contents;
  }

  #projectForm > .project-name-row > label {
    grid-column: 1;
  }

  #projectForm > .project-meta-row > label:nth-child(1) {
    grid-column: 2;
  }

  #projectForm > .project-meta-row > label:nth-child(2) {
    grid-column: 3;
  }

  #projectForm > .project-meta-row > label:nth-child(3) {
    grid-column: 1;
  }

  #projectForm > .project-desc-row > label {
    grid-column: 2 / 4;
  }

  #projectForm > .reminder-set,
  #projectForm > .fields-head,
  #projectForm > .field-list,
  #projectForm > .modal-foot {
    grid-column: 1 / -1;
  }
}

/* 1. 桌面端记录弹窗：左 1/3 填新记录，右 2/3 历史/统计两页 */
@media (min-width: 761px) {
  #recordModal .modal-content.wide {
    width: min(1080px, calc(100vw - 48px));
  }

  #recordModal .record-layout {
    display: grid;
    grid-template-columns: minmax(300px, 1fr) minmax(0, 2fr);
    grid-template-rows: auto minmax(0, 1fr);
    column-gap: 0;
    min-height: 560px;
    max-height: calc(92vh - 64px);
    overflow: hidden;
  }

  #recordModal .record-tabs {
    grid-column: 2;
    grid-row: 1;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    padding: 16px 20px 12px;
    border-left: 1px solid var(--border);
  }

  #recordModal .record-tab[data-record-tab="add"] {
    display: none;
  }

  #recordModal #recordPanelAdd {
    grid-column: 1;
    grid-row: 1 / 3;
    display: block !important;
    min-height: 0;
    border-right: 1px solid var(--border);
    background: #fff;
  }

  #recordModal #recordPanelHistory,
  #recordModal #recordPanelStats {
    grid-column: 2;
    grid-row: 2;
    min-height: 0;
    overflow-y: auto;
  }

  #recordModal #recordPanelHistory:not(.active),
  #recordModal #recordPanelStats:not(.active) {
    display: none !important;
  }

  #recordModal #recordPanelHistory.active,
  #recordModal #recordPanelStats.active {
    display: block !important;
  }

  #recordModal #recordForm {
    min-height: 100%;
    padding: 22px 24px 0;
  }

  #recordModal .record-history,
  #recordModal .record-event-stats {
    padding: 22px 24px;
  }
}

/* 3. 移动端记录事件弹窗与页面同宽，并避免左右空隙 */
@media (max-width: 760px) {
  #recordModal.modal {
    inset: 0;
    width: 100vw;
    max-width: 100vw;
  }

  #recordModal .modal-content.wide {
    width: 100vw !important;
    max-width: 100vw !important;
    min-width: 100vw !important;
    border-left: 0;
    border-right: 0;
  }
}

/* 4. 移动端新建事件右上角关闭按钮同样美化 */
@media (max-width: 760px) {
  #projectModal .modal-head .icon-btn {
    display: inline-grid;
    place-items: center;
    width: 40px;
    height: 40px;
    border: 1px solid rgba(230, 232, 239, 0.96);
    border-radius: 14px;
    color: #5f6b84;
    background:
      radial-gradient(circle at 22% 18%, rgba(255,255,255,.9), transparent 24px),
      linear-gradient(180deg, rgba(255,255,255,1), rgba(242,245,252,.96));
    box-shadow:
      0 10px 22px rgba(20, 30, 60, 0.10),
      inset 0 1px 0 rgba(255,255,255,.9);
    font-size: 23px;
    font-weight: 900;
    line-height: 1;
    transition: all .15s ease;
  }

  #projectModal .modal-head .icon-btn:hover {
    color: #fff;
    border-color: transparent;
    background: linear-gradient(135deg, #ff6b7a, #ff8792);
    box-shadow: 0 12px 24px rgba(255, 93, 108, 0.26);
  }
}

/* 5. 移动端记录事件右上角按钮继续强化 */
#recordModal .modal-action-btn {
  width: 46px;
  height: 46px;
  border-radius: 16px;
  font-size: 24px;
}

#recordModal .edit-top-btn,
#recordModal .close-top-btn {
  font-size: 25px;
}

@media (max-width: 760px) {
  #recordModal .modal-action-btn {
    width: 44px !important;
    height: 44px !important;
    border-radius: 15px !important;
    font-size: 25px !important;
  }

  #recordModal .edit-top-btn,
  #recordModal .close-top-btn {
    font-size: 26px !important;
  }
}

/* ====== v14：桌面端新建项目布局修正 + 关闭按钮统一风格 + PWA 适配 ====== */

/* 1. 桌面端：彻底修正"新建项目"行布局错乱
   思路：放弃外层 grid + display:contents 的方式（会被旧的 .row.project-meta-row
   双类规则覆盖），改为每个 .row 自己是一个独立 grid，列数与列宽显式声明，
   并用 !important 覆盖之前所有版本里的同名规则。 */
@media (min-width: 761px) {
  /* 还原 #projectForm 为普通流式布局，避免被 v13 的 grid 影响 */
  #projectForm.form {
    display: block !important;
    grid-template-columns: none !important;
    gap: 0 !important;
    padding: 22px 24px 4px;
  }

  #projectForm > .row {
    display: grid !important;
    gap: 14px !important;
    margin-bottom: 14px !important;
  }

  /* 名称单独占一行 */
  #projectForm > .row.project-name-row {
    grid-template-columns: 1fr !important;
  }

  /* 第一行：名称 / 图标 / 颜色 —— 但 HTML 中 name 单独成行，
     这里 meta-row 是图标/颜色/分类，按要求改为 [图标 颜色 分类] 共一行 */
  #projectForm > .row.project-meta-row {
    grid-template-columns: 132px 132px minmax(180px, 1fr) !important;
    align-items: end !important;
  }

  /* 分类/简介行 —— 实际 HTML 中只有 description 一个 label，
     按要求把"分类"与"简介"放一行。我们在桌面端把 .project-meta-row 中的
     "分类"label 视觉上保留，再让 .project-desc-row 仅承载"简介"，
     与 reminder 之前形成视觉连续。 */
  #projectForm > .row.project-desc-row {
    grid-template-columns: 1fr !important;
  }

  /* 让图标输入框（emoji 字符）不再溢出 */
  #projectForm > .row.project-meta-row .icon-picker {
    display: flex;
    gap: 8px;
    align-items: center;
  }
  #projectForm > .row.project-meta-row .icon-preview {
    width: 42px;
    height: 42px;
    border-radius: 12px;
    flex: 0 0 auto;
  }
  #projectForm > .row.project-meta-row #iconInput {
    min-width: 0;
    width: 100%;
    height: 42px;
  }

  /* 颜色和下拉与图标对齐高度 */
  #projectForm > .row.project-meta-row input[type="color"],
  #projectForm > .row.project-meta-row select {
    min-height: 42px;
    height: 42px;
    width: 100%;
  }

  /* 强制让 v8 旧的 nth-of-type 规则在桌面端失效 */
  #projectModal #projectForm > .row:nth-of-type(1),
  #projectModal #projectForm > .row:nth-of-type(2) {
    grid-template-columns: revert;
  }
}

/* 2. 桌面端：新建项目右上角关闭按钮统一为与记录弹窗一致的图标按钮 */
@media (min-width: 761px) {
  #projectModal .modal-head .icon-btn {
    display: inline-grid;
    place-items: center;
    width: 42px;
    height: 42px;
    padding: 0;
    border: 1px solid rgba(230, 232, 239, 0.96);
    border-radius: 15px;
    color: #5f6b84;
    background:
      radial-gradient(circle at 22% 18%, rgba(255,255,255,.9), transparent 24px),
      linear-gradient(180deg, rgba(255,255,255,1), rgba(242,245,252,.96));
    box-shadow:
      0 10px 22px rgba(20, 30, 60, 0.10),
      inset 0 1px 0 rgba(255,255,255,.9);
    font-size: 22px;
    font-weight: 900;
    line-height: 1;
    cursor: pointer;
    transition: all .15s ease;
  }

  #projectModal .modal-head .icon-btn:hover {
    color: #fff;
    border-color: transparent;
    transform: translateY(-1px);
    background: linear-gradient(135deg, #ff6b7a, #ff8792);
    box-shadow: 0 12px 24px rgba(255, 93, 108, 0.26);
  }

  #projectModal .modal-head .icon-btn:active {
    transform: translateY(0);
    box-shadow: 0 6px 14px rgba(255, 93, 108, 0.18);
  }
}

/* 3. PWA 安装后浏览器外壳隐藏时，给顶部留出安全区 */
@media (display-mode: standalone) {
  body {
    padding-top: env(safe-area-inset-top);
    padding-bottom: env(safe-area-inset-bottom);
  }
}

