:root {
  --pink: #ff4fa1;
  --pink-soft: #ffd6ec;
  --blue: #38b6ff;
  --blue-soft: #d8f3ff;
  --ink: #21223a;
  --muted: #6f7191;
  --card: rgba(255, 255, 255, 0.9);
  --line: rgba(33, 34, 58, 0.1);
  --shadow: 0 16px 38px rgba(45, 36, 97, 0.18);
  --radius-xl: 28px;
  --radius-lg: 20px;
  --radius-md: 14px;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  font-family: "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Segoe UI", sans-serif;
  color: var(--ink);
  background: #ffffff;
  display: grid;
  place-items: center;
  padding: 18px;
}

.page-bg {
  position: fixed;
  inset: 0;
  pointer-events: none;
  background: transparent;
}

.phone-shell {
  position: relative;
  width: min(420px, 100%);
  height: min(860px, 100dvh - 24px);
  border: 10px solid #fff;
  border-radius: 40px;
  background: linear-gradient(165deg, rgba(255, 79, 161, 0.16), rgba(56, 182, 255, 0.18));
  box-shadow: 0 24px 48px rgba(30, 30, 60, 0.24);
  overflow: hidden;
}

.phone-camera {
  position: absolute;
  top: 8px;
  left: 50%;
  transform: translateX(-50%);
  width: 96px;
  height: 22px;
  border-radius: 999px;
  background: rgba(20, 25, 52, 0.85);
  z-index: 3;
}

.mini-app {
  position: relative;
  z-index: 2;
  height: 100%;
  display: flex;
  flex-direction: column;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.68), rgba(255, 255, 255, 0.78));
}

.top-time {
  padding: calc(28px + env(safe-area-inset-top, 0px)) 18px 10px;
  text-align: center;
}

.top-time p {
  margin: 0;
  font-size: 1rem;
  font-weight: 700;
  color: #2b2d5c;
}

.view {
  display: none;
  flex: 1;
  overflow-y: auto;
  padding: 4px 14px calc(90px + env(safe-area-inset-bottom, 0px));
}

.view--active {
  display: block;
}

.panel {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow);
  padding: 14px;
  margin-bottom: 12px;
  backdrop-filter: blur(6px);
}

.panel-title {
  margin: 0 0 10px;
  font-size: 1.12rem;
}

.panel-title-sm {
  font-size: 1rem;
  margin: 0;
}

.mood-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.mood-btn {
  border: 2px solid transparent;
  border-radius: 18px;
  min-height: 92px;
  background: linear-gradient(180deg, #ffffff, #f9f2ff);
  font: inherit;
  color: var(--ink);
  font-weight: 700;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: transform 0.14s ease, border-color 0.14s ease;
}

.mood-btn .emoji {
  font-size: 1.5rem;
  line-height: 1;
}

.mood-btn .name {
  font-size: 0.84rem;
}

.mood-btn.is-active {
  border-color: rgba(255, 79, 161, 0.65);
  transform: translateY(-1px) scale(1.02);
}

.diary-input,
.chat-input {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  resize: none;
  padding: 12px;
  font: inherit;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.92);
}

.chat-input {
  padding: 10px 12px;
}

.diary-input:focus,
.chat-input:focus {
  outline: 2px solid rgba(56, 182, 255, 0.44);
  border-color: transparent;
}

.voice-bar {
  width: 100%;
  border: none;
  margin-top: 10px;
  border-radius: 18px;
  min-height: 56px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0;
  padding: 0 16px;
  background: linear-gradient(90deg, #ff5cac, #5fc9ff);
  color: #fff;
  font: inherit;
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 10px 24px rgba(255, 79, 161, 0.34);
}

.now-tools-row {
  margin-top: 10px;
  display: flex;
  gap: 10px;
}

.now-tools-row > * {
  flex: 1 1 0;
  min-width: 0;
}

.now-tools-row .voice-bar {
  width: auto; /* 避免在 flex 下仍被 width: 100% 影响布局 */
  margin-top: 0;
}

.image-bar {
  width: auto;
  border: 1px solid rgba(33, 34, 58, 0.12);
  border-radius: 18px;
  min-height: 56px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0;
  padding: 0 14px;
  background: linear-gradient(90deg, rgba(56, 182, 255, 0.14), rgba(255, 79, 161, 0.14));
  color: #2b2d5c;
  font: inherit;
  font-size: 1rem;
  font-weight: 900;
  cursor: pointer;
  box-shadow: 0 10px 24px rgba(56, 182, 255, 0.10);
}

.image-bar .image-icon {
  font-size: 1.12rem;
}

.voice-bar-chat {
  position: relative;
  justify-content: center;
}

.voice-bar-chat .voice-dot {
  position: absolute;
  left: 16px;
}

.voice-bar-chat #voice-chat-label {
  width: 100%;
  text-align: center;
}

.voice-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 0 0 0 rgba(255, 255, 255, 0.6);
}

.voice-bar.is-recording .voice-dot {
  animation: pulse 1.1s ease-in-out infinite;
}

@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgba(255, 255, 255, 0.56); }
  70% { box-shadow: 0 0 0 10px rgba(255, 255, 255, 0); }
  100% { box-shadow: 0 0 0 0 rgba(255, 255, 255, 0); }
}

.row-between {
  margin-top: 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.hint {
  color: var(--muted);
  font-size: 0.88rem;
  font-weight: 600;
}

.btn {
  border: none;
  border-radius: 16px;
  min-height: 54px;
  padding: 0 18px;
  font: inherit;
  font-size: 1rem;
  font-weight: 800;
  cursor: pointer;
}

.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.btn-primary {
  background: linear-gradient(120deg, #ff4fa1, #38b6ff);
  color: #fff;
}

.btn-secondary {
  background: linear-gradient(120deg, #38b6ff, #ff7abb);
  color: #fff;
}

.btn-ghost {
  min-height: 44px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.9);
  color: #2b2d5c;
  border: 1px solid var(--line);
  font-size: 0.92rem;
}

.btn-block {
  width: 100%;
  margin-top: 10px;
}

#send-chat {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  padding: 0;
  display: grid;
  place-items: center;
  margin: 12px auto 0;
  box-shadow: 0 10px 24px rgba(56, 182, 255, 0.22);
}

.panel-chat {
  margin-bottom: 0;
}

.chat-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}

.chat-list {
  min-height: 130px;
  max-height: 230px;
  overflow-y: auto;
  background: rgba(255, 255, 255, 0.74);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 10px;
}

.chat-msg {
  margin-bottom: 8px;
  display: flex;
}

.chat-msg:last-child {
  margin-bottom: 0;
}

.chat-msg.user {
  justify-content: flex-end;
}

.bubble {
  max-width: 84%;
  padding: 10px 12px;
  border-radius: 14px;
  font-size: 0.94rem;
  line-height: 1.5;
}

.bubble.ai {
  background: #ffffff;
  border: 1px solid #dfedf7;
}

.bubble.user {
  background: linear-gradient(120deg, #ff69b4, #58c3ff);
  color: #fff;
}

.quick-actions {
  display: flex;
  gap: 8px;
  margin: 10px 0;
  overflow-x: auto;
  padding-bottom: 2px;
}

.quick-chip {
  flex: 0 0 auto;
  min-height: 38px;
  padding: 0 14px;
  border: 1px solid rgba(255, 93, 171, 0.18);
  border-radius: 999px;
  background: linear-gradient(120deg, rgba(255, 255, 255, 0.95), rgba(249, 245, 255, 0.95));
  color: #565b82;
  font: inherit;
  font-size: 0.88rem;
  font-weight: 800;
  cursor: pointer;
}

.archive-tools {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  margin-top: 10px;
}

.archive-tabs {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.archive-tab {
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 12px;
  font: inherit;
  font-size: 0.9rem;
  font-weight: 800;
  color: #4f5379;
  background: rgba(255, 255, 255, 0.9);
  cursor: pointer;
}

.archive-tab.is-active {
  color: #fff;
  border-color: transparent;
  background: linear-gradient(130deg, #ff5dab, #4ec4ff);
}

.archive-panel {
  margin-bottom: 10px;
}

.calendar-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 10px;
}

.calendar-title {
  margin: 0;
  font-size: 0.95rem;
  font-weight: 800;
  color: #43486f;
}

.cal-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 6px;
}

.cal-cell {
  min-height: 38px;
  border: 1px solid rgba(33, 34, 58, 0.08);
  border-radius: 10px;
  background: #fff;
  font: inherit;
  font-size: 0.83rem;
  color: #4f5379;
  cursor: pointer;
}

.cal-cell.has-entry {
  background: linear-gradient(130deg, rgba(255, 93, 171, 0.2), rgba(78, 196, 255, 0.2));
  border-color: rgba(255, 93, 171, 0.28);
}

.cal-cell.is-active {
  color: #fff;
  border-color: transparent;
  background: linear-gradient(130deg, #ff5dab, #4ec4ff);
}

.report-switch {
  display: flex;
  gap: 8px;
}

.report-charts {
  margin-top: 12px;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 12px;
}

.report-chart-card {
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 14px;
  background: rgba(255, 255, 255, 0.9);
  box-shadow: 0 12px 24px rgba(55, 73, 122, 0.08);
}

.report-chart-title {
  margin: 0 0 12px;
  font-size: 0.95rem;
  color: #394062;
}

.report-chart-main {
  display: flex;
  align-items: center;
  gap: 14px;
}

.report-chart-pie {
  width: 112px;
  height: 112px;
  border-radius: 50%;
  flex: 0 0 112px;
  background: conic-gradient(#d9deef 0deg 360deg);
  box-shadow: inset 0 0 0 10px rgba(255, 255, 255, 0.85);
}

.report-chart-legend {
  flex: 1;
  min-width: 0;
  display: grid;
  gap: 8px;
}

.report-chart-item {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.report-chart-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex: 0 0 10px;
}

.report-chart-text {
  min-width: 0;
  display: flex;
  justify-content: space-between;
  gap: 8px;
  width: 100%;
  font-size: 0.82rem;
  color: #4a5175;
}

.report-chart-label {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.report-chart-value {
  white-space: nowrap;
  color: #2f3656;
  font-weight: 700;
}

.report-chart-empty {
  margin: 0;
  color: #7b81a6;
  font-size: 0.88rem;
}

.report-body {
  margin-top: 10px;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 12px;
  background: rgba(255, 255, 255, 0.88);
}

.report-line {
  margin: 0 0 8px;
  color: #3f4365;
  line-height: 1.5;
  font-size: 0.93rem;
}

.report-line:last-child {
  margin-bottom: 0;
}

.field-label {
  display: block;
  margin: 8px 0 6px;
  font-size: 0.85rem;
  font-weight: 700;
  color: #50557b;
}

.field-input {
  width: 100%;
  min-height: 48px;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 0 12px;
  font: inherit;
  font-size: 0.95rem;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.94);
}

.field-textarea {
  min-height: 96px;
  padding: 10px 12px;
  resize: none;
}

.field-input:focus {
  outline: 2px solid rgba(56, 182, 255, 0.44);
  border-color: transparent;
}

.stats-bar {
  margin-top: 10px;
  border-radius: 12px;
  padding: 10px 12px;
  background: linear-gradient(120deg, rgba(255, 92, 172, 0.16), rgba(56, 182, 255, 0.18));
  font-size: 0.9rem;
  font-weight: 700;
  color: #3d3f62;
}

.panel-archive-list {
  margin-bottom: 0;
}

.archive-list {
  display: grid;
  gap: 10px;
}

.archive-empty {
  margin: 0;
  text-align: center;
  color: var(--muted);
  font-weight: 700;
  padding: 20px 8px;
}

.entry-card {
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.92);
  border-radius: 16px;
  padding: 10px;
}

.entry-head {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
}

.entry-time {
  font-size: 0.82rem;
  color: #5f658e;
  font-weight: 700;
}

.entry-mood {
  font-size: 0.8rem;
  padding: 2px 8px;
  border-radius: 999px;
  background: linear-gradient(120deg, rgba(255, 92, 172, 0.2), rgba(56, 182, 255, 0.2));
}

.entry-text {
  margin: 0;
  line-height: 1.5;
  font-size: 0.93rem;
  color: #303455;
  white-space: pre-wrap;
}

.entry-actions {
  margin-top: 8px;
  display: flex;
  justify-content: flex-end;
}

.entry-image-thumb {
  margin-top: 10px;
  border-radius: 14px;
  overflow: hidden;
  border: 1px solid rgba(33, 34, 58, 0.08);
  background: rgba(255, 255, 255, 0.6);
}

.entry-image-thumb img {
  width: 100%;
  height: 110px;
  object-fit: cover;
  display: block;
}

.btn-small {
  min-height: 40px;
  padding: 0 12px;
  border-radius: 12px;
  font-size: 0.86rem;
  font-weight: 700;
}

.profile-box {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 12px;
  align-items: start;
}

.avatar {
  width: 62px;
  height: 62px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 1.6rem;
  background: linear-gradient(120deg, #ff79bc, #5ac6ff);
  color: #fff;
  box-shadow: 0 8px 18px rgba(255, 79, 161, 0.26);
}

.profile-fields {
  min-width: 0;
}

.profile-actions {
  display: grid;
  gap: 8px;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.stat-card {
  border-radius: 18px;
  padding: 12px;
  background: linear-gradient(140deg, rgba(255, 255, 255, 0.95), rgba(243, 249, 255, 0.95));
  border: 1px solid rgba(33, 34, 58, 0.08);
}

.stat-label {
  margin: 0 0 4px;
  font-size: 0.82rem;
  color: #6a7091;
  font-weight: 700;
}

.stat-value {
  margin: 0;
  font-size: 1.18rem;
  color: #31365b;
  font-weight: 900;
}

.profile-note-card {
  margin-top: 10px;
  border-radius: 18px;
  padding: 12px;
  background: linear-gradient(120deg, rgba(255, 95, 171, 0.14), rgba(78, 196, 255, 0.14));
  color: #364062;
  line-height: 1.6;
  font-size: 0.92rem;
  min-height: 68px;
}

.view-detail,
.view-subpage {
  position: absolute;
  inset: 0;
  z-index: 5;
  background: linear-gradient(180deg, rgba(255, 244, 250, 0.98), rgba(239, 250, 255, 0.98));
}

.mini-app.is-overlay .bottom-nav {
  display: none;
}

.detail-body {
  border: 1px solid var(--line);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.94);
  padding: 14px;
}

.detail-time {
  margin: 0 0 8px;
  font-size: 0.82rem;
  color: #677091;
  font-weight: 700;
}

.detail-mood-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 10px;
  padding: 6px 10px;
  border-radius: 999px;
  background: linear-gradient(120deg, rgba(255, 92, 172, 0.18), rgba(56, 182, 255, 0.18));
  color: #3b4264;
  font-size: 0.86rem;
  font-weight: 800;
}

.detail-text {
  margin: 0;
  white-space: pre-wrap;
  line-height: 1.7;
  color: #2e3357;
}

.detail-actions {
  margin-top: 12px;
}

.detail-image {
  width: 100%;
  max-height: 260px;
  object-fit: cover;
  border-radius: 16px;
  border: 1px solid var(--line);
  margin: 10px 0;
  display: block;
}

.subpage-topbar {
  padding: calc(18px + env(safe-area-inset-top, 0px)) 16px 10px;
  border-bottom: 1px solid rgba(33, 34, 58, 0.08);
  background: rgba(255, 255, 255, 0.86);
  backdrop-filter: blur(10px);
}

.subpage-content-wrap {
  height: calc(100% - 164px);
  padding: 12px 16px 0;
}

.subpage-body {
  height: 100%;
  overflow-y: auto;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.94);
  padding: 16px;
  color: #394062;
  line-height: 1.78;
  white-space: pre-wrap;
}

.subpage-footer {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  padding: 10px 16px calc(10px + env(safe-area-inset-bottom, 0px));
  border-top: 1px solid rgba(33, 34, 58, 0.08);
  background: rgba(255, 255, 255, 0.9);
  backdrop-filter: blur(10px);
}

.toast {
  position: absolute;
  left: 50%;
  bottom: calc(82px + env(safe-area-inset-bottom, 0px));
  transform: translateX(-50%);
  z-index: 12;
  max-width: calc(100% - 32px);
  padding: 10px 14px;
  border-radius: 999px;
  background: rgba(43, 47, 80, 0.9);
  color: #fff;
  font-size: 0.9rem;
  font-weight: 700;
  text-align: center;
  box-shadow: 0 10px 22px rgba(24, 28, 54, 0.24);
}

.modal-root {
  position: absolute;
  inset: 0;
  z-index: 15;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(22, 26, 44, 0.32);
}

.modal-panel {
  position: absolute;
  left: 16px;
  right: 16px;
  top: 50%;
  transform: translateY(-50%);
  border-radius: 22px;
  background: rgba(255, 255, 255, 0.98);
  padding: 16px;
  box-shadow: 0 20px 40px rgba(23, 26, 53, 0.2);
}

.modal-message {
  margin: 6px 0 12px;
  color: #485072;
  line-height: 1.6;
  white-space: pre-wrap;
}

.modal-avatar-tools {
  margin-bottom: 12px;
}

.modal-file-name {
  margin: 8px 4px 0;
  text-align: left;
}

.avatar-image {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  object-fit: cover;
  display: block;
}

.modal-input {
  margin-bottom: 12px;
}

.modal-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.bottom-nav {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  padding: 8px 12px calc(8px + env(safe-area-inset-bottom, 0px));
  background: rgba(255, 255, 255, 0.9);
  backdrop-filter: blur(10px);
  border-top: 1px solid var(--line);
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.nav-item {
  border: none;
  min-height: 48px;
  border-radius: 14px;
  background: #f7f8ff;
  color: #555b80;
  font: inherit;
  font-size: 0.92rem;
  font-weight: 800;
  cursor: pointer;
}

.nav-item.is-active {
  background: linear-gradient(130deg, #ff5dab, #4ec4ff);
  color: #fff;
}

.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;
}

@media (max-width: 480px) {
  body {
    padding: 0;
  }

  .phone-shell {
    width: 100%;
    height: 100dvh;
    border: none;
    border-radius: 0;
  }

  .phone-camera {
    top: calc(6px + env(safe-area-inset-top, 0px));
  }

  .view {
    padding: 2px 12px calc(88px + env(safe-area-inset-bottom, 0px));
  }

  .profile-box {
    grid-template-columns: 1fr;
  }

  .avatar {
    margin: 0 auto;
  }
}
