:root {
  --cream: #fff4c9;
  --cream-deep: #f8e7b0;
  --ice: #d9f1ff;
  --ice-deep: #c5e8f7;
  --beautify-ink: #243a45;
  --global-font-size: 14px;
  --chat-bubble-font-size: 14px;
  --default-phone-wallpaper: url("/assets/backgrounds/star-ice-default.jpg");
}

/* 奶黄与冰蓝主屏幕 */
.phone-screen:has(.home-view.is-active) {
  background: var(--ice);
}

.home-view {
  --home-background-image: none;
  color: #284554;
  background: var(--ice);
  background-position: center;
  background-repeat: no-repeat;
  background-size: cover;
}

.home-wallpaper {
  background-color: var(--ice);
  background-image:
    linear-gradient(180deg, rgba(255, 255, 255, 0.08), rgba(37, 87, 108, 0.08)),
    var(--default-phone-wallpaper);
  background-position: center;
  background-repeat: no-repeat;
  background-size: cover;
}

.home-wallpaper::after,
.home-wallpaper .wallpaper-line,
.home-wallpaper .wallpaper-tile {
  display: none;
}

.home-view.has-custom-background .home-wallpaper {
  background-color: #d9f1ff;
  background-image:
    linear-gradient(180deg, rgba(255, 249, 225, 0.12), rgba(26, 55, 68, 0.28)),
    var(--home-background-image);
  background-position: center;
  background-repeat: no-repeat;
  background-size: cover;
}

.home-view.has-custom-background .wallpaper-line,
.home-view.has-custom-background .wallpaper-tile,
.home-view.has-custom-background .home-wallpaper::after {
  display: none;
}

.app-grid {
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 14px 6px;
}

.app-icon-button {
  font-size: calc(var(--global-font-size) - 4px);
}

.app-beautify {
  color: #375b68;
  background:
    linear-gradient(145deg, rgba(255, 255, 255, 0.48), transparent 48%),
    linear-gradient(135deg, var(--cream-deep), #cce9f5);
}

.home-top h1 {
  font-size: calc(var(--global-font-size) + 12px);
}

.summary-heading strong {
  font-size: var(--global-font-size);
}

.home-note p {
  font-size: calc(var(--global-font-size) - 5px);
}

.app-header h1 {
  font-size: calc(var(--global-font-size) + 7px);
}

.connection-intro h2,
.result-heading h2,
.local-data-heading h2,
.guide-hero h2 {
  font-size: calc(var(--global-font-size) + 2px);
}

.field-label,
.guide-list strong,
.chat-contact-copy h1,
.chat-empty h2,
.beautify-panel-heading h2 {
  font-size: var(--global-font-size);
}

.message-bubble {
  font-size: var(--chat-bubble-font-size) !important;
}

/* 锁屏 */
.lock-screen {
  --lock-drag-y: 0px;
  position: absolute;
  z-index: 35;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  overflow: hidden;
  padding:
    calc(26px + env(safe-area-inset-top, 0px))
    calc(24px + env(safe-area-inset-right, 0px))
    calc(28px + env(safe-area-inset-bottom, 0px))
    calc(24px + env(safe-area-inset-left, 0px));
  color: #213d49;
  background: var(--ice);
  cursor: grab;
  touch-action: none;
  transform: translateY(var(--lock-drag-y));
  transition:
    transform 220ms ease,
    opacity 220ms ease;
  user-select: none;
}

.lock-screen.is-dragging {
  cursor: grabbing;
  transition: none;
}

.lock-screen.is-unlocking {
  opacity: 0;
  transform: translateY(-105%);
  transition:
    transform 260ms cubic-bezier(0.32, 0.72, 0, 1),
    opacity 220ms ease;
}

.lock-screen.is-unlocked {
  display: none;
}

.lock-screen:focus {
  outline: 0;
}

.lock-screen:focus-visible {
  box-shadow: inset 0 0 0 3px rgba(44, 103, 127, 0.28);
}

.lock-screen-background {
  position: absolute;
  z-index: -2;
  inset: 0;
  background-color: var(--ice);
  background-image:
    linear-gradient(180deg, rgba(255, 255, 255, 0.06), rgba(31, 50, 57, 0.2)),
    var(--default-phone-wallpaper);
  background-position: center;
  background-repeat: no-repeat;
  background-size: cover;
  transform: scale(1.02);
}

.lock-screen-background.has-image {
  background-repeat: no-repeat;
  background-size: cover;
}

.lock-screen::before {
  display: none;
}

.lock-screen::after {
  display: none;
}

.lock-topline {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  color: rgba(34, 64, 76, 0.68);
  font-family: var(--mono);
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.05em;
}

.lock-time-block {
  width: 100%;
  margin-top: clamp(78px, 14vh, 132px);
  text-align: center;
}

.lock-date,
.lock-greeting {
  margin: 0;
  color: #486672;
}

.lock-date {
  font-size: 12px;
  font-weight: 700;
}

.lock-clock {
  margin: 8px 0 4px;
  color: #173846;
  font-family: var(--sans);
  font-size: clamp(66px, 18vw, 82px);
  font-weight: 300;
  letter-spacing: -0.045em;
  line-height: 1;
}

.lock-greeting {
  font-size: 12px;
  letter-spacing: 0.08em;
}

.lock-decoration {
  position: absolute;
  right: 10.24%;
  bottom: 18.05%;
  display: grid;
  gap: min(1.95cqw, 1.95cqh);
  opacity: 0.42;
}

.lock-decoration span {
  display: block;
  width: min(8.29cqw, 8.29cqh);
  aspect-ratio: 34 / 4;
  border-radius: 2px;
  background: #335e6d;
}

.lock-decoration span:last-child {
  width: min(4.88cqw, 4.88cqh);
  margin-left: min(3.41cqw, 3.41cqh);
}

.lock-unlock-hint {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  min-width: 164px;
  min-height: 62px;
  margin-top: auto;
  padding: 8px 18px;
  border: 1px solid rgba(39, 85, 103, 0.16);
  border-radius: 8px;
  color: #31515f;
  background: rgba(255, 255, 255, 0.35);
  font-size: 11px;
  font-weight: 750;
  cursor: pointer;
  backdrop-filter: blur(12px);
}

.lock-unlock-hint svg {
  width: 18px;
  height: 18px;
  animation: lock-hint-rise 1.7s ease-in-out infinite;
}

@keyframes lock-hint-rise {
  0%,
  100% {
    transform: translateY(3px);
  }
  50% {
    transform: translateY(-3px);
  }
}

/* 美化 App */
.beautify-view {
  color: var(--beautify-ink);
  background:
    linear-gradient(152deg, rgba(255, 244, 201, 0.42), transparent 38%),
    linear-gradient(160deg, #fffdf5 0%, #f4fbfe 62%, #e8f7fc 100%);
}

.beautify-header {
  border-bottom-color: rgba(56, 95, 109, 0.13);
  background: rgba(255, 252, 239, 0.9);
}

.beautify-header-mark {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  margin-left: auto;
  border: 1px solid rgba(54, 101, 118, 0.13);
  border-radius: 8px;
  color: #3e6879;
  background: linear-gradient(135deg, var(--cream), var(--ice));
}

.beautify-header-mark svg {
  width: 17px;
  height: 17px;
}

.beautify-scroll {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 14px 17px calc(28px + env(safe-area-inset-bottom, 0px));
  scrollbar-width: thin;
  scrollbar-color: #aec9d2 transparent;
}

.beautify-main-tabs {
  position: sticky;
  z-index: 5;
  top: -14px;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 5px;
  padding: 9px 0;
  background: linear-gradient(180deg, #fffdf5 78%, rgba(255, 253, 245, 0));
}

.beautify-main-tab {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 5px;
  min-width: 0;
  min-height: 58px;
  padding: 7px 4px;
  border: 1px solid rgba(54, 94, 110, 0.12);
  border-radius: 8px;
  color: #5c747e;
  background: rgba(255, 255, 255, 0.48);
  font-size: 10px;
  font-weight: 750;
  cursor: pointer;
}

.beautify-main-tab svg {
  width: 18px;
  height: 18px;
}

.beautify-main-tab.is-active {
  border-color: #7fb7ca;
  color: #234e60;
  background: linear-gradient(145deg, var(--cream), var(--ice));
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.5);
}

.beautify-status {
  margin: 5px 0 17px;
  padding: 9px 11px;
  border-left: 3px solid #7eaeba;
  color: #47616b;
  background: rgba(238, 248, 251, 0.72);
}

.beautify-status strong {
  display: block;
  margin-bottom: 2px;
  font-size: 10px;
}

.beautify-status p {
  margin: 0;
  font-size: 9px;
  line-height: 1.5;
}

.beautify-status[data-state="working"] {
  border-left-color: #b7862c;
  background: rgba(255, 247, 218, 0.82);
}

.beautify-status[data-state="success"] {
  border-left-color: #3d9077;
  background: rgba(229, 246, 238, 0.86);
}

.beautify-status[data-state="warning"],
.beautify-status[data-state="error"] {
  border-left-color: #b54f3d;
  background: rgba(252, 235, 229, 0.88);
}

.beautify-panel-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 2px 1px 14px;
}

.beautify-panel-heading h2 {
  margin: 0;
  line-height: 1.2;
}

.beautify-panel-heading > p {
  width: 48%;
  margin: 2px 0 0;
  color: #71868e;
  font-size: 9px;
  line-height: 1.55;
  text-align: right;
}

.beautify-phone-tabs {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 3px;
  margin-bottom: 17px;
  padding: 3px;
  border: 1px solid rgba(54, 94, 110, 0.13);
  border-radius: 8px;
  background: rgba(238, 247, 250, 0.75);
}

.beautify-phone-tab {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  min-width: 0;
  min-height: 34px;
  padding: 5px 4px;
  border: 0;
  border-radius: 6px;
  color: #637a83;
  background: transparent;
  font-size: 10px;
  font-weight: 750;
  cursor: pointer;
}

.beautify-phone-tab svg {
  width: 14px;
  height: 14px;
}

.beautify-phone-tab.is-active {
  color: #234b5c;
  background: #fffef8;
  box-shadow: 0 2px 8px rgba(41, 78, 91, 0.09);
}

.beautify-section-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin: 0 1px 13px;
}

.beautify-section-heading h3 {
  margin: 0 0 4px;
  font-size: 14px;
}

.beautify-section-heading p {
  margin: 0;
  color: #70858d;
  font-size: 9px;
  line-height: 1.5;
}

.beautify-local-badge {
  display: flex;
  align-items: center;
  flex: 0 0 auto;
  gap: 4px;
  padding: 4px 6px;
  border: 1px solid rgba(52, 127, 101, 0.16);
  border-radius: 6px;
  color: #39725e;
  background: rgba(229, 246, 238, 0.7);
  font-size: 8px;
  font-weight: 750;
}

.beautify-local-badge svg {
  width: 11px;
  height: 11px;
}

.wallpaper-options {
  display: grid;
  gap: 9px;
}

.wallpaper-option {
  display: grid;
  grid-template-columns: 104px minmax(0, 1fr);
  gap: 11px;
  min-width: 0;
  padding: 8px;
  border: 1px solid rgba(55, 94, 109, 0.13);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.6);
}

.wallpaper-preview {
  position: relative;
  min-width: 0;
  min-height: 82px;
  overflow: hidden;
  border: 1px solid rgba(47, 85, 100, 0.12);
  border-radius: 6px;
  background-position: center;
  background-repeat: no-repeat;
  background-size: cover;
}

.wallpaper-preview::before {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, transparent 42%, rgba(20, 46, 57, 0.48));
}

.wallpaper-preview-home {
  background-color: var(--ice);
  background-image:
    linear-gradient(180deg, rgba(255, 255, 255, 0.08), rgba(37, 87, 108, 0.08)),
    var(--default-phone-wallpaper);
  background-position: center;
  background-repeat: no-repeat;
  background-size: cover;
}

.wallpaper-preview-lock {
  background-color: var(--ice);
  background-image:
    linear-gradient(180deg, rgba(255, 255, 255, 0.06), rgba(31, 50, 57, 0.2)),
    var(--default-phone-wallpaper);
  background-position: center;
  background-repeat: no-repeat;
  background-size: cover;
}

.wallpaper-preview-chat {
  background:
    linear-gradient(135deg, rgba(255, 244, 201, 0.8), rgba(217, 241, 255, 0.88)),
    #edf8fc;
  background-position: center;
  background-repeat: no-repeat;
  background-size: 100% 100%;
}

.wallpaper-preview span {
  position: absolute;
  z-index: 1;
  right: 6px;
  bottom: 6px;
  max-width: calc(100% - 12px);
  overflow: hidden;
  color: #f9fffd;
  font-size: 9px;
  font-weight: 800;
  text-overflow: ellipsis;
  text-shadow: 0 1px 4px rgba(18, 41, 51, 0.45);
  white-space: nowrap;
}

.wallpaper-copy {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 8px;
  min-width: 0;
}

.wallpaper-copy h4 {
  margin: 2px 0 3px;
  font-size: 12px;
}

.wallpaper-copy p {
  margin: 0;
  color: #75878e;
  font-size: 8px;
  line-height: 1.45;
}

.wallpaper-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.wallpaper-upload,
.wallpaper-remove {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  min-height: 30px;
  padding: 5px 8px;
  border: 1px solid rgba(53, 100, 118, 0.18);
  border-radius: 6px;
  font-size: 8px;
  font-weight: 800;
  cursor: pointer;
}

.wallpaper-upload {
  color: #275467;
  background: var(--ice);
}

.wallpaper-remove {
  color: #7c5145;
  background: #fff7f3;
}

.wallpaper-remove:disabled {
  opacity: 0.45;
  cursor: default;
}

.wallpaper-upload svg,
.wallpaper-remove svg {
  width: 12px;
  height: 12px;
}

.beautify-tip {
  margin: 11px 2px 0;
  color: #73878f;
  font-size: 8px;
  line-height: 1.55;
}

.font-control {
  padding: 17px 1px;
  border-top: 1px solid rgba(54, 94, 110, 0.13);
}

.font-control:first-of-type {
  padding-top: 2px;
  border-top: 0;
}

.font-control-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

.font-control-heading h4 {
  margin: 0;
  font-size: 13px;
}

.font-control-heading output {
  min-width: 46px;
  padding: 5px 7px;
  border: 1px solid rgba(47, 88, 104, 0.13);
  border-radius: 6px;
  color: #264e5d;
  background: #fffef8;
  font-family: var(--mono);
  font-size: 10px;
  font-weight: 800;
  text-align: center;
}

.font-preview {
  min-height: 58px;
  display: flex;
  align-items: center;
  margin-bottom: 10px;
  padding: 12px;
  border: 1px solid rgba(54, 94, 110, 0.12);
  border-radius: 8px;
  color: #2d4651;
  background:
    linear-gradient(145deg, rgba(255, 255, 255, 0.58), transparent),
    rgba(239, 249, 252, 0.8);
  line-height: 1.55;
}

.font-preview-chat {
  display: block;
}

.font-chat-sample {
  display: flex;
  align-items: flex-start;
  gap: 7px;
}

.font-chat-avatar {
  display: grid;
  place-items: center;
  flex: 0 0 27px;
  width: 27px;
  height: 27px;
  border-radius: 50%;
  color: #f9fffd;
  background: #477565;
  font-size: 10px;
  font-weight: 800;
}

.font-chat-sample p {
  max-width: calc(100% - 34px);
  margin: 0;
  padding: 8px 10px;
  border: 1px solid rgba(54, 94, 110, 0.12);
  border-radius: 4px 12px 12px;
  color: #2a3633;
  background: #fffef9;
  line-height: 1.6;
  overflow-wrap: anywhere;
}

.font-range {
  width: 100%;
  height: 28px;
  margin: 0;
  padding: 0;
  background: transparent;
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
}

.font-range::-webkit-slider-runnable-track {
  height: 3px;
  border-radius: 2px;
  background: #26353b;
}

.font-range::-webkit-slider-thumb {
  width: 18px;
  height: 18px;
  margin-top: -7.5px;
  border: 2px solid #fff;
  border-radius: 50%;
  background: #101211;
  box-shadow: 0 1px 5px rgba(18, 31, 36, 0.38);
  appearance: none;
  -webkit-appearance: none;
}

.font-range::-moz-range-track {
  height: 3px;
  border: 0;
  border-radius: 2px;
  background: #26353b;
}

.font-range::-moz-range-thumb {
  width: 16px;
  height: 16px;
  border: 2px solid #fff;
  border-radius: 50%;
  background: #101211;
  box-shadow: 0 1px 5px rgba(18, 31, 36, 0.38);
}

.font-range:focus-visible {
  outline: 3px solid rgba(63, 124, 145, 0.22);
  outline-offset: 3px;
}

.font-range-scale {
  display: flex;
  justify-content: space-between;
  margin-top: -1px;
  color: #87989e;
  font-family: var(--mono);
  font-size: 8px;
}

.beautify-coming-soon {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 340px;
  padding: 36px 24px;
  text-align: center;
}

.beautify-coming-icon {
  display: grid;
  place-items: center;
  width: 62px;
  height: 62px;
  margin-bottom: 16px;
  border: 1px solid rgba(54, 94, 110, 0.13);
  border-radius: 8px;
  color: #3f6877;
  background: linear-gradient(135deg, var(--cream), var(--ice));
}

.beautify-coming-icon svg {
  width: 25px;
  height: 25px;
}

.beautify-coming-soon h2,
.beautify-coming-soon h3 {
  margin: 0 0 8px;
  font-size: 18px;
}

.beautify-coming-soon > p:last-child {
  max-width: 260px;
  margin: 0;
  color: #71858d;
  font-size: 10px;
  line-height: 1.65;
}

/* 自定义聊天背景 */
.chat-view.has-custom-background {
  background-color: var(--ice);
  background-image:
    linear-gradient(180deg, rgba(255, 250, 231, 0.3), rgba(28, 57, 69, 0.28)),
    var(--chat-background-image);
  background-position: center;
  background-repeat: no-repeat;
  background-size: cover;
}

.chat-view.has-custom-background .chat-header {
  background: rgba(255, 253, 247, 0.9);
}

.chat-view.has-custom-background .chat-scroll {
  background: rgba(235, 249, 255, 0.34);
}

.chat-view.has-custom-background .chat-composer {
  background: rgba(255, 253, 247, 0.93);
}

@media (max-width: 600px) {
  .home-view {
    padding-right: calc(16px + env(safe-area-inset-right, 0px));
    padding-left: calc(16px + env(safe-area-inset-left, 0px));
  }

  .app-grid {
    column-gap: 5px;
  }

  .beautify-scroll {
    padding-right: calc(16px + env(safe-area-inset-right, 0px));
    padding-left: calc(16px + env(safe-area-inset-left, 0px));
  }

  .wallpaper-copy h4 {
    font-size: 13px;
  }

  .wallpaper-copy p,
  .beautify-tip {
    font-size: 9px;
  }

  .wallpaper-upload,
  .wallpaper-remove {
    min-height: 34px;
    font-size: 9px;
  }

  .font-range::-webkit-slider-thumb {
    width: 20px;
    height: 20px;
    margin-top: -8.5px;
  }

  .font-range::-moz-range-thumb {
    width: 18px;
    height: 18px;
  }
}

@media (max-width: 360px) {
  .app-icon {
    width: 47px;
    height: 47px;
  }

  .app-icon-button {
    gap: 6px;
    font-size: 9px;
  }

  .beautify-main-tab {
    min-height: 55px;
    font-size: 9px;
  }

  .wallpaper-option {
    grid-template-columns: 1fr;
  }

  .wallpaper-preview {
    min-height: 92px;
  }

  .wallpaper-copy {
    gap: 9px;
  }

  .wallpaper-copy p {
    font-size: 8px;
  }

  .lock-screen {
    padding-right: 18px;
    padding-left: 18px;
  }

  .lock-clock {
    font-size: 64px;
  }
}

@media (max-height: 500px) and (orientation: landscape) {
  .lock-screen {
    padding-top: calc(18px + env(safe-area-inset-top, 0px));
    padding-bottom: calc(16px + env(safe-area-inset-bottom, 0px));
  }

  .lock-time-block {
    margin-top: 30px;
  }

  .lock-clock {
    margin-top: 3px;
    font-size: 60px;
  }

  .lock-decoration {
    right: 72px;
    bottom: 72px;
  }

  .lock-unlock-hint {
    min-height: 48px;
    flex-direction: row;
    gap: 8px;
  }

  .beautify-scroll {
    padding-top: 8px;
  }

  .beautify-main-tabs {
    top: -8px;
  }

  .beautify-main-tab {
    min-height: 44px;
    flex-direction: row;
  }

  .wallpaper-option {
    grid-template-columns: 108px minmax(0, 1fr);
  }
}
