:root {
  --accent: #4a90d9;
  --bg: #f2f2f7;
  --card: #ffffff;
  --text: #1c1c1e;
  --muted: #8e8e93;
  --sep: #e5e5ea;
  --green: #34c759;
  --red: #ff3b30;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "PingFang SC", "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}

.hidden { display: none !important; }

/* ---------- 登录 ---------- */
.login {
  position: fixed; inset: 0;
  display: flex; align-items: center; justify-content: center;
  padding: 24px;
  background: linear-gradient(160deg, #3a86d9, #2b6cc0);
}
.login-card {
  width: 100%; max-width: 340px;
  background: var(--card);
  border-radius: 20px;
  padding: 28px 22px;
  box-shadow: 0 20px 60px rgba(0,0,0,.18);
  text-align: center;
}
.login-logo { font-size: 44px; }
.login-card h1 { margin: 8px 0 4px; font-size: 22px; }
.login-sub { margin: 0 0 18px; color: var(--muted); font-size: 13px; line-height: 1.5; }
.login-card input {
  width: 100%; height: 46px; margin-bottom: 12px;
  border: 1px solid var(--sep); border-radius: 12px;
  padding: 0 14px; font-size: 16px; background: #fafafa; outline: none;
}
.login-card input:focus { border-color: var(--accent); background: #fff; }
.login-card button {
  width: 100%; height: 48px; border: none; border-radius: 12px;
  background: var(--accent); color: #fff; font-size: 17px; font-weight: 600;
  cursor: pointer;
}
.login-card button:active { opacity: .85; }
.login-err { color: var(--red); font-size: 13px; min-height: 18px; margin: 10px 0 0; }

/* ---------- 主视图 ---------- */
.app {
  display: flex; flex-direction: column;
  height: 100%;
  padding-top: var(--safe-top);
  padding-bottom: var(--safe-bottom);
}
.topbar {
  display: flex; align-items: center; gap: 10px;
  padding: 14px 18px 10px;
  background: rgba(255,255,255,.8);
  backdrop-filter: saturate(180%) blur(20px);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  border-bottom: 1px solid var(--sep);
}
.topbar .title { font-size: 20px; font-weight: 700; flex: 1; }
.status { font-size: 14px; color: var(--muted); width: 18px; text-align: center; }
.status.on { color: var(--green); }
.status.off { color: var(--muted); }
.status.err { color: var(--red); }
.logout {
  border: none; background: transparent; color: var(--muted);
  font-size: 20px; cursor: pointer; padding: 4px 8px;
}

.progress {
  height: 3px; background: var(--sep); margin: 0 18px;
  border-radius: 2px; overflow: hidden;
}
.progress-bar { height: 100%; width: 0; background: var(--accent); transition: width .25s; }

.list {
  list-style: none; margin: 0; padding: 8px 14px 16px;
  flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch;
}
.empty {
  text-align: center; color: var(--muted); font-size: 14px;
  margin-top: 60px; line-height: 1.6;
}

.item {
  display: flex; align-items: center; gap: 12px;
  background: var(--card); border-radius: 14px;
  padding: 14px 14px; margin-bottom: 10px;
  box-shadow: 0 1px 3px rgba(0,0,0,.05);
  animation: pop .18s ease;
}
@keyframes pop { from { opacity: 0; transform: translateY(4px);} to { opacity:1; transform: none;} }
.item .check {
  width: 24px; height: 24px; border-radius: 50%;
  border: 2px solid var(--accent); flex: none;
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-size: 14px; cursor: pointer;
}
.item.done .check { background: var(--green); border-color: var(--green); }
.item .txt { flex: 1; font-size: 16px; line-height: 1.4; word-break: break-word; }
.item.done .txt { color: var(--muted); text-decoration: line-through; }
.item .del {
  border: none; background: transparent; color: var(--muted);
  font-size: 18px; cursor: pointer; padding: 4px 6px; flex: none;
}
.item .del:active { color: var(--red); }
.item .seq {
  width: 24px; flex: none; text-align: right;
  font-size: 15px; font-weight: 700; color: var(--accent);
  font-variant-numeric: tabular-nums;
}
.item.done .seq { color: var(--muted); }

.add-row {
  display: flex; gap: 10px; align-items: center;
  padding: 12px 14px calc(12px + var(--safe-bottom));
  background: rgba(255,255,255,.9);
  backdrop-filter: saturate(180%) blur(20px);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  border-top: 1px solid var(--sep);
}
.add-row input {
  flex: 1; height: 44px; border: 1px solid var(--sep);
  border-radius: 12px; padding: 0 14px; font-size: 16px;
  background: #fafafa; outline: none;
}
.add-row input:focus { border-color: var(--accent); background: #fff; }
.add-row button {
  width: 44px; height: 44px; flex: none; border: none;
  border-radius: 12px; background: var(--accent); color: #fff;
  font-size: 24px; line-height: 1; cursor: pointer;
}
.add-row button:active { opacity: .85; }

/* ---------- 桌面 / 宽屏适配：居中卡片，不再拉伸 ---------- */
@media (min-width: 600px) {
  html, body { height: 100%; }
  body {
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(160deg, #eef2f7 0%, #dde6f1 100%);
  }
  .app {
    width: 440px;
    max-width: 92vw;
    height: 88vh;
    max-height: 820px;
    margin: 0 auto;
    border-radius: 22px;
    overflow: hidden;
    box-shadow: 0 24px 60px rgba(20, 40, 80, .18);
    background: var(--bg);
    border: 1px solid rgba(255, 255, 255, .6);
  }
  /* 桌面下登录也改成柔和的居中卡片，而不是满屏深蓝 */
  .login {
    background: linear-gradient(160deg, #eef2f7 0%, #dde6f1 100%);
  }
  .login-card {
    box-shadow: 0 24px 60px rgba(20, 40, 80, .18);
    border: 1px solid rgba(255, 255, 255, .6);
  }
  /* 桌面鼠标交互反馈（手机触屏无 hover，不生效） */
  .item { transition: background .15s; }
  .item:hover { background: #fafbfd; }
  .item .del { opacity: .3; transition: opacity .15s, color .15s; }
  .item:hover .del { opacity: 1; }
  .item .del:hover { color: var(--red); }
  .item .check:hover { border-color: var(--green); }
  .topbar .logout:hover { color: var(--accent); }
}
