:root {
  color-scheme: light;
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", sans-serif;
  font-synthesis: none;
  text-rendering: optimizeLegibility;
  --blue: #2477f3;
  --text: #111318;
  --secondary: #737780;
  --line: #eceef2;
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
  min-height: 100%;
  background: #ffffff;
  -webkit-text-size-adjust: 100%;
}

body {
  min-height: 100vh;
  min-height: 100dvh;
  margin: 0;
  color: var(--text);
  background: #ffffff;
}

button,
input {
  font: inherit;
}

.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;
}

.app-list {
  width: 100%;
  max-width: 680px;
  min-height: 100vh;
  min-height: 100dvh;
  margin: 0 auto;
  padding: env(safe-area-inset-top, 0px) max(16px, env(safe-area-inset-right, 0px)) env(safe-area-inset-bottom, 0px) max(16px, env(safe-area-inset-left, 0px));
}

.page-toolbar {
  position: sticky;
  top: env(safe-area-inset-top, 0px);
  z-index: 10;
  display: flex;
  min-height: 54px;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  background: rgba(255, 255, 255, 0.92);
  border-bottom: 1px solid var(--line);
  -webkit-backdrop-filter: blur(18px) saturate(160%);
  backdrop-filter: blur(18px) saturate(160%);
}

.page-toolbar h1 {
  margin: 0;
  overflow: hidden;
  font-size: 17px;
  font-weight: 700;
  letter-spacing: -0.02em;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.toolbar-actions {
  display: inline-flex;
  flex: 0 0 auto;
  align-items: center;
  gap: 8px;
}

.refresh-button {
  display: inline-grid;
  width: 36px;
  height: 36px;
  padding: 0;
  place-items: center;
  color: var(--blue);
  background: #edf4ff;
  border: 0;
  border-radius: 50%;
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

.refresh-button svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.refresh-button:active {
  opacity: 0.72;
  transform: scale(0.94);
}

.refresh-button:disabled {
  cursor: wait;
}

.refresh-button.is-refreshing svg {
  animation: refresh-spin 0.65s linear infinite;
}

@keyframes refresh-spin {
  to {
    transform: rotate(360deg);
  }
}

.add-home-button {
  display: inline-flex;
  min-height: 36px;
  flex: 0 0 auto;
  align-items: center;
  gap: 7px;
  padding: 0 13px;
  color: var(--blue);
  font-size: 13px;
  font-weight: 650;
  background: #edf4ff;
  border: 0;
  border-radius: 18px;
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

.add-home-button:active {
  opacity: 0.72;
  transform: scale(0.97);
}

.add-home-button.is-installed {
  color: #5e6470;
  background: #f1f2f4;
}

.add-home-glyph {
  position: relative;
  width: 15px;
  height: 15px;
  border: 1.5px solid currentColor;
  border-radius: 4px;
}

.add-home-glyph::before,
.add-home-glyph::after {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 7px;
  height: 1.5px;
  content: "";
  background: currentColor;
  border-radius: 2px;
  transform: translate(-50%, -50%);
}

.add-home-glyph::after {
  transform: translate(-50%, -50%) rotate(90deg);
}

.app-row {
  display: grid;
  grid-template-columns: 56px minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  min-height: 84px;
  padding: 14px 0;
  border-bottom: 1px solid var(--line);
}

.app-row:first-of-type {
  padding-top: 12px;
}

.app-icon {
  position: relative;
  display: grid;
  width: 56px;
  height: 56px;
  overflow: hidden;
  place-items: center;
  color: #ffffff;
  font-size: 24px;
  font-weight: 700;
  background: linear-gradient(145deg, #3488ff, #1d63e5);
  border-radius: 13px;
  box-shadow: inset 0 0 0 0.5px rgba(0, 0, 0, 0.08);
}

.app-icon img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.app-details {
  min-width: 0;
}

.app-details h2 {
  margin: 0 0 4px;
  overflow: hidden;
  color: var(--text);
  font-size: 17px;
  font-weight: 650;
  line-height: 1.2;
  letter-spacing: -0.01em;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.app-details p,
.app-details time {
  display: block;
  margin: 0;
  overflow: hidden;
  color: var(--secondary);
  font-size: 12px;
  font-weight: 400;
  line-height: 1.45;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.install-button {
  display: inline-grid;
  min-width: 62px;
  min-height: 36px;
  padding: 0 15px;
  place-items: center;
  color: #ffffff;
  font-size: 14px;
  font-weight: 650;
  line-height: 1;
  text-decoration: none;
  background: var(--blue);
  border-radius: 18px;
  touch-action: manipulation;
  transition: transform 160ms cubic-bezier(0.23, 1, 0.32, 1);
  -webkit-tap-highlight-color: transparent;
}

.install-button:active {
  opacity: 0.72;
  transform: scale(0.97);
}

.install-button.is-installing {
  cursor: wait;
  pointer-events: none;
}

.install-button.is-installing .install-button-label {
  display: none;
}

.install-spinner {
  display: none;
  width: 17px;
  height: 17px;
  border: 2px solid rgba(255, 255, 255, 0.42);
  border-top-color: #ffffff;
  border-radius: 50%;
}

.install-button.is-installing .install-spinner {
  display: block;
  animation: install-spin 0.7s linear infinite;
}

@keyframes install-spin {
  to {
    transform: rotate(360deg);
  }
}

@keyframes install-pulse {
  50% {
    opacity: 0.5;
  }
}

@media (prefers-reduced-motion: reduce) {
  .install-button {
    transition: none;
  }

  .install-button.is-installing .install-spinner {
    animation: install-pulse 1s linear infinite;
  }
}

.install-button:focus-visible,
.refresh-button:focus-visible,
.add-home-button:focus-visible,
.dialog-close:focus-visible,
.dialog-done:focus-visible,
.login-card button:focus-visible,
.login-card input:focus-visible {
  outline: 3px solid rgba(36, 119, 243, 0.25);
  outline-offset: 2px;
}

.refresh-toast {
  position: fixed;
  right: 50%;
  bottom: calc(24px + env(safe-area-inset-bottom, 0px));
  z-index: 100;
  display: inline-flex;
  min-height: 44px;
  align-items: center;
  gap: 8px;
  padding: 0 16px;
  color: #ffffff;
  font-size: 14px;
  font-weight: 600;
  background: rgba(25, 27, 32, 0.92);
  border-radius: 22px;
  box-shadow: 0 8px 28px rgba(17, 19, 24, 0.2);
  opacity: 0;
  pointer-events: none;
  transform: translate(50%, 12px);
  transition: opacity 0.2s ease, transform 0.2s ease;
  -webkit-backdrop-filter: blur(12px);
  backdrop-filter: blur(12px);
}

.refresh-toast[hidden] {
  display: none;
}

.refresh-toast.is-visible {
  opacity: 1;
  transform: translate(50%, 0);
}

.refresh-toast-check {
  display: inline-grid;
  width: 20px;
  height: 20px;
  place-items: center;
  color: #ffffff;
  font-size: 13px;
  line-height: 1;
  background: #30a46c;
  border-radius: 50%;
}

.add-home-dialog {
  width: min(calc(100% - 32px), 360px);
  max-width: none;
  margin: auto;
  padding: 26px 22px 20px;
  color: var(--text);
  background: #ffffff;
  border: 0;
  border-radius: 22px;
  box-shadow: 0 24px 70px rgba(17, 19, 24, 0.2);
}

.add-home-dialog::backdrop {
  background: rgba(17, 19, 24, 0.38);
  -webkit-backdrop-filter: blur(2px);
  backdrop-filter: blur(2px);
}

.dialog-close {
  position: absolute;
  top: 12px;
  right: 12px;
  display: grid;
  width: 32px;
  height: 32px;
  padding: 0;
  place-items: center;
  color: #6e737c;
  font-size: 23px;
  font-weight: 300;
  line-height: 1;
  background: #f3f4f6;
  border: 0;
  border-radius: 50%;
  cursor: pointer;
}

.dialog-mark {
  position: relative;
  display: grid;
  width: 48px;
  height: 48px;
  margin-bottom: 16px;
  place-items: center;
  background: #edf4ff;
  border-radius: 14px;
}

.dialog-mark span {
  position: relative;
  width: 22px;
  height: 22px;
  border: 2px solid var(--blue);
  border-radius: 6px;
}

.dialog-mark span::before,
.dialog-mark span::after {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 10px;
  height: 2px;
  content: "";
  background: var(--blue);
  border-radius: 2px;
  transform: translate(-50%, -50%);
}

.dialog-mark span::after {
  transform: translate(-50%, -50%) rotate(90deg);
}

.add-home-dialog h2 {
  margin: 0;
  font-size: 21px;
  letter-spacing: -0.02em;
}

.home-help > p {
  margin: 8px 0 18px;
  color: var(--secondary);
  font-size: 14px;
  line-height: 1.55;
}

.home-help[hidden] {
  display: none;
}

.home-help ol {
  display: grid;
  gap: 10px;
  margin: 0;
  padding: 0;
  list-style: none;
  counter-reset: home-step;
}

.home-help li {
  position: relative;
  min-height: 30px;
  padding: 5px 0 5px 40px;
  color: #32353b;
  font-size: 14px;
  line-height: 1.45;
  counter-increment: home-step;
}

.home-help li::before {
  position: absolute;
  top: 0;
  left: 0;
  display: grid;
  width: 30px;
  height: 30px;
  place-items: center;
  color: var(--blue);
  font-size: 13px;
  font-weight: 700;
  content: counter(home-step);
  background: #edf4ff;
  border-radius: 50%;
}

.share-glyph {
  display: inline-grid;
  width: 20px;
  height: 20px;
  margin-left: 2px;
  place-items: center;
  color: var(--blue);
  font-size: 18px;
  font-weight: 700;
  vertical-align: -2px;
}

.dialog-done {
  width: 100%;
  min-height: 44px;
  margin-top: 22px;
  color: #ffffff;
  font-size: 15px;
  font-weight: 650;
  background: var(--blue);
  border: 0;
  border-radius: 12px;
  cursor: pointer;
}

.empty-state {
  display: grid;
  min-height: 70vh;
  padding: 24px;
  place-content: center;
  text-align: center;
}

.empty-icon,
.login-mark {
  display: grid;
  width: 56px;
  height: 56px;
  margin: 0 auto 16px;
  place-items: center;
  color: #ffffff;
  font-size: 24px;
  font-weight: 700;
  background: var(--blue);
  border-radius: 14px;
}

.empty-state h2 {
  margin: 0;
  font-size: 18px;
}

.empty-state p {
  margin: 7px 0 0;
  color: var(--secondary);
  font-size: 14px;
}

.login-shell {
  display: grid;
  width: 100%;
  min-height: 100vh;
  min-height: 100dvh;
  padding: max(24px, env(safe-area-inset-top, 0px)) max(20px, env(safe-area-inset-right, 0px)) max(24px, env(safe-area-inset-bottom, 0px)) max(20px, env(safe-area-inset-left, 0px));
  place-items: center;
}

.login-card {
  width: min(100%, 360px);
}

.login-card h1 {
  margin: 0;
  text-align: center;
  font-size: 24px;
  letter-spacing: -0.02em;
}

.login-intro {
  margin: 8px 0 28px;
  color: var(--secondary);
  font-size: 14px;
  text-align: center;
}

.login-error {
  margin: 0 0 16px;
  padding: 10px 12px;
  color: #b42318;
  font-size: 13px;
  background: #fef3f2;
  border-radius: 10px;
}

.login-card label {
  display: grid;
  gap: 7px;
  margin-top: 15px;
  color: #424650;
  font-size: 13px;
  font-weight: 600;
}

.login-card input {
  width: 100%;
  height: 48px;
  padding: 0 14px;
  color: var(--text);
  background: #f6f7f9;
  border: 1px solid transparent;
  border-radius: 12px;
  outline: none;
}

.login-card input:focus {
  background: #ffffff;
  border-color: var(--blue);
}

.login-card button {
  width: 100%;
  height: 48px;
  margin-top: 22px;
  color: #ffffff;
  font-weight: 650;
  background: var(--blue);
  border: 0;
  border-radius: 12px;
  cursor: pointer;
}

@media (max-width: 370px) {
  .page-toolbar {
    gap: 10px;
  }

  .add-home-button {
    padding: 0 11px;
  }

  .app-row {
    grid-template-columns: 52px minmax(0, 1fr) auto;
    gap: 10px;
  }

  .app-icon {
    width: 52px;
    height: 52px;
    border-radius: 12px;
  }

  .install-button {
    min-width: 58px;
    padding: 0 13px;
  }
}
