:root {
  color-scheme: dark;
  --background: #111214;
  --surface: rgba(38, 39, 42, 0.72);
  --surface-strong: rgba(49, 50, 54, 0.82);
  --label: #f5f5f7;
  --secondary: rgba(235, 235, 245, 0.64);
  --tertiary: rgba(235, 235, 245, 0.38);
  --separator: rgba(255, 255, 255, 0.11);
  --glass-edge: rgba(255, 255, 255, 0.17);
  --blue: #0a84ff;
  --cyan: #64d2ff;
  --green: #30d158;
  --yellow: #ffd60a;
  --red: #ff453a;
  --safe-top: max(18px, env(safe-area-inset-top));
  --safe-bottom: max(18px, env(safe-area-inset-bottom));
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "SF Pro Display",
    "PingFang SC", "Noto Sans SC", "Segoe UI Variable", "Segoe UI",
    "Microsoft YaHei UI", sans-serif;
  font-synthesis: none;
  letter-spacing: 0;
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
  min-height: 100%;
  background: var(--background);
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  min-width: 320px;
  min-height: 100vh;
  min-height: 100dvh;
  margin: 0;
  overflow-x: hidden;
  background:
    linear-gradient(180deg, #17181b 0, var(--background) 38%, #0d0e10 100%);
  color: var(--label);
  font-family: inherit;
  letter-spacing: 0;
  -webkit-font-smoothing: antialiased;
}

button,
input {
  font: inherit;
  letter-spacing: 0;
}

button {
  border: 0;
  color: inherit;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

button:focus-visible,
input:focus-visible {
  outline: 3px solid rgba(100, 210, 255, 0.48);
  outline-offset: 2px;
}

button:disabled,
input:disabled {
  cursor: default;
  opacity: 0.48;
}

[hidden] {
  display: none !important;
}

.control-shell {
  width: min(100%, 520px);
  min-height: 100vh;
  min-height: 100dvh;
  margin: 0 auto;
  padding: var(--safe-top) 18px var(--safe-bottom);
}

.control-header {
  display: flex;
  min-height: 54px;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 0 3px;
}

.control-logo {
  display: block;
  width: auto;
  max-width: 112px;
  height: 32px;
  object-fit: contain;
  object-position: left center;
}

.security-mark {
  display: inline-flex;
  min-height: 30px;
  align-items: center;
  padding: 0 11px;
  border: 0.75px solid var(--glass-edge);
  border-radius: 15px;
  background: rgba(45, 46, 50, 0.62);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.16),
    0 6px 18px rgba(0, 0, 0, 0.2);
  color: var(--secondary);
  font-size: 12px;
  font-weight: 650;
  line-height: 16px;
  backdrop-filter: blur(24px) saturate(170%);
  -webkit-backdrop-filter: blur(24px) saturate(170%);
}

.control-surface {
  position: relative;
  min-height: 455px;
  margin-top: 34px;
  padding: 22px;
  overflow: hidden;
  border: 0.75px solid var(--glass-edge);
  border-radius: 26px;
  background: var(--surface);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.16),
    inset 0 -1px 0 rgba(0, 0, 0, 0.3),
    0 24px 64px rgba(0, 0, 0, 0.34);
  backdrop-filter: blur(34px) saturate(180%);
  -webkit-backdrop-filter: blur(34px) saturate(180%);
}

.control-surface::before {
  position: absolute;
  inset: 0 0 auto;
  height: 92px;
  background: linear-gradient(
    180deg,
    rgba(255, 255, 255, 0.065),
    rgba(255, 255, 255, 0)
  );
  content: "";
  pointer-events: none;
}

.control-shell[data-view="unlockedView"] .control-surface {
  min-height: 0;
}

.surface-heading {
  position: relative;
  z-index: 1;
  display: flex;
  min-height: 54px;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
}

.eyebrow {
  margin: 0 0 3px;
  color: var(--secondary);
  font-size: 13px;
  font-weight: 600;
  line-height: 18px;
}

h1 {
  margin: 0;
  font-size: 27px;
  font-weight: 720;
  line-height: 34px;
}

.state-pill {
  display: inline-flex;
  min-height: 28px;
  flex: 0 0 auto;
  align-items: center;
  padding: 0 10px;
  border-radius: 14px;
  background: rgba(142, 142, 147, 0.15);
  color: var(--secondary);
  font-size: 12px;
  font-weight: 650;
  line-height: 16px;
}

.state-pill[data-state="open"] {
  background: rgba(48, 209, 88, 0.14);
  color: #62e57e;
}

.state-pill[data-state="locked"] {
  background: rgba(10, 132, 255, 0.14);
  color: #6cb5ff;
}

.state-pill[data-state="draining"] {
  background: rgba(255, 214, 10, 0.13);
  color: #ffe45c;
}

.state-pill[data-state="closed"],
.state-pill[data-state="unavailable"] {
  background: rgba(255, 69, 58, 0.13);
  color: #ff7770;
}

.loading-view,
.message-view,
.enrollment-view,
.setup-confirm-view,
.locked-view,
.unlocked-view {
  position: relative;
  z-index: 1;
  min-height: 320px;
}

.loading-view,
.message-view,
.locked-view {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
}

.loading-view p,
.message-view p,
.status-copy p {
  margin: 7px 0 0;
  color: var(--secondary);
  font-size: 14px;
  line-height: 21px;
}

.message-view strong,
.status-copy strong {
  font-size: 17px;
  font-weight: 680;
  line-height: 23px;
}

.message-view p {
  max-width: 310px;
}

.activity-indicator {
  width: 24px;
  height: 24px;
  border: 2px solid rgba(235, 235, 245, 0.18);
  border-top-color: var(--label);
  border-radius: 50%;
  animation: spin 760ms linear infinite;
}

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

.enrollment-view {
  padding-top: 34px;
}

.setup-confirm-view {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding-top: 22px;
  text-align: center;
}

.status-copy {
  max-width: 360px;
}

.setup-field,
.code-field {
  display: grid;
  width: 100%;
  gap: 8px;
  margin: 28px 0 18px;
  text-align: left;
}

.setup-field span,
.code-field span,
.duration-control legend {
  color: var(--secondary);
  font-size: 13px;
  font-weight: 600;
  line-height: 18px;
}

.setup-field input,
.code-field input {
  width: 100%;
  height: 48px;
  padding: 0 14px;
  border: 0.75px solid var(--separator);
  border-radius: 12px;
  background: rgba(15, 16, 18, 0.54);
  color: var(--label);
  caret-color: var(--cyan);
}

.code-field {
  margin-top: 20px;
}

.code-field input {
  font-size: 23px;
  font-variant-numeric: tabular-nums;
  font-weight: 650;
  text-align: center;
}

.qr-frame {
  display: grid;
  width: 232px;
  height: 232px;
  flex: 0 0 auto;
  place-items: center;
  padding: 8px;
  border-radius: 8px;
  background: #ffffff;
  box-shadow:
    0 0 0 0.75px rgba(255, 255, 255, 0.28),
    0 14px 34px rgba(0, 0, 0, 0.28);
}

.qr-frame canvas {
  display: block;
  width: 216px;
  height: 216px;
}

.setup-confirm-copy {
  margin-top: 19px;
}

.lock-symbol {
  position: relative;
  width: 62px;
  height: 62px;
  margin-bottom: 24px;
  border: 0.75px solid var(--glass-edge);
  border-radius: 19px;
  background: var(--surface-strong);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.17),
    0 12px 28px rgba(0, 0, 0, 0.22);
}

.lock-symbol::before {
  position: absolute;
  top: 13px;
  left: 20px;
  width: 20px;
  height: 20px;
  border: 3px solid rgba(245, 245, 247, 0.88);
  border-bottom: 0;
  border-radius: 12px 12px 0 0;
  content: "";
}

.lock-symbol span {
  position: absolute;
  right: 16px;
  bottom: 12px;
  left: 16px;
  height: 25px;
  border-radius: 7px;
  background: rgba(245, 245, 247, 0.9);
}

.locked-view .status-copy {
  margin-bottom: 0;
}

.locked-code-field {
  margin: 23px 0 18px;
}

.primary-button,
.secondary-button {
  display: inline-flex;
  width: 100%;
  min-height: 48px;
  align-items: center;
  justify-content: center;
  padding: 0 18px;
  border-radius: 16px;
  font-size: 15px;
  font-weight: 680;
  line-height: 20px;
  transition:
    transform 130ms ease,
    filter 160ms ease,
    opacity 160ms ease;
}

.primary-button {
  background: linear-gradient(180deg, #198fff 0, #0877e7 100%);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.28),
    0 9px 24px rgba(0, 101, 214, 0.28);
  color: #ffffff;
}

.secondary-button {
  border: 0.75px solid var(--separator);
  background: rgba(255, 255, 255, 0.065);
}

.primary-button:active,
.secondary-button:active {
  transform: scale(0.985);
  filter: brightness(0.92);
}

.unlocked-view {
  padding-top: 24px;
}

.window-status {
  display: grid;
  min-height: 68px;
  grid-template-columns: 12px minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  border-bottom: 0.75px solid var(--separator);
}

.window-indicator {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--red);
  box-shadow: 0 0 0 4px rgba(255, 69, 58, 0.1);
}

.window-indicator[data-state="open"] {
  background: var(--green);
  box-shadow: 0 0 0 4px rgba(48, 209, 88, 0.1);
}

.window-indicator[data-state="draining"] {
  background: var(--yellow);
  box-shadow: 0 0 0 4px rgba(255, 214, 10, 0.1);
}

.window-status div {
  display: grid;
  gap: 2px;
}

.window-status small {
  color: var(--secondary);
  font-size: 12px;
  line-height: 16px;
}

.window-status strong {
  font-size: 16px;
  font-weight: 680;
  line-height: 21px;
}

.window-status time {
  color: var(--secondary);
  font-size: 15px;
  font-variant-numeric: tabular-nums;
  font-weight: 650;
  line-height: 20px;
}

.duration-control {
  min-width: 0;
  margin: 25px 0 0;
  padding: 0;
  border: 0;
}

.duration-control legend {
  margin-bottom: 10px;
}

.segmented-control {
  display: grid;
  width: 100%;
  min-height: 40px;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 2px;
  padding: 3px;
  border: 0.75px solid rgba(255, 255, 255, 0.09);
  border-radius: 12px;
  background: rgba(10, 11, 13, 0.48);
}

.segmented-control label {
  min-width: 0;
}

.segmented-control input {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  opacity: 0;
}

.segmented-control span {
  display: grid;
  min-width: 0;
  height: 32px;
  place-items: center;
  border-radius: 9px;
  color: var(--secondary);
  font-size: 12px;
  font-weight: 620;
  line-height: 16px;
  white-space: nowrap;
}

.segmented-control input:checked + span {
  background: rgba(96, 97, 102, 0.62);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.16),
    0 2px 7px rgba(0, 0, 0, 0.24);
  color: var(--label);
}

.segmented-control input:focus-visible + span {
  outline: 2px solid rgba(100, 210, 255, 0.56);
}

.action-row {
  display: grid;
  grid-template-columns: minmax(0, 1.5fr) minmax(110px, 0.8fr);
  gap: 10px;
  margin-top: 22px;
}

.danger-button {
  color: #ff7770;
}

.error-message {
  position: relative;
  z-index: 1;
  margin: 15px 0 0;
  padding-top: 13px;
  border-top: 0.75px solid rgba(255, 69, 58, 0.25);
  color: #ff7770;
  font-size: 13px;
  line-height: 19px;
  text-align: center;
}

@media (max-width: 380px) {
  .control-shell {
    padding-right: 14px;
    padding-left: 14px;
  }

  .control-surface {
    min-height: 438px;
    margin-top: 24px;
    padding: 19px;
    border-radius: 23px;
  }

  h1 {
    font-size: 25px;
    line-height: 32px;
  }

  .segmented-control span {
    font-size: 11px;
  }

  .action-row {
    grid-template-columns: 1fr;
  }

  .qr-frame {
    width: 212px;
    height: 212px;
  }

  .qr-frame canvas {
    width: 196px;
    height: 196px;
  }
}

@media (min-width: 700px) {
  .control-shell {
    display: grid;
    min-height: 100dvh;
    grid-template-rows: auto 1fr;
    align-items: center;
    padding-right: 0;
    padding-left: 0;
  }

  .control-header {
    align-self: start;
  }

  .control-surface {
    width: 100%;
    margin-top: 12px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 1ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 1ms !important;
  }
}

@supports not ((backdrop-filter: blur(1px))) {
  .control-surface,
  .security-mark {
    background: rgba(38, 39, 42, 0.96);
  }
}
