*, *::before, *::after { box-sizing: border-box; }

/* hidden 属性必须能压过 display:flex/grid */
[hidden] { display: none !important; }


:root {
  --bg: #FDF6F0;
  --bg-grad: radial-gradient(120% 80% at 50% 0%, #FFF3E8 0%, #FDF6F0 45%, #F8F1F5 100%);
  --card: #FFFFFF;
  --ink: #2F2A33;
  --ink-2: #6B6470;
  --ink-3: #A69FA9;
  --line: #F0E7E0;
  --brand: #F5833C;
  --brand-deep: #E06A22;
  --danger: #E5544B;
  --ok: #55B97F;
  --shadow: 0 6px 20px rgba(122, 96, 76, .09), 0 1px 3px rgba(122, 96, 76, .06);
  --shadow-lg: 0 18px 50px rgba(90, 60, 40, .18);
  --radius: 20px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --content-max: 1400px;
  --gutter: 20px;
}

html, body { height: 100%; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans SC", sans-serif;
  color: var(--ink);
  background: var(--bg-grad);
  background-attachment: fixed;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior-y: contain;
}

/* ---------------- 顶栏 ---------------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  background: linear-gradient(180deg, rgba(253, 246, 240, .96), rgba(253, 246, 240, .78));
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

.topbar-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  max-width: var(--content-max);
  margin: 0 auto;
  padding: 14px var(--gutter) 10px;
}

.top-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 0 0 auto;
}

.today {
  font-size: 14px;
  font-weight: 500;
  color: var(--ink-2);
  white-space: nowrap;
  letter-spacing: .2px;
  padding-right: 2px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 9px;
  font-size: 19px;
  font-weight: 700;
  letter-spacing: .3px;
}

.brand-dot {
  width: 10px; height: 10px; border-radius: 50%;
  background: var(--brand);
  box-shadow: 0 0 0 4px rgba(245, 131, 60, .16);
}

.icon-btn {
  width: 40px; height: 40px;
  display: grid; place-items: center;
  border: 0; border-radius: 12px;
  background: rgba(255, 255, 255, .7);
  color: var(--ink-2);
  font-size: 19px;
  cursor: pointer;
  transition: transform .15s ease, background .15s ease;
}
.icon-btn:active { transform: scale(.94); background: #fff; }

/* ---------------- 成员条 ---------------- */
.members {
  display: flex;
  gap: 10px;
  max-width: var(--content-max);
  margin: 0 auto;
  padding: 6px var(--gutter) 14px;
  overflow-x: auto;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}
.members::-webkit-scrollbar { display: none; }

.member {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 7px 15px 7px 7px;
  border-radius: 999px;
  background: rgba(255, 255, 255, .62);
  border: 1.5px solid transparent;
  cursor: pointer;
  transition: all .2s ease;
  user-select: none;
}

.member .avatar {
  width: 36px; height: 36px;
  border-radius: 50%;
  display: grid; place-items: center;
  overflow: hidden;
  font-size: 14px;
  font-weight: 700;
  color: #fff;
  flex: 0 0 auto;
  background: var(--brand);
}
.member .avatar img { width: 100%; height: 100%; object-fit: cover; display: block; }

.member .mname {
  font-size: 15px;
  font-weight: 600;
  color: var(--ink-2);
  white-space: nowrap;
  max-width: 120px;
  overflow: hidden;
  text-overflow: ellipsis;
}

.member.active {
  background: #fff;
  border-color: var(--brand);
  box-shadow: 0 4px 14px rgba(245, 131, 60, .18);
}
.member.active .mname { color: var(--brand-deep); }

.member.add-member {
  padding: 8px 14px;
  color: var(--ink-3);
  font-size: 14px;
  border: 1.5px dashed #DCD1C8;
}

/* ---------------- 列表 ---------------- */
.list {
  max-width: var(--content-max);
  margin: 0 auto;
  padding: 4px var(--gutter) calc(120px + var(--safe-b));
}

/* ---------------- 成员分组 ---------------- */
.group {
  margin-bottom: 26px;
  scroll-margin-top: 130px;
}

.group-head {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 0 4px 11px;
}

.group-head .avatar {
  width: 40px; height: 40px;
  border-radius: 50%;
  display: grid; place-items: center;
  overflow: hidden;
  flex: 0 0 auto;
  font-size: 15px;
  font-weight: 700;
  color: #fff;
  box-shadow: 0 3px 8px rgba(0, 0, 0, .08);
}
.group-head .avatar img { width: 100%; height: 100%; object-fit: cover; display: block; }

.group-name {
  font-size: 17.5px;
  font-weight: 700;
  letter-spacing: .2px;
}

.group-count {
  font-size: 12.5px;
  color: var(--ink-3);
  padding-top: 3px;
}

.group-add {
  margin-left: auto;
  width: 36px; height: 36px;
  flex: 0 0 auto;
  border: 0;
  border-radius: 50%;
  background: rgba(245, 131, 60, .13);
  color: var(--brand-deep);
  font-size: 21px;
  line-height: 1;
  cursor: pointer;
  display: grid; place-items: center;
  transition: transform .15s ease, background .15s ease;
}
.group-add:active { transform: scale(.92); background: rgba(245, 131, 60, .26); }

.group-items {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.group-empty {
  padding: 16px 18px;
  border-radius: 16px;
  border: 1.5px dashed #EFE4DB;
  background: rgba(255, 255, 255, .45);
  color: var(--ink-3);
  font-size: 14px;
  text-align: center;
}

.item {
  display: flex;
  align-items: flex-start;
  gap: 13px;
  padding: 17px 18px;
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  cursor: pointer;
  user-select: none;
  touch-action: pan-y;
  transition: transform .12s ease, box-shadow .2s ease, opacity .2s ease;
  position: relative;
  overflow: hidden;
}
.item:active { transform: scale(.985); }

.item .check {
  width: 26px; height: 26px;
  flex: 0 0 auto;
  margin-top: 1px;
  border-radius: 50%;
  border: 2px solid #E4D9D0;
  display: grid; place-items: center;
  color: transparent;
  font-size: 15px;
  font-weight: 700;
  transition: all .18s ease;
}

.item .text {
  flex: 1 1 auto;
  font-size: 18px;
  line-height: 1.45;
  word-break: break-word;
  transition: color .2s ease;
}

.item .meta {
  flex: 0 0 auto;
  font-size: 12px;
  color: var(--ink-3);
  padding-top: 5px;
}

.item.done { opacity: .55; }
.item.done .check {
  background: var(--ok);
  border-color: var(--ok);
  color: #fff;
}
.item.done .text {
  text-decoration: line-through;
  text-decoration-thickness: 1.5px;
  color: var(--ink-3);
}

/* 长按视觉反馈 */
.item.pressing { box-shadow: 0 0 0 3px rgba(245, 131, 60, .22), var(--shadow); }

/* 清除已完成 */
.clear-done {
  align-self: center;
  margin: 4px auto 8px;
  padding: 10px 20px;
  font-size: 14px;
  color: var(--ink-3);
  background: rgba(255, 255, 255, .55);
  border-radius: 999px;
  cursor: pointer;
  user-select: none;
  transition: background .18s ease;
}
.clear-done:active { background: #fff; }

/* ---------------- 空态 ---------------- */
.empty {
  text-align: center;
  padding: 60px 20px 120px;
  color: var(--ink-3);
}
.empty-emoji { font-size: 46px; margin-bottom: 10px; }
.empty p { margin: 4px 0; font-size: 16px; }
.empty-sub { font-size: 14px !important; color: #C3BAB3; }

/* ---------------- 悬浮按钮 ---------------- */
.fab {
  position: fixed;
  right: 24px;
  bottom: calc(26px + var(--safe-b));
  width: 62px; height: 62px;
  border: 0;
  border-radius: 50%;
  background: linear-gradient(145deg, #F98F4D, var(--brand-deep));
  color: #fff;
  font-size: 32px;
  line-height: 1;
  font-weight: 300;
  box-shadow: 0 12px 26px rgba(224, 106, 34, .34);
  cursor: pointer;
  z-index: 40;
  transition: transform .16s ease;
  display: grid; place-items: center;
}
.fab:active { transform: scale(.92); }

/* ---------------- 弹窗 ---------------- */
.mask {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: rgba(48, 38, 32, .42);
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 0;
  animation: fadeIn .18s ease;
}
@keyframes fadeIn { from { opacity: 0 } to { opacity: 1 } }

.modal {
  width: 100%;
  max-width: 520px;
  background: #fff;
  border-radius: 24px 24px 0 0;
  padding: 26px 22px calc(22px + var(--safe-b));
  box-shadow: var(--shadow-lg);
  animation: slideUp .24s cubic-bezier(.22, .9, .3, 1);
}
@keyframes slideUp { from { transform: translateY(30px); opacity: 0 } to { transform: none; opacity: 1 } }

.modal h3 {
  margin: 0 0 6px;
  font-size: 19px;
  font-weight: 700;
}
.modal-tip {
  margin: 0 0 16px;
  font-size: 14px;
  color: var(--ink-2);
  line-height: 1.6;
  word-break: break-word;
}

.input {
  width: 100%;
  padding: 15px 16px;
  font-size: 17px;
  font-family: inherit;
  color: var(--ink);
  background: #FAF5F1;
  border: 1.5px solid #EEE3DA;
  border-radius: 14px;
  outline: none;
  transition: border-color .18s ease, background .18s ease;
}
.input:focus { border-color: var(--brand); background: #fff; }

.input-row { display: flex; gap: 10px; align-items: center; }
.mic-btn {
  flex: 0 0 auto;
  width: 50px; height: 50px;
  border: 1.5px solid #EEE3DA;
  background: #FAF5F1;
  border-radius: 14px;
  font-size: 20px;
  cursor: pointer;
  transition: all .18s ease;
}
.mic-btn.listening {
  background: var(--brand);
  border-color: var(--brand);
  color: #fff;
  animation: pulse 1.2s infinite;
}
@keyframes pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(245, 131, 60, .4) }
  50% { box-shadow: 0 0 0 10px rgba(245, 131, 60, 0) }
}

.btns {
  display: flex;
  gap: 10px;
  margin-top: 20px;
}
.btn {
  flex: 1;
  padding: 14px 16px;
  font-size: 16px;
  font-weight: 600;
  font-family: inherit;
  border: 0;
  border-radius: 14px;
  cursor: pointer;
  transition: all .16s ease;
}
.btn:active { transform: scale(.97); }
.btn.primary { background: var(--brand); color: #fff; box-shadow: 0 6px 16px rgba(245, 131, 60, .28); }
.btn.ghost { background: #F3EDE8; color: var(--ink-2); }
.btn.danger { background: var(--danger); color: #fff; }

/* 历史记录 */
.hist-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 14px;
  max-height: 46vh;
  overflow-y: auto;
  padding: 2px;
}

.hist-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  background: #FAF5F1;
  border-radius: 14px;
}

.hist-main { flex: 1 1 auto; min-width: 0; }

.hist-text {
  font-size: 15px;
  font-weight: 600;
  color: var(--ink);
  word-break: break-word;
  line-height: 1.4;
}
.hist-text.done { text-decoration: line-through; color: var(--ink-3); font-weight: 500; }

.hist-meta {
  font-size: 12px;
  color: var(--ink-3);
  margin-top: 3px;
}

.hist-restore {
  flex: 0 0 auto;
  padding: 7px 13px;
  font-size: 13px;
  font-family: inherit;
  color: var(--brand-deep);
  background: #fff;
  border: 1px solid #F0DFCE;
  border-radius: 10px;
  cursor: pointer;
  transition: background .15s ease;
}
.hist-restore:active { background: #FFF3E8; }

.hist-empty {
  padding: 34px 0;
  text-align: center;
  color: var(--ink-3);
  font-size: 14px;
}

/* 成员选择弹窗 */
.pick-list {
  display: flex;
  flex-direction: column;
  gap: 9px;
  margin-top: 6px;
  max-height: 52vh;
  overflow-y: auto;
  padding: 2px;
}
.pick-row {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 12px 14px;
  border: 0;
  border-radius: 14px;
  background: #FAF5F1;
  cursor: pointer;
  font-family: inherit;
  text-align: left;
  transition: background .15s ease;
}
.pick-row:active { background: #F2E8DF; }
.pick-row .avatar {
  width: 40px; height: 40px;
  border-radius: 50%;
  display: grid; place-items: center;
  color: #fff; font-weight: 700; font-size: 15px;
  overflow: hidden; flex: 0 0 auto;
}
.pick-row .avatar img { width: 100%; height: 100%; object-fit: cover; display: block; }
.pick-name { font-size: 16px; font-weight: 600; color: var(--ink); }
.pick-count { margin-left: auto; font-size: 12.5px; color: var(--ink-3); }

/* 成员管理列表 */
.member-editor { display: flex; flex-direction: column; gap: 10px; margin-top: 4px; max-height: 46vh; overflow-y: auto; padding: 2px; }
.me-row {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 12px;
  background: #FAF5F1;
  border-radius: 14px;
}
.me-row .avatar {
  width: 44px; height: 44px; border-radius: 50%;
  display: grid; place-items: center;
  color: #fff; font-weight: 700; font-size: 16px;
  overflow: hidden; cursor: pointer; flex: 0 0 auto;
  position: relative;
}
.me-row .avatar img { width: 100%; height: 100%; object-fit: cover; display: block; }
.me-row .avatar::after {
  content: "改"; position: absolute; inset: auto 0 0 0;
  font-size: 10px; background: rgba(0, 0, 0, .38);
  color: #fff; padding: 1px 0; text-align: center;
  opacity: 0; transition: opacity .2s;
}
.me-row .avatar:hover::after { opacity: 1; }
.me-row .name {
  flex: 1; font-size: 16px; font-weight: 600;
  background: transparent; border: 0; outline: none;
  font-family: inherit; color: var(--ink);
  padding: 6px 4px;
  border-radius: 8px;
}
.me-row .name:focus { background: #fff; box-shadow: 0 0 0 1.5px var(--brand); }
.me-row .del {
  border: 0; background: transparent; color: var(--danger);
  font-size: 14px; cursor: pointer; padding: 8px;
  border-radius: 8px;
}
.me-row .del:disabled { color: #D8D0C9; cursor: not-allowed; }

/* ---------------- Toast ---------------- */
.toast {
  position: fixed;
  left: 50%;
  bottom: calc(110px + var(--safe-b));
  transform: translateX(-50%) translateY(10px);
  background: rgba(47, 42, 51, .92);
  color: #fff;
  font-size: 14.5px;
  padding: 11px 20px;
  border-radius: 999px;
  z-index: 200;
  opacity: 0;
  transition: opacity .2s ease, transform .2s ease;
  pointer-events: none;
  max-width: 86vw;
  text-align: center;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ---------------- 触屏优化 ---------------- */
@media (hover: none) {
  .item:hover { transform: none; }
}

/* ---------------- 平板 / 宽屏：多列 ---------------- */
@media (min-width: 820px) {
  :root { --gutter: 30px; }

  .list {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 26px;
    align-items: start;
  }
  .group { margin-bottom: 0; }

  .item .text { font-size: 19px; }
  .fab { right: 34px; bottom: 34px; }
}

@media (min-width: 1400px) {
  :root { --gutter: 36px; }
  .list { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg-grad: radial-gradient(120% 80% at 50% 0%, #2B2420 0%, #201B1A 45%, #1A1618 100%);
    --card: #2A2426;
    --ink: #F1E9E3;
    --ink-2: #B7ABA3;
    --ink-3: #83776F;
    --line: #382F2B;
    --shadow: 0 6px 20px rgba(0, 0, 0, .35);
  }
  .topbar { background: linear-gradient(180deg, rgba(32, 27, 26, .96), rgba(32, 27, 26, .75)); }
  .member { background: rgba(255, 255, 255, .07); }
  .member.active { background: #332B2D; }
  .member.add-member { border-color: #443A36; }
  .icon-btn { background: rgba(255, 255, 255, .08); }
  .item .check { border-color: #443A36; }
  .modal { background: #342D2F; box-shadow: 0 -8px 40px rgba(0, 0, 0, .55); }
  .input, .mic-btn { background: #2E2729; border-color: #3C3335; color: var(--ink); }
  .me-row { background: #2E2729; }
  .me-row .name { color: var(--ink); }
  .btn.ghost { background: #332C2E; color: var(--ink-2); }
  .clear-done { background: rgba(255, 255, 255, .08); }
  .pick-row { background: #2E2729; }
  .group-empty { background: rgba(255, 255, 255, .05); border-color: #443A36; }
  .group-add { background: rgba(245, 131, 60, .2); }
  .hist-row { background: #2E2729; }
  .hist-restore { background: #332C2E; border-color: #443A36; }
}
