/* PawRota — Collar-Tag Routine Loop theme */

:root {
  --oat: #f5efe3;
  --paper: #fffaf0;
  --teal: #2f6b5f;
  --teal-soft: #dcebe6;
  --coral: #e07a5f;
  --coral-soft: #fbe4dc;
  --mustard: #d9a441;
  --ink: #2b2a26;
  --ink-soft: #6f6a5e;
  --edge-line: #e5dcc9;
  --radius-tag: 18px;
  --sat: env(safe-area-inset-top, 0px);
  --sab: env(safe-area-inset-bottom, 0px);
  --bar-h: 64px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%;
}

body {
  font-family: "Avenir Next", "Trebuchet MS", "Segoe UI", system-ui, sans-serif;
  background: var(--oat);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
  -webkit-text-size-adjust: 100%;
}

#app {
  max-width: 480px;
  margin: 0 auto;
  min-height: 100dvh;
  padding-bottom: calc(var(--bar-h) + var(--sab) + 16px);
}

.tab-panel { padding: 0 16px; animation: rise .18s ease-out; }
@keyframes rise { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

button { font: inherit; cursor: pointer; border: 0; background: none; color: inherit; }
input { font: inherit; }

/* ---------- Today header (slim buckle) ---------- */
.buckle-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: calc(10px + var(--sat)) 2px 10px;
}

.buckle-brand { display: flex; align-items: center; gap: 8px; min-width: 0; }

.collar-ring {
  width: 26px; height: 26px;
  border: 5px solid var(--teal);
  border-radius: 50%;
  position: relative;
  flex: none;
}
.bone-tag {
  position: absolute;
  right: -8px; bottom: -7px;
  width: 9px; height: 7px;
  background: var(--coral);
  border-radius: 4px;
}

.buckle-brand h1 {
  font-size: 1.25rem;
  letter-spacing: .02em;
  white-space: nowrap;
}

.counters { display: flex; gap: 8px; }

.counter {
  width: 46px; height: 46px;
  border-radius: 50%;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  line-height: 1;
}
.counter-open { background: var(--coral-soft); color: #9c4430; }
.counter-done { background: var(--teal-soft); color: var(--teal); }
.counter-num { font-size: 1.05rem; font-weight: 700; }
.counter-word { font-size: .58rem; text-transform: uppercase; letter-spacing: .08em; margin-top: 2px; }

/* ---------- Add strip ---------- */
.add-strip {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--teal);
  color: #f2f7f5;
  border-radius: 16px;
  padding: 16px 18px;
  margin: 4px 0 14px;
  box-shadow: 0 3px 0 #245247;
  text-align: left;
  min-height: 56px;
}
.add-strip:active { transform: translateY(1px); box-shadow: 0 2px 0 #245247; }
.add-strip-label { font-weight: 700; font-size: 1.02rem; letter-spacing: .02em; }
.add-strip-plus { font-size: 1.4rem; font-weight: 700; }

/* ---------- Panel heads ---------- */
.panel-head { padding: calc(14px + var(--sat)) 2px 12px; }
.panel-head h2 { font-size: 1.3rem; }
.panel-sub { color: var(--ink-soft); font-size: .85rem; margin-top: 3px; }

/* ---------- Today: pinned next-open card ---------- */
.next-label {
  font-size: .7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .12em;
  color: var(--ink-soft);
  margin: 2px 2px 8px;
}

.next-card {
  position: relative;
  background: var(--paper);
  border: 1.5px solid var(--edge-line);
  border-left: 10px solid var(--teal);
  border-radius: 20px 26px 26px 20px;
  padding: 18px 16px 16px;
  box-shadow: 0 6px 18px rgba(47, 107, 95, .10);
}
.next-card::before { /* collar-loop clip */
  content: "";
  position: absolute;
  top: -1px; right: 14px;
  width: 46px; height: 14px;
  background: var(--oat);
  border: 1.5px solid var(--edge-line);
  border-top: 0;
  border-radius: 0 0 14px 14px;
}
.next-name { font-size: 1.35rem; font-weight: 700; padding-right: 40px; }
.next-meta { color: var(--ink-soft); font-size: .92rem; margin: 6px 0 14px; }
.next-meta strong { color: var(--ink); font-weight: 600; }

.state-toggle {
  width: 100%;
  min-height: 46px;
  border-radius: 12px;
  font-weight: 700;
  letter-spacing: .03em;
  border: 1.5px solid var(--coral);
  color: var(--coral);
  background: transparent;
  display: flex; align-items: center; justify-content: center; gap: 8px;
}
.state-toggle .dot {
  width: 10px; height: 10px; border-radius: 50%;
  border: 2px solid currentColor;
  flex: none;
}
.state-toggle.is-done { border-color: var(--teal); color: var(--teal); }
.state-toggle.is-done .dot { background: currentColor; }

/* ---------- Routines list ---------- */
.pet-group { margin-bottom: 16px; }
.pet-group-head {
  display: flex; align-items: center; gap: 8px;
  margin: 4px 2px 8px;
}
.pet-swatch { width: 10px; height: 10px; border-radius: 50%; flex: none; }
.pet-group-head h3 { font-size: .95rem; font-weight: 700; }
.pet-group-head .pet-count { color: var(--ink-soft); font-size: .8rem; }

.tag-row {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 12px;
  text-align: left;
  background: var(--paper);
  border: 1.5px solid var(--edge-line);
  border-left: 8px solid var(--teal);
  border-radius: 12px 16px 16px 12px;
  padding: 12px 12px 12px 14px;
  margin-bottom: 8px;
  min-height: 60px;
}
.tag-row:active { background: #fdf6e8; }
.tag-row.is-done { opacity: .75; }
.tag-row .tag-text { flex: 1; min-width: 0; }
.tag-row .tag-name {
  font-weight: 600;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.tag-row .tag-time { color: var(--ink-soft); font-size: .8rem; margin-top: 2px; }

/* Per-pet edge colours: Teal / Coral / Mustard / Ink */
.edge-teal { border-left-color: var(--teal); }
.edge-coral { border-left-color: var(--coral); }
.edge-mustard { border-left-color: var(--mustard); }
.edge-ink { border-left-color: var(--ink); }
.pc-teal { background: var(--teal); }
.pc-coral { background: var(--coral); }
.pc-mustard { background: var(--mustard); }
.pc-ink { background: var(--ink); }

.time-bead {
  width: 14px; height: 14px;
  border-radius: 50%;
  background: var(--mustard);
  border: 2px solid #c08d2c;
  flex: none;
}

.state-word {
  display: flex; align-items: center; gap: 6px;
  font-size: .82rem; font-weight: 700;
  flex: none;
}
.state-word .dot {
  width: 9px; height: 9px; border-radius: 50%;
  border: 2px solid currentColor;
}
.state-word.open { color: var(--coral); }
.state-word.open .dot { background: currentColor; }
.state-word.done { color: var(--teal); }

/* ---------- Forms ---------- */
.stamp-form, .about-card {
  background: var(--paper);
  border: 1.5px solid var(--edge-line);
  border-radius: var(--radius-tag);
  padding: 16px;
}

.field { margin-bottom: 14px; }
.field label {
  display: block;
  font-size: .78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--ink-soft);
  margin-bottom: 6px;
}
.field input {
  width: 100%;
  min-height: 48px;
  border: 1.5px solid var(--edge-line);
  border-radius: 12px;
  padding: 0 14px;
  background: #fff;
  color: var(--ink);
}
.field input:focus { outline: none; border-color: var(--teal); box-shadow: 0 0 0 3px rgba(47,107,95,.15); }
.field input.invalid { border-color: var(--coral); box-shadow: 0 0 0 3px rgba(224,122,95,.18); }

.chip-row { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.chip {
  padding: 7px 14px;
  border-radius: 999px;
  border: 1.5px solid var(--edge-line);
  background: #fff;
  font-size: .85rem;
  min-height: 34px;
}
.chip.on { background: var(--teal); border-color: var(--teal); color: #fff; }
.chip-row .chip.on { background: var(--teal-soft); border-color: var(--teal); color: var(--teal); }

.form-error {
  color: #a8402a;
  background: var(--coral-soft);
  border-radius: 10px;
  padding: 10px 12px;
  font-size: .88rem;
  margin-bottom: 12px;
}

.primary-btn {
  width: 100%;
  min-height: 52px;
  border-radius: 14px;
  background: var(--teal);
  color: #fff;
  font-weight: 700;
  font-size: 1rem;
  box-shadow: 0 3px 0 #245247;
}
.primary-btn:active { transform: translateY(1px); box-shadow: 0 2px 0 #245247; }

.danger-btn {
  min-height: 48px;
  padding: 0 16px;
  border-radius: 12px;
  border: 1.5px solid var(--coral);
  color: var(--coral);
  background: transparent;
  font-weight: 700;
}
.ghost-btn {
  min-height: 48px;
  padding: 0 16px;
  border-radius: 12px;
  border: 1.5px solid var(--edge-line);
  color: var(--ink-soft);
  background: transparent;
  font-weight: 600;
}

/* ---------- Find ---------- */
.search-wrap { margin-bottom: 10px; }
#find-input {
  width: 100%;
  min-height: 48px;
  border: 1.5px solid var(--edge-line);
  border-radius: 999px;
  padding: 0 18px;
  background: var(--paper);
}
#find-input:focus { outline: none; border-color: var(--teal); }

#find-chips { margin-bottom: 14px; }

.find-hit {
  display: flex; align-items: center; gap: 10px;
  width: 100%;
  text-align: left;
  background: var(--paper);
  border: 1.5px solid var(--edge-line);
  border-left: 8px solid var(--teal);
  border-radius: 12px 16px 16px 12px;
  padding: 12px 14px;
  margin-bottom: 8px;
  min-height: 58px;
}
.find-hit .hit-name { font-weight: 600; }
.find-hit .hit-meta { color: var(--ink-soft); font-size: .8rem; margin-top: 2px; }

.about-card { margin-top: 22px; }
.about-card h3 { font-size: .95rem; margin-bottom: 8px; }
.about-card p { font-size: .85rem; color: var(--ink-soft); line-height: 1.5; margin-bottom: 12px; }

/* ---------- Empty states ---------- */
.empty {
  text-align: center;
  padding: 34px 20px;
  background: var(--paper);
  border: 1.5px dashed var(--edge-line);
  border-radius: var(--radius-tag);
}
.empty .empty-ring {
  width: 44px; height: 44px;
  border: 8px solid var(--teal-soft);
  border-radius: 50%;
  margin: 0 auto 12px;
  position: relative;
}
.empty .empty-ring::after {
  content: "";
  position: absolute;
  right: -9px; bottom: -8px;
  width: 14px; height: 11px;
  background: var(--coral-soft);
  border-radius: 6px;
}
.empty h3 { font-size: 1rem; margin-bottom: 6px; }
.empty p { color: var(--ink-soft); font-size: .87rem; line-height: 1.5; }
.empty .empty-action {
  margin-top: 14px;
  display: inline-block;
  padding: 10px 20px;
  border-radius: 999px;
  background: var(--teal);
  color: #fff;
  font-weight: 700;
}

/* ---------- Bottom tab bar ---------- */
.tab-bar {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  max-width: 480px;
  margin: 0 auto;
  height: calc(var(--bar-h) + var(--sab));
  padding: 6px 8px var(--sab);
  display: flex;
  background: var(--paper);
  border-top: 1.5px solid var(--edge-line);
  z-index: 40;
}
.tab-btn {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  border-radius: 14px;
  color: var(--ink-soft);
  font-size: .72rem;
  font-weight: 600;
  min-height: 52px;
}
.tab-dot { width: 8px; height: 8px; border-radius: 50%; background: currentColor; opacity: .55; }
.tab-btn.active {
  color: var(--teal);
  background: var(--teal-soft);
  transform: translateY(-6px);
  box-shadow: 0 6px 14px rgba(47, 107, 95, .22);
}
.tab-btn.active .tab-dot { opacity: 1; }
.tab-btn-add.active { background: var(--teal); color: #fff; }
.tab-buckle {
  width: 22px; height: 22px;
  border: 3.5px solid currentColor;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: .8rem; font-weight: 800; line-height: 1;
}

/* ---------- Sheets ---------- */
.sheet-backdrop {
  position: fixed; inset: 0;
  background: rgba(43, 42, 38, .45);
  z-index: 50;
}
.sheet {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  max-width: 480px;
  margin: 0 auto;
  background: var(--paper);
  border-radius: 22px 22px 0 0;
  padding: 10px 18px calc(18px + var(--sab));
  z-index: 60;
  animation: sheet-up .2s ease-out;
}
@keyframes sheet-up { from { transform: translateY(100%); } to { transform: none; } }
.sheet-grip {
  width: 40px; height: 5px;
  background: var(--edge-line);
  border-radius: 3px;
  margin: 4px auto 12px;
}
.sheet h2 { font-size: 1.15rem; margin-bottom: 14px; }
.sheet .field { margin-bottom: 12px; }
.sheet-toggle-row {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}
.sheet-toggle-label {
  font-size: .78rem; font-weight: 700;
  text-transform: uppercase; letter-spacing: .08em;
  color: var(--ink-soft);
}
.sheet-toggle-row .state-toggle { width: 132px; min-height: 42px; }
.sheet-actions { display: flex; gap: 8px; margin-top: 4px; }
.sheet-actions .primary-btn { flex: 1; box-shadow: none; }
.confirm-sheet { padding-bottom: calc(24px + var(--sab)); }
.confirm-text { color: var(--ink-soft); font-size: .92rem; line-height: 1.5; margin-bottom: 16px; }

/* ---------- Toast ---------- */
.toast {
  position: fixed;
  left: 50%;
  bottom: calc(var(--bar-h) + var(--sab) + 14px);
  transform: translateX(-50%);
  background: var(--ink);
  color: var(--oat);
  padding: 10px 18px;
  border-radius: 999px;
  font-size: .85rem;
  z-index: 70;
  white-space: nowrap;
  animation: rise .18s ease-out;
}
