:root {
  --paper: #eef8f7;
  --ink: #1f2f35;
  --muted: #5f7480;
  --line: #c8e0e8;
  --panel: #f8fdff;
  --sage: #7cb342;
  --sage-dark: #3a7ca5;
  --amber: #7cb342;
  --red: #a63d33;
  --blue: #3a7ca5;
  --dino-soft: #d9eef7;
  --shadow: 0 14px 40px rgba(37, 86, 112, 0.13);
  font-family: "Avenir Next", "PingFang SC", "Microsoft YaHei", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background:
    radial-gradient(circle at 12% 8%, rgba(124, 179, 66, 0.16), transparent 24%),
    radial-gradient(circle at 88% 12%, rgba(58, 124, 165, 0.16), transparent 28%),
    linear-gradient(135deg, rgba(217, 238, 247, 0.78), transparent 46%),
    var(--paper);
  color: var(--ink);
  min-height: 100vh;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  opacity: 0.18;
  background-image:
    radial-gradient(ellipse at center, var(--blue) 0 2px, transparent 3px),
    radial-gradient(ellipse at center, var(--sage) 0 2px, transparent 3px),
    radial-gradient(ellipse at center, var(--sage) 0 5px, transparent 6px);
  background-size: 78px 78px, 78px 78px, 96px 96px;
  background-position: 12px 18px, 38px 42px, 70px 18px;
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.48;
}

.app-shell {
  max-width: 760px;
  min-height: 100vh;
  margin: 0 auto;
  padding: 18px 14px 92px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 2px 18px;
}

.top-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.identity-button {
  min-width: 96px;
  min-height: 44px;
  padding: 7px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(248, 253, 255, 0.92);
  color: var(--ink);
  text-align: left;
}

.identity-button span {
  display: block;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.2;
}

.identity-button strong {
  display: block;
  margin-top: 2px;
  font-size: 14px;
  line-height: 1.2;
}

.identity-button.is-empty strong {
  color: var(--red);
}

.eyebrow,
.label {
  display: block;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.4;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  display: flex;
  align-items: center;
  gap: 9px;
  font-size: 28px;
  letter-spacing: 0;
}

.dino-head {
  flex: none;
  width: 42px;
  height: 32px;
  object-fit: contain;
  filter: drop-shadow(0 4px 8px rgba(58, 124, 165, 0.16));
}

h2 {
  font-size: 18px;
  letter-spacing: 0;
}

.view {
  display: none;
}

.view.active {
  display: block;
  animation: viewIn 180ms ease-out;
}

@keyframes viewIn {
  from {
    transform: translateY(6px);
    opacity: 0;
  }
}

.care-strip,
.status-board,
.metric-grid,
.form-grid,
.data-actions {
  display: grid;
  gap: 12px;
}

.care-strip {
  grid-template-columns: 1fr 1fr minmax(110px, 140px);
  align-items: end;
  margin-bottom: 14px;
}

.care-strip > div,
.weight-control,
.panel,
.next-dose,
.episode-card,
.encouragement-card {
  border: 1px solid var(--line);
  background: rgba(248, 253, 255, 0.9);
  box-shadow: var(--shadow);
}

.care-strip > div,
.weight-control {
  min-height: 74px;
  padding: 12px;
  border-radius: 8px;
}

.weight-control input {
  width: 100%;
  margin-top: 4px;
}

.status-board {
  grid-template-columns: 1.35fr 0.85fr;
  margin-bottom: 14px;
}

.next-dose,
.episode-card,
.panel,
.encouragement-card {
  border-radius: 8px;
  padding: 16px;
}

.encouragement-card {
  position: relative;
  overflow: hidden;
  margin-bottom: 12px;
  min-height: 82px;
  padding-right: 118px;
  background:
    radial-gradient(circle at 88% 24%, rgba(124, 179, 66, 0.25), transparent 26%),
    radial-gradient(circle at 96% 78%, rgba(58, 124, 165, 0.16), transparent 20%),
    linear-gradient(135deg, rgba(248, 253, 255, 0.97), rgba(217, 238, 247, 0.86));
  box-shadow: none;
}

.encouragement-card::before {
  content: "";
  position: absolute;
  right: 78px;
  top: 14px;
  width: 48px;
  height: 16px;
  opacity: 0.55;
  background:
    radial-gradient(ellipse at center, var(--sage-dark) 0 4px, transparent 5px),
    radial-gradient(ellipse at center, var(--sage-dark) 0 3px, transparent 4px),
    radial-gradient(ellipse at center, var(--sage-dark) 0 3px, transparent 4px);
  background-size: 18px 14px;
  background-position: 0 5px, 16px 0, 31px 6px;
  background-repeat: no-repeat;
  transform: rotate(-12deg);
}

.encouragement-card::after {
  content: "";
  position: absolute;
  right: 8px;
  bottom: 2px;
  width: 116px;
  height: 84px;
  opacity: 0.54;
  background: url("./dino.svg") center / contain no-repeat;
}

.encouragement-card p {
  margin-top: 0;
  color: var(--sage-dark);
  font-size: 15px;
  line-height: 1.7;
  font-weight: 700;
}

.next-dose h2 {
  font-size: 30px;
  margin: 8px 0;
}

.next-dose p,
.episode-card p {
  color: var(--muted);
  font-size: 14px;
  line-height: 1.6;
}

.episode-card strong {
  display: block;
  font-size: 22px;
  margin: 8px 0;
}

.primary-action,
.secondary-action,
.text-button,
.icon-button,
.bottom-nav button {
  border: 0;
  border-radius: 8px;
}

.primary-action {
  width: 100%;
  min-height: 48px;
  margin-top: 14px;
  background: var(--sage-dark);
  color: #f8fdff;
  font-weight: 700;
}

.secondary-action {
  min-height: 44px;
  padding: 0 14px;
  background: #d9eef7;
  color: var(--ink);
  font-weight: 700;
}

.text-button {
  min-height: 36px;
  padding: 0 10px;
  background: transparent;
  color: var(--sage-dark);
  font-weight: 700;
}

.icon-button {
  width: 38px;
  height: 38px;
  background: var(--panel);
  color: var(--ink);
  border: 1px solid var(--line);
  font-size: 24px;
}

.section-head,
.calendar-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.section-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 6px;
}

.compact-action {
  width: 100%;
  margin-top: 12px;
}

.timeline {
  display: grid;
  gap: 10px;
}

.record-episode-panel {
  margin-top: 14px;
}

.episode-progress {
  display: grid;
  gap: 10px;
}

.episode-progress-head {
  padding: 12px;
  border-radius: 8px;
  background: #f8fdff;
  border: 1px solid var(--line);
}

.episode-progress-head strong {
  display: block;
  margin-bottom: 6px;
}

.medicine-chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 10px;
}

.timeline-item {
  display: grid;
  grid-template-columns: 76px 1fr;
  gap: 10px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fdff;
}

.timeline-time {
  color: var(--muted);
  font-size: 13px;
}

.timeline-body strong {
  display: block;
  margin-bottom: 4px;
}

.timeline-body p {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.55;
}

.pill-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}

.pill {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 0 8px;
  border-radius: 8px;
  background: #d9eef7;
  color: var(--ink);
  font-size: 12px;
}

.pill.alert {
  background: rgba(166, 61, 51, 0.12);
  color: var(--red);
}

.record-admin {
  margin-top: 8px;
}

.record-admin summary {
  color: var(--muted);
  font-size: 12px;
  min-height: 28px;
}

.danger-action {
  min-height: 36px;
  padding: 0 10px;
  border: 1px solid rgba(166, 61, 51, 0.28);
  border-radius: 8px;
  background: rgba(166, 61, 51, 0.10);
  color: var(--red);
  font-weight: 700;
}

.record-form {
  margin-bottom: 14px;
}

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

label span,
.subhead {
  display: block;
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 13px;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fdff;
  color: var(--ink);
  min-height: 44px;
  padding: 10px 11px;
}

textarea {
  resize: vertical;
  line-height: 1.6;
}

.dose-row {
  display: grid;
  grid-template-columns: 1fr 82px;
  gap: 8px;
}

.dose-advisor,
.dose-schedule,
.warning-box {
  margin-top: 12px;
  padding: 12px;
  border-radius: 8px;
  line-height: 1.6;
  font-size: 14px;
}

.dose-advisor {
  background: rgba(58, 124, 165, 0.10);
  border: 1px solid rgba(58, 124, 165, 0.18);
}

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

.rx-grid > div {
  min-height: 72px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fdff;
}

.rx-grid b {
  display: block;
  margin-top: 4px;
  color: var(--ink);
  line-height: 1.35;
}

.rx-note {
  margin-top: 10px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.6;
}

.dose-schedule {
  display: grid;
  gap: 8px;
  background: rgba(124, 179, 66, 0.12);
  border: 1px solid rgba(124, 179, 66, 0.24);
}

.dose-schedule strong {
  color: var(--sage-dark);
}

.schedule-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.schedule-cell {
  min-height: 70px;
  padding: 10px;
  border-radius: 8px;
  background: #f8fdff;
  border: 1px solid var(--line);
}

.schedule-cell b {
  display: block;
  margin-top: 4px;
  color: var(--ink);
  font-size: 18px;
}

.schedule-cell b.alert {
  color: var(--red);
}

.warning-box {
  background: rgba(166, 61, 51, 0.12);
  border: 1px solid rgba(166, 61, 51, 0.22);
  color: var(--red);
  font-weight: 700;
}

.optional-fields {
  margin-top: 12px;
}

.optional-fields summary {
  min-height: 40px;
  color: var(--sage-dark);
  font-weight: 700;
}

.full-line,
.diazepam-fields {
  display: block;
  margin-top: 12px;
}

.form-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  align-items: end;
}

.form-actions .primary-action {
  margin-top: 0;
}

.weekday-row,
.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 6px;
}

.weekday-row {
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 12px;
  text-align: center;
}

.day-cell {
  position: relative;
  min-height: 54px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fdff;
  padding: 6px;
  text-align: left;
}

.day-cell.is-muted {
  opacity: 0.36;
}

.day-cell.is-selected {
  outline: 2px solid var(--sage-dark);
}

.day-cell.has-record {
  background:
    radial-gradient(ellipse at 82% 78%, rgba(124, 179, 66, 0.46) 0 7px, transparent 8px),
    #d9eef7;
}

.day-number {
  display: block;
  font-weight: 700;
}

.day-dot {
  display: inline-block;
  width: 9px;
  height: 11px;
  margin-right: 3px;
  border-radius: 50% 50% 46% 46%;
  background: var(--amber);
  box-shadow: 5px -2px 0 -2px var(--sage-dark);
  transform: rotate(-12deg);
}

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

.metric {
  padding: 12px;
  border-radius: 8px;
  background: #f8fdff;
  border: 1px solid var(--line);
}

.metric strong {
  display: block;
  margin-top: 4px;
  font-size: 24px;
}

.lookup-fields {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 12px;
}

.lookup-field {
  min-height: 36px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fdff;
  color: var(--sage-dark);
  font-weight: 700;
}

.lookup-field.active {
  background: var(--sage-dark);
  color: #f8fdff;
}

.lookup-results {
  display: grid;
  gap: 10px;
}

.lookup-item {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fdff;
}

.lookup-item strong {
  display: block;
  margin-bottom: 6px;
}

.lookup-item p {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.6;
}

.summary-table-wrap {
  overflow-x: auto;
}

.summary-table {
  width: 100%;
  min-width: 520px;
  border-collapse: collapse;
  font-size: 13px;
}

.summary-table th,
.summary-table td {
  border-bottom: 1px solid var(--line);
  padding: 10px 8px;
  text-align: left;
}

.medicine-settings {
  display: grid;
  gap: 12px;
}

.medicine-config {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: #f8fdff;
}

.medicine-config h3 {
  margin: 0 0 10px;
  font-size: 16px;
}

.settings-save-bar {
  display: grid;
  grid-template-columns: 1fr minmax(140px, 180px);
  gap: 12px;
  align-items: center;
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}

.settings-save-bar strong {
  display: block;
  margin-top: 4px;
  color: var(--ink);
}

.settings-save-action {
  margin-top: 0;
}

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

.import-label {
  display: grid;
  align-content: center;
  min-height: 44px;
  padding: 10px 12px;
  border-radius: 8px;
  background: #d9eef7;
  font-weight: 700;
}

.import-label span {
  margin: 0;
  color: var(--ink);
  font-size: 14px;
}

.import-label input {
  display: none;
}

.empty-state {
  display: grid;
  justify-items: center;
  gap: 7px;
  padding: 22px;
  border: 1px dashed var(--line);
  border-radius: 8px;
  color: var(--muted);
  text-align: center;
  background:
    radial-gradient(circle at 50% 20%, rgba(124, 179, 66, 0.12), transparent 35%),
    rgba(248, 253, 255, 0.58);
}

.empty-state strong {
  color: var(--ink);
  font-size: 15px;
}

.empty-state small {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}

.empty-dino {
  width: 78px;
  height: 54px;
  object-fit: contain;
  filter: drop-shadow(0 8px 14px rgba(58, 124, 165, 0.14));
}

.identity-modal,
.app-modal {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: grid;
  place-items: end center;
  padding: 18px 12px;
  background: rgba(37, 35, 31, 0.28);
}

.identity-modal[hidden],
.app-modal[hidden] {
  display: none;
}

.identity-panel,
.app-modal-panel {
  width: min(520px, 100%);
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.app-modal-panel {
  position: relative;
  overflow: hidden;
  padding: 18px;
}

.app-modal-panel::after {
  content: "";
  position: absolute;
  right: -8px;
  top: -8px;
  width: 102px;
  height: 72px;
  opacity: 0.14;
  background: url("./dino.svg") center / contain no-repeat;
}

.app-modal-kicker {
  display: inline-flex;
  min-height: 26px;
  align-items: center;
  padding: 0 9px;
  border-radius: 8px;
  background: rgba(58, 124, 165, 0.12);
  color: var(--sage-dark);
  font-size: 12px;
  font-weight: 800;
}

.app-modal-panel h2 {
  margin-top: 12px;
  font-size: 20px;
}

.app-modal-panel p {
  margin-top: 10px;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.7;
  white-space: pre-line;
}

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

.app-modal-actions.single {
  grid-template-columns: 1fr;
}

.app-modal-action {
  min-height: 46px;
  border: 0;
  border-radius: 8px;
  font-weight: 800;
}

.app-modal-action.primary {
  background: var(--sage-dark);
  color: #f8fdff;
}

.app-modal-action.secondary {
  background: #d9eef7;
  color: var(--ink);
}

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

.identity-option {
  min-height: 46px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fdff;
  color: var(--ink);
  font-weight: 700;
}

.identity-option.active {
  background: var(--sage-dark);
  color: #f8fdff;
}

.identity-note {
  margin-top: 12px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.6;
}

.bottom-nav {
  position: fixed;
  left: 50%;
  bottom: 12px;
  z-index: 20;
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 4px;
  width: min(732px, calc(100vw - 24px));
  transform: translateX(-50%);
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(248, 253, 255, 0.94);
  box-shadow: var(--shadow);
  backdrop-filter: blur(14px);
}

.bottom-nav button {
  min-height: 44px;
  background: transparent;
  color: var(--muted);
  font-weight: 700;
}

.bottom-nav button.active {
  background: var(--sage-dark);
  color: #f8fdff;
}

@media (max-width: 560px) {
  .app-shell {
    padding-inline: 10px;
  }

  h1 {
    font-size: 24px;
  }

  .topbar {
    align-items: flex-start;
  }

  .identity-button {
    min-width: 86px;
  }

  .care-strip,
  .status-board,
  .form-grid,
  .form-actions,
  .config-grid {
    grid-template-columns: 1fr;
  }

  .care-strip {
    grid-template-columns: 1fr 1fr;
  }

  .weight-control {
    grid-column: 1 / -1;
  }

  .section-head {
    align-items: flex-start;
  }

  .section-actions {
    max-width: 156px;
  }

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

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

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

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

  .day-cell {
    min-height: 46px;
    padding: 5px;
  }
}
