/* ============================================================
   泳记 · 深水泳馆主题
   深水底色 / 泳池瓷砖热力图 / 跑表数字 / 珊瑚橙打卡按钮
   ============================================================ */

:root {
  color-scheme: dark;

  --bg:        #051a1f;   /* 页面 · 深水 */
  --surface:   #0a2a31;   /* 卡片 */
  --surface-2: #0e3540;   /* 输入框 / 徽章 */
  --line:      rgba(154, 226, 219, 0.11);

  --ink:       #e9f7f3;   /* 主文字 */
  --ink-2:     #9dc6c1;   /* 次文字 */
  --muted:     #6e9a97;   /* 弱文字 */

  --aqua-100:  #7df4e3;   /* 最亮（量级 4）*/
  --aqua-300:  #2ec8bd;   /* 数据强调（量级 3）*/
  --coral:     #ff7a59;
  --coral-deep:#ef6440;

  /* 热力图量级色阶（已通过 dataviz 校验：单色相 · 亮度单调 · 浅端 2.10:1） */
  --lv0: #10333c;  /* 没游（贴近底面） */
  --lv1: #14606a;
  --lv2: #178e93;
  --lv3: #2ec8bd;
  --lv4: #7df4e3;

  --cell: 11px;

  --font-sans: system-ui, -apple-system, "Segoe UI", "PingFang SC",
               "HarmonyOS Sans SC", "Microsoft YaHei UI", "Microsoft YaHei", sans-serif;
  --font-num:  ui-monospace, "Cascadia Code", "SF Mono", Consolas,
               "Roboto Mono", monospace;  /* 跑表数字 */
}

* { box-sizing: border-box; }
body, h1, h2, h3, p, form, fieldset, legend { margin: 0; padding: 0; }
button, input { font: inherit; color: inherit; }
button { cursor: pointer; }

::selection { background: rgba(46, 200, 189, 0.3); }
:focus-visible { outline: 2px solid var(--aqua-300); outline-offset: 2px; border-radius: 4px; }

/* ---------- 背景：深水 + 池底瓷砖 ---------- */

body {
  min-height: 100dvh;
  font-family: var(--font-sans);
  color: var(--ink);
  line-height: 1.5;
  background:
    radial-gradient(1100px 520px at 85% -10%, rgba(46, 200, 189, 0.07), transparent 60%),
    radial-gradient(900px 480px at -15% 25%, rgba(23, 142, 147, 0.06), transparent 60%),
    radial-gradient(760px 700px at 50% 118%, rgba(20, 96, 106, 0.12), transparent 62%),
    var(--bg);
}

/* 池底瓷砖网格，向下淡出 */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background:
    repeating-linear-gradient(0deg,  rgba(157,198,193,0.028) 0 1px, transparent 1px 44px),
    repeating-linear-gradient(90deg, rgba(157,198,193,0.028) 0 1px, transparent 1px 44px);
  -webkit-mask-image: radial-gradient(85% 55% at 50% 0%, #000, transparent 78%);
          mask-image: radial-gradient(85% 55% at 50% 0%, #000, transparent 78%);
}

.top, main, .foot { position: relative; z-index: 1; }

/* ---------- 顶部 ---------- */

.top {
  max-width: 760px;
  margin: 0 auto;
  padding: 20px 18px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.wordmark { display: flex; align-items: baseline; gap: 9px; }
.wordmark .mark {
  font-size: 24px;
  line-height: 1;
  color: var(--aqua-300);
  transform: rotate(-14deg);
  translate: 0 1px;
}
.wordmark h1 { font-size: 21px; font-weight: 800; letter-spacing: 0.22em; }
.wordmark .sub {
  font-family: var(--font-num);
  font-size: 10px;
  letter-spacing: 0.32em;
  color: var(--muted);
}
.count-chip {
  display: flex;
  align-items: baseline;
  gap: 5px;
  padding: 6px 13px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  font-size: 11px;
  color: var(--muted);
}
.count-chip b { font-family: var(--font-num); font-size: 15px; color: var(--aqua-100); font-weight: 700; }

/* ---------- 布局与卡片 ---------- */

main {
  max-width: 760px;
  margin: 0 auto;
  padding: 2px 16px 44px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.card {
  background:
    linear-gradient(180deg, rgba(157,198,193,0.05), rgba(157,198,193,0) 40%),
    var(--surface);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 20px 18px;
  box-shadow: 0 14px 34px rgba(2, 10, 12, 0.5);
}
.card-head h2 { font-size: 15px; font-weight: 700; letter-spacing: 0.06em; }
.card-sub { margin-top: 2px; font-size: 12px; color: var(--muted); }

/* 入场动画 */
.reveal { animation: rise 0.55s cubic-bezier(0.2, 0.7, 0.3, 1) both; animation-delay: calc(var(--d, 0) * 75ms); }
@keyframes rise { from { opacity: 0; transform: translateY(16px); } }

/* ---------- 打卡区 ---------- */

.hero { text-align: center; padding-top: 26px; }
.today-line { font-size: 13px; color: var(--ink-2); letter-spacing: 0.05em; }

.dive-zone {
  position: relative;
  width: 168px;
  height: 168px;
  margin: 16px auto 10px;
  display: grid;
  place-items: center;
}
.rings i {
  position: absolute;
  inset: 8px;
  border-radius: 50%;
  border: 1px solid rgba(46, 200, 189, 0.26);
  animation: pulse 3.4s ease-out infinite;
}
.rings i:nth-child(2) { animation-delay: 1.7s; }
@keyframes pulse {
  from { transform: scale(0.74); opacity: 0.8; }
  to   { transform: scale(1.22); opacity: 0; }
}

/* 大按钮：外圈跑表刻度 + 珊瑚浮板 */
.dive-btn {
  position: relative;
  width: 124px;
  height: 124px;
  border: 0;
  border-radius: 50%;
  background: none;
  -webkit-tap-highlight-color: transparent;
}
.dive-btn::before {  /* 刻度圈 */
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: repeating-conic-gradient(rgba(233,247,243,0.3) 0 1.6deg, transparent 1.6deg 30deg);
  -webkit-mask: radial-gradient(closest-side, transparent calc(100% - 11px), #000 calc(100% - 10px));
          mask: radial-gradient(closest-side, transparent calc(100% - 11px), #000 calc(100% - 10px));
}
.dive-btn::after {   /* 珊瑚圆盘 */
  content: "";
  position: absolute;
  inset: 11px;
  border-radius: 50%;
  background: radial-gradient(120% 120% at 30% 22%, #ff9a76, var(--coral-deep) 58%, #d94e2c);
  box-shadow:
    0 12px 32px rgba(242, 96, 58, 0.32),
    inset 0 2px 6px rgba(255, 255, 255, 0.35),
    inset 0 -10px 18px rgba(120, 25, 5, 0.35);
}
.dive-btn-face {
  position: absolute;
  inset: 11px;
  z-index: 1;
  border-radius: 50%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1px;
  color: #2a0d05;
  font-weight: 800;
  transition: transform 0.15s;
}
.dive-btn:hover  .dive-btn-face { transform: scale(1.05); }
.dive-btn:active .dive-btn-face { transform: scale(0.95); }
.dive-emoji { font-size: 27px; filter: drop-shadow(0 2px 3px rgba(90, 20, 5, 0.3)); }
.dive-text  { font-size: 14px; letter-spacing: 0.14em; }

/* 打卡成功的水波纹 */
.ripple {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 124px;
  height: 124px;
  margin: -62px 0 0 -62px;
  border-radius: 50%;
  border: 2px solid rgba(125, 244, 227, 0.55);
  animation: rippleOut 0.9s ease-out forwards;
  pointer-events: none;
}
@keyframes rippleOut {
  from { transform: scale(0.8); opacity: 0.85; }
  to   { transform: scale(2.0); opacity: 0; }
}

.hero-hint { font-size: 12.5px; color: var(--muted); }

/* ---------- 打卡表单 ---------- */

.checkin-form {
  margin-top: 18px;
  padding-top: 18px;
  text-align: left;
  border-top: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  gap: 14px;
  animation: formIn 0.25s ease both;
}
@keyframes formIn { from { opacity: 0; transform: translateY(-6px); } }
.form-title {
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.12em;
  color: var(--aqua-100);
}

.field-row { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px 12px; }
.field-row .field:first-child { grid-column: 1 / -1; }

.field { display: flex; flex-direction: column; gap: 6px; font-size: 12px; color: var(--ink-2); border: 0; }
.field input {
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px 12px;
  color: var(--ink);
  font-size: 14px;
  width: 100%;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.field input::placeholder { color: rgba(110, 154, 151, 0.55); }
.field input:focus {
  outline: none;
  border-color: var(--aqua-300);
  box-shadow: 0 0 0 3px rgba(46, 200, 189, 0.16);
}
.field input[type="date"] { color-scheme: dark; min-height: 42px; }
.field input[type="number"] { appearance: textfield; -moz-appearance: textfield; }
.field input[type="number"]::-webkit-outer-spin-button,
.field input[type="number"]::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.field legend { margin-bottom: 6px; padding: 0; }

.mood-row { display: flex; gap: 8px; }
.mood-btn {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--surface-2);
  border: 1px solid var(--line);
  font-size: 20px;
  line-height: 1;
  transition: transform 0.15s, background 0.15s, border-color 0.15s, box-shadow 0.15s;
  filter: grayscale(0.5) opacity(0.75);
}
.mood-btn:hover { filter: none; }
.mood-btn.on {
  filter: none;
  transform: scale(1.08);
  background: rgba(46, 200, 189, 0.16);
  border-color: var(--aqua-300);
  box-shadow: 0 0 0 3px rgba(46, 200, 189, 0.15);
}

.form-actions { display: flex; justify-content: flex-end; gap: 10px; }

.btn {
  padding: 10px 20px;
  border-radius: 12px;
  border: 1px solid transparent;
  font-size: 14px;
  font-weight: 700;
  transition: filter 0.15s, border-color 0.15s, color 0.15s, background 0.15s;
}
.btn.primary {
  background: linear-gradient(180deg, #ff8a66, var(--coral-deep));
  color: #2a0d05;
  box-shadow: 0 6px 18px rgba(242, 96, 58, 0.28);
}
.btn.primary:hover { filter: brightness(1.08); }
.btn.ghost { background: transparent; border-color: var(--line); color: var(--ink-2); }
.btn.ghost:hover { color: var(--ink); border-color: rgba(157, 198, 193, 0.3); }
.btn.aqua { background: rgba(46, 200, 189, 0.12); border-color: rgba(46, 200, 189, 0.4); color: var(--aqua-100); }
.btn.aqua:hover { background: rgba(46, 200, 189, 0.2); }
.btn.danger { background: transparent; border-color: rgba(255, 122, 89, 0.35); color: #ff9a80; }
.btn.danger:hover { border-color: rgba(255, 122, 89, 0.7); background: rgba(255, 122, 89, 0.08); }

/* ---------- 统计 ---------- */

.stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}
.tile {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 13px 12px 11px;
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 0;
}
.t-label { font-size: 11px; color: var(--muted); letter-spacing: 0.05em; }
.t-value { font-family: var(--font-num); font-size: 22px; font-weight: 600; display: flex; align-items: baseline; gap: 4px; }
.t-value i { font-style: normal; font-size: 11px; font-weight: 400; color: var(--muted); }
.t-sub { font-size: 10.5px; color: var(--muted); opacity: 0.85; }

/* ---------- 热力图 ---------- */

/* 左缘渐隐：提示更早的周在滚动区里 */
.hm-frame { position: relative; }
.hm-frame::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 36px;
  z-index: 2;
  pointer-events: none;
  background: linear-gradient(90deg, var(--surface) 12%, transparent);
}

.hm-scroll {
  overflow-x: auto;
  margin: 14px -4px 0;
  padding: 0 4px 6px;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
  scrollbar-color: #155061 transparent;
}
.hm-scroll::-webkit-scrollbar { height: 6px; }
.hm-scroll::-webkit-scrollbar-thumb { background: #155061; border-radius: 3px; }
.hm-scroll::-webkit-scrollbar-track { background: transparent; }

.hm-inner { display: inline-block; min-width: 100%; }
.hm-months {
  position: relative;
  height: 15px;
  margin-left: 18px;
  font-family: var(--font-num);
  font-size: 10px;
  color: var(--muted);
}
.hm-months span { position: absolute; top: 2px; white-space: nowrap; }

.hm-body { display: flex; gap: 4px; align-items: flex-start; }
.hm-weekdays {
  display: grid;
  grid-template-rows: repeat(7, var(--cell));
  gap: 2px;
  width: 14px;
  font-size: 9px;
  color: var(--muted);
  position: sticky;      /* 钉在滚动区左侧，不被横向滚动卷走 */
  left: 0;
  z-index: 3;
  background: var(--surface);
}
.hm-weekdays span { line-height: var(--cell); }

.hm-grid {
  display: grid;
  grid-auto-flow: column;
  grid-template-rows: repeat(7, var(--cell));
  grid-auto-columns: var(--cell);
  gap: 2px;              /* 2px 表面缝隙分隔瓷砖 */
}
.cell { border-radius: 3px; background: var(--lv0); transition: transform 0.12s, filter 0.12s; }
.lv0 { background: var(--lv0); }
.lv1 { background: var(--lv1); }
.lv2 { background: var(--lv2); }
.lv3 { background: var(--lv3); }
.lv4 { background: var(--lv4); }
.cell.void { background: transparent; }
.cell.today { outline: 1.5px solid rgba(125, 244, 227, 0.9); outline-offset: 1px; }
.cell:not(.void):hover,
.cell:not(.void):focus-visible {
  filter: brightness(1.3);
  transform: scale(1.35);
  z-index: 2;
}
.cell:focus-visible { outline: 2px solid var(--aqua-100); outline-offset: 1px; }

.hm-foot {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 10px;
  font-size: 11px;
  color: var(--muted);
}
.if-touch { display: none; }
@media (hover: none) {
  .if-touch { display: inline; }
  .if-mouse { display: none; }
}
.hm-legend { display: inline-flex; align-items: center; gap: 3px; }
.sw { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }

/* ---------- 悬浮提示 ---------- */

.tooltip {
  position: fixed;
  z-index: 60;
  max-width: 232px;
  padding: 8px 11px;
  background: #0d3841;
  border: 1px solid rgba(125, 244, 227, 0.22);
  border-radius: 10px;
  box-shadow: 0 10px 26px rgba(2, 10, 12, 0.55);
  font-size: 12px;
  pointer-events: none;
}
.tt-date { color: var(--muted); font-size: 11px; margin-bottom: 2px; }
.tt-val  { color: var(--ink); font-weight: 700; font-size: 13px; }
.tt-mood { margin-top: 2px; font-size: 13px; }
.tt-note {
  margin-top: 3px;
  color: var(--ink-2);
  font-size: 11.5px;
  max-width: 200px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ---------- 历史记录 ---------- */

.month-h {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin: 18px 0 2px;
}
.month-h:first-child { margin-top: 4px; }
.month-h h3 { font-size: 13px; font-weight: 700; color: var(--ink-2); letter-spacing: 0.04em; }
.month-sub { font-family: var(--font-num); font-size: 11px; color: var(--muted); }

.h-row {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  padding: 11px 0;
  border-bottom: 1px solid rgba(157, 198, 193, 0.07);
}
.h-day { min-width: 38px; text-align: center; }
.h-day b { display: block; font-family: var(--font-num); font-size: 19px; font-weight: 600; line-height: 1.15; }
.h-day span { font-size: 10px; color: var(--muted); }

.h-main { flex: 1; min-width: 0; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 3px 10px;
  font-size: 11.5px;
  color: var(--ink-2);
}
.chip.mood { font-size: 14px; line-height: 1; padding: 3px 8px 4px; }
.h-note { margin-top: 6px; font-size: 12.5px; color: var(--ink-2); line-height: 1.55; }

.h-actions { display: flex; gap: 6px; opacity: 0; transition: opacity 0.15s; }
.h-row:hover .h-actions,
.h-actions:focus-within { opacity: 1; }
@media (hover: none) { .h-actions { opacity: 1; } }
.icon-btn {
  background: none;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 4px 9px;
  font-size: 11px;
  color: var(--muted);
  transition: color 0.15s, border-color 0.15s;
}
.icon-btn:hover { color: var(--ink); border-color: rgba(157, 198, 193, 0.3); }
.icon-btn.danger:hover { color: #ff9a80; border-color: rgba(255, 122, 89, 0.45); }

.empty { padding: 28px 0 22px; text-align: center; color: var(--muted); font-size: 13px; }

/* ---------- 数据管理 ---------- */

.data-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 14px; }
.data-note { margin-top: 13px; font-size: 11.5px; color: var(--muted); line-height: 1.65; }

/* ---------- 云同步 ---------- */

.sync-setup { display: flex; flex-direction: column; gap: 14px; margin-top: 14px; }
.sync-help { font-size: 11.5px; color: var(--muted); line-height: 1.7; }
.sync-help a { color: var(--aqua-300); }
.sync-help b { color: var(--ink-2); }
.sync-save-row { display: flex; justify-content: flex-end; }

/* ---------- 页脚 ---------- */

.foot { max-width: 760px; margin: 0 auto; padding: 0 16px 34px; text-align: center; }
.lane {
  width: min(280px, 70%);
  height: 3px;
  margin: 0 auto 14px;
  border-radius: 2px;
  background: repeating-linear-gradient(90deg, rgba(46, 200, 189, 0.32) 0 12px, transparent 12px 24px);
}
.foot p { font-size: 11px; color: var(--muted); letter-spacing: 0.06em; }

/* ---------- 全局提示 ---------- */

.store-banner {
  position: relative;
  z-index: 5;
  padding: 10px 16px;
  background: #5c2413;
  color: #ffd9c9;
  font-size: 12.5px;
  text-align: center;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 28px;
  z-index: 70;
  transform: translateX(-50%) translateY(10px);
  padding: 10px 20px;
  background: #0d3841;
  border: 1px solid rgba(125, 244, 227, 0.28);
  border-radius: 12px;
  box-shadow: 0 10px 28px rgba(2, 10, 12, 0.6);
  font-size: 13px;
  color: var(--ink);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s, transform 0.25s;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ---------- 桌面端 ---------- */

@media (min-width: 700px) {
  :root { --cell: 12px; }
  .stats { grid-template-columns: repeat(6, minmax(0, 1fr)); }
  .field-row { grid-template-columns: 1.2fr minmax(0, 1fr) minmax(0, 1fr); }
  .field-row .field:first-child { grid-column: auto; }
}

/* ---------- 减少动态 ---------- */

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
