/* PetKit Cats — daily-use PWA visual system.
 * Light, image-first: evidence media carries the screen while neutral surfaces
 * and restrained accent colors keep it readable in normal indoor lighting.
 * Stable aspect ratios + fixed-size controls avoid layout shift on load. */

:root {
  --bg: #f5f6f8;
  --surface: #ffffff;
  --surface-2: #f1f3f5;
  --surface-3: #e7eaef;
  --border: #e3e6ec;
  --border-strong: #d3d8e0;
  --text: #1f2329;
  --text-2: #4a5363;
  --muted: #7a8290;
  --accent: #e07a3c;          /* warm amber — primary actions */
  --accent-strong: #c9651f;
  --accent-ink: #ffffff;
  --accent-soft: rgba(224, 122, 60, 0.12);
  --ok: #2f9e6e;
  --ok-soft: rgba(47, 158, 110, 0.13);
  --warn: #b9791c;
  --warn-soft: rgba(185, 121, 28, 0.14);
  --danger: #d4485a;
  --danger-soft: rgba(212, 72, 90, 0.12);
  --radius: 16px;
  --radius-sm: 10px;
  --radius-xs: 8px;
  --pill: 999px;
  --shadow-card: 0 1px 2px rgba(20, 24, 31, 0.04), 0 6px 16px rgba(20, 24, 31, 0.05);
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --nav-h: 60px;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
html, body { margin: 0; padding: 0; height: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 -apple-system, BlinkMacSystemFont, system-ui, "Segoe UI", Roboto,
        "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  -webkit-font-smoothing: antialiased;
  padding-bottom: calc(var(--nav-h) + var(--safe-bottom));
}
a { color: var(--accent-strong); }

/* ── Top bar ─────────────────────────────────────────────────── */
.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  min-height: 52px;
  padding: 10px 16px; padding-top: max(10px, var(--safe-top));
  background: rgba(255, 255, 255, 0.86);
  backdrop-filter: saturate(180%) blur(10px);
  -webkit-backdrop-filter: saturate(180%) blur(10px);
  border-bottom: 1px solid var(--border);
}
.topbar-title { display: flex; align-items: center; gap: 8px; min-width: 0; }
.topbar-logo { font-size: 18px; line-height: 1; }
.topbar h1 { font-size: 16px; margin: 0; font-weight: 680; letter-spacing: -0.01em; }
.freshness {
  font-size: 12px; font-weight: 600; color: var(--warn);
  background: var(--warn-soft); padding: 4px 10px; border-radius: var(--pill);
  max-width: 60%; text-align: right; overflow: hidden; text-overflow: ellipsis;
  white-space: nowrap;
}

/* ── View container ──────────────────────────────────────────── */
.view { padding: 14px 14px 28px; max-width: 640px; margin: 0 auto; }
.view-narrow { max-width: 460px; }

.section-title {
  color: var(--muted); font-size: 12px; font-weight: 700;
  text-transform: uppercase; letter-spacing: .05em;
  margin: 20px 4px 10px; display: flex; align-items: center; justify-content: space-between;
}
.section-title:first-child { margin-top: 4px; }
.link-btn {
  background: none; border: 0; color: var(--accent-strong); font-weight: 650;
  font-size: 13px; padding: 4px 6px; cursor: pointer; margin: -4px -6px 0;
}

/* ── Generic controls ────────────────────────────────────────── */
input, select, textarea {
  width: 100%; padding: 12px 13px; border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong); background: var(--surface);
  color: var(--text); font-size: 15px; font-family: inherit;
}
input:focus { outline: 2px solid var(--accent); outline-offset: -1px; border-color: var(--accent); }
button {
  cursor: pointer; border: 0; border-radius: var(--radius-sm);
  background: var(--accent); color: var(--accent-ink);
  font-weight: 680; font-size: 15px; font-family: inherit;
  padding: 12px 16px; min-height: 44px;
  transition: background .12s ease, opacity .12s ease;
}
button:hover { background: var(--accent-strong); }
button.secondary {
  background: var(--surface); color: var(--text-2);
  border: 1px solid var(--border-strong);
}
button.secondary:hover { background: var(--surface-2); }
button.ghost { background: transparent; color: var(--accent-strong); }
button:disabled { opacity: 0.5; cursor: default; }
.row { display: flex; gap: 10px; }
.row > * { flex: 1; min-width: 0; }

/* ── Login ───────────────────────────────────────────────────── */
.login-wrap {
  min-height: 100vh; min-height: 100dvh; display: flex; flex-direction: column;
  align-items: center; justify-content: center; padding: 24px;
  background: linear-gradient(180deg, #fbf7f3 0%, var(--bg) 55%);
}
.login-brand { text-align: center; margin-bottom: 22px; }
.login-brand .logo { font-size: 44px; }
.login-brand h1 { margin: 6px 0 0; font-size: 22px; font-weight: 720; letter-spacing: -0.02em; }
.login-brand p { margin: 6px 0 0; color: var(--muted); font-size: 14px; }
.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 22px; width: 100%; max-width: 340px;
  box-shadow: var(--shadow-card);
}
.card label { display: block; font-size: 12px; font-weight: 600; color: var(--muted); margin: 0 0 6px; }
.card .help { margin: 6px 0 16px; color: var(--muted); font-size: 13px; }
.card button { width: 100%; margin-top: 4px; }

/* ── Status chips ────────────────────────────────────────────── */
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 11px; font-weight: 650; line-height: 1;
  padding: 5px 9px; border-radius: var(--pill); white-space: nowrap;
  background: var(--surface-2); color: var(--text-2); border: 1px solid transparent;
}
.chip .dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: .85; }
.chip.ok { background: var(--ok-soft); color: var(--ok); }
.chip.warn { background: var(--warn-soft); color: var(--warn); }
.chip.bad { background: var(--danger-soft); color: var(--danger); }
.chip.accent { background: var(--accent-soft); color: var(--accent-strong); }
.chip.muted { background: var(--surface-2); color: var(--muted); }

/* ── Hero (Today latest evidence) ────────────────────────────── */
.hero {
  display: block; background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow-card);
  color: inherit; text-decoration: none;
}
.media-frame {
  position: relative; width: 100%; aspect-ratio: 16 / 9; background: var(--surface-3);
  overflow: hidden;
}
.media-frame img, .media-frame video { width: 100%; height: 100%; object-fit: cover; display: block; }
.placeholder {
  width: 100%; height: 100%; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 6px;
  color: var(--muted); background: var(--surface-2);
}
.placeholder .glyph { font-size: 30px; opacity: .7; }
.placeholder .txt { font-size: 13px; font-weight: 600; }
.play-badge {
  position: absolute; right: 10px; bottom: 10px;
  display: inline-flex; align-items: center; gap: 6px;
  background: rgba(15, 18, 24, 0.78); color: #fff; font-size: 12px; font-weight: 650;
  padding: 6px 10px 6px 8px; border-radius: var(--pill); backdrop-filter: blur(4px);
}
.play-badge .tri { width: 0; height: 0; border-left: 8px solid #fff;
  border-top: 5px solid transparent; border-bottom: 5px solid transparent; }
.hero-overlay {
  position: absolute; left: 10px; top: 10px; display: flex; gap: 6px;
}
.hero-body { padding: 13px 15px 15px; }
.hero-title { font-size: 17px; font-weight: 690; margin: 2px 0 8px; letter-spacing: -0.01em; }
.ts { color: var(--muted); font-size: 12px; font-weight: 600; }

/* ── Today summary strip ─────────────────────────────────────── */
.summary {
  display: flex; align-items: center; gap: 12px; padding: 12px 14px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow-card);
}
.summary .num { font-size: 24px; font-weight: 740; color: var(--text); line-height: 1; }
.summary .lbl { color: var(--muted); font-size: 12px; margin-top: 3px; }
.summary .spacer { flex: 1; }
.summary .sub { text-align: right; font-size: 12px; color: var(--muted); }

/* ── Event rows (Events list) ────────────────────────────────── */
.day-head {
  position: sticky; top: 52px; z-index: 5;
  margin: 18px -4px 6px; padding: 6px 8px; font-size: 12px; font-weight: 700;
  text-transform: uppercase; letter-spacing: .04em; color: var(--text-2);
  background: linear-gradient(var(--bg), var(--bg));
}
.row-event {
  display: flex; gap: 12px; align-items: stretch;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 10px; margin-bottom: 8px;
  color: inherit; text-decoration: none; box-shadow: var(--shadow-card);
}
.row-thumb {
  flex: 0 0 96px; width: 96px; aspect-ratio: 4 / 3; border-radius: var(--radius-xs);
  background: var(--surface-3); overflow: hidden; position: relative;
}
.row-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.row-thumb .mini-placeholder {
  width: 100%; height: 100%; display: flex; align-items: center; justify-content: center;
  color: var(--muted); font-size: 20px; background: var(--surface-2);
}
.row-body { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.row-body .name { font-weight: 680; font-size: 15px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row-body .meta { display: flex; flex-wrap: wrap; gap: 4px 8px; color: var(--muted); font-size: 12px; }
.row-body .meta .sep { opacity: .5; }
.row-body .chips { margin-top: auto; padding-top: 5px; }

/* ── Detail / evidence page ──────────────────────────────────── */
.back-row { display: flex; align-items: center; margin: 2px 2px 12px; }
.back-btn {
  display: inline-flex; align-items: center; gap: 6px; background: none; border: 0;
  color: var(--text-2); font-size: 14px; font-weight: 650; padding: 6px 4px; min-height: 0;
}
.back-btn:hover { color: var(--accent-strong); }
.detail-hero { border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow-card); }
.detail-hero video, .detail-hero img { width: 100%; display: block; background: #000; }
.detail-title { font-size: 20px; font-weight: 720; margin: 14px 0 4px; letter-spacing: -0.01em; }
.notice {
  display: flex; gap: 10px; align-items: flex-start; padding: 12px 14px; border-radius: var(--radius-sm);
  font-size: 13px; margin: 10px 0;
}
.notice .glyph { font-size: 16px; line-height: 1.4; }
.notice.warn { background: var(--warn-soft); color: var(--warn); }
.notice.bad { background: var(--danger-soft); color: var(--danger); }
.notice.muted { background: var(--surface-2); color: var(--text-2); }

.kv {
  display: grid; grid-template-columns: 112px 1fr; gap: 8px 14px;
  margin-top: 6px; font-size: 14px;
}
.kv dt { color: var(--muted); }
.kv dd { margin: 0; font-weight: 600; word-break: break-word; }

/* ── List (Cats / System rows) ───────────────────────────────── */
.list {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow-card);
}
.list .item {
  display: flex; justify-content: space-between; align-items: center; gap: 12px;
  padding: 13px 15px; border-bottom: 1px solid var(--border);
}
.list .item:last-child { border-bottom: 0; }
.list .item .k { color: var(--text-2); font-size: 14px; font-weight: 600; min-width: 0; }
.list .item .v { font-weight: 680; text-align: right; font-size: 14px; display: inline-flex; align-items: center; gap: 7px; }
.list .item .desc { color: var(--muted); font-size: 12px; margin-top: 2px; font-weight: 500; }
.list .item .col { min-width: 0; }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; }
.dot.ok { background: var(--ok); } .dot.warn { background: var(--warn); } .dot.bad { background: var(--danger); } .dot.muted { background: var(--muted); }
.system-group { margin-bottom: 14px; }
.cat-avatar {
  flex: 0 0 40px; width: 40px; height: 40px; border-radius: 50%;
  background: var(--surface-2); display: flex; align-items: center; justify-content: center;
  font-size: 20px; border: 1px solid var(--border);
}

/* ── States ──────────────────────────────────────────────────── */
.state {
  text-align: center; padding: 56px 24px; color: var(--muted);
}
.state .glyph { font-size: 40px; opacity: .8; }
.state .title { font-size: 16px; font-weight: 690; color: var(--text-2); margin: 10px 0 4px; }
.state .sub { font-size: 13px; }
.skeleton {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  overflow: hidden; box-shadow: var(--shadow-card);
}
.skeleton .bar { background: var(--surface-2); }
.skeleton .media-frame { background: var(--surface-2); }
.skeleton .line { height: 12px; margin: 10px 15px; border-radius: 6px; background: var(--surface-2); }
.skeleton .line.short { width: 45%; }

.load-more { display: block; margin: 14px auto 4px; }

/* ── Bottom navigation ───────────────────────────────────────── */
.tabbar {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 20;
  display: grid; grid-template-columns: repeat(4, 1fr);
  background: rgba(255, 255, 255, 0.94);
  backdrop-filter: saturate(180%) blur(12px);
  -webkit-backdrop-filter: saturate(180%) blur(12px);
  border-top: 1px solid var(--border);
  padding-bottom: var(--safe-bottom);
}
.tabbar .tab {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  padding: 8px 2px; color: var(--muted); text-decoration: none;
  font-size: 11px; font-weight: 600; min-height: var(--nav-h);
}
.tabbar .tab .tab-icon {
  width: 24px; height: 24px; display: block;
  background-repeat: no-repeat; background-position: center; background-size: 24px 24px;
  opacity: .9;
}
.tabbar .tab.active { color: var(--accent-strong); }
.tabbar .tab.active .tab-icon { opacity: 1; }

/* Tab icons (inline SVG, currentColor) — visible without JS. */
.tab[data-tab="today"]  .tab-icon { background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%237a8290' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'><circle cx='12' cy='12' r='4'/><path d='M12 2v2M12 20v2M4.9 4.9l1.4 1.4M17.7 17.7l1.4 1.4M2 12h2M20 12h2M4.9 19.1l1.4-1.4M17.7 6.3l1.4-1.4'/></svg>"); }
.tab[data-tab="events"] .tab-icon { background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%237a8290' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'><line x1='8' y1='6' x2='21' y2='6'/><line x1='8' y1='12' x2='21' y2='12'/><line x1='8' y1='18' x2='21' y2='18'/><circle cx='3.5' cy='6' r='1.3' fill='%237a8290' stroke='none'/><circle cx='3.5' cy='12' r='1.3' fill='%237a8290' stroke='none'/><circle cx='3.5' cy='18' r='1.3' fill='%237a8290' stroke='none'/></svg>"); }
.tab[data-tab="cats"]   .tab-icon { background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%237a8290' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'><circle cx='5.5' cy='11' r='1.6'/><circle cx='9.5' cy='6.5' r='1.6'/><circle cx='14.5' cy='6.5' r='1.6'/><circle cx='18.5' cy='11' r='1.6'/><path d='M8 16c0-2 1.8-3 4-3s4 1 4 3-1.8 4-4 4-4-2-4-4z'/></svg>"); }
.tab[data-tab="system"] .tab-icon { background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%237a8290' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'><circle cx='12' cy='12' r='3'/><path d='M19.4 15a1.6 1.6 0 0 0 .3 1.8l.1.1a2 2 0 1 1-2.8 2.8l-.1-.1a1.6 1.6 0 0 0-1.8-.3 1.6 1.6 0 0 0-1 1.5V21a2 2 0 1 1-4 0v-.1a1.6 1.6 0 0 0-1-1.5 1.6 1.6 0 0 0-1.8.3l-.1.1a2 2 0 1 1-2.8-2.8l.1-.1a1.6 1.6 0 0 0 .3-1.8 1.6 1.6 0 0 0-1.5-1H3a2 2 0 1 1 0-4h.1a1.6 1.6 0 0 0 1.5-1 1.6 1.6 0 0 0-.3-1.8l-.1-.1a2 2 0 1 1 2.8-2.8l.1.1a1.6 1.6 0 0 0 1.8.3H9a1.6 1.6 0 0 0 1-1.5V3a2 2 0 1 1 4 0v.1a1.6 1.6 0 0 0 1 1.5 1.6 1.6 0 0 0 1.8-.3l.1-.1a2 2 0 1 1 2.8 2.8l-.1.1a1.6 1.6 0 0 0-.3 1.8V9a1.6 1.6 0 0 0 1.5 1H21a2 2 0 1 1 0 4h-.1a1.6 1.6 0 0 0-1.5 1z'/></svg>"); }
.tab[data-tab="today"].active  .tab-icon { background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='%23c9651f' stroke='%23c9651f' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'><circle cx='12' cy='12' r='4'/><path d='M12 2v2M12 20v2M4.9 4.9l1.4 1.4M17.7 17.7l1.4 1.4M2 12h2M20 12h2M4.9 19.1l1.4-1.4M17.7 6.3l1.4-1.4' fill='none'/></svg>"); }
.tab[data-tab="events"].active .tab-icon { background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23c9651f' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'><line x1='8' y1='6' x2='21' y2='6'/><line x1='8' y1='12' x2='21' y2='12'/><line x1='8' y1='18' x2='21' y2='18'/><circle cx='3.5' cy='6' r='1.4' fill='%23c9651f' stroke='none'/><circle cx='3.5' cy='12' r='1.4' fill='%23c9651f' stroke='none'/><circle cx='3.5' cy='18' r='1.4' fill='%23c9651f' stroke='none'/></svg>"); }
.tab[data-tab="cats"].active   .tab-icon { background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='%23c9651f' stroke='%23c9651f' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'><circle cx='5.5' cy='11' r='1.7'/><circle cx='9.5' cy='6.5' r='1.7'/><circle cx='14.5' cy='6.5' r='1.7'/><circle cx='18.5' cy='11' r='1.7'/><path d='M8 16c0-2 1.8-3 4-3s4 1 4 3-1.8 4-4 4-4-2-4-4z' fill='%23c9651f'/></svg>"); }
.tab[data-tab="system"].active .tab-icon { background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23c9651f' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'><circle cx='12' cy='12' r='3' fill='%23c9651f'/><path d='M19.4 15a1.6 1.6 0 0 0 .3 1.8l.1.1a2 2 0 1 1-2.8 2.8l-.1-.1a1.6 1.6 0 0 0-1.8-.3 1.6 1.6 0 0 0-1 1.5V21a2 2 0 1 1-4 0v-.1a1.6 1.6 0 0 0-1-1.5 1.6 1.6 0 0 0-1.8.3l-.1.1a2 2 0 1 1-2.8-2.8l.1-.1a1.6 1.6 0 0 0 .3-1.8 1.6 1.6 0 0 0-1.5-1H3a2 2 0 1 1 0-4h.1a1.6 1.6 0 0 0 1.5-1 1.6 1.6 0 0 0-.3-1.8l-.1-.1a2 2 0 1 1 2.8-2.8l.1.1a1.6 1.6 0 0 0 1.8.3H9a1.6 1.6 0 0 0 1-1.5V3a2 2 0 1 1 4 0v.1a1.6 1.6 0 0 0 1 1.5 1.6 1.6 0 0 0 1.8-.3l.1-.1a2 2 0 1 1 2.8 2.8l-.1.1a1.6 1.6 0 0 0-.3 1.8V9a1.6 1.6 0 0 0 1.5 1H21a2 2 0 1 1 0 4h-.1a1.6 1.6 0 0 0-1.5 1z'/></svg>"); }

/* ── Desktop: keep content constrained ───────────────────────── */
@media (min-width: 760px) {
  .view { max-width: 620px; }
  body { padding-bottom: calc(var(--nav-h) + var(--safe-bottom) + 12px); }
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #14171c; --surface: #1c2027; --surface-2: #232832; --surface-3: #2a303b;
    --border: #2c333e; --border-strong: #39414e; --text: #e9ecf1; --text-2: #c4cbd6;
    --muted: #8a93a3; --accent-soft: rgba(224,122,60,0.20); --ok-soft: rgba(47,158,110,0.20);
    --warn-soft: rgba(185,121,28,0.22); --danger-soft: rgba(212,72,90,0.20);
    --shadow-card: 0 1px 2px rgba(0,0,0,0.3), 0 6px 16px rgba(0,0,0,0.28);
  }
  .topbar { background: rgba(28,32,39,0.86); }
  .tabbar { background: rgba(28,32,39,0.94); }
  .day-head { background: linear-gradient(var(--bg), var(--bg)); }
}
