/* Trông Con · ứng dụng của bố mẹ.
   Theo thói quen giao diện của iPhone: nền nhóm màu xám nhạt, thẻ bo tròn không viền, tiêu đề lớn, thanh trên trong mờ,
   thanh tab dưới đáy trên điện thoại, nút cao 44 điểm, tấm trượt từ dưới lên, màu hệ thống cho cả sáng và tối, phông hệ thống.
   CSP của trang cấm style viết thẳng trong HTML: mọi kiểu dáng đều đi qua lớp ở đây. */
:root {
  color-scheme: light dark;
  --bg: #f2f2f7; --card: #ffffff; --fill: rgba(118, 118, 128, .12); --fill-2: rgba(118, 118, 128, .2);
  --ink: #000000; --muted: rgba(60, 60, 67, .68); --faint: rgba(60, 60, 67, .36); --line: rgba(60, 60, 67, .18);
  --accent: #007aff; --accent-ink: #ffffff; --accent-soft: rgba(0, 122, 255, .12);
  --good: #248a3d; --good-fill: #34c759; --good-soft: rgba(52, 199, 89, .16);
  --warn: #b25000; --warn-fill: #ff9500; --warn-soft: rgba(255, 149, 0, .16);
  --bad: #d70015; --bad-fill: #ff3b30; --bad-soft: rgba(255, 59, 48, .13);
  --grey-fill: #8e8e93;
  --bar: rgba(249, 249, 249, .82); --shadow: 0 1px 2px rgba(0, 0, 0, .04);
  --r-card: 16px; --r-ctl: 12px; --tabbar: 0px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #000000; --card: #1c1c1e; --fill: rgba(118, 118, 128, .24); --fill-2: rgba(118, 118, 128, .36);
    --ink: #ffffff; --muted: rgba(235, 235, 245, .64); --faint: rgba(235, 235, 245, .32); --line: rgba(84, 84, 88, .6);
    --accent: #0a84ff; --accent-ink: #ffffff; --accent-soft: rgba(10, 132, 255, .2);
    --good: #30d158; --good-fill: #30d158; --good-soft: rgba(48, 209, 88, .18);
    --warn: #ff9f0a; --warn-fill: #ff9f0a; --warn-soft: rgba(255, 159, 10, .18);
    --bad: #ff453a; --bad-fill: #ff453a; --bad-soft: rgba(255, 69, 58, .18);
    --grey-fill: #8e8e93;
    --bar: rgba(22, 22, 24, .8); --shadow: none;
  }
}
* { box-sizing: border-box; }
html { font-size: 16px; -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 1rem/1.42 -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", system-ui, Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased; -webkit-tap-highlight-color: transparent; overscroll-behavior-y: none;
}
h1, h2, h3 { line-height: 1.2; margin: 0; letter-spacing: -.01em; }
h1 { font-size: 2.125rem; font-weight: 700; letter-spacing: -.02em; } h2 { font-size: 1.25rem; font-weight: 700; } h3 { font-size: 1.0625rem; font-weight: 600; }
p { margin: 0 0 8px; }
a { color: var(--accent); text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; touch-action: manipulation; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; border-radius: 8px; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: .875rem; }
.num { font-variant-numeric: tabular-nums; }
.boot { text-align: center; color: var(--muted); padding: 30vh 20px 0; }

/* nút: xám nhạt là nút thường, xanh đặc là việc chính, chữ xanh là việc phụ, đỏ là việc không hoàn tác được */
.btn {
  display: inline-flex; align-items: center; justify-content: center; min-height: 44px; padding: 9px 16px;
  border: 0; border-radius: var(--r-ctl); background: var(--fill); color: var(--accent);
  font-weight: 600; text-decoration: none; text-align: center; line-height: 1.2;
}
.btn:hover { background: var(--fill-2); }
.btn:active { opacity: .7; }
.btn.primary { background: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { background: var(--accent); filter: brightness(1.06); }
.btn.danger { color: var(--bad); }
.btn.danger.solid { background: var(--bad-fill); color: #ffffff; }
.btn.quiet { background: transparent; font-weight: 500; }
.btn.quiet:hover { background: var(--fill); }
.btn.sm { min-height: 36px; padding: 6px 12px; font-size: .875rem; border-radius: 10px; }
.btn.wide { width: 100%; }
.btn:disabled { opacity: .45; cursor: default; filter: none; }

/* ô nhập */
input[type=text], input[type=password], input[type=number], input[type=date], textarea, select {
  border: 0; border-radius: 10px; background: var(--fill); padding: 10px 12px; min-height: 44px; max-width: 100%;
}
input[type=checkbox] { width: 22px; height: 22px; accent-color: var(--accent); flex: none; }
.field { display: block; margin-bottom: 14px; }
.field > span { display: block; font-weight: 600; font-size: .8125rem; color: var(--muted); margin-bottom: 6px; }
.field input[type=text], .field input[type=number] { width: 100%; }
.field .hint { display: block; font-weight: 400; margin-top: 5px; }

/* nút chọn một trong vài giá trị */
.seg { display: flex; background: var(--fill); border-radius: 11px; padding: 3px; }
.seg button { flex: 1; min-width: 0; border: 0; background: transparent; border-radius: 8px; padding: 6px 4px; min-height: 38px; font-weight: 500; font-size: .9375rem; color: var(--ink); white-space: nowrap; }
.seg button[aria-pressed=true] { background: var(--card); font-weight: 600; box-shadow: 0 1px 3px rgba(0, 0, 0, .14); }
@media (prefers-color-scheme: dark) { .seg button[aria-pressed=true] { background: rgba(118, 118, 128, .5); } }

/* đăng nhập */
.login { min-height: 100vh; min-height: 100dvh; display: flex; align-items: center; justify-content: center; padding: calc(20px + env(safe-area-inset-top)) 20px calc(20px + env(safe-area-inset-bottom)); }
.login form { background: var(--card); border-radius: 22px; box-shadow: var(--shadow); padding: 28px 24px; width: 100%; max-width: 380px; }
.login img { display: block; width: 64px; height: 64px; border-radius: 15px; margin-bottom: 16px; }
.login h1 { font-size: 2rem; margin-bottom: 4px; }
.login p { margin: 0 0 20px; color: var(--muted); }
.login label { display: block; font-weight: 600; font-size: .875rem; color: var(--muted); margin-bottom: 6px; }
.login label.second { margin-top: 16px; }
.login input[type=password], .login input[type=text] { width: 100%; min-height: 48px; }
.login input#code { letter-spacing: .3em; font-size: 1.25rem; font-variant-numeric: tabular-nums; }
.login label.keep { display: flex; align-items: flex-start; margin-top: 18px; font-weight: 400; color: var(--ink); }
.login label.keep input { margin: 0 10px 0 0; }
.login .btn { width: 100%; margin-top: 20px; min-height: 50px; font-size: 1.0625rem; }
.login .error { color: var(--bad); margin: 12px 0 0; min-height: 1.5em; font-size: .9375rem; }

/* khung: thanh trên trong mờ, thanh tab dưới đáy trên điện thoại */
.top {
  position: sticky; top: 0; z-index: 20; background: var(--bar); border-bottom: .5px solid var(--line);
  -webkit-backdrop-filter: saturate(180%) blur(20px); backdrop-filter: saturate(180%) blur(20px);
  padding-top: env(safe-area-inset-top);
}
.top .in { max-width: 860px; margin: 0 auto; padding: 8px calc(20px + env(safe-area-inset-right)) 8px calc(20px + env(safe-area-inset-left)); display: flex; align-items: center; min-height: 52px; }
.brand { font-weight: 700; font-size: 1.0625rem; margin-right: 20px; white-space: nowrap; }
.nav { display: flex; flex: 1; }
.nav a { color: var(--ink); padding: 7px 12px; border-radius: 10px; font-weight: 500; margin-right: 2px; }
.nav a:hover { background: var(--fill); }
.nav a.on { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
main { max-width: 860px; margin: 0 auto; padding: 20px calc(20px + env(safe-area-inset-right)) calc(48px + var(--tabbar) + env(safe-area-inset-bottom)) calc(20px + env(safe-area-inset-left)); }
.tabbar { display: none; }
@media (max-width: 760px) {
  :root { --tabbar: 58px; }
  .top .in { padding-top: 6px; padding-bottom: 6px; min-height: 44px; justify-content: center; }
  .top .nav { display: none; }
  .brand { margin-right: 0; }
  main { padding-left: calc(16px + env(safe-area-inset-left)); padding-right: calc(16px + env(safe-area-inset-right)); padding-top: 14px; }
  h1 { font-size: 1.875rem; }
  .tabbar {
    display: flex; position: fixed; left: 0; right: 0; bottom: 0; z-index: 20; background: var(--bar); border-top: .5px solid var(--line);
    -webkit-backdrop-filter: saturate(180%) blur(20px); backdrop-filter: saturate(180%) blur(20px);
    padding: 6px calc(4px + env(safe-area-inset-right)) calc(4px + env(safe-area-inset-bottom)) calc(4px + env(safe-area-inset-left));
  }
  .tabbar a { flex: 1; min-width: 0; min-height: 44px; display: flex; flex-direction: column; align-items: center; justify-content: center; color: var(--muted); font-size: .6875rem; font-weight: 500; }
  .tabbar a.on { color: var(--accent); font-weight: 600; }
  .tabbar .ico { display: flex; height: 26px; align-items: center; margin-bottom: 2px; }
}
.ico svg { width: 25px; height: 25px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.head { display: flex; flex-wrap: wrap; align-items: center; margin: 4px 0 16px; }
.head h1 { flex: 1; min-width: 160px; }
.sechead { margin: 26px 4px 8px; font-size: .8125rem; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .03em; }

/* thẻ, nhãn, ghi chú */
.card { background: var(--card); border-radius: var(--r-card); box-shadow: var(--shadow); padding: 16px; margin-bottom: 16px; }
.card > h2 { margin-bottom: 4px; }
.tag { display: inline-flex; align-items: center; font-size: .75rem; font-weight: 600; padding: 3px 9px; border-radius: 999px; background: var(--fill); color: var(--muted); white-space: nowrap; }
.tag.good { color: var(--good); background: var(--good-soft); }
.tag.warn { color: var(--warn); background: var(--warn-soft); }
.tag.bad { color: var(--bad); background: var(--bad-soft); }
.notice { background: var(--warn-soft); color: var(--ink); padding: 12px 14px; border-radius: 14px; margin-bottom: 16px; }
.notice p { margin: 0 0 6px; } .notice p:last-child { margin: 0; }
.notice.bad { background: var(--bad-soft); }
.notice .btn { margin-top: 8px; background: var(--card); }
.state { text-align: center; color: var(--muted); padding: 34px 16px; }
.state h2 { color: var(--ink); margin-bottom: 6px; }
.state .btn { margin-top: 14px; }
.spin { display: inline-block; width: 16px; height: 16px; margin-right: 8px; vertical-align: -3px; border: 2px solid var(--accent); border-right-color: transparent; border-radius: 50%; animation: spin .9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.toast {
  position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(18px + var(--tabbar) + env(safe-area-inset-bottom)); z-index: 70;
  background: rgba(40, 40, 44, .94); color: #fff; padding: 11px 18px; border-radius: 999px; max-width: min(92vw, 520px); text-align: center;
  font-size: .9375rem; font-weight: 500; box-shadow: 0 6px 24px rgba(0, 0, 0, .22);
}
.toast.bad { background: #c9001a; }
.actions { display: flex; flex-wrap: wrap; align-items: center; margin: 12px -4px -4px; }
.actions > * { margin: 4px; }

/* màn hình Máy */
.dev-head { display: flex; align-items: center; margin-bottom: 6px; }
.dev-head h2 { flex: 1; min-width: 0; overflow-wrap: anywhere; font-size: 1.375rem; }
.health { display: flex; align-items: flex-start; margin: 0 0 12px; font-weight: 500; }
.dot { flex: none; width: 12px; height: 12px; border-radius: 50%; margin: 5px 9px 0 0; background: var(--grey-fill); }
.health.good .dot { background: var(--good-fill); box-shadow: 0 0 0 4px var(--good-soft); }
.health.bad .dot { background: var(--bad-fill); box-shadow: 0 0 0 4px var(--bad-soft); }
.health.good { color: var(--good); }
.health.bad { color: var(--bad); }
.health.off, .health.stale { color: var(--muted); }
.facts { margin: 0 0 14px; }
.facts div { display: flex; padding: 9px 0; border-top: .5px solid var(--line); }
.facts dt { flex: 0 0 104px; color: var(--muted); font-size: .9375rem; }
.facts dd { flex: 1; min-width: 0; margin: 0; overflow-wrap: anywhere; }
.facts dd small { display: block; color: var(--muted); font-size: .875rem; }
.bigbtns { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); grid-gap: 10px; }
.bigbtn { display: flex; flex-direction: column; align-items: center; justify-content: center; min-height: 84px; padding: 10px 6px; border: 0; border-radius: 16px; background: var(--fill); color: var(--ink); font-weight: 600; font-size: 1.0625rem; }
.bigbtn .ico { margin-bottom: 6px; }
.bigbtn .ico svg { width: 28px; height: 28px; }
.bigbtn:hover { background: var(--fill-2); }
.bigbtn:active { opacity: .7; }
.bigbtn:disabled { opacity: .45; cursor: default; }
.bigbtn.lock { color: var(--bad); background: var(--bad-soft); }
.bigbtn.allow { color: var(--good); background: var(--good-soft); }
.result { margin: 12px 0 0; padding: 10px 12px; border-radius: 12px; background: var(--fill); font-size: .9375rem; }
.result.ok { background: var(--good-soft); }
.result.wait { background: var(--warn-soft); }
.result.bad { background: var(--bad-soft); }
.result.run { background: var(--accent-soft); }
.shotrow { display: flex; align-items: center; margin-top: 14px; padding-top: 14px; border-top: .5px solid var(--line); }
.shotrow .thumb { flex: 0 0 112px; height: 70px; margin-right: 12px; border-radius: 10px; overflow: hidden; background: var(--fill); display: flex; align-items: center; justify-content: center; color: var(--faint); font-size: .75rem; text-align: center; }
.shotrow .thumb img { display: block; width: 100%; height: 100%; object-fit: cover; }
.shotrow .meta { flex: 1; min-width: 0; font-size: .875rem; color: var(--muted); }
.shotrow .btn { flex: none; margin-left: 8px; }

/* màn hình Ảnh */
.daybar { display: flex; align-items: center; margin-bottom: 12px; }
.daybar input[type=date] { flex: 1; min-width: 0; margin: 0 8px; text-align: center; }
.daybar .btn { flex: none; min-width: 44px; padding-left: 10px; padding-right: 10px; }
.shots { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); grid-gap: 10px; }
.shots button { display: block; padding: 0; border: 0; border-radius: 12px; overflow: hidden; background: var(--card); color: var(--ink); text-align: left; box-shadow: var(--shadow); }
.shots img { display: block; width: 100%; aspect-ratio: 16 / 10; object-fit: cover; background: var(--fill); }
.shots span { display: block; padding: 6px 10px 8px; font-size: .875rem; font-weight: 600; font-variant-numeric: tabular-nums; }
.shots span small { font-weight: 400; color: var(--muted); margin-left: 6px; }
@media (max-width: 420px) { .shots { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.viewer { position: fixed; top: 0; right: 0; bottom: 0; left: 0; z-index: 50; background: #000; color: #fff; display: flex; flex-direction: column; }
.viewer .vbar { display: flex; align-items: center; padding: calc(8px + env(safe-area-inset-top)) calc(12px + env(safe-area-inset-right)) 8px calc(16px + env(safe-area-inset-left)); }
.viewer .vbar div { flex: 1; min-width: 0; font-weight: 600; font-variant-numeric: tabular-nums; }
.viewer .vbar small { display: block; font-weight: 400; color: rgba(255, 255, 255, .64); }
.viewer .vimg { flex: 1; min-height: 0; display: flex; align-items: center; justify-content: center; overflow: auto; }
.viewer .vimg img { max-width: 100%; max-height: 100%; object-fit: contain; }
.viewer .vfoot { display: flex; padding: 8px calc(12px + env(safe-area-inset-right)) calc(10px + env(safe-area-inset-bottom)) calc(12px + env(safe-area-inset-left)); }
.viewer .btn { background: rgba(255, 255, 255, .16); color: #fff; }
.viewer .vfoot .btn { flex: 1; margin: 0 4px; }
.viewer .btn.danger { color: #ff6961; }

/* màn hình Cài đặt */
.rowlist > div { display: flex; align-items: center; padding: 10px 0; border-top: .5px solid var(--line); }
.rowlist > div:first-child { border-top: 0; }
.rowlist > div > span { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.rowlist small { display: block; color: var(--muted); }
.codebox { text-align: center; margin: 14px 0; }
.codebox b { display: block; font-size: 2.75rem; letter-spacing: .12em; font-variant-numeric: tabular-nums; line-height: 1.1; }
.cmdline { display: block; background: var(--fill); border-radius: 10px; padding: 10px 12px; margin: 8px 0; font: .875rem/1.4 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; overflow-wrap: anywhere; user-select: all; -webkit-user-select: all; }

/* màn hình Nhật ký */
.log { padding: 4px 16px; }
.log > div { display: flex; padding: 11px 0; border-top: .5px solid var(--line); }
.log > div:first-child { border-top: 0; }
.log time { flex: 0 0 64px; color: var(--muted); font-size: .8125rem; font-variant-numeric: tabular-nums; padding-top: 2px; }
.log p { flex: 1; min-width: 0; margin: 0; overflow-wrap: anywhere; }
.log p small { display: block; color: var(--muted); margin-top: 2px; }
.log .bad { color: var(--bad); }
.log .tag { margin-right: 6px; }

/* tấm trượt từ dưới lên trên điện thoại, hộp giữa màn hình trên máy tính */
.sheet { position: fixed; top: 0; right: 0; bottom: 0; left: 0; z-index: 60; background: rgba(0, 0, 0, .4); display: flex; align-items: center; justify-content: center; padding: 16px; animation: fade .2s ease; }
.sheet-in { background: var(--card); color: var(--ink); border-radius: 20px; padding: 20px; width: 100%; max-width: 440px; max-height: 100%; overflow: auto; box-shadow: 0 20px 60px rgba(0, 0, 0, .3); }
.sheet-in h2 { margin: 0 0 6px; }
.sheet-in .stack .btn { width: 100%; margin-top: 10px; }
@media (max-width: 640px) {
  .sheet { align-items: flex-end; padding: 0; }
  .sheet-in { max-width: none; border-radius: 22px 22px 0 0; padding: 10px calc(18px + env(safe-area-inset-right)) calc(16px + env(safe-area-inset-bottom)) calc(18px + env(safe-area-inset-left)); max-height: 92vh; animation: rise .28s cubic-bezier(.2, .8, .2, 1); }
  .sheet-in::before { content: ""; display: block; width: 36px; height: 5px; border-radius: 3px; background: var(--faint); margin: 0 auto 12px; }
}
@keyframes fade { from { opacity: 0; } }
@keyframes rise { from { transform: translateY(100%); } }
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }
