* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { background: #15131a; font-family: var(--md-font); color: var(--md-on-surface); overflow: hidden; -webkit-user-select: none; user-select: none;
  touch-action: manipulation; }
button { font-family: inherit; cursor: pointer; }

#stage { position: fixed; inset: 0; display: flex; align-items: center; justify-content: center;
  background: radial-gradient(1200px 700px at 30% 20%, #2b2340, #120f18 70%); }
#phone { width: 384px; height: 812px; border-radius: 52px; padding: 12px; background: #0c0b10; flex: none;
  box-shadow: 0 0 0 2px #2c2a33, 0 30px 80px rgba(0,0,0,.6); transform-origin: center; position: relative; }
#phone::before { /* side buttons */ content: ''; position: absolute; right: -4px; top: 180px; width: 4px; height: 90px; border-radius: 0 3px 3px 0; background: #2c2a33; }
#screen { position: relative; width: 360px; height: 788px; border-radius: 40px; overflow: hidden; background: #000; isolation: isolate; }
#screen.inverted { filter: invert(1) hue-rotate(180deg); }
#screen.saver { filter: grayscale(1) contrast(.85); }
#screen.inverted.saver { filter: invert(1) hue-rotate(180deg) grayscale(1); }

/* phone mode: real device, fill viewport */
body.native #stage { background: #000; }
body.native #phone { width: 100vw !important; height: 100dvh !important; border-radius: 0 !important; padding: 0 !important; box-shadow: none; transform: none !important; }
body.native #phone::before, body.native .bz, body.native #foldBtn, body.native #cutout { display: none; }
body.native #screen { width: 100% !important; height: 100% !important; border-radius: 0 !important; }

/* wallpaper */
#wallpaper { position: absolute; inset: 0; z-index: 0;
  background: radial-gradient(120% 60% at 20% 10%, #c9b6ff 0%, transparent 60%), radial-gradient(90% 60% at 90% 80%, #ffb4c8 0%, transparent 60%),
  linear-gradient(160deg, #7a5fcf, #3d2b7a 60%, #241a4a); }
#wallpaper video { width: 100%; height: 100%; object-fit: cover; transform: scaleX(-1); }

/* status bar */
#statusbar { position: absolute; top: 0; left: 0; right: 0; height: 36px; z-index: 50; display: flex; align-items: center; padding: 6px 24px 0;
  font: 500 14px var(--md-font); color: #fff; cursor: pointer; }
#statusbar.dark { color: var(--md-on-surface); }
#statusbar .sp { flex: 1; }
#statusbar .ic { display: flex; gap: 4px; align-items: center; }
#statusbar .ic .ms { font-size: 17px; }
#statusbar .camera { position: absolute; left: 50%; top: 10px; width: 14px; height: 14px; margin-left: -7px; border-radius: 50%; background: #000; box-shadow: 0 0 0 2px #1b1a20; }
#statusbar .nicons { display: flex; gap: 4px; margin-left: 8px; }
#statusbar .nicons .ms { font-size: 16px; }

/* home */
#home { position: absolute; inset: 0; z-index: 1; padding: 52px 16px 44px; display: flex; flex-direction: column; color: #fff; transition: transform .3s var(--md-ease), opacity .3s; }
#home.behind { transform: scale(.94); opacity: .4; }
.glance { padding: 24px 8px 0; min-height: 132px; }
.glance .date { font-size: 22px; line-height: 28px; }
.glance .event { margin-top: 6px; font-size: 14px; display: flex; gap: 6px; align-items: center; opacity: .95; }
.glance .event .ms { font-size: 18px; }
.grid { display: grid; grid-template-columns: repeat(var(--cols, 4), 1fr); row-gap: 18px; column-gap: 8px; align-content: start; }
.app-ic { display: flex; flex-direction: column; align-items: center; gap: 6px; border: 0; background: none; padding: 0; color: #fff; position: relative; }
.app-ic .ic { width: 56px; height: 56px; border-radius: 50%; display: flex; align-items: center; justify-content: center; position: relative;
  box-shadow: 0 1px 3px rgba(0,0,0,.25); transition: transform .12s; }
.app-ic:active .ic { transform: scale(.9); }
.app-ic .ic .ms { font-size: 28px; }
.app-ic .nm { font-size: 12px; line-height: 14px; max-width: 76px; text-align: center; text-shadow: 0 1px 2px rgba(0,0,0,.4);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.app-ic .badge { top: -2px; right: -2px; box-shadow: 0 0 0 2px rgba(0,0,0,.08); }
.app-ic.locked .ic { filter: grayscale(.8) brightness(.8); }
.app-ic.locked .ic::after { content: 'lock'; font-family: 'Material Symbols Rounded'; position: absolute; right: -4px; bottom: -4px; font-size: 16px;
  width: 22px; height: 22px; border-radius: 50%; background: #fff; color: #333; display: flex; align-items: center; justify-content: center; }
.app-ic.new .ic { animation: pop .6s var(--md-ease-emph); }
@keyframes pop { 0% { transform: scale(0); } 70% { transform: scale(1.15); } 100% { transform: scale(1); } }
.home-spacer { flex: 1; }
.dock { display: grid; grid-template-columns: repeat(4, 1fr); width: 100%; max-width: 380px; margin: 0 auto; padding: 0 0 12px; }
.home-search { margin: 0 4px 16px; height: 52px; border-radius: 26px; background: rgba(255,255,255,.85); color: #444; display: flex; align-items: center; gap: 12px; padding: 0 18px; border: 0;
  font: 16px var(--md-font); }
.home-search .g { width: 24px; height: 24px; border-radius: 50%; background: conic-gradient(#7a5fcf 0 25%, #ff7aa2 0 50%, #ffc857 0 75%, #4cc9a6 0); }

/* app layer */
#appLayer { position: absolute; inset: 0; z-index: 10; pointer-events: none; }
.app { position: absolute; inset: 0; background: var(--md-surface); color: var(--md-on-surface); display: flex; flex-direction: column; padding-top: 36px; padding-bottom: 48px;
  pointer-events: auto; animation: appIn .32s var(--md-ease-emph); overflow: hidden; }
.app.closing { animation: appOut .2s var(--md-ease) forwards; }
@keyframes appIn { from { transform: scale(.85); opacity: 0; border-radius: 40px; } }
@keyframes appOut { to { transform: scale(.9); opacity: 0; } }
.app .scroll { flex: 1; overflow-y: auto; overflow-x: hidden; scrollbar-width: none; }
.app .scroll::-webkit-scrollbar { display: none; }

/* system nav (3-button) */
#navbar { position: absolute; left: 0; right: 0; bottom: 0; height: 48px; z-index: 60; display: flex; justify-content: space-around; align-items: center; color: #fff; }
#navbar.dark { color: var(--md-on-surface); background: var(--md-surface); }
#navbar button { border: 0; background: none; color: inherit; width: 64px; height: 40px; border-radius: 20px; display: flex; align-items: center; justify-content: center; }
#navbar button .ms { font-size: 22px; }

/* heads-up notification */
#headsup { position: absolute; top: 40px; left: 8px; right: 8px; z-index: 80; pointer-events: none; }
.hu { pointer-events: auto; background: var(--md-surface-container-high); color: var(--md-on-surface); border-radius: 24px; padding: 12px 16px; display: flex; gap: 12px;
  box-shadow: 0 6px 20px rgba(0,0,0,.25); animation: huIn .4s var(--md-ease-emph); cursor: pointer; margin-bottom: 8px; }
.hu.out { animation: huOut .25s var(--md-ease) forwards; }
@keyframes huIn { from { transform: translateY(-120%); opacity: 0; } }
@keyframes huOut { to { transform: translateY(-120%); opacity: 0; } }
.hu .av, .nt .av { width: 36px; height: 36px; border-radius: 50%; flex: none; display: flex; align-items: center; justify-content: center; color: #fff; }
.hu .av .ms, .nt .av .ms { font-size: 20px; }
.hu .b, .nt .b { flex: 1; min-width: 0; }
.hu .app-name, .nt .app-name { font-size: 12px; color: var(--md-on-surface-variant); }
.hu .t, .nt .t { font-weight: 500; font-size: 14px; line-height: 20px; }
.hu .m, .nt .m { font-size: 14px; line-height: 20px; color: var(--md-on-surface-variant); }

/* notification shade */
#shade { position: absolute; inset: 0; z-index: 90; background: rgba(20,18,26,.75); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  transform: translateY(-100%); transition: transform .35s var(--md-ease); display: flex; flex-direction: column; padding: 44px 12px 60px; color: #fff; }
#shade.open { transform: none; }
#shade .tiles { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; margin-bottom: 16px; }
#shade .tile { height: 64px; border-radius: 32px; background: rgba(255,255,255,.12); display: flex; align-items: center; gap: 12px; padding: 0 18px; border: 0; color: #fff; font: 500 14px var(--md-font); text-align: left; }
#shade .tile.on { background: var(--md-primary-container); color: var(--md-on-primary-container); }
#shade .list { flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 4px; scrollbar-width: none; }
.nt { background: var(--md-surface-container-high); color: var(--md-on-surface); border-radius: 20px; padding: 12px 16px; display: flex; gap: 12px; cursor: pointer; }
.nt:first-child { border-radius: 24px 24px 6px 6px; } .nt:last-child { border-radius: 6px 6px 24px 24px; } .nt:only-child { border-radius: 24px; }
#shade .empty { text-align: center; opacity: .6; padding: 40px 0; }
#shade .shade-handle { width: 40px; height: 4px; border-radius: 2px; background: currentColor; opacity: .4; margin: 14px auto 0; flex: none; }
#shade { touch-action: none; }
#shade .list { touch-action: pan-y; }
#statusbar { touch-action: none; }

/* dialogs */
#overlay { position: absolute; inset: 0; z-index: 100; pointer-events: none; }
.scrim { position: absolute; inset: 0; background: var(--md-scrim); pointer-events: auto; display: flex; align-items: center; justify-content: center; padding: 24px;
  animation: fade .2s; }
@keyframes fade { from { opacity: 0; } }
.dialog { background: var(--md-surface-container-high); border-radius: 28px; padding: 24px; width: 100%; max-width: 312px; max-height: 88%; display: flex; flex-direction: column;
  animation: dlgIn .3s var(--md-ease-emph); }
@keyframes dlgIn { from { transform: scale(.9); opacity: 0; } }
.dialog .icon { text-align: center; color: var(--md-secondary); margin-bottom: 16px; }
.dialog .icon .ms { font-size: 24px; }
.dialog h2 { margin: 0 0 16px; font-size: 24px; line-height: 32px; font-weight: 400; }
.dialog .icon + h2 { text-align: center; }
.dialog .body { font-size: 14px; line-height: 20px; color: var(--md-on-surface-variant); overflow-y: auto; }
.dialog .actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 24px; flex-wrap: wrap; }
.sheet-scrim { align-items: flex-end; padding: 0; }
.sheet { background: var(--md-surface-container-low); border-radius: 28px 28px 0 0; width: 100%; max-height: 92%; display: flex; flex-direction: column; padding-bottom: 48px;
  animation: sheetIn .35s var(--md-ease-emph); }
@keyframes sheetIn { from { transform: translateY(100%); } }
.sheet > div { scrollbar-width: none; min-height: 0; }
.sheet > div::-webkit-scrollbar { display: none; }
.sheet .handle { width: 32px; height: 4px; border-radius: 2px; background: var(--md-outline); opacity: .4; margin: 16px auto 8px; flex: none; }

/* toasts / snackbar / achievements */
#toasts { position: absolute; left: 12px; right: 12px; bottom: 60px; z-index: 110; display: flex; flex-direction: column; gap: 8px; pointer-events: none; align-items: stretch; }
.snack { background: var(--md-inverse-surface); color: var(--md-inverse-on-surface); border-radius: 4px; padding: 14px 16px; font-size: 14px; line-height: 20px;
  box-shadow: 0 4px 12px rgba(0,0,0,.3); animation: snackIn .3s var(--md-ease-emph); }
.snack.out { animation: snackOut .2s forwards; }
@keyframes snackIn { from { transform: translateY(20px); opacity: 0; } }
@keyframes snackOut { to { opacity: 0; } }
.ach { pointer-events: auto; cursor: pointer; background: linear-gradient(135deg, #2d1f5e, #4a2f8f); color: #fff; border-radius: 20px; padding: 12px 14px; display: flex; gap: 12px; align-items: center;
  box-shadow: 0 8px 24px rgba(40,20,90,.5); animation: snackIn .4s var(--md-ease-emph); }
.ach .medal { width: 44px; height: 44px; border-radius: 50%; background: linear-gradient(135deg, #ffd66b, #ff9f43); color: #5a3300; display: flex; align-items: center; justify-content: center; flex: none; }
.ach .k { font-size: 11px; letter-spacing: 1px; text-transform: uppercase; opacity: .7; }
.ach .t { font-weight: 500; font-size: 15px; }
.ach .d { font-size: 12px; opacity: .8; }
.money-pop { position: absolute; top: 40px; right: 20px; z-index: 120; font: 700 18px var(--md-font); color: #2e7d32; background: #fff; border-radius: 16px; padding: 4px 12px;
  animation: moneyPop 1.6s var(--md-ease) forwards; pointer-events: none; }
.money-pop.neg { color: var(--md-error); }
@keyframes moneyPop { 0% { transform: translateY(10px); opacity: 0; } 15% { transform: none; opacity: 1; } 80% { opacity: 1; } 100% { transform: translateY(-20px); opacity: 0; } }

/* lock screen */
#lock { position: absolute; inset: 0; z-index: 70; color: #fff; display: flex; flex-direction: column; align-items: center; padding-top: 110px;
  background: rgba(16,10,36,.55); backdrop-filter: blur(22px); -webkit-backdrop-filter: blur(22px); transition: transform .45s var(--md-ease), opacity .45s; touch-action: none; }
#lock.gone { transform: translateY(-100%); opacity: 0; pointer-events: none; }
#lock .clock { font-size: 92px; line-height: 1; font-weight: 300; letter-spacing: -2px; }
#lock .d { margin-top: 12px; font-size: 16px; opacity: .9; }
#lock .hint { margin-top: auto; margin-bottom: 80px; display: flex; flex-direction: column; align-items: center; gap: 6px; font-size: 13px; opacity: .85; }
#lock .hint .ms { animation: bob 1.4s infinite; }
@keyframes bob { 50% { transform: translateY(-8px); } }
#lock .title { margin-top: 40px; font: 700 13px/1 var(--md-font); letter-spacing: 6px; opacity: .55; }

/* day summary */
.summary { position: absolute; inset: 0; z-index: 130; background: linear-gradient(180deg, #1b1430, #3d2b7a); color: #fff; display: flex; flex-direction: column;
  padding: 72px 24px 56px; animation: fade .6s; overflow-y: auto; }
.summary h1 { font-weight: 400; font-size: 36px; line-height: 44px; margin: 0 0 8px; }
.summary .stat { display: flex; justify-content: space-between; padding: 12px 0; border-bottom: 1px solid rgba(255,255,255,.12); font-size: 15px; }
.summary .achs { margin-top: 20px; display: flex; flex-direction: column; gap: 8px; }
.summary .achs > div { display: flex; gap: 10px; align-items: center; font-size: 14px; }
.summary .achs .ms { color: #ffd66b; }
.summary .achs .locked { opacity: .35; }
.summary .next { margin-top: 24px; padding: 16px; border-radius: 16px; background: rgba(255,255,255,.08); font-size: 14px; line-height: 20px; }
