/* 麦芽 Maltie · 小窝小居民第一版
   只负责花盆麦芽的前端展示，不接后端、不影响聊天主流程。 */
:root {
  --maltie-yellow: #ffd84f;
  --maltie-yellow-soft: #fff3a8;
  --maltie-green: #75c84a;
  --maltie-ink: #5f4a24;
  --maltie-pot: #df8951;
  --maltie-soil: #6a4026;
  --maltie-card: rgba(255, 253, 244, 0.82);
  --maltie-line: rgba(180, 132, 58, 0.18);
  --maltie-shadow: 0 18px 42px rgba(138, 108, 45, 0.18);
}

.maltie-corner {
  position: absolute;
  z-index: 6;
  width: 174px;
  min-height: 206px;
  display: grid;
  justify-items: center;
  align-content: end;
  gap: 8px;
  pointer-events: none;
}

.maltie-corner[data-maltie-home] {
  position: static;
  grid-column: 4;
  grid-row: 2 / 4;
  justify-self: stretch;
  align-self: stretch;
  width: 100%;
  min-height: 0;
  margin: 0;
  display: grid;
  place-items: center;
}

.maltie-corner[data-maltie-room] {
  position: relative;
  right: auto;
  top: auto;
  justify-self: end;
  width: 174px;
  margin: -4px 4px 16px auto;
}

.maltie-pad {
  position: relative;
  width: 158px;
  min-height: 178px;
  padding: 10px 10px 14px;
  border: 1px solid rgba(255, 255, 255, 0.74);
  border-radius: 34px;
  background:
    radial-gradient(circle at 50% 74%, rgba(166, 221, 116, 0.22) 0 34%, transparent 35%),
    linear-gradient(145deg, rgba(255, 254, 242, 0.86), rgba(255, 244, 184, 0.62));
  box-shadow: var(--maltie-shadow);
  backdrop-filter: blur(12px);
  pointer-events: auto;
}

.maltie-pad::before {
  content: "";
  position: absolute;
  left: 17px;
  right: 17px;
  bottom: 12px;
  height: 32px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(117, 200, 74, 0.22), rgba(255, 255, 255, 0.1) 68%);
  filter: blur(1px);
}

.maltie-button {
  position: relative;
  z-index: 2;
  width: 100%;
  min-height: 142px;
  border: 0;
  padding: 0;
  background: transparent;
  cursor: pointer;
  display: grid;
  place-items: end center;
}

.maltie-portrait {
  width: 132px;
  height: 132px;
  object-fit: contain;
  filter: drop-shadow(0 13px 18px rgba(110, 76, 28, 0.19));
  transform-origin: 50% 88%;
  animation: maltie-breathe 4.8s ease-in-out infinite;
  user-select: none;
  -webkit-user-drag: none;
}

.maltie-button:hover .maltie-portrait,
.maltie-button:focus-visible .maltie-portrait {
  animation-duration: 2.8s;
  transform: translateY(-2px) rotate(-1deg) scale(1.025);
}

.maltie-button:focus-visible {
  outline: 3px solid rgba(255, 207, 72, 0.62);
  outline-offset: 5px;
  border-radius: 28px;
}

.maltie-nameplate {
  position: relative;
  z-index: 3;
  margin: -4px auto 0;
  width: fit-content;
  max-width: 132px;
  padding: 5px 10px;
  border-radius: 999px;
  color: #6f5825;
  background: rgba(255, 255, 255, 0.74);
  box-shadow: 0 8px 18px rgba(128, 91, 25, 0.1);
  font-size: 12px;
  font-weight: 900;
  white-space: nowrap;
}

.maltie-bubble {
  position: absolute;
  z-index: 8;
  right: 20px;
  bottom: calc(100% - 20px);
  width: min(238px, 72vw);
  padding: 12px 14px;
  border: 1px solid rgba(255, 232, 133, 0.76);
  border-radius: 22px 22px 8px 22px;
  color: var(--maltie-ink);
  background: rgba(255, 253, 241, 0.96);
  box-shadow: 0 16px 34px rgba(116, 80, 20, 0.16);
  line-height: 1.54;
  font-size: 13px;
  font-weight: 800;
  opacity: 0;
  transform: translateY(8px) scale(0.96);
  pointer-events: none;
  transition: opacity 150ms ease, transform 150ms ease;
}

.maltie-bubble::after {
  content: "";
  position: absolute;
  right: 22px;
  bottom: -7px;
  width: 14px;
  height: 14px;
  background: inherit;
  border-right: 1px solid rgba(255, 232, 133, 0.76);
  border-bottom: 1px solid rgba(255, 232, 133, 0.76);
  transform: rotate(45deg);
}

.maltie-corner.is-talking .maltie-bubble {
  opacity: 1;
  transform: translateY(0) scale(1);
}

.maltie-note {
  position: relative;
  z-index: 3;
  max-width: 155px;
  margin: 2px auto 0;
  color: rgba(98, 77, 39, 0.72);
  font-size: 11px;
  font-weight: 800;
  line-height: 1.45;
  text-align: center;
}

.maltie-corner[data-mood="sleeping"] .maltie-portrait,
.maltie-corner[data-mood="tired"] .maltie-portrait {
  animation-name: maltie-sleepy-breathe;
}

.maltie-corner[data-mood="sunny"] .maltie-pad {
  background:
    radial-gradient(circle at 38% 18%, rgba(255, 237, 119, 0.54), transparent 34%),
    radial-gradient(circle at 50% 74%, rgba(166, 221, 116, 0.22) 0 34%, transparent 35%),
    linear-gradient(145deg, rgba(255, 254, 242, 0.9), rgba(255, 244, 184, 0.7));
}

.maltie-corner[data-mood="waiting"] .maltie-pad {
  background:
    radial-gradient(circle at 72% 16%, rgba(145, 201, 255, 0.26), transparent 34%),
    linear-gradient(145deg, rgba(255, 254, 242, 0.88), rgba(255, 244, 184, 0.6));
}

.maltie-corner[data-mood="dazed"] .maltie-pad {
  background:
    radial-gradient(circle at 40% 18%, rgba(255, 255, 255, 0.42), transparent 34%),
    linear-gradient(145deg, rgba(255, 254, 242, 0.88), rgba(255, 246, 198, 0.62));
}

.maltie-corner[data-mood="thinking"] .maltie-pad {
  background:
    radial-gradient(circle at 70% 18%, rgba(255, 255, 255, 0.56), transparent 32%),
    radial-gradient(circle at 36% 72%, rgba(126, 203, 113, 0.16), transparent 36%),
    linear-gradient(145deg, rgba(255, 254, 242, 0.9), rgba(255, 244, 184, 0.64));
}

@keyframes maltie-breathe {
  0%, 100% { transform: translateY(0) rotate(0deg) scale(1); }
  42% { transform: translateY(-3px) rotate(-0.7deg) scale(1.012); }
  68% { transform: translateY(-1px) rotate(0.7deg) scale(1.005); }
}

@keyframes maltie-sleepy-breathe {
  0%, 100% { transform: translateY(0) scale(0.998); filter: drop-shadow(0 13px 18px rgba(110, 76, 28, 0.17)) saturate(0.92); }
  50% { transform: translateY(2px) scale(0.99); filter: drop-shadow(0 10px 14px rgba(110, 76, 28, 0.13)) saturate(0.86); }
}

@media (max-width: 820px) {
  .maltie-corner,
  .maltie-corner[data-maltie-home],
  .maltie-corner[data-maltie-room] {
    position: relative;
    grid-column: auto;
    grid-row: auto;
    justify-self: center;
    right: auto;
    top: auto;
    width: min(100%, 210px);
    margin: 12px auto 0;
  }

  .maltie-pad {
    width: 170px;
  }

  .maltie-bubble {
    left: 50%;
    right: auto;
    bottom: calc(100% - 6px);
    transform: translate(-50%, 8px) scale(0.96);
    border-radius: 22px 22px 22px 8px;
  }

  .maltie-corner.is-talking .maltie-bubble {
    transform: translate(-50%, 0) scale(1);
  }

  .maltie-bubble::after {
    left: 34px;
    right: auto;
  }
}

/* v3：麦芽成长档案 / 小居民计时器 */
.maltie-profile-button {
  position: relative;
  z-index: 4;
  display: block;
  width: fit-content;
  margin: 8px auto 0;
  border: 0;
  border-radius: 999px;
  padding: 6px 12px;
  color: #7a5b13;
  background: rgba(255, 255, 255, 0.78);
  box-shadow: 0 8px 18px rgba(128, 91, 25, 0.1);
  font-size: 12px;
  font-weight: 900;
  cursor: pointer;
}

.maltie-profile-button:hover,
.maltie-profile-button:focus-visible {
  background: rgba(255, 244, 172, 0.94);
  outline: none;
  transform: translateY(-1px);
}

.maltie-profile-panel[hidden] {
  display: none;
}

.maltie-profile-panel {
  position: fixed;
  inset: 0;
  z-index: 2000;
  display: grid;
  place-items: center;
  padding: 22px;
}

.maltie-profile-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(39, 64, 82, 0.22);
  backdrop-filter: blur(8px);
}

.maltie-profile-card {
  position: relative;
  z-index: 1;
  width: min(520px, calc(100vw - 32px));
  max-height: min(720px, calc(100vh - 44px));
  overflow: auto;
  border: 1px solid rgba(255, 255, 255, 0.82);
  border-radius: 34px;
  padding: 20px;
  color: var(--maltie-ink);
  background:
    radial-gradient(circle at 18% 8%, rgba(255, 235, 119, 0.46), transparent 26%),
    linear-gradient(145deg, rgba(255, 253, 239, 0.98), rgba(255, 245, 200, 0.96));
  box-shadow: 0 28px 80px rgba(91, 73, 36, 0.24);
}

.maltie-profile-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 16px;
}

.maltie-profile-head span {
  color: rgba(95, 74, 36, 0.62);
  font-size: 12px;
  font-weight: 900;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.maltie-profile-head h3 {
  margin: 4px 0 0;
  font-size: 28px;
  letter-spacing: -0.04em;
}

.maltie-profile-close {
  width: 42px;
  height: 42px;
  border: 0;
  border-radius: 50%;
  color: #8b641d;
  background: rgba(255, 255, 255, 0.72);
  box-shadow: 0 10px 20px rgba(128, 91, 25, 0.12);
  font-size: 24px;
  font-weight: 900;
  cursor: pointer;
}

.maltie-profile-close:focus-visible {
  outline: 3px solid rgba(255, 207, 72, 0.68);
  outline-offset: 3px;
}

.maltie-profile-hero {
  display: grid;
  grid-template-columns: 132px 1fr;
  gap: 16px;
  align-items: center;
  padding: 14px;
  border: 1px solid rgba(255, 231, 141, 0.55);
  border-radius: 26px;
  background: rgba(255, 255, 255, 0.55);
}

.maltie-profile-hero img {
  width: 132px;
  height: 132px;
  object-fit: contain;
  filter: drop-shadow(0 13px 18px rgba(110, 76, 28, 0.16));
}

.maltie-profile-hero strong,
.maltie-profile-hero span {
  display: block;
}

.maltie-profile-hero strong {
  font-size: 22px;
  font-weight: 1000;
}

.maltie-profile-hero span {
  margin-top: 5px;
  color: rgba(95, 74, 36, 0.68);
  font-size: 13px;
  font-weight: 900;
}

.maltie-profile-hero p {
  margin: 10px 0 0;
  color: rgba(95, 74, 36, 0.76);
  line-height: 1.6;
  font-size: 13px;
  font-weight: 800;
}

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

.maltie-profile-grid div {
  min-width: 0;
  padding: 12px 14px;
  border: 1px solid rgba(255, 231, 141, 0.44);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.46);
}

.maltie-profile-grid dt {
  color: rgba(95, 74, 36, 0.6);
  font-size: 12px;
  font-weight: 900;
}

.maltie-profile-grid dd {
  margin: 4px 0 0;
  color: #5f4a24;
  font-size: 16px;
  font-weight: 1000;
  word-break: break-word;
}

.maltie-growth-card {
  padding: 15px;
  border-radius: 24px;
  background: linear-gradient(145deg, rgba(255, 252, 235, 0.82), rgba(255, 239, 163, 0.72));
  box-shadow: inset 0 0 0 1px rgba(255, 231, 141, 0.58);
}

.maltie-growth-line {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 6px 0;
  font-size: 13px;
  font-weight: 900;
}

.maltie-growth-line span {
  color: rgba(95, 74, 36, 0.65);
}

.maltie-growth-line strong {
  color: #684d16;
}

.maltie-progress-track {
  height: 12px;
  margin: 13px 0 9px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(118, 167, 78, 0.18);
}

.maltie-progress-track span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #ffd84f, #7fcf57);
}

.maltie-growth-card p,
.maltie-profile-foot {
  margin: 0;
  color: rgba(95, 74, 36, 0.72);
  line-height: 1.55;
  font-size: 13px;
  font-weight: 800;
}

.maltie-profile-foot {
  margin-top: 12px;
  text-align: center;
}

@media (max-width: 560px) {
  .maltie-profile-card {
    padding: 16px;
    border-radius: 28px;
  }

  .maltie-profile-hero {
    grid-template-columns: 1fr;
    justify-items: center;
    text-align: center;
  }

  .maltie-profile-grid {
    grid-template-columns: 1fr;
  }

  .maltie-growth-line {
    align-items: flex-start;
    flex-direction: column;
    gap: 2px;
  }
}

/* 2026-10-13 · 7.2.1：客厅竖版里麦芽跟随工具小卡右下角 */
html[data-layout-effective="portrait"] #homeView .maltie-corner[data-maltie-home] {
  grid-column: 5 !important;
  grid-row: 1 !important;
  position: relative !important;
  justify-self: stretch !important;
  align-self: stretch !important;
  width: 100% !important;
  min-height: 68px !important;
  margin: 0 !important;
  display: grid !important;
  place-items: center !important;
}
html[data-layout-effective="portrait"] #homeView .maltie-corner[data-maltie-home] .maltie-pad {
  width: 100% !important;
  min-height: 68px !important;
  padding: 7px 4px !important;
  border-radius: 20px !important;
}
html[data-layout-effective="portrait"] #homeView .maltie-corner[data-maltie-home] .maltie-button {
  min-height: 44px !important;
}
html[data-layout-effective="portrait"] #homeView .maltie-corner[data-maltie-home] .maltie-portrait {
  width: 50px !important;
  height: 50px !important;
}
html[data-layout-effective="portrait"] #homeView .maltie-corner[data-maltie-home] .maltie-nameplate {
  max-width: 100% !important;
  font-size: 10px !important;
  padding: 3px 5px !important;
}
html[data-layout-effective="portrait"] #homeView .maltie-corner[data-maltie-home] .maltie-note,
html[data-layout-effective="portrait"] #homeView .maltie-corner[data-maltie-home] .maltie-profile-button {
  display: none !important;
}

/* 2026-10-14 · 7.4.3：客厅竖版麦芽跟随 2×2 工具区右侧，跨两行。 */
html[data-layout-effective="portrait"] #homeView .maltie-corner[data-maltie-home] {
  grid-column: 3 !important;
  grid-row: 1 / span 2 !important;
  align-self: stretch !important;
  justify-self: stretch !important;
  width: 100% !important;
  min-width: 0 !important;
  min-height: 0 !important;
  margin: 0 !important;
  display: grid !important;
  place-items: stretch !important;
}
html[data-layout-effective="portrait"] #homeView .maltie-corner[data-maltie-home] .maltie-pad {
  width: 100% !important;
  height: 100% !important;
  min-height: 0 !important;
  box-sizing: border-box !important;
  display: grid !important;
  align-content: center !important;
  justify-items: center !important;
  padding: 8px 5px !important;
}
html[data-layout-effective="portrait"] #homeView .maltie-corner[data-maltie-home] .maltie-button {
  width: 100% !important;
  min-height: 58px !important;
  place-items: center !important;
}
html[data-layout-effective="portrait"] #homeView .maltie-corner[data-maltie-home] .maltie-portrait {
  width: 62px !important;
  height: 62px !important;
}
