:root {
  color-scheme: light;
  --ink: #24202b;
  --muted: #6d6678;
  --line: #2f2a39;
  --paper: #fff8e8;
  --panel: #f8eac7;
  --panel-2: #dcf1da;
  --blue: #87c7d4;
  --green: #8fca8d;
  --pink: #f3a7b5;
  --gold: #f1c85b;
  --danger: #c75050;
  --shadow: rgba(36, 32, 43, 0.16);
  font-family: "Courier New", "Noto Sans TC", monospace;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    linear-gradient(90deg, rgba(36, 32, 43, 0.04) 1px, transparent 1px),
    linear-gradient(rgba(36, 32, 43, 0.04) 1px, transparent 1px),
    #9fc8b8;
  background-size: 18px 18px;
  color: var(--ink);
}

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

button {
  cursor: pointer;
}

.app-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 18px;
}

.login-screen {
  width: min(100%, 430px);
  border: 4px solid var(--line);
  background: var(--paper);
  box-shadow: 10px 10px 0 var(--shadow);
}

.phone {
  width: min(100%, 430px);
  min-height: min(900px, calc(100vh - 36px));
  max-height: calc(100vh - 36px);
  overflow: auto;
  border: 4px solid var(--line);
  background: var(--paper);
  box-shadow: 10px 10px 0 var(--shadow);
  image-rendering: pixelated;
}

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

.eyebrow,
.label {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  letter-spacing: 0;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: 30px;
}

h2 {
  margin-bottom: 0;
  font-size: 18px;
}

.crisis-button,
.primary-button,
.secondary-button,
.tab,
.chip,
.icon-button,
.role-option {
  border: 3px solid var(--line);
  color: var(--ink);
  background: #fff;
  box-shadow: 3px 3px 0 var(--line);
}

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

.role-badge,
.live-status {
  border: 2px solid var(--line);
  background: #fffdf5;
  padding: 6px 8px;
  font-size: 12px;
}

.live-status.active {
  background: var(--gold);
}

.live-status.warn {
  background: #ffe3e3;
  color: var(--danger);
}

.crisis-button {
  background: #ffe3e3;
  padding: 8px 12px;
}

.secondary-button {
  background: #fff;
  padding: 8px 10px;
  font-size: 13px;
}

.role-picker {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  margin: 18px 0 14px;
}

.role-option {
  min-height: 46px;
  background: #fff;
}

.role-option.active {
  background: var(--green);
  transform: translate(2px, 2px);
  box-shadow: 1px 1px 0 var(--line);
}

.auth-error {
  border: 3px solid var(--danger);
  background: #ffe3e3;
  color: var(--danger);
  padding: 9px;
  line-height: 1.5;
}

.tabs {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  gap: 7px;
  padding: 8px 12px 12px;
  background: var(--paper);
}

.tab {
  flex: 1 1 0;
  min-width: 0;
  min-height: 40px;
  padding: 8px 4px;
  font-size: 13px;
}

.tab.active {
  background: var(--gold);
  transform: translate(2px, 2px);
  box-shadow: 1px 1px 0 var(--line);
}

.view {
  display: none;
  padding: 0 14px 18px;
}

.view.active {
  display: block;
}

.hero-panel,
.pixel-card,
.feedback-card {
  border: 4px solid var(--line);
  background: var(--panel);
  box-shadow: 5px 5px 0 var(--line);
  padding: 14px;
  margin-bottom: 16px;
}

.hero-panel {
  display: grid;
  grid-template-columns: 1fr 116px;
  gap: 12px;
  align-items: center;
  background: #d7ecf0;
}

.day-count {
  display: block;
  margin: 4px 0 8px;
  font-size: clamp(42px, 13vw, 62px);
  line-height: 0.95;
}

.soft-copy {
  color: var(--muted);
  line-height: 1.55;
  margin-bottom: 0;
}

.pet-stage {
  display: grid;
  justify-items: center;
  gap: 6px;
}

.pet-stage p {
  margin: 0;
  font-size: 13px;
}

.pet-image {
  width: 86px;
  height: 86px;
  object-fit: contain;
  image-rendering: pixelated;
  filter: drop-shadow(3px 3px 0 var(--line));
}


.stat-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-bottom: 16px;
}

.stat-grid article {
  min-height: 70px;
  border: 3px solid var(--line);
  background: #fff;
  padding: 10px;
  box-shadow: 3px 3px 0 var(--line);
}

.stat-grid span {
  display: block;
  color: var(--muted);
  font-size: 12px;
}

.stat-grid strong {
  display: block;
  margin-top: 5px;
  font-size: 24px;
}

.stats-grid article:nth-child(2) strong::after {
  content: "天";
  margin-left: 2px;
  font-size: 13px;
  color: var(--muted);
}

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

.section-title span {
  color: var(--muted);
  font-size: 12px;
}

.upload-box {
  min-height: 190px;
  display: grid;
  place-items: center;
  border: 3px dashed var(--line);
  background: #fffdf5;
  margin-bottom: 12px;
  overflow: hidden;
  text-align: center;
  color: var(--muted);
}

.upload-box input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.upload-box img {
  width: 100%;
  height: 210px;
  object-fit: cover;
}

.chip-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}

.chip {
  padding: 8px 10px;
  background: #fff;
}

.chip.active {
  background: var(--green);
}

.field {
  display: grid;
  gap: 6px;
  margin-bottom: 12px;
}

.field span,
.slider-pair span {
  color: var(--muted);
  font-size: 13px;
}

.field input,
.field textarea,
.field select {
  width: 100%;
  border: 3px solid var(--line);
  background: #fffdf5;
  padding: 10px;
  color: var(--ink);
  resize: vertical;
}

.slider-pair,
.inline-fields {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  margin-bottom: 12px;
}

.slider-pair label {
  display: grid;
  gap: 8px;
}

input[type="range"] {
  accent-color: var(--green);
}

.check-row {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  line-height: 1.5;
  margin: 8px 0 14px;
  color: var(--muted);
  font-size: 13px;
}

.primary-button {
  width: 100%;
  min-height: 48px;
  background: var(--gold);
  font-weight: 700;
}

.primary-button:active,
.secondary-button:active,
.crisis-button:active,
.role-option:active,
.chip:active,
.calendar-control:active {
  transform: translate(2px, 2px);
  box-shadow: 1px 1px 0 var(--line);
}

.feedback-card {
  background: var(--panel-2);
}

.feedback-card p:last-child {
  line-height: 1.6;
  margin-bottom: 0;
}

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

.meter {
  display: grid;
  grid-template-columns: 48px 1fr;
  gap: 10px;
  align-items: center;
  font-size: 13px;
}

.meter i {
  height: 18px;
  border: 3px solid var(--line);
  background: #fffdf5;
}

.meter b {
  display: block;
  height: 100%;
  width: 0;
  background: var(--blue);
}

.calendar-controls {
  display: grid;
  grid-template-columns: 42px 1fr 42px;
  gap: 8px;
  margin-bottom: 12px;
}

.calendar-control {
  min-height: 38px;
  border: 3px solid var(--line);
  background: #fff;
  color: var(--ink);
  box-shadow: 3px 3px 0 var(--line);
}

.today-control {
  background: var(--blue);
  font-weight: 700;
}

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

.calendar-weekday,
.calendar-spacer {
  min-height: 22px;
}

.calendar-weekday {
  display: grid;
  place-items: center;
  color: var(--muted);
  font-size: 12px;
}

.calendar-day {
  aspect-ratio: 1;
  border: 2px solid var(--line);
  background: #fffdf5;
  font-size: 12px;
  box-shadow: 2px 2px 0 var(--line);
}

.calendar-day.has-entry {
  background: var(--green);
}

.calendar-day.incident {
  background: #e8c0c0;
}

.calendar-day.today {
  outline: 3px solid var(--blue);
  outline-offset: -5px;
}

.calendar-day.selected {
  background: var(--gold);
  transform: translate(2px, 2px);
  box-shadow: 1px 1px 0 var(--line);
}

.entry-detail img {
  width: 100%;
  max-height: 260px;
  object-fit: cover;
  border: 3px solid var(--line);
  margin-bottom: 10px;
}

.entry-detail p {
  line-height: 1.6;
}


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

.message-item {
  border: 3px solid var(--line);
  background: #fffdf5;
  padding: 10px;
}

.message-item p {
  margin-bottom: 8px;
  line-height: 1.55;
}

.message-meta,
.quick-message-row {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}

.message-meta span {
  border: 2px solid var(--line);
  background: #fff;
  padding: 4px 6px;
  color: var(--muted);
  font-size: 12px;
}

.quick-message-row {
  margin: 0 0 12px;
}

.message-template {
  background: #fff;
}

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

.timeline-item {
  border: 3px solid var(--line);
  background: #fffdf5;
  padding: 10px;
}

.timeline-item h3 {
  margin: 0 0 6px;
  font-size: 15px;
}

.timeline-item p {
  margin-bottom: 8px;
  color: var(--muted);
  line-height: 1.5;
}

.trend-block {
  display: grid;
  gap: 8px;
  margin-bottom: 16px;
}

.trend-block:last-child {
  margin-bottom: 0;
}

.trend-heading {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
}

.trend-heading span {
  font-weight: 700;
}

.trend-heading small {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.4;
}

.bar-chart {
  min-height: 146px;
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: minmax(34px, 1fr);
  align-items: end;
  gap: 8px;
  border: 3px solid var(--line);
  background: #fffdf5;
  padding: 10px 8px 8px;
  overflow-x: auto;
}

.bar-item {
  min-width: 34px;
  display: grid;
  grid-template-rows: 18px 90px 20px;
  justify-items: center;
  align-items: end;
  gap: 5px;
  color: var(--muted);
  font-size: 11px;
}

.bar-value {
  color: var(--ink);
  font-weight: 700;
}

.bar-pixel {
  width: 100%;
  min-height: 6px;
  border: 2px solid var(--line);
  background: var(--pink);
  box-shadow: 2px 2px 0 var(--line);
}

.mood-chart .bar-pixel {
  background: var(--blue);
}

.care-list {
  display: grid;
  gap: 8px;
}

.care-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  border: 3px solid var(--line);
  background: #fffdf5;
  padding: 10px;
}

.care-item strong {
  font-size: 18px;
}

.mini-button {
  border: 2px solid var(--line);
  background: var(--blue);
  padding: 7px 9px;
  box-shadow: 2px 2px 0 var(--line);
}

.safety-dialog {
  width: min(92vw, 390px);
  border: 4px solid var(--line);
  background: var(--paper);
  box-shadow: 8px 8px 0 var(--line);
  color: var(--ink);
}

.safety-dialog::backdrop {
  background: rgba(36, 32, 43, 0.5);
}

.icon-button {
  width: 34px;
  height: 34px;
  background: #fff;
}

.hotline-list {
  display: grid;
  gap: 8px;
}

.hotline-list a {
  border: 3px solid var(--line);
  background: #ffe3e3;
  color: var(--ink);
  padding: 10px;
  text-decoration: none;
  box-shadow: 3px 3px 0 var(--line);
}

@media (max-width: 440px) {
  .app-shell {
    padding: 0;
  }

  .login-screen,
  .phone {
    width: 100%;
    min-height: 100vh;
    max-height: none;
    border-width: 0;
    box-shadow: none;
  }

  .hero-panel {
    grid-template-columns: 1fr 96px;
  }
}

.compact-panel {
  background: #fff3c7;
}

.reply-list,
.special-list,
.journal-list {
  display: grid;
  gap: 10px;
}

.notify-toggle {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  border: 3px solid var(--line);
  background: #fffdf5;
  padding: 10px;
  margin-bottom: 12px;
  line-height: 1.45;
}

.notify-toggle.disabled {
  opacity: 0.62;
}

.notify-toggle input {
  width: 18px;
  height: 18px;
  margin-top: 2px;
  accent-color: var(--green);
}

.notify-toggle span {
  display: grid;
  gap: 3px;
}

.notify-toggle strong {
  font-size: 14px;
}

.notify-toggle small {
  color: var(--muted);
  font-size: 12px;
}

.reply-item,
.special-item,
.journal-item {
  border: 3px solid var(--line);
  background: #fffdf5;
  padding: 10px;
}

.reply-item p,
.special-item p,
.journal-item p {
  margin-bottom: 8px;
  line-height: 1.5;
}

.reply-item span,
.special-item span,
.journal-head span {
  color: var(--muted);
  font-size: 12px;
}

.special-item {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: start;
  gap: 10px;
}

.special-item h3,
.special-inline h3 {
  margin: 4px 0 6px;
  font-size: 15px;
}

.special-item.past {
  opacity: 0.72;
}

.special-inline {
  border: 3px solid var(--line);
  background: #fff3c7;
  padding: 10px;
  margin-bottom: 12px;
}

.calendar-day.special-day {
  background: #fff3c7;
}

.calendar-day.has-entry.special-day {
  background: linear-gradient(135deg, var(--green) 0 50%, #fff3c7 50% 100%);
}

.journal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 8px;
}

.journal-head h3 {
  margin: 0;
}

.notice-badge {
  border: 2px solid var(--line);
  background: var(--gold);
  padding: 4px 6px;
  color: var(--ink) !important;
}

.journal-item img {
  width: 100%;
  max-height: 180px;
  object-fit: cover;
  border: 3px solid var(--line);
  margin-bottom: 8px;
}

.compact-replies {
  margin-top: 12px;
}


.selected-entry {
  border: 3px solid var(--line);
  background: #fffdf5;
  padding: 10px;
  margin: -2px 0 12px;
}

.selected-entry-head {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 8px;
}

.selected-entry-head span {
  color: var(--muted);
  font-size: 12px;
}

.selected-entry p {
  margin-bottom: 8px;
  line-height: 1.5;
}

.form-notice {
  border: 3px solid var(--line);
  background: var(--panel-2);
  padding: 9px;
  margin: 0 0 12px;
  line-height: 1.5;
}
