:root {
  color-scheme: light;
  --paper: #f6f6f3;
  --ink: #101010;
  --soft-ink: #4b4b4b;
  --line: #d8d8d2;
  --glass: rgba(247, 247, 244, 0.82);
  --icon-bg: rgba(255, 255, 255, 0.76);
  --icon-fg: #111111;
  --icon-cut: #f7f7f4;
  --icon-soft: #deded9;
  --desktop-pad-top: max(8px, calc(env(safe-area-inset-top) - 28px));
  --desktop-frame-top: calc(var(--desktop-pad-top) + 54px);
  --shadow: 0 18px 44px rgba(0, 0, 0, 0.1);
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html,
body {
  width: 100%;
  height: 100%;
}

body {
  margin: 0;
  overflow: hidden;
  font-family:
    Inter, "Pretendard", "Noto Sans KR", "Noto Sans SC", "Microsoft YaHei",
    sans-serif;
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.88), rgba(219, 219, 214, 0.7)),
    var(--paper);
  color: var(--ink);
  overscroll-behavior: none;
  touch-action: manipulation;
  -webkit-user-select: none;
  user-select: none;
}

body.is-installed {
  --desktop-pad-top: max(8px, env(safe-area-inset-top));
  --desktop-frame-top: calc(var(--desktop-pad-top) + 18px);
}

button {
  border: 0;
  padding: 0;
  font: inherit;
  color: inherit;
  background: transparent;
}

[hidden] {
  display: none !important;
}

.stage {
  position: fixed;
  inset: 0;
  display: block;
  min-height: 100dvh;
  overflow: hidden;
}

.loader {
  position: fixed;
  inset: 0;
  z-index: 5;
  display: grid;
  place-items: center;
  background: #f7f7f4;
  transition:
    opacity 700ms ease,
    visibility 700ms ease;
}

.bubble-field {
  position: absolute;
  inset: 0;
  overflow: hidden;
}

.bubble {
  position: absolute;
  display: block;
  width: 78px;
  aspect-ratio: 1;
  border: 1px solid rgba(18, 18, 18, 0.25);
  border-radius: 50%;
  background:
    radial-gradient(circle at 32% 28%, rgba(255, 255, 255, 0.88) 0 14%, transparent 15%),
    radial-gradient(circle at 66% 72%, rgba(0, 0, 0, 0.08), transparent 38%),
    rgba(255, 255, 255, 0.3);
  box-shadow: inset 0 0 18px rgba(255, 255, 255, 0.85);
  animation: float-bubble 2100ms ease-in-out infinite;
}

.bubble-a {
  left: 18%;
  bottom: 18%;
  width: 92px;
  animation-delay: -200ms;
}

.bubble-b {
  left: 64%;
  bottom: 24%;
  width: 54px;
  animation-delay: -760ms;
}

.bubble-c {
  left: 42%;
  bottom: 8%;
  width: 118px;
  animation-delay: -1080ms;
}

.bubble-d {
  left: 74%;
  bottom: 58%;
  width: 72px;
  animation-delay: -1420ms;
}

.bubble-e {
  left: 12%;
  bottom: 62%;
  width: 48px;
  animation-delay: -1660ms;
}

.auth-panel {
  position: relative;
  z-index: 1;
  display: grid;
  width: min(88vw, 360px);
  gap: 13px;
  padding: 18px;
  border: 1px solid rgba(17, 17, 17, 0.12);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.88);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.9),
    0 18px 50px rgba(0, 0, 0, 0.12);
  backdrop-filter: blur(16px);
}

.auth-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  padding: 4px;
  border: 1px solid rgba(17, 17, 17, 0.1);
  border-radius: 7px;
  background: rgba(246, 246, 243, 0.72);
}

.auth-tab,
.auth-submit {
  min-height: 40px;
  border-radius: 6px;
  font-weight: 800;
  cursor: pointer;
}

.auth-tab.is-active {
  background: #171717;
  color: #fff;
}

.auth-field {
  display: grid;
  gap: 7px;
}

.auth-field span {
  color: var(--soft-ink);
  font-size: 0.82rem;
  font-weight: 750;
}

.auth-panel[data-mode="login"] .auth-code-field {
  display: none;
}

.auth-field input {
  width: 100%;
  min-height: 42px;
  border: 1px solid rgba(17, 17, 17, 0.14);
  border-radius: 7px;
  padding: 0 12px;
  background: rgba(255, 255, 255, 0.94);
  color: var(--ink);
  font: inherit;
  outline: none;
}

.auth-field input:focus {
  border-color: #171717;
  box-shadow: 0 0 0 3px rgba(0, 0, 0, 0.08);
}

.auth-message {
  min-height: 20px;
  margin: 0;
  color: #b3261e;
  font-size: 0.86rem;
  line-height: 1.45;
}

.auth-message.success {
  color: #176b3a;
}

.auth-submit {
  background: #171717;
  color: #fff;
}

.auth-submit:disabled,
.auth-tab:disabled {
  cursor: wait;
  opacity: 0.62;
}

.desktop {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  min-height: 100dvh;
  padding:
    var(--desktop-pad-top)
    calc(env(safe-area-inset-right) + 18px)
    calc(env(safe-area-inset-bottom) + 18px)
    calc(env(safe-area-inset-left) + 18px);
  opacity: 0;
  transform: translateY(18px);
  transition:
    opacity 850ms ease 360ms,
    transform 850ms ease 360ms;
}

.desktop::before {
  position: absolute;
  inset:
    var(--desktop-frame-top)
    calc(env(safe-area-inset-right) + 18px)
    calc(env(safe-area-inset-bottom) + 126px)
    calc(env(safe-area-inset-left) + 18px);
  z-index: 0;
  border: 1px solid rgba(0, 0, 0, 0.08);
  border-radius: 30px;
  background:
    linear-gradient(rgba(255, 255, 255, 0.34) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.34) 1px, transparent 1px);
  background-size: 34px 34px;
  content: "";
}

.top-status {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: min(100%, 430px);
  min-height: 28px;
  margin: 0 auto;
  padding: 0 8px;
  color: #1d1d1d;
  font-size: 0.78rem;
  font-weight: 800;
  line-height: 1;
}

body.is-installed .top-status {
  display: none;
}

body.is-installed .app-grid {
  margin-top: 34px;
}

.status-right {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.status-battery {
  align-items: center;
  gap: 4px;
}

.status-battery:not([hidden]) {
  display: inline-flex;
}

.battery-shell {
  position: relative;
  display: inline-flex;
  width: 22px;
  height: 10px;
  padding: 1px;
  border: 1.5px solid currentColor;
  border-radius: 3px;
}

.battery-shell::after {
  position: absolute;
  top: 2px;
  right: -3.5px;
  width: 2px;
  height: 4px;
  border-radius: 0 2px 2px 0;
  background: currentColor;
  content: "";
}

.battery-fill {
  display: block;
  width: 0%;
  height: 100%;
  border-radius: 1px;
  background: currentColor;
}

.app-grid {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: repeat(4, minmax(58px, 1fr));
  gap: 18px 8px;
  width: min(100%, 430px);
  margin: 40px auto 0;
}

.app-icon,
.dock-icon {
  display: grid;
  justify-items: center;
  gap: 8px;
  min-width: 0;
  cursor: default;
}

.icon-mark,
.dock-mark {
  display: grid;
  width: clamp(54px, 15vw, 66px);
  aspect-ratio: 1;
  place-items: center;
  border: 1px solid rgba(17, 17, 17, 0.1);
  border-radius: 20px;
  background:
    linear-gradient(145deg, rgba(255, 255, 255, 0.92), rgba(232, 232, 226, 0.7)),
    var(--icon-bg);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.88),
    inset 0 -12px 18px rgba(17, 17, 17, 0.025),
    0 12px 24px rgba(0, 0, 0, 0.075);
  color: var(--icon-fg);
}

.icon-svg {
  width: 66%;
  height: 66%;
  overflow: visible;
  fill: none;
  stroke: none;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.glyph-main {
  fill: var(--icon-fg);
}

.glyph-soft {
  fill: var(--icon-soft);
}

.glyph-cut {
  fill: var(--icon-cut);
}

.stroke-wide {
  fill: none;
  stroke: var(--icon-cut);
  stroke-width: 3.1;
  stroke-linecap: round;
}

.stroke-cut {
  fill: none;
  stroke: var(--icon-cut);
  stroke-width: 1.7;
  stroke-linecap: round;
}

.app-name,
.dock-name {
  max-width: 88px;
  overflow: hidden;
  color: var(--soft-ink);
  font-size: 0.76rem;
  font-weight: 650;
  line-height: 1.2;
  text-align: center;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.dock {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  width: min(100%, 430px);
  margin: auto auto 0;
  padding: 13px 12px 12px;
  border: 1px solid rgba(255, 255, 255, 0.64);
  border-radius: 28px;
  background: var(--glass);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.8),
    var(--shadow);
  backdrop-filter: blur(16px);
}

.dock-mark {
  width: clamp(50px, 14vw, 60px);
  border-radius: 18px;
}

body.is-loaded .loader {
  visibility: hidden;
  opacity: 0;
}

body.is-loaded .desktop {
  opacity: 1;
  transform: translateY(0);
}

@keyframes float-bubble {
  0% {
    opacity: 0;
    transform: translate3d(0, 30px, 0) scale(0.78);
  }

  28% {
    opacity: 1;
  }

  100% {
    opacity: 0;
    transform: translate3d(18px, -220px, 0) scale(1.18);
  }
}

@media (min-width: 760px) {
  .desktop {
    padding-inline: calc(50vw - 215px);
  }
}

@media (max-height: 600px) {
  :root {
    --desktop-pad-top: max(6px, calc(env(safe-area-inset-top) - 34px));
    --desktop-frame-top: calc(var(--desktop-pad-top) + 48px);
  }

  .app-grid {
    margin-top: 24px;
  }

  .dock {
    padding-block: 10px;
  }
}
