/* ============================================================
   styles.css —— 手机优先的界面样式（深色 / 浅色自动切换）
   ============================================================ */

* {
  box-sizing: border-box;
}

/* 关键：让 [hidden] 在任何 display 设置下都能真正隐藏 */
[hidden] {
  display: none !important;
}

:root {
  color-scheme: dark;
  --bg: #0e1016;
  --card: #181d28;
  --card-2: #1f2532;
  --line: #272e3e;
  --text: #e9ecf4;
  --muted: #8b94aa;
  --accent: #7c8cff;
  --accent-soft: rgba(124, 140, 255, 0.16);
  --danger: #ff6b6b;
  --ok: #34d399;
  --shadow: 0 12px 28px rgba(0, 0, 0, 0.45);
  --r: 18px;
  --tabbar: 62px;
  --sheet-bg: #141924;
}

@media (prefers-color-scheme: light) {
  :root {
    color-scheme: light;
    --bg: #f4f6fb;
    --card: #ffffff;
    --card-2: #f1f4fa;
    --line: #e3e8f3;
    --text: #131826;
    --muted: #65708a;
    --accent: #5468ff;
    --accent-soft: rgba(84, 104, 255, 0.12);
    --danger: #e5484d;
    --shadow: 0 10px 24px rgba(23, 32, 64, 0.1);
    --sheet-bg: #ffffff;
  }
}

html,
body {
  margin: 0;
  padding: 0;
}

body {
  background: var(--bg);
  color: var(--text);
  font: 16px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  min-height: 100dvh;
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior-y: contain;
}

h1,
h2,
h3,
p,
ul {
  margin: 0;
}

ul {
  list-style: none;
  padding: 0;
}

button {
  font: inherit;
  color: inherit;
  border: 0;
  background: none;
  cursor: pointer;
  touch-action: manipulation;
}

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

.app {
  max-width: 620px;
  margin: 0 auto;
  padding: calc(env(safe-area-inset-top, 0px) + 10px) 14px
    calc(var(--tabbar) + env(safe-area-inset-bottom, 0px) + 26px);
}

/* ---------------- 顶栏 ---------------- */

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 6px 2px 14px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.brand-logo {
  width: 38px;
  height: 38px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  font-size: 20px;
  font-weight: 700;
  color: #fff;
  background: linear-gradient(160deg, #6d7dff, #a855f7);
  box-shadow: 0 6px 16px rgba(109, 125, 255, 0.35);
  flex: none;
}

.brand-text h1 {
  font-size: 18px;
  font-weight: 700;
  letter-spacing: 0.2px;
}

.brand-text p {
  font-size: 12.5px;
  color: var(--muted);
  margin-top: 1px;
}

.icon-btn {
  width: 38px;
  height: 38px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  font-size: 18px;
  color: var(--muted);
  background: var(--card);
  border: 1px solid var(--line);
  flex: none;
}
.icon-btn:active {
  transform: scale(0.94);
}

/* ---------------- 主内容 ---------------- */

.view {
  display: block;
  animation: fade 0.18s ease;
}

@keyframes fade {
  from {
    opacity: 0;
    transform: translateY(4px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

.section-note {
  font-size: 12.5px;
  color: var(--muted);
  padding: 0 4px 10px;
  line-height: 1.6;
}

.empty {
  text-align: center;
  color: var(--muted);
  font-size: 14px;
  padding: 42px 20px;
  border: 1px dashed var(--line);
  border-radius: var(--r);
  line-height: 1.8;
}

/* ---------------- 待办卡片（主页面） ---------------- */

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

.card {
  position: relative;
  display: flex;
  align-items: flex-start;
  gap: 11px;
  padding: 13px 12px 13px 13px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--r);
  transition: background 0.15s, opacity 0.15s, transform 0.1s;
}

.card:active {
  transform: scale(0.995);
}

/* 提醒到点 / 已逾期：整张卡高亮 */
.card.attention {
  border-color: rgba(251, 191, 36, 0.75);
  box-shadow: 0 0 0 1px rgba(251, 191, 36, 0.35), 0 8px 22px rgba(251, 191, 36, 0.14);
  animation: pulse 2.4s ease-in-out infinite;
}
.card.attention::after {
  content: "该做了";
  position: absolute;
  top: -8px;
  right: 12px;
  font-size: 10.5px;
  font-weight: 700;
  color: #1a1200;
  background: #fbbf24;
  padding: 1px 7px;
  border-radius: 8px;
}

@keyframes pulse {
  0%,
  100% {
    box-shadow: 0 0 0 1px rgba(251, 191, 36, 0.3), 0 8px 22px rgba(251, 191, 36, 0.1);
  }
  50% {
    box-shadow: 0 0 0 2px rgba(251, 191, 36, 0.55), 0 8px 26px rgba(251, 191, 36, 0.24);
  }
}

.card.is-done {
  opacity: 0.55;
}
.card.is-done .title {
  text-decoration: line-through;
  text-decoration-color: var(--muted);
}

.check {
  width: 24px;
  height: 24px;
  margin-top: 2px;
  border-radius: 50%;
  border: 2px solid var(--line);
  display: grid;
  place-items: center;
  flex: none;
  color: transparent;
  font-size: 13px;
  font-weight: 900;
  background: transparent;
  transition: 0.15s;
}
.card.is-done .check,
.sitem.is-done .check {
  background: var(--ok);
  border-color: var(--ok);
  color: #06241a;
}

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

.chips {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px;
  margin-bottom: 4px;
}

/* 时段标签和重要程度标签共用同一个盒子：同高、同内边距、不随 flex 拉伸 */
.chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  align-self: center;
  height: 14px;
  min-height: 14px;
  max-height: 14px;
  padding: 0 6px;
  border-radius: 6px;
  font-size: 10px;
  font-weight: 700;
  line-height: 1;
  white-space: nowrap;
}
.chip.period {
  color: var(--c, #fbbf24);
  background: color-mix(in srgb, var(--c, #fbbf24) 16%, transparent);
  border: 1px solid color-mix(in srgb, var(--c, #fbbf24) 42%, transparent);
}
.chip.quad {
  color: var(--c, #94a3b8);
  background: color-mix(in srgb, var(--c, #94a3b8) 14%, transparent);
  border: 1px solid color-mix(in srgb, var(--c, #94a3b8) 38%, transparent);
}
.chip.warn {
  color: #fbbf24;
  background: rgba(251, 191, 36, 0.14);
  border: 1px solid rgba(251, 191, 36, 0.4);
}
.chip.over {
  color: #ff6b6b;
  background: rgba(255, 107, 107, 0.13);
  border: 1px solid rgba(255, 107, 107, 0.4);
}

.title {
  font-size: 15.5px;
  font-weight: 600;
  line-height: 1.45;
  word-break: break-word;
}

.note {
  font-size: 13px;
  color: var(--muted);
  margin-top: 3px;
  line-height: 1.55;
  white-space: pre-wrap;
  word-break: break-word;
}

.metas {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 10px;
  margin-top: 6px;
}
.meta {
  font-size: 11.5px;
  color: var(--muted);
  display: inline-flex;
  align-items: center;
  gap: 3px;
}
.meta.over {
  color: var(--danger);
  font-weight: 600;
}

.card-actions {
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex: none;
}
.mini-btn {
  width: 28px;
  height: 26px;
  border-radius: 9px;
  display: grid;
  place-items: center;
  font-size: 13px;
  color: var(--muted);
  background: var(--card-2);
}
.mini-btn:active {
  transform: scale(0.92);
}
.mini-btn.del:active {
  color: var(--danger);
}

/* ---------------- 通用：底部导航 + 加号 ---------------- */

.tabbar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 30;
  display: flex;
  justify-content: center;
  gap: 6px;
  padding: 6px 10px calc(env(safe-area-inset-bottom, 0px) + 6px);
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(14px);
  border-top: 1px solid var(--line);
}
.tabbar a {
  flex: 1;
  max-width: 160px;
  text-decoration: none;
  color: var(--muted);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1px;
  padding: 5px 0;
  border-radius: 12px;
  font-size: 11.5px;
  line-height: 1.3;
}
.tabbar a b {
  font-size: 19px;
  filter: grayscale(0.55);
  opacity: 0.75;
  transition: 0.15s;
}
.tabbar a[aria-current="page"] {
  color: var(--accent);
  background: var(--accent-soft);
}
.tabbar a[aria-current="page"] b {
  filter: none;
  opacity: 1;
}

.fab {
  position: fixed;
  right: max(16px, calc(50% - 310px + 16px));
  bottom: calc(var(--tabbar) + env(safe-area-inset-bottom, 0px) + 16px);
  width: 54px;
  height: 54px;
  border-radius: 50%;
  z-index: 31;
  display: grid;
  place-items: center;
  font-size: 27px;
  font-weight: 300;
  color: #fff;
  background: linear-gradient(160deg, #6d7dff, #a855f7);
  box-shadow: 0 10px 24px rgba(109, 125, 255, 0.45);
}
.fab:active {
  transform: scale(0.94);
}

/* ---------------- 日程表 ---------------- */

.day-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 8px 10px;
  margin-bottom: 12px;
}
.day-nav .center {
  text-align: center;
  flex: 1;
}
.day-nav .d1 {
  font-size: 15px;
  font-weight: 700;
}
.day-nav .d2 {
  font-size: 11.5px;
  color: var(--muted);
  margin-top: 1px;
}
.day-nav button {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  background: var(--card-2);
  color: var(--muted);
  font-size: 15px;
  flex: none;
}
.day-nav .today-btn {
  width: auto;
  padding: 0 10px;
  font-size: 12px;
  font-weight: 700;
  color: var(--accent);
}

.timeline {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.block {
  border-radius: var(--r);
  background: var(--card);
  border: 1px solid var(--line);
  border-left: 3px solid var(--c, #fbbf24);
  overflow: hidden;
}
.block-head {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  line-height: 1.4;
  background: color-mix(in srgb, var(--c, #fbbf24) 11%, transparent);
}
.block-head .name {
  font-size: 12px;
  font-weight: 800;
  color: var(--c, #fbbf24);
}
.block-head .range {
  font-size: 10.5px;
  color: var(--muted);
}
.block-head .count {
  margin-left: auto;
  font-size: 10.5px;
  color: var(--muted);
  background: var(--card-2);
  padding: 0 7px;
  border-radius: 7px;
}
.block-body {
  display: flex;
  flex-direction: column;
}
.sitem {
  display: flex;
  align-items: flex-start;
  gap: 9px;
  padding: 9px 11px;
  border-top: 1px solid var(--line);
}
.sitem:first-child {
  border-top: 0;
}
.sitem.attention {
  background: rgba(251, 191, 36, 0.08);
  box-shadow: inset 3px 0 0 #fbbf24;
}
.sitem.is-done {
  opacity: 0.5;
}
/* 「每 N 天」但今天不是它的日子：变淡但仍然在 */
.sitem.is-offday {
  opacity: 0.5;
}
.sitem.is-offday .s-title {
  font-weight: 500;
}
.sitem.is-done .s-title {
  text-decoration: line-through;
}
.sitem .check {
  margin-top: 1px;
}
.sitem-main {
  flex: 1;
  min-width: 0;
}
.s-title {
  font-size: 14.5px;
  font-weight: 600;
  word-break: break-word;
}
.s-note {
  font-size: 12px;
  color: var(--muted);
  margin-top: 2px;
  word-break: break-word;
}
.s-time {
  display: inline-flex;
  align-items: center;
  height: 14px;
  font-size: 10px;
  font-weight: 700;
  color: var(--c, #fbbf24);
  background: color-mix(in srgb, var(--c, #fbbf24) 14%, transparent);
  padding: 0 6px;
  border-radius: 6px;
  line-height: 1;
  white-space: nowrap;
  margin-top: 1px;
}

/* ---------------- 四象限 ---------------- */

.quad-top {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  padding: 0 4px 10px;
  gap: 8px;
}
.quad-top .t {
  font-size: 13px;
  color: var(--muted);
}
.quad-top .t b {
  color: var(--text);
  font-size: 16px;
}

.quad-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  align-items: start;
}

.quad {
  border-radius: 16px;
  background: var(--card);
  border: 1px solid var(--line);
  border-top: 3px solid var(--c, #94a3b8);
  padding: 10px;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.quad-head {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}
.quad-name {
  font-size: 12.5px;
  font-weight: 800;
  color: var(--c, #94a3b8);
}
.quad-hint {
  font-size: 10.5px;
  color: var(--muted);
  background: var(--card-2);
  padding: 1px 6px;
  border-radius: 6px;
}
.quad-score {
  margin-left: auto;
  font-size: 11px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}
.bar {
  height: 4px;
  border-radius: 4px;
  background: var(--card-2);
  overflow: hidden;
}
.bar i {
  display: block;
  height: 100%;
  border-radius: 4px;
  background: var(--c, #94a3b8);
  transition: width 0.3s;
}
.quad-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.qitem {
  display: flex;
  align-items: flex-start;
  gap: 7px;
  padding: 6px 7px;
  border-radius: 10px;
  background: var(--card-2);
  border-left: 3px solid var(--c, #94a3b8);
}
.qitem .check {
  width: 18px;
  height: 18px;
  border-width: 2px;
  font-size: 10px;
  margin-top: 1px;
}
.qitem.is-done {
  opacity: 0.5;
}
.qitem.is-done .q-title {
  text-decoration: line-through;
}
.qitem-main {
  flex: 1;
  min-width: 0;
}
.q-title {
  font-size: 12.5px;
  font-weight: 600;
  line-height: 1.4;
  word-break: break-word;
}
.q-sub {
  font-size: 10.5px;
  color: var(--muted);
  margin-top: 1px;
}
.quad.empty-cell .quad-list {
  color: var(--muted);
  font-size: 11.5px;
}

.axis {
  display: flex;
  justify-content: space-between;
  font-size: 11px;
  color: var(--muted);
  padding: 10px 4px 0;
}

/* ---------------- 弹窗（底部抽屉） ---------------- */

dialog.sheet {
  position: fixed;
  inset: auto 0 0 0;
  width: 100%;
  max-width: 620px;
  margin: 0 auto;
  max-height: 92dvh;
  padding: 0;
  border: 0;
  border-top-left-radius: 22px;
  border-top-right-radius: 22px;
  background: var(--sheet-bg);
  color: var(--text);
  box-shadow: var(--shadow);
  overflow: hidden;
}
dialog.sheet[open] {
  display: flex;
  flex-direction: column;
  animation: slideup 0.22s ease;
}
@keyframes slideup {
  from {
    transform: translateY(26px);
    opacity: 0.6;
  }
  to {
    transform: none;
    opacity: 1;
  }
}
dialog.sheet::backdrop {
  background: rgba(6, 9, 16, 0.6);
  backdrop-filter: blur(3px);
}

.sheet-head {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 14px 16px 10px;
  border-bottom: 1px solid var(--line);
  flex: none;
}
.sheet-head h2 {
  font-size: 16px;
  font-weight: 700;
  flex: 1;
}
.sheet-scroll {
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  flex: 1;
}
.sheet-foot {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 16px calc(env(safe-area-inset-bottom, 0px) + 12px);
  border-top: 1px solid var(--line);
  background: var(--sheet-bg);
  flex: none;
}
.sheet-foot .spacer {
  flex: 1;
}

/* ---------------- 表单 ---------------- */

.field {
  display: flex;
  flex-direction: column;
  gap: 7px;
}
.field > .label {
  font-size: 12.5px;
  font-weight: 700;
  color: var(--muted);
  letter-spacing: 0.3px;
  display: flex;
  align-items: center;
  gap: 6px;
}
.field .hint {
  font-size: 11.5px;
  color: var(--muted);
  line-height: 1.5;
}

.input,
.textarea {
  width: 100%;
  background: var(--card-2);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 11px 12px;
  outline: none;
  font-size: 15px;
  min-height: 44px;
}
.input:focus,
.textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.textarea {
  min-height: 66px;
  resize: vertical;
  line-height: 1.55;
}
.input[type="number"] {
  width: 84px;
  text-align: center;
}

.seg {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.seg button {
  padding: 8px 12px;
  border-radius: 11px;
  background: var(--card-2);
  border: 1px solid var(--line);
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
  flex: 1 0 auto;
  min-height: 40px;
  transition: 0.14s;
}
.seg button.on {
  color: #fff;
  border-color: transparent;
  background: var(--c, var(--accent));
  box-shadow: 0 4px 14px color-mix(in srgb, var(--c, var(--accent)) 40%, transparent);
}

.quad-pick {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 7px;
}
.quad-pick button {
  text-align: left;
  padding: 5px 10px;
  border-radius: 12px;
  background: var(--card-2);
  border: 1.5px solid var(--line);
  min-height: 40px;
}
.quad-pick button .n {
  font-size: 12.5px;
  line-height: 1.35;
  font-weight: 700;
  color: var(--text);
  display: block;
}
.quad-pick button .h {
  font-size: 10px;
  line-height: 1.3;
  color: var(--muted);
}
.quad-pick button.on {
  border-color: var(--c, var(--accent));
  background: color-mix(in srgb, var(--c, var(--accent)) 13%, transparent);
}
.quad-pick button.on .h {
  color: var(--c, var(--accent));
  font-weight: 700;
}

.row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.row .unit {
  font-size: 13px;
  color: var(--muted);
}

.time-row {
  display: flex;
  align-items: center;
  gap: 8px;
}
.time-row .input {
  flex: 1;
  min-width: 0;
}
.time-row .dash {
  color: var(--muted);
}

/* 开关 */
.switch {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 12px;
  background: var(--card-2);
  border: 1px solid var(--line);
  border-radius: 12px;
  width: 100%;
}
.switch .st {
  font-size: 13.5px;
  font-weight: 600;
}
.switch .sd {
  font-size: 11.5px;
  color: var(--muted);
  margin-top: 1px;
  line-height: 1.45;
}
.toggle {
  width: 46px;
  height: 27px;
  border-radius: 20px;
  background: var(--line);
  position: relative;
  flex: none;
  transition: 0.18s;
}
.toggle::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 21px;
  height: 21px;
  border-radius: 50%;
  background: #fff;
  transition: 0.18s;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
}
.toggle.on {
  background: var(--accent);
}
.toggle.on::after {
  transform: translateX(19px);
}

/* 按钮 */
.btn {
  padding: 11px 18px;
  border-radius: 12px;
  font-size: 14.5px;
  font-weight: 700;
  min-height: 44px;
  background: var(--card-2);
  border: 1px solid var(--line);
  color: var(--text);
}
.btn:active {
  transform: scale(0.975);
}
.btn.primary {
  color: #fff;
  border-color: transparent;
  background: linear-gradient(160deg, #6d7dff, #8b5cf6);
  box-shadow: 0 6px 18px rgba(109, 125, 255, 0.35);
}
.btn.danger {
  color: var(--danger);
}
.btn.ghost {
  background: transparent;
}
.btn[disabled] {
  opacity: 0.45;
}

/* 菜单列表 */
.menu-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.menu-item {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 13px 14px;
  border-radius: 13px;
  background: var(--card-2);
  border: 1px solid var(--line);
  text-align: left;
  width: 100%;
  font-size: 14.5px;
}
.menu-item .ic {
  font-size: 18px;
  width: 22px;
  text-align: center;
}
.menu-item .tx {
  flex: 1;
  min-width: 0;
}
.menu-item .tx b {
  font-weight: 600;
}
.menu-item .tx small {
  display: block;
  font-size: 11.5px;
  color: var(--muted);
  margin-top: 1px;
  line-height: 1.45;
}
.menu-item .chev {
  color: var(--muted);
  font-size: 14px;
}

/* 提示条 */
.tipbar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 13px;
  border-radius: 13px;
  background: var(--accent-soft);
  border: 1px solid color-mix(in srgb, var(--accent) 35%, transparent);
  margin-bottom: 12px;
  font-size: 12.5px;
  line-height: 1.55;
}
.tipbar .btn {
  padding: 7px 12px;
  min-height: 34px;
  font-size: 12.5px;
  flex: none;
}

/* 轻提示 */
.toast {
  position: fixed;
  left: 50%;
  bottom: calc(var(--tabbar) + env(safe-area-inset-bottom, 0px) + 22px);
  transform: translate(-50%, 12px);
  z-index: 99;
  background: #0b0e15;
  color: #fff;
  font-size: 13.5px;
  padding: 10px 16px;
  border-radius: 12px;
  box-shadow: var(--shadow);
  opacity: 0;
  transition: 0.2s;
  pointer-events: none;
  max-width: 88vw;
  text-align: center;
}
.toast.show {
  opacity: 1;
  transform: translate(-50%, 0);
}

@media (max-width: 360px) {
  .quad-grid {
    grid-template-columns: 1fr;
  }
  .brand-text h1 {
    font-size: 16.5px;
  }
}
