:root {
  color-scheme: light;
  --ink: #352018;
  --muted: #7a5f52;
  --line: #6c3f2e;
  --paper: #fff6e6;
  --panel: rgba(255, 250, 240, 0.9);
  --panel-solid: #fff8eb;
  --accent: #f6b95d;
  --accent-strong: #d76f45;
  --blue: #72bdd0;
  --green: #8fcf9c;
  --pink: #f2a4b7;
  --danger: #ef6b5c;
  --shadow: 0 18px 45px rgba(83, 51, 31, 0.18);
  font-family: "Microsoft JhengHei", "PingFang TC", system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background:
    linear-gradient(90deg, rgba(97, 66, 44, 0.08) 0 1px, transparent 1px 100%),
    linear-gradient(0deg, rgba(97, 66, 44, 0.08) 0 1px, transparent 1px 100%),
    #f8dba8;
  background-size: 52px 52px;
}

button,
textarea,
input {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-shell {
  min-height: 100vh;
  padding: 18px clamp(14px, 3vw, 34px) 106px;
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.7), rgba(255, 255, 255, 0) 36%),
    radial-gradient(circle at 20% 18%, rgba(255, 255, 255, 0.55), transparent 24rem);
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  max-width: 1180px;
  margin: 0 auto 18px;
}

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

.brand h1,
.brand p {
  margin: 0;
}

.brand h1 {
  font-size: clamp(1.55rem, 3vw, 2.4rem);
  line-height: 1.05;
}

.eyebrow {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.date-chip {
  border: 2px solid var(--line);
  border-radius: 999px;
  padding: 10px 16px;
  background: var(--panel);
  box-shadow: 0 6px 0 rgba(76, 43, 26, 0.15);
  font-weight: 900;
}

.main {
  max-width: 1180px;
  margin: 0 auto;
}

.dashboard {
  display: grid;
  grid-template-columns: minmax(280px, 0.92fr) minmax(330px, 1.08fr);
  gap: 22px;
  align-items: stretch;
}

.monster-stage {
  min-height: 520px;
  border: 3px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  position: relative;
  background:
    linear-gradient(180deg, rgba(255, 238, 204, 0.62), rgba(255, 246, 230, 0.95)),
    url("/assets/room.svg") center / cover;
  box-shadow: var(--shadow);
}

.speech {
  position: absolute;
  left: 50%;
  top: 34px;
  transform: translateX(-50%);
  width: min(78%, 480px);
  padding: 16px 20px;
  border: 3px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 251, 243, 0.96);
  font-weight: 900;
  line-height: 1.45;
  text-align: center;
  box-shadow: 0 8px 0 rgba(76, 43, 26, 0.12);
}

.speech::after {
  content: "";
  position: absolute;
  left: 50%;
  bottom: -18px;
  width: 24px;
  height: 24px;
  background: inherit;
  border-right: 3px solid var(--line);
  border-bottom: 3px solid var(--line);
  transform: translateX(-50%) rotate(45deg);
}

.monster-scene {
  height: 100%;
  display: grid;
  place-items: end center;
  padding: 120px 24px 46px;
}

.monster-art {
  --monster-color: #fff3dc;
  --monster-accent: #efd1a8;
  width: min(58vw, 310px);
  aspect-ratio: 1 / 1.06;
  position: relative;
  filter: drop-shadow(0 22px 16px rgba(69, 38, 24, 0.22));
  transition: transform 220ms ease;
}

.monster-art:active {
  transform: translateY(3px) scale(0.99);
}

.monster-body {
  position: absolute;
  left: 16%;
  right: 16%;
  top: 23%;
  bottom: 9%;
  border: 4px solid var(--line);
  border-radius: 45% 45% 36% 36%;
  background:
    radial-gradient(circle at 32% 32%, rgba(255, 255, 255, 0.8), transparent 18%),
    var(--monster-color);
}

.monster-body::before,
.monster-body::after {
  content: "";
  position: absolute;
  top: 42%;
  width: 34%;
  height: 28%;
  border: 4px solid var(--line);
  border-radius: 50%;
  background: var(--monster-color);
  z-index: -1;
}

.monster-body::before {
  left: -23%;
}

.monster-body::after {
  right: -23%;
}

.monster-foot {
  position: absolute;
  bottom: 4%;
  width: 24%;
  height: 18%;
  border: 4px solid var(--line);
  border-top: 0;
  border-radius: 0 0 50% 50%;
  background: var(--monster-color);
}

.monster-foot.left {
  left: 30%;
}

.monster-foot.right {
  right: 30%;
}

.eye {
  position: absolute;
  top: 43%;
  width: 8.5%;
  height: 11%;
  border-radius: 50%;
  background: var(--ink);
  z-index: 2;
}

.eye.left {
  left: 39%;
}

.eye.right {
  right: 39%;
}

.cheek {
  position: absolute;
  top: 55%;
  width: 12%;
  height: 7%;
  border-radius: 50%;
  background: rgba(239, 115, 105, 0.42);
  z-index: 2;
}

.cheek.left {
  left: 29%;
}

.cheek.right {
  right: 29%;
}

.mouth {
  position: absolute;
  left: 47%;
  top: 55%;
  width: 7%;
  height: 4%;
  border-bottom: 4px solid var(--line);
  border-radius: 0 0 999px 999px;
  z-index: 3;
}

.face-sad .mouth,
.face-worried .mouth,
.face-angry .mouth {
  border-top: 4px solid var(--line);
  border-bottom: 0;
  border-radius: 999px 999px 0 0;
}

.face-happy .mouth {
  width: 14%;
  height: 10%;
  left: 43%;
  border: 4px solid var(--line);
  border-top: 0;
  background: #db6d69;
}

.face-angry .eye {
  height: 7%;
  border-radius: 999px;
  transform: rotate(15deg);
}

.face-angry .eye.right {
  transform: rotate(-15deg);
}

.palette-blue {
  --monster-color: #9dd4e6;
  --monster-accent: #629eb7;
}

.palette-coral {
  --monster-color: #ffd4bf;
  --monster-accent: #e36e58;
}

.palette-mint {
  --monster-color: #c8ead6;
  --monster-accent: #73b58b;
}

.palette-pink {
  --monster-color: #ffd3df;
  --monster-accent: #ed92aa;
}

.palette-green {
  --monster-color: #d7edc4;
  --monster-accent: #82bd66;
}

.horn,
.ear,
.flower,
.sprout,
.tear,
.sleepy,
.body-item {
  position: absolute;
  z-index: 4;
}

.horn {
  top: 13%;
  width: 12%;
  height: 18%;
  border: 4px solid var(--line);
  background: var(--danger);
  clip-path: polygon(50% 0, 100% 100%, 0 100%);
}

.horn.left {
  left: 30%;
  transform: rotate(-18deg);
}

.horn.right {
  right: 30%;
  transform: rotate(18deg);
}

.ear {
  top: 16%;
  width: 16%;
  height: 18%;
  border: 4px solid var(--line);
  background: #f7aac0;
  clip-path: polygon(50% 0, 100% 100%, 0 100%);
}

.ear.left {
  left: 26%;
  transform: rotate(-28deg);
}

.ear.right {
  right: 26%;
  transform: rotate(28deg);
}

.flower {
  right: 25%;
  top: 16%;
  width: 22%;
  height: 22%;
  background:
    radial-gradient(circle, #f7cc58 0 18%, transparent 19%),
    radial-gradient(circle at 50% 0, #f19ab3 0 24%, transparent 25%),
    radial-gradient(circle at 100% 50%, #f19ab3 0 24%, transparent 25%),
    radial-gradient(circle at 50% 100%, #f19ab3 0 24%, transparent 25%),
    radial-gradient(circle at 0 50%, #f19ab3 0 24%, transparent 25%);
}

.sprout {
  left: 45%;
  top: 9%;
  width: 12%;
  height: 18%;
  border-left: 4px solid #497743;
}

.sprout::after {
  content: "";
  position: absolute;
  left: 3px;
  top: 0;
  width: 34px;
  height: 20px;
  border: 3px solid #497743;
  border-radius: 50% 50% 50% 0;
  background: #8fd37a;
  transform: rotate(-24deg);
}

.tear {
  top: 57%;
  width: 7%;
  height: 12%;
  border: 3px solid #367f9e;
  border-radius: 60% 60% 60% 0;
  background: #7fd5ed;
}

.tear.left {
  left: 33%;
  transform: rotate(-20deg);
}

.tear.right {
  right: 33%;
  transform: rotate(-20deg);
}

.sleepy {
  top: 36%;
  width: 14%;
  height: 8%;
  border-top: 4px solid var(--line);
  transform: rotate(18deg);
}

.sleepy.left {
  left: 31%;
}

.sleepy.right {
  right: 31%;
  transform: rotate(-18deg);
}

.glasses {
  position: absolute;
  left: 32%;
  top: 41%;
  width: 36%;
  height: 15%;
  z-index: 4;
}

.glasses::before,
.glasses::after {
  content: "";
  position: absolute;
  width: 38%;
  height: 88%;
  border: 4px solid var(--line);
  border-radius: 50%;
}

.glasses::before {
  left: 0;
}

.glasses::after {
  right: 0;
}

.glasses span {
  position: absolute;
  left: 39%;
  top: 45%;
  width: 22%;
  border-top: 4px solid var(--line);
}

.body-item {
  left: 58%;
  top: 47%;
  width: 28%;
  height: 34%;
  border: 4px solid var(--line);
  border-radius: 8px;
  background: #d69541;
}

.body-item.bell {
  left: 43%;
  top: 68%;
  width: 14%;
  height: 14%;
  border-radius: 50% 50% 45% 45%;
  background: #79c8dc;
}

.body-item.scarf {
  left: 26%;
  top: 60%;
  width: 48%;
  height: 10%;
  border-radius: 999px;
  background: #e8735f;
}

.body-item.clover {
  left: 60%;
  top: 64%;
  width: 18%;
  height: 18%;
  border: 0;
  background:
    radial-gradient(circle at 30% 30%, #77c96e 0 25%, transparent 27%),
    radial-gradient(circle at 70% 30%, #77c96e 0 25%, transparent 27%),
    radial-gradient(circle at 35% 70%, #77c96e 0 25%, transparent 27%),
    radial-gradient(circle at 70% 70%, #77c96e 0 25%, transparent 27%);
}

.body-item.star,
.body-item.wings {
  left: 60%;
  top: 55%;
  width: 20%;
  height: 20%;
  border-radius: 50%;
  background: #f6d55f;
}

.body-item.wings {
  left: 18%;
  background: #fff8ed;
  border-radius: 50% 10% 50% 10%;
}

.panel {
  border: 3px solid var(--line);
  border-radius: 8px;
  background: var(--panel-solid);
  box-shadow: var(--shadow);
}

.interaction-panel {
  display: grid;
  gap: 16px;
  padding: 18px;
}

.mood-panel {
  padding: 18px;
}

.panel-title {
  margin: 0 0 12px;
  font-size: 1.18rem;
}

.mood-row {
  display: grid;
  grid-template-columns: 58px 1fr 58px;
  gap: 10px;
  align-items: center;
  font-weight: 900;
}

.mood-meter {
  position: relative;
  height: 22px;
  border: 3px solid var(--line);
  border-radius: 999px;
  overflow: hidden;
  background: linear-gradient(90deg, #5aaed0, #f5d97a 50%, #ef6b5c);
}

.mood-thumb {
  position: absolute;
  top: -5px;
  width: 18px;
  height: 28px;
  border: 3px solid var(--line);
  border-radius: 999px;
  background: #fff8ee;
  transform: translateX(-50%);
}

.entry-form {
  display: grid;
  gap: 12px;
}

textarea,
input {
  width: 100%;
  border: 3px solid var(--line);
  border-radius: 8px;
  background: #fffdfa;
  color: var(--ink);
  padding: 14px 16px;
  resize: vertical;
  min-height: 130px;
  outline: none;
}

textarea:focus,
input:focus {
  box-shadow: 0 0 0 4px rgba(246, 185, 93, 0.38);
}

.primary-button,
.ghost-button,
.icon-button {
  min-height: 48px;
  border: 3px solid var(--line);
  border-radius: 8px;
  background: var(--accent);
  color: var(--ink);
  font-weight: 950;
  box-shadow: 0 6px 0 rgba(76, 43, 26, 0.18);
}

.primary-button:disabled,
.ghost-button:disabled {
  opacity: 0.56;
  cursor: not-allowed;
}

.ghost-button {
  background: #fff8eb;
}

.chat-log {
  max-height: 220px;
  overflow: auto;
  display: grid;
  gap: 10px;
  padding: 14px;
  border: 3px solid rgba(108, 63, 46, 0.28);
  border-radius: 8px;
  background: rgba(255, 253, 250, 0.74);
}

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

.chat-bubble {
  margin: 0;
  width: fit-content;
  max-width: 92%;
  padding: 10px 12px;
  border: 2px solid var(--line);
  border-radius: 8px;
  line-height: 1.5;
  font-weight: 800;
}

.user-bubble {
  justify-self: end;
  background: #f6dca6;
}

.monster-bubble {
  justify-self: start;
  background: #e6f4f1;
}

.empty-chat {
  margin: 0;
  color: var(--muted);
  font-weight: 800;
}

.carry-panel,
.magic-card {
  display: grid;
  gap: 10px;
  padding: 14px;
  border: 3px solid rgba(108, 63, 46, 0.28);
  border-radius: 8px;
  background: rgba(255, 253, 250, 0.74);
}

.magic-view {
  max-width: 760px;
  margin: 0 auto;
}

.magic-card {
  padding: 18px;
}

.magic-monster {
  display: flex;
  align-items: center;
  gap: 14px;
}

.magic-monster h3,
.magic-monster p {
  margin: 0;
}

.magic-monster h3 {
  font-size: 1.2rem;
}

.magic-monster p {
  color: var(--muted);
  font-weight: 800;
}

.magic-link-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  align-items: center;
}

.magic-link-row input {
  min-height: 48px;
}

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

.status-line {
  min-height: 24px;
  color: var(--muted);
  font-weight: 800;
}

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

.task-grid,
.post-grid,
.diary-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 16px;
}

.task-card,
.post-card,
.diary-card {
  padding: 16px;
  border: 3px solid var(--line);
  border-radius: 8px;
  background: var(--panel-solid);
  box-shadow: 0 10px 0 rgba(76, 43, 26, 0.1);
}

.task-card {
  display: grid;
  grid-template-columns: 58px 1fr auto;
  gap: 12px;
  align-items: center;
}

.task-symbol {
  width: 58px;
  height: 58px;
  border: 3px solid var(--line);
  border-radius: 8px;
  display: grid;
  place-items: center;
  background: #d9eef3;
}

.task-symbol::before,
.nav-icon::before,
.icon-button::before {
  content: "";
  display: block;
  width: 24px;
  height: 24px;
  border: 3px solid currentColor;
}

.symbol-wind::before {
  border-left: 0;
  border-bottom: 0;
  border-radius: 50%;
}

.symbol-note::before,
.icon-task::before,
.icon-diary::before {
  border-radius: 4px;
}

.symbol-cup::before {
  border-radius: 0 0 8px 8px;
}

.symbol-hand::before {
  border-radius: 50% 50% 8px 8px;
}

.symbol-pencil::before {
  transform: rotate(-35deg);
  border-radius: 5px;
}

.symbol-spark::before {
  transform: rotate(45deg);
}

.task-card h3,
.post-card h3,
.diary-card h3 {
  margin: 0 0 6px;
  font-size: 1.06rem;
}

.task-card p,
.post-card p,
.diary-card p {
  margin: 0;
  color: var(--muted);
  line-height: 1.55;
}

.task-meta {
  display: inline-block;
  margin: 0 0 6px;
  padding: 3px 8px;
  border: 2px solid var(--line);
  border-radius: 999px;
  background: #e6f4f1;
  color: var(--ink);
  font-size: 0.78rem;
  font-weight: 950;
}

.mini-monster {
  width: 74px;
  height: 74px;
  border: 3px solid var(--line);
  border-radius: 50% 50% 42% 42%;
  background: var(--monster-color, #fff3dc);
  position: relative;
}

.mini-monster::before,
.mini-monster::after {
  content: "";
  position: absolute;
  top: 34%;
  width: 8px;
  height: 10px;
  border-radius: 50%;
  background: var(--ink);
}

.mini-monster::before {
  left: 24px;
}

.mini-monster::after {
  right: 24px;
}

.post-card {
  display: grid;
  gap: 10px;
}

.post-head,
.diary-head {
  display: flex;
  gap: 12px;
  align-items: center;
}

.post-actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
}

.empty {
  padding: 26px;
  text-align: center;
  color: var(--muted);
  font-weight: 800;
}

.bottom-nav {
  position: fixed;
  left: 50%;
  bottom: 14px;
  transform: translateX(-50%);
  width: min(1180px, calc(100vw - 28px));
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  border: 3px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  background: rgba(255, 248, 235, 0.94);
  box-shadow: 0 16px 40px rgba(83, 51, 31, 0.22);
  z-index: 20;
}

.nav-item {
  min-width: 0;
  min-height: 72px;
  border: 0;
  border-right: 2px solid rgba(108, 63, 46, 0.24);
  background: transparent;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  color: var(--ink);
  font-weight: 950;
}

.nav-item:last-child {
  border-right: 0;
}

.nav-item.is-active {
  background: var(--accent);
}

.nav-icon {
  width: 30px;
  height: 30px;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
}

.icon-monster::before {
  border-radius: 50% 50% 42% 42%;
  background: #9fd8d0;
}

.icon-community::before {
  border-radius: 50%;
  box-shadow: 14px 0 0 -3px currentColor, -14px 0 0 -3px currentColor;
}

.icon-link::before {
  width: 26px;
  height: 16px;
  border-radius: 999px;
  transform: rotate(-28deg);
}

.install-backdrop {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: end center;
  padding: 18px;
  background: rgba(53, 32, 24, 0.24);
}

.install-sheet {
  width: min(480px, 100%);
  padding: 18px;
  border: 3px solid var(--line);
  border-radius: 8px;
  background: var(--panel-solid);
  box-shadow: var(--shadow);
}

.install-sheet h2,
.install-sheet p {
  margin: 0 0 12px;
}

.install-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

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

.section-head h2 {
  margin: 0;
  font-size: clamp(1.4rem, 3vw, 2rem);
}

.community-form {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
}

.community-form input {
  min-height: 52px;
}

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

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

  .monster-stage {
    min-height: 470px;
  }

  .speech {
    width: calc(100% - 28px);
    top: 20px;
    font-size: 0.98rem;
  }

  .interaction-panel {
    padding: 14px;
  }

  .date-chip {
    display: none;
  }

  .nav-item {
    min-height: 66px;
    gap: 4px;
    flex-direction: column;
    font-size: 0.72rem;
  }

  .task-card {
    grid-template-columns: 52px 1fr;
  }

  .task-card button {
    grid-column: 1 / -1;
  }

  .community-form {
    grid-template-columns: 1fr;
  }

  .magic-link-row {
    grid-template-columns: 1fr;
  }
}
