/* [hidden] must beat class rules that set display (.sheet, .view, .topbar-actions).
   Without this the modals and every view render on page load and Cancel does nothing. */
[hidden] { display: none !important; }

:root {
  --ink: #3B2A1E;
  --muted: #6B5A4B;
  --page: #FFF8EF;
  --card: #FFFFFF;
  --line: #EFE0CE;
  --accent: #C8742F;
  --accent-ink: #A2531D;
  --grass: #5F8A4E;
  --grass-soft: #F1F5EC;
  --alert: #B8452E;
  --alert-soft: #FBE7E1;
  --radius: 18px;
  --display: Fredoka, system-ui, sans-serif;
  --body: Nunito, system-ui, sans-serif;
}

body[data-skin="lcd"] {
  --ink: #22300F;
  --muted: #3E5221;
  --page: #8FA646;
  --card: #A9BF52;
  --line: #6D4020;
  --accent: #6D4020;
  --accent-ink: #3E2410;
  --grass: #3E5221;
  --grass-soft: #9CB44C;
  --alert: #7A2A18;
  --alert-soft: #9CB44C;
  --radius: 6px;
  --display: Silkscreen, monospace;
  --body: Silkscreen, monospace;
}
body[data-skin="lcd"] .card,
body[data-skin="lcd"] .pet { border-width: 3px; box-shadow: none; }
body[data-skin="lcd"] h1 { font-size: 20px; letter-spacing: 1px; }
body[data-skin="lcd"] h2 { font-size: 13px; letter-spacing: 1px; }
body[data-skin="lcd"] .btn,
body[data-skin="lcd"] .nav-item,
body[data-skin="lcd"] .choice { font-size: 11px; letter-spacing: 0.5px; border-radius: 6px; }
body[data-skin="lcd"] .pet-name { font-size: 20px; }
body[data-skin="lcd"] .stat-big { font-size: 22px; }

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: var(--body);
  color: var(--ink);
  background: var(--page);
  -webkit-text-size-adjust: 100%;
}

h1 { font-family: var(--display); font-size: 24px; margin: 0; font-weight: 600; }
h2 { font-family: var(--display); font-size: 17px; margin: 0 0 10px; font-weight: 600; }
p { margin: 0; }
.muted { color: var(--muted); font-size: 13px; line-height: 1.5; }
.sub { color: var(--muted); font-size: 13px; font-weight: 600; margin-top: 3px; }
.kicker { font-size: 11px; font-weight: 800; letter-spacing: 1.3px; color: var(--accent-ink); margin-bottom: 5px; }

.shell { display: flex; min-height: 100dvh; }

/* ---------- nav ---------- */
.nav {
  display: flex;
  gap: 4px;
  background: var(--card);
  border-top: 2px solid var(--line);
  position: fixed;
  inset: auto 0 0 0;
  padding: 8px 6px calc(8px + env(safe-area-inset-bottom));
  z-index: 20;
}
.brand, .nav-foot { display: none; }
.nav-item {
  flex: 1 1 0;
  min-height: 52px;
  border: 0;
  border-radius: 12px;
  background: transparent;
  color: var(--muted);
  font-family: var(--body);
  font-weight: 700;
  font-size: 12px;
  cursor: pointer;
}
.nav-item.is-on { background: var(--grass-soft); color: var(--ink); }

/* ---------- main ---------- */
.main {
  flex: 1 1 auto;
  padding: 18px 16px calc(84px + env(safe-area-inset-bottom));
  max-width: 1280px;
  margin: 0 auto;
  width: 100%;
}
.topbar { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; margin-bottom: 16px; }
.topbar-actions { display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }

.card {
  background: var(--card);
  border: 2px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
}
.stack { display: flex; flex-direction: column; gap: 14px; }
.grid-2 { display: grid; grid-template-columns: 1fr; gap: 14px; }
.view { display: flex; flex-direction: column; gap: 14px; }
.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-top: 10px; }

/* ---------- pet header ---------- */
.pet {
  display: flex; align-items: center; gap: 14px;
  background: var(--card); border: 2px solid var(--line);
  border-radius: var(--radius); padding: 14px; margin-bottom: 14px;
}
.pet-art { width: 84px; height: 84px; flex: 0 0 auto; border-radius: 20px; background: var(--grass-soft); display: flex; align-items: center; justify-content: center; }
.pet-art svg { width: 62px; height: 48px; }
.pet-name { font-family: var(--display); font-size: 24px; }
.pet-line { color: var(--muted); font-size: 13px; font-weight: 600; }
.pet-stats { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 8px; font-size: 12px; color: var(--muted); font-weight: 600; }
.pet-stats b { color: var(--ink); font-size: 15px; }

/* ---------- tasks ---------- */
.tasks { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.tasks li { display: flex; align-items: center; gap: 12px; }
.tasks label { display: flex; align-items: center; gap: 12px; flex: 1 1 auto; min-height: 50px; padding: 0 14px; border: 2px solid var(--line); border-radius: 14px; cursor: pointer; font-weight: 700; font-size: 14px; }
.tasks label.done { background: var(--grass-soft); border-color: var(--grass-soft); color: var(--grass); text-decoration: line-through; }
.tasks input[type="checkbox"] { width: 20px; height: 20px; accent-color: var(--grass); flex: 0 0 auto; }
.icon-btn { min-width: 44px; min-height: 44px; border: 0; background: transparent; color: var(--muted); font-size: 18px; cursor: pointer; border-radius: 10px; }

/* ---------- ring ---------- */
.ring-card { display: flex; align-items: center; gap: 16px; }
.ring { width: 84px; height: 84px; flex: 0 0 auto; }
.ring-bg { fill: none; stroke: var(--line); stroke-width: 12; }
.ring-fg { fill: none; stroke: var(--grass); stroke-width: 12; stroke-linecap: round; stroke-dasharray: 0 239; transition: stroke-dasharray .4s ease; }

/* ---------- lists ---------- */
.loglist { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.loglist li { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--line); font-size: 13px; font-weight: 700; }
.loglist li:last-child { border-bottom: 0; }
.loglist .when { color: var(--muted); }
.loglist .what { text-align: right; }
.loglist .in { color: var(--alert); }
.loglist .out { color: var(--grass); }
.loglist .empty { color: var(--muted); font-weight: 600; justify-content: flex-start; }

/* ---------- streak grid ---------- */
.days { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 6px; }
.days div { aspect-ratio: 1 / 1; border-radius: 6px; background: var(--line); position: relative; }
.days .clean { background: var(--grass); }
.days .dirty { background: var(--alert); }
.legend { margin-top: 10px; display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.sw { width: 12px; height: 12px; border-radius: 3px; display: inline-block; }
.sw-clean { background: var(--grass); }
.sw-dirty { background: var(--alert); }
.sw-none { background: var(--line); }

.hours { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: 4px; align-items: end; height: 96px; }
.hours div { background: var(--accent); border-radius: 4px 4px 0 0; min-height: 3px; }
.hours span { display: block; font-size: 9px; text-align: center; color: var(--muted); }

/* ---------- tips ---------- */
.tips { display: flex; flex-direction: column; gap: 12px; }
.tips details { background: var(--card); border: 2px solid var(--line); border-radius: var(--radius); padding: 14px 16px; }
.tips summary { font-family: var(--display); font-size: 16px; cursor: pointer; min-height: 30px; }
.tips ul { margin: 10px 0 0; padding-left: 18px; }
.tips li { font-size: 14px; line-height: 1.55; margin-bottom: 7px; }
.tip p { font-size: 14px; line-height: 1.5; }

/* ---------- controls ---------- */
.btn {
  min-height: 46px; padding: 0 16px; border: 2px solid var(--line);
  border-radius: 12px; background: var(--card); color: var(--ink);
  font-family: var(--body); font-weight: 800; font-size: 14px; cursor: pointer;
}
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-danger { background: var(--alert-soft); border-color: var(--alert); color: var(--alert); }
.btn.is-on { background: var(--grass); border-color: var(--grass); color: #fff; }
.choices { display: flex; gap: 8px; flex-wrap: wrap; }
.choice { min-height: 46px; padding: 0 16px; border: 2px solid var(--line); border-radius: 12px; background: var(--card); font-family: var(--body); font-weight: 800; font-size: 14px; color: var(--ink); cursor: pointer; }
.choice.is-on { background: var(--grass); border-color: var(--grass); color: #fff; }
.field { display: flex; flex-direction: column; gap: 5px; margin-top: 10px; font-size: 12px; font-weight: 800; color: var(--muted); }
.field input, .row input[type="text"] {
  min-height: 46px; padding: 0 12px; border: 2px solid var(--line); border-radius: 12px;
  background: var(--card); color: var(--ink); font-family: var(--body); font-size: 15px; font-weight: 600;
}
.row input[type="text"] { flex: 1 1 160px; }

/* ---------- sheets ---------- */
.sheet { position: fixed; inset: 0; background: rgba(40,28,18,.45); display: flex; align-items: flex-end; justify-content: center; z-index: 40; }
.sheet-card { background: var(--card); width: 100%; max-width: 460px; border-radius: 20px 20px 0 0; padding: 20px 18px calc(20px + env(safe-area-inset-bottom)); max-height: 92dvh; overflow: auto; }

.toast { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(92px + env(safe-area-inset-bottom)); background: var(--ink); color: var(--page); padding: 10px 16px; border-radius: 999px; font-size: 13px; font-weight: 700; z-index: 50; }

.sync-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--muted); display: inline-block; }
.sync-dot.ok { background: var(--grass); }
.sync-dot.err { background: var(--alert); }
.sync-dot.busy { background: var(--accent); }

/* ---------- desktop ---------- */
@media (min-width: 900px) {
  .shell { gap: 0; }
  .nav {
    position: sticky; inset: 0 auto 0 0; height: 100dvh; width: 232px;
    flex-direction: column; border-top: 0; border-right: 2px solid var(--line);
    padding: 24px 16px; gap: 6px; flex: 0 0 232px;
  }
  .brand { display: flex; align-items: center; gap: 10px; margin-bottom: 18px; }
  .brand-mark { width: 34px; height: 26px; fill: var(--accent); stroke: var(--accent); }
  .brand-name { font-family: var(--display); font-size: 19px; }
  .nav-item { flex: 0 0 auto; text-align: left; padding: 0 14px; font-size: 15px; min-height: 46px; }
  .nav-foot { display: flex; align-items: center; gap: 8px; margin-top: auto; font-size: 12px; font-weight: 700; color: var(--muted); }
  .main { padding: 26px 30px 40px; }
  h1 { font-size: 27px; }
  .grid-2 { grid-template-columns: 1fr 1fr; align-items: start; }
  .pet-art { width: 96px; height: 96px; }
}
