:root {
  color-scheme: dark;
  --ink: #eef1f0;
  --muted: #9aa4a6;
  --accent: #d9a441;
  --accent-rgb: 217, 164, 65;
  --accent-contrast: #171207;
  --accent-soft: rgba(217, 164, 65, 0.14);
  --sand: #1a1f20;
  --stone: #2b3336;
  --gold: var(--accent);
  --foam: #1b2123;
  --surface: #121718;
  --surface-alt: #151b1c;
  --surface-deep: #101415;
  --panel: #0b0f10;
  --border: rgba(238, 241, 240, 0.12);
  --shadow: rgba(0, 0, 0, 0.45);
  --bg-start: #1e2426;
  --bg-mid: #15191a;
  --bg-end: #0e1112;
  --metric-start: #0f1314;
  --metric-end: #2a2316;
  --chart-start: #1b2123;
  --chart-end: #14191a;
}

[data-theme="sage"] {
  color-scheme: dark;
  --ink: #eef5ee;
  --muted: #9eb4ab;
  --accent: #7cc59f;
  --accent-rgb: 124, 197, 159;
  --accent-contrast: #0c2117;
  --accent-soft: rgba(124, 197, 159, 0.16);
  --sand: #16201d;
  --stone: #2a3a35;
  --gold: var(--accent);
  --foam: #1a2723;
  --surface: #101a17;
  --surface-alt: #15231f;
  --surface-deep: #0e1714;
  --panel: #09110f;
  --border: rgba(226, 241, 233, 0.13);
  --shadow: rgba(0, 0, 0, 0.42);
  --bg-start: #20302a;
  --bg-mid: #161f1c;
  --bg-end: #0e1412;
  --metric-start: #12211d;
  --metric-end: #20352e;
  --chart-start: #1c2b26;
  --chart-end: #15201c;
}

[data-theme="ember"] {
  color-scheme: dark;
  --ink: #f3ece8;
  --muted: #b8a49b;
  --accent: #e2965d;
  --accent-rgb: 226, 150, 93;
  --accent-contrast: #251107;
  --accent-soft: rgba(226, 150, 93, 0.16);
  --sand: #251b1a;
  --stone: #3b2d2c;
  --gold: var(--accent);
  --foam: #2a1f1e;
  --surface: #1f1716;
  --surface-alt: #271d1b;
  --surface-deep: #191312;
  --panel: #100c0b;
  --border: rgba(245, 230, 221, 0.13);
  --shadow: rgba(0, 0, 0, 0.46);
  --bg-start: #2d2120;
  --bg-mid: #1d1616;
  --bg-end: #110f0f;
  --metric-start: #211513;
  --metric-end: #412722;
  --chart-start: #2a201f;
  --chart-end: #1c1615;
}

[data-theme="tide"] {
  color-scheme: dark;
  --ink: #eef5f8;
  --muted: #9eb3bd;
  --accent: #66b7dd;
  --accent-rgb: 102, 183, 221;
  --accent-contrast: #061a25;
  --accent-soft: rgba(102, 183, 221, 0.16);
  --sand: #162027;
  --stone: #2a3b45;
  --gold: var(--accent);
  --foam: #19262d;
  --surface: #101a20;
  --surface-alt: #15232b;
  --surface-deep: #0c151a;
  --panel: #071014;
  --border: rgba(226, 240, 246, 0.13);
  --shadow: rgba(0, 0, 0, 0.44);
  --bg-start: #20303a;
  --bg-mid: #141f26;
  --bg-end: #0b1115;
  --metric-start: #10202a;
  --metric-end: #1e3947;
  --chart-start: #1a2931;
  --chart-end: #121d23;
}

[data-theme="paper"] {
  color-scheme: light;
  --ink: #212725;
  --muted: #62706b;
  --accent: #386f68;
  --accent-rgb: 56, 111, 104;
  --accent-contrast: #f8fffb;
  --accent-soft: rgba(56, 111, 104, 0.13);
  --sand: #edf2ee;
  --stone: #cedbd5;
  --gold: var(--accent);
  --foam: #ffffff;
  --surface: #f8fbf8;
  --surface-alt: #eef5f0;
  --surface-deep: #e5eee9;
  --panel: #f6faf7;
  --border: rgba(33, 39, 37, 0.13);
  --shadow: rgba(36, 53, 47, 0.16);
  --bg-start: #fffaf0;
  --bg-mid: #f4f7f1;
  --bg-end: #eaf0eb;
  --metric-start: #29443f;
  --metric-end: #3c756b;
  --chart-start: #ffffff;
  --chart-end: #f4f8f5;
}

[data-theme="morning"] {
  color-scheme: light;
  --ink: #2b261f;
  --muted: #756c60;
  --accent: #b45d3c;
  --accent-rgb: 180, 93, 60;
  --accent-contrast: #fff8f2;
  --accent-soft: rgba(180, 93, 60, 0.13);
  --sand: #f5ece0;
  --stone: #dfd0c0;
  --gold: var(--accent);
  --foam: #fffaf4;
  --surface: #fff7ef;
  --surface-alt: #f6eadf;
  --surface-deep: #eee0d1;
  --panel: #fffaf4;
  --border: rgba(43, 38, 31, 0.13);
  --shadow: rgba(94, 65, 44, 0.16);
  --bg-start: #fff0dd;
  --bg-mid: #fbf5eb;
  --bg-end: #efe7db;
  --metric-start: #472c24;
  --metric-end: #a4603f;
  --chart-start: #fffaf4;
  --chart-end: #f8eee3;
}

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

[hidden] {
  display: none !important;
}

body {
  font-family: "Space Grotesk", "Segoe UI", sans-serif;
  background: radial-gradient(circle at top, var(--bg-start) 0%, var(--bg-mid) 55%, var(--bg-end) 100%);
  color: var(--ink);
  overflow-x: hidden;
}

.page {
  width: 100%;
  max-width: 1100px;
  margin: 0 auto;
  padding: 48px 24px 64px;
}

.app-shell {
  display: grid;
  gap: 32px;
  min-width: 0;
}

.topbar {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 32px;
  min-width: 0;
}

.brand-home {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  max-width: 100%;
  padding: 6px 12px 6px 6px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  color: var(--ink);
  text-transform: none;
  text-decoration: none;
  box-shadow: none;
  cursor: pointer;
}

.brand-home:hover {
  border-color: rgba(var(--accent-rgb), 0.58);
  box-shadow: 0 8px 18px rgba(var(--accent-rgb), 0.16);
}

.brand-logo {
  width: 36px;
  height: 36px;
  border-radius: 999px;
  background: var(--surface-alt);
  object-fit: cover;
  flex: 0 0 auto;
}

.brand-name {
  font-size: 1.04rem;
  font-weight: 800;
  letter-spacing: 0;
  white-space: nowrap;
}

.admin-session-name {
  color: var(--muted);
  font-size: 0.95rem;
  font-weight: 600;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.notifications-wrap {
  position: relative;
}

.notification-button {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 42px;
  height: 42px;
  padding: 0;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--ink);
  box-shadow: none;
}

.notification-button:hover {
  transform: none;
  border-color: rgba(var(--accent-rgb), 0.5);
  box-shadow: 0 8px 18px rgba(var(--accent-rgb), 0.16);
}

.notification-button.has-unread {
  border-color: transparent;
  background: var(--gold);
  color: var(--accent-contrast);
  box-shadow: 0 0 0 4px rgba(var(--accent-rgb), 0.16), 0 10px 22px rgba(var(--accent-rgb), 0.28);
}

.notification-icon {
  display: inline-flex;
  width: 17px;
  height: 17px;
}

.notification-icon svg {
  width: 100%;
  height: 100%;
  fill: currentColor;
}

.notifications-panel {
  position: absolute;
  top: calc(100% + 10px);
  right: 0;
  width: min(360px, calc(100vw - 32px));
  padding: 14px;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: var(--surface);
  box-shadow: 0 16px 34px rgba(0, 0, 0, 0.35);
  z-index: 35;
}

.notification-badge {
  position: absolute;
  top: -5px;
  right: -5px;
  min-width: 19px;
  height: 19px;
  padding: 0 5px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--gold);
  color: var(--accent-contrast);
  font-size: 0.68rem;
  font-weight: 700;
  line-height: 1;
  box-shadow: 0 0 0 3px var(--bg-mid);
}

.notifications-list {
  list-style: none;
  display: grid;
  gap: 9px;
  margin-top: 10px;
  max-height: 280px;
  overflow-y: auto;
}

.push-settings {
  display: grid;
  gap: 8px;
  margin: 0;
}

.push-settings button {
  width: 100%;
  min-height: 36px;
  padding: 8px 12px;
}

.danger-button {
  width: 100%;
  min-height: 36px;
  border: 1px solid rgba(240, 86, 86, 0.45);
  background: rgba(75, 21, 21, 0.6);
  color: #ffd8d8;
}

.danger-button:hover {
  border-color: rgba(240, 86, 86, 0.75);
  background: rgba(97, 24, 24, 0.72);
}

.push-settings .helper {
  margin: 0;
  font-size: 0.82rem;
}

.notification-item {
  padding: 10px 12px;
  border-radius: 10px;
  background: var(--surface-alt);
  border: 1px solid var(--border);
  display: grid;
  gap: 4px;
}

.notification-item strong {
  font-size: 0.9rem;
}

.notification-item small {
  color: var(--muted);
  font-size: 0.76rem;
}

.notification-item.is-unread {
  border-color: rgba(var(--accent-rgb), 0.45);
}

.notification-item.is-empty {
  color: var(--muted);
}

.notification-toast {
  position: absolute;
  top: calc(100% + 10px);
  right: 0;
  max-width: min(380px, calc(100vw - 32px));
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid rgba(var(--accent-rgb), 0.45);
  background: var(--accent-soft);
  color: var(--ink);
  box-shadow: 0 12px 26px rgba(0, 0, 0, 0.32);
  opacity: 0;
  transform: translateY(-4px);
  pointer-events: none;
  transition: opacity 0.18s ease, transform 0.18s ease;
  z-index: 34;
}

.notification-toast.is-visible {
  opacity: 1;
  transform: translateY(0);
}

.profile-button {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 6px 12px 6px 6px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--ink);
  max-width: min(280px, 55vw);
}

.profile-button:hover {
  border-color: rgba(var(--accent-rgb), 0.5);
  box-shadow: 0 8px 18px rgba(var(--accent-rgb), 0.16);
}

.profile-initial {
  display: inline-grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 999px;
  background: var(--gold);
  color: var(--accent-contrast);
  font-weight: 700;
  flex: 0 0 auto;
}

.profile-name-label {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.topbar-link {
  color: var(--ink);
  text-decoration: none;
  font-weight: 600;
}

.topbar-link:hover {
  color: var(--gold);
}

.topbar-button {
  padding: 10px 14px;
  border-radius: 12px;
  background: transparent;
  border: 1px solid rgba(var(--accent-rgb), 0.4);
  color: var(--ink);
}

.topbar-button:hover {
  box-shadow: 0 8px 18px rgba(var(--accent-rgb), 0.2);
}

.hero {
  display: grid;
  gap: 24px;
  grid-template-columns: minmax(0, 1fr);
  margin-bottom: 40px;
  min-width: 0;
}

.eyebrow {
  text-transform: uppercase;
  letter-spacing: 0.32em;
  font-size: 0.72rem;
  color: var(--muted);
  margin-bottom: 12px;
}

h1 {
  font-size: clamp(2.2rem, 3vw, 3.4rem);
  line-height: 1.1;
  margin-bottom: 12px;
}

.subtitle {
  color: var(--muted);
  max-width: 460px;
  font-size: 1.05rem;
}

.hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 18px;
  margin-bottom: 12px;
}

.hero-pet-switch {
  display: grid;
  gap: 8px;
  max-width: 260px;
  margin-bottom: 12px;
}

.hero-pet-switch label {
  font-size: 0.85rem;
  color: var(--muted);
}

.hero-pet-switch select {
  background-color: var(--surface);
  padding-right: 42px;
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 14 14'%3E%3Cpath d='M3 5.25 7 9l4-3.75' fill='none' stroke='%23c2c8c6' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
  background-size: 12px 12px;
}

.ghost-button {
  background: linear-gradient(180deg, rgba(var(--accent-rgb), 0.2), rgba(var(--accent-rgb), 0.11));
  color: var(--ink);
  border: 1px solid rgba(var(--accent-rgb), 0.5);
}

.ghost-button:hover {
  background: linear-gradient(180deg, rgba(var(--accent-rgb), 0.28), rgba(var(--accent-rgb), 0.16));
  border-color: rgba(var(--accent-rgb), 0.72);
  box-shadow: 0 8px 18px rgba(var(--accent-rgb), 0.2);
}

.metric-card {
  background: var(--metric-start);
  color: #f7f4ee;
  border-radius: 20px;
  padding: 24px;
  box-shadow: 0 18px 40px var(--shadow);
  background-image: linear-gradient(120deg, var(--metric-start) 0%, var(--metric-end) 100%);
  display: grid;
  gap: 12px;
}

.metric-block {
  display: grid;
  gap: 4px;
}

.metric-label {
  text-transform: uppercase;
  letter-spacing: 0.25em;
  font-size: 0.65rem;
  margin-bottom: 8px;
}

.metric-value {
  font-size: 2.6rem;
  font-weight: 600;
}

.metric-value-small {
  font-size: 1.9rem;
}

.metric-date {
  color: #cab894;
}

.metric-helper {
  color: #ddccac;
  font-size: 0.82rem;
}

.metric-divider {
  width: 100%;
  height: 1px;
  background: rgba(247, 244, 238, 0.18);
}

.content {
  display: grid;
  gap: 24px;
}

.app-nav {
  display: inline-flex;
  gap: 8px;
  width: fit-content;
  padding: 4px;
  margin: -12px 0 8px;
  border-radius: 999px;
  background: var(--surface-deep);
  border: 1px solid var(--border);
}

.app-nav-button {
  padding: 10px 16px;
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  border: 1px solid transparent;
}

.app-nav-button.is-active {
  background: var(--gold);
  color: var(--accent-contrast);
}

.app-nav-button:hover {
  transform: none;
  box-shadow: none;
  color: var(--ink);
  border-color: rgba(var(--accent-rgb), 0.35);
}

.app-nav-button.is-active:hover {
  color: var(--accent-contrast);
}

.app-page {
  animation: pageIn 0.18s ease;
  min-width: 0;
}

@keyframes pageIn {
  from {
    opacity: 0;
    transform: translateY(4px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.card {
  background: var(--foam);
  border-radius: 20px;
  padding: 24px;
  box-shadow: 0 12px 30px var(--shadow);
  border: 1px solid rgba(var(--accent-rgb), 0.16);
  min-width: 0;
  max-width: 100%;
}

.card h2 {
  margin-bottom: 12px;
  font-size: 1.35rem;
}

.card-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
}

.helper {
  color: var(--muted);
  font-size: 0.9rem;
}

.view-switch {
  display: inline-flex;
  gap: 8px;
  padding: 4px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface);
}

.chart-controls {
  display: inline-flex;
  align-items: flex-end;
  flex-wrap: wrap;
  gap: 12px;
}

.trend-period-control {
  display: grid;
  gap: 6px;
  min-width: 160px;
  font-size: 0.8rem;
  color: var(--muted);
}

.trend-period-control select {
  min-height: 34px;
  padding: 7px 10px;
  font-size: 0.9rem;
}

.switch-btn {
  background: transparent;
  color: var(--muted);
  border-radius: 999px;
  padding: 8px 12px;
  border: none;
  box-shadow: none;
}

.switch-btn:hover {
  transform: none;
  box-shadow: none;
  color: var(--ink);
}

.switch-btn.is-active {
  background: var(--gold);
  color: var(--accent-contrast);
}

.view-panel {
  margin-top: 10px;
  opacity: 0;
  transform: translateY(6px);
  transition: opacity 0.18s ease, transform 0.18s ease;
}

.view-panel.is-active {
  opacity: 1;
  transform: translateY(0);
}

.view-panel.is-leaving {
  opacity: 0;
  transform: translateY(-4px);
}

form {
  display: grid;
  gap: 16px;
}

label {
  display: grid;
  gap: 8px;
  font-weight: 500;
  color: var(--ink);
}

input {
  min-width: 0;
  max-width: 100%;
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--ink);
  font-size: 1rem;
}

select {
  min-width: 0;
  max-width: 100%;
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--ink);
  font-size: 1rem;
}

button {
  padding: 12px 16px;
  border: none;
  border-radius: 12px;
  background: var(--gold);
  color: var(--accent-contrast);
  font-weight: 600;
  text-transform: capitalize;
  cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

button:hover {
  transform: translateY(-1px);
  box-shadow: 0 8px 18px rgba(var(--accent-rgb), 0.28);
}

button:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

.auth-page,
.admin-page {
  max-width: 720px;
}

.auth-card {
  background: var(--foam);
  border-radius: 20px;
  padding: 32px;
  box-shadow: 0 18px 40px var(--shadow);
  border: 1px solid rgba(var(--accent-rgb), 0.18);
}

.auth-form {
  margin-top: 16px;
}

.form-grid {
  display: grid;
  gap: 16px;
}

.two-column {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.auth-tabs {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 20px;
}

.auth-tab {
  padding: 10px 14px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--muted);
  font-weight: 600;
  cursor: pointer;
}

.auth-tab.is-active {
  background: var(--gold);
  color: var(--accent-contrast);
  border-color: transparent;
}

.checkbox-row {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 500;
}

.checkbox-row input {
  width: 18px;
  height: 18px;
}

.entries {
  list-style: none;
  display: grid;
  gap: 12px;
}

.entry {
  display: flex;
  justify-content: space-between;
  padding: 12px 16px;
  border-radius: 12px;
  background: var(--surface-alt);
  border: 1px solid var(--border);
}

.entry span {
  font-weight: 500;
}

.entry small {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 0.78rem;
}

.food-log-form,
.owner-form {
  align-items: end;
  margin: 12px 0 16px;
}

.food-log-form {
  grid-template-columns:
    minmax(120px, 0.75fr)
    minmax(180px, 1.25fr)
    minmax(150px, 1fr)
    minmax(140px, 0.85fr)
    minmax(190px, 1.1fr);
  gap: 18px 16px;
}

.food-log-form label {
  min-width: 0;
}

.food-log-form input,
.food-log-form select {
  width: 100%;
}

.food-log-form input[type="datetime-local"] {
  min-width: 0;
  max-width: 100%;
}

.food-log-form button {
  grid-column: 1 / -1;
  justify-self: end;
  min-width: 98px;
  height: 44px;
  padding: 0 18px;
  white-space: nowrap;
}

.food-log-form .helper,
.owner-form .helper {
  grid-column: 1 / -1;
}

.owner-form {
  grid-template-columns: minmax(0, 1fr) 160px auto;
  border-bottom: 1px solid var(--border);
  padding-bottom: 16px;
}

.food-page {
  display: grid;
  gap: 24px;
}

.food-page-card {
  background: var(--surface-deep);
}

.food-page-card .food-log-form {
  padding: 20px;
  border-radius: 12px;
  background: var(--surface-alt);
  border: 1px solid var(--border);
}

.food-log-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 16px;
  align-items: center;
  padding: 14px 16px;
  border-radius: 12px;
  background: var(--surface-alt);
  border: 1px solid var(--border);
}

.food-log-summary {
  display: grid;
  gap: 4px;
  min-width: 0;
}

.food-log-summary small {
  color: var(--muted);
  font-size: 0.78rem;
}

.food-log-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  justify-content: flex-end;
}

.food-log-actions button {
  padding: 9px 12px;
}

.food-log-item.is-editing {
  grid-template-columns:
    minmax(110px, 0.7fr)
    minmax(150px, 1.15fr)
    minmax(130px, 0.95fr)
    minmax(120px, 0.75fr)
    minmax(180px, 1.1fr)
    auto;
  align-items: end;
}

.food-log-item.is-editing input,
.food-log-item.is-editing select {
  width: 100%;
}

.owner-list {
  list-style: none;
  display: grid;
  gap: 10px;
}

.owner-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 140px auto;
  gap: 10px;
  align-items: center;
  padding: 12px 14px;
  border-radius: 8px;
  background: var(--surface-alt);
  border: 1px solid var(--border);
}

.owner-item span {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 0.78rem;
}

.pet-select {
  display: grid;
  gap: 16px;
  margin-bottom: 20px;
}

.pet-update-row {
  display: grid;
  gap: 12px;
}

.pet-update-row button {
  width: fit-content;
}

.pet-details {
  color: var(--muted);
  font-size: 0.95rem;
}

.pet-form {
  border-top: 1px solid var(--border);
  padding-top: 16px;
}

.coach-card {
  background: var(--surface-deep);
  border-color: var(--border);
}

.coach-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
}

.chat-list {
  display: grid;
  align-content: start;
  gap: 12px;
  min-height: 420px;
  max-height: 560px;
  overflow-y: auto;
  margin: 18px 0;
  padding: 18px 12px;
  border-radius: 18px;
  background: var(--panel);
  border: 1px solid var(--border);
}

.chat-bubble {
  display: grid;
  gap: 5px;
  width: fit-content;
  max-width: min(680px, 84%);
  padding: 10px 14px;
  border: none;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.18);
}

.chat-user {
  justify-self: end;
  border-radius: 18px 18px 4px 18px;
  background: #0a84ff;
  color: #fff;
}

.chat-assistant {
  justify-self: start;
  border-radius: 18px 18px 18px 4px;
  background: var(--surface-alt);
}

.chat-pending {
  opacity: 0.72;
}

.chat-pending .chat-body {
  color: var(--muted);
}

.chat-role {
  font-weight: 600;
  font-size: 0.72rem;
  opacity: 0.78;
}

.chat-body {
  color: inherit;
  display: grid;
  gap: 10px;
  line-height: 1.5;
  white-space: normal;
}

.chat-body a {
  color: #f0c674;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.chat-body p {
  margin: 0;
}

.chat-body ul,
.chat-body ol {
  margin: 0;
  padding-left: 1.25rem;
}

.chat-body li {
  margin: 4px 0;
}

.chat-body strong {
  color: inherit;
  font-weight: 800;
}

.chat-body code {
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 6px;
  background: rgba(0, 0, 0, 0.2);
  padding: 0 5px;
  font-size: 0.92em;
}

.chat-time {
  color: currentColor;
  font-size: 0.7rem;
  opacity: 0.58;
}

.coach-form {
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: end;
  margin-bottom: 12px;
}

.coach-form .helper {
  grid-column: 1 / -1;
}

.coach-empty {
  display: grid;
  gap: 8px;
  padding: 18px;
  border-radius: 8px;
  background: var(--surface-alt);
  border: 1px solid rgba(var(--accent-rgb), 0.18);
  color: var(--muted);
}

.coach-empty strong {
  color: var(--ink);
}

.coach-memory-status {
  padding-top: 12px;
  border-top: 1px solid var(--border);
}

.routine-starter {
  display: none;
}

.starter-questions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin: 4px 0 16px;
  padding: 14px;
  border-radius: 14px;
  background: var(--accent-soft);
  border: 1px solid rgba(var(--accent-rgb), 0.22);
}

.starter-question {
  width: fit-content;
  max-width: 100%;
  padding: 10px 13px;
  border-radius: 999px;
  border: 1px solid rgba(var(--accent-rgb), 0.45);
  background: var(--surface-alt);
  color: var(--ink);
  text-align: left;
  font: inherit;
  box-shadow: none;
}

.starter-question:hover,
.starter-question:focus-visible {
  transform: none;
  box-shadow: 0 8px 18px rgba(var(--accent-rgb), 0.18);
  border-color: rgba(var(--accent-rgb), 0.75);
}

.facts-form {
  display: grid;
  gap: 12px;
  margin-bottom: 16px;
}

.questions {
  display: grid;
  gap: 12px;
}

.question-item {
  display: grid;
  gap: 8px;
  font-weight: 500;
}

.facts-history h3 {
  font-size: 1.05rem;
  margin-bottom: 10px;
}

.facts {
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.fact-item {
  display: inline-flex;
  gap: 8px;
  align-items: baseline;
  padding: 10px 12px;
  border-radius: 8px;
  background: var(--surface-alt);
  border: 1px solid var(--border);
}

.fact-item strong {
  font-weight: 600;
}

.memory-editor {
  list-style: none;
  display: grid;
  gap: 14px;
  margin-top: 16px;
}

.memory-editor-item {
  display: grid;
  grid-template-columns: minmax(120px, 0.6fr) minmax(180px, 1fr) auto;
  gap: 12px;
  align-items: end;
  padding: 14px;
  border-radius: 10px;
  background: var(--surface-alt);
  border: 1px solid var(--border);
}

.memory-editor-actions {
  display: flex;
  gap: 8px;
}

.memory-editor-actions button {
  white-space: nowrap;
}

.routine-page,
.vet-page {
  display: grid;
  gap: 18px;
}

.routine-header {
  align-items: start;
}

.routine-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  margin-top: 16px;
}

.routine-secondary-grid {
  margin-top: 14px;
}

.routine-panel {
  padding: 16px;
  border-radius: 16px;
  background: linear-gradient(180deg, var(--accent-soft), var(--surface-alt));
  border: 1px solid rgba(var(--accent-rgb), 0.16);
}

.routine-panel h3 {
  margin-bottom: 12px;
  font-size: 1rem;
}

.routine-list,
.vet-reminder-list {
  list-style: none;
  display: grid;
  gap: 10px;
}

.routine-item {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 10px;
  align-items: start;
  padding: 12px;
  border-radius: 12px;
  background: var(--surface);
  border: 1px solid var(--border);
}

.routine-item div,
.vet-reminder-main {
  display: grid;
  gap: 4px;
}

.routine-kind {
  width: fit-content;
  padding: 3px 8px;
  border-radius: 999px;
  background: var(--surface-deep);
  color: var(--ink) !important;
  font-size: 0.68rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.routine-kind-food {
  background: rgba(66, 181, 124, 0.16);
  color: #8ad8ad !important;
}

.routine-kind-treat {
  background: var(--accent-soft);
  color: var(--gold) !important;
}

.routine-kind-activity {
  background: rgba(10, 132, 255, 0.16);
  color: #8bc7ff !important;
}

.routine-item span,
.routine-list.compact li,
.vet-reminder-main span,
.vet-reminder-main small {
  color: var(--muted);
}

.routine-time {
  padding: 4px 8px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--gold) !important;
  font-size: 0.78rem;
  font-weight: 700;
}

.routine-empty {
  color: var(--muted);
}

.routine-editor {
  margin-top: 18px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}

.routine-editor summary {
  cursor: pointer;
  font-weight: 700;
}

.routine-edit-form,
.vet-reminder-form {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin-top: 14px;
}

.routine-edit-form textarea {
  width: 100%;
  min-height: 90px;
  resize: vertical;
}

.routine-edit-form button,
.vet-reminder-form button,
.vet-reminder-form .helper,
.vet-reminder-form .full-row {
  grid-column: 1 / -1;
}

.vet-reminder-list {
  margin-top: 18px;
}

.vet-reminder-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  gap: 12px;
  align-items: center;
  padding: 14px;
  border-radius: 14px;
  background: var(--surface-alt);
  border: 1px solid var(--border);
}

.vet-reminder-item.is-empty {
  display: block;
  color: var(--muted);
}

.vet-status {
  padding: 6px 10px;
  border-radius: 999px;
  background: var(--surface-deep);
  color: var(--ink);
  font-size: 0.78rem;
  font-weight: 800;
  white-space: nowrap;
}

.vet-status.due-soon {
  background: var(--accent-soft);
  color: var(--gold);
}

.vet-status.due-today,
.vet-status.overdue {
  background: rgba(255, 120, 92, 0.18);
  color: #ffb09d;
}

.vet-reminder-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}

.chart-card {
  background-image: linear-gradient(180deg, var(--chart-start) 0%, var(--chart-end) 100%);
}

.list-card {
  background-image: linear-gradient(180deg, var(--chart-start) 0%, var(--chart-end) 100%);
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 20px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.18s ease;
}

.modal.is-open {
  opacity: 1;
  pointer-events: auto;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(3, 4, 5, 0.72);
  backdrop-filter: blur(2px);
  opacity: 0;
  transition: opacity 0.18s ease;
}

.modal.is-open .modal-backdrop {
  opacity: 1;
}

.modal-dialog {
  position: relative;
  width: min(780px, 100%);
  max-height: calc(100vh - 40px);
  overflow: auto;
  opacity: 0;
  transform: translateY(16px) scale(0.985);
  transition: opacity 0.2s ease, transform 0.2s ease;
}

.modal.is-open .modal-dialog {
  opacity: 1;
  transform: translateY(0) scale(1);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}

.profile-dialog {
  width: min(600px, 100%);
}

.profile-form input:disabled {
  color: var(--muted);
  background: var(--surface-deep);
}

.profile-actions {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
}

.profile-settings-section {
  display: grid;
  gap: 12px;
  margin-top: 18px;
  padding-top: 18px;
  border-top: 1px solid var(--border);
}

.profile-settings-section h3 {
  margin: 0 0 4px;
  font-size: 1rem;
}

.theme-preset-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.theme-preset-option {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  gap: 10px;
  min-height: 52px;
  padding: 8px 10px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--ink);
  box-shadow: none;
  text-align: left;
}

.theme-preset-option:hover {
  transform: none;
  border-color: rgba(var(--accent-rgb), 0.45);
  box-shadow: 0 8px 18px rgba(var(--accent-rgb), 0.12);
}

.theme-preset-option.is-active {
  border-color: rgba(var(--accent-rgb), 0.8);
  box-shadow: 0 0 0 3px rgba(var(--accent-rgb), 0.14);
}

.theme-swatch {
  display: inline-grid;
  grid-template-columns: repeat(2, 1fr);
  width: 42px;
  height: 28px;
  overflow: hidden;
  border-radius: 8px;
  border: 1px solid var(--border);
}

.theme-swatch span {
  display: block;
}

.theme-preset-option[data-theme-option="obsidian"] .theme-swatch span:first-child {
  background: #15191a;
}

.theme-preset-option[data-theme-option="obsidian"] .theme-swatch span:last-child {
  background: #d9a441;
}

.theme-preset-option[data-theme-option="sage"] .theme-swatch span:first-child {
  background: #16231f;
}

.theme-preset-option[data-theme-option="sage"] .theme-swatch span:last-child {
  background: #7cc59f;
}

.theme-preset-option[data-theme-option="ember"] .theme-swatch span:first-child {
  background: #241918;
}

.theme-preset-option[data-theme-option="ember"] .theme-swatch span:last-child {
  background: #e2965d;
}

.theme-preset-option[data-theme-option="tide"] .theme-swatch span:first-child {
  background: #14212a;
}

.theme-preset-option[data-theme-option="tide"] .theme-swatch span:last-child {
  background: #66b7dd;
}

.theme-preset-option[data-theme-option="paper"] .theme-swatch span:first-child {
  background: #f8fbf8;
}

.theme-preset-option[data-theme-option="paper"] .theme-swatch span:last-child {
  background: #386f68;
}

.theme-preset-option[data-theme-option="morning"] .theme-swatch span:first-child {
  background: #fff4e8;
}

.theme-preset-option[data-theme-option="morning"] .theme-swatch span:last-child {
  background: #b45d3c;
}

.legacy-coach-modal {
  display: none !important;
}

.modal-tabs {
  display: inline-flex;
  gap: 8px;
  padding: 4px;
  margin-bottom: 18px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface);
}

.pet-panel {
  margin-top: 4px;
}

.coach-dialog {
  width: min(720px, 100%);
}

.modal-close {
  width: 38px;
  height: 38px;
  padding: 0;
  border-radius: 999px;
  background: transparent;
  border: 1px solid var(--border);
  color: var(--ink);
  font-size: 1.4rem;
  line-height: 1;
}

.modal-close:hover {
  transform: none;
  box-shadow: none;
  border-color: rgba(var(--accent-rgb), 0.4);
  color: var(--gold);
}

body.has-modal-open {
  overflow: hidden;
}

@media (max-width: 640px) {
  .page {
    padding-left: 16px;
    padding-right: 16px;
  }

  .app-shell,
  .hero,
  .hero-actions,
  .app-nav,
  .app-page,
  .card,
  .metric-card {
    width: 100%;
    min-width: 0;
    max-width: 100%;
  }

  .two-column {
    grid-template-columns: 1fr;
  }

  .topbar-actions {
    width: 100%;
    justify-content: space-between;
    min-width: 0;
  }

  .profile-button {
    max-width: calc(100vw - 160px);
  }

  .hero > *,
  .content,
  .chart-card,
  .coach-card {
    min-width: 0;
    max-width: 100%;
  }

  .hero-actions {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .hero-actions button {
    min-width: 0;
    padding-left: 10px;
    padding-right: 10px;
  }

  .hero-actions button:last-child {
    grid-column: 1 / -1;
  }

  .hero-pet-switch {
    max-width: none;
  }

  .theme-preset-grid {
    grid-template-columns: 1fr;
  }

  .app-nav {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 6px;
    width: 100%;
    margin-top: -8px;
    border-radius: 24px;
  }

  .app-nav-button {
    min-width: 0;
    padding: 11px 8px;
    line-height: 1.15;
    white-space: normal;
  }

  .card,
  .metric-card {
    padding: 20px;
  }

  .routine-plan-card {
    padding: 18px;
  }

  .routine-panel {
    padding: 14px;
  }

  .routine-item {
    grid-template-columns: 1fr;
    gap: 8px;
  }

  .routine-time {
    width: fit-content;
  }

  .notifications-panel,
  .notification-toast {
    position: fixed;
    top: 132px;
    left: 16px;
    right: 16px;
    width: auto;
    max-width: none;
  }

  .food-page-card .food-log-form {
    padding: 16px;
  }

  .food-log-form input[type="datetime-local"],
  .food-log-item.is-editing input[type="datetime-local"] {
    font-size: 0.88rem;
    padding-left: 10px;
    padding-right: 10px;
  }

  .food-log-form input[type="datetime-local"]::-webkit-calendar-picker-indicator,
  .food-log-item.is-editing input[type="datetime-local"]::-webkit-calendar-picker-indicator {
    margin-left: 0;
    padding: 0;
  }
}

@media (min-width: 900px) {
  .hero {
    grid-template-columns: minmax(0, 2fr) minmax(0, 1fr);
    align-items: center;
  }

  .content {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    align-items: start;
  }

  .chart-card {
    grid-column: span 2;
  }

  .coach-card {
    grid-column: span 2;
  }

  .pet-update-row {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) auto;
    align-items: end;
  }
}

@media (max-width: 1040px) {
  .food-log-form {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .food-log-form button {
    grid-column: 1 / -1;
    width: fit-content;
  }

  .food-log-item.is-editing {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .food-log-item.is-editing .food-log-actions {
    grid-column: 1 / -1;
  }
}

@media (max-width: 720px) {
  .card-header {
    align-items: flex-start;
    flex-wrap: wrap;
  }

  .coach-form,
  .memory-editor-item,
  .routine-grid,
  .routine-edit-form,
  .vet-reminder-form,
  .vet-reminder-item,
  .food-log-form,
  .food-log-item,
  .food-log-item.is-editing,
  .owner-form,
  .owner-item {
    grid-template-columns: 1fr;
  }

  .chat-bubble {
    max-width: 92%;
  }

  .memory-editor-actions {
    justify-content: flex-start;
  }

  .vet-reminder-actions {
    justify-content: flex-start;
  }

  .food-log-form button,
  .vet-reminder-form button {
    grid-column: 1;
    justify-self: start;
  }

  .food-log-actions {
    justify-content: flex-start;
  }
}
