:root {
  color-scheme: dark;
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "PingFang SC", "Microsoft YaHei", sans-serif;
  background: #111821;
  color: #f7f3e9;
}

* { box-sizing: border-box; }
body { margin: 0; }
button { font: inherit; cursor: pointer; }
[hidden] { display: none !important; }

.stage {
  min-height: 100svh;
  display: grid;
  place-content: center;
  padding: 16px;
  background:
    radial-gradient(circle at 20% 18%, #46596a55, transparent 28%),
    radial-gradient(circle at 80% 88%, #7a5a4d40, transparent 30%),
    #111821;
}

.phone {
  position: relative;
  width: min(390px, calc(100vw - 32px));
  height: min(810px, calc(100svh - 32px));
  min-height: 560px;
  padding: 8px;
  border: 2px solid #3b414b;
  border-radius: 54px;
  background: #080b10;
  box-shadow: 0 25px 80px #0009, inset 0 0 0 2px #171b20;
}

.side-button {
  position: absolute;
  top: 24%;
  right: -5px;
  width: 4px;
  height: 67px;
  padding: 0;
  border: 0;
  border-radius: 0 3px 3px 0;
  background: #66707b;
}
.side-button:focus-visible { outline: 2px solid #fff; outline-offset: 4px; }

.screen {
  position: relative;
  isolation: isolate;
  height: 100%;
  overflow: hidden;
  border-radius: 45px;
  background: #ed679b url("./wallpaper.png") center / cover no-repeat;
}

.island {
  position: absolute;
  z-index: 5;
  top: 11px;
  left: 50%;
  width: 105px;
  height: 30px;
  transform: translateX(-50%);
  border-radius: 30px;
  background: #090c11;
}

.status-bar {
  position: absolute;
  z-index: 4;
  top: 16px;
  left: 31px;
  right: 26px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  min-height: 22px;
  font-size: 15px;
  font-weight: 600;
  letter-spacing: -.025em;
  text-shadow: 0 1px 6px #6f214a;
}

.status-icons { display: inline-flex; align-items: center; gap: 5px; }
.status-icons svg { display: block; fill: currentColor; }
.cellular-icon { width: 19px; height: 14px; }
.wifi-icon { width: 18px; height: 15px; }
.battery-icon { width: 28px; height: 14px; margin-left: 1px; }
.status-carrier { font-size: 13px; letter-spacing: 0; }
.lock-screen, .pin-screen, .home-screen { height: 100%; }
.lock-screen {
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  text-align: center;
  touch-action: none;
  user-select: none;
  transform: translateY(calc(-1 * var(--swipe-offset, 0px)));
  transition: transform .25s ease-out;
}
.lock-screen::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: linear-gradient(#24132336 0%, transparent 37%, transparent 67%, #21111d70 100%);
}
.lock-screen.dragging { transition: none; }
.lock-screen:focus-visible { outline: 2px solid #fff; outline-offset: -12px; }
.lock-heading, .lock-bottom { position: relative; }
.lock-heading { padding-top: clamp(57px, 8%, 76px); text-shadow: 0 2px 12px #74284fbb; }
.lock-glyph { display: block; width: 21px; height: 27px; margin: 0 auto 15px; filter: drop-shadow(0 1px 5px #0005); }
.lock-heading p { margin: 0; font-size: 20px; font-weight: 500; letter-spacing: .015em; }
.lock-heading h1 { margin: -2px 0; font-size: clamp(76px, 22vw, 88px); font-weight: 200; line-height: 1.12; letter-spacing: -.055em; font-variant-numeric: tabular-nums; }
.lock-bottom { padding: 0 38px 47px; }
.swipe-hint {
  display: inline-block;
  margin-bottom: 25px;
  font-size: 14px;
  font-weight: 500;
  letter-spacing: .02em;
  text-shadow: 0 1px 8px #0008;
  animation: float-up 2.4s ease-in-out infinite;
}
.lock-shortcuts { display: flex; justify-content: space-between; align-items: center; }
.lock-shortcut {
  display: grid;
  place-items: center;
  width: 50px;
  height: 50px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: #22232a80;
  color: #fff;
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
}
.lock-shortcut svg { width: 22px; height: 26px; }

.pin-screen {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: clamp(78px, 12svh, 108px) 28px 43px;
  background: #31203970;
  backdrop-filter: blur(22px) saturate(1.3);
  -webkit-backdrop-filter: blur(22px) saturate(1.3);
}
.pin-heading { flex: 1 1 auto; min-height: 110px; text-align: center; }
.pin-heading h2 { margin: 0 0 19px; font-size: 20px; font-weight: 500; }
.pin-dots { display: flex; justify-content: center; gap: 23px; }
.pin-dots span { width: 12px; height: 12px; border: 1.5px solid #fff; border-radius: 50%; }
.pin-dots span.filled { background: #fff; }
.pin-feedback { min-height: 18px; margin: 13px 0 0; color: #ffc3a8; font-size: 13px; }
.pin-heading.shake { animation: shake .32s ease-in-out; }

.keypad {
  width: min(274px, 100%);
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  justify-items: center;
  gap: clamp(10px, 2svh, 20px) 10px;
}
.keypad button {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: clamp(57px, 9svh, 76px);
  aspect-ratio: 1;
  border: 0;
  border-radius: 50%;
  background: #ffffff35;
  color: #fff;
  font-size: 32px;
  font-weight: 400;
  line-height: 1;
  transition: background .15s, transform .15s;
}
.keypad small { min-height: 9px; margin-top: 4px; font-size: 9px; font-weight: 600; line-height: 1; letter-spacing: .13em; }
.keypad button:active { background: #ffffff75; transform: scale(.94); }
.pin-actions {
  display: flex;
  justify-content: space-between;
  width: min(296px, 100%);
  margin-top: clamp(23px, 5svh, 43px);
}
.pin-actions button {
  min-width: 64px;
  padding: 6px 0;
  border: 0;
  background: transparent;
  color: #fff;
  font-size: 14px;
}
.pin-actions button:focus-visible { outline: 2px solid #fff; border-radius: 4px; }

.home-screen { display: flex; flex-direction: column; padding: 84px 22px 27px; }
.widget-row {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 22px;
}
.home-widget {
  position: relative;
  width: 100%;
  aspect-ratio: 1;
  overflow: hidden;
  border: 0;
  border-radius: 24px;
  box-shadow: 0 7px 20px #682a4a35;
  transition: transform .15s ease;
}
.home-widget:active { transform: scale(.97); }
.home-widget:focus-visible { outline: 2px solid #fff; outline-offset: 3px; }
.weather-widget {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  padding: 14px 14px 12px;
  background: linear-gradient(158deg, #4b9ee9 0%, #66b4f0 52%, #9ad0f8 100%);
  color: #fff;
  text-align: left;
  text-shadow: 0 1px 4px #27669666;
}
.widget-city { font-size: 16px; font-weight: 600; }
.widget-temperature { margin-top: 1px; font-size: 47px; font-weight: 300; line-height: 1; letter-spacing: -.06em; }
.widget-weather-icon { position: absolute; top: 38%; right: 9%; width: 46px; height: 46px; filter: drop-shadow(0 2px 3px #2573a74d); }
.widget-weather-icon svg { width: 100%; height: 100%; }
.widget-condition { margin-top: auto; font-size: 13px; font-weight: 600; }
.widget-range { margin-top: 2px; font-size: 11px; white-space: nowrap; }
.photo-widget { background: linear-gradient(145deg, #f4e8ed, #d9c7d4); }
.app-grid, .dock { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); justify-items: center; }
.app-grid { row-gap: 22px; column-gap: 8px; }
.app-tile {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  min-width: 0;
  padding: 0;
  border: 0;
  background: transparent;
  color: #fff;
  font-size: 11px;
  white-space: nowrap;
  text-shadow: 0 1px 5px #74284f;
}
.app-tile:focus-visible { outline: 2px solid #fff; outline-offset: 4px; border-radius: 14px; }
.app-tile:active .app-icon { transform: scale(.9); }
.app-icon {
  position: relative;
  display: block;
  width: 58px;
  height: 58px;
  overflow: hidden;
  border-radius: 15px;
  box-shadow: 0 4px 12px #55254342;
  transition: transform .15s ease;
}
.app-icon img { display: block; width: 100%; height: 100%; object-fit: cover; }
.icon-calendar::before {
  content: "";
  position: absolute;
  inset: 8%;
  border-radius: 10px;
  background: #fff;
}
.icon-calendar small, .icon-calendar strong {
  position: absolute;
  left: 0;
  right: 0;
  text-align: center;
  text-shadow: none;
}
.icon-calendar small { top: 11%; color: #ed403d; font-size: 11px; font-weight: 700; }
.icon-calendar strong { top: 29%; color: #1c1c1e; font-size: 35px; font-weight: 400; line-height: 1; }
.dock {
  margin-top: auto;
  padding: 13px 4px 11px;
  border-radius: 26px;
  background: #f4c6d085;
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
}
.dock .app-tile > span:last-child {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
}
.app-screen { height: 100%; background: #f6f6f8; color: #1b1b1f; }
.app-header { position: relative; display: flex; align-items: center; justify-content: center; height: 108px; padding-top: 48px; }
.app-header h2 { margin: 0; font-size: 17px; font-weight: 600; }
.app-back { position: absolute; left: 18px; bottom: 20px; padding: 0; border: 0; background: none; color: #087bf5; font-size: 15px; }
.screen.app-open .status-bar { color: #1b1b1f; text-shadow: none; }
.home-indicator {
  position: absolute;
  z-index: 5;
  bottom: 9px;
  left: 50%;
  width: 115px;
  height: 4px;
  padding: 0;
  transform: translateX(-50%);
  border: 0;
  border-radius: 5px;
  background: #fff;
}
.screen.app-open .home-indicator { background: #1b1b1f; }

@keyframes float-up {
  50% { transform: translateY(-5px); opacity: .7; }
}

@keyframes shake {
  25% { transform: translateX(-9px); }
  50% { transform: translateX(9px); }
  75% { transform: translateX(-5px); }
}

@media (max-height: 670px) {
  .stage { padding: 0; }
  .phone { height: 100svh; border-radius: 42px; }
  .screen { border-radius: 34px; }
  .pin-screen { padding-top: 65px; padding-bottom: 25px; }
  .pin-heading { min-height: 87px; }
  .keypad { gap: 9px 10px; }
  .keypad button { width: clamp(54px, 9svh, 62px); }
  .pin-actions { margin-top: 18px; }
  .home-screen { padding-top: 75px; }
}

@media (max-width: 600px), (max-height: 500px) and (pointer: coarse) {
  html, body { width: 100%; height: 100%; overflow: hidden; }
  .stage {
    width: 100%;
    min-height: 100vh;
    min-height: 100dvh;
    height: 100vh;
    height: 100dvh;
    display: block;
    padding: 0;
    overflow: hidden;
    overscroll-behavior: none;
  }
  .phone {
    width: 100%;
    height: 100%;
    min-height: 0;
    padding: 0;
    border: 0;
    border-radius: 0;
    box-shadow: none;
  }
  .screen { border-radius: 0; }
  .side-button {
    z-index: 6;
    top: 22%;
    right: 0;
    width: 24px;
    height: 68px;
    background: transparent;
  }
  .side-button::after {
    content: "";
    position: absolute;
    top: 0;
    right: 0;
    width: 3px;
    height: 100%;
    border-radius: 3px 0 0 3px;
    background: #5c2b4b99;
  }
  .status-bar { top: max(16px, env(safe-area-inset-top)); }
  .island { top: max(11px, env(safe-area-inset-top)); }
  .lock-heading { padding-top: max(65px, calc(env(safe-area-inset-top) + 45px)); }
  .lock-bottom { padding-bottom: max(47px, calc(env(safe-area-inset-bottom) + 36px)); }
  .pin-screen {
    padding-top: max(70px, calc(env(safe-area-inset-top) + 48px));
    padding-bottom: max(31px, calc(env(safe-area-inset-bottom) + 22px));
  }
  .home-screen { padding-top: max(84px, calc(env(safe-area-inset-top) + 65px)); }
  .app-header { height: max(108px, calc(env(safe-area-inset-top) + 82px)); padding-top: max(48px, env(safe-area-inset-top)); }
  .home-indicator { bottom: max(9px, calc(env(safe-area-inset-bottom) + 5px)); }
}

@media (display-mode: standalone) and (max-width: 600px) {
  .island, .status-bar, .home-indicator { display: none; }
}

@media (max-width: 600px) and (max-height: 670px) {
  .pin-screen { padding-top: max(61px, calc(env(safe-area-inset-top) + 38px)); padding-bottom: max(22px, calc(env(safe-area-inset-bottom) + 14px)); }
  .pin-heading { min-height: 78px; }
  .pin-heading h2 { margin-bottom: 13px; }
  .pin-actions { margin-top: 12px; }
  .lock-heading { padding-top: max(58px, calc(env(safe-area-inset-top) + 37px)); }
  .lock-heading h1 { font-size: clamp(68px, 21vw, 84px); }
  .lock-bottom { padding-bottom: max(34px, calc(env(safe-area-inset-bottom) + 24px)); }
}

@media (max-width: 600px) and (max-height: 670px) {
  .home-screen { padding-top: max(58px, calc(env(safe-area-inset-top) + 48px)); }
  .widget-row { gap: 10px; margin-bottom: 17px; }
  .home-widget { border-radius: 20px; }
  .weather-widget { padding: 10px 11px; }
  .widget-city { font-size: 13px; }
  .widget-temperature { font-size: 38px; }
  .widget-weather-icon { width: 35px; height: 35px; }
  .widget-condition { font-size: 11px; }
  .widget-range { font-size: 9px; }
  .app-icon { width: 48px; height: 48px; font-size: 24px; }
  .app-tile { gap: 6px; font-size: 10px; }
  .icon-calendar small { font-size: 9px; }
  .icon-calendar strong { font-size: 29px; }
  .dock { padding: 9px 4px; }
}

@media (prefers-reduced-motion: reduce) {
  .swipe-hint { animation: none; }
  .lock-screen { transition: none; }
}
