:root {
  color-scheme: light;
  --bg: #f7f9fc;
  --surface: #ffffff;
  --surface-soft: #f3f7fc;
  --line: #dfe7f1;
  --line-strong: #c7d3e0;
  --text: #162033;
  --muted: #65758b;
  --brand: #2f75ff;
  --brand-strong: #155de6;
  --brand-soft: #e8f1ff;
  --success: #2e9f67;
  --warning: #c47a1d;
  --danger: #d84a4a;
  --pet-gold: #f2a54b;
  --mint: #2ba98c;
  --shadow: 0 18px 45px rgba(20, 47, 78, 0.1);
  --radius: 8px;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  min-width: 320px;
  min-height: 100vh;
  margin: 0;
  background: var(--bg);
  color: var(--text);
}

button,
input {
  font: inherit;
}

button {
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
}

svg {
  display: block;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.app-shell {
  display: grid;
  grid-template-columns: 230px minmax(0, 1fr);
  width: min(1420px, calc(100vw - 32px));
  min-height: calc(100vh - 32px);
  margin: 16px auto;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.88);
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.sidebar {
  display: flex;
  flex-direction: column;
  gap: 28px;
  padding: 24px 18px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.96), rgba(242, 247, 252, 0.96));
  border-right: 1px solid var(--line);
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 32px;
  font-weight: 800;
}

.brand-mark,
.nav-icon,
.parent-shortcut span,
.notice span {
  display: inline-grid;
  place-items: center;
  flex: 0 0 auto;
}

.brand-mark {
  width: 30px;
  height: 30px;
  color: var(--brand);
}

.brand-mark svg,
.nav-icon svg,
.parent-shortcut svg,
.notice svg {
  width: 100%;
  height: 100%;
  fill: currentColor;
}

.nav-list {
  display: grid;
  gap: 10px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  min-height: 48px;
  padding: 0 14px;
  color: var(--text);
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--radius);
  font-weight: 700;
  text-align: left;
}

.nav-icon {
  width: 22px;
  height: 22px;
  color: currentColor;
}

.nav-item.is-active {
  color: var(--brand-strong);
  background: var(--brand-soft);
  border-color: #d3e4ff;
}

.main-panel {
  display: flex;
  flex-direction: column;
  min-width: 0;
  background: rgba(255, 255, 255, 0.76);
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 76px;
  padding: 0 40px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.9);
}

.mobile-brand {
  display: none;
}

.topbar h1 {
  margin: 0;
  font-size: 22px;
  line-height: 1.2;
}

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

.time-chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 70px;
  min-height: 34px;
  padding: 0 12px;
  color: var(--muted);
  background: var(--surface-soft);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  font-weight: 800;
}

.parent-shortcut,
.secondary-button,
.ghost-button,
.primary-button,
.icon-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 40px;
  padding: 0 16px;
  border-radius: var(--radius);
  border: 1px solid transparent;
  font-weight: 800;
  white-space: nowrap;
}

.parent-shortcut {
  color: var(--text);
  background: transparent;
}

.parent-shortcut span {
  width: 20px;
  height: 20px;
}

.primary-button {
  color: #fff;
  background: var(--brand);
  border-color: var(--brand);
  box-shadow: 0 8px 16px rgba(47, 117, 255, 0.18);
}

.primary-button:hover:not(:disabled) {
  background: var(--brand-strong);
}

.primary-button:disabled {
  color: #71839a;
  background: #e9eef5;
  border-color: #dbe4ef;
  box-shadow: none;
}

.secondary-button {
  color: var(--brand-strong);
  background: var(--brand-soft);
  border-color: #cfe0ff;
}

.ghost-button {
  color: var(--muted);
  background: transparent;
  border-color: var(--line);
}

.view {
  display: none;
  flex: 1;
  padding: 24px 40px 22px;
}

.view.is-active {
  display: block;
}

.dashboard-grid {
  display: grid;
  grid-template-columns: minmax(280px, 0.82fr) minmax(430px, 1.58fr);
  gap: 20px;
}

.left-column {
  display: grid;
  grid-template-rows: 1fr auto;
  gap: 20px;
  min-width: 0;
}

.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: 0 10px 28px rgba(22, 45, 78, 0.06);
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.panel h2 {
  margin: 0;
  font-size: 18px;
  line-height: 1.3;
}

.task-panel {
  padding: 22px;
}

.task-summary,
.pet-status {
  flex: 0 0 auto;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.task-list {
  display: grid;
  gap: 8px;
  padding: 16px 0 0;
  margin: 0;
  list-style: none;
}

.task-item {
  display: grid;
  grid-template-columns: 26px minmax(0, 1fr) auto auto;
  align-items: center;
  gap: 12px;
  min-height: 54px;
  padding: 8px 0;
  border-bottom: 1px solid #eef3f8;
}

.task-item:last-child {
  border-bottom: 0;
}

.task-item.is-current {
  padding-inline: 10px;
  margin-inline: -10px;
  background: #f0f8f4;
  border-radius: var(--radius);
  border-bottom-color: transparent;
}

.task-item.is-completed .task-title {
  color: var(--muted);
  text-decoration: line-through;
}

.task-dot {
  display: grid;
  place-items: center;
  width: 21px;
  height: 21px;
  color: transparent;
  border: 2px solid var(--brand);
  border-radius: 50%;
  font-size: 14px;
  font-weight: 900;
}

.task-item.is-completed .task-dot {
  color: #fff;
  background: var(--success);
  border-color: var(--success);
}

.task-main {
  min-width: 0;
}

.task-title {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 800;
}

.task-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.current-pill,
.completed-pill,
.reward-pill {
  display: inline-flex;
  align-items: center;
  min-height: 20px;
  padding: 0 7px;
  border-radius: 999px;
}

.current-pill {
  color: #147451;
  background: #def7ed;
}

.completed-pill {
  color: #347048;
  background: #e2f6e9;
}

.reward-pill {
  color: #885819;
  background: #fff1d9;
}

.task-time {
  color: var(--text);
  font-variant-numeric: tabular-nums;
  font-weight: 800;
}

.task-action {
  min-height: 34px;
  padding: 0 12px;
  color: var(--brand-strong);
  background: var(--brand-soft);
  border: 1px solid #cfe0ff;
  border-radius: var(--radius);
  font-size: 13px;
  font-weight: 900;
}

.task-action:hover:not(:disabled) {
  color: #fff;
  background: var(--brand);
}

.task-action:disabled {
  color: #7b8ca3;
  background: #eef2f6;
  border-color: #e0e7ef;
}

.empty-state {
  padding: 28px 4px 8px;
  color: var(--muted);
  line-height: 1.7;
}

.food-panel {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  min-height: 104px;
  padding: 20px 22px;
}

.food-count {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 12px;
  font-size: 22px;
  font-weight: 900;
}

.food-bag {
  width: 31px;
  height: 31px;
}

.pet-panel {
  display: flex;
  flex-direction: column;
  min-width: 0;
  padding: 22px 28px 26px;
  background: linear-gradient(135deg, #f4f9ff 0%, #eaf4ff 58%, #f8fbff 100%);
}

.pet-stage {
  position: relative;
  display: block;
  width: 100%;
  min-height: 316px;
  padding: 0;
  margin: 8px 0 12px;
  overflow: hidden;
  background: transparent;
  border: 0;
  border-radius: var(--radius);
}

.pet-stage:focus-visible,
.nav-item:focus-visible,
.primary-button:focus-visible,
.secondary-button:focus-visible,
.ghost-button:focus-visible,
.parent-shortcut:focus-visible,
.task-action:focus-visible,
.icon-button:focus-visible,
input:focus-visible {
  outline: 3px solid rgba(47, 117, 255, 0.35);
  outline-offset: 2px;
}

.speech-bubble {
  position: absolute;
  top: 28px;
  right: 6%;
  z-index: 2;
  max-width: 178px;
  min-height: 72px;
  padding: 16px 18px;
  color: #1f406f;
  background: #fff;
  border: 1px solid #e1edf9;
  border-radius: 8px;
  box-shadow: 0 10px 26px rgba(30, 77, 132, 0.1);
  font-weight: 900;
  line-height: 1.45;
  text-align: left;
}

.speech-bubble::after {
  position: absolute;
  left: 18px;
  bottom: -16px;
  width: 22px;
  height: 18px;
  background: #fff;
  clip-path: polygon(0 0, 100% 0, 10% 100%);
  content: "";
}

.pet-svg {
  width: min(100%, 720px);
  height: auto;
  margin: 6px auto 0;
}

.tail {
  transform-box: fill-box;
  transform-origin: left center;
  animation: tailWag 1.15s ease-in-out infinite;
}

.eye {
  transform-box: fill-box;
  transform-origin: center;
  animation: blink 5s ease-in-out infinite;
}

.tongue {
  transform-box: fill-box;
  transform-origin: top center;
  animation: tongueBounce 2.5s ease-in-out infinite;
}

.pet-stage:hover .tail,
.pet-stage:focus-visible .tail {
  animation-duration: 0.58s;
}

.pet-panel.is-fed .pet-character,
.pet-panel.is-played .pet-character {
  animation: happyBounce 0.72s ease both;
}

.pet-panel.is-played .right-front-paw {
  transform-box: fill-box;
  transform-origin: 20% 18%;
  animation: pawWave 0.52s ease-in-out 3;
}

.pet-panel.is-fed .tongue {
  animation: excitedTongue 0.35s ease-in-out 5;
}

.pet-panel.is-resting .tail {
  animation-duration: 2.4s;
}

.pet-panel.is-resting .eye {
  animation: none;
  transform: scaleY(0.18);
}

.pet-panel.is-hungry .tail {
  animation-duration: 1.9s;
}

.pet-meter-row {
  display: grid;
  grid-template-columns: auto minmax(130px, 1fr) auto;
  align-items: center;
  gap: 14px;
  font-weight: 800;
}

.meter {
  height: 14px;
  overflow: hidden;
  background: #dbeafe;
  border-radius: 999px;
}

.meter span {
  display: block;
  width: 0%;
  height: 100%;
  background: linear-gradient(90deg, var(--mint), var(--brand));
  border-radius: inherit;
  transition: width 240ms ease;
}

.pet-actions {
  display: flex;
  justify-content: flex-end;
  margin-top: 14px;
}

.notice {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 58px;
  padding: 0 22px;
  margin-top: 20px;
  color: #334766;
  background: rgba(255, 255, 255, 0.86);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.notice.is-resting {
  color: #7a4b13;
  background: #fff7e8;
  border-color: #f3d79c;
}

.notice span {
  width: 24px;
  height: 24px;
  color: currentColor;
}

.notice p {
  margin: 0;
  line-height: 1.6;
}

.settings-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 20px;
}

.settings-heading h2 {
  margin: 0;
  font-size: 22px;
}

.settings-heading p {
  margin: 8px 0 0;
  color: var(--muted);
}

.settings-grid {
  display: grid;
  grid-template-columns: minmax(360px, 1.45fr) minmax(300px, 0.85fr);
  gap: 20px;
  align-items: start;
}

.manager-panel,
.form-panel {
  padding: 22px;
}

.manager-panel {
  grid-row: span 2;
}

.settings-task-list {
  display: grid;
  gap: 10px;
  margin-top: 16px;
}

.settings-task-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 14px;
  align-items: center;
  padding: 14px 0;
  border-bottom: 1px solid #eef3f8;
}

.settings-task-item:last-child {
  border-bottom: 0;
}

.settings-task-title {
  overflow-wrap: anywhere;
  font-weight: 900;
}

.settings-task-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 7px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

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

.icon-button {
  min-width: 56px;
  min-height: 34px;
  padding: 0 10px;
  color: var(--text);
  background: var(--surface-soft);
  border-color: var(--line);
  font-size: 13px;
}

.icon-button.danger {
  color: var(--danger);
  background: #fff1f1;
  border-color: #ffd4d4;
}

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

.task-form label {
  display: grid;
  gap: 8px;
  color: var(--muted);
  font-size: 14px;
  font-weight: 800;
}

.task-form input {
  width: 100%;
  min-height: 42px;
  padding: 0 12px;
  color: var(--text);
  background: #fff;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  font-weight: 700;
}

.form-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.toast {
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 20;
  max-width: min(360px, calc(100vw - 40px));
  padding: 14px 18px;
  color: #fff;
  background: #16345f;
  border-radius: var(--radius);
  box-shadow: 0 18px 38px rgba(20, 47, 78, 0.26);
  opacity: 0;
  transform: translateY(12px);
  transition: opacity 180ms ease, transform 180ms ease;
  pointer-events: none;
  font-weight: 800;
}

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

@keyframes tailWag {
  0%, 100% { transform: rotate(-6deg); }
  50% { transform: rotate(13deg); }
}

@keyframes blink {
  0%, 92%, 100% { transform: scaleY(1); }
  94%, 96% { transform: scaleY(0.12); }
}

@keyframes tongueBounce {
  0%, 100% { transform: scaleY(1); }
  50% { transform: scaleY(1.16); }
}

@keyframes excitedTongue {
  0%, 100% { transform: scaleY(1); }
  50% { transform: scaleY(1.28); }
}

@keyframes happyBounce {
  0% { transform: translateY(0) scale(1); }
  35% { transform: translateY(-12px) scale(1.02); }
  70% { transform: translateY(2px) scale(0.99); }
  100% { transform: translateY(0) scale(1); }
}

@keyframes pawWave {
  0%, 100% { transform: rotate(0deg) translateY(0); }
  45% { transform: rotate(-20deg) translateY(-16px); }
}

@media (max-width: 1100px) {
  .app-shell {
    grid-template-columns: 190px minmax(0, 1fr);
  }

  .topbar,
  .view {
    padding-inline: 26px;
  }

  .dashboard-grid {
    grid-template-columns: 1fr;
  }

  .left-column {
    grid-template-columns: minmax(0, 1fr) minmax(260px, 0.72fr);
    grid-template-rows: auto;
  }

  .pet-stage {
    min-height: 292px;
  }

  .settings-grid {
    grid-template-columns: 1fr;
  }

  .manager-panel {
    grid-row: auto;
  }
}

@media (max-width: 760px) {
  .app-shell {
    display: block;
    width: 100%;
    min-height: 100vh;
    margin: 0;
    border: 0;
    border-radius: 0;
  }

  .sidebar {
    position: sticky;
    top: 0;
    z-index: 10;
    display: grid;
    grid-template-columns: 1fr;
    gap: 12px;
    padding: 12px 14px;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .brand {
    justify-content: center;
    font-size: 15px;
  }

  .brand-mark {
    width: 24px;
    height: 24px;
  }

  .nav-list {
    grid-template-columns: 1fr 1fr;
    gap: 8px;
  }

  .nav-item {
    justify-content: center;
    min-height: 40px;
    padding: 0 10px;
    font-size: 14px;
  }

  .nav-icon {
    width: 19px;
    height: 19px;
  }

  .topbar {
    min-height: 62px;
    padding: 0 16px;
  }

  .topbar h1 {
    font-size: 18px;
  }

  .parent-shortcut {
    display: none;
  }

  .time-chip {
    min-width: 62px;
  }

  .view {
    padding: 16px;
  }

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

  .task-panel,
  .food-panel,
  .pet-panel,
  .manager-panel,
  .form-panel {
    padding: 16px;
  }

  .task-item {
    grid-template-columns: 24px minmax(0, 1fr) auto;
    gap: 10px;
  }

  .task-action {
    grid-column: 1 / -1;
    width: 100%;
    min-height: 40px;
  }

  .food-panel {
    min-height: 84px;
  }

  .pet-stage {
    min-height: 238px;
    margin-top: 4px;
  }

  .speech-bubble {
    top: 18px;
    right: 8px;
    max-width: 132px;
    min-height: 56px;
    padding: 10px 12px;
    font-size: 12px;
  }

  .plant {
    display: none;
  }

  .pet-meter-row {
    grid-template-columns: auto minmax(90px, 1fr) auto;
    gap: 10px;
    font-size: 13px;
  }

  .settings-heading {
    align-items: stretch;
    flex-direction: column;
  }

  .settings-task-item {
    grid-template-columns: 1fr;
  }

  .row-actions,
  .form-actions,
  .settings-heading .secondary-button {
    width: 100%;
  }

  .row-actions .icon-button,
  .form-actions button,
  .settings-heading .secondary-button {
    flex: 1;
  }

  .notice {
    align-items: flex-start;
    padding: 14px 16px;
  }
}

@media (max-width: 430px) {
  .task-title {
    white-space: normal;
  }

  .food-panel {
    flex-direction: column;
    align-items: stretch;
  }

  .food-panel .primary-button {
    width: 100%;
  }

  .pet-svg {
    width: 112%;
    margin-left: -6%;
  }

  .speech-bubble {
    right: 0;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}