/* ============ 倒计时看板 · 浅色简洁样式 ============ */
:root {
  --bg: #f5f6f8;
  --surface: #ffffff;
  --line: #e5e7eb;
  --line-2: #d9dee6;
  --text: #111827;
  --text-2: #4b5563;
  --muted: #8b95a5;

  --brand: #2563eb;
  --danger: #e11d48;
  --warn: #ea8c00;
  --ok: #0f9d63;
  --expired: #b8bfca;

  --radius: 12px;
  --shadow-1: 0 1px 2px rgba(17, 24, 39, 0.05);
  --shadow-2: 0 8px 20px rgba(17, 24, 39, 0.08);

  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB",
    "Microsoft YaHei", "Noto Sans SC", sans-serif;
  --num: "SF Mono", ui-monospace, "JetBrains Mono", Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  min-height: 100%;
}

body {
  font-family: var(--font);
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ------------------------------ 展示页 ------------------------------ */
.wrap {
  max-width: 1440px;
  margin: 0 auto;
  padding: 28px 32px 64px;
}

.topbar {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 20px;
  flex-wrap: wrap;
  padding-bottom: 18px;
  border-bottom: 1px solid var(--line);
}

.brand { display: flex; align-items: center; gap: 12px; }

.brand .mark {
  width: 4px;
  height: 30px;
  border-radius: 2px;
  background: var(--brand);
  flex: none;
}

.brand h1 {
  margin: 0;
  font-size: 23px;
  font-weight: 700;
  letter-spacing: 0.2px;
  line-height: 1.2;
}

.brand .sub {
  margin-top: 5px;
  font-size: 13px;
  color: var(--muted);
  line-height: 1.4;
}

.clockbox { text-align: right; }

.clock {
  font-family: var(--font);
  font-size: 26px;
  font-weight: 650;
  letter-spacing: 0;
  font-variant-numeric: tabular-nums;
  line-height: 1.1;
  color: var(--text);
}
.clock .sep { color: var(--expired); }

.clock-sub {
  margin-top: 5px;
  font-size: 12.5px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

/* 筛选栏 */
.toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin: 20px 0 4px;
}

.chip {
  appearance: none;
  cursor: pointer;
  border: 1px solid var(--line-2);
  background: var(--surface);
  color: var(--text-2);
  padding: 6px 13px;
  border-radius: 8px;
  font-size: 13px;
  font-family: inherit;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.chip:hover { border-color: var(--line-2); background: #fbfbfc; color: var(--text); }
.chip.on {
  background: var(--text);
  border-color: var(--text);
  color: #fff;
  font-weight: 600;
}
.chip .dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: currentColor;
  flex: none;
}
.chip.on .dot { background: #fff; opacity: 0.9; }

.toolbar.is-empty { display: none; }
.toolbar .spacer { flex: 1; }

.switch {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  font-size: 13px;
  color: var(--text-2);
  user-select: none;
}
.switch input { display: none; }
.switch .track {
  width: 36px;
  height: 20px;
  border-radius: 999px;
  background: #dfe3e9;
  position: relative;
  transition: background 0.18s ease;
}
.switch .track::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 2px rgba(17, 24, 39, 0.2);
  transition: transform 0.18s ease;
}
.switch input:checked + .track { background: var(--brand); }
.switch input:checked + .track::after { transform: translateX(16px); }

/* 卡片 */
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 16px;
  margin-top: 16px;
}

.card {
  position: relative;
  overflow: hidden;
  padding: 17px 18px 15px 20px;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: var(--surface);
  box-shadow: var(--shadow-1);
  display: flex;
  flex-direction: column;
  gap: 10px;
  transition: box-shadow 0.18s ease, transform 0.18s ease, border-color 0.18s ease;
}
.card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-2);
  border-color: var(--line-2);
}

/* 左侧紧急度色条 */
.card::before {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0;
  width: 3px;
  background: var(--accent, var(--expired));
}

.card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}

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

.card-tags {
  display: flex;
  align-items: center;
  gap: 6px;
  flex: none;
  padding-top: 1px;
}

.card h3 {
  margin: 0;
  font-size: 16.5px;
  line-height: 1.45;
  font-weight: 600;
  color: var(--text);
  word-break: break-word;
}

.badge {
  flex: none;
  font-size: 11.5px;
  line-height: 1.6;
  padding: 1px 8px;
  border-radius: 6px;
  color: var(--cat, var(--brand));
  background: color-mix(in srgb, var(--cat, var(--brand)) 10%, transparent);
  white-space: nowrap;
}

.pin {
  display: inline-block;
  font-size: 11px;
  line-height: 1.7;
  padding: 0 7px;
  border-radius: 5px;
  color: var(--brand);
  background: #eff4ff;
  border: 1px solid #c9d8fb;
  white-space: nowrap;
}

.note {
  font-size: 13px;
  line-height: 1.6;
  color: var(--text-2);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.countdown {
  font-family: var(--num);
  font-variant-numeric: tabular-nums;
  font-size: 31px;
  font-weight: 700;
  letter-spacing: 0.5px;
  line-height: 1.15;
  color: var(--text);
  display: flex;
  align-items: baseline;
  gap: 5px;
  flex-wrap: wrap;
}
.countdown .unit {
  font-size: 12.5px;
  font-family: var(--font);
  font-weight: 500;
  color: var(--muted);
  letter-spacing: 0;
}
.countdown .small { font-size: 0.62em; letter-spacing: 0; }

.card-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  font-size: 12.5px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.bar {
  height: 5px;
  border-radius: 999px;
  background: #eef1f5;
  overflow: hidden;
}
.bar > i {
  display: block;
  height: 100%;
  border-radius: 999px;
  background: var(--accent, var(--expired));
  transition: width 0.6s ease;
}

/* 紧急度 */
.u-calm { --accent: var(--ok); }
.u-warn { --accent: var(--warn); }
.u-danger { --accent: var(--danger); }
.u-danger .countdown { color: var(--danger); }
.u-expired { --accent: var(--expired); }
.u-expired h3 { color: var(--text-2); }
.u-expired .countdown { font-size: 24px; color: var(--muted); }
.u-expired .badge { opacity: 0.75; }

.empty {
  grid-column: 1 / -1;
  text-align: center;
  padding: 64px 20px;
  color: var(--muted);
  border: 1px dashed var(--line-2);
  border-radius: var(--radius);
  background: var(--surface);
  font-size: 14.5px;
  line-height: 2;
}

.empty--plain {
  border: 0;
  background: transparent;
  padding: 80px 20px;
  font-size: 15px;
  letter-spacing: 0.02em;
}

.empty small {
  display: block;
  font-size: 13px;
  color: var(--muted);
  line-height: 1.9;
}

.footnote {
  margin-top: 26px;
  text-align: center;
  font-size: 12px;
  color: var(--muted);
}/* ------------------------------ 管理页 ------------------------------ */
.admin-wrap { max-width: 1120px; margin: 0 auto; padding: 28px 24px 72px; }

.admin-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  padding-bottom: 18px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 20px;
}
.admin-head h1 { margin: 0; font-size: 21px; font-weight: 700; letter-spacing: 0.2px; }
.admin-head .hint { color: var(--muted); font-size: 13px; margin-top: 6px; }

.layout {
  display: grid;
  grid-template-columns: 360px minmax(0, 1fr);
  gap: 20px;
  align-items: start;
}
@media (max-width: 900px) {
  .layout { grid-template-columns: minmax(0, 1fr); }
}

.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-1);
  padding: 20px;
  min-width: 0;
}

.panel h2 {
  margin: 0 0 16px;
  font-size: 14px;
  color: var(--text);
  font-weight: 600;
  letter-spacing: 0.2px;
}

.field { margin-bottom: 14px; }
.field label {
  display: block;
  font-size: 12.5px;
  color: var(--text-2);
  margin-bottom: 6px;
}
.field label.switch {
  display: inline-flex;
  margin-bottom: 0;
  font-size: 13px;
  color: var(--text-2);
}
.field .req { color: var(--danger); }

input[type="text"], input[type="datetime-local"], textarea, select {
  width: 100%;
  max-width: 100%;
  min-width: 0;
  padding: 9px 11px;
  border-radius: 8px;
  border: 1px solid var(--line-2);
  background: #fff;
  color: var(--text);
  font-family: inherit;
  font-size: 14px;
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
input:focus, textarea:focus, select:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}
textarea { min-height: 76px; resize: vertical; line-height: 1.6; }
input::placeholder, textarea::placeholder { color: #aab2c0; }

.btn {
  appearance: none;
  cursor: pointer;
  border: 1px solid var(--line-2);
  background: #fff;
  color: var(--text);
  padding: 9px 15px;
  border-radius: 8px;
  font-size: 13.5px;
  font-family: inherit;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
}
.btn:hover { background: #f7f8fa; border-color: var(--line-2); }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }

.btn-primary {
  background: var(--brand);
  color: #fff;
  border-color: var(--brand);
  font-weight: 600;
}
.btn-primary:hover { background: #1d4ed8; border-color: #1d4ed8; }

.btn-danger { color: var(--danger); border-color: #f3d3da; background: #fff; }
.btn-danger:hover { background: #fff1f4; border-color: #eab6c2; }

.btn-sm { padding: 5px 10px; font-size: 12.5px; border-radius: 7px; }

.row { display: flex; gap: 10px; flex-wrap: wrap; }
.row > * { flex: 1; }
.row.btn-row > * { flex: 0 0 auto; }
.row.btn-row { justify-content: flex-start; margin-top: 4px; }

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

.item {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px 14px;
  border-radius: 9px;
  border: 1px solid var(--line);
  background: #fff;
  transition: border-color 0.15s ease, background 0.15s ease;
}
.item:hover { border-color: var(--line-2); background: #fcfcfd; }
.item.past { background: #fbfbfc; }
.item.past .t { color: var(--text-2); }

.item .main { flex: 1; min-width: 0; }
.item .t {
  font-size: 14px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 7px;
  flex-wrap: wrap;
  min-width: 0;
}
.item .m {
  margin-top: 5px;
  font-size: 12.5px;
  color: var(--muted);
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  font-variant-numeric: tabular-nums;
}
.item .m .note {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 34ch;
}
.item .acts { display: flex; gap: 6px; flex: none; }

.tag {
  font-size: 11px;
  line-height: 1.7;
  padding: 0 7px;
  border-radius: 5px;
  border: 1px solid var(--line);
  color: var(--text-2);
  font-weight: 500;
}
.tag.live { color: var(--ok); border-color: #c9e9d9; background: #f3fbf7; }
.tag.dead { color: var(--muted); background: #f7f8fa; }
.tag.pin-tag { color: var(--brand); border-color: #c9d8fb; background: #eff4ff; }

/* toast */
#toast {
  position: fixed;
  left: 50%;
  bottom: 32px;
  transform: translate(-50%, 16px);
  background: #fff;
  color: var(--text);
  border: 1px solid var(--line-2);
  padding: 10px 18px;
  border-radius: 9px;
  font-size: 13.5px;
  box-shadow: var(--shadow-2);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
  z-index: 99;
  max-width: 86vw;
}
#toast.show { opacity: 1; transform: translate(-50%, 0); }
#toast.err { border-color: #f3b6c3; color: var(--danger); }

.stat-line { font-size: 12.5px; color: var(--muted); margin-top: 12px; }
.stat-line.err { color: var(--danger); }

/* ------------------------------ 小屏 ------------------------------ */
@media (max-width: 620px) {
  .wrap { padding: 18px 16px 48px; }
  .topbar { align-items: flex-start; }
  .brand h1 { font-size: 20px; }
  .clockbox { text-align: left; }
  .clock { font-size: 22px; }
  .grid { grid-template-columns: minmax(0, 1fr); gap: 12px; }
  .countdown { font-size: 27px; }

  /* 管理页：单列、可换行、按钮排满，避免任何遮挡 */
  .admin-wrap { padding: 16px 12px calc(48px + env(safe-area-inset-bottom)); }
  .admin-head { gap: 12px; padding-bottom: 14px; margin-bottom: 14px; }
  .admin-head h1 { font-size: 19px; }
  .admin-head .hint { font-size: 12.5px; line-height: 1.65; }

  .layout { gap: 14px; }
  .panel { padding: 16px; border-radius: 10px; }
  .panel h2 { font-size: 13.5px; margin-bottom: 14px; }
  .field { margin-bottom: 12px; }
  /* 16px 可避免 iOS 聚焦输入框时自动放大页面 */
  input[type="text"], input[type="datetime-local"], textarea, select { font-size: 16px; }
  .btn { padding: 10px 14px; }
  .row.btn-row .btn { flex: 1 1 0; justify-content: center; }

  .item { flex-wrap: wrap; gap: 10px; padding: 12px; align-items: flex-start; }
  .item .main { flex: 1 1 100%; }
  .item .m { flex-direction: column; gap: 4px; margin-top: 6px; line-height: 1.55; }
  .item .m .note { white-space: normal; max-width: none; overflow: visible; }
  .item .acts { width: 100%; gap: 8px; justify-content: flex-end; }
  .item .acts .btn { flex: 0 0 auto; padding: 9px 16px; }

  #toast {
    bottom: calc(20px + env(safe-area-inset-bottom));
    left: 12px;
    right: 12px;
    transform: translateY(16px);
    max-width: none;
    text-align: center;
  }
  #toast.show { transform: translateY(0); }
}
