:root {
  --bg: #f2f7f8;
  --surface: #ffffff;
  --surface-soft: #eaf4f5;
  --ink: #123039;
  --muted: #617980;
  --line: #d6e5e8;
  --primary: #0b6f85;
  --primary-strong: #07586b;
  --primary-soft: #d9eef2;
  --accent: #0da5a0;
  --danger: #b83b48;
  --danger-soft: #fff0f1;
  --shadow: 0 16px 44px rgba(22, 58, 66, 0.09);
  --radius-xl: 24px;
  --radius-lg: 18px;
  --radius-md: 14px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-right: env(safe-area-inset-right, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left: env(safe-area-inset-left, 0px);
  color-scheme: light;
}

* { box-sizing: border-box; }

html { min-height: 100%; background: var(--bg); }
body {
  min-height: 100%;
  margin: 0;
  background:
    radial-gradient(circle at 10% 0%, rgba(13, 165, 160, 0.13), transparent 30rem),
    linear-gradient(180deg, #f6fbfb 0%, var(--bg) 42%);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "PingFang SC", "Microsoft YaHei", sans-serif;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

button, input, select, textarea { font: inherit; }
button { -webkit-appearance: none; }
button, label.file-button { touch-action: manipulation; }

.app-shell {
  width: min(1320px, 100%);
  min-height: 100vh;
  margin: 0 auto;
  padding: calc(14px + var(--safe-top)) calc(22px + var(--safe-right)) calc(38px + var(--safe-bottom)) calc(22px + var(--safe-left));
}

.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 10px 2px 18px;
}

.brand-wrap { display: flex; align-items: center; gap: 13px; }
.brand-wrap h1 { margin: 0; font-size: clamp(22px, 3vw, 30px); letter-spacing: -0.03em; }
.brand-wrap p { margin: 3px 0 0; color: var(--muted); font-size: 13px; }
.brand-mark {
  position: relative;
  width: 48px;
  height: 48px;
  overflow: hidden;
  border-radius: 15px;
  background: linear-gradient(145deg, #0b6f85, #10aaa4);
  box-shadow: 0 10px 24px rgba(11,111,133,.22);
}
.brand-mark::before,
.brand-mark::after {
  content: "";
  position: absolute;
  left: 8px;
  right: 8px;
  border: 2px solid rgba(255,255,255,.88);
  border-top: 0;
  border-radius: 0 0 8px 8px;
}
.brand-mark::before { top: 9px; bottom: 24px; }
.brand-mark::after { top: 25px; bottom: 8px; }
.brand-mark span {
  position: absolute;
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: #fff;
}
.brand-mark span:first-child { top: 10px; right: 10px; }
.brand-mark span:last-child { top: 22px; left: 14px; opacity: .75; }

.main-nav {
  position: sticky;
  z-index: 30;
  top: calc(8px + var(--safe-top));
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 8px;
  padding: 7px;
  border: 1px solid rgba(214,229,232,.9);
  border-radius: 20px;
  background: rgba(255,255,255,.88);
  box-shadow: 0 12px 36px rgba(22,58,66,.08);
  -webkit-backdrop-filter: blur(18px);
  backdrop-filter: blur(18px);
}
.nav-item {
  min-height: 52px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 0;
  border-radius: 14px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
}
.nav-item span { font-size: 18px; line-height: 1; }
.nav-item b { font-size: 14px; font-weight: 700; }
.nav-item.active { background: var(--primary); color: #fff; box-shadow: 0 8px 18px rgba(11,111,133,.18); }

.content { padding-top: 26px; }
.view { display: none; animation: rise .22s ease; }
.view.active { display: block; }
@keyframes rise { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

.hero-card {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 28px;
  padding: clamp(24px, 4vw, 42px);
  border: 1px solid rgba(255,255,255,.65);
  border-radius: var(--radius-xl);
  background:
    linear-gradient(120deg, rgba(255,255,255,.96), rgba(234,247,248,.92)),
    radial-gradient(circle at 85% 15%, rgba(13,165,160,.14), transparent 16rem);
  box-shadow: var(--shadow);
}
.hero-card h2 { margin: 5px 0 8px; font-size: clamp(30px, 5vw, 48px); letter-spacing: -0.045em; }
.hero-actions, .page-actions { display: flex; flex-wrap: wrap; gap: 10px; }

.eyebrow {
  margin: 0;
  color: var(--primary);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: .13em;
  text-transform: uppercase;
}
.muted { color: var(--muted); }
.micro-copy { margin: 10px 0 0; color: var(--muted); font-size: 12px; line-height: 1.55; }

.section-heading, .page-heading {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 20px;
}
.section-heading { margin: 34px 2px 15px; }
.section-heading.spaced { margin-top: 38px; }
.section-heading h3, .page-heading h2 { margin: 5px 0 0; letter-spacing: -0.025em; }
.section-heading h3 { font-size: 22px; }
.page-heading { margin-bottom: 18px; }
.page-heading h2 { font-size: clamp(28px, 4vw, 38px); }
.page-heading p.muted { margin: 7px 0 0; }

.button, .text-button, .icon-button {
  border: 0;
  cursor: pointer;
  transition: transform .16s ease, box-shadow .16s ease, background .16s ease;
}
.button:active, .text-button:active, .icon-button:active { transform: scale(.98); }
.button {
  min-height: 46px;
  padding: 0 18px;
  border-radius: 13px;
  font-weight: 750;
}
.button.compact { min-height: 42px; padding: 0 15px; font-size: 14px; }
.button.primary { background: var(--primary); color: #fff; box-shadow: 0 9px 22px rgba(11,111,133,.18); }
.button.primary:hover { background: var(--primary-strong); }
.button.secondary { background: var(--primary-soft); color: var(--primary-strong); }
.button.ghost { background: #eef3f4; color: var(--ink); }
.button.wide { min-width: 180px; }
.button.danger { background: var(--danger); color: #fff; }
.button.ghost-danger { background: var(--danger-soft); color: var(--danger); box-shadow: none; }
.text-button { padding: 8px 0; background: transparent; color: var(--primary); font-weight: 750; }
.icon-button { width: 42px; height: 42px; border-radius: 50%; background: var(--surface-soft); color: var(--ink); font-size: 25px; }

.stack-list { display: grid; gap: 10px; }
.task-row {
  display: grid;
  grid-template-columns: auto minmax(0,1fr) auto;
  align-items: center;
  gap: 13px;
  padding: 15px 16px;
  border: 1px solid var(--line);
  border-radius: 17px;
  background: var(--surface);
  box-shadow: 0 6px 20px rgba(22,58,66,.045);
}
.task-row.completed { opacity: .63; }
.task-row.completed .task-title { text-decoration: line-through; }
.task-check {
  width: 30px;
  height: 30px;
  display: grid;
  place-items: center;
  border: 2px solid #a9c7cd;
  border-radius: 50%;
  background: #fff;
  color: transparent;
  font-weight: 900;
  cursor: pointer;
}
.task-row.completed .task-check { border-color: var(--accent); background: var(--accent); color: #fff; }
.task-main { min-width: 0; }
.task-title { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 780; }
.task-meta { margin-top: 3px; color: var(--muted); font-size: 12px; }
.task-edit { border: 0; border-radius: 10px; padding: 8px 10px; background: var(--surface-soft); color: var(--primary-strong); cursor: pointer; }

.empty-state {
  padding: 28px;
  border: 1px dashed #b7d0d5;
  border-radius: var(--radius-lg);
  background: rgba(255,255,255,.66);
  text-align: center;
  color: var(--muted);
}
.empty-state b { display: block; margin-bottom: 6px; color: var(--ink); }
.empty-state .button { margin-top: 14px; }

.tank-grid { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 16px; }
.tank-card {
  padding: 21px;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: 0 8px 26px rgba(22,58,66,.055);
}
.tank-card-header { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.tank-name { display: flex; align-items: center; gap: 9px; font-size: 18px; font-weight: 800; }
.tank-dot { width: 12px; height: 12px; border-radius: 4px; background: var(--primary); }
.tank-card:nth-child(2) .tank-dot { background: var(--accent); }
.latest-time { color: var(--muted); font-size: 12px; }
.param-summary { display: grid; grid-template-columns: repeat(3, minmax(0,1fr)); gap: 9px; margin-top: 17px; }
.param-mini { padding: 10px; border-radius: 12px; background: var(--surface-soft); }
.param-mini small { display: block; color: var(--muted); font-size: 10px; }
.param-mini b { display: block; margin-top: 3px; font-size: 15px; }
.no-reading { margin: 20px 0 2px; color: var(--muted); }

.week-board { display: grid; grid-template-columns: repeat(4, minmax(0,1fr)); gap: 13px; }
.day-card { min-height: 210px; padding: 15px; border: 1px solid var(--line); border-radius: var(--radius-lg); background: var(--surface); }
.day-card.today { border-color: rgba(11,111,133,.55); box-shadow: 0 10px 28px rgba(11,111,133,.09); }
.day-card-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.day-card-header h3 { margin: 0; font-size: 17px; }
.day-count { min-width: 25px; height: 25px; display: grid; place-items: center; border-radius: 9px; background: var(--surface-soft); color: var(--primary); font-size: 12px; font-weight: 800; }
.day-task-list { display: grid; gap: 8px; }
.day-task {
  width: 100%;
  padding: 10px;
  border: 1px solid #e1ecee;
  border-radius: 13px;
  background: #fbfdfd;
  text-align: left;
  cursor: pointer;
}
.day-task.done { opacity: .57; }
.day-task.done .day-task-title { text-decoration: line-through; }
.day-task-time { color: var(--primary); font-size: 11px; font-weight: 850; }
.day-task-title { display: block; margin-top: 4px; color: var(--ink); font-size: 13px; font-weight: 750; line-height: 1.35; }
.day-task-tank { display: block; margin-top: 5px; color: var(--muted); font-size: 10px; }
.day-empty { padding: 22px 4px; color: #91a5aa; font-size: 12px; text-align: center; }

.form-card, .settings-card {
  border: 1px solid var(--line);
  border-radius: var(--radius-xl);
  background: var(--surface);
  box-shadow: 0 10px 32px rgba(22,58,66,.055);
}
.form-card { padding: clamp(20px, 4vw, 34px); }
.field-group { margin-bottom: 20px; }
.field-label { display: block; margin-bottom: 9px; color: var(--muted); font-size: 13px; font-weight: 700; }
.segmented { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 8px; padding: 6px; border-radius: 16px; background: var(--surface-soft); }
.segment-button { min-height: 48px; border: 0; border-radius: 12px; background: transparent; color: var(--muted); font-weight: 780; cursor: pointer; }
.segment-button.active { background: var(--surface); color: var(--primary); box-shadow: 0 6px 18px rgba(22,58,66,.09); }
.form-row { display: grid; gap: 14px; }
.form-row.two-columns { grid-template-columns: repeat(2, minmax(0,1fr)); }
.field { display: grid; gap: 7px; }
.field > span { color: var(--muted); font-size: 13px; font-weight: 700; }
input, select, textarea {
  width: 100%;
  min-height: 46px;
  border: 1px solid #cfe0e3;
  border-radius: 12px;
  outline: none;
  background: #fbfdfd;
  color: var(--ink);
  padding: 10px 12px;
}
textarea { resize: vertical; }
input:focus, select:focus, textarea:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(11,111,133,.10); }
.parameter-grid { display: grid; grid-template-columns: repeat(3, minmax(0,1fr)); gap: 13px; margin-top: 18px; }
.parameter-field { display: grid; gap: 7px; padding: 14px; border: 1px solid var(--line); border-radius: 16px; background: #fbfdfd; }
.parameter-field > span { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.parameter-field b { font-size: 16px; }
.parameter-field small { color: var(--muted); font-size: 10px; }
.parameter-field input { min-height: 54px; border: 0; border-radius: 10px; background: var(--surface-soft); text-align: center; font-size: 21px; font-weight: 750; }
.form-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 22px; }

.select-control { min-height: 46px; width: auto; min-width: 150px; }
.history-list { display: grid; gap: 12px; }
.history-card {
  display: grid;
  grid-template-columns: 150px minmax(0,1fr) auto;
  gap: 16px;
  align-items: center;
  padding: 17px;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--surface);
}
.history-meta b { display: block; font-size: 16px; }
.history-meta span { display: block; margin-top: 4px; color: var(--muted); font-size: 12px; }
.history-values { display: flex; flex-wrap: wrap; gap: 7px; }
.value-chip { padding: 7px 9px; border-radius: 10px; background: var(--surface-soft); font-size: 12px; }
.value-chip b { margin-right: 4px; color: var(--primary-strong); }
.history-note { width: 100%; margin-top: 2px; color: var(--muted); font-size: 12px; }
.history-actions { display: flex; gap: 7px; }
.small-action { min-height: 38px; padding: 0 11px; border: 0; border-radius: 10px; background: var(--surface-soft); color: var(--primary-strong); font-weight: 750; cursor: pointer; }
.small-action.delete { background: var(--danger-soft); color: var(--danger); }

.settings-grid { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 16px; }
.settings-card { padding: 22px; }
.settings-card h3 { margin: 0 0 7px; font-size: 19px; }
.settings-card p { line-height: 1.55; }
.settings-form { display: grid; gap: 13px; margin-top: 17px; }
.button-stack { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 17px; }
.file-button { display: inline-flex; align-items: center; justify-content: center; }
.file-button input { display: none; }
.install-card ol { margin: 14px 0 0; padding-left: 22px; color: var(--muted); line-height: 1.85; }
.danger-card { border-color: #f0cdd1; background: linear-gradient(180deg, #fff, #fff9f9); }
.about-card { background: linear-gradient(135deg, #eaf7f8, #fff); }

.modal {
  width: min(620px, calc(100vw - 28px));
  max-height: calc(100vh - 28px);
  padding: 0;
  border: 0;
  border-radius: 24px;
  background: transparent;
  color: var(--ink);
}
.modal::backdrop { background: rgba(9,34,41,.42); -webkit-backdrop-filter: blur(5px); backdrop-filter: blur(5px); }
.modal-card { display: grid; gap: 15px; max-height: calc(100vh - 28px); overflow-y: auto; padding: 24px; border-radius: 24px; background: var(--surface); box-shadow: 0 24px 80px rgba(0,0,0,.24); }
.modal-heading { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.modal-heading h2 { margin: 4px 0 0; }
.modal-actions { display: flex; align-items: center; gap: 9px; margin-top: 4px; }
.modal-spacer { flex: 1; }

.toast {
  position: fixed;
  z-index: 100;
  left: 50%;
  bottom: calc(24px + var(--safe-bottom));
  max-width: min(90vw, 440px);
  padding: 12px 16px;
  border-radius: 13px;
  background: #123039;
  color: #fff;
  box-shadow: 0 14px 40px rgba(0,0,0,.22);
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, 12px);
  transition: opacity .2s ease, transform .2s ease;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.hidden { display: none !important; }

@media (max-width: 980px) {
  .week-board { grid-template-columns: repeat(2, minmax(0,1fr)); }
  .history-card { grid-template-columns: 120px minmax(0,1fr); }
  .history-actions { grid-column: 1 / -1; justify-content: flex-end; }
}

@media (max-width: 720px) {
  .app-shell { padding-left: calc(13px + var(--safe-left)); padding-right: calc(13px + var(--safe-right)); padding-bottom: calc(92px + var(--safe-bottom)); }
  .app-header { padding-bottom: 12px; }
  .app-header .button { display: none; }
  .main-nav {
    position: fixed;
    inset: auto calc(10px + var(--safe-right)) calc(8px + var(--safe-bottom)) calc(10px + var(--safe-left));
    top: auto;
    z-index: 50;
  }
  .nav-item { min-height: 56px; flex-direction: column; gap: 3px; }
  .nav-item span { font-size: 17px; }
  .nav-item b { font-size: 10px; }
  .content { padding-top: 8px; }
  .hero-card, .page-heading, .section-heading { align-items: stretch; flex-direction: column; }
  .hero-actions, .page-actions { width: 100%; }
  .hero-actions .button, .page-actions .button, .page-actions .select-control { flex: 1; }
  .tank-grid, .settings-grid, .form-row.two-columns { grid-template-columns: 1fr; }
  .parameter-grid { grid-template-columns: repeat(2, minmax(0,1fr)); }
  .week-board { grid-template-columns: 1fr; }
  .day-card { min-height: auto; }
  .history-card { grid-template-columns: 1fr; }
  .history-actions { grid-column: auto; justify-content: flex-start; }
}

@media (max-width: 420px) {
  .parameter-grid { grid-template-columns: 1fr 1fr; gap: 9px; }
  .parameter-field { padding: 10px; }
  .button { padding-inline: 13px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; transition-duration: .01ms !important; }
}

/* 周计划任务的勾选与编辑区域 */
.day-task {
  display: grid;
  grid-template-columns: 26px minmax(0, 1fr);
  gap: 8px;
  align-items: center;
  width: 100%;
  padding: 8px;
  border: 1px solid #e1ecee;
  border-radius: 13px;
  background: #fbfdfd;
}
.day-task-check {
  width: 25px;
  height: 25px;
  display: grid;
  place-items: center;
  padding: 0;
  border: 2px solid #b5cdd2;
  border-radius: 50%;
  background: #fff;
  color: transparent;
  font-size: 12px;
  font-weight: 900;
  cursor: pointer;
}
.day-task.done .day-task-check { border-color: var(--accent); background: var(--accent); color: #fff; }
.day-task-body {
  min-width: 0;
  padding: 2px;
  border: 0;
  background: transparent;
  text-align: left;
  cursor: pointer;
}
.day-empty {
  width: 100%;
  border: 0;
  background: transparent;
  cursor: pointer;
}
