/* Routine · routine.nkmwei.de — Apple-minimal, warm off-white, light-blue accent */

:root {
  --bg: #f6f4ef;
  --bg-soft: #efece5;
  --card: #ffffff;
  --ink: #1d1d1f;
  --ink-2: #6e6e73;
  --ink-3: #a1a1a6;
  --line: rgba(29, 29, 31, 0.08);
  --accent: #4a94d4;
  --accent-deep: #2f78ba;
  --accent-soft: #e9f2fa;
  --night: #5b5f8f;
  --night-soft: #ecedf6;
  --ok: #4a94d4;
  --radius-lg: 20px;
  --radius-md: 14px;
  --radius-sm: 10px;
  --shadow-card: 0 1px 2px rgba(29, 29, 31, 0.04), 0 10px 30px rgba(29, 29, 31, 0.05);
  --shadow-lift: 0 2px 4px rgba(29, 29, 31, 0.05), 0 14px 34px rgba(29, 29, 31, 0.09);
  --ease-spring: cubic-bezier(0.34, 1.45, 0.5, 1);
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", "Segoe UI", Roboto, sans-serif;
  font-size: 15px;
  line-height: 1.55;
  min-height: 100dvh;
  overflow-x: hidden;
}

button {
  font: inherit;
  color: inherit;
  background: none;
  border: 0;
  padding: 0;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

img { display: block; max-width: 100%; }

.app {
  max-width: 1280px;
  margin: 0 auto;
  padding: 0 20px calc(84px + env(safe-area-inset-bottom));
}

/* ---------- Header ---------- */

.site-header {
  position: sticky;
  top: 0;
  z-index: 30;
  margin: 0 -20px;
  padding: calc(10px + env(safe-area-inset-top)) 20px 10px;
  background: rgba(246, 244, 239, 0.88);
  -webkit-backdrop-filter: saturate(1.4) blur(14px);
  backdrop-filter: saturate(1.4) blur(14px);
  border-bottom: 1px solid rgba(29, 29, 31, 0.05);
}

.header-inner {
  max-width: 1240px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.brand { display: flex; align-items: baseline; gap: 8px; }

.brand-mark {
  align-self: center;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 4px var(--accent-soft);
}

.brand-name { font-size: 17px; font-weight: 700; letter-spacing: -0.02em; }
.brand-sub { font-size: 13px; color: var(--ink-2); }

.header-date { font-size: 13px; color: var(--ink-2); white-space: nowrap; }

/* ---------- View layout ---------- */

.view-root { padding-top: 22px; }

.view {
  animation: view-in 0.34s ease both;
}

@keyframes view-in {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: none; }
}

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

.col-main { display: grid; gap: 20px; min-width: 0; }
.col-side { display: grid; gap: 20px; min-width: 0; }

/* ---------- Cards ---------- */

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
  padding: 22px;
  animation: card-rise 0.5s ease both;
}

.card:nth-child(2) { animation-delay: 0.05s; }
.card:nth-child(3) { animation-delay: 0.1s; }
.card:nth-child(4) { animation-delay: 0.15s; }

@keyframes card-rise {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: none; }
}

.card-title {
  margin: 0 0 4px;
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.card-sub { margin: 0; font-size: 13px; color: var(--ink-2); }

/* ---------- Hero / mode ---------- */

.hero { padding: 19px 20px; }

.hero-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
}

.hero-greeting { margin: 0; font-size: 22px; font-weight: 700; letter-spacing: -0.022em; }
.hero-line { margin: 4px 0 0; font-size: 13.5px; color: var(--ink-2); max-width: 46ch; }

.seg {
  display: inline-flex;
  padding: 3px;
  border-radius: 999px;
  background: var(--bg-soft);
  border: 1px solid rgba(29, 29, 31, 0.04);
  flex: none;
}

.seg button {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 6px 13px;
  border-radius: 999px;
  font-size: 13.5px;
  font-weight: 600;
  color: var(--ink-2);
  transition: color 0.25s ease, background 0.25s ease, box-shadow 0.25s ease;
  min-height: 34px;
}

.seg button svg { width: 14px; height: 14px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; }

.seg button.active {
  background: var(--card);
  color: var(--ink);
  box-shadow: 0 1px 2px rgba(29, 29, 31, 0.08), 0 4px 12px rgba(29, 29, 31, 0.08);
}

.seg button.active[data-mode="morning"] { color: var(--accent-deep); }
.seg button.active[data-mode="night"] { color: var(--night); }

/* Workout toggle */

.workout-row {
  margin-top: 13px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 11px 14px;
  border-radius: var(--radius-md);
  background: var(--night-soft);
  border: 1px solid rgba(91, 95, 143, 0.14);
  animation: view-in 0.3s ease both;
}

.workout-row[hidden] { display: none; }

.workout-label { display: flex; align-items: center; gap: 10px; font-weight: 600; font-size: 14.5px; }
.workout-label svg { width: 19px; height: 19px; fill: none; stroke: var(--night); stroke-width: 1.7; stroke-linecap: round; }
.workout-hint { display: block; font-weight: 400; font-size: 12.5px; color: var(--ink-2); margin-top: 1px; }

.switch {
  flex: none;
  width: 51px;
  height: 31px;
  border-radius: 999px;
  background: rgba(29, 29, 31, 0.16);
  position: relative;
  transition: background 0.25s ease;
}

.switch::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 27px;
  height: 27px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 2px 6px rgba(29, 29, 31, 0.25);
  transition: transform 0.3s var(--ease-spring);
}

.switch[aria-pressed="true"] { background: var(--night); }
.switch[aria-pressed="true"]::after { transform: translateX(20px); }

/* Mobile progress strip */

.hero-progress { margin-top: 13px; }
.hero-progress .bar-row {
  display: flex; align-items: center; justify-content: space-between;
  font-size: 12px; color: var(--ink-2); margin-bottom: 6px;
}
.hero-progress .bar-row strong { color: var(--ink); font-weight: 650; }

.bar {
  height: 6px;
  border-radius: 999px;
  background: var(--bg-soft);
  overflow: hidden;
}

.bar i {
  display: block;
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--accent), #6fb1e4);
  transition: width 0.45s var(--ease-spring);
}

.night .bar i { background: linear-gradient(90deg, var(--night), #8a8fc0); }

/* ---------- Checklist ---------- */

.routine-card { padding: 22px 22px 12px; }

.routine-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 6px;
}

.routine-head .card-sub { margin-top: 3px; }

.reset-btn {
  flex: none;
  font-size: 13px;
  font-weight: 600;
  color: var(--accent-deep);
  padding: 7px 13px;
  border-radius: 999px;
  background: var(--accent-soft);
  transition: transform 0.2s ease, filter 0.2s ease;
  min-height: 34px;
}

.reset-btn:active { transform: scale(0.96); }

.steps { list-style: none; margin: 8px 0 0; padding: 0; }

.fade-swap { transition: opacity 0.18s ease, transform 0.18s ease; }
.fade-swap.fading { opacity: 0; transform: translateY(5px); }

.step-section {
  padding: 16px 2px 8px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: var(--ink-3);
  text-transform: uppercase;
}

.step {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  padding: 13px 2px;
  border-top: 1px solid rgba(29, 29, 31, 0.05);
}

.step-section + .step { border-top: 0; }

.check {
  flex: none;
  width: 27px;
  height: 27px;
  margin-top: 2px;
  border-radius: 50%;
  border: 1.8px solid rgba(29, 29, 31, 0.22);
  background: var(--card);
  display: grid;
  place-items: center;
  transition: border-color 0.2s ease, background 0.2s ease;
}

.check svg {
  width: 14px;
  height: 14px;
  fill: none;
  stroke: #fff;
  stroke-width: 2.6;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-dasharray: 22;
  stroke-dashoffset: 22;
  opacity: 0;
}

.step.done .check {
  background: var(--accent);
  border-color: var(--accent);
  animation: check-pop 0.42s var(--ease-spring);
}

.night .step.done .check { background: var(--night); border-color: var(--night); }

.step.done .check svg {
  opacity: 1;
  stroke-dashoffset: 0;
  transition: stroke-dashoffset 0.28s ease 0.05s, opacity 0.1s ease;
}

@keyframes check-pop {
  0% { transform: scale(0.82); }
  55% { transform: scale(1.12); }
  100% { transform: scale(1); }
}

.step-body { flex: 1; min-width: 0; }

.step-title {
  font-size: 15px;
  font-weight: 650;
  letter-spacing: -0.01em;
  transition: color 0.25s ease;
}

.step-en { font-size: 12.5px; font-weight: 550; color: var(--accent-deep); margin-left: 6px; white-space: nowrap; }

.step-note { margin: 3px 0 0; font-size: 13px; color: var(--ink-2); }

.step.done .step-title { color: var(--ink-3); text-decoration: line-through; text-decoration-color: rgba(29, 29, 31, 0.25); }
.step.done .step-note { color: var(--ink-3); }
.step.done .step-en { color: var(--ink-3); }

.step-thumbs { flex: none; display: flex; gap: 6px; margin-top: 1px; }

.thumb {
  width: 44px;
  height: 44px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  background: #fff;
  padding: 4px;
  transition: opacity 0.25s ease;
}

.thumb img { width: 100%; height: 100%; object-fit: contain; }

.step.done .thumb { opacity: 0.45; }

.rule-note {
  margin: 10px 0 12px;
  padding: 11px 14px;
  border-radius: var(--radius-md);
  background: var(--accent-soft);
  color: var(--accent-deep);
  font-size: 13px;
  font-weight: 550;
}

.night .rule-note { background: var(--night-soft); color: var(--night); }

/* ---------- Sidebar ---------- */

.side-sticky { position: static; }

.progress-card { display: flex; align-items: center; gap: 18px; }

.ring { flex: none; width: 76px; height: 76px; transform: rotate(-90deg); }
.ring circle { fill: none; stroke-width: 7; stroke-linecap: round; }
.ring .ring-bg { stroke: var(--bg-soft); }
.ring .ring-fg { stroke: var(--accent); transition: stroke-dashoffset 0.5s var(--ease-spring); }
.night .ring .ring-fg { stroke: var(--night); }

.progress-meta .card-title { font-size: 17px; }
.progress-meta .num { font-size: 13px; color: var(--ink-2); margin-top: 2px; }
.progress-meta .num strong { color: var(--ink); font-weight: 700; font-size: 15px; }

/* Product overview — collapsible category groups */

.overview-group { padding: 8px 0 2px; }
.overview-group:first-of-type { padding-top: 4px; }

.overview-label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: var(--ink-3);
  text-transform: uppercase;
  padding: 6px 0;
  cursor: pointer;
  list-style: none;
  user-select: none;
  transition: color 0.2s ease;
}

.overview-label::-webkit-details-marker { display: none; }
.overview-label:hover { color: var(--ink-2); }

.overview-label .line { flex: 1; height: 1px; background: rgba(29, 29, 31, 0.06); }

.overview-label .chev {
  flex: none;
  width: 13px;
  height: 13px;
  fill: none;
  stroke: var(--ink-3);
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
  transition: transform 0.25s ease;
}

details[open] > .overview-label .chev { transform: rotate(180deg); }

.p-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 7px 0;
}

.p-row .thumb { width: 42px; height: 42px; }

.p-row-body { flex: 1; min-width: 0; }

.p-row-name {
  font-size: 13.5px;
  font-weight: 650;
  letter-spacing: -0.01em;
  line-height: 1.35;
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

.p-row-zh { font-size: 12px; color: var(--ink-2); margin-top: 1px; }

.stars { font-size: 9.5px; letter-spacing: 1.4px; color: #d9ab63; margin-top: 2px; }
.stars .off { color: rgba(29, 29, 31, 0.15); }

/* ---------- Category views ---------- */

.cat-hero { padding: 20px; }
.cat-hero h1 { margin: 0; font-size: 21px; font-weight: 700; letter-spacing: -0.022em; }
.cat-hero .cat-en { color: var(--accent-deep); font-size: 13px; font-weight: 650; margin-left: 8px; letter-spacing: 0; }
.cat-hero p { margin: 6px 0 0; font-size: 13.5px; color: var(--ink-2); }

.chain {
  margin-top: 14px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 7px;
  font-size: 13px;
  font-weight: 600;
}

.chain-tag {
  padding: 5px 11px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent-deep);
}

.chain-arrow { color: var(--ink-3); font-weight: 400; }

.chain-title { width: 100%; font-size: 12px; font-weight: 700; letter-spacing: 0.06em; color: var(--ink-3); text-transform: uppercase; margin-top: 8px; }
.chain-title:first-child { margin-top: 0; }

.product-card {
  display: flex;
  gap: 16px;
  align-items: center;
  transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.product-img {
  flex: none;
  width: 92px;
  height: 92px;
  border-radius: var(--radius-md);
  border: 1px solid var(--line);
  background: #fff;
  padding: 8px;
  transition: transform 0.3s ease;
}

.product-img img { width: 100%; height: 100%; object-fit: contain; }

.product-body { flex: 1; min-width: 0; }
.product-name { margin: 0; font-size: 15.5px; font-weight: 700; letter-spacing: -0.015em; line-height: 1.35; }
.product-zh { margin: 4px 0 0; font-size: 13px; color: var(--ink-2); }
.product-card .stars { font-size: 10.5px; margin-top: 6px; }

.tips-card ul { margin: 10px 0 0; padding: 0; list-style: none; }
.tips-card li {
  position: relative;
  padding: 7px 0 7px 22px;
  font-size: 13.5px;
  color: var(--ink-2);
}
.tips-card li::before {
  content: "";
  position: absolute;
  left: 4px;
  top: 14px;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent);
}

/* ---------- Bottom navigation (mobile) ---------- */

.tabbar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 40;
  display: flex;
  justify-content: space-around;
  padding: 7px 10px calc(7px + env(safe-area-inset-bottom));
  background: rgba(251, 250, 247, 0.78);
  -webkit-backdrop-filter: saturate(1.8) blur(22px);
  backdrop-filter: saturate(1.8) blur(22px);
  border-top: 0.5px solid rgba(29, 29, 31, 0.1);
}

.tab {
  flex: 1;
  max-width: 96px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 5px 0 3px;
  font-size: 10px;
  font-weight: 550;
  letter-spacing: 0.01em;
  color: #b4b4b9;
  border-radius: 12px;
  transition: color 0.22s ease, transform 0.22s ease;
  min-height: 48px;
}

.tab svg {
  width: 22px;
  height: 22px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
  transition: transform 0.3s var(--ease-spring);
}

.tab.active { color: #2b74b8; font-weight: 600; }
.tab.active svg { transform: translateY(-1px) scale(1.06); }
.tab:active { transform: scale(0.94); }

/* Tips cards shown beside the checklist on desktop only —
   the same guidance lives in the category tabs on mobile */
.desk-tips { display: none; }

/* ---------- Footer ---------- */

.foot {
  margin-top: 26px;
  text-align: center;
  font-size: 12px;
  color: var(--ink-3);
}

/* ---------- Desktop ---------- */

@media (min-width: 900px) {
  body { font-size: 15.5px; }

  .app { padding: 0 32px 56px; }
  .site-header { margin: 0 -32px; padding-left: 32px; padding-right: 32px; }

  .tabbar { display: none; }

  .layout {
    grid-template-columns: minmax(0, 1.6fr) minmax(300px, 1fr);
    gap: 24px;
  }

  .view-root { padding-top: 28px; }

  .card-title { font-size: 19px; }

  .hero { padding: 30px 32px; }
  .hero-greeting { font-size: 30px; }
  .hero-progress { display: none; }

  .routine-card { padding: 26px 30px 16px; }
  .card { padding: 26px 30px; }

  .side-sticky {
    position: sticky;
    top: 76px;
    display: grid;
    gap: 20px;
    max-height: calc(100dvh - 96px);
    overflow-y: auto;
    overscroll-behavior: contain;
    scrollbar-width: none;
    border-radius: var(--radius-lg);
  }
  .side-sticky::-webkit-scrollbar { display: none; }

  .product-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-lift); }
  .product-card:hover .product-img { transform: scale(1.04); }
  .p-row:hover .thumb { transform: translateY(-2px); box-shadow: 0 6px 14px rgba(29, 29, 31, 0.08); }
  .thumb { transition: transform 0.25s ease, box-shadow 0.25s ease, opacity 0.25s ease; }

  .desk-tips { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
}

@media (min-width: 1200px) {
  .layout { grid-template-columns: minmax(0, 1.7fr) minmax(330px, 1fr); gap: 28px; }
}

/* Category product grid on wide screens */
@media (min-width: 900px) {
  .product-list { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
  .product-list .card { animation-delay: 0s; }
}

/* ---------- Reduced motion ---------- */

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-delay: 0ms !important;
    transition-duration: 0.01ms !important;
  }
}
