:root {
  color-scheme: light;
  --phone-width: 430px;
  --gutter: 16px;
  --nav-inset: 12px;
  --paper: #faf8f1;
  --tab-paper: #fbfaee;
  --white: #fff;
  --ink: #33302b;
  --muted: #686458;
  --line: #efecdf;
  --mint: #52b184;
  --mint-soft: #e8f6ef;
  --green: #36795b;
  --olive: #4b6700;
  --lime: #bfff00;
  --warm: #fbf1e2;
  --danger: #9c3d36;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  line-height: 1.6;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; background: #eeeae0; color: var(--ink); }
a { color: var(--green); text-decoration: none; }
a:hover { text-decoration: underline; }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
button:disabled { opacity: .55; cursor: wait; }
:focus-visible { outline: 2px solid var(--green); outline-offset: 3px; }
img { display: block; max-width: 100%; }
img.icon { width: 1.35rem; height: 1.35rem; object-fit: contain; }
h1, h2, h3, p { margin: 0; }
h1 { font-size: 1.85rem; line-height: 1.17; letter-spacing: -.025em; overflow-wrap: anywhere; }
h2 { font-size: 1.1rem; line-height: 1.4; }
h3 { font-size: 1rem; line-height: 1.45; }
p { overflow-wrap: anywhere; }
small, .muted { color: var(--muted); }
.skip { position: fixed; top: -10rem; padding: .75rem; z-index: 5; background: var(--white); }
.skip:focus { top: .5rem; }

.shell {
  width: 100%;
  max-width: var(--phone-width);
  min-height: 100vh;
  min-height: 100dvh;
  margin-inline: auto;
  background: var(--tab-paper);
}
@media (min-width: 431px) {
  .shell { box-shadow: 0 0 0 1px #20251c11, 0 0 42px #33302b15; }
}
.shell[data-page="health"] { background: var(--paper); }
.shell[data-page="diaries"] { background: linear-gradient(180deg, var(--tab-paper) 55%, #fff1ee); }
.shell[data-page="login"] {
  background:
    radial-gradient(circle 110px at 0 0, var(--mint-soft) 99%, transparent),
    radial-gradient(circle 140px at 111% 78%, var(--warm) 98%, transparent),
    var(--paper);
}
.shell[data-page="login"] .sidebar { display: none; }

.sidebar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .65rem;
  padding: max(12px, env(safe-area-inset-top)) max(var(--gutter), env(safe-area-inset-right)) 8px
    max(var(--gutter), env(safe-area-inset-left));
}
.brand { display: inline-flex; align-items: center; gap: .5rem; color: var(--ink); line-height: 1.3; }
.brand strong, .brand small { display: block; white-space: nowrap; }
.brand strong { font-size: .94rem; }
.brand small { font-size: .72rem; letter-spacing: .04em; }
.brand-mark, .tile-icon {
  display: grid; place-items: center; flex: none;
  width: 2.4rem; height: 2.4rem; background: var(--mint-soft); border-radius: .8rem;
}
.brand-mark img, nav img { width: 1.15rem; height: 1.15rem; object-fit: contain; }
.side-note { display: none; }

nav {
  position: fixed;
  z-index: 2;
  inset-inline: 0;
  bottom: calc(8px + env(safe-area-inset-bottom));
  width: min(
    calc(100% - 2 * var(--nav-inset) - env(safe-area-inset-left) - env(safe-area-inset-right)),
    calc(var(--phone-width) - 2 * var(--nav-inset))
  );
  margin-inline: auto;
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 2px;
  padding: 4px;
  background: var(--tab-paper);
  background: #fbfaeef5;
  border: 1px solid #cac8ac66;
  border-radius: .95rem;
  box-shadow: 0 4px 14px #1a1a1421;
}
nav a {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: .14rem; min-height: 44px; padding: .2rem .05rem; border-radius: 999px;
  color: #57574b; font-size: .75rem; font-weight: 600; line-height: 1.15; white-space: nowrap;
}
nav a:hover { background: #f1efe0; text-decoration: none; }
nav a[aria-current="page"] { background: var(--lime); color: #24241f; }

main {
  min-width: 0;
  padding: 8px max(var(--gutter), env(safe-area-inset-right))
    calc(6rem + env(safe-area-inset-bottom)) max(var(--gutter), env(safe-area-inset-left));
}
main:focus { outline: none; }
.shell[data-page="login"] main { padding-top: env(safe-area-inset-top); padding-bottom: calc(1.5rem + env(safe-area-inset-bottom)); }
.pet-bar { min-width: 0; display: flex; align-items: center; gap: .4rem; color: var(--muted); }
.pet-bar label { font-size: .8rem; white-space: nowrap; }
.pet-bar select { width: min(6.5rem, 26vw); padding: .35rem .4rem; text-overflow: ellipsis; }
.notice { padding: .75rem .9rem; margin-bottom: .8rem; background: var(--mint-soft); border-radius: .85rem; }
.notice.error { color: var(--danger); background: #f9e8e4; }
.page-head { display: flex; justify-content: space-between; align-items: flex-start; gap: .75rem; margin: .5rem 0 1rem; }
.page-head > div { min-width: 0; }
.page-head > .button { flex: none; }
.page-head p { color: var(--muted); margin-top: .3rem; }

.hero {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(54px, .42fr);
  align-items: center;
  gap: .75rem;
  min-height: 11.4rem;
  overflow: hidden;
  padding: 1rem;
  background: var(--lime);
  color: #24291a;
  border-radius: .8rem;
  box-shadow: 0 5px 13px #4d600d12;
}
.hero::after {
  content: "";
  position: absolute;
  top: .5rem; right: .75rem;
  width: 1.25rem; height: 1.25rem;
  border: 1px solid #4b67006b; border-radius: 50%;
  pointer-events: none;
}
.hero .kicker { color: var(--olive); font-size: .82rem; font-weight: 700; }
.hero h1 { margin: .2rem 0 .4rem; font-size: 1.65rem; }
.hero p { color: #343f1f; }
.hero .actions { margin-top: .85rem; }
.hero .actions .button { font-size: .875rem; padding-inline: .65rem; }
.hero-photo {
  width: 100%; aspect-ratio: 1; object-fit: cover;
  border-radius: .85rem; background: #ffffff50;
}
.hero-icon {
  display: grid; place-items: center; justify-self: center;
  width: min(86%, 5rem); aspect-ratio: 1; border-radius: 50%;
  background: #ffffff70; border: 1px solid #4b670032; box-shadow: 0 0 0 7px #4b67000d;
}
.hero-icon img { width: 44%; height: 44%; }

.actions, .tags { display: flex; flex-wrap: wrap; align-items: center; gap: .55rem; }
.button, button {
  display: inline-flex; justify-content: center; align-items: center; gap: .4rem; min-height: 44px;
  border: 1px solid transparent; border-radius: 999px; padding: .45rem .85rem;
  background: var(--mint); color: #16382a; font-weight: 650; text-align: center; text-decoration: none;
}
.button:hover, button:hover { text-decoration: none; filter: brightness(.95); }
.secondary { background: var(--white); color: var(--green); border-color: #dcded0; }
.danger { background: #fbefed; border-color: #eed6d0; color: var(--danger); }
.pill { display: inline-flex; align-items: center; border-radius: 999px; padding: .15rem .55rem; font-size: .82rem; color: var(--green); background: var(--mint-soft); }
.section { margin-top: 1.2rem; }
.section-head { display: flex; align-items: center; justify-content: space-between; gap: .65rem; margin-bottom: .6rem; }
.section-head a { font-size: .875rem; font-weight: 600; }
.grid, .stack { display: grid; grid-template-columns: minmax(0, 1fr); gap: .65rem; }
.card {
  display: block; min-width: 0; padding: .9rem;
  border: 1px solid var(--line); border-radius: 1rem; background: var(--white); color: var(--ink);
  box-shadow: 0 3px 8px #312d2310;
}
a.card:hover { border-color: #a9c6ab; text-decoration: none; }
.card h2, .card h3 { margin-bottom: .2rem; overflow-wrap: anywhere; }
.card p + p, .card .tags:not(:empty), .card .actions { margin-top: .55rem; }
.tile { display: flex; align-items: center; gap: .6rem; }
.tile > div { min-width: 0; }
.tile strong, .tile small { display: block; overflow-wrap: anywhere; }
.hero + .section .grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.hero + .section .tile { display: grid; align-content: start; gap: .4rem; background: #eef4e7; }
.hero + .section .tile:nth-child(2) { background: #fff6e4; }
.hero + .section .tile:nth-child(2) .tile-icon { background: var(--warm); }
.empty { padding: 1.6rem 1rem; text-align: center; background: var(--white); border: 1px dashed #d4d3c2; border-radius: 1rem; }
.empty p { margin: .35rem 0 .75rem; color: var(--muted); }
.text { white-space: pre-wrap; }
.excerpt { display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.diary-cover { width: 100%; aspect-ratio: 2.5; object-fit: cover; border-radius: .65rem; margin-bottom: .65rem; background: var(--warm); }
.photos { display: grid; gap: .5rem; grid-template-columns: repeat(3, minmax(0, 1fr)); margin-top: .8rem; }
.photos figure { margin: 0; min-width: 0; }
.photos img { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: .65rem; background: var(--warm); }
.photos label { display: flex; align-items: center; gap: .3rem; margin-top: .25rem; font-size: .85rem; font-weight: 400; }
.avatar { width: 4.2rem; height: 4.2rem; flex: none; object-fit: cover; border-radius: 1rem; background: var(--mint-soft); }
.pet-entry { display: flex; align-items: center; gap: .7rem; }
.pet-entry div { min-width: 0; }
dl { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: .35rem .7rem; }
dt { color: var(--muted); }
dd { margin: 0; overflow-wrap: anywhere; }

form { display: grid; gap: .8rem; }
.fields { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .65rem; }
label { display: block; min-width: 0; font-size: .9rem; font-weight: 600; }
input, select, textarea {
  display: block; width: 100%; min-width: 0; min-height: 44px; border: 1px solid #d3d4c5;
  color: var(--ink); background: #fffefa; border-radius: .65rem; padding: .45rem .6rem;
  font-size: max(16px, 1rem);
}
label > input, label > select, label > textarea { margin-top: .2rem; }
input[type="checkbox"] { width: 1.1rem; height: 1.1rem; min-height: 0; accent-color: var(--green); }
.check { display: flex; align-items: center; gap: .45rem; }
textarea { resize: vertical; min-height: 7rem; }

.auth-layout { display: grid; gap: 1.65rem; padding: clamp(1.75rem, 9vh, 4.5rem) 1rem 0; }
.auth-layout .hero {
  justify-items: center;
  min-height: auto;
  padding: 0;
  text-align: center;
  grid-template-columns: 1fr;
  gap: .8rem;
  background: transparent;
  box-shadow: none;
}
.auth-layout .hero::after { content: none; }
.auth-layout .hero h1 { font-size: 1.75rem; letter-spacing: .045em; }
.auth-layout .hero p { color: var(--muted); }
.auth-layout .hero-icon {
  width: 5rem; background: var(--white); border: 0; border-radius: 1.65rem;
  box-shadow: 0 9px 24px #52b18426;
}
.auth-layout .card {
  display: grid; gap: .8rem; padding: 1rem 0; background: transparent; border: 0; box-shadow: none;
}
.auth-layout button { width: 100%; min-height: 48px; }
.auth-layout .secondary { border-color: var(--mint); }
@media (max-width: 360px) {
  :root { --gutter: 12px; --nav-inset: 8px; }
  .brand { gap: .35rem; }
  .pet-bar select { width: min(5.75rem, 27vw); }
  .fields { grid-template-columns: minmax(0, 1fr); }
  .auth-layout { padding-inline: .6rem; }
}
