/* ============================================================
   Our Home — A Guide for You / 我们家的约定
   Mobile-first shared stylesheet — screen + print (A4).
   Font stack is CJK-friendly and uses system fonts only, so the
   guide renders reliably on any phone with no slow font download.
   Design language: calm, clean, editorial document.
   ============================================================ */

:root {
  /* ink + neutrals */
  --ink:        #1b252b;
  --ink-2:      #38464e;
  --muted:      #5f7079;
  --muted-2:    #6d8794;
  --faint:      #93a2aa;
  --line:       #e4eaee;
  --line-soft:  #eef3f6;

  /* surfaces */
  --bg:         #ffffff;
  --panel:      #f6fafb;
  --panel-2:    #eef4f7;

  /* accent */
  --accent:     #2c6b79;
  --accent-ink: #1f5361;
  --accent-soft:#eaf3f5;

  /* callout tones */
  --warn-bg:    #fff8e6;
  --warn-line:  #e0bd57;
  --red-bg:     #fdf1f1;
  --red-line:   #cd8d8d;
  --rest-bg:    #f1f6f1;
  --rest-line:  #9cbfa5;

  --radius:     14px;
  --content-max: 720px;      /* ≈ 65–72 characters per line at 17px */
  --pad:        20px;
  --shadow:     0 1px 2px rgba(20, 40, 50, .05), 0 10px 24px -18px rgba(20, 40, 50, .30);
}

@media (min-width: 480px) { :root { --pad: 24px; } }

* { box-sizing: border-box; }

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: "Noto Sans SC", "PingFang SC", "Hiragino Sans GB",
               "Microsoft YaHei", system-ui, -apple-system, "Segoe UI",
               Roboto, sans-serif;
  font-size: 17px;
  line-height: 1.68;
  font-weight: 400;
  letter-spacing: .004em;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

/* ---------- sticky slim header ------------------------------ */

.topbar {
  position: sticky;
  top: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  gap: 10px;
  height: 54px;
  padding: 0 14px;
  background: rgba(255, 255, 255, .93);
  -webkit-backdrop-filter: saturate(180%) blur(12px);
  backdrop-filter: saturate(180%) blur(12px);
  border-bottom: 1px solid var(--line);
}

.topbar-back {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 44px;
  padding: 0 12px;
  margin-left: -12px;
  border-radius: 10px;
  color: var(--accent-ink);
  font-weight: 600;
  font-size: .9rem;
  text-decoration: none;
}
.topbar-back:hover { background: var(--accent-soft); }
.topbar-back .zh { color: var(--muted); font-size: .82rem; font-weight: 500; }

.topbar-title {
  margin-left: auto;
  min-width: 0;
  font-size: .72rem;
  font-weight: 700;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--faint);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ---------- page shell -------------------------------------- */

main {
  max-width: var(--content-max);
  margin: 0 auto;
  padding: 6px var(--pad) 96px;
}

/* ---------- bilingual pair ---------------------------------- */

.pair { margin: 0 0 .85em; }
.pair:last-child { margin-bottom: 0; }
.pair .en { display: block; }
.pair .zh {
  display: block;
  font-size: .9em;
  line-height: 1.6;
  color: var(--muted);
  margin-top: .12em;
}

.lead { margin: 0 0 1.2em; font-size: 1.02em; color: var(--ink-2); }

/* ---------- headings ---------------------------------------- */

h1, h2, h3 { font-weight: 650; line-height: 1.3; }

.page-head { padding-top: 26px; }

.eyebrow {
  display: inline-block;
  font-size: .72rem;
  font-weight: 700;
  letter-spacing: .18em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: .7em;
}

h1.page-title {
  font-size: clamp(1.7rem, 7.5vw, 2.05rem);
  line-height: 1.2;
  letter-spacing: -.015em;
  margin: 0;
}
.page-title .zh-lead {
  display: block;
  font-size: .5em;
  font-weight: 600;
  letter-spacing: .02em;
  color: var(--muted);
  margin-top: .45em;
}

/* cover */
.cover { padding-top: 28px; }
.cover h1.page-title { font-size: clamp(1.95rem, 9vw, 2.5rem); }
.cover .page-title .zh-lead { font-size: .42em; }
.kicker {
  font-size: .72rem;
  font-weight: 700;
  letter-spacing: .22em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 1em;
}
.cover .opening { margin-top: 1.5em; }
.cover .opening .pair .en { font-size: 1.02em; }

/* numbered section heading (e.g. 1.1) */
h2.sec {
  font-size: 1.3rem;
  line-height: 1.3;
  letter-spacing: -.008em;
  margin: 2.3em 0 0;
  padding-top: .7em;
  border-top: 2px solid var(--ink);
}
h2.sec .sec-num {
  color: var(--accent);
  margin-right: .35em;
}
h2.sec .zh-lead {
  display: block;
  font-size: .66em;
  font-weight: 500;
  color: var(--muted);
  letter-spacing: .01em;
  margin-top: .32em;
}

h3.sub {
  font-size: 1.06rem;
  margin: 1.7em 0 .5em;
}
h3.sub .zh-lead {
  display: block;
  font-size: .8em;
  font-weight: 500;
  color: var(--muted);
  margin-top: .18em;
}

/* "in this part" mini nav */
.mini-nav {
  margin: 1.6em 0 0;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--panel);
  padding: 12px 14px;
}
.mini-nav h4 {
  margin: 0 0 .5em;
  font-size: .7rem;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--faint);
  font-weight: 700;
}
.mini-nav ol {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 2px;
}
.mini-nav a {
  display: flex;
  gap: 10px;
  padding: 8px 4px;
  color: var(--ink-2);
  text-decoration: none;
  font-size: .92rem;
  border-radius: 8px;
}
.mini-nav a:hover { color: var(--accent-ink); }
.mini-nav .n {
  flex: 0 0 auto;
  color: var(--accent);
  font-weight: 700;
  font-size: .78rem;
  letter-spacing: .04em;
}

/* ---------- menu (index) ------------------------------------ */

.menu {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
  margin: 22px 0 0;
  padding: 0;
  list-style: none;
}

.menu-card {
  display: flex;
  align-items: center;
  gap: 14px;
  min-height: 74px;
  padding: 15px 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  box-shadow: var(--shadow);
  color: inherit;
  text-decoration: none;
  transition: border-color .15s ease, background .15s ease, transform .12s ease;
}
.menu-card:hover { border-color: var(--accent); background: var(--panel); }
.menu-card:active { transform: scale(.99); }

.menu-num {
  flex: 0 0 auto;
  width: 46px;
  height: 46px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  background: var(--accent-soft);
  color: var(--accent-ink);
  font-weight: 700;
  font-size: .82rem;
  letter-spacing: .04em;
  text-transform: uppercase;
}
.menu-num.wide { font-size: .72rem; }

.menu-body { flex: 1 1 auto; min-width: 0; }
.menu-title { font-weight: 650; font-size: 1.06rem; line-height: 1.3; }
.menu-title .zh {
  display: block;
  font-size: .8em;
  font-weight: 500;
  color: var(--muted);
  margin-top: 3px;
}
.menu-arrow { flex: 0 0 auto; color: var(--faint); font-size: 1.35rem; line-height: 1; }

/* ---------- meta card --------------------------------------- */

.kv {
  margin: 20px 0 0;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--panel);
  overflow: hidden;
}
.kv-row {
  padding: 12px 15px;
  border-bottom: 1px solid var(--line-soft);
}
.kv-row:last-child { border-bottom: 0; }
.kv-k { display: block; font-weight: 650; font-size: .95rem; }
.kv-k .zh { font-size: .82em; font-weight: 500; color: var(--muted); }
.kv-v { display: block; margin-top: 3px; color: var(--ink-2); font-size: .95rem; }

/* ---------- definition cards (spec tables → blocks) --------- */

.cards { display: grid; gap: 12px; margin: 16px 0 4px; }

.card {
  border: 1px solid var(--line);
  border-left: 4px solid var(--accent-soft);
  border-radius: 12px;
  background: var(--panel);
  padding: 14px 16px;
}
.card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 9px;
}
.card-label {
  font-weight: 650;
  font-size: 1rem;
  line-height: 1.35;
}
.card-label .zh {
  display: block;
  font-size: .82em;
  font-weight: 500;
  color: var(--muted);
  margin-top: 2px;
}
.card-head .mark { flex: 0 0 auto; }

/* ---------- schedule slots (Part 2) ------------------------- */

.slots { display: grid; gap: 12px; margin: 16px 0 4px; }

.slot {
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
  padding: 14px 16px;
}
.slot-time {
  display: flex;
  align-items: center;
  gap: 9px;
  flex-wrap: wrap;
  margin-bottom: 8px;
  font-variant-numeric: tabular-nums;
  font-weight: 700;
  font-size: .95rem;
  letter-spacing: .01em;
  color: var(--accent-ink);
}
.slot-time .mark { margin-left: auto; }
.slot.fixed {
  border-color: var(--accent);
  background: var(--accent-soft);
}
.slot.rest { border-color: var(--rest-line); background: var(--rest-bg); }
.slot.zero { background: var(--panel-2); border-color: var(--line); }

/* ---------- mark chips -------------------------------------- */

.mark {
  display: inline-block;
  font-size: .66rem;
  font-weight: 700;
  letter-spacing: .06em;
  text-transform: uppercase;
  padding: 3px 9px;
  border-radius: 999px;
  white-space: nowrap;
}
.mark.must    { background: #fbe9e9; color: #a23c3c; }
.mark.daily   { background: #eaf1f6; color: #3a6675; }
.mark.weekly  { background: #ebeff8; color: #465489; }
.mark.monthly { background: #f1ecf7; color: #635093; }
.mark.restd   { background: var(--rest-bg); color: #3f6b4a; }
.mark.plain   { background: var(--panel-2); color: var(--muted); }
.mark.none    { background: transparent; color: var(--faint); padding: 0; }

/* ---------- callout boxes ----------------------------------- */

.box {
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--panel);
  padding: 15px 16px;
  margin: 18px 0;
}
.box-title { font-weight: 700; margin-bottom: .5em; }
.box-title .zh {
  display: block;
  font-size: .84em;
  font-weight: 500;
  color: var(--muted);
  margin-top: 2px;
}
.box.note { background: var(--accent-soft); border-color: #cfe3e7; }
.box.warn { background: var(--warn-bg); border-color: var(--warn-line); }
.box.firm { background: var(--red-bg); border-color: var(--red-line); }
.box.rest { background: var(--rest-bg); border-color: var(--rest-line); }

.box.firm ol { margin: .4em 0 0; padding-left: 1.25em; }
.box.firm li { margin-bottom: .95em; }
.box.firm li:last-child { margin-bottom: 0; }
.box.firm li .en { font-weight: 650; }

/* ---------- plain lists ------------------------------------- */

ul.plain, ol.plain { margin: .6em 0 1.2em; padding-left: 1.2em; }
ul.plain > li, ol.plain > li { margin-bottom: .85em; }
ul.plain > li:last-child, ol.plain > li:last-child { margin-bottom: 0; }
ol.plain { padding-left: 1.4em; }

/* ---------- notes / closing --------------------------------- */

.lines { margin: .7em 0 0; }
.lines .l { border-bottom: 1px dashed var(--faint); height: 1.9em; }

.closing {
  margin: 2.6em 0 0;
  padding: 22px 18px;
  border-top: 2px solid var(--ink);
  border-bottom: 2px solid var(--ink);
  font-size: 1.08rem;
}
.closing .pair .en { font-weight: 600; }

hr.soft { border: 0; border-top: 1px solid var(--line); margin: 2.4em 0; }

/* ---------- checklist components ---------------------------- */

.slot-time .tt { flex: 1 1 auto; }

.cb {
  display: inline-block;
  flex: 0 0 auto;
  width: 22px;
  height: 22px;
  border: 2px solid var(--faint);
  border-radius: 6px;
  background: #fff;
}
.slot-time .cb { margin-left: 6px; }

.sheet-title {
  font-size: 1.18rem;
  font-weight: 700;
  letter-spacing: -.005em;
  margin: 2.2em 0 0;
  padding-top: .6em;
  border-top: 2px solid var(--ink);
}
.sheet-title:first-of-type { margin-top: .4em; }
.sheet-title .zh {
  display: block;
  font-size: .72em;
  font-weight: 500;
  color: var(--muted);
  margin-top: .3em;
}

.sheet-date {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 20px;
  margin: .7em 0 0;
  font-size: .9rem;
  color: var(--ink-2);
}
.sheet-date .f { display: inline-flex; gap: 6px; align-items: baseline; }
.sheet-date .bl { display: inline-block; min-width: 60px; border-bottom: 1px solid var(--faint); }

/* weekly task rows */
.wk { display: grid; gap: 10px; margin: 14px 0 4px; }
.wk-row {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
  padding: 12px 14px;
}
.wk-row .wk-body { flex: 1 1 auto; min-width: 0; }
.wk-day { font-weight: 700; font-size: .95rem; }
.wk-day .zh { font-weight: 500; color: var(--muted); font-size: .82em; margin-left: 6px; }
.wk-task .en { font-size: .95rem; }
.wk-task .zh { display: block; font-size: .85em; color: var(--muted); margin-top: 2px; }
.wk-done {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-top: 8px;
  font-size: .82rem;
  color: var(--muted);
}
.wk-done .bl { display: inline-block; min-width: 54px; border-bottom: 1px solid var(--faint); }
.wk-row.rest { border-color: var(--rest-line); background: var(--rest-bg); }

/* money sheet */
.money { display: grid; gap: 10px; margin: 14px 0 4px; }
.money-row {
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
  padding: 12px 14px;
}
.money-row .line {
  display: flex;
  gap: 10px;
  align-items: baseline;
  margin-bottom: 9px;
}
.money-row .line:last-child { margin-bottom: 0; }
.money-row .k {
  flex: 0 0 auto;
  min-width: 58px;
  font-weight: 650;
  font-size: .8rem;
  letter-spacing: .02em;
  color: var(--muted);
}
.money-row .v { flex: 1 1 auto; border-bottom: 1px dotted var(--faint); min-height: 1.35em; }
.money-row .line.checks { gap: 7px 16px; flex-wrap: wrap; }
.money-row .line.checks .k { min-width: 58px; }
.money-opt {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: .82rem;
  color: var(--ink-2);
}
.money-opt .cb { width: 18px; height: 18px; border-radius: 5px; }

.money-total {
  display: grid;
  gap: 8px;
  margin: 14px 0 4px;
  padding: 13px 15px;
  border: 1px solid var(--accent);
  border-radius: 12px;
  background: var(--accent-soft);
}
.money-total .line { display: flex; gap: 10px; align-items: baseline; }
.money-total .k { flex: 0 0 auto; min-width: 90px; font-weight: 650; font-size: .9rem; }
.money-total .v { flex: 1 1 auto; border-bottom: 1px dotted var(--faint); min-height: 1.35em; }

/* callable box used on the checklist */
.box.fixed-times { background: var(--red-bg); border-color: var(--red-line); }

/* print button */
.printbtn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 46px;
  margin-top: 1.4em;
  padding: 0 18px;
  border: 1px solid var(--accent);
  border-radius: 12px;
  background: #fff;
  color: var(--accent-ink);
  font: inherit;
  font-weight: 650;
  font-size: .92rem;
  cursor: pointer;
}
.printbtn:hover { background: var(--accent-soft); }

/* ---------- page footer nav --------------------------------- */

.pagenav {
  display: flex;
  gap: 10px;
  margin-top: 3em;
  padding-top: 1.4em;
  border-top: 1px solid var(--line);
}
.pagenav a {
  flex: 1 1 0;
  display: flex;
  align-items: center;
  min-height: 48px;
  padding: 10px 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
  color: var(--ink-2);
  text-decoration: none;
  font-weight: 600;
  font-size: .9rem;
}
.pagenav a:hover { border-color: var(--accent); background: var(--panel); }
.pagenav a.next { justify-content: flex-end; text-align: right; }
.pagenav a.home { justify-content: center; text-align: center; }

/* ============================================================
   PRINT — browser Print → Save as PDF (A4).
   @page margins live in each page <head> (guide vs checklist).
   ============================================================ */

@media print {
  .topbar, .no-print, .pagenav, .mini-nav, .menu-arrow { display: none !important; }

  body { font-size: 10.3pt; line-height: 1.45; color: #000; }
  main { max-width: none; padding: 0; }
  a { color: inherit; text-decoration: none; }

  h1, h2, h3 { break-after: avoid; page-break-after: avoid; }
  h2.sec { page-break-before: auto; }

  .card, .slot, .box, .kv, .menu-card, .closing { break-inside: avoid; page-break-inside: avoid; }

  .cover { page-break-after: always; }
  .cards, .slots { gap: 8px; }
  .card, .slot { padding: 9px 11px; }
  .box { padding: 9px 12px; margin: .8em 0; }

  .pair .zh, .card-label .zh, .box-title .zh, .h2 .zh-lead,
  .zh, .zh-lead { font-size: 8.6pt; line-height: 1.4; }

  .page-break { page-break-before: always; }

  /* checklist: keep each of the three sheets tidy */
  .sheet { page-break-after: always; }
  .sheet:last-of-type { page-break-after: auto; }
  .cb { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}

/* ============================================================
   Language toggle — EN (default) / 中文-only.
   Body carries .lang-en or .lang-zh (set by assets/app.js).
   ============================================================ */
.lang-en .zh, .lang-en .zh-lead { display: none !important; }
.lang-zh .en { display: none !important; }

/* Login link — first item, top-left of the top bar */
.topbar-login {
  display: inline-flex;
  align-items: center;
  min-height: 34px;
  padding: 0 11px;
  border: 1px solid var(--line);
  border-radius: 10px;
  color: var(--accent-ink);
  font-weight: 650;
  font-size: .8rem;
  letter-spacing: .02em;
  text-decoration: none;
  white-space: nowrap;
}
.topbar-login:hover { background: var(--accent-soft); border-color: var(--accent); }

/* Segmented EN / 中文 switch — right side of the top bar */
.lang-toggle {
  flex: 0 0 auto;
  display: inline-flex;
  gap: 2px;
  padding: 2px;
  margin-left: 8px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--panel);
}
.lang-btn {
  -webkit-appearance: none;
  appearance: none;
  border: 0;
  background: transparent;
  font: inherit;
  font-size: .72rem;
  font-weight: 700;
  letter-spacing: .04em;
  color: var(--muted);
  padding: 4px 10px;
  border-radius: 999px;
  cursor: pointer;
  line-height: 1.2;
}
.lang-btn:hover { color: var(--accent-ink); }
.lang-btn.active { background: var(--accent); color: #fff; }
.lang-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }

/* ============================================================
   Private area (login.html / private.html)
   ============================================================ */
.authwrap { max-width: 440px; margin: 8vh auto 0; }
.authcard {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  box-shadow: var(--shadow);
  padding: 24px 22px;
}
.authcard h1 { margin: 0 0 .15em; font-size: 1.55rem; }
.authcard label {
  display: block;
  font-weight: 650;
  font-size: .92rem;
  margin: 1em 0 .35em;
}
.authcard input[type=password] {
  width: 100%;
  min-height: 46px;
  padding: 10px 12px;
  font: inherit;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
}
.authcard input[type=password]:focus { outline: 2px solid var(--accent); outline-offset: 1px; border-color: var(--accent); }
.authbtn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: 48px;
  margin-top: 1.1em;
  border: 0;
  border-radius: 12px;
  background: var(--accent);
  color: #fff;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}
.authbtn:hover { background: var(--accent-ink); }
.auth-msg { min-height: 1.25em; margin-top: .8em; font-size: .9rem; font-weight: 600; color: #a23c3c; }
.auth-note { margin-top: 1.1em; font-size: .84rem; color: var(--muted); }

@media print {
  .lang-toggle, .topbar-login { display: none !important; }
}

/* ============================================================
   Brand logo
   ============================================================ */
.topbar-logo { width: 26px; height: 26px; border-radius: 7px; flex: 0 0 auto; margin-right: 9px; }
.cover-logo { width: 60px; height: 60px; border-radius: 16px; display: block; margin: 0 0 .55em; box-shadow: var(--shadow); }

/* ============================================================
   Print (A4) — every web page prints to A4 with real margins.
   ============================================================ */
@media print {
  @page { size: A4; margin: 16mm 15mm; }
  html, body { background: #fff !important; }
  .topbar, .pagenav, .mini-nav, .no-print, .lang-toggle, .printbtn, .menu-arrow { display: none !important; }
  .zh, .zh-lead { display: none !important; }
  body.lang-zh .en { display: revert !important; }
  .card, .slot, .wk-row, .money-row, .menu-card, article, li, tr { break-inside: avoid; }
  h1, h2, h3 { break-after: avoid; }
  a { color: inherit !important; text-decoration: none !important; }
  .sheet { break-after: page; }
}
